@agentshouse/app-bridge 0.1.0-c58a055eeaa71 → 0.1.0-c599cdbcc172a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +4 -2
  2. package/dist/calls.d.ts +953 -0
  3. package/dist/calls.js +1 -0
  4. package/dist/index.d.ts +32 -11
  5. package/dist/mdmodel/blocks.d.ts +10 -0
  6. package/dist/mdmodel/condition.d.ts +148 -0
  7. package/dist/mdmodel/definition.d.ts +79 -0
  8. package/dist/mdmodel/divide.d.ts +2 -0
  9. package/dist/mdmodel/document.d.ts +15 -0
  10. package/dist/mdmodel/fields.d.ts +5 -0
  11. package/dist/mdmodel/index.d.ts +18 -0
  12. package/dist/mdmodel/paths.d.ts +17 -0
  13. package/dist/mdmodel/profile.d.ts +5 -0
  14. package/dist/mdmodel/project.d.ts +21 -0
  15. package/dist/mdmodel/references.d.ts +3 -0
  16. package/dist/mdmodel/types.d.ts +143 -0
  17. package/dist/mdmodel/validate.d.ts +8 -0
  18. package/dist/mdmodel/version.d.ts +1 -0
  19. package/dist/mdmodel/yaml.d.ts +55 -0
  20. package/dist/mdruntime/adapter.d.ts +492 -0
  21. package/dist/mdruntime/binary.d.ts +22 -0
  22. package/dist/mdruntime/change-set.d.ts +34 -0
  23. package/dist/mdruntime/change.d.ts +88 -0
  24. package/dist/mdruntime/client.d.ts +86 -0
  25. package/dist/mdruntime/collection.d.ts +39 -0
  26. package/dist/mdruntime/connection.d.ts +146 -0
  27. package/dist/mdruntime/conversation.d.ts +110 -0
  28. package/dist/mdruntime/durability.d.ts +14 -0
  29. package/dist/mdruntime/failure.d.ts +12 -0
  30. package/dist/mdruntime/file.d.ts +19 -0
  31. package/dist/mdruntime/model.d.ts +57 -0
  32. package/dist/mdruntime/observation.d.ts +31 -0
  33. package/dist/mdruntime/open.d.ts +1 -0
  34. package/dist/mdruntime/outcome.d.ts +52 -0
  35. package/dist/mdruntime/overlay.d.ts +28 -0
  36. package/dist/mdruntime/query.d.ts +273 -0
  37. package/dist/mdruntime/reach.d.ts +44 -0
  38. package/dist/mdruntime/readiness.d.ts +52 -0
  39. package/dist/mdruntime/recovery.d.ts +24 -0
  40. package/dist/mdruntime/replica.d.ts +50 -0
  41. package/dist/mdruntime/room-draft.d.ts +155 -0
  42. package/dist/mdruntime/rows.d.ts +38 -0
  43. package/dist/mdruntime/save.d.ts +65 -0
  44. package/dist/mdruntime/search.d.ts +104 -0
  45. package/dist/mdruntime/seed.d.ts +15 -0
  46. package/dist/mdruntime/shared.d.ts +13 -0
  47. package/dist/mdruntime/status.d.ts +26 -0
  48. package/dist/mdruntime/store.d.ts +174 -0
  49. package/dist/mdruntime/transfer.d.ts +9 -0
  50. package/dist/mdruntime/turn.d.ts +8 -0
  51. package/dist/mdruntime/wire.d.ts +222 -0
  52. package/dist/test-host.d.ts +5 -5
  53. package/dist/test-host.js +57 -22
  54. package/docs/families.md +49 -7
  55. package/package.json +1 -4
package/dist/calls.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,18 @@
1
- import type { MdRuntimeClient } from '@agentshouse/mdruntime/client';
2
- type Open<Value extends string> = Value | (string & {});
1
+ import type { MdRuntimeClient, Open } from './mdruntime/client.js';
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
+ });
13
+ export interface HouseRuntime extends Omit<MdRuntimeClient, 'call'> {
14
+ call<Name extends Open<keyof HouseMethods>>(method: Name, params: HouseParams<Name>): Promise<HouseResult<Name>>;
15
+ }
3
16
  export interface HouseSyncState {
4
17
  readonly state: string;
5
18
  readonly providerUnreachable: boolean;
@@ -67,6 +80,7 @@ export interface HouseExternalRequest {
67
80
  readonly body_base64?: string;
68
81
  readonly account?: string;
69
82
  readonly slot?: string;
83
+ readonly room_ref?: string;
70
84
  }
71
85
  export type HouseExternalAnswer = {
72
86
  readonly status: number;
@@ -88,12 +102,6 @@ export interface HouseAppMessage {
88
102
  }
89
103
  export type HouseInstallation = Open<'accepted' | 'dismissed' | 'manual'>;
90
104
  export type HouseNotifications = Open<'on' | 'off' | 'blocked' | 'unavailable'>;
91
- export interface HouseImageCopy {
92
- readonly attachment: string;
93
- readonly copy: string;
94
- readonly name: string;
95
- readonly media_type: string;
96
- }
97
105
  export interface HouseCeremonyRefused extends Error {
98
106
  readonly name: 'HouseCeremonyRefused';
99
107
  readonly code: Open<'house_ceremony_refused'>;
@@ -110,8 +118,22 @@ export interface HouseBrowserRefused extends Error {
110
118
  readonly code: string;
111
119
  readonly retryable: boolean;
112
120
  }
121
+ export interface HouseTrialWithheld {
122
+ readonly code: Open<'house_trial_withheld'>;
123
+ readonly retryable: true;
124
+ }
125
+ export type HouseTask = unknown;
126
+ export type HouseActivation = Open<'committed' | 'abandoned'>;
127
+ export interface HouseCooperation {
128
+ checkpoint(): Promise<void> | void;
129
+ persist(): Promise<void> | void;
130
+ capture(): Promise<HouseTask> | HouseTask;
131
+ restore(task: HouseTask | null): Promise<void> | void;
132
+ ready(): Promise<boolean> | boolean;
133
+ settle(activation: HouseActivation): void;
134
+ }
113
135
  export interface HouseBridge {
114
- readonly runtime: Promise<MdRuntimeClient>;
136
+ readonly runtime: Promise<HouseRuntime>;
115
137
  address(): string | null;
116
138
  onAddress(listener: (address: string) => void): () => void;
117
139
  push(address: string): Promise<string>;
@@ -121,7 +143,6 @@ export interface HouseBridge {
121
143
  notifications(on?: boolean): Promise<HouseNotifications>;
122
144
  setBadge(unread: readonly string[]): Promise<void>;
123
145
  setTab(tab: HouseTab): void;
124
- readAttachment(room: string, attachment: string): Promise<HouseImageCopy | null>;
125
146
  sourceTop(app: string, release?: string): Promise<HouseSourceTop | HouseRefusal | null>;
126
147
  sourceDownload(app: string, release?: string): Promise<HouseSourceDownload | HouseRefusal | null>;
127
148
  callExternal(request: HouseExternalRequest): Promise<HouseExternalAnswer | HouseRefusal | null>;
@@ -131,9 +152,9 @@ export interface HouseBridge {
131
152
  onStatus(listener: (status: HouseStatus) => void): () => void;
132
153
  messages(listener: (message: HouseAppMessage) => void): () => void;
133
154
  analyticsConsent(choice: HouseAnalyticsChoice): void;
155
+ cooperate(cooperation: HouseCooperation): () => void;
134
156
  }
135
157
  export interface HouseHeld {
136
158
  readonly houseBridge: HouseBridge;
137
159
  }
138
160
  export declare const houseBridge: () => HouseBridge;
139
- export {};
@@ -0,0 +1,10 @@
1
+ import type { Extent } from './types.js';
2
+ export type HeadingLine = {
3
+ readonly level: number;
4
+ readonly name: string;
5
+ readonly start: number;
6
+ readonly textEnd: number;
7
+ readonly next: number;
8
+ };
9
+ export declare function headingLines(content: string, from: number, to: number): HeadingLine[];
10
+ export declare function blockRanges(content: string, from: number, to: number): Extent[];
@@ -0,0 +1,148 @@
1
+ import { type ValueFacts } from './definition.js';
2
+ import type { Document, VerifiedModel } from './types.js';
3
+ export type ConditionValue = string | number | boolean | {
4
+ readonly owner: true;
5
+ };
6
+ export type ConditionTest = {
7
+ readonly all: readonly ConditionTest[];
8
+ } | {
9
+ readonly any: readonly ConditionTest[];
10
+ } | {
11
+ readonly not: ConditionTest;
12
+ } | ({
13
+ readonly path: string;
14
+ } & ({
15
+ readonly eq: ConditionValue;
16
+ } | {
17
+ readonly in: readonly ConditionValue[];
18
+ } | {
19
+ readonly exists: boolean;
20
+ } | {
21
+ readonly contains: ConditionValue;
22
+ } | {
23
+ readonly gt: number | string;
24
+ } | {
25
+ readonly gte: number | string;
26
+ } | {
27
+ readonly lt: number | string;
28
+ } | {
29
+ readonly lte: number | string;
30
+ } | {
31
+ readonly prefix: string;
32
+ }));
33
+ export type ConditionScope = {
34
+ readonly type: string;
35
+ } | {
36
+ readonly folder: string;
37
+ } | {
38
+ readonly document: string;
39
+ };
40
+ type DocumentEventBase = {
41
+ readonly on: 'documents';
42
+ readonly scope: ConditionScope;
43
+ readonly by?: ConditionTest;
44
+ };
45
+ export type DocumentCondition = (DocumentEventBase & {
46
+ readonly mode: 'starts_matching';
47
+ readonly new_documents: boolean;
48
+ readonly match: ConditionTest;
49
+ }) | (DocumentEventBase & {
50
+ readonly mode: 'field_changes';
51
+ readonly field: string;
52
+ readonly from?: readonly ConditionValue[] | 'new';
53
+ readonly to?: readonly ConditionValue[] | 'deleted';
54
+ readonly match?: ConditionTest;
55
+ });
56
+ export type ItemCondition = {
57
+ readonly on: 'items';
58
+ readonly source?: string;
59
+ readonly address?: string;
60
+ readonly match?: ConditionTest;
61
+ };
62
+ export type CronCondition = {
63
+ readonly on: 'clock';
64
+ readonly cron: string;
65
+ readonly time_zone: string;
66
+ };
67
+ export type DateCondition = {
68
+ readonly on: 'clock';
69
+ readonly scope: {
70
+ readonly type: string;
71
+ };
72
+ readonly date: string;
73
+ readonly days: number;
74
+ readonly at: string;
75
+ readonly time_zone: string;
76
+ readonly match?: ConditionTest;
77
+ };
78
+ export type Condition = DocumentCondition | ItemCondition | CronCondition | DateCondition;
79
+ export type FactKind = 'string' | 'number' | 'boolean' | 'date' | 'time' | 'enum' | 'reference';
80
+ type Scalar = string | number | boolean;
81
+ export type Fact = {
82
+ readonly kind: FactKind;
83
+ readonly value: Scalar;
84
+ readonly member?: string;
85
+ } | {
86
+ readonly kind: 'prose';
87
+ } | {
88
+ readonly kind: 'null';
89
+ } | {
90
+ readonly kind: 'unreadable';
91
+ } | {
92
+ readonly kind: 'list';
93
+ readonly items: readonly Fact[];
94
+ } | {
95
+ readonly kind: 'object';
96
+ readonly fields: Readonly<Record<string, Fact>>;
97
+ };
98
+ export type DocumentFacts = {
99
+ readonly id: string;
100
+ readonly path: string;
101
+ readonly type: string | null;
102
+ readonly fields: Readonly<Record<string, Fact>>;
103
+ readonly sections: readonly string[];
104
+ };
105
+ export declare const WRITE_DOORS: readonly ['browser', 'agent', 'client'];
106
+ export type WriteDoor = (typeof WRITE_DOORS)[number];
107
+ export type Actor = {
108
+ readonly user?: string;
109
+ readonly site?: string;
110
+ readonly door?: WriteDoor;
111
+ };
112
+ export type DocumentEvent = {
113
+ readonly before: DocumentFacts | null;
114
+ readonly after: DocumentFacts | null;
115
+ readonly changed: readonly string[];
116
+ readonly by: Actor;
117
+ };
118
+ export type ItemFacts = {
119
+ readonly delivery: string;
120
+ readonly source: string | null;
121
+ readonly address: string | null;
122
+ readonly has_attachment: boolean;
123
+ readonly container: string | null;
124
+ readonly author: string | null;
125
+ readonly headers: Readonly<Record<string, string>>;
126
+ readonly json: {
127
+ readonly value: unknown;
128
+ } | null;
129
+ };
130
+ export type Resolved = {
131
+ readonly id: string;
132
+ readonly member?: string;
133
+ };
134
+ type Truth = boolean | undefined;
135
+ export declare function factKind(facts: ValueFacts): FactKind | null;
136
+ export declare function facts(document: Document, at: {
137
+ readonly id: string;
138
+ readonly path: string;
139
+ }, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
140
+ export declare function prosePaths(facts: DocumentFacts): string[];
141
+ export declare function datePointers(fields: Readonly<Record<string, ValueFacts>>): string[];
142
+ export declare function dated(value: unknown): value is string;
143
+ export declare function instant(value: unknown): bigint | undefined;
144
+ export declare function pointed(value: unknown, pointer: string): unknown;
145
+ export declare function holds(test: ConditionTest, document: DocumentFacts, owner: string): Truth;
146
+ export declare function fires(condition: DocumentCondition, event: DocumentEvent, owner: string): boolean;
147
+ export declare function itemFires(condition: ItemCondition, item: ItemFacts, owner: string): boolean;
148
+ export {};
@@ -0,0 +1,79 @@
1
+ import type { VerifiedModel } from './types.js';
2
+ export type JsonType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
3
+ export type ValueFacts = {
4
+ readonly type?: JsonType;
5
+ readonly format?: string;
6
+ readonly values?: readonly unknown[];
7
+ readonly reference?: readonly string[];
8
+ readonly prose: boolean;
9
+ readonly conditional?: true;
10
+ readonly prefix?: readonly ValueFacts[];
11
+ readonly items?: ValueFacts;
12
+ readonly properties?: Readonly<Record<string, ValueFacts>>;
13
+ readonly patterns?: readonly PatternFacts[];
14
+ readonly additional?: ValueFacts;
15
+ };
16
+ export type PatternFacts = {
17
+ readonly pattern: string;
18
+ readonly facts: ValueFacts;
19
+ };
20
+ export type SectionSpec = {
21
+ readonly kind: 'text';
22
+ readonly required: boolean;
23
+ } | {
24
+ readonly kind: 'list';
25
+ readonly required: boolean;
26
+ readonly items: ValueFacts;
27
+ };
28
+ export type Shape = {
29
+ readonly schema: Readonly<Record<string, unknown>>;
30
+ readonly defs: Readonly<Record<string, unknown>>;
31
+ };
32
+ export type RuleValue = string | number | boolean | null;
33
+ export type Transition = {
34
+ readonly from: RuleValue;
35
+ readonly to: RuleValue;
36
+ readonly roles?: readonly string[];
37
+ };
38
+ export type FieldRules = {
39
+ readonly changeRoles?: readonly string[];
40
+ readonly initialRoles?: readonly string[];
41
+ readonly transitions?: readonly Transition[];
42
+ };
43
+ export type Definition = {
44
+ readonly name: string;
45
+ readonly memberDocument: boolean;
46
+ readonly frontmatter: ValueFacts;
47
+ readonly fields: Readonly<Record<string, ValueFacts>>;
48
+ readonly sections: Readonly<Record<string, SectionSpec>>;
49
+ readonly rules: Readonly<Record<string, FieldRules>>;
50
+ readonly createRoles?: readonly string[];
51
+ readonly deleteRoles?: readonly string[];
52
+ readonly shape: Shape;
53
+ };
54
+ export type Failure = {
55
+ readonly rule: string;
56
+ readonly location?: string;
57
+ };
58
+ export declare const JSON_TYPES: readonly JsonType[];
59
+ export declare const BUILT_IN_TYPE = "any";
60
+ export declare const ATTACHMENT = "attachment";
61
+ export declare const ARRAY_INDEX: RegExp;
62
+ export declare function escapePointer(key: string): string;
63
+ export declare function pointerSegments(pointer: string): string[];
64
+ export declare function refTarget(reference: string, defs: Readonly<Record<string, unknown>>): {
65
+ readonly name: string;
66
+ readonly node: unknown;
67
+ } | undefined;
68
+ export declare function valueFacts(node: unknown, defs: Readonly<Record<string, unknown>>): ValueFacts;
69
+ export declare function itemFacts(facts: ValueFacts, index: number): ValueFacts | undefined;
70
+ export declare function memberFacts(facts: ValueFacts, key: string): ValueFacts | undefined;
71
+ export type PointerFacts = {
72
+ readonly facts: ValueFacts;
73
+ readonly through: boolean;
74
+ readonly conditional: boolean;
75
+ };
76
+ export declare function crossedFacts(facts: ValueFacts): ValueFacts[];
77
+ export declare function fieldFacts(definition: Definition, key: string): ValueFacts | undefined;
78
+ export declare function pointerFacts(definition: Definition, pointer: string): PointerFacts | undefined;
79
+ export declare function readSchema(text: string): VerifiedModel | Failure;
@@ -0,0 +1,2 @@
1
+ import type { Division, DivisionContext, Document } from './types.js';
2
+ export declare function divide(document: Document, file: string, context: DivisionContext): Division;
@@ -0,0 +1,15 @@
1
+ import { type Definition } from './definition.js';
2
+ import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, LinkOccurrence, ParseResult } from './types.js';
3
+ import { type YamlMap } from './yaml.js';
4
+ export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
5
+ export declare function parse(content: string, file?: string): ParseResult;
6
+ export declare function relativize(document: Document, file: string, handle: string, definition?: Definition): ApplyResult;
7
+ export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
8
+ export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
9
+ export declare function links(document: Document, file: string): readonly Link[];
10
+ export declare function linkOccurrences(document: Document, file: string): readonly LinkOccurrence[];
11
+ export declare function bodyLinks(body: string, file: string): readonly Link[];
12
+ export declare function apply(document: Document, change: Change): ApplyResult;
13
+ export declare function serialize(document: Document): string;
14
+ export declare function fieldStart(document: Document, pointer: string): number | undefined;
15
+ export declare function frontmatter(document: Document): YamlMap | null;
@@ -0,0 +1,5 @@
1
+ export declare const TYPE_FIELD = "type";
2
+ export declare const MEMBER_FIELD = "member";
3
+ export declare const SITE_FIELD = "site";
4
+ export declare const RECEIVED_FIELD = "received";
5
+ export declare const HOUSE_FIELDS: readonly string[];
@@ -0,0 +1,18 @@
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';
3
+ export { headingLines } from './blocks.js';
4
+ export type { HeadingLine } from './blocks.js';
5
+ export { divide } from './divide.js';
6
+ export { apply, bodyLinks, fieldStart, linkOccurrences, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
7
+ export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
8
+ export { relative, retarget, target } from './paths.js';
9
+ export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
10
+ export { project } from './project.js';
11
+ export { references } from './references.js';
12
+ export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
13
+ 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, validating, verify, } from './validate.js';
16
+ export { VERSION } from './version.js';
17
+ export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
18
+ export type { FrontmatterValue } from './yaml.js';
@@ -0,0 +1,17 @@
1
+ export declare function dirname(path: string): string;
2
+ export declare function join(base: string, relative: string): string;
3
+ export declare function normalize(path: string): string | null;
4
+ export declare function destinationPath(href: string): string | null;
5
+ export declare function classifyHref(from: string, href: string): {
6
+ kind: 'skip';
7
+ } | {
8
+ kind: 'path';
9
+ path: string;
10
+ } | {
11
+ kind: 'invalid';
12
+ };
13
+ export declare function target(from: string, href: string): string | null;
14
+ export declare function retarget(href: string, to: string): string;
15
+ export declare function relative(from: string, target: string): string;
16
+ export declare const SHELL_ROOMS = "/rooms/";
17
+ export declare function shellTarget(href: string, handle: string): string | null;
@@ -0,0 +1,5 @@
1
+ export declare const MARKDOWN_SYNTAX_PROFILE: {
2
+ readonly name: 'GitHub Flavored Markdown';
3
+ readonly spec: '0.29';
4
+ readonly url: 'https://github.github.com/gfm/';
5
+ };
@@ -0,0 +1,21 @@
1
+ import type { Document, Extent, Projection, ProjectionContext, Refusal } from './types.js';
2
+ export type Piece = Extent & {
3
+ readonly text: string;
4
+ };
5
+ export type Edit = Piece;
6
+ export type Input = {
7
+ readonly values: readonly Piece[];
8
+ readonly ranges: readonly Extent[];
9
+ readonly edits: readonly Edit[];
10
+ };
11
+ export type InputResult = {
12
+ readonly ok: true;
13
+ readonly input: Input;
14
+ } | {
15
+ readonly ok: false;
16
+ readonly refusal: Refusal;
17
+ };
18
+ export declare function firstEditFrom(edits: readonly Edit[], start: number): number;
19
+ export declare function rangeText(content: string, range: Extent, edits: readonly Edit[]): string;
20
+ export declare function projectionInput(document: Document, file: string, context: ProjectionContext): InputResult;
21
+ export declare function project(document: Document, file: string, context?: ProjectionContext): Projection;
@@ -0,0 +1,3 @@
1
+ import { type Definition } from './definition.js';
2
+ import type { Frontmatter, Reference } from './types.js';
3
+ export declare function references(document: Pick<Frontmatter, 'fields'>, definition: Definition): readonly Reference[];
@@ -0,0 +1,143 @@
1
+ import type { Definition } from './definition.js';
2
+ export type Library = Readonly<Record<string, string>>;
3
+ export type VerifiedModel = {
4
+ readonly types: Readonly<Record<string, Definition>>;
5
+ };
6
+ export type ModelVerification = {
7
+ readonly verdict: 'accept';
8
+ readonly model: VerifiedModel;
9
+ } | {
10
+ readonly verdict: 'refuse';
11
+ readonly rule: string;
12
+ readonly location?: string;
13
+ };
14
+ export type ValidationContext = {
15
+ readonly binaryTargets: readonly string[];
16
+ };
17
+ export type ProjectionContext = {
18
+ readonly documentTargets: readonly string[];
19
+ readonly definition?: Definition;
20
+ };
21
+ export type DivisionContext = ProjectionContext & {
22
+ readonly budget: number;
23
+ };
24
+ export type Extent = {
25
+ readonly start: number;
26
+ readonly end: number;
27
+ };
28
+ export type Span = Extent & {
29
+ readonly text: string;
30
+ };
31
+ export type Frontmatter = {
32
+ readonly content: string;
33
+ readonly type: string | undefined;
34
+ readonly fields: Readonly<Record<string, unknown>>;
35
+ };
36
+ export type Document = Frontmatter & {
37
+ readonly preamble: string;
38
+ readonly sections: Readonly<Record<string, string>>;
39
+ };
40
+ export type Refusal = {
41
+ readonly file: string;
42
+ readonly rule: string;
43
+ readonly location?: string;
44
+ readonly referrers?: readonly string[];
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
+ };
58
+ export type Validation = {
59
+ readonly verdict: 'accept';
60
+ } | ({
61
+ readonly verdict: 'refuse';
62
+ } & Refusal);
63
+ export type Projection = {
64
+ readonly ok: true;
65
+ readonly text: string;
66
+ } | {
67
+ readonly ok: false;
68
+ readonly refusal: Refusal;
69
+ };
70
+ export type Division = {
71
+ readonly ok: true;
72
+ readonly spans: readonly Span[];
73
+ } | {
74
+ readonly ok: false;
75
+ readonly refusal: Refusal;
76
+ };
77
+ export type FrontmatterResult = {
78
+ readonly ok: true;
79
+ readonly frontmatter: Frontmatter;
80
+ } | {
81
+ readonly ok: false;
82
+ readonly refusal: Refusal;
83
+ };
84
+ export type ParseResult = {
85
+ readonly ok: true;
86
+ readonly document: Document;
87
+ } | {
88
+ readonly ok: false;
89
+ readonly refusal: Refusal;
90
+ };
91
+ export type Link = {
92
+ readonly href: string;
93
+ readonly target: string;
94
+ };
95
+ export type LinkOccurrence = Link & {
96
+ readonly start: number;
97
+ };
98
+ export type Reference = {
99
+ readonly pointer: string;
100
+ readonly value: string;
101
+ readonly to: readonly string[];
102
+ };
103
+ export type Change = {
104
+ readonly kind: 'field';
105
+ readonly name: string;
106
+ readonly value: unknown;
107
+ readonly prior: unknown;
108
+ } | {
109
+ readonly kind: 'section';
110
+ readonly name: string;
111
+ readonly value: string;
112
+ readonly prior: string;
113
+ } | {
114
+ readonly kind: 'preamble';
115
+ readonly value: string;
116
+ readonly prior: string;
117
+ } | {
118
+ readonly kind: 'link';
119
+ readonly href: string;
120
+ readonly to: string;
121
+ } | {
122
+ readonly kind: 'reference';
123
+ readonly pointer: string;
124
+ readonly value: string;
125
+ readonly prior: string;
126
+ };
127
+ export type ApplyResult = {
128
+ readonly outcome: 'applied';
129
+ readonly document: Document;
130
+ } | {
131
+ readonly outcome: 'stale';
132
+ readonly document: Document;
133
+ } | {
134
+ readonly outcome: 'refuse';
135
+ readonly refusal: Refusal;
136
+ };
137
+ export type BodyResult = {
138
+ readonly outcome: 'applied';
139
+ readonly body: string;
140
+ } | {
141
+ readonly outcome: 'refuse';
142
+ readonly refusal: Refusal;
143
+ };
@@ -0,0 +1,8 @@
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;
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[];
7
+ export declare function validating(library: Library, context?: ValidationContext, model?: VerifiedModel): Generator<string, Validation, void>;
8
+ export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
@@ -0,0 +1 @@
1
+ export declare const VERSION = "0.1.0-alpha.19";
@@ -0,0 +1,55 @@
1
+ export declare class YamlError extends Error {
2
+ readonly offset: number;
3
+ constructor(offset: number);
4
+ }
5
+ export type YamlScalar = {
6
+ readonly kind: 'scalar';
7
+ readonly value: string | number | boolean | null;
8
+ readonly start: number;
9
+ readonly end: number;
10
+ };
11
+ export type YamlSeq = {
12
+ readonly kind: 'seq';
13
+ readonly items: readonly YamlNode[];
14
+ readonly start: number;
15
+ readonly end: number;
16
+ };
17
+ export type YamlEntry = {
18
+ readonly key: string;
19
+ readonly after: number;
20
+ readonly value: YamlNode;
21
+ };
22
+ export type YamlMap = {
23
+ readonly kind: 'map';
24
+ readonly entries: readonly YamlEntry[];
25
+ readonly start: number;
26
+ readonly end: number;
27
+ };
28
+ export type YamlNode = YamlScalar | YamlSeq | YamlMap;
29
+ export declare function interpretPlain(text: string): string | number | boolean | null;
30
+ export declare function parseYamlMapping(text: string, start: number, end: number): YamlMap;
31
+ export declare function jsValue(node: YamlNode): unknown;
32
+ export declare function mapEntry(map: YamlMap, key: string): YamlEntry | undefined;
33
+ export declare function isPlainSafe(text: string): boolean;
34
+ export type FrontmatterValue = string | number | boolean | null | readonly FrontmatterValue[] | {
35
+ readonly [name: string]: FrontmatterValue;
36
+ };
37
+ export declare function plain(value: unknown): value is Record<string, unknown>;
38
+ export declare function frontmatterValue(value: unknown): value is FrontmatterValue;
39
+ export declare function serializeJs(value: FrontmatterValue): string;
40
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
41
+ export declare function serializeKey(name: string): string;
42
+ export declare function bodyStartAfterYaml(content: string, yamlEnd: number): number;
43
+ export declare function bodyStartOf(content: string): number;
44
+ export declare function bodyAfterFrontmatter(content: string): string;
45
+ export declare function extractFrontmatter(content: string): {
46
+ kind: 'none';
47
+ } | {
48
+ kind: 'unclosed';
49
+ } | {
50
+ kind: 'ok';
51
+ yamlStart: number;
52
+ yamlEnd: number;
53
+ };
54
+ export declare function equalValue(left: unknown, right: unknown): boolean;
55
+ export declare function lineEnding(content: string): '\n' | '\r\n';