@agentshouse/app-bridge 0.1.0-cf8a685b77ec0 → 0.1.0-cfefe363de456

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 (67) hide show
  1. package/README.md +15 -12
  2. package/dist/calls.d.ts +117 -0
  3. package/dist/calls.js +1 -0
  4. package/dist/index.d.ts +151 -0
  5. package/dist/index.js +1 -0
  6. package/dist/mdmodel/blocks.d.ts +10 -0
  7. package/dist/mdmodel/condition.d.ts +149 -0
  8. package/dist/mdmodel/definition.d.ts +65 -0
  9. package/dist/mdmodel/divide.d.ts +2 -0
  10. package/dist/mdmodel/document.d.ts +15 -0
  11. package/dist/mdmodel/fields.d.ts +5 -0
  12. package/dist/mdmodel/index.d.ts +18 -0
  13. package/dist/mdmodel/paths.d.ts +17 -0
  14. package/dist/mdmodel/profile.d.ts +5 -0
  15. package/dist/mdmodel/project.d.ts +20 -0
  16. package/dist/mdmodel/references.d.ts +3 -0
  17. package/dist/mdmodel/types.d.ts +143 -0
  18. package/dist/mdmodel/validate.d.ts +7 -0
  19. package/dist/mdmodel/version.d.ts +1 -0
  20. package/dist/mdmodel/yaml.d.ts +55 -0
  21. package/dist/mdruntime/acquisition.d.ts +13 -0
  22. package/dist/mdruntime/adapter.d.ts +475 -0
  23. package/dist/mdruntime/binary.d.ts +22 -0
  24. package/dist/mdruntime/change-set.d.ts +34 -0
  25. package/dist/mdruntime/change.d.ts +88 -0
  26. package/dist/mdruntime/client.d.ts +82 -0
  27. package/dist/mdruntime/collection.d.ts +38 -0
  28. package/dist/mdruntime/connection.d.ts +139 -0
  29. package/dist/mdruntime/conversation.d.ts +104 -0
  30. package/dist/mdruntime/durability.d.ts +14 -0
  31. package/dist/mdruntime/failure.d.ts +12 -0
  32. package/dist/mdruntime/file.d.ts +19 -0
  33. package/dist/mdruntime/model.d.ts +57 -0
  34. package/dist/mdruntime/observation.d.ts +29 -0
  35. package/dist/mdruntime/open.d.ts +1 -0
  36. package/dist/mdruntime/outcome.d.ts +46 -0
  37. package/dist/mdruntime/overlay.d.ts +26 -0
  38. package/dist/mdruntime/query.d.ts +247 -0
  39. package/dist/mdruntime/reach.d.ts +44 -0
  40. package/dist/mdruntime/readiness.d.ts +52 -0
  41. package/dist/mdruntime/recovery.d.ts +24 -0
  42. package/dist/mdruntime/replica.d.ts +45 -0
  43. package/dist/mdruntime/room-draft.d.ts +143 -0
  44. package/dist/mdruntime/rows.d.ts +36 -0
  45. package/dist/mdruntime/save.d.ts +63 -0
  46. package/dist/mdruntime/search.d.ts +89 -0
  47. package/dist/mdruntime/shared.d.ts +10 -0
  48. package/dist/mdruntime/status.d.ts +26 -0
  49. package/dist/mdruntime/store.d.ts +159 -0
  50. package/dist/mdruntime/transfer.d.ts +9 -0
  51. package/dist/mdruntime/turn.d.ts +6 -0
  52. package/dist/mdruntime/wire.d.ts +206 -0
  53. package/dist/{client/src/test-host.d.ts → test-host.d.ts} +7 -8
  54. package/dist/test-host.js +200 -0
  55. package/docs/families.md +74 -34
  56. package/package.json +6 -9
  57. package/dist/client/src/bridge.d.ts +0 -38
  58. package/dist/client/src/bridge.js +0 -320
  59. package/dist/client/src/index.d.ts +0 -3
  60. package/dist/client/src/index.js +0 -2
  61. package/dist/client/src/test-host.js +0 -185
  62. package/dist/client/src/wire.d.ts +0 -215
  63. package/dist/client/src/wire.js +0 -1
  64. package/dist/src/apps/remainder.d.ts +0 -2
  65. package/dist/src/apps/remainder.js +0 -16
  66. package/dist/src/apps/tab.d.ts +0 -6
  67. package/dist/src/apps/tab.js +0 -27
package/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # @agentshouse/app-bridge
2
2
 
3
- The renderer-side client of the agents.house App bridge. An App served by House
4
- receives one message port before its own scripts run; this package is that
5
- port's one listener. It carries eleven families: navigation, ceremonies,
6
- installation, notifications, status, Site image reads, App release code,
7
- external calls, App messages and App and Site screenshot reads.
3
+ The types of the agents.house App bridge, an accessor and an in-page test host.
4
+ House builds the bridge object in every App it serves and hands it to the page
5
+ before the App's own scripts run; `houseBridge()` returns that object, so an App
6
+ carries no bridge code of its own. It carries eleven families: navigation,
7
+ ceremonies, installation, notifications, status, Site image reads, App release
8
+ code, external calls, App messages and App and Site screenshot reads.
8
9
  [docs/families.md](docs/families.md) describes each and the test host.
9
10
 
10
- The package carries no credential handling and no Runtime family. House builds
11
+ The bridge carries no credential handling and no Runtime family. House builds
11
12
  the MD Runtime client into the page beside the bridge, and `bridge.runtime`
12
13
  resolves to that client, so the App imports and constructs none.
13
14
 
@@ -16,9 +17,9 @@ House's `find_command` "App" is the guide to building an App or a Site.
16
17
  ## Use
17
18
 
18
19
  ```js
19
- import { connectHouseBridge } from '@agentshouse/app-bridge';
20
+ import { houseBridge } from '@agentshouse/app-bridge';
20
21
 
21
- const bridge = connectHouseBridge();
22
+ const bridge = houseBridge();
22
23
  const md = await bridge.runtime;
23
24
 
24
25
  bridge.onAddress((address) => render(address));
@@ -34,22 +35,24 @@ async function manageSecurity(securityPath) {
34
35
  try {
35
36
  await bridge.ceremony(securityPath);
36
37
  } catch (refusal) {
37
- report(refusal);
38
+ if (refusal.name === 'HouseCeremonyRefused') report(refusal.path);
38
39
  }
39
40
  }
40
41
  ```
41
42
 
42
43
  `bridge.runtime` resolves to the `MdRuntimeClient` of
43
- `@agentshouse/mdruntime/client`, whose README describes its members.
44
+ `@agentshouse/mdruntime/client`, whose README describes its members. Its
45
+ `call(name, input)` reaches House: `HouseCalls` names each Call an App makes
46
+ and the input it takes, such as `call('member.list', { room_ref })`.
44
47
 
45
48
  ## Test without a House
46
49
 
47
50
  ```js
48
- import { connectHouseBridge } from '@agentshouse/app-bridge';
51
+ import { houseBridge } from '@agentshouse/app-bridge';
49
52
  import { createHouseBridgeTestHost } from '@agentshouse/app-bridge/test-host';
50
53
 
51
54
  const host = createHouseBridgeTestHost({ address: '/rooms/atlas' });
52
- const bridge = connectHouseBridge(host);
55
+ const bridge = houseBridge();
53
56
 
54
57
  bridge.push('/rooms/atlas/members');
55
58
  host.open('/rooms/atlas');
@@ -0,0 +1,117 @@
1
+ export interface HouseCalls {
2
+ readonly 'access.read': {
3
+ readonly room_ref: string;
4
+ };
5
+ readonly 'conversation.answer': {
6
+ readonly answer: {
7
+ readonly interaction_id: string;
8
+ readonly response: unknown;
9
+ };
10
+ readonly conversation: string;
11
+ readonly operation_id?: string;
12
+ };
13
+ readonly 'conversation.create': {
14
+ readonly agent_id: string;
15
+ readonly operation_id?: string;
16
+ };
17
+ readonly 'conversation.delete': {
18
+ readonly conversation: string;
19
+ readonly operation_id?: string;
20
+ };
21
+ readonly 'conversation.history': {
22
+ readonly conversations: readonly {
23
+ readonly after?: string;
24
+ readonly conversation: string;
25
+ }[];
26
+ };
27
+ readonly 'conversation.interrupt': {
28
+ readonly conversation: string;
29
+ readonly operation_id?: string;
30
+ };
31
+ readonly 'conversation.kill': {
32
+ readonly conversation: string;
33
+ readonly operation_id?: string;
34
+ };
35
+ readonly 'conversation.markDone': {
36
+ readonly conversation_id?: string;
37
+ readonly result?: string;
38
+ readonly operation_id: string;
39
+ };
40
+ readonly 'conversation.rename': {
41
+ readonly conversation_id: string;
42
+ readonly operation_id: string;
43
+ readonly name: string;
44
+ };
45
+ readonly 'conversation.send': {
46
+ readonly conversation: string;
47
+ readonly files?: readonly {
48
+ readonly blob: Blob;
49
+ readonly byteLength: number;
50
+ readonly contentHash: string;
51
+ readonly height?: number;
52
+ readonly mediaType: string;
53
+ readonly name: string;
54
+ readonly width?: number;
55
+ }[];
56
+ readonly operation_id: string;
57
+ readonly text?: string;
58
+ };
59
+ readonly 'conversation.setOption': {
60
+ readonly conversation_id: string;
61
+ readonly operation_id: string;
62
+ readonly option: string;
63
+ readonly value: string | boolean;
64
+ };
65
+ readonly 'feature.list': Readonly<Record<string, never>>;
66
+ readonly 'holder.list': Readonly<Record<string, never>>;
67
+ readonly 'holder.ring': {
68
+ readonly to: string;
69
+ };
70
+ readonly 'member.list': {
71
+ readonly room_ref: string;
72
+ readonly history?: boolean;
73
+ readonly limit?: number;
74
+ readonly cursor?: string;
75
+ };
76
+ readonly 'message.send': {
77
+ readonly to: string;
78
+ readonly body: unknown;
79
+ };
80
+ readonly 'processing.read': {
81
+ readonly room_ref: string;
82
+ readonly path: string;
83
+ };
84
+ readonly 'record.list': {
85
+ readonly room_ref: string;
86
+ readonly record?: string;
87
+ readonly cursor?: string;
88
+ readonly limit?: number;
89
+ readonly order?: 'asc' | 'desc';
90
+ };
91
+ readonly 'relay.read': Readonly<Record<string, never>>;
92
+ readonly 'routine.list': {
93
+ readonly room_ref: string;
94
+ };
95
+ readonly 'routineAccess.list': {
96
+ readonly room_ref: string;
97
+ };
98
+ readonly 'routineAllowance.list': {
99
+ readonly room_ref: string;
100
+ readonly access: string;
101
+ };
102
+ readonly 'routineRequest.list': {
103
+ readonly room_ref: string;
104
+ };
105
+ readonly 'storage.read': {
106
+ readonly room_ref?: string;
107
+ };
108
+ readonly submit: {
109
+ readonly content: string;
110
+ };
111
+ readonly 'trigger.list': {
112
+ readonly room_ref: string;
113
+ };
114
+ readonly 'triggerOccurrence.list': {
115
+ readonly room_ref: string;
116
+ };
117
+ }
package/dist/calls.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,151 @@
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;
5
+ export interface HouseRuntime extends Omit<MdRuntimeClient, 'call'> {
6
+ call<Name extends Open<keyof HouseCalls>>(name: Name, input: HouseCallInput<Name>): ReturnType<MdRuntimeClient['call']>;
7
+ }
8
+ export interface HouseSyncState {
9
+ readonly state: string;
10
+ readonly providerUnreachable: boolean;
11
+ }
12
+ export interface HouseCredentialState {
13
+ readonly state: Open<'none' | 'held' | 'rejected'>;
14
+ readonly expiresAt: number | null;
15
+ }
16
+ export type HouseAnalyticsChoice = 'accept' | 'decline';
17
+ export interface HouseAnalytics {
18
+ readonly measures: boolean;
19
+ readonly choice: Open<HouseAnalyticsChoice> | null;
20
+ }
21
+ export interface HouseStatus {
22
+ readonly app: string | null;
23
+ readonly preferences: {
24
+ readonly roomRef: string;
25
+ readonly path: string;
26
+ } | null;
27
+ readonly runtime: string;
28
+ readonly credential: HouseCredentialState;
29
+ readonly sync: HouseSyncState | null;
30
+ readonly refusal: {
31
+ readonly code: string;
32
+ readonly retryable: boolean;
33
+ } | null;
34
+ readonly loss: string | null;
35
+ readonly analytics: HouseAnalytics;
36
+ readonly serviceMode: Open<'open' | 'write-halted'> | null;
37
+ readonly offline: boolean;
38
+ }
39
+ export type HouseNavigationMode = 'push' | 'replace';
40
+ export interface HouseTab {
41
+ readonly title?: string;
42
+ readonly icon?: string;
43
+ }
44
+ interface HouseRelease {
45
+ readonly app_ref: string;
46
+ readonly release: string;
47
+ }
48
+ export interface HouseSourceTop extends HouseRelease {
49
+ readonly folders: readonly string[];
50
+ readonly files: readonly {
51
+ readonly name: string;
52
+ readonly size: number;
53
+ }[];
54
+ readonly readme: string | null;
55
+ }
56
+ export type HouseSourceFile = {
57
+ readonly path: string;
58
+ readonly size: number;
59
+ } & ({
60
+ readonly text: string;
61
+ } | {
62
+ readonly base64: string;
63
+ });
64
+ export interface HouseSourceDownload extends HouseRelease {
65
+ readonly files: readonly HouseSourceFile[];
66
+ }
67
+ export interface HouseExternalRequest {
68
+ readonly url: string;
69
+ readonly method?: string;
70
+ readonly headers?: Readonly<Record<string, string>>;
71
+ readonly body?: string;
72
+ readonly body_base64?: string;
73
+ readonly account?: string;
74
+ readonly slot?: string;
75
+ }
76
+ export type HouseExternalAnswer = {
77
+ readonly status: number;
78
+ readonly headers: Readonly<Record<string, string | readonly string[]>>;
79
+ } & ({
80
+ readonly body: string;
81
+ } | {
82
+ readonly body_base64: string;
83
+ });
84
+ export interface HouseRefusal {
85
+ readonly error: {
86
+ readonly code: string;
87
+ readonly retryable: boolean;
88
+ };
89
+ }
90
+ export interface HouseAppMessage {
91
+ readonly from: string;
92
+ readonly body: unknown;
93
+ }
94
+ export type HouseInstallation = Open<'accepted' | 'dismissed' | 'manual'>;
95
+ export type HouseNotifications = Open<'on' | 'off' | 'blocked' | 'unavailable'>;
96
+ export interface HouseCeremonyRefused extends Error {
97
+ readonly name: 'HouseCeremonyRefused';
98
+ readonly code: Open<'house_ceremony_refused'>;
99
+ readonly retryable: boolean;
100
+ readonly path: string | null;
101
+ }
102
+ export interface HouseNavigationRefused extends Error {
103
+ readonly name: 'HouseNavigationRefused';
104
+ readonly code: Open<'house_navigation_refused'>;
105
+ readonly retryable: boolean;
106
+ readonly address: string | null;
107
+ }
108
+ export interface HouseBrowserRefused extends Error {
109
+ readonly code: string;
110
+ readonly retryable: boolean;
111
+ }
112
+ export interface HouseTrialWithheld {
113
+ readonly code: Open<'house_trial_withheld'>;
114
+ readonly retryable: true;
115
+ }
116
+ export type HouseTask = unknown;
117
+ export type HouseActivation = Open<'committed' | 'abandoned'>;
118
+ export interface HouseCooperation {
119
+ checkpoint(): Promise<void> | void;
120
+ persist(): Promise<void> | void;
121
+ capture(): Promise<HouseTask> | HouseTask;
122
+ restore(task: HouseTask | null): Promise<void> | void;
123
+ ready(): Promise<boolean> | boolean;
124
+ settle(activation: HouseActivation): void;
125
+ }
126
+ export interface HouseBridge {
127
+ readonly runtime: Promise<HouseRuntime>;
128
+ address(): string | null;
129
+ onAddress(listener: (address: string) => void): () => void;
130
+ push(address: string): Promise<string>;
131
+ replace(address: string): Promise<string>;
132
+ ceremony(path: string): Promise<never>;
133
+ install(): Promise<HouseInstallation>;
134
+ notifications(on?: boolean): Promise<HouseNotifications>;
135
+ setBadge(unread: readonly string[]): Promise<void>;
136
+ setTab(tab: HouseTab): void;
137
+ sourceTop(app: string, release?: string): Promise<HouseSourceTop | HouseRefusal | null>;
138
+ sourceDownload(app: string, release?: string): Promise<HouseSourceDownload | HouseRefusal | null>;
139
+ callExternal(request: HouseExternalRequest): Promise<HouseExternalAnswer | HouseRefusal | null>;
140
+ readScreenshot(app: string): Promise<Blob | null>;
141
+ readSiteScreenshot(site: string): Promise<Blob | null>;
142
+ status(): HouseStatus | null;
143
+ onStatus(listener: (status: HouseStatus) => void): () => void;
144
+ messages(listener: (message: HouseAppMessage) => void): () => void;
145
+ analyticsConsent(choice: HouseAnalyticsChoice): void;
146
+ cooperate(cooperation: HouseCooperation): () => void;
147
+ }
148
+ export interface HouseHeld {
149
+ readonly houseBridge: HouseBridge;
150
+ }
151
+ export declare const houseBridge: () => HouseBridge;
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export const houseBridge = () => globalThis.houseBridge;
@@ -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,149 @@
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 provider: string | null;
124
+ readonly container: string | null;
125
+ readonly author: string | null;
126
+ readonly headers: Readonly<Record<string, string>>;
127
+ readonly json: {
128
+ readonly value: unknown;
129
+ } | null;
130
+ };
131
+ export type Resolved = {
132
+ readonly id: string;
133
+ readonly member?: string;
134
+ };
135
+ type Truth = boolean | undefined;
136
+ export declare function factKind(facts: ValueFacts): FactKind | null;
137
+ export declare function facts(document: Document, at: {
138
+ readonly id: string;
139
+ readonly path: string;
140
+ }, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
141
+ export declare function prosePaths(facts: DocumentFacts): string[];
142
+ export declare function datePointers(fields: Readonly<Record<string, ValueFacts>>): string[];
143
+ export declare function dated(value: unknown): value is string;
144
+ export declare function instant(value: unknown): bigint | undefined;
145
+ 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;
149
+ export {};
@@ -0,0 +1,65 @@
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 Definition = {
33
+ readonly name: string;
34
+ readonly memberDocument: boolean;
35
+ readonly frontmatter: ValueFacts;
36
+ readonly fields: Readonly<Record<string, ValueFacts>>;
37
+ readonly sections: Readonly<Record<string, SectionSpec>>;
38
+ readonly shape: Shape;
39
+ };
40
+ export type Failure = {
41
+ readonly rule: string;
42
+ readonly location?: string;
43
+ };
44
+ export declare const JSON_TYPES: readonly JsonType[];
45
+ export declare const BUILT_IN_TYPE = "any";
46
+ export declare const ATTACHMENT = "attachment";
47
+ export declare const ARRAY_INDEX: RegExp;
48
+ export declare function escapePointer(key: string): string;
49
+ export declare function pointerSegments(pointer: string): string[];
50
+ export declare function refTarget(reference: string, defs: Readonly<Record<string, unknown>>): {
51
+ readonly name: string;
52
+ readonly node: unknown;
53
+ } | undefined;
54
+ export declare function valueFacts(node: unknown, defs: Readonly<Record<string, unknown>>): ValueFacts;
55
+ export declare function itemFacts(facts: ValueFacts, index: number): ValueFacts | undefined;
56
+ export declare function memberFacts(facts: ValueFacts, key: string): ValueFacts | undefined;
57
+ export type PointerFacts = {
58
+ readonly facts: ValueFacts;
59
+ readonly through: boolean;
60
+ readonly conditional: boolean;
61
+ };
62
+ export declare function crossedFacts(facts: ValueFacts): ValueFacts[];
63
+ export declare function fieldFacts(definition: Definition, key: string): ValueFacts | undefined;
64
+ export declare function pointerFacts(definition: Definition, pointer: string): PointerFacts | undefined;
65
+ 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, 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';
16
+ export { VERSION } from './version.js';
17
+ export { 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,20 @@
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 rangeText(content: string, range: Extent, edits: readonly Edit[]): string;
19
+ export declare function projectionInput(document: Document, file: string, context: ProjectionContext): InputResult;
20
+ 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[];