@agentshouse/app-bridge 0.1.0-cf2e2ca943fbc → 0.1.0-cf304386b60e3

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 (101) hide show
  1. package/README.md +21 -16
  2. package/dist/index.d.ts +1075 -0
  3. package/dist/index.js +1 -0
  4. package/dist/mdmodel/blocks.d.ts +10 -0
  5. package/dist/mdmodel/definition.d.ts +81 -0
  6. package/dist/mdmodel/divide.d.ts +2 -0
  7. package/dist/mdmodel/document.d.ts +16 -0
  8. package/dist/mdmodel/event.d.ts +77 -0
  9. package/dist/mdmodel/facts.d.ts +14 -0
  10. package/dist/mdmodel/fields.d.ts +5 -0
  11. package/dist/mdmodel/index.d.ts +33 -0
  12. package/dist/mdmodel/kinds.d.ts +18 -0
  13. package/dist/mdmodel/links.d.ts +28 -0
  14. package/dist/mdmodel/paths.d.ts +25 -0
  15. package/dist/mdmodel/pattern.d.ts +9 -0
  16. package/dist/mdmodel/profile.d.ts +5 -0
  17. package/dist/mdmodel/project.d.ts +21 -0
  18. package/dist/mdmodel/query/language.d.ts +253 -0
  19. package/dist/mdmodel/query/match.d.ts +13 -0
  20. package/dist/mdmodel/query/rows.d.ts +31 -0
  21. package/dist/mdmodel/query/sql.d.ts +38 -0
  22. package/dist/mdmodel/references.d.ts +3 -0
  23. package/dist/mdmodel/reserved.d.ts +4 -0
  24. package/dist/mdmodel/types.d.ts +178 -0
  25. package/dist/mdmodel/validate.d.ts +33 -0
  26. package/dist/mdmodel/version.d.ts +1 -0
  27. package/dist/mdmodel/yaml.d.ts +55 -0
  28. package/dist/mdruntime/adapter.d.ts +546 -0
  29. package/dist/mdruntime/attached-model.d.ts +7 -0
  30. package/dist/mdruntime/binary.d.ts +17 -0
  31. package/dist/mdruntime/bootstrap.d.ts +43 -0
  32. package/dist/mdruntime/chain.d.ts +11 -0
  33. package/dist/mdruntime/change-set.d.ts +27 -0
  34. package/dist/mdruntime/change.d.ts +119 -0
  35. package/dist/mdruntime/client.d.ts +100 -0
  36. package/dist/mdruntime/collection.d.ts +28 -0
  37. package/dist/mdruntime/compile.d.ts +15 -0
  38. package/dist/mdruntime/connection.d.ts +129 -0
  39. package/dist/mdruntime/conversation-row.d.ts +32 -0
  40. package/dist/mdruntime/conversation.d.ts +127 -0
  41. package/dist/mdruntime/durability.d.ts +17 -0
  42. package/dist/mdruntime/failure.d.ts +12 -0
  43. package/dist/mdruntime/figures.d.ts +47 -0
  44. package/dist/mdruntime/identity.d.ts +5 -0
  45. package/dist/mdruntime/job.d.ts +32 -0
  46. package/dist/mdruntime/live.d.ts +22 -0
  47. package/dist/mdruntime/log.d.ts +5 -0
  48. package/dist/mdruntime/media.d.ts +7 -0
  49. package/dist/mdruntime/messages.d.ts +51 -0
  50. package/dist/mdruntime/model.d.ts +55 -0
  51. package/dist/mdruntime/observation.d.ts +44 -0
  52. package/dist/mdruntime/open.d.ts +1 -0
  53. package/dist/mdruntime/opened.d.ts +21 -0
  54. package/dist/mdruntime/outcome.d.ts +85 -0
  55. package/dist/mdruntime/overlay.d.ts +25 -0
  56. package/dist/mdruntime/query.d.ts +88 -0
  57. package/dist/mdruntime/reach.d.ts +53 -0
  58. package/dist/mdruntime/readiness.d.ts +49 -0
  59. package/dist/mdruntime/reads.d.ts +35 -0
  60. package/dist/mdruntime/recovery.d.ts +25 -0
  61. package/dist/mdruntime/refresh.d.ts +26 -0
  62. package/dist/mdruntime/replica.d.ts +67 -0
  63. package/dist/mdruntime/room-draft.d.ts +174 -0
  64. package/dist/mdruntime/room-drafts.d.ts +28 -0
  65. package/dist/mdruntime/save.d.ts +102 -0
  66. package/dist/mdruntime/saves.d.ts +95 -0
  67. package/dist/mdruntime/search.d.ts +21 -0
  68. package/dist/mdruntime/seed.d.ts +29 -0
  69. package/dist/mdruntime/socket/admission.d.ts +6 -0
  70. package/dist/mdruntime/socket/answers.d.ts +5 -0
  71. package/dist/mdruntime/socket.d.ts +42 -0
  72. package/dist/mdruntime/source.d.ts +60 -0
  73. package/dist/mdruntime/status.d.ts +25 -0
  74. package/dist/mdruntime/store/fences.d.ts +15 -0
  75. package/dist/mdruntime/store/installs.d.ts +29 -0
  76. package/dist/mdruntime/store/records.d.ts +211 -0
  77. package/dist/mdruntime/store/room-held.d.ts +7 -0
  78. package/dist/mdruntime/store/watchers.d.ts +14 -0
  79. package/dist/mdruntime/store/writes.d.ts +23 -0
  80. package/dist/mdruntime/store.d.ts +86 -0
  81. package/dist/mdruntime/stored.d.ts +155 -0
  82. package/dist/mdruntime/tables.d.ts +406 -0
  83. package/dist/mdruntime/tallies.d.ts +17 -0
  84. package/dist/mdruntime/transfer.d.ts +4 -0
  85. package/dist/mdruntime/turn.d.ts +8 -0
  86. package/dist/mdruntime/wire.d.ts +249 -0
  87. package/dist/{client/src/test-host.d.ts → test-host.d.ts} +10 -8
  88. package/dist/test-host.js +190 -0
  89. package/docs/families.md +101 -45
  90. package/package.json +12 -10
  91. package/dist/client/src/bridge.d.ts +0 -38
  92. package/dist/client/src/bridge.js +0 -320
  93. package/dist/client/src/index.d.ts +0 -3
  94. package/dist/client/src/index.js +0 -2
  95. package/dist/client/src/test-host.js +0 -185
  96. package/dist/client/src/wire.d.ts +0 -215
  97. package/dist/client/src/wire.js +0 -1
  98. package/dist/src/apps/remainder.d.ts +0 -2
  99. package/dist/src/apps/remainder.js +0 -16
  100. package/dist/src/apps/tab.d.ts +0 -6
  101. package/dist/src/apps/tab.js +0 -27
@@ -1,14 +1,19 @@
1
- import type { MdRuntimeClient } from '@agentshouse/mdruntime/client';
2
- import type { HouseBridgeSource, HouseImageCopy } from './bridge.js';
3
- import type { HouseAppMessage, HouseExternalAnswer, HouseExternalRequest, HouseGaChoice, HouseNavigationMode, HouseRefusal, HouseSourceDownload, HouseSourceTop, HouseStatus, HouseTab } from './wire.js';
1
+ import type { MdRuntimeClient } from './mdruntime/client.js';
2
+ import type { HouseAnalyticsChoice, HouseAppMessage, HouseChatOptions, HouseExternalAnswer, HouseExternalRequest, HouseNavigationMode, HouseRefusal, HouseSourceDownload, HouseSourceTop, HouseStatus, HouseTab } from './index.js';
4
3
  export interface HouseBridgeNavigation {
5
4
  readonly mode: HouseNavigationMode;
6
5
  readonly address: string;
7
6
  }
8
- export interface HouseBridgeTestHost extends HouseBridgeSource {
7
+ export interface HouseBridgeChat {
8
+ readonly element: object;
9
+ readonly options: HouseChatOptions;
10
+ readonly mounted: boolean;
11
+ }
12
+ export interface HouseBridgeTestHost {
9
13
  readonly navigations: readonly HouseBridgeNavigation[];
14
+ readonly chats: readonly HouseBridgeChat[];
10
15
  readonly ceremonies: readonly string[];
11
- readonly consents: readonly HouseGaChoice[];
16
+ readonly consents: readonly HouseAnalyticsChoice[];
12
17
  readonly tabs: readonly HouseTab[];
13
18
  readonly externalCalls: readonly HouseExternalRequest[];
14
19
  address(): string;
@@ -20,9 +25,6 @@ export interface HouseBridgeTestHost extends HouseBridgeSource {
20
25
  export interface HouseBridgeTestHostOptions {
21
26
  readonly address?: string;
22
27
  readonly status?: HouseStatus;
23
- readonly images?: readonly (HouseImageCopy & {
24
- readonly room: string;
25
- })[];
26
28
  readonly sources?: readonly {
27
29
  readonly top: HouseSourceTop;
28
30
  readonly download: HouseSourceDownload;
@@ -0,0 +1,190 @@
1
+ const HOST_ORIGIN = 'https://house.invalid';
2
+ const ADDRESS_MAX_CHARS = 64 * 1024;
3
+ function sameOriginPath(value) {
4
+ if (typeof value !== 'string')
5
+ return null;
6
+ if (value.charAt(0) !== '/' || value.slice(0, 2) === '//')
7
+ return null;
8
+ if (value.length > ADDRESS_MAX_CHARS)
9
+ return null;
10
+ const target = new URL(value, HOST_ORIGIN);
11
+ return target.origin === HOST_ORIGIN ? `${target.pathname}${target.search}${target.hash}` : null;
12
+ }
13
+ function appAddress(address) {
14
+ return address.startsWith('/') ? address : `/${address}`;
15
+ }
16
+ function ceremonyRefused(path) {
17
+ return Object.assign(new Error('house_ceremony_refused'), {
18
+ name: 'HouseCeremonyRefused',
19
+ code: 'house_ceremony_refused',
20
+ retryable: false,
21
+ path,
22
+ });
23
+ }
24
+ function navigationRefused(address) {
25
+ return Object.assign(new Error('house_navigation_refused'), {
26
+ name: 'HouseNavigationRefused',
27
+ code: 'house_navigation_refused',
28
+ retryable: false,
29
+ address,
30
+ });
31
+ }
32
+ function followHeld(listeners, listener, held) {
33
+ let following = true;
34
+ queueMicrotask(() => {
35
+ if (!following)
36
+ return;
37
+ listeners.add(listener);
38
+ const value = held();
39
+ if (value !== null)
40
+ listener(value);
41
+ });
42
+ return () => {
43
+ following = false;
44
+ listeners.delete(listener);
45
+ };
46
+ }
47
+ export function createHouseBridgeTestHost(options = {}) {
48
+ const navigations = [];
49
+ const ceremonies = [];
50
+ const consents = [];
51
+ const tabs = [];
52
+ const externalCalls = [];
53
+ const chats = [];
54
+ const addressListeners = new Set();
55
+ const statusListeners = new Set();
56
+ const messageListeners = new Set();
57
+ let current = appAddress(options.address ?? '/');
58
+ let published = options.status ?? null;
59
+ let shown = null;
60
+ let seen = null;
61
+ let attached = () => { };
62
+ const runtime = new Promise((resolve) => {
63
+ attached = resolve;
64
+ });
65
+ function arrive(target) {
66
+ current = target;
67
+ queueMicrotask(() => {
68
+ shown = target;
69
+ for (const listener of addressListeners)
70
+ listener(target);
71
+ });
72
+ }
73
+ function publish(next) {
74
+ published = next;
75
+ queueMicrotask(() => {
76
+ seen = next;
77
+ for (const listener of statusListeners)
78
+ listener(next);
79
+ });
80
+ }
81
+ function navigate(mode, asked) {
82
+ let path = asked;
83
+ if (/^https?:\/\//i.test(asked)) {
84
+ try {
85
+ const target = new URL(asked);
86
+ path = target.origin === HOST_ORIGIN ? target.pathname + target.search + target.hash : '';
87
+ }
88
+ catch {
89
+ path = '';
90
+ }
91
+ }
92
+ const target = sameOriginPath(path);
93
+ if (target === null)
94
+ return Promise.reject(navigationRefused(asked));
95
+ navigations.push({ mode, address: target });
96
+ arrive(target);
97
+ return new Promise((resolve) => {
98
+ queueMicrotask(() => resolve(target));
99
+ });
100
+ }
101
+ const bridge = {
102
+ runtime: runtime,
103
+ chat: {
104
+ mount(element, options = {}) {
105
+ const chat = { element, options, mounted: true };
106
+ chats.push(chat);
107
+ return Promise.resolve({
108
+ update(next) {
109
+ chat.options = next;
110
+ },
111
+ unmount() {
112
+ chat.mounted = false;
113
+ },
114
+ });
115
+ },
116
+ },
117
+ address: () => shown,
118
+ onAddress(listener) {
119
+ return followHeld(addressListeners, listener, () => shown);
120
+ },
121
+ push: (asked) => navigate('push', asked),
122
+ replace: (asked) => navigate('replace', asked),
123
+ ceremony(path) {
124
+ const target = sameOriginPath(path);
125
+ if (target === null)
126
+ return Promise.reject(ceremonyRefused(path));
127
+ ceremonies.push(target);
128
+ return new Promise(() => { });
129
+ },
130
+ install: () => Promise.resolve('manual'),
131
+ notifications: () => Promise.resolve('unavailable'),
132
+ telegram: () => Promise.resolve({ state: 'unavailable', name: null, username: null }),
133
+ setTab(tab) {
134
+ tabs.push(tab);
135
+ },
136
+ sourceTop: (app) => Promise.resolve(options.sources?.find((entry) => entry.top.app_ref === app)?.top ?? null),
137
+ sourceDownload: (app) => Promise.resolve(options.sources?.find((entry) => entry.top.app_ref === app)?.download ?? null),
138
+ callExternal(request) {
139
+ externalCalls.push(request);
140
+ return Promise.resolve(options.external?.(request) ?? null);
141
+ },
142
+ readScreenshot: (app) => Promise.resolve(options.screenshots?.[app] ?? null),
143
+ readSiteScreenshot: (site) => Promise.resolve(options.siteScreenshots?.[site] ?? null),
144
+ status: () => seen,
145
+ onStatus(listener) {
146
+ return followHeld(statusListeners, listener, () => seen);
147
+ },
148
+ messages(listener) {
149
+ messageListeners.add(listener);
150
+ return () => {
151
+ messageListeners.delete(listener);
152
+ };
153
+ },
154
+ analyticsConsent(choice) {
155
+ if (published === null || !published.analytics.measures)
156
+ return;
157
+ if (choice !== 'accept' && choice !== 'decline')
158
+ return;
159
+ consents.push(choice);
160
+ publish({ ...published, analytics: { measures: true, choice } });
161
+ },
162
+ cooperate: () => () => { },
163
+ };
164
+ Object.defineProperty(globalThis, 'houseBridge', { value: bridge, configurable: true });
165
+ if (published !== null)
166
+ publish(published);
167
+ arrive(current);
168
+ return {
169
+ navigations,
170
+ chats,
171
+ ceremonies,
172
+ consents,
173
+ tabs,
174
+ externalCalls,
175
+ address: () => current,
176
+ open(asked) {
177
+ arrive(appAddress(asked));
178
+ },
179
+ publish,
180
+ message({ from, body }) {
181
+ queueMicrotask(() => {
182
+ for (const listener of messageListeners)
183
+ listener({ from, body });
184
+ });
185
+ },
186
+ attachRuntime(client) {
187
+ attached(client);
188
+ },
189
+ };
190
+ }
package/docs/families.md CHANGED
@@ -12,39 +12,67 @@
12
12
  purpose-bound authenticated pages. The shell navigates only to a same-origin
13
13
  absolute path, carries its current address as the return target, and the page
14
14
  returns there when it completes. An App names an address House gave it in a
15
- reading and composes none.
15
+ reading and composes one only for `/bind/<app_ref>`, where the User binds
16
+ its Rooms, with `?slot=<name>` to open at one slot, and `/sign-out`, which
17
+ signs the User out and opens sign-in.
16
18
  - **Installation** - `install()` offers the page as a Home-screen app. Where the
17
19
  browser has an install prompt ready the shell shows it and the call resolves
18
20
  `'accepted'` or `'dismissed'` with the User's choice, spending that prompt;
19
21
  otherwise, as on every iPhone and iPad, it resolves `'manual'` and the App
20
22
  shows its own instructions. A prompt the browser refuses to show, as for a
21
- call made without a click, rejects with the browser's own `DOMException`
22
- and stays ready. Call it from a click. The standard
23
+ call made without a click, rejects with an error named and coded by the
24
+ browser's own error name, with `retryable` false, and stays ready. Call it from a click. The standard
23
25
  `display-mode: standalone` media query tells the App it runs installed.
24
26
  - **Notifications** - House's own panel alone; an App's or a Site's call
25
- rejects with `HouseCeremonyRefused`. `notifications()` answers this browser
27
+ rejects with an error named `HouseCeremonyRefused`, carrying `code` and `retryable`. `notifications()` answers this browser
26
28
  storage's push state: `'on'`, `'off'`, `'blocked'` where the browser refuses
27
29
  notifications, or `'unavailable'` where it has no push, as on an iPhone or
28
30
  iPad outside a Home-screen app. `notifications(true)` asks the browser's
29
31
  permission and subscribes, `notifications(false)` unsubscribes, and each
30
- answers the state it leaves; a failure of the browser's push service rejects
31
- with the browser's own `DOMException`. Call `notifications(true)` from a
32
- click. `setBadge(unread)` takes the identifiers of the Human Notifications
33
- unread in this storage and sets the icon's badge to their number, or clears
34
- it at none, where the browser shows one.
32
+ answers the state it leaves; a failure of the browser's push service
33
+ rejects the same way. Call `notifications(true)` from a click. House's
34
+ service worker counts the icon's badge itself, as pushes arrive and as
35
+ read marks reach this storage.
36
+ - **Telegram** - House's own panel alone, refused to an App or a Site the same
37
+ way. `telegram()` answers `{ state, name, username }`: `state` is
38
+ `'available'` where the page runs inside a House bot's Mini App that gave it
39
+ Telegram's launch data naming an account, with that account's `name` and its
40
+ `username` or `null`, and `'unavailable'` with both `null` elsewhere.
41
+ `telegram(true)` links the signed-in User to that account and answers
42
+ `'linked'` with it; where the User's sign-in is
43
+ not recent, the page goes to sign in again, and nothing links until a later
44
+ `telegram(true)`.
45
+ Telegram's refusal rejects with an error coded `linked_elsewhere`,
46
+ `rate_limited` or `refused`, and a failed request with the browser's own
47
+ error name.
35
48
  - **Status** - the App reference the runtime client is attached under,
36
- `preferences`: the `room_ref` and Path of the App's own preferences document,
49
+ `preferences`: the `roomRef` and Path of the App's own preferences document,
37
50
  or `null` until the runtime holds that Room, sync
38
- state, credential state and observed failure, `ga`:
51
+ state, credential state and its `expiresAt`, observed failure, `analytics`:
39
52
  whether the page measures and the visitor's stored analytics choice, and
40
- `service_mode`: `open`, `write-halted` while House refuses writes, so the
53
+ `serviceMode`: `open`, `write-halted` while House refuses writes, so the
41
54
  App can stop retrying them, or `null` while the runtime holds no House
42
- connection.
43
- The App reports the visitor's choice with `gaConsent('accept')` or
44
- `gaConsent('decline')`; the shell hands it to House's analytics loader, and
55
+ connection. Every status field is camelCase. `onStatus(listener)` and
56
+ `onAddress(listener)` hand a listener the status and the address the bridge
57
+ already holds, then each change.
58
+ The App reports the visitor's choice with `analyticsConsent('accept')` or
59
+ `analyticsConsent('decline')`; the shell hands it to House's analytics loader, and
45
60
  the choice never reaches House.
46
- - **Site image read** - given a Published Room and an original attachment
47
- reference, it answers the web copy's path and metadata, or `null` when no
61
+ - **Releases and builds** - an open App keeps the release it loaded: a newer
62
+ release, or a newer House build, takes effect at the App's next load, offline
63
+ too once the browser stored it. When one tab loads a newer House build, the
64
+ other House tabs reload into it; Room Drafts, chat drafts and unsent changes
65
+ survive the reload.
66
+ - **A runtime that ends** - when the browser ends House's runtime under an open
67
+ App, the App keeps running, its `runtime` client and observations included:
68
+ each observation goes on with the next runtime's values, and the status and
69
+ the address arrive again. A runtime that ended before answering has its reads
70
+ answered by the next one; since it may have applied any other call, an act on
71
+ House is answered the outcome `transport-uncertainty`, and every other call,
72
+ a Save or a draft write among them, fails with the retryable code
73
+ `transport-uncertainty`.
74
+ - **Site image read** - given a Published Room and the Path of one of its
75
+ binary entries, it answers the web copy's path and metadata, or `null` when no
48
76
  copy exists. The original bytes never cross this bridge at a Site.
49
77
  - **App release code** - `sourceTop(app, release)` answers the top level of
50
78
  the latest successful release of an App the User may use: its folders, its
@@ -53,24 +81,24 @@
53
81
  path, its size and its `text`, or its bytes as `base64`. The browser keeps
54
82
  each answer per App and release: a read naming a release it holds answers
55
83
  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
84
+ refusal is House's `{ error: { code, retryable } }`, `app_release_not_found` for an
57
85
  App with no release; a read House does not answer, or one that outlived
58
86
  the browser's signed-in User, is `null`.
59
- - **External calls** - `callExternal({ url, method, headers, body, slot })`
87
+ - **External calls** - `callExternal({ url, method, headers, body, room_ref })`
60
88
  has House's server send an HTTPS request to one of the release's declared
61
89
  external origins and resolves with the service's `status`, `headers` and its
62
90
  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
64
- App and its running release; naming an account slot places the key of the
65
- account the User connected to it, which the App never sees, and naming none
66
- sends no key. A Site's call names no slot, and the House panel names an
67
- `account` instead. `body_base64` replaces `body` for bytes.
91
+ `{ error: { code, retryable } }`, or `null` when House does not answer. House fills in the
92
+ App and its running release. A `room_ref` names a Room the signed-in User binds to the App
93
+ in a `write` slot, and House adds that Room's Service key for the URL's origin, which App
94
+ code never sees; a call naming no Room carries no key, and a Site's call names no Room.
95
+ `body_base64` replaces `body` for bytes.
68
96
  - **App messages** - `messages(listener)` hands the listener each message
69
97
  another holder of this App sends to this User's running copies, as `from`,
70
98
  the sender's User id, and `body`, the JSON value they sent, until the
71
99
  function it returns is called. App code sends one through the Runtime's
72
100
  `call('apps/messages/send', { to, body })` with the recipient's User id and
73
- a body of at most 32 KiB of JSON; House fills in the App and relays it only
101
+ a body of at most 32 kB of JSON; House fills in the App and relays it only
74
102
  to copies running now, storing nothing. The panel sends none.
75
103
  - **App screenshot read** - given an App reference, `readScreenshot(app)`
76
104
  answers the image this browser captured of that App's screen the first time
@@ -82,25 +110,53 @@
82
110
  after its latest release, as a JPEG `Blob`, or `null` when House holds none
83
111
  or does not answer. A Site's own renderer reads none.
84
112
 
113
+ - **Chat** - `chat.mount(element, options)` places House's Chat, the one chat
114
+ in which the User's Agent conversations show, in `element` over the page's
115
+ `runtime` client, and resolves to a handle: `update(options)` replaces its
116
+ options and `unmount()` removes it. House serves the Chat with the page and
117
+ keeps it current, so the App installs and bundles nothing for it. The
118
+ options: `conversation` opens one, `null` for a new chat, `agent` is the
119
+ Agent a new chat goes to, `showChats` adds its conversation list, `width` is
120
+ `full`, the element, or `3/4`, `1/2` or `1/3` of the window docked at its
121
+ right edge, `onOpen` hears each conversation it opens as
122
+ `{ conversation, agent }`, and `onLink` takes a link without a scheme in
123
+ place of the browser. CSS custom properties named `--chat-*` on the element
124
+ or an ancestor set its look. It shows conversations only to a release that
125
+ declares them. A Site and the House panel have none: their call rejects with
126
+ an error named and coded `NotSupportedError`, with `retryable` false.
127
+
128
+ - **First place** - `cooperate({ placed })` tells House when the page has
129
+ drawn the place it opened on; the function it returns withdraws it. Register
130
+ it in the entry script, before the first draw. `placed()` resolves once the
131
+ page has drawn that place with what it shows: House keeps its
132
+ first-preparation surface over a page registered by its first draw until
133
+ then, and lifts it at the first draw of a page that registered none, so the
134
+ User goes from the surface to a drawn place in one change. House asks the
135
+ page for nothing else.
136
+
85
137
  ## The test host
86
138
 
87
- The host plays the shell and the worker: it delivers the address the App starts
88
- at and each address `open` plays as Back or Forward through the shell's own
89
- slice below the App's path, admitting nothing, so it delivers `//notes` exactly
90
- as a browser at `/apps/<app>//notes` does. It records every push and replace
91
- and answers each with the address the shell would then show, records an
92
- admitted ceremony, refuses a push, replace or ceremony that is not a
93
- same-origin absolute path, publishes a status, its `service_mode` included,
94
- records in `consents` each
95
- `gaConsent` it takes while that status measures and publishes the status the
96
- choice leaves, records in `tabs` each `setTab` the shell would take and ignores
97
- any other, answers a release code read from the `sources` it was given, or
98
- `null`, answers each `callExternal` from the `external` function it was given, or
99
- `null`, and records the request in `externalCalls`, answers `readScreenshot`
100
- from the `screenshots` it was given by App
101
- reference and `readSiteScreenshot` from the `siteScreenshots` it was given by
102
- Site identifier, answers every `install()` `'manual'`, as a browser with no install
103
- prompt does, answers every `notifications()` `'unavailable'`, as a browser
104
- without push does, settles every `setBadge`, delivers each App message
105
- `message({ from, body })` plays, and hands `bridge.runtime` the MD Runtime
106
- client `attachRuntime(client)` gives it.
139
+ `createHouseBridgeTestHost(options)` plays House in one page: it installs a
140
+ bridge object that `houseBridge()` returns, until the next host replaces it.
141
+ It delivers the address the App starts at and each address `open` plays as
142
+ Back or Forward, admitting nothing, so it delivers `//notes` exactly as a
143
+ browser at `/apps/<app>//notes` does. It records every push and replace and
144
+ answers each with the address the shell would then show, records an admitted
145
+ ceremony, and refuses a push, replace or ceremony that is not a same-origin
146
+ absolute path of at most 1,000 characters with an error named
147
+ `HouseNavigationRefused` or `HouseCeremonyRefused`. It publishes a status,
148
+ its `serviceMode` included, records in `consents` each `analyticsConsent` it
149
+ takes while that status measures and publishes the status the choice leaves,
150
+ records in `tabs` each `setTab`, answers a release code read from the
151
+ `sources` it was given, or `null`, answers each `callExternal` from the
152
+ `external` function it was given, or `null`, and records the request in
153
+ `externalCalls`, answers `readScreenshot` from the `screenshots` it was given
154
+ by App reference and `readSiteScreenshot` from the `siteScreenshots` it was
155
+ given by Site identifier, answers every `install()` `'manual'`, as a browser
156
+ with no install prompt does, answers every `notifications()` `'unavailable'`,
157
+ as a browser without push does, records in `chats`
158
+ each Chat `chat.mount` places, with its `element`, the `options` it was last
159
+ given and whether it is still `mounted`, drawing nothing, delivers each App
160
+ message `message({ from, body })` plays, and hands `bridge.runtime` the MD
161
+ Runtime client `attachRuntime(client)` gives it. It takes a `cooperate` and
162
+ never calls `placed()`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentshouse/app-bridge",
3
- "version": "0.1.0-cf2e2ca943fbc",
4
- "description": "Renderer-side client of the agents.house App bridge: 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 in-page test host.",
3
+ "version": "0.1.0-cf304386b60e3",
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, App messages and the Chat, with an accessor and an in-page test host.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -10,21 +10,23 @@
10
10
  },
11
11
  "exports": {
12
12
  ".": {
13
- "types": "./dist/client/src/index.d.ts",
14
- "default": "./dist/client/src/index.js"
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
15
  },
16
16
  "./test-host": {
17
- "types": "./dist/client/src/test-host.d.ts",
18
- "default": "./dist/client/src/test-host.js"
17
+ "types": "./dist/test-host.d.ts",
18
+ "default": "./dist/test-host.js"
19
19
  }
20
20
  },
21
- "dependencies": {
22
- "@agentshouse/mdruntime": "0.1.0-cacb4c3f6734e"
23
- },
24
21
  "files": [
25
22
  "dist",
26
23
  "docs",
27
24
  "README.md",
28
25
  "LICENSE"
29
- ]
26
+ ],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/agentshouse/core.git",
30
+ "directory": "client"
31
+ }
30
32
  }
@@ -1,38 +0,0 @@
1
- import type { MdRuntimeClient } from '@agentshouse/mdruntime/client';
2
- import type { HouseAppMessage, HouseExternalAnswer, HouseExternalRequest, HouseBridgePort, HouseGaChoice, HouseImageCopy, HouseInstallation, HouseNotifications, HouseRefusal, HouseSourceDownload, HouseSourceTop, HouseStatus, HouseTab } from './wire.js';
3
- export type { HouseImageCopy } from './wire.js';
4
- export declare class HouseCeremonyRefused extends Error {
5
- readonly path: string | null;
6
- constructor(path: string | null);
7
- }
8
- export declare class HouseNavigationRefused extends Error {
9
- readonly address: string | null;
10
- constructor(address: string | null);
11
- }
12
- export interface HouseBridgeSource {
13
- readonly port: Promise<HouseBridgePort>;
14
- readonly runtime: Promise<MdRuntimeClient>;
15
- }
16
- export interface HouseBridge {
17
- readonly runtime: Promise<MdRuntimeClient>;
18
- address(): string | null;
19
- onAddress(listener: (address: string) => void): () => void;
20
- push(address: string): Promise<string>;
21
- replace(address: string): Promise<string>;
22
- ceremony(path: string): Promise<never>;
23
- install(): Promise<HouseInstallation>;
24
- notifications(on?: boolean): Promise<HouseNotifications>;
25
- setBadge(unread: readonly string[]): Promise<void>;
26
- setTab(tab: HouseTab): void;
27
- readAttachment(room: string, attachment: string): Promise<HouseImageCopy | null>;
28
- sourceTop(app: string, release?: string): Promise<HouseSourceTop | HouseRefusal | null>;
29
- sourceDownload(app: string, release?: string): Promise<HouseSourceDownload | HouseRefusal | null>;
30
- callExternal(request: HouseExternalRequest): Promise<HouseExternalAnswer | HouseRefusal | null>;
31
- readScreenshot(app: string): Promise<Blob | null>;
32
- readSiteScreenshot(site: string): Promise<Blob | null>;
33
- status(): HouseStatus | null;
34
- onStatus(listener: (status: HouseStatus) => void): () => void;
35
- messages(listener: (message: HouseAppMessage) => void): () => void;
36
- gaConsent(choice: HouseGaChoice): void;
37
- }
38
- export declare function connectHouseBridge(source?: HouseBridgeSource): HouseBridge;