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

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/index.d.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  import type { MdRuntimeClient, Open } from './mdruntime/client.js';
2
- import type { HouseCalls } from './calls.js';
3
- export type { HouseCalls } from './calls.js';
4
- export type HouseCallInput<Name extends string> = Name extends keyof HouseCalls ? HouseCalls[Name] : unknown;
2
+ import type { HouseMethods } from './calls.js';
3
+ export type { HouseMethods } from './calls.js';
4
+ export type HouseParams<Name extends string> = Name extends keyof HouseMethods ? HouseMethods[Name]['params'] : unknown;
5
+ type CallResult = Awaited<ReturnType<MdRuntimeClient['call']>>;
6
+ export type HouseResult<Name extends string> = Exclude<CallResult, {
7
+ readonly kind: 'action';
8
+ }> | (Extract<CallResult, {
9
+ readonly kind: 'action';
10
+ }> & {
11
+ readonly result: Name extends keyof HouseMethods ? HouseMethods[Name]['result'] : unknown;
12
+ });
5
13
  export interface HouseRuntime extends Omit<MdRuntimeClient, 'call'> {
6
- call<Name extends Open<keyof HouseCalls>>(name: Name, input: HouseCallInput<Name>): ReturnType<MdRuntimeClient['call']>;
14
+ call<Name extends Open<keyof HouseMethods>>(method: Name, params: HouseParams<Name>): Promise<HouseResult<Name>>;
7
15
  }
8
16
  export interface HouseSyncState {
9
17
  readonly state: string;
@@ -1,8 +1,6 @@
1
1
  import { type ValueFacts } from './definition.js';
2
2
  import type { Document, VerifiedModel } from './types.js';
3
- export type ConditionValue = string | number | boolean | {
4
- readonly owner: true;
5
- };
3
+ export type ConditionValue = string | number | boolean;
6
4
  export type ConditionTest = {
7
5
  readonly all: readonly ConditionTest[];
8
6
  } | {
@@ -120,7 +118,6 @@ export type ItemFacts = {
120
118
  readonly source: string | null;
121
119
  readonly address: string | null;
122
120
  readonly has_attachment: boolean;
123
- readonly provider: string | null;
124
121
  readonly container: string | null;
125
122
  readonly author: string | null;
126
123
  readonly headers: Readonly<Record<string, string>>;
@@ -143,7 +140,8 @@ export declare function datePointers(fields: Readonly<Record<string, ValueFacts>
143
140
  export declare function dated(value: unknown): value is string;
144
141
  export declare function instant(value: unknown): bigint | undefined;
145
142
  export declare function pointed(value: unknown, pointer: string): unknown;
146
- export declare function holds(test: ConditionTest, document: DocumentFacts, owner: string): Truth;
147
- export declare function fires(condition: DocumentCondition, event: DocumentEvent, owner: string): boolean;
148
- export declare function itemFires(condition: ItemCondition, item: ItemFacts, owner: string): boolean;
143
+ export declare function members(document: DocumentFacts, path: string): readonly string[];
144
+ export declare function holds(test: ConditionTest, document: DocumentFacts): Truth;
145
+ export declare function fires(condition: DocumentCondition, event: DocumentEvent): boolean;
146
+ export declare function itemFires(condition: ItemCondition, item: ItemFacts): boolean;
149
147
  export {};
@@ -5,6 +5,7 @@ export type ValueFacts = {
5
5
  readonly format?: string;
6
6
  readonly values?: readonly unknown[];
7
7
  readonly reference?: readonly string[];
8
+ readonly crossRoom?: true;
8
9
  readonly prose: boolean;
9
10
  readonly conditional?: true;
10
11
  readonly prefix?: readonly ValueFacts[];
@@ -9,7 +9,7 @@ export declare function relinkBody(body: string, file: string, moves: ReadonlyMa
9
9
  export declare function links(document: Document, file: string): readonly Link[];
10
10
  export declare function linkOccurrences(document: Document, file: string): readonly LinkOccurrence[];
11
11
  export declare function bodyLinks(body: string, file: string): readonly Link[];
12
- export declare function apply(document: Document, change: Change): ApplyResult;
12
+ export declare function apply(document: Document, changes: readonly Change[]): ApplyResult;
13
13
  export declare function serialize(document: Document): string;
14
14
  export declare function fieldStart(document: Document, pointer: string): number | undefined;
15
15
  export declare function frontmatter(document: Document): YamlMap | null;
@@ -1,18 +1,19 @@
1
- export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
1
+ export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, members, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
2
2
  export type { Actor, Condition, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, Resolved, WriteDoor, } from './condition.js';
3
3
  export { headingLines } from './blocks.js';
4
4
  export type { HeadingLine } from './blocks.js';
5
5
  export { divide } from './divide.js';
6
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
- export { relative, retarget, target } from './paths.js';
8
+ export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
9
+ export type { RoomTarget } from './paths.js';
9
10
  export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
10
11
  export { project } from './project.js';
11
12
  export { references } from './references.js';
12
13
  export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
13
14
  export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.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';
15
+ export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, LinkOccurrence, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
16
+ export { bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verify, } from './validate.js';
16
17
  export { VERSION } from './version.js';
17
18
  export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
18
19
  export type { FrontmatterValue } from './yaml.js';
@@ -2,14 +2,22 @@ export declare function dirname(path: string): string;
2
2
  export declare function join(base: string, relative: string): string;
3
3
  export declare function normalize(path: string): string | null;
4
4
  export declare function destinationPath(href: string): string | null;
5
+ export type RoomTarget = {
6
+ readonly handle: string;
7
+ readonly path: string;
8
+ };
5
9
  export declare function classifyHref(from: string, href: string): {
6
10
  kind: 'skip';
7
11
  } | {
8
12
  kind: 'path';
9
13
  path: string;
10
- } | {
14
+ } | ({
15
+ kind: 'room';
16
+ } & RoomTarget) | {
11
17
  kind: 'invalid';
12
18
  };
19
+ export declare function roomTarget(href: string): RoomTarget | null;
20
+ export declare function roomPath(href: string): string | null;
13
21
  export declare function target(from: string, href: string): string | null;
14
22
  export declare function retarget(href: string, to: string): string;
15
23
  export declare function relative(from: string, target: string): string;
@@ -15,6 +15,7 @@ export type InputResult = {
15
15
  readonly ok: false;
16
16
  readonly refusal: Refusal;
17
17
  };
18
+ export declare function firstEditFrom(edits: readonly Edit[], start: number): number;
18
19
  export declare function rangeText(content: string, range: Extent, edits: readonly Edit[]): string;
19
20
  export declare function projectionInput(document: Document, file: string, context: ProjectionContext): InputResult;
20
21
  export declare function project(document: Document, file: string, context?: ProjectionContext): Projection;
@@ -99,7 +99,25 @@ export type Reference = {
99
99
  readonly pointer: string;
100
100
  readonly value: string;
101
101
  readonly to: readonly string[];
102
+ readonly crossRoom?: true;
102
103
  };
104
+ export type RoomReference = {
105
+ readonly handle: string;
106
+ readonly path: string;
107
+ } & ({
108
+ readonly kind: 'link';
109
+ readonly href: string;
110
+ } | {
111
+ readonly kind: 'field';
112
+ readonly pointer: string;
113
+ readonly value: string;
114
+ readonly to: readonly string[];
115
+ } | {
116
+ readonly kind: 'item';
117
+ readonly section: string;
118
+ readonly href: string;
119
+ readonly to: readonly string[];
120
+ });
103
121
  export type Change = {
104
122
  readonly kind: 'field';
105
123
  readonly name: string;
@@ -130,6 +148,7 @@ export type ApplyResult = {
130
148
  } | {
131
149
  readonly outcome: 'stale';
132
150
  readonly document: Document;
151
+ readonly stale: readonly number[];
133
152
  } | {
134
153
  readonly outcome: 'refuse';
135
154
  readonly refusal: Refusal;
@@ -1,7 +1,10 @@
1
1
  import { type Definition } from './definition.js';
2
- import type { DocumentCheck, Library, ModelVerification, Reached, Validation, ValidationContext, VerifiedModel } from './types.js';
2
+ import type { DocumentCheck, Library, ModelVerification, Reached, RoomReference, Validation, ValidationContext, VerifiedModel } from './types.js';
3
3
  export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
4
4
  export declare function verify(schema: string): ModelVerification;
5
5
  export declare function checkDocument(file: string, content: string, model: VerifiedModel): DocumentCheck;
6
6
  export declare function sectionReferences(file: string, content: string, definition: Definition): readonly Reached[];
7
+ export declare function bodyRoomLinks(body: string): RoomReference[];
8
+ export declare function roomReferences(file: string, content: string, definition?: Definition): readonly RoomReference[];
9
+ export declare function validating(library: Library, context?: ValidationContext, model?: VerifiedModel): Generator<string, Validation, void>;
7
10
  export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
@@ -10,8 +10,6 @@ export type TypedSelection = {
10
10
  roots: readonly string[];
11
11
  };
12
12
  export type OperationScopes = {
13
- read: readonly string[];
14
- sync: readonly string[];
15
13
  write: readonly string[];
16
14
  delete: readonly string[];
17
15
  };
@@ -49,6 +47,7 @@ export type ListedConversation = {
49
47
  created: string;
50
48
  finished: string | null;
51
49
  outcome: string | null;
50
+ waiting: boolean;
52
51
  };
53
52
  export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
54
53
  export type ConversationMessage = {
@@ -162,6 +161,18 @@ export type ConversationEvent = {
162
161
  kind: 'options';
163
162
  conversation: string;
164
163
  options: readonly SessionOption[];
164
+ } | {
165
+ kind: 'starting';
166
+ conversation: string;
167
+ step: string | null;
168
+ } | {
169
+ kind: 'link';
170
+ conversation: string;
171
+ connected: boolean;
172
+ } | {
173
+ kind: 'deliveries';
174
+ conversation: string;
175
+ unknown: readonly string[];
165
176
  } | {
166
177
  kind: 'accepted-message';
167
178
  conversation: string;
@@ -210,6 +221,10 @@ export type Discovery = {
210
221
  providerLimits: readonly ProviderLimit[];
211
222
  retention: Retention;
212
223
  member?: Member;
224
+ covered?: readonly string[];
225
+ };
226
+ export type DiscoveryScope = {
227
+ readonly authorities: readonly string[];
213
228
  };
214
229
  export type TransportUncertainty = {
215
230
  kind: 'transport-uncertainty';
@@ -229,7 +244,7 @@ export type ProviderRefusal = {
229
244
  export type ScopedRefusal = ProviderRefusal & {
230
245
  kind: 'scoped-refusal';
231
246
  locator: string;
232
- scope: Open<'content' | 'sync' | 'model' | 'operation' | 'undisclosed'>;
247
+ scope: Open<'content' | 'model' | 'operation' | 'undisclosed'>;
233
248
  };
234
249
  export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
235
250
  export type ContractUnavailable = ProviderRefusal & {
@@ -400,6 +415,13 @@ export type BinaryResult = {
400
415
  } | (ProviderRefusal & {
401
416
  kind: 'rejected';
402
417
  }) | AdapterFailure;
418
+ export type BinaryLinkResult = {
419
+ kind: 'link';
420
+ url: string;
421
+ name: string;
422
+ } | (ProviderRefusal & {
423
+ kind: 'rejected';
424
+ }) | AdapterFailure;
403
425
  export type ActionRequest = {
404
426
  name: string;
405
427
  input: unknown;
@@ -430,6 +452,9 @@ export type RoomStreamEvent = {
430
452
  } | {
431
453
  kind: 'opening';
432
454
  expired: readonly string[];
455
+ } | {
456
+ kind: 'authority-changed';
457
+ scope?: DiscoveryScope;
433
458
  } | {
434
459
  kind: 'room-version';
435
460
  locator: string;
@@ -448,12 +473,8 @@ export type StreamReceipts = {
448
473
  }): Promise<void>;
449
474
  drop(keys: readonly string[]): Promise<void>;
450
475
  };
451
- export type AcquiredDemand = {
452
- rooms: readonly string[];
453
- conversations: boolean;
454
- };
455
476
  export type RoomStream = {
456
- hold(rooms: readonly HeldRoom[], demand: AcquiredDemand | null): void;
477
+ hold(rooms: readonly HeldRoom[]): void;
457
478
  reopen(): void;
458
479
  published(locator: string, roomVersion: string): void;
459
480
  observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
@@ -462,12 +483,15 @@ export type Adapter = {
462
483
  readonly localSaves?: true;
463
484
  readonly exhaustiveDiscovery?: true;
464
485
  authorize(): Promise<Authorization>;
465
- discover(authorization: Authorization): Promise<DiscoverResult>;
486
+ discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
466
487
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
467
488
  refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
468
489
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
469
490
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
470
491
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
492
+ link(authorization: Authorization, request: Extract<BinaryRequest, {
493
+ kind: 'path';
494
+ }>): Promise<BinaryLinkResult>;
471
495
  referrerScope(referrer: unknown): ReferrerScope | null;
472
496
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
473
497
  reached(locator: string, roomVersion: string, target: string): boolean;
@@ -23,12 +23,15 @@ export type ChangeSet = {
23
23
  messages: readonly MessageChange[];
24
24
  conversations: readonly string[];
25
25
  };
26
- export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
26
+ type Changed = {
27
27
  drafts?: readonly string[];
28
28
  room?: boolean;
29
29
  queue?: boolean;
30
30
  presentation?: string;
31
- }): ChangeSet;
31
+ };
32
+ export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: Changed): ChangeSet;
33
+ export declare function changing(locator: string, before: Replica | null, after: Replica | null, changed?: Changed): Generator<number, ChangeSet, void>;
32
34
  export declare function entering(locator: string, replica: Replica, paths: readonly string[]): ChangeSet;
33
35
  export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
34
36
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
37
+ export {};
@@ -1,9 +1,9 @@
1
- import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedRoomDraft, SaveResult } from './connection.js';
1
+ import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
2
2
  import type { Member, ServiceMode } from './adapter.js';
3
3
  import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
4
4
  import { type Observation } from './observation.js';
5
5
  import type { BinaryReference } from './binary.js';
6
- import type { BinaryAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
6
+ import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
7
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';
@@ -25,9 +25,11 @@ export type MdRuntimeClient = {
25
25
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
26
26
  };
27
27
  save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
28
+ saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
28
29
  presentation: {
29
30
  read(): Promise<unknown>;
30
31
  write(value: unknown): Promise<void>;
32
+ edit(members: Readonly<Record<string, unknown>>): Promise<void>;
31
33
  };
32
34
  conversation: {
33
35
  list(): Promise<readonly ConversationEntry[]>;
@@ -42,11 +44,13 @@ export type MdRuntimeClient = {
42
44
  };
43
45
  chatDraft: {
44
46
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
47
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
45
48
  discard(conversation: string): Promise<void>;
46
49
  };
47
50
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
48
51
  binaryFile: {
49
52
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
53
+ link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
50
54
  readReference(reference: BinaryReference): Promise<BinaryAnswer>;
51
55
  };
52
56
  call(name: string, input: unknown): Promise<CallResult>;
@@ -19,11 +19,12 @@ export type Composition = {
19
19
  };
20
20
  export declare function governing(composition: Composition, path: string): ModelState;
21
21
  export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Collection;
22
+ export declare function collecting(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Generator<number, Collection, void>;
22
23
  export declare function passingFrontmatter(collection: Collection, path: string): Frontmatter | undefined;
23
24
  export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
24
- export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Refused | null;
25
+ export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Generator<number, Refused | null, void>;
25
26
  export declare function validRoot(root: unknown): root is string;
26
- export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
27
+ export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Generator<number, Validation, void>;
27
28
  type Held = {
28
29
  text: Paths<string>;
29
30
  binaries: Paths<unknown>;
@@ -34,5 +35,5 @@ export declare function referring(held: Held, composition: Composition, targets:
34
35
  export declare function available(composition: Composition): boolean;
35
36
  export declare function changedCleanly(next: Held, previous: Held & {
36
37
  composition: Composition;
37
- }, composition: Composition): boolean;
38
+ }, composition: Composition): Generator<number, boolean, void>;
38
39
  export {};
@@ -8,13 +8,12 @@ import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry,
8
8
  import { type WrittenBy } from './change.js';
9
9
  import type { Open } from './open.js';
10
10
  import { type BinaryReference } from './binary.js';
11
- import { type BinaryAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
11
+ import { type BinaryAnswer, type BinaryLinkAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
12
12
  import { type Recovery } from './recovery.js';
13
13
  import { type SaveRefusal } from './save.js';
14
- import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
14
+ import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
15
15
  import { type SyncStatus } from './status.js';
16
16
  import { type RuntimeShell } from './durability.js';
17
- import { type RuntimeDemand } from './acquisition.js';
18
17
  import { type CapacityCause, type CodeAvailability, type Persistence, type Readiness, type SearchObligation } from './readiness.js';
19
18
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
20
19
  export type AppTypedSelection = {
@@ -64,6 +63,10 @@ export type SavedRoomDraft = {
64
63
  readonly path: string;
65
64
  readonly revision: string;
66
65
  };
66
+ export type SavedParts = {
67
+ readonly path: string;
68
+ readonly parts: RoomDraftParts;
69
+ };
67
70
  export type RoomDraftSurface = {
68
71
  list(): Promise<readonly RoomDraft[]>;
69
72
  read(room: string, path: string): RoomDraft | null;
@@ -73,9 +76,11 @@ export type RoomDraftSurface = {
73
76
  export type PresentationSurface = {
74
77
  read(app: string): Promise<unknown>;
75
78
  write(app: string, value: unknown): Promise<void>;
79
+ edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
76
80
  };
77
81
  export type BinaryFileSurface = {
78
82
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
83
+ link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
79
84
  readReference(reference: BinaryReference): Promise<BinaryAnswer>;
80
85
  };
81
86
  export type HistoryQuery = {
@@ -96,6 +101,7 @@ export type MdRuntime = {
96
101
  chatDraft: ChatDraftSurface;
97
102
  presentation: PresentationSurface;
98
103
  save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
104
+ saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
99
105
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
100
106
  binaryFile: BinaryFileSurface;
101
107
  call(name: string, input: unknown): Promise<CallResult>;
@@ -133,7 +139,6 @@ export type ComposedRuntime = RuntimeView & {
133
139
  seed(entry: EntrySeed): void;
134
140
  stop(): Promise<void>;
135
141
  lose(locators: readonly string[]): Promise<void>;
136
- acquire(demand: RuntimeDemand): void;
137
142
  persisted(answer: Persistence): void;
138
143
  within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
139
144
  };
@@ -17,6 +17,7 @@ export type ConversationEntry = {
17
17
  created: string;
18
18
  finished: string | null;
19
19
  outcome: string | null;
20
+ waiting: boolean;
20
21
  state: ConversationState;
21
22
  started: string | null;
22
23
  };
@@ -36,10 +37,14 @@ export type ChatDraft = {
36
37
  };
37
38
  export type ConversationOptions = {
38
39
  limit?: number;
40
+ after?: string;
41
+ total?: true;
39
42
  };
40
43
  export type ConversationView = {
41
44
  conversation: string;
42
45
  messages: readonly ConversationMessage[];
46
+ next?: string;
47
+ total?: number;
43
48
  turn: RunningTurn | null;
44
49
  questions: readonly unknown[];
45
50
  process: {
@@ -47,6 +52,11 @@ export type ConversationView = {
47
52
  } | null;
48
53
  commands: readonly ProcessCommand[];
49
54
  options: readonly SessionOption[];
55
+ starting: string | null;
56
+ link: {
57
+ connected: boolean;
58
+ } | null;
59
+ deliveryUnknown: readonly string[];
50
60
  chatDraft: (ChatDraft & {
51
61
  readonly revision: string;
52
62
  }) | null;
@@ -64,6 +74,7 @@ export type ConversationSurface = {
64
74
  };
65
75
  export type ChatDraftSurface = {
66
76
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
77
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
67
78
  discard(conversation: string): Promise<void>;
68
79
  };
69
80
  export type ConversationDependencies = {
@@ -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 = {
@@ -1,4 +1,4 @@
1
- import type { ActionResult, AdapterFailure, BinaryResult, HistoryResult, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
1
+ import type { ActionResult, AdapterFailure, BinaryLinkResult, BinaryResult, HistoryResult, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
2
2
  import type { ChangeBatch } from './change.js';
3
3
  type Refused<Kind extends string> = ProviderRefusal & {
4
4
  kind: Kind;
@@ -18,8 +18,14 @@ export type BinaryAnswer = {
18
18
  kind: 'binary';
19
19
  blob: Blob;
20
20
  } | Refused<'rejected'> | Refused<'absent'> | Failure;
21
- export declare function absentBinary(path: string): BinaryAnswer;
21
+ export type BinaryLinkAnswer = {
22
+ kind: 'link';
23
+ url: string;
24
+ name: string;
25
+ } | Refused<'rejected'> | Refused<'absent'> | Failure;
26
+ export declare function absentBinary(path: string): Refused<'absent'>;
22
27
  export declare function binaryAnswer(result: BinaryResult): BinaryAnswer;
28
+ export declare function binaryLinkAnswer(result: BinaryLinkResult): BinaryLinkAnswer;
23
29
  export type Offline = {
24
30
  readonly kind: 'offline';
25
31
  };
@@ -21,7 +21,7 @@ export type Layer = Heads & {
21
21
  export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Record<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>;
25
+ export declare function sameText(left: Layer, right: Layer): Generator<number, boolean, void>;
26
+ export declare function changedPaths(left: Layer, right: Layer): Generator<number, ReadonlySet<string>, void>;
27
+ export declare function overlayChanged(base: Layer, batch: ChangeBatch, previousBase: Layer, previousBatch: ChangeBatch, previousVisible: Layer): 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' | {
@@ -71,6 +73,8 @@ export type DocumentQuery = Filter & {
71
73
  direction?: Direction;
72
74
  } & OrderOptions)[];
73
75
  limit?: number;
76
+ after?: string;
77
+ total?: true;
74
78
  };
75
79
  export type GroupQuery = Filter & {
76
80
  groupBy: readonly Exclude<Key, 'path'>[];
@@ -79,6 +83,8 @@ export type GroupQuery = Filter & {
79
83
  direction?: Direction;
80
84
  }[];
81
85
  limit?: number;
86
+ after?: string;
87
+ total?: true;
82
88
  };
83
89
  export type LocalQuery = DocumentQuery | GroupQuery;
84
90
  export type Backlink = {
@@ -123,9 +129,13 @@ export type PendingResult = {
123
129
  };
124
130
  export type DocumentRows = {
125
131
  documents: readonly QueryDocument[];
132
+ next?: string;
133
+ total?: number;
126
134
  };
127
135
  export type GroupRows = {
128
136
  groups: readonly QueryGroup[];
137
+ next?: string;
138
+ total?: number;
129
139
  };
130
140
  export type QueryRows = DocumentRows | GroupRows;
131
141
  export type DocumentResult = DocumentRows & {
@@ -189,6 +199,8 @@ export type KeyPlan = {
189
199
  of: 'path';
190
200
  } | {
191
201
  of: 'type';
202
+ } | {
203
+ of: 'folder';
192
204
  } | {
193
205
  of: 'field';
194
206
  field: string;
@@ -221,11 +233,17 @@ export type PlanReach = {
221
233
  rooms: readonly string[];
222
234
  documents: readonly string[];
223
235
  };
236
+ export type Continuation = {
237
+ text: string;
238
+ values: readonly unknown[] | null;
239
+ };
224
240
  export type Plan = {
225
241
  key: string;
226
242
  rooms: readonly string[] | null;
227
243
  reach: PlanReach | null;
228
244
  root: Scope;
245
+ folder: string | null;
246
+ paths: readonly string[] | null;
229
247
  hop: (Scope & {
230
248
  field: string;
231
249
  }) | null;
@@ -234,6 +252,8 @@ export type Plan = {
234
252
  }) | null;
235
253
  shape: DocumentShape | GroupShape;
236
254
  limit: number | null;
255
+ after: Continuation | null;
256
+ total: boolean;
237
257
  };
238
258
  export declare class QueryError extends Error {
239
259
  readonly code: QueryErrorCode;
@@ -4,6 +4,7 @@ import { type Layer } from './overlay.js';
4
4
  import type { MutationResult } from './adapter.js';
5
5
  import type { ReplicaRecord } from './store.js';
6
6
  import type { Refused } from './transfer.js';
7
+ import { type Later } from './turn.js';
7
8
  export type ConfirmedLayer = {
8
9
  record: ReplicaRecord;
9
10
  collection: Collection;
@@ -31,15 +32,20 @@ type ReplayStep = {
31
32
  export declare function compositionOf(record: ReplicaRecord): Composition;
32
33
  export declare function confirmedOf(record: ReplicaRecord, previous?: ConfirmedLayer): ConfirmedLayer;
33
34
  export declare function sameMembership(record: ReplicaRecord, other: ReplicaRecord): boolean;
34
- export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Staged;
35
- export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Staged | {
35
+ export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Later<Staged>;
36
+ export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Later<Staged | {
36
37
  kind: 'deferred';
37
- };
38
+ }>;
38
39
  type Accepted = Extract<MutationResult, {
39
40
  kind: 'accepted';
40
41
  }>;
41
- export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Staged;
42
+ export declare function applyReturned(confirmed: ConfirmedLayer, submitted: ChangeBatch, accepted: Accepted, roomVersion: string, writtenAt: string): Later<Staged>;
43
+ export declare function replicating(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Generator<number, Replica, void>;
42
44
  export declare function replicaOf(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Replica;
43
45
  export declare function landed(batch: ChangeBatch, confirmed: ConfirmedLayer, current?: Readonly<Record<string, string>>): boolean;
44
- export declare function withdrawals(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean): readonly ChangeBatch[];
46
+ export type Standing = {
47
+ readonly withdrawn: readonly ChangeBatch[];
48
+ readonly kept: readonly ChangeBatch[];
49
+ };
50
+ export declare function standing(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean, local: boolean): Generator<number, Standing, void>;
45
51
  export {};
@@ -13,6 +13,7 @@ export type DocumentRow = {
13
13
  values: Fields;
14
14
  reached: Readonly<Record<string, readonly unknown[]>>;
15
15
  directories: readonly string[];
16
+ folder: string;
16
17
  text: string | null;
17
18
  change: HeadChange | null;
18
19
  fileId: string | null;