@agentshouse/app-bridge 0.1.0-c1b72582712c7 → 0.1.0-c1bc683ed8f4e

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.
package/dist/calls.d.ts CHANGED
@@ -53,7 +53,7 @@ export interface HouseCalls {
53
53
  readonly name: string;
54
54
  readonly width?: number;
55
55
  }[];
56
- readonly operation_id?: string;
56
+ readonly operation_id: string;
57
57
  readonly text?: string;
58
58
  };
59
59
  readonly 'conversation.setOption': {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import type { MdRuntimeClient } from './mdruntime/client.js';
1
+ import type { MdRuntimeClient, Open } from './mdruntime/client.js';
2
2
  import type { HouseCalls } from './calls.js';
3
3
  export type { HouseCalls } from './calls.js';
4
- type Open<Value extends string> = Value | (string & {});
5
4
  export type HouseCallInput<Name extends string> = Name extends keyof HouseCalls ? HouseCalls[Name] : unknown;
6
5
  export interface HouseRuntime extends Omit<MdRuntimeClient, 'call'> {
7
6
  call<Name extends Open<keyof HouseCalls>>(name: Name, input: HouseCallInput<Name>): ReturnType<MdRuntimeClient['call']>;
@@ -110,6 +109,20 @@ export interface HouseBrowserRefused extends Error {
110
109
  readonly code: string;
111
110
  readonly retryable: boolean;
112
111
  }
112
+ export interface HouseTrialWithheld {
113
+ readonly code: Open<'house_trial_withheld'>;
114
+ readonly retryable: true;
115
+ }
116
+ export type HouseTask = unknown;
117
+ export type HouseActivation = Open<'committed' | 'abandoned'>;
118
+ export interface HouseCooperation {
119
+ checkpoint(): Promise<void> | void;
120
+ persist(): Promise<void> | void;
121
+ capture(): Promise<HouseTask> | HouseTask;
122
+ restore(task: HouseTask | null): Promise<void> | void;
123
+ ready(): Promise<boolean> | boolean;
124
+ settle(activation: HouseActivation): void;
125
+ }
113
126
  export interface HouseBridge {
114
127
  readonly runtime: Promise<HouseRuntime>;
115
128
  address(): string | null;
@@ -130,6 +143,7 @@ export interface HouseBridge {
130
143
  onStatus(listener: (status: HouseStatus) => void): () => void;
131
144
  messages(listener: (message: HouseAppMessage) => void): () => void;
132
145
  analyticsConsent(choice: HouseAnalyticsChoice): void;
146
+ cooperate(cooperation: HouseCooperation): () => void;
133
147
  }
134
148
  export interface HouseHeld {
135
149
  readonly houseBridge: HouseBridge;
@@ -1,6 +1,7 @@
1
1
  import { type Definition } from './definition.js';
2
- import type { ApplyResult, BodyResult, Change, Document, Link, LinkOccurrence, ParseResult } from './types.js';
2
+ import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, LinkOccurrence, ParseResult } from './types.js';
3
3
  import { type YamlMap } from './yaml.js';
4
+ export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
4
5
  export declare function parse(content: string, file?: string): ParseResult;
5
6
  export declare function relativize(document: Document, file: string, handle: string, definition?: Definition): ApplyResult;
6
7
  export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
@@ -3,7 +3,7 @@ export type { Actor, Condition, ConditionScope, ConditionTest, ConditionValue, C
3
3
  export { headingLines } from './blocks.js';
4
4
  export type { HeadingLine } from './blocks.js';
5
5
  export { divide } from './divide.js';
6
- export { apply, bodyLinks, fieldStart, linkOccurrences, links, parse, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
6
+ export { apply, bodyLinks, fieldStart, linkOccurrences, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
7
7
  export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
8
8
  export { relative, retarget, target } from './paths.js';
9
9
  export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
@@ -11,8 +11,8 @@ export { project } from './project.js';
11
11
  export { references } from './references.js';
12
12
  export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
13
13
  export type { Definition, JsonType, PatternFacts, PointerFacts, SectionSpec, Shape, ValueFacts, } from './definition.js';
14
- export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, Library, ModelVerification, Link, LinkOccurrence, ParseResult, Projection, ProjectionContext, Reference, Refusal, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
15
- export { validate, verify } from './validate.js';
14
+ export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, LinkOccurrence, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
15
+ export { checkDocument, resolves, sectionReferences, validate, verify } from './validate.js';
16
16
  export { VERSION } from './version.js';
17
17
  export { equalValue, frontmatterValue } from './yaml.js';
18
18
  export type { FrontmatterValue } from './yaml.js';
@@ -1,3 +1,3 @@
1
1
  import { type Definition } from './definition.js';
2
- import type { Document, Reference } from './types.js';
3
- export declare function references(document: Document, definition: Definition): readonly Reference[];
2
+ import type { Frontmatter, Reference } from './types.js';
3
+ export declare function references(document: Pick<Frontmatter, 'fields'>, definition: Definition): readonly Reference[];
@@ -28,10 +28,12 @@ export type Extent = {
28
28
  export type Span = Extent & {
29
29
  readonly text: string;
30
30
  };
31
- export type Document = {
31
+ export type Frontmatter = {
32
32
  readonly content: string;
33
33
  readonly type: string | undefined;
34
34
  readonly fields: Readonly<Record<string, unknown>>;
35
+ };
36
+ export type Document = Frontmatter & {
35
37
  readonly preamble: string;
36
38
  readonly sections: Readonly<Record<string, string>>;
37
39
  };
@@ -41,6 +43,18 @@ export type Refusal = {
41
43
  readonly location?: string;
42
44
  readonly referrers?: readonly string[];
43
45
  };
46
+ export type Reached = {
47
+ readonly target: string | null;
48
+ readonly to: readonly string[];
49
+ };
50
+ export type DocumentCheck = {
51
+ readonly ok: false;
52
+ } | {
53
+ readonly ok: true;
54
+ readonly type: string;
55
+ readonly typed: boolean;
56
+ readonly references: readonly Reached[];
57
+ };
44
58
  export type Validation = {
45
59
  readonly verdict: 'accept';
46
60
  } | ({
@@ -60,6 +74,13 @@ export type Division = {
60
74
  readonly ok: false;
61
75
  readonly refusal: Refusal;
62
76
  };
77
+ export type FrontmatterResult = {
78
+ readonly ok: true;
79
+ readonly frontmatter: Frontmatter;
80
+ } | {
81
+ readonly ok: false;
82
+ readonly refusal: Refusal;
83
+ };
63
84
  export type ParseResult = {
64
85
  readonly ok: true;
65
86
  readonly document: Document;
@@ -1,3 +1,7 @@
1
- import type { Library, ModelVerification, Validation, ValidationContext, VerifiedModel } from './types.js';
1
+ import { type Definition } from './definition.js';
2
+ import type { DocumentCheck, Library, ModelVerification, Reached, Validation, ValidationContext, VerifiedModel } from './types.js';
3
+ export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
2
4
  export declare function verify(schema: string): ModelVerification;
5
+ export declare function checkDocument(file: string, content: string, model: VerifiedModel): DocumentCheck;
6
+ export declare function sectionReferences(file: string, content: string, definition: Definition): readonly Reached[];
3
7
  export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
@@ -0,0 +1,13 @@
1
+ export type RuntimeDemand = {
2
+ readonly whole: boolean;
3
+ readonly rooms: readonly string[];
4
+ readonly handles: readonly string[];
5
+ readonly conversations: boolean;
6
+ };
7
+ export declare const WHOLE_DEMAND: RuntimeDemand;
8
+ export declare function demanded(demand: RuntimeDemand, room: {
9
+ readonly locator: string;
10
+ readonly handle: string;
11
+ }): boolean;
12
+ export declare function wider(next: RuntimeDemand, current: RuntimeDemand): boolean;
13
+ export declare function narrower(next: RuntimeDemand, current: RuntimeDemand): boolean;
@@ -238,17 +238,15 @@ export type ContractUnavailable = ProviderRefusal & {
238
238
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
239
239
  export type PageToken = string;
240
240
  export type ChangeAuthor = {
241
- kind: 'user';
241
+ kind: Open<'user' | 'site'>;
242
242
  id: string;
243
243
  name: string;
244
- } | {
245
- kind: 'site';
244
+ };
245
+ export type Member = {
246
+ kind: Open<'user'>;
246
247
  id: string;
247
248
  name: string;
248
249
  };
249
- export type Member = Extract<ChangeAuthor, {
250
- kind: 'user';
251
- }>;
252
250
  export type HeadChange = {
253
251
  author: ChangeAuthor | null;
254
252
  time: string;
@@ -259,10 +257,15 @@ export type BinaryFile = {
259
257
  mediaType: string;
260
258
  sha256: string;
261
259
  };
260
+ export type HeldContent = {
261
+ documents: Readonly<Record<string, string>>;
262
+ revisions: Readonly<Record<string, string>>;
263
+ };
262
264
  export type BootstrapRequest = {
263
265
  locator: string;
264
266
  selection: string;
265
267
  pageToken?: PageToken;
268
+ held?: HeldContent;
266
269
  };
267
270
  export type RoomModels = {
268
271
  collection?: ModelResult;
@@ -278,7 +281,9 @@ export type BootstrapPage = {
278
281
  binaryFiles: Readonly<Record<string, BinaryFile>>;
279
282
  pageToken?: PageToken;
280
283
  };
281
- export type BootstrapResult = BootstrapPage | AdapterFailure;
284
+ export type BootstrapResult = BootstrapPage | {
285
+ kind: 'beyond-horizon';
286
+ } | AdapterFailure;
282
287
  export type RefreshRequest = {
283
288
  locator: string;
284
289
  selection: string;
@@ -335,6 +340,7 @@ export type MutationResult = {
335
340
  kind: 'write-halted';
336
341
  } | {
337
342
  kind: 'expired';
343
+ restored?: true;
338
344
  } | AdapterFailure;
339
345
  export type HistoryAuthor = {
340
346
  kind: 'user';
@@ -425,10 +431,28 @@ export type RoomStreamEvent = {
425
431
  locator: string;
426
432
  roomVersion: string;
427
433
  };
434
+ export type KeptReceipt = {
435
+ key: string;
436
+ head: unknown;
437
+ };
438
+ export type StreamReceipts = {
439
+ heads(): Promise<readonly KeptReceipt[]>;
440
+ parts(key: string, count: number): Promise<readonly unknown[]>;
441
+ keep(key: string, head: unknown, part?: {
442
+ index: number;
443
+ value: unknown;
444
+ }): Promise<void>;
445
+ drop(keys: readonly string[]): Promise<void>;
446
+ };
447
+ export type AcquiredDemand = {
448
+ rooms: readonly string[];
449
+ conversations: boolean;
450
+ };
428
451
  export type RoomStream = {
429
- hold(rooms: readonly HeldRoom[]): void;
452
+ hold(rooms: readonly HeldRoom[], demand: AcquiredDemand | null): void;
430
453
  reopen(): void;
431
- observe(notify: (event: RoomStreamEvent) => void): () => void;
454
+ published(locator: string, roomVersion: string): void;
455
+ observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
432
456
  };
433
457
  export type Adapter = {
434
458
  readonly localSaves?: true;
@@ -9,6 +9,7 @@ export type DocumentChange = {
9
9
  export type MessageChange = {
10
10
  conversation: string;
11
11
  identity: string;
12
+ text: string | null;
12
13
  };
13
14
  export type ChangeSet = {
14
15
  documents: readonly DocumentChange[];
@@ -28,5 +29,6 @@ export declare function changeSet(locator: string, before: Replica | null, after
28
29
  queue?: boolean;
29
30
  presentation?: string;
30
31
  }): ChangeSet;
32
+ export declare function entering(locator: string, replica: Replica, paths: readonly string[]): ChangeSet;
31
33
  export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
32
34
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
@@ -4,16 +4,17 @@ import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptio
4
4
  import { type Observation } from './observation.js';
5
5
  import type { BinaryReference } from './binary.js';
6
6
  import type { BinaryAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
7
- import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
7
+ import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
8
8
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
9
9
  import type { SearchRequest, SearchResult } from './search.js';
10
+ import type { Readiness } from './readiness.js';
10
11
  import type { SyncStatus } from './status.js';
11
12
  import { type RuntimePort } from './wire.js';
12
13
  export type MdRuntimeClient = {
13
14
  rooms(): Promise<readonly AppRoom[]>;
14
15
  query: {
15
- (query: DocumentQuery): Promise<DocumentResult>;
16
- (query: GroupQuery): Promise<GroupResult>;
16
+ (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
17
+ (query: GroupQuery): Promise<GroupResult | PendingResult>;
17
18
  };
18
19
  search(request: SearchRequest): Promise<SearchResult>;
19
20
  types(locator: string): Promise<RoomSchemas>;
@@ -52,16 +53,18 @@ export type MdRuntimeClient = {
52
53
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
53
54
  log(): Promise<string>;
54
55
  persistence(): Promise<boolean>;
56
+ retry(): Promise<void>;
55
57
  observe: {
56
58
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
57
59
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
60
+ (topic: 'readiness'): Promise<Observation<Readiness>>;
58
61
  (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
59
62
  (topic: 'storage-loss'): Promise<Observation<string | null>>;
60
63
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
61
64
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
62
65
  (topic: 'member'): Promise<Observation<Member | null>>;
63
- (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
64
- (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
66
+ (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
67
+ (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
65
68
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
66
69
  (topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
67
70
  (topic: 'presentation'): Promise<Observation<unknown>>;
@@ -75,4 +78,5 @@ export type MdRuntimeClient = {
75
78
  export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
76
79
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
77
80
  export type { Observation } from './observation.js';
78
- export type { RuntimePort } from './wire.js';
81
+ export type { Open } from './open.js';
82
+ export { unanswered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,7 +1,9 @@
1
- import { type Document, type Validation } from '../mdmodel/index.js';
2
- import type { ModelState } from './model.js';
1
+ import { type Document, type Frontmatter, type Validation } from '../mdmodel/index.js';
2
+ import { type ModelState } from './model.js';
3
3
  import type { MdModelIdentity } from './adapter.js';
4
+ import { type Paths } from './shared.js';
4
5
  import type { Refused } from './transfer.js';
6
+ import { type Later } from './turn.js';
5
7
  export declare const MD_MODEL: MdModelIdentity;
6
8
  export type Collection = {
7
9
  text: Readonly<Record<string, string>>;
@@ -17,8 +19,20 @@ export type Composition = {
17
19
  };
18
20
  export declare function governing(composition: Composition, path: string): ModelState;
19
21
  export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Collection;
20
- export declare function passingDocument(collection: Collection, path: string): Document | undefined;
22
+ export declare function passingFrontmatter(collection: Collection, path: string): Frontmatter | undefined;
21
23
  export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
22
24
  export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Refused | null;
23
25
  export declare function validRoot(root: unknown): root is string;
24
26
  export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
27
+ type Held = {
28
+ text: Paths<string>;
29
+ binaries: Paths<unknown>;
30
+ };
31
+ export declare function indexReferrers(held: Held, composition: Composition): Later<void>;
32
+ export declare function referencesIndexed(held: Held, composition: Composition): boolean;
33
+ export declare function referring(held: Held, composition: Composition, targets: Iterable<string>): ReadonlySet<string> | null;
34
+ export declare function available(composition: Composition): boolean;
35
+ export declare function changedCleanly(next: Held, previous: Held & {
36
+ composition: Composition;
37
+ }, composition: Composition): boolean;
38
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { type TypesResult } from './model.js';
2
2
  import { type Observation } from './observation.js';
3
- import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult } from './query.js';
3
+ import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult, type PendingResult } from './query.js';
4
4
  import { type SearchRequest, type SearchResult } from './search.js';
5
5
  import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
6
6
  import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
@@ -8,10 +8,13 @@ import { type WrittenBy } from './change.js';
8
8
  import type { Open } from './open.js';
9
9
  import { type BinaryReference } from './binary.js';
10
10
  import { type BinaryAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
11
+ import { type Recovery } from './recovery.js';
11
12
  import { type SaveRefusal } from './save.js';
12
13
  import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
13
14
  import { type SyncStatus } from './status.js';
14
15
  import { type RuntimeShell } from './durability.js';
16
+ import { type RuntimeDemand } from './acquisition.js';
17
+ import { type CapacityCause, type CodeAvailability, type Persistence, type Readiness } from './readiness.js';
15
18
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
16
19
  export type AppTypedSelection = {
17
20
  roots: readonly string[];
@@ -48,6 +51,7 @@ export type MdRuntimeOptions = {
48
51
  shell: RuntimeShell;
49
52
  authorization?: Authorization;
50
53
  signal?: AbortSignal;
54
+ recovery?: Recovery;
51
55
  };
52
56
  export type SaveResult = {
53
57
  outcome: 'saved';
@@ -81,8 +85,8 @@ export type MdRuntime = {
81
85
  loaded(): Promise<void>;
82
86
  rooms(): readonly AppRoom[];
83
87
  query: {
84
- (query: DocumentQuery): Promise<DocumentResult>;
85
- (query: GroupQuery): Promise<GroupResult>;
88
+ (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
89
+ (query: GroupQuery): Promise<GroupResult | PendingResult>;
86
90
  };
87
91
  search(request: SearchRequest): Promise<SearchResult>;
88
92
  types(locator: string): RoomSchemas;
@@ -97,15 +101,17 @@ export type MdRuntime = {
97
101
  reached(locator: string, roomVersion: string, path?: string): boolean;
98
102
  log(): string;
99
103
  persistence(): boolean;
104
+ retry(): Promise<void>;
100
105
  observe: {
101
106
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
107
+ (topic: 'readiness'): Promise<Observation<Readiness>>;
102
108
  (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
103
109
  (topic: 'storage-loss'): Promise<Observation<string | null>>;
104
110
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
105
111
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
106
112
  (topic: 'member'): Promise<Observation<Member | null>>;
107
- (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
108
- (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
113
+ (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
114
+ (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
109
115
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
110
116
  (topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
111
117
  (topic: 'presentation', app: string): Promise<Observation<unknown>>;
@@ -115,11 +121,18 @@ export type MdRuntime = {
115
121
  };
116
122
  reauthorize(): Promise<void>;
117
123
  };
118
- export type RuntimeTopic = 'rooms' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
124
+ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
125
+ export type ReadinessPort = {
126
+ readonly target: string;
127
+ readonly code: CodeAvailability;
128
+ readonly capacity: CapacityCause | null;
129
+ };
119
130
  export type ComposedRuntime = RuntimeView & {
120
131
  stop(): Promise<void>;
121
132
  lose(locators: readonly string[]): Promise<void>;
122
- within(reach: PortReach | null): NarrowedView;
133
+ acquire(demand: RuntimeDemand): void;
134
+ persisted(answer: Persistence): void;
135
+ within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
123
136
  };
124
137
  export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
125
138
  export {};
@@ -3,8 +3,7 @@ import { type ChangeSet } from './change-set.js';
3
3
  import { type ChatDraftFile } from './file.js';
4
4
  import type { Open } from './open.js';
5
5
  import { type CallResult, type Offline } from './outcome.js';
6
- import type { DocumentResult } from './query.js';
7
- import type { SearchedMessage } from './search.js';
6
+ import type { DocumentResult, PendingResult } from './query.js';
8
7
  import type { CycleProgress } from './status.js';
9
8
  import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
10
9
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
@@ -69,13 +68,15 @@ export type ChatDraftSurface = {
69
68
  };
70
69
  export type ConversationDependencies = {
71
70
  agents(): ConversationAgents | undefined;
72
- documents(locator: string): Promise<DocumentResult>;
71
+ documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
73
72
  call(name: ConversationAction, input: unknown): Promise<CallResult>;
74
73
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
75
74
  stream(): ConversationStream | undefined;
76
75
  publish(set: ChangeSet): void;
77
76
  online(): boolean;
78
77
  closed(): boolean;
78
+ unanswered(): void;
79
+ expired(operation: string): boolean;
79
80
  };
80
81
  export type ConversationStore = {
81
82
  surface: ConversationSurface;
@@ -85,15 +86,18 @@ export type ConversationStore = {
85
86
  catchUp(progress: CycleProgress): Promise<void>;
86
87
  resend(progress: CycleProgress): Promise<void>;
87
88
  current(): boolean;
89
+ known(): boolean;
88
90
  reconnected(): void;
91
+ reopened(): void;
89
92
  watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
90
93
  watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
91
94
  watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
92
95
  changed(set: ChangeSet): void;
93
96
  receive(event: ConversationEvent): boolean;
94
- messages(): readonly SearchedMessage[];
95
- message(conversation: string, identity: string): SearchedMessage | null;
97
+ searchable(): readonly string[];
98
+ acquired(conversation: string): boolean;
96
99
  close(): void;
97
100
  };
98
101
  export declare function unheldView(conversation: string): ConversationView;
102
+ export declare const SESSION_STARTED = "Session started";
99
103
  export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
@@ -1,8 +1,14 @@
1
+ import type { Persistence } from './readiness.js';
2
+ export type StorageEstimate = {
3
+ readonly usage: number;
4
+ readonly quota: number;
5
+ };
1
6
  export type RuntimeShell = {
2
- persistentStorage: boolean;
7
+ persistence: Persistence;
3
8
  generation: string | null;
4
9
  keepGeneration(value: string): void | Promise<void>;
5
10
  dropGeneration(): void | Promise<void>;
11
+ estimate?(): Promise<StorageEstimate | null>;
6
12
  };
7
13
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
8
14
  export declare function nextGeneration(stored: string | null, reported: string | null): string;
@@ -29,12 +29,13 @@ export type ModelState = {
29
29
  types: VerifiedModel['types'];
30
30
  };
31
31
  export type TypesResult = {
32
- status: 'unavailable';
32
+ status: Open<'unavailable'>;
33
33
  reason: ModelUnavailableReason;
34
+ types: null;
34
35
  schema?: string | null;
35
36
  revision?: string | null;
36
37
  } | {
37
- status: 'current' | 'cached';
38
+ status: Open<'current' | 'cached'>;
38
39
  identity: string;
39
40
  version: string;
40
41
  verifiedWith: ModelIdentity;
@@ -52,4 +53,5 @@ export declare function definitionOf(state: ModelState, type: string | undefined
52
53
  export declare function modelTypes(state: ModelState): TypesResult;
53
54
  export declare function cached(state: ModelState): ModelState;
54
55
  export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
56
+ export declare function sameTyping(left: ModelState, right: ModelState): boolean;
55
57
  export declare function referenceField(facts: ValueFacts | undefined): boolean;
@@ -1,4 +1,4 @@
1
- import type { QueryDocument, QueryGroup, QueryResult } from './query.js';
1
+ import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
2
2
  export type Observation<T> = {
3
3
  current(): T;
4
4
  subscribe(listener: (value: T) => void): () => void;
@@ -13,14 +13,17 @@ export type QueryChange = {
13
13
  changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
14
14
  removed: readonly RowKey[];
15
15
  order: readonly RowKey[] | null;
16
+ coverage?: QueryCoverage;
16
17
  };
18
+ export type QueryMessage = KeyedResult | QueryChange;
17
19
  export type Observed = {
18
20
  observation: Observation<unknown>;
19
21
  receive(message: unknown): void;
20
22
  end(): void;
21
23
  };
22
24
  export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
23
- export declare function applied(keyed: KeyedResult, change: QueryChange): KeyedResult;
25
+ export declare function whole(message: QueryMessage): message is KeyedResult;
26
+ export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
24
27
  export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
25
28
  export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
26
29
  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>>;
@@ -22,4 +22,5 @@ export declare function sameBinary(left: HeldBinary | undefined, right: HeldBina
22
22
  export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
23
23
  export declare function overlay(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Layer;
24
24
  export declare function sameLayerText(left: Layer, right: Layer): boolean;
25
+ export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
25
26
  export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
@@ -1,6 +1,7 @@
1
1
  import { type Definition } from '../mdmodel/index.js';
2
2
  import type { HeadChange } from './adapter.js';
3
3
  import type { BinaryFileRecord } from './binary.js';
4
+ import type { Open } from './open.js';
4
5
  export type Value = string | number | boolean | null;
5
6
  export type Predicate = Value | {
6
7
  $eq: Value;
@@ -100,13 +101,38 @@ export type QueryGroup = {
100
101
  key: readonly unknown[];
101
102
  count: number;
102
103
  };
103
- export type DocumentResult = {
104
+ export type CoveredRoom = {
105
+ room: string;
106
+ generation: string;
107
+ current: boolean;
108
+ };
109
+ export type QueryCoverage = {
110
+ rooms: readonly CoveredRoom[];
111
+ indexes: readonly string[];
112
+ overlay: readonly string[];
113
+ };
114
+ export type Awaits = Open<'acquisition' | 'preparation' | 'index'>;
115
+ export type PendingRoom = {
116
+ room: string;
117
+ awaits: Awaits;
118
+ };
119
+ export type PendingResult = {
120
+ pending: readonly PendingRoom[];
121
+ };
122
+ export type DocumentRows = {
104
123
  documents: readonly QueryDocument[];
105
124
  };
106
- export type GroupResult = {
125
+ export type GroupRows = {
107
126
  groups: readonly QueryGroup[];
108
127
  };
109
- export type QueryResult = DocumentResult | GroupResult;
128
+ export type QueryRows = DocumentRows | GroupRows;
129
+ export type DocumentResult = DocumentRows & {
130
+ coverage: QueryCoverage;
131
+ };
132
+ export type GroupResult = GroupRows & {
133
+ coverage: QueryCoverage;
134
+ };
135
+ export type QueryResult = DocumentResult | GroupResult | PendingResult;
110
136
  export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
111
137
  export type RoomFacts = {
112
138
  locator: string;
@@ -1,6 +1,7 @@
1
1
  import type { ReferrerScope } from './adapter.js';
2
- import type { MdRuntime, RuntimeTopic } from './connection.js';
2
+ import type { MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
3
3
  import type { Plan, PlanReach, QueryResult } from './query.js';
4
+ import type { Readiness } from './readiness.js';
4
5
  import type { SearchResult } from './search.js';
5
6
  export type ReachedDocument = {
6
7
  readonly room: string;
@@ -19,12 +20,15 @@ export type RuntimeView = {
19
20
  };
20
21
  export type NarrowedView = RuntimeView & {
21
22
  narrow(reach: PortReach | null): void;
23
+ facts(port: ReadinessPort): void;
22
24
  };
23
25
  export type Reachable = RuntimeView & {
24
26
  plan(input: unknown, reach: PortReach | null): Plan;
25
27
  query(plan: Plan): Promise<QueryResult>;
26
28
  watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
27
29
  search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
30
+ searching(target: string): void;
31
+ watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
28
32
  referrerScope(referrer: unknown): ReferrerScope | null;
29
33
  };
30
34
  export declare function holds(reach: PortReach | null, room: string): boolean;
@@ -38,4 +42,4 @@ export declare function governs(reach: PortReach | null, room: {
38
42
  readonly selection: boolean;
39
43
  };
40
44
  export declare function planReach(reach: PortReach | null): PlanReach | null;
41
- export declare function narrowed(runtime: Reachable, given: PortReach | null): NarrowedView;
45
+ export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;