@agentshouse/app-bridge 0.1.0-c94ad2bcf90f7 → 0.1.0-c98040c2bf3b7
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/README.md +3 -1
- package/dist/calls.d.ts +117 -0
- package/dist/calls.js +1 -0
- package/dist/index.d.ts +27 -15
- 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/README.md
CHANGED
|
@@ -41,7 +41,9 @@ async function manageSecurity(securityPath) {
|
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
`bridge.runtime` resolves to the `MdRuntimeClient` of
|
|
44
|
-
`@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 })`.
|
|
45
47
|
|
|
46
48
|
## Test without a House
|
|
47
49
|
|
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
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import type { MdRuntimeClient } from '@agentshouse/mdruntime/client';
|
|
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
|
+
}
|
|
2
9
|
export interface HouseSyncState {
|
|
3
10
|
readonly state: string;
|
|
4
11
|
readonly providerUnreachable: boolean;
|
|
5
12
|
}
|
|
6
13
|
export interface HouseCredentialState {
|
|
7
|
-
readonly state: 'none' | 'held' | 'rejected'
|
|
14
|
+
readonly state: Open<'none' | 'held' | 'rejected'>;
|
|
8
15
|
readonly expiresAt: number | null;
|
|
9
16
|
}
|
|
10
17
|
export type HouseAnalyticsChoice = 'accept' | 'decline';
|
|
11
18
|
export interface HouseAnalytics {
|
|
12
19
|
readonly measures: boolean;
|
|
13
|
-
readonly choice: HouseAnalyticsChoice | null;
|
|
20
|
+
readonly choice: Open<HouseAnalyticsChoice> | null;
|
|
14
21
|
}
|
|
15
22
|
export interface HouseStatus {
|
|
16
23
|
readonly app: string | null;
|
|
@@ -22,11 +29,12 @@ export interface HouseStatus {
|
|
|
22
29
|
readonly credential: HouseCredentialState;
|
|
23
30
|
readonly sync: HouseSyncState | null;
|
|
24
31
|
readonly refusal: {
|
|
25
|
-
readonly
|
|
32
|
+
readonly code: string;
|
|
33
|
+
readonly retryable: boolean;
|
|
26
34
|
} | null;
|
|
27
35
|
readonly loss: string | null;
|
|
28
36
|
readonly analytics: HouseAnalytics;
|
|
29
|
-
readonly serviceMode: 'open' | 'write-halted' | null;
|
|
37
|
+
readonly serviceMode: Open<'open' | 'write-halted'> | null;
|
|
30
38
|
readonly offline: boolean;
|
|
31
39
|
}
|
|
32
40
|
export type HouseNavigationMode = 'push' | 'replace';
|
|
@@ -77,30 +85,33 @@ export type HouseExternalAnswer = {
|
|
|
77
85
|
export interface HouseRefusal {
|
|
78
86
|
readonly error: {
|
|
79
87
|
readonly code: string;
|
|
88
|
+
readonly retryable: boolean;
|
|
80
89
|
};
|
|
81
90
|
}
|
|
82
91
|
export interface HouseAppMessage {
|
|
83
92
|
readonly from: string;
|
|
84
93
|
readonly body: unknown;
|
|
85
94
|
}
|
|
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
|
-
}
|
|
95
|
+
export type HouseInstallation = Open<'accepted' | 'dismissed' | 'manual'>;
|
|
96
|
+
export type HouseNotifications = Open<'on' | 'off' | 'blocked' | 'unavailable'>;
|
|
94
97
|
export interface HouseCeremonyRefused extends Error {
|
|
95
98
|
readonly name: 'HouseCeremonyRefused';
|
|
99
|
+
readonly code: Open<'house_ceremony_refused'>;
|
|
100
|
+
readonly retryable: boolean;
|
|
96
101
|
readonly path: string | null;
|
|
97
102
|
}
|
|
98
103
|
export interface HouseNavigationRefused extends Error {
|
|
99
104
|
readonly name: 'HouseNavigationRefused';
|
|
105
|
+
readonly code: Open<'house_navigation_refused'>;
|
|
106
|
+
readonly retryable: boolean;
|
|
100
107
|
readonly address: string | null;
|
|
101
108
|
}
|
|
109
|
+
export interface HouseBrowserRefused extends Error {
|
|
110
|
+
readonly code: string;
|
|
111
|
+
readonly retryable: boolean;
|
|
112
|
+
}
|
|
102
113
|
export interface HouseBridge {
|
|
103
|
-
readonly runtime: Promise<
|
|
114
|
+
readonly runtime: Promise<HouseRuntime>;
|
|
104
115
|
address(): string | null;
|
|
105
116
|
onAddress(listener: (address: string) => void): () => void;
|
|
106
117
|
push(address: string): Promise<string>;
|
|
@@ -110,7 +121,6 @@ export interface HouseBridge {
|
|
|
110
121
|
notifications(on?: boolean): Promise<HouseNotifications>;
|
|
111
122
|
setBadge(unread: readonly string[]): Promise<void>;
|
|
112
123
|
setTab(tab: HouseTab): void;
|
|
113
|
-
readAttachment(room: string, attachment: string): Promise<HouseImageCopy | null>;
|
|
114
124
|
sourceTop(app: string, release?: string): Promise<HouseSourceTop | HouseRefusal | null>;
|
|
115
125
|
sourceDownload(app: string, release?: string): Promise<HouseSourceDownload | HouseRefusal | null>;
|
|
116
126
|
callExternal(request: HouseExternalRequest): Promise<HouseExternalAnswer | HouseRefusal | null>;
|
|
@@ -121,5 +131,7 @@ export interface HouseBridge {
|
|
|
121
131
|
messages(listener: (message: HouseAppMessage) => void): () => void;
|
|
122
132
|
analyticsConsent(choice: HouseAnalyticsChoice): void;
|
|
123
133
|
}
|
|
134
|
+
export interface HouseHeld {
|
|
135
|
+
readonly houseBridge: HouseBridge;
|
|
136
|
+
}
|
|
124
137
|
export declare const houseBridge: () => HouseBridge;
|
|
125
|
-
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-c98040c2bf3b7",
|
|
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-c24bc09d750de"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|