@agentshouse/app-bridge 0.1.0-ca4ec913df08d → 0.1.0-cb97f7eb638a2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -13
- package/dist/test-host.d.ts +1 -4
- package/dist/test-host.js +4 -11
- package/docs/families.md +8 -8
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { MdRuntimeClient } from '@agentshouse/mdruntime/client';
|
|
2
|
+
type Open<Value extends string> = Value | (string & {});
|
|
2
3
|
export interface HouseSyncState {
|
|
3
4
|
readonly state: string;
|
|
4
5
|
readonly providerUnreachable: boolean;
|
|
5
6
|
}
|
|
6
7
|
export interface HouseCredentialState {
|
|
7
|
-
readonly state: 'none' | 'held' | 'rejected'
|
|
8
|
+
readonly state: Open<'none' | 'held' | 'rejected'>;
|
|
8
9
|
readonly expiresAt: number | null;
|
|
9
10
|
}
|
|
10
11
|
export type HouseAnalyticsChoice = 'accept' | 'decline';
|
|
11
12
|
export interface HouseAnalytics {
|
|
12
13
|
readonly measures: boolean;
|
|
13
|
-
readonly choice: HouseAnalyticsChoice | null;
|
|
14
|
+
readonly choice: Open<HouseAnalyticsChoice> | null;
|
|
14
15
|
}
|
|
15
16
|
export interface HouseStatus {
|
|
16
17
|
readonly app: string | null;
|
|
@@ -22,11 +23,12 @@ export interface HouseStatus {
|
|
|
22
23
|
readonly credential: HouseCredentialState;
|
|
23
24
|
readonly sync: HouseSyncState | null;
|
|
24
25
|
readonly refusal: {
|
|
25
|
-
readonly
|
|
26
|
+
readonly code: string;
|
|
27
|
+
readonly retryable: boolean;
|
|
26
28
|
} | null;
|
|
27
29
|
readonly loss: string | null;
|
|
28
30
|
readonly analytics: HouseAnalytics;
|
|
29
|
-
readonly serviceMode: 'open' | 'write-halted' | null;
|
|
31
|
+
readonly serviceMode: Open<'open' | 'write-halted'> | null;
|
|
30
32
|
readonly offline: boolean;
|
|
31
33
|
}
|
|
32
34
|
export type HouseNavigationMode = 'push' | 'replace';
|
|
@@ -77,28 +79,31 @@ export type HouseExternalAnswer = {
|
|
|
77
79
|
export interface HouseRefusal {
|
|
78
80
|
readonly error: {
|
|
79
81
|
readonly code: string;
|
|
82
|
+
readonly retryable: boolean;
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
85
|
export interface HouseAppMessage {
|
|
83
86
|
readonly from: string;
|
|
84
87
|
readonly body: unknown;
|
|
85
88
|
}
|
|
86
|
-
export type HouseInstallation = 'accepted' | 'dismissed' | 'manual'
|
|
87
|
-
export type HouseNotifications = 'on' | 'off' | 'blocked' | 'unavailable'
|
|
88
|
-
export interface HouseImageCopy {
|
|
89
|
-
readonly attachment: string;
|
|
90
|
-
readonly copy: string;
|
|
91
|
-
readonly name: string;
|
|
92
|
-
readonly media_type: string;
|
|
93
|
-
}
|
|
89
|
+
export type HouseInstallation = Open<'accepted' | 'dismissed' | 'manual'>;
|
|
90
|
+
export type HouseNotifications = Open<'on' | 'off' | 'blocked' | 'unavailable'>;
|
|
94
91
|
export interface HouseCeremonyRefused extends Error {
|
|
95
92
|
readonly name: 'HouseCeremonyRefused';
|
|
93
|
+
readonly code: Open<'house_ceremony_refused'>;
|
|
94
|
+
readonly retryable: boolean;
|
|
96
95
|
readonly path: string | null;
|
|
97
96
|
}
|
|
98
97
|
export interface HouseNavigationRefused extends Error {
|
|
99
98
|
readonly name: 'HouseNavigationRefused';
|
|
99
|
+
readonly code: Open<'house_navigation_refused'>;
|
|
100
|
+
readonly retryable: boolean;
|
|
100
101
|
readonly address: string | null;
|
|
101
102
|
}
|
|
103
|
+
export interface HouseBrowserRefused extends Error {
|
|
104
|
+
readonly code: string;
|
|
105
|
+
readonly retryable: boolean;
|
|
106
|
+
}
|
|
102
107
|
export interface HouseBridge {
|
|
103
108
|
readonly runtime: Promise<MdRuntimeClient>;
|
|
104
109
|
address(): string | null;
|
|
@@ -110,7 +115,6 @@ export interface HouseBridge {
|
|
|
110
115
|
notifications(on?: boolean): Promise<HouseNotifications>;
|
|
111
116
|
setBadge(unread: readonly string[]): Promise<void>;
|
|
112
117
|
setTab(tab: HouseTab): void;
|
|
113
|
-
readAttachment(room: string, attachment: string): Promise<HouseImageCopy | null>;
|
|
114
118
|
sourceTop(app: string, release?: string): Promise<HouseSourceTop | HouseRefusal | null>;
|
|
115
119
|
sourceDownload(app: string, release?: string): Promise<HouseSourceDownload | HouseRefusal | null>;
|
|
116
120
|
callExternal(request: HouseExternalRequest): Promise<HouseExternalAnswer | HouseRefusal | null>;
|
|
@@ -121,5 +125,8 @@ export interface HouseBridge {
|
|
|
121
125
|
messages(listener: (message: HouseAppMessage) => void): () => void;
|
|
122
126
|
analyticsConsent(choice: HouseAnalyticsChoice): void;
|
|
123
127
|
}
|
|
128
|
+
export interface HouseHeld {
|
|
129
|
+
readonly houseBridge: HouseBridge;
|
|
130
|
+
}
|
|
124
131
|
export declare const houseBridge: () => HouseBridge;
|
|
125
132
|
export {};
|
package/dist/test-host.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MdRuntimeClient } from '@agentshouse/mdruntime/client';
|
|
2
|
-
import type { HouseAnalyticsChoice, HouseAppMessage, HouseExternalAnswer, HouseExternalRequest,
|
|
2
|
+
import type { HouseAnalyticsChoice, HouseAppMessage, HouseExternalAnswer, HouseExternalRequest, HouseNavigationMode, HouseRefusal, HouseSourceDownload, HouseSourceTop, HouseStatus, HouseTab } from './index.js';
|
|
3
3
|
export interface HouseBridgeNavigation {
|
|
4
4
|
readonly mode: HouseNavigationMode;
|
|
5
5
|
readonly address: string;
|
|
@@ -19,9 +19,6 @@ export interface HouseBridgeTestHost {
|
|
|
19
19
|
export interface HouseBridgeTestHostOptions {
|
|
20
20
|
readonly address?: string;
|
|
21
21
|
readonly status?: HouseStatus;
|
|
22
|
-
readonly images?: readonly (HouseImageCopy & {
|
|
23
|
-
readonly room: string;
|
|
24
|
-
})[];
|
|
25
22
|
readonly sources?: readonly {
|
|
26
23
|
readonly top: HouseSourceTop;
|
|
27
24
|
readonly download: HouseSourceDownload;
|
package/dist/test-host.js
CHANGED
|
@@ -16,12 +16,16 @@ function appAddress(address) {
|
|
|
16
16
|
function ceremonyRefused(path) {
|
|
17
17
|
return Object.assign(new Error('house_ceremony_refused'), {
|
|
18
18
|
name: 'HouseCeremonyRefused',
|
|
19
|
+
code: 'house_ceremony_refused',
|
|
20
|
+
retryable: false,
|
|
19
21
|
path,
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
function navigationRefused(address) {
|
|
23
25
|
return Object.assign(new Error('house_navigation_refused'), {
|
|
24
26
|
name: 'HouseNavigationRefused',
|
|
27
|
+
code: 'house_navigation_refused',
|
|
28
|
+
retryable: false,
|
|
25
29
|
address,
|
|
26
30
|
});
|
|
27
31
|
}
|
|
@@ -92,17 +96,6 @@ export function createHouseBridgeTestHost(options = {}) {
|
|
|
92
96
|
setTab(tab) {
|
|
93
97
|
tabs.push(tab);
|
|
94
98
|
},
|
|
95
|
-
readAttachment(room, attachment) {
|
|
96
|
-
const image = options.images?.find((entry) => entry.room === room && entry.attachment === attachment);
|
|
97
|
-
return Promise.resolve(image === undefined
|
|
98
|
-
? null
|
|
99
|
-
: {
|
|
100
|
-
attachment: image.attachment,
|
|
101
|
-
copy: image.copy,
|
|
102
|
-
name: image.name,
|
|
103
|
-
media_type: image.media_type,
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
99
|
sourceTop: (app) => Promise.resolve(options.sources?.find((entry) => entry.top.app_ref === app)?.top ?? null),
|
|
107
100
|
sourceDownload: (app) => Promise.resolve(options.sources?.find((entry) => entry.top.app_ref === app)?.download ?? null),
|
|
108
101
|
callExternal(request) {
|
package/docs/families.md
CHANGED
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
`'accepted'` or `'dismissed'` with the User's choice, spending that prompt;
|
|
19
19
|
otherwise, as on every iPhone and iPad, it resolves `'manual'` and the App
|
|
20
20
|
shows its own instructions. A prompt the browser refuses to show, as for a
|
|
21
|
-
call made without a click, rejects with
|
|
22
|
-
and stays ready. Call it from a click. The standard
|
|
21
|
+
call made without a click, rejects with an error named and coded by the
|
|
22
|
+
browser's own error name, with `retryable` false, and stays ready. Call it from a click. The standard
|
|
23
23
|
`display-mode: standalone` media query tells the App it runs installed.
|
|
24
24
|
- **Notifications** - House's own panel alone; an App's or a Site's call
|
|
25
|
-
rejects with an error named `HouseCeremonyRefused`. `notifications()` answers this browser
|
|
25
|
+
rejects with an error named `HouseCeremonyRefused`, carrying `code` and `retryable`. `notifications()` answers this browser
|
|
26
26
|
storage's push state: `'on'`, `'off'`, `'blocked'` where the browser refuses
|
|
27
27
|
notifications, or `'unavailable'` where it has no push, as on an iPhone or
|
|
28
28
|
iPad outside a Home-screen app. `notifications(true)` asks the browser's
|
|
29
29
|
permission and subscribes, `notifications(false)` unsubscribes, and each
|
|
30
|
-
answers the state it leaves; a failure of the browser's push service
|
|
31
|
-
|
|
30
|
+
answers the state it leaves; a failure of the browser's push service, and
|
|
31
|
+
of `setBadge`, rejects the same way. Call `notifications(true)` from a
|
|
32
32
|
click. `setBadge(unread)` takes the identifiers of the Human Notifications
|
|
33
33
|
unread in this storage and sets the icon's badge to their number, or clears
|
|
34
34
|
it at none, where the browser shows one.
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
path, its size and its `text`, or its bytes as `base64`. The browser keeps
|
|
54
54
|
each answer per App and release: a read naming a release it holds answers
|
|
55
55
|
without asking House, and keeping a newer release drops the earlier one. A
|
|
56
|
-
refusal is House's `{ error: { code } }`, `app_release_not_found` for an
|
|
56
|
+
refusal is House's `{ error: { code, retryable } }`, `app_release_not_found` for an
|
|
57
57
|
App with no release; a read House does not answer, or one that outlived
|
|
58
58
|
the browser's signed-in User, is `null`.
|
|
59
59
|
- **External calls** - `callExternal({ url, method, headers, body, slot })`
|
|
60
60
|
has House's server send an HTTPS request to one of the release's declared
|
|
61
61
|
external origins and resolves with the service's `status`, `headers` and its
|
|
62
62
|
body as `body` text or `body_base64`, or a refusal as House's
|
|
63
|
-
`{ error: { code } }`, or `null` when House does not answer. House fills in the
|
|
63
|
+
`{ error: { code, retryable } }`, or `null` when House does not answer. House fills in the
|
|
64
64
|
App and its running release; naming an account slot places the key of the
|
|
65
65
|
account the User connected to it, which the App never sees, and naming none
|
|
66
66
|
sends no key. A Site's call names no slot, and the House panel names an
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
another holder of this App sends to this User's running copies, as `from`,
|
|
70
70
|
the sender's User id, and `body`, the JSON value they sent, until the
|
|
71
71
|
function it returns is called. App code sends one through the Runtime's
|
|
72
|
-
`call('
|
|
72
|
+
`call('message.send', { to, body })` with the recipient's User id and
|
|
73
73
|
a body of at most 32 KiB of JSON; House fills in the App and relays it only
|
|
74
74
|
to copies running now, storing nothing. The panel sends none.
|
|
75
75
|
- **App screenshot read** - given an App reference, `readScreenshot(app)`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/app-bridge",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-cb97f7eb638a2",
|
|
4
4
|
"description": "Types of the agents.house App bridge House hands every App: navigation, the tab title and icon, ceremonies, installation, notifications and the icon badge, status, Site image reads, App release code, App and Site screenshot reads, and App messages, with an accessor and an in-page test host.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
22
|
+
"@agentshouse/mdruntime": "0.1.0-cb95ca2c884cf"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|