@agentshouse/app-bridge 0.1.0-alpha.9 → 0.1.0-c094380be07ea
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +21 -79
- package/dist/calls.d.ts +117 -0
- package/dist/calls.js +1 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +1 -0
- package/dist/mdmodel/blocks.d.ts +10 -0
- package/dist/mdmodel/condition.d.ts +149 -0
- package/dist/mdmodel/definition.d.ts +65 -0
- package/dist/mdmodel/divide.d.ts +2 -0
- package/dist/mdmodel/document.d.ts +15 -0
- package/dist/mdmodel/fields.d.ts +5 -0
- package/dist/mdmodel/index.d.ts +18 -0
- package/dist/mdmodel/paths.d.ts +17 -0
- package/dist/mdmodel/profile.d.ts +5 -0
- package/dist/mdmodel/project.d.ts +20 -0
- package/dist/mdmodel/references.d.ts +3 -0
- package/dist/mdmodel/types.d.ts +143 -0
- package/dist/mdmodel/validate.d.ts +7 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/acquisition.d.ts +13 -0
- package/dist/mdruntime/adapter.d.ts +477 -0
- package/dist/mdruntime/binary.d.ts +22 -0
- package/dist/mdruntime/change-set.d.ts +34 -0
- package/dist/mdruntime/change.d.ts +88 -0
- package/dist/mdruntime/client.d.ts +81 -0
- package/dist/mdruntime/collection.d.ts +38 -0
- package/dist/mdruntime/connection.d.ts +138 -0
- package/dist/mdruntime/conversation.d.ts +103 -0
- package/dist/mdruntime/durability.d.ts +14 -0
- package/dist/mdruntime/failure.d.ts +12 -0
- package/dist/mdruntime/file.d.ts +19 -0
- package/dist/mdruntime/model.d.ts +56 -0
- package/dist/mdruntime/observation.d.ts +29 -0
- package/dist/mdruntime/open.d.ts +1 -0
- package/dist/mdruntime/outcome.d.ts +46 -0
- package/dist/mdruntime/overlay.d.ts +26 -0
- package/dist/mdruntime/query.d.ts +246 -0
- package/dist/mdruntime/reach.d.ts +45 -0
- package/dist/mdruntime/readiness.d.ts +52 -0
- package/dist/mdruntime/recovery.d.ts +24 -0
- package/dist/mdruntime/replica.d.ts +45 -0
- package/dist/mdruntime/room-draft.d.ts +143 -0
- package/dist/mdruntime/rows.d.ts +36 -0
- package/dist/mdruntime/save.d.ts +63 -0
- package/dist/mdruntime/search.d.ts +83 -0
- package/dist/mdruntime/shared.d.ts +10 -0
- package/dist/mdruntime/status.d.ts +26 -0
- package/dist/mdruntime/store.d.ts +159 -0
- package/dist/mdruntime/transfer.d.ts +9 -0
- package/dist/mdruntime/turn.d.ts +6 -0
- package/dist/mdruntime/wire.d.ts +104 -0
- package/dist/test-host.d.ts +33 -0
- package/dist/test-host.js +200 -0
- package/docs/families.md +136 -0
- package/package.json +11 -14
- package/client/src/bridge.d.ts +0 -35
- package/client/src/bridge.js +0 -229
- package/client/src/index.d.ts +0 -3
- package/client/src/index.js +0 -2
- package/client/src/test-host.d.ts +0 -30
- package/client/src/test-host.js +0 -159
- package/client/src/wire.d.ts +0 -69
- package/client/src/wire.js +0 -1
- package/src/apps/remainder.d.ts +0 -2
- package/src/apps/remainder.js +0 -16
- package/src/apps/tab.d.ts +0 -6
- package/src/apps/tab.js +0 -27
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anton (trof3039)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,70 +1,26 @@
|
|
|
1
1
|
# @agentshouse/app-bridge
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
5
|
-
|
|
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.
|
|
9
|
+
[docs/families.md](docs/families.md) describes each and the test host.
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
sets its tab's title and icon with `setTab({ title, icon })`, either or both:
|
|
11
|
-
a title of at most 200 characters and an icon given as a base64 `data:` URL
|
|
12
|
-
of an SVG, PNG, GIF or WebP image of at most 1,048,576 characters. The shell
|
|
13
|
-
shows them over the App's display name, or a Site's title, and its tab icon
|
|
14
|
-
until the next load, and ignores a request outside those bounds.
|
|
15
|
-
- **Ceremony** - the App asks the shell to leave for one of House's own
|
|
16
|
-
purpose-bound authenticated pages. The shell navigates only to a same-origin
|
|
17
|
-
absolute path, carries its current address as the return target, and the page
|
|
18
|
-
returns there when it completes. An App names an address House gave it in a
|
|
19
|
-
reading and composes none.
|
|
20
|
-
- **Installation** - `install()` offers the page as a Home-screen app. Where the
|
|
21
|
-
browser has an install prompt ready the shell shows it and the call resolves
|
|
22
|
-
`'accepted'` or `'dismissed'` with the User's choice, spending that prompt;
|
|
23
|
-
otherwise, as on every iPhone and iPad, it resolves `'manual'` and the App
|
|
24
|
-
shows its own instructions. A prompt the browser refuses to show, as for a
|
|
25
|
-
call made without a click, rejects with the browser's own `DOMException`
|
|
26
|
-
and stays ready. Call it from a click. The standard
|
|
27
|
-
`display-mode: standalone` media query tells the App it runs installed.
|
|
28
|
-
- **Status** - the App reference the Runtime port is attached under, sync
|
|
29
|
-
state, credential state, release availability and observed failure, `ga`:
|
|
30
|
-
whether the page measures and the visitor's stored analytics choice, and
|
|
31
|
-
`service_mode`: `open`, `write-halted` while House refuses writes, so the
|
|
32
|
-
App can stop retrying them, or `null` while the runtime holds no House
|
|
33
|
-
connection.
|
|
34
|
-
The App reports the visitor's choice with `gaConsent('accept')` or
|
|
35
|
-
`gaConsent('decline')`; the shell hands it to House's analytics loader, and
|
|
36
|
-
the choice never reaches House.
|
|
37
|
-
- **Site image read** - given a Published Room and an original attachment
|
|
38
|
-
reference, it answers the web copy's path and metadata, or `null` when no
|
|
39
|
-
copy exists. The original bytes never cross this bridge at a Site.
|
|
40
|
-
- **App release code** - `sourceTop(app, release)` answers the top level of
|
|
41
|
-
the latest successful release of an App the User may use: its folders, its
|
|
42
|
-
files with their sizes and its root README's text, or `null` for none;
|
|
43
|
-
`sourceDownload(app, release)` answers every file of that release with its
|
|
44
|
-
path, its size and its `text`, or its bytes as `base64`. The browser keeps
|
|
45
|
-
each answer per App and release: a read naming a release it holds answers
|
|
46
|
-
without asking House, and keeping a newer release drops the earlier one. A
|
|
47
|
-
refusal is House's `{ error: { code } }`, `app_release_not_found` for an
|
|
48
|
-
App with no release; a read House does not answer, or one that outlived
|
|
49
|
-
the browser's signed-in User, is `null`.
|
|
50
|
-
- **App screenshot read** - given an App reference, `readScreenshot(app)`
|
|
51
|
-
answers the image this browser captured of that App's screen the first time
|
|
52
|
-
it ran its current release, as a PNG `Blob` at most 1200 pixels wide, or
|
|
53
|
-
`null` when this browser holds none. The image stays in the browser; a Site
|
|
54
|
-
holds none.
|
|
11
|
+
The bridge carries no credential handling and no Runtime family. House builds
|
|
12
|
+
the MD Runtime client into the page beside the bridge, and `bridge.runtime`
|
|
13
|
+
resolves to that client, so the App imports and constructs none.
|
|
55
14
|
|
|
56
|
-
|
|
57
|
-
the dedicated Runtime port the worker transfers over the bridge as a plain
|
|
58
|
-
message port, which the App hands to the MD Runtime client entry.
|
|
15
|
+
House's `find_command` "App" is the guide to building an App or a Site.
|
|
59
16
|
|
|
60
17
|
## Use
|
|
61
18
|
|
|
62
19
|
```js
|
|
63
|
-
import {
|
|
64
|
-
import { connectMdRuntime } from '@agentshouse/mdruntime/client';
|
|
20
|
+
import { houseBridge } from '@agentshouse/app-bridge';
|
|
65
21
|
|
|
66
|
-
const bridge =
|
|
67
|
-
const md =
|
|
22
|
+
const bridge = houseBridge();
|
|
23
|
+
const md = await bridge.runtime;
|
|
68
24
|
|
|
69
25
|
bridge.onAddress((address) => render(address));
|
|
70
26
|
bridge.onStatus((status) => showSync(status.sync));
|
|
@@ -79,39 +35,25 @@ async function manageSecurity(securityPath) {
|
|
|
79
35
|
try {
|
|
80
36
|
await bridge.ceremony(securityPath);
|
|
81
37
|
} catch (refusal) {
|
|
82
|
-
report(refusal);
|
|
38
|
+
if (refusal.name === 'HouseCeremonyRefused') report(refusal.path);
|
|
83
39
|
}
|
|
84
40
|
}
|
|
85
41
|
```
|
|
86
42
|
|
|
87
|
-
`bridge.runtime` resolves
|
|
88
|
-
|
|
89
|
-
|
|
43
|
+
`bridge.runtime` resolves to the `MdRuntimeClient` of
|
|
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 })`.
|
|
90
47
|
|
|
91
48
|
## Test without a House
|
|
92
49
|
|
|
93
50
|
```js
|
|
94
|
-
import {
|
|
51
|
+
import { houseBridge } from '@agentshouse/app-bridge';
|
|
95
52
|
import { createHouseBridgeTestHost } from '@agentshouse/app-bridge/test-host';
|
|
96
53
|
|
|
97
54
|
const host = createHouseBridgeTestHost({ address: '/rooms/atlas' });
|
|
98
|
-
const bridge =
|
|
55
|
+
const bridge = houseBridge();
|
|
99
56
|
|
|
100
57
|
bridge.push('/rooms/atlas/members');
|
|
101
58
|
host.open('/rooms/atlas');
|
|
102
59
|
```
|
|
103
|
-
|
|
104
|
-
The host plays the shell and the worker: it delivers the address the App starts
|
|
105
|
-
at and each address `open` plays as Back or Forward through the shell's own
|
|
106
|
-
slice below the App's path, admitting nothing, so it delivers `//notes` exactly
|
|
107
|
-
as a browser at `/apps/<app>//notes` does. It records every push and replace
|
|
108
|
-
and answers each with the address the shell would then show, records an
|
|
109
|
-
admitted ceremony, refuses a push, replace or ceremony that is not a
|
|
110
|
-
same-origin absolute path, publishes a status, its `service_mode` included,
|
|
111
|
-
records in `consents` each
|
|
112
|
-
`gaConsent` it takes while that status measures and publishes the status the
|
|
113
|
-
choice leaves, records in `tabs` each `setTab` the shell would take and ignores
|
|
114
|
-
any other, answers a release code read from the `sources` it was given, or
|
|
115
|
-
`null`, answers `readScreenshot` from the `screenshots` it was given by App
|
|
116
|
-
reference, answers every `install()` `'manual'`, as a browser with no install
|
|
117
|
-
prompt does, and attaches a Runtime port.
|
package/dist/calls.d.ts
ADDED
|
@@ -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 {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './mdruntime/client.js';
|
|
2
|
+
import type { HouseCalls } from './calls.js';
|
|
3
|
+
export type { HouseCalls } from './calls.js';
|
|
4
|
+
type Open<Value extends string> = Value | (string & {});
|
|
5
|
+
export type HouseCallInput<Name extends string> = Name extends keyof HouseCalls ? HouseCalls[Name] : unknown;
|
|
6
|
+
export interface HouseRuntime extends Omit<MdRuntimeClient, 'call'> {
|
|
7
|
+
call<Name extends Open<keyof HouseCalls>>(name: Name, input: HouseCallInput<Name>): ReturnType<MdRuntimeClient['call']>;
|
|
8
|
+
}
|
|
9
|
+
export interface HouseSyncState {
|
|
10
|
+
readonly state: string;
|
|
11
|
+
readonly providerUnreachable: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface HouseCredentialState {
|
|
14
|
+
readonly state: Open<'none' | 'held' | 'rejected'>;
|
|
15
|
+
readonly expiresAt: number | null;
|
|
16
|
+
}
|
|
17
|
+
export type HouseAnalyticsChoice = 'accept' | 'decline';
|
|
18
|
+
export interface HouseAnalytics {
|
|
19
|
+
readonly measures: boolean;
|
|
20
|
+
readonly choice: Open<HouseAnalyticsChoice> | null;
|
|
21
|
+
}
|
|
22
|
+
export interface HouseStatus {
|
|
23
|
+
readonly app: string | null;
|
|
24
|
+
readonly preferences: {
|
|
25
|
+
readonly roomRef: string;
|
|
26
|
+
readonly path: string;
|
|
27
|
+
} | null;
|
|
28
|
+
readonly runtime: string;
|
|
29
|
+
readonly credential: HouseCredentialState;
|
|
30
|
+
readonly sync: HouseSyncState | null;
|
|
31
|
+
readonly refusal: {
|
|
32
|
+
readonly code: string;
|
|
33
|
+
readonly retryable: boolean;
|
|
34
|
+
} | null;
|
|
35
|
+
readonly loss: string | null;
|
|
36
|
+
readonly analytics: HouseAnalytics;
|
|
37
|
+
readonly serviceMode: Open<'open' | 'write-halted'> | null;
|
|
38
|
+
readonly offline: boolean;
|
|
39
|
+
}
|
|
40
|
+
export type HouseNavigationMode = 'push' | 'replace';
|
|
41
|
+
export interface HouseTab {
|
|
42
|
+
readonly title?: string;
|
|
43
|
+
readonly icon?: string;
|
|
44
|
+
}
|
|
45
|
+
interface HouseRelease {
|
|
46
|
+
readonly app_ref: string;
|
|
47
|
+
readonly release: string;
|
|
48
|
+
}
|
|
49
|
+
export interface HouseSourceTop extends HouseRelease {
|
|
50
|
+
readonly folders: readonly string[];
|
|
51
|
+
readonly files: readonly {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly size: number;
|
|
54
|
+
}[];
|
|
55
|
+
readonly readme: string | null;
|
|
56
|
+
}
|
|
57
|
+
export type HouseSourceFile = {
|
|
58
|
+
readonly path: string;
|
|
59
|
+
readonly size: number;
|
|
60
|
+
} & ({
|
|
61
|
+
readonly text: string;
|
|
62
|
+
} | {
|
|
63
|
+
readonly base64: string;
|
|
64
|
+
});
|
|
65
|
+
export interface HouseSourceDownload extends HouseRelease {
|
|
66
|
+
readonly files: readonly HouseSourceFile[];
|
|
67
|
+
}
|
|
68
|
+
export interface HouseExternalRequest {
|
|
69
|
+
readonly url: string;
|
|
70
|
+
readonly method?: string;
|
|
71
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
72
|
+
readonly body?: string;
|
|
73
|
+
readonly body_base64?: string;
|
|
74
|
+
readonly account?: string;
|
|
75
|
+
readonly slot?: string;
|
|
76
|
+
}
|
|
77
|
+
export type HouseExternalAnswer = {
|
|
78
|
+
readonly status: number;
|
|
79
|
+
readonly headers: Readonly<Record<string, string | readonly string[]>>;
|
|
80
|
+
} & ({
|
|
81
|
+
readonly body: string;
|
|
82
|
+
} | {
|
|
83
|
+
readonly body_base64: string;
|
|
84
|
+
});
|
|
85
|
+
export interface HouseRefusal {
|
|
86
|
+
readonly error: {
|
|
87
|
+
readonly code: string;
|
|
88
|
+
readonly retryable: boolean;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export interface HouseAppMessage {
|
|
92
|
+
readonly from: string;
|
|
93
|
+
readonly body: unknown;
|
|
94
|
+
}
|
|
95
|
+
export type HouseInstallation = Open<'accepted' | 'dismissed' | 'manual'>;
|
|
96
|
+
export type HouseNotifications = Open<'on' | 'off' | 'blocked' | 'unavailable'>;
|
|
97
|
+
export interface HouseCeremonyRefused extends Error {
|
|
98
|
+
readonly name: 'HouseCeremonyRefused';
|
|
99
|
+
readonly code: Open<'house_ceremony_refused'>;
|
|
100
|
+
readonly retryable: boolean;
|
|
101
|
+
readonly path: string | null;
|
|
102
|
+
}
|
|
103
|
+
export interface HouseNavigationRefused extends Error {
|
|
104
|
+
readonly name: 'HouseNavigationRefused';
|
|
105
|
+
readonly code: Open<'house_navigation_refused'>;
|
|
106
|
+
readonly retryable: boolean;
|
|
107
|
+
readonly address: string | null;
|
|
108
|
+
}
|
|
109
|
+
export interface HouseBrowserRefused extends Error {
|
|
110
|
+
readonly code: string;
|
|
111
|
+
readonly retryable: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface HouseTrialWithheld {
|
|
114
|
+
readonly code: Open<'house_trial_withheld'>;
|
|
115
|
+
readonly retryable: true;
|
|
116
|
+
}
|
|
117
|
+
export type HouseTask = unknown;
|
|
118
|
+
export type HouseActivation = Open<'committed' | 'abandoned'>;
|
|
119
|
+
export interface HouseCooperation {
|
|
120
|
+
checkpoint(): Promise<void> | void;
|
|
121
|
+
persist(): Promise<void> | void;
|
|
122
|
+
capture(): Promise<HouseTask> | HouseTask;
|
|
123
|
+
restore(task: HouseTask | null): Promise<void> | void;
|
|
124
|
+
ready(): Promise<boolean> | boolean;
|
|
125
|
+
settle(activation: HouseActivation): void;
|
|
126
|
+
}
|
|
127
|
+
export interface HouseBridge {
|
|
128
|
+
readonly runtime: Promise<HouseRuntime>;
|
|
129
|
+
address(): string | null;
|
|
130
|
+
onAddress(listener: (address: string) => void): () => void;
|
|
131
|
+
push(address: string): Promise<string>;
|
|
132
|
+
replace(address: string): Promise<string>;
|
|
133
|
+
ceremony(path: string): Promise<never>;
|
|
134
|
+
install(): Promise<HouseInstallation>;
|
|
135
|
+
notifications(on?: boolean): Promise<HouseNotifications>;
|
|
136
|
+
setBadge(unread: readonly string[]): Promise<void>;
|
|
137
|
+
setTab(tab: HouseTab): void;
|
|
138
|
+
sourceTop(app: string, release?: string): Promise<HouseSourceTop | HouseRefusal | null>;
|
|
139
|
+
sourceDownload(app: string, release?: string): Promise<HouseSourceDownload | HouseRefusal | null>;
|
|
140
|
+
callExternal(request: HouseExternalRequest): Promise<HouseExternalAnswer | HouseRefusal | null>;
|
|
141
|
+
readScreenshot(app: string): Promise<Blob | null>;
|
|
142
|
+
readSiteScreenshot(site: string): Promise<Blob | null>;
|
|
143
|
+
status(): HouseStatus | null;
|
|
144
|
+
onStatus(listener: (status: HouseStatus) => void): () => void;
|
|
145
|
+
messages(listener: (message: HouseAppMessage) => void): () => void;
|
|
146
|
+
analyticsConsent(choice: HouseAnalyticsChoice): void;
|
|
147
|
+
cooperate(cooperation: HouseCooperation): () => void;
|
|
148
|
+
}
|
|
149
|
+
export interface HouseHeld {
|
|
150
|
+
readonly houseBridge: HouseBridge;
|
|
151
|
+
}
|
|
152
|
+
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,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;
|