@agentshouse/app-bridge 0.1.0-c646d0da70608 → 0.1.0-c66ec79ae3f1a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +4 -4
  2. package/dist/calls.d.ts +897 -66
  3. package/dist/index.d.ts +15 -4
  4. package/dist/mdmodel/condition.d.ts +20 -8
  5. package/dist/mdmodel/definition.d.ts +16 -1
  6. package/dist/mdmodel/document.d.ts +5 -5
  7. package/dist/mdmodel/index.d.ts +10 -8
  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 +27 -4
  12. package/dist/mdmodel/validate.d.ts +27 -3
  13. package/dist/mdruntime/adapter.d.ts +67 -24
  14. package/dist/mdruntime/chain.d.ts +10 -0
  15. package/dist/mdruntime/change-set.d.ts +8 -9
  16. package/dist/mdruntime/change.d.ts +31 -1
  17. package/dist/mdruntime/client.d.ts +11 -2
  18. package/dist/mdruntime/collection.d.ts +6 -19
  19. package/dist/mdruntime/compile.d.ts +10 -0
  20. package/dist/mdruntime/connection.d.ts +23 -9
  21. package/dist/mdruntime/conversation.d.ts +15 -3
  22. package/dist/mdruntime/durability.d.ts +2 -1
  23. package/dist/mdruntime/file.d.ts +2 -10
  24. package/dist/mdruntime/observation.d.ts +14 -0
  25. package/dist/mdruntime/opened.d.ts +21 -0
  26. package/dist/mdruntime/outcome.d.ts +35 -4
  27. package/dist/mdruntime/overlay.d.ts +3 -5
  28. package/dist/mdruntime/query.d.ts +29 -2
  29. package/dist/mdruntime/reach.d.ts +6 -3
  30. package/dist/mdruntime/readiness.d.ts +1 -1
  31. package/dist/mdruntime/recovery.d.ts +2 -2
  32. package/dist/mdruntime/replica.d.ts +55 -33
  33. package/dist/mdruntime/room-draft.d.ts +15 -1
  34. package/dist/mdruntime/save.d.ts +51 -14
  35. package/dist/mdruntime/search.d.ts +25 -5
  36. package/dist/mdruntime/seed.d.ts +15 -0
  37. package/dist/mdruntime/shared.d.ts +8 -3
  38. package/dist/mdruntime/store.d.ts +99 -71
  39. package/dist/mdruntime/stored.d.ts +142 -0
  40. package/dist/mdruntime/tables.d.ts +319 -0
  41. package/dist/mdruntime/turn.d.ts +5 -3
  42. package/dist/mdruntime/wire.d.ts +32 -0
  43. package/dist/test-host.js +1 -1
  44. package/docs/families.md +8 -5
  45. package/package.json +1 -1
  46. package/dist/mdruntime/acquisition.d.ts +0 -13
  47. package/dist/mdruntime/rows.d.ts +0 -36
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;
@@ -13,6 +21,7 @@ export interface HouseCredentialState {
13
21
  readonly state: Open<'none' | 'held' | 'rejected'>;
14
22
  readonly expiresAt: number | null;
15
23
  }
24
+ export type HouseDatabaseFailure = 'unsupported' | 'damaged' | 'update-required';
16
25
  export type HouseAnalyticsChoice = 'accept' | 'decline';
17
26
  export interface HouseAnalytics {
18
27
  readonly measures: boolean;
@@ -32,6 +41,7 @@ export interface HouseStatus {
32
41
  readonly retryable: boolean;
33
42
  } | null;
34
43
  readonly loss: string | null;
44
+ readonly database: Open<HouseDatabaseFailure> | null;
35
45
  readonly analytics: HouseAnalytics;
36
46
  readonly serviceMode: Open<'open' | 'write-halted'> | null;
37
47
  readonly offline: boolean;
@@ -72,6 +82,7 @@ export interface HouseExternalRequest {
72
82
  readonly body_base64?: string;
73
83
  readonly account?: string;
74
84
  readonly slot?: string;
85
+ readonly room_ref?: string;
75
86
  }
76
87
  export type HouseExternalAnswer = {
77
88
  readonly status: number;
@@ -1,8 +1,8 @@
1
- import { type ValueFacts } from './definition.js';
1
+ import { type Definition, 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;
4
+ export declare const CONDITION_OPERATORS: readonly ['eq', 'in', 'exists', 'contains', 'gt', 'gte', 'lt', 'lte', 'prefix'];
5
+ export type ConditionOperator = (typeof CONDITION_OPERATORS)[number];
6
6
  export type ConditionTest = {
7
7
  readonly all: readonly ConditionTest[];
8
8
  } | {
@@ -41,6 +41,7 @@ type DocumentEventBase = {
41
41
  readonly on: 'documents';
42
42
  readonly scope: ConditionScope;
43
43
  readonly by?: ConditionTest;
44
+ readonly moved_between_rooms?: boolean;
44
45
  };
45
46
  export type DocumentCondition = (DocumentEventBase & {
46
47
  readonly mode: 'starts_matching';
@@ -114,13 +115,13 @@ export type DocumentEvent = {
114
115
  readonly after: DocumentFacts | null;
115
116
  readonly changed: readonly string[];
116
117
  readonly by: Actor;
118
+ readonly moved_between_rooms: boolean;
117
119
  };
118
120
  export type ItemFacts = {
119
121
  readonly delivery: string;
120
122
  readonly source: string | null;
121
123
  readonly address: string | null;
122
124
  readonly has_attachment: boolean;
123
- readonly provider: string | null;
124
125
  readonly container: string | null;
125
126
  readonly author: string | null;
126
127
  readonly headers: Readonly<Record<string, string>>;
@@ -140,10 +141,21 @@ export declare function facts(document: Document, at: {
140
141
  }, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
141
142
  export declare function prosePaths(facts: DocumentFacts): string[];
142
143
  export declare function datePointers(fields: Readonly<Record<string, ValueFacts>>): string[];
144
+ export declare function valuedChange(definition: Definition, field: string): boolean;
145
+ export declare function changeFields(definition: Definition): string[];
146
+ export declare function memberPointers(definition: Definition, memberType: string): string[];
147
+ export declare const DOCUMENT_PATHS: readonly string[];
148
+ export declare const ACTOR_PATHS: readonly string[];
149
+ export declare const ITEM_PATHS: readonly string[];
150
+ export declare function testOperators(definitions: readonly Definition[], path: string, memberType: string | null): readonly ConditionOperator[];
151
+ export declare function actorOperators(path: string): readonly ConditionOperator[];
152
+ export declare function itemOperators(path: string): readonly ConditionOperator[];
153
+ export declare function itemKind(path: string): FactKind | null;
143
154
  export declare function dated(value: unknown): value is string;
144
155
  export declare function instant(value: unknown): bigint | undefined;
145
156
  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;
157
+ export declare function members(document: DocumentFacts, path: string): readonly string[];
158
+ export declare function holds(test: ConditionTest, document: DocumentFacts): Truth;
159
+ export declare function fires(condition: DocumentCondition, event: DocumentEvent): boolean;
160
+ export declare function itemFires(condition: ItemCondition, item: ItemFacts): boolean;
149
161
  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[];
@@ -29,12 +30,26 @@ export type Shape = {
29
30
  readonly schema: Readonly<Record<string, unknown>>;
30
31
  readonly defs: Readonly<Record<string, unknown>>;
31
32
  };
33
+ export type RuleValue = string | number | boolean | null;
34
+ export type Transition = {
35
+ readonly from: RuleValue;
36
+ readonly to: RuleValue;
37
+ readonly roles?: readonly string[];
38
+ };
39
+ export type FieldRules = {
40
+ readonly changeRoles?: readonly string[];
41
+ readonly initialRoles?: readonly string[];
42
+ readonly transitions?: readonly Transition[];
43
+ };
32
44
  export type Definition = {
33
45
  readonly name: string;
34
46
  readonly memberDocument: boolean;
35
47
  readonly frontmatter: ValueFacts;
36
48
  readonly fields: Readonly<Record<string, ValueFacts>>;
37
49
  readonly sections: Readonly<Record<string, SectionSpec>>;
50
+ readonly rules: Readonly<Record<string, FieldRules>>;
51
+ readonly createRoles?: readonly string[];
52
+ readonly deleteRoles?: readonly string[];
38
53
  readonly shape: Shape;
39
54
  };
40
55
  export type Failure = {
@@ -62,4 +77,4 @@ export type PointerFacts = {
62
77
  export declare function crossedFacts(facts: ValueFacts): ValueFacts[];
63
78
  export declare function fieldFacts(definition: Definition, key: string): ValueFacts | undefined;
64
79
  export declare function pointerFacts(definition: Definition, pointer: string): PointerFacts | undefined;
65
- export declare function readSchema(text: string): VerifiedModel | Failure;
80
+ export declare function readSchema(text: string, provided?: VerifiedModel): VerifiedModel | Failure;
@@ -1,15 +1,15 @@
1
1
  import { type Definition } from './definition.js';
2
- import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, LinkOccurrence, ParseResult } from './types.js';
2
+ import { type LinkInventory } from './links.js';
3
+ import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, ParseResult } from './types.js';
3
4
  import { type YamlMap } from './yaml.js';
5
+ export declare function inventoryOf(document: Document): LinkInventory;
4
6
  export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
5
7
  export declare function parse(content: string, file?: string): ParseResult;
6
- export declare function relativize(document: Document, file: string, handle: string, definition?: Definition): ApplyResult;
8
+ export declare function relativize(document: Document, file: string, handle: string, definition?: Definition, kept?: ReadonlySet<string>): ApplyResult;
7
9
  export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
8
10
  export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
9
11
  export declare function links(document: Document, file: string): readonly Link[];
10
- export declare function linkOccurrences(document: Document, file: string): readonly LinkOccurrence[];
11
12
  export declare function bodyLinks(body: string, file: string): readonly Link[];
12
- export declare function apply(document: Document, change: Change): ApplyResult;
13
+ export declare function apply(document: Document, changes: readonly Change[]): ApplyResult;
13
14
  export declare function serialize(document: Document): string;
14
- export declare function fieldStart(document: Document, pointer: string): number | undefined;
15
15
  export declare function frontmatter(document: Document): YamlMap | null;
@@ -1,18 +1,20 @@
1
- export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
2
- export type { Actor, Condition, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, Resolved, WriteDoor, } from './condition.js';
1
+ export { ACTOR_PATHS, actorOperators, changeFields, CONDITION_OPERATORS, dated, datePointers, DOCUMENT_PATHS, factKind, facts, fires, holds, instant, ITEM_PATHS, itemFires, itemKind, itemOperators, memberPointers, members, pointed, prosePaths, testOperators, valuedChange, WRITE_DOORS, } from './condition.js';
2
+ export type { Actor, Condition, ConditionOperator, 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
- export { apply, bodyLinks, fieldStart, linkOccurrences, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
6
+ export { apply, bodyLinks, 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
- export type { Definition, JsonType, PatternFacts, PointerFacts, SectionSpec, Shape, 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';
14
+ export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
15
+ export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
16
+ export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
17
+ export type { Assessment, Verdicts } from './validate.js';
16
18
  export { VERSION } from './version.js';
17
- export { equalValue, frontmatterValue } from './yaml.js';
19
+ export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
18
20
  export type { FrontmatterValue } from './yaml.js';
@@ -0,0 +1,28 @@
1
+ export declare function escapes(text: string, index: number): boolean;
2
+ export declare function spanCursor(spans: readonly (readonly [number, number])[]): (index: number) => number | undefined;
3
+ export type HrefOccurrence = {
4
+ readonly href: string;
5
+ readonly start: number;
6
+ readonly end: number;
7
+ readonly bracketed: boolean;
8
+ };
9
+ export type LinkUse = {
10
+ readonly start: number;
11
+ readonly end: number;
12
+ readonly labelStart: number;
13
+ readonly labelEnd: number;
14
+ readonly destination: HrefOccurrence;
15
+ };
16
+ export type DefinitionBlock = {
17
+ readonly start: number;
18
+ readonly end: number;
19
+ readonly destination: HrefOccurrence;
20
+ };
21
+ export type LinkInventory = {
22
+ readonly uses: readonly LinkUse[];
23
+ readonly blocks: readonly DefinitionBlock[];
24
+ };
25
+ export declare function fenceSpans(text: string): readonly (readonly [number, number])[];
26
+ export declare function linkInventory(body: string): LinkInventory;
27
+ export declare function destinations(inventory: LinkInventory): readonly HrefOccurrence[];
28
+ export declare function hrefOccurrences(body: string): readonly HrefOccurrence[];
@@ -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;
@@ -13,13 +13,14 @@ export type ModelVerification = {
13
13
  };
14
14
  export type ValidationContext = {
15
15
  readonly binaryTargets: readonly string[];
16
+ readonly anyRoom?: true;
16
17
  };
17
18
  export type ProjectionContext = {
18
19
  readonly documentTargets: readonly string[];
19
20
  readonly definition?: Definition;
20
21
  };
21
22
  export type DivisionContext = ProjectionContext & {
22
- readonly budget: number;
23
+ readonly bound: number;
23
24
  };
24
25
  export type Extent = {
25
26
  readonly start: number;
@@ -60,6 +61,10 @@ export type Validation = {
60
61
  } | ({
61
62
  readonly verdict: 'refuse';
62
63
  } & Refusal);
64
+ export type ValidationStep = {
65
+ readonly path: string;
66
+ readonly resolved: number;
67
+ };
63
68
  export type Projection = {
64
69
  readonly ok: true;
65
70
  readonly text: string;
@@ -92,14 +97,31 @@ export type Link = {
92
97
  readonly href: string;
93
98
  readonly target: string;
94
99
  };
95
- export type LinkOccurrence = Link & {
96
- readonly start: number;
97
- };
98
100
  export type Reference = {
99
101
  readonly pointer: string;
100
102
  readonly value: string;
101
103
  readonly to: readonly string[];
104
+ readonly crossRoom?: true;
102
105
  };
106
+ export type RoomReference = {
107
+ readonly handle: string;
108
+ readonly path: string;
109
+ } & ({
110
+ readonly kind: 'link';
111
+ readonly href: string;
112
+ } | {
113
+ readonly kind: 'field';
114
+ readonly pointer: string;
115
+ readonly value: string;
116
+ readonly to: readonly string[];
117
+ readonly crossRoom?: true;
118
+ } | {
119
+ readonly kind: 'item';
120
+ readonly section: string;
121
+ readonly href: string;
122
+ readonly to: readonly string[];
123
+ readonly crossRoom?: true;
124
+ });
103
125
  export type Change = {
104
126
  readonly kind: 'field';
105
127
  readonly name: string;
@@ -130,6 +152,7 @@ export type ApplyResult = {
130
152
  } | {
131
153
  readonly outcome: 'stale';
132
154
  readonly document: Document;
155
+ readonly stale: readonly number[];
133
156
  } | {
134
157
  readonly outcome: 'refuse';
135
158
  readonly refusal: Refusal;
@@ -1,7 +1,31 @@
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, ValidationStep, VerifiedModel } from './types.js';
3
3
  export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
4
- export declare function verify(schema: string): ModelVerification;
5
- export declare function checkDocument(file: string, content: string, model: VerifiedModel): DocumentCheck;
4
+ export declare function verify(schema: string, provided?: VerifiedModel): ModelVerification;
5
+ export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Pick<ValidationContext, 'anyRoom'>): 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
+ type Placed = {
10
+ readonly reference: Reached;
11
+ readonly location: string;
12
+ };
13
+ export type Assessment = {
14
+ readonly file: string;
15
+ readonly type: string | undefined;
16
+ readonly targets: readonly string[];
17
+ readonly read: Validation | null;
18
+ readonly structured: Validation | null;
19
+ readonly fields: readonly Placed[];
20
+ readonly linked: boolean;
21
+ readonly sections: readonly Placed[];
22
+ };
23
+ export declare function assess(file: string, content: string, binary: boolean, model?: VerifiedModel, context?: Pick<ValidationContext, 'anyRoom'>): Assessment;
24
+ export type Verdicts = {
25
+ add(assessment: Assessment, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): number;
26
+ verdict(): Validation;
27
+ };
28
+ export declare function verdicts(): Verdicts;
29
+ export declare function validating(library: ReadonlyMap<string, string>, context?: ValidationContext, model?: VerifiedModel): Generator<ValidationStep, Validation, void>;
7
30
  export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
31
+ export {};
@@ -10,14 +10,13 @@ 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
  };
18
16
  export type ReplicaAdmission = {
19
17
  selection: string;
20
18
  admission: Open<'admitted' | 'unavailable'>;
19
+ offline: Open<'locked' | 'open'>;
21
20
  };
22
21
  export type DiscoveredRoom = {
23
22
  name: string;
@@ -49,8 +48,9 @@ export type ListedConversation = {
49
48
  created: string;
50
49
  finished: string | null;
51
50
  outcome: string | null;
51
+ waiting: boolean;
52
52
  };
53
- export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
53
+ export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.attach' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
54
54
  export type ConversationMessage = {
55
55
  identity: string;
56
56
  turn: string;
@@ -162,6 +162,18 @@ export type ConversationEvent = {
162
162
  kind: 'options';
163
163
  conversation: string;
164
164
  options: readonly SessionOption[];
165
+ } | {
166
+ kind: 'starting';
167
+ conversation: string;
168
+ step: string | null;
169
+ } | {
170
+ kind: 'link';
171
+ conversation: string;
172
+ connected: boolean;
173
+ } | {
174
+ kind: 'deliveries';
175
+ conversation: string;
176
+ unknown: readonly string[];
165
177
  } | {
166
178
  kind: 'accepted-message';
167
179
  conversation: string;
@@ -187,6 +199,7 @@ export type ActionDeclaration = {
187
199
  name: string;
188
200
  inputShape: unknown;
189
201
  resultKind: unknown;
202
+ room?: string;
190
203
  };
191
204
  export type ProviderLimit = {
192
205
  name: string;
@@ -210,6 +223,10 @@ export type Discovery = {
210
223
  providerLimits: readonly ProviderLimit[];
211
224
  retention: Retention;
212
225
  member?: Member;
226
+ covered?: readonly string[];
227
+ };
228
+ export type DiscoveryScope = {
229
+ readonly authorities: readonly string[];
213
230
  };
214
231
  export type TransportUncertainty = {
215
232
  kind: 'transport-uncertainty';
@@ -229,7 +246,7 @@ export type ProviderRefusal = {
229
246
  export type ScopedRefusal = ProviderRefusal & {
230
247
  kind: 'scoped-refusal';
231
248
  locator: string;
232
- scope: Open<'content' | 'sync' | 'model' | 'operation' | 'undisclosed'>;
249
+ scope: Open<'content' | 'model' | 'operation' | 'undisclosed'>;
233
250
  };
234
251
  export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
235
252
  export type ContractUnavailable = ProviderRefusal & {
@@ -238,7 +255,7 @@ export type ContractUnavailable = ProviderRefusal & {
238
255
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
239
256
  export type PageToken = string;
240
257
  export type ChangeAuthor = {
241
- kind: Open<'user' | 'site'>;
258
+ kind: Open<'user' | 'site' | 'inbox'>;
242
259
  id: string;
243
260
  name: string;
244
261
  };
@@ -257,9 +274,16 @@ export type BinaryFile = {
257
274
  mediaType: string;
258
275
  sha256: string;
259
276
  };
277
+ export type HeldFile = {
278
+ readonly path: string;
279
+ readonly revision: string;
280
+ };
260
281
  export type HeldContent = {
261
- documents: Readonly<Record<string, string>>;
262
- revisions: Readonly<Record<string, string>>;
282
+ files(after: string | null, limit: number): Promise<readonly HeldFile[]>;
283
+ contents(paths: readonly string[]): Promise<ReadonlyMap<string, {
284
+ readonly content: string;
285
+ readonly revision: string;
286
+ }>>;
263
287
  };
264
288
  export type BootstrapRequest = {
265
289
  locator: string;
@@ -277,8 +301,10 @@ export type BootstrapPage = {
277
301
  models?: RoomModels;
278
302
  documents: Readonly<Record<string, string>>;
279
303
  revisions: Readonly<Record<string, string>>;
304
+ fileIds?: Readonly<Record<string, string>>;
280
305
  changes: Readonly<Record<string, HeadChange>>;
281
306
  binaryFiles: Readonly<Record<string, BinaryFile>>;
307
+ folders?: readonly string[];
282
308
  pageToken?: PageToken;
283
309
  };
284
310
  export type BootstrapResult = BootstrapPage | {
@@ -296,9 +322,12 @@ export type RefreshPage = {
296
322
  models?: RoomModels;
297
323
  documents: Readonly<Record<string, string>>;
298
324
  revisions: Readonly<Record<string, string>>;
325
+ fileIds?: Readonly<Record<string, string>>;
299
326
  changes: Readonly<Record<string, HeadChange>>;
300
327
  binaryFiles: Readonly<Record<string, BinaryFile>>;
301
328
  removals: readonly string[];
329
+ folders?: readonly string[];
330
+ folderRemovals?: readonly string[];
302
331
  pageToken?: PageToken;
303
332
  };
304
333
  export type RefreshResult = {
@@ -309,6 +338,7 @@ export type RefreshResult = {
309
338
  export type MutationRequest = {
310
339
  locator: string;
311
340
  changeBatch: ChangeBatch;
341
+ file(localId: string): Promise<Blob>;
312
342
  upload?: unknown;
313
343
  };
314
344
  export type RetryableRefusal = ProviderRefusal & {
@@ -319,17 +349,21 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
319
349
  export type ServiceModeSignal = {
320
350
  observe(notify: (mode: ServiceMode) => void): () => void;
321
351
  };
322
- export type MutationResult = {
323
- kind: 'accepted';
352
+ export type AcceptedRoom = {
324
353
  roomVersion: string;
325
354
  documents: Readonly<Record<string, string>>;
326
355
  revisions: Readonly<Record<string, string>>;
356
+ fileIds?: Readonly<Record<string, string>>;
327
357
  changes: Readonly<Record<string, HeadChange>>;
328
358
  removals: readonly string[];
329
359
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
360
+ };
361
+ export type MutationResult = (AcceptedRoom & {
362
+ kind: 'accepted';
330
363
  author?: string;
331
364
  time?: string;
332
- } | (ProviderRefusal & {
365
+ destination?: AcceptedRoom;
366
+ }) | (ProviderRefusal & {
333
367
  kind: 'conflicted';
334
368
  roomVersion?: string;
335
369
  affected: Readonly<Record<string, string>>;
@@ -346,7 +380,7 @@ export type HistoryAuthor = {
346
380
  kind: 'user';
347
381
  id: string;
348
382
  } | {
349
- kind: 'site';
383
+ kind: 'site' | 'inbox';
350
384
  id: string;
351
385
  name: string;
352
386
  };
@@ -385,15 +419,21 @@ export type BinaryRequest = {
385
419
  referrer: unknown;
386
420
  };
387
421
  export type ReferrerScope = {
388
- kind: 'room';
389
422
  locator: string;
390
423
  path?: string;
391
- } | {
392
- kind: 'conversations';
393
424
  };
394
425
  export type BinaryResult = {
395
426
  kind: 'binary';
396
- blob: Blob;
427
+ body: ReadableStream<Uint8Array>;
428
+ mediaType: string;
429
+ sha256?: string;
430
+ } | (ProviderRefusal & {
431
+ kind: 'rejected';
432
+ }) | AdapterFailure;
433
+ export type BinaryLinkResult = {
434
+ kind: 'link';
435
+ url: string;
436
+ name: string;
397
437
  } | (ProviderRefusal & {
398
438
  kind: 'rejected';
399
439
  }) | AdapterFailure;
@@ -415,17 +455,20 @@ export type ActionResult = {
415
455
  export type HeldRoom = {
416
456
  locator: string;
417
457
  roomVersion: string;
418
- documents: Readonly<Record<string, string>>;
419
- revisions: Readonly<Record<string, string>>;
420
458
  };
459
+ export type HeldRevisions = (locator: string, paths: readonly string[]) => Promise<ReadonlyMap<string, string>>;
421
460
  export type RoomStreamEvent = {
422
461
  kind: 'opened';
423
462
  } | {
424
463
  kind: 'closed';
425
464
  revoked: boolean;
465
+ lost: boolean;
426
466
  } | {
427
467
  kind: 'opening';
428
468
  expired: readonly string[];
469
+ } | {
470
+ kind: 'authority-changed';
471
+ scope?: DiscoveryScope;
429
472
  } | {
430
473
  kind: 'room-version';
431
474
  locator: string;
@@ -444,26 +487,26 @@ export type StreamReceipts = {
444
487
  }): Promise<void>;
445
488
  drop(keys: readonly string[]): Promise<void>;
446
489
  };
447
- export type AcquiredDemand = {
448
- rooms: readonly string[];
449
- conversations: boolean;
450
- };
451
490
  export type RoomStream = {
452
- hold(rooms: readonly HeldRoom[], demand: AcquiredDemand | null): void;
491
+ hold(rooms: readonly HeldRoom[]): void;
453
492
  reopen(): void;
454
493
  published(locator: string, roomVersion: string): void;
455
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
494
+ observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts, revisions: HeldRevisions): () => void;
456
495
  };
457
496
  export type Adapter = {
458
497
  readonly localSaves?: true;
459
498
  readonly exhaustiveDiscovery?: true;
499
+ readonly roomTypes?: string;
460
500
  authorize(): Promise<Authorization>;
461
- discover(authorization: Authorization): Promise<DiscoverResult>;
501
+ discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
462
502
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
463
503
  refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
464
504
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
465
505
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
466
506
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
507
+ link(authorization: Authorization, request: Extract<BinaryRequest, {
508
+ kind: 'path';
509
+ }>): Promise<BinaryLinkResult>;
467
510
  referrerScope(referrer: unknown): ReferrerScope | null;
468
511
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
469
512
  reached(locator: string, roomVersion: string, target: string): boolean;
@@ -0,0 +1,10 @@
1
+ import type { MdRuntimeClient } from './client.js';
2
+ import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
3
+ type Rows = DocumentResult | GroupResult;
4
+ export type WindowAnswer = Rows | PendingResult;
5
+ export type WindowChain = {
6
+ want(count: number): void;
7
+ close(): void;
8
+ };
9
+ export declare function chainedWindows(runtime: MdRuntimeClient, query: DocumentQuery | GroupQuery, count: number, publish: (answers: readonly (WindowAnswer | null)[], settled: boolean) => void): WindowChain;
10
+ export {};
@@ -1,10 +1,6 @@
1
- import { type Replica } from './replica.js';
2
- import { type Row } from './rows.js';
3
1
  export type DocumentChange = {
4
- locator: string;
5
- path: string;
6
- before: readonly Row[];
7
- after: readonly Row[];
2
+ readonly locator: string;
3
+ readonly path: string | null;
8
4
  };
9
5
  export type MessageChange = {
10
6
  conversation: string;
@@ -23,12 +19,15 @@ export type ChangeSet = {
23
19
  messages: readonly MessageChange[];
24
20
  conversations: readonly string[];
25
21
  };
26
- export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
22
+ type Changed = {
23
+ documents?: readonly string[] | null;
27
24
  drafts?: readonly string[];
28
25
  room?: boolean;
29
26
  queue?: boolean;
30
27
  presentation?: string;
31
- }): ChangeSet;
32
- export declare function entering(locator: string, replica: Replica, paths: readonly string[]): ChangeSet;
28
+ };
29
+ export declare function changeSet(locator: string, changed?: Changed): ChangeSet;
33
30
  export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
34
31
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
32
+ export declare function touches(set: ChangeSet, locator: string, path: string): boolean;
33
+ export {};