@hearthscale/app 0.1.0 → 0.2.0

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 CHANGED
@@ -4,9 +4,11 @@ The types an app imports: its manifest, `app.json` (`Manifest`), what
4
4
  `backend.js` exports (`Backend`), what its
5
5
  tool bodies receive (`AppContext`, `ToolRun`), and the slots a view
6
6
  reserves for the shell's chat, composer, cards, live terminal and the
7
- tab's web page (`HostSlot`). The package carries no runtime: the app host serves `require('@hearthscale/app')` from
8
- itself, so a bundle with the package marked external ships nothing of the
9
- platform.
7
+ tab's web page (`HostSlot`). The package carries no runtime for a
8
+ backend: `hearthscale dev` and `hearthscale pack` bundle an import of
9
+ `@hearthscale/app` as an empty module, so a backend ships nothing of the
10
+ platform and imports only its types. `@hearthscale/app/view` is the one
11
+ runtime part, which a view bundles.
10
12
 
11
13
  ```sh
12
14
  npm install --save-dev @hearthscale/app
@@ -29,17 +31,24 @@ as requests of its MCP Apps `App`, and hears the host's notifications
29
31
  `app.fallbackNotificationHandler`. `ViewHostContext` types the keys the host
30
32
  adds to the host context, and `ContentBlockMeta`, `ModelContextAnswer`,
31
33
  `MessageOptions`, `ResourceReadOptions`, `ResourceVersion` and
32
- `ResourcePath` the `_meta` of the standard messages. `ViewExtensionCall`
33
- types one call of an extension:
34
+ `ResourcePath` the `_meta` of the standard messages. `hostCall` of
35
+ `@hearthscale/app/view` gives one typed call of every request a view sends
36
+ beyond MCP Apps, the host methods and the extensions alike (`HostCall`,
37
+ over `ViewMethods`), and of the MCP Apps requests that take Hearthscale's
38
+ own fields (`ViewStandardMethods`; `ViewCall` covers both):
34
39
 
35
- ```js
36
- import { App, McpUiMessageResultSchema } from '@modelcontextprotocol/ext-apps';
37
- const call = (method, params) => app.request({ method, params }, McpUiMessageResultSchema);
38
- const { sessions } = await call('hearthscale/sessions/list', {});
40
+ ```ts
41
+ import { App } from '@modelcontextprotocol/ext-apps';
42
+ import { hostCall } from '@hearthscale/app/view';
43
+
44
+ const app = new App({ name: 'Inbox', version: '1.0.0' }, {});
45
+ const call = hostCall(app);
46
+ const { sessions } = await call('hearthscale/sessions/list');
47
+ await call('hearthscale/ui/set-tab', { title: 'Inbox' });
39
48
  ```
40
49
 
41
50
  A view keeps a JSON value for its next load with
42
- `hearthscale/ui/set-widget-state` (`{ state }`, at most 64 KiB as JSON) and
51
+ `hearthscale/ui/set-widget-state` (`{ state }`, at most 65,536 UTF-16 code units as JSON text) and
43
52
  reads it back from the host context as `hearthscale/widgetState`, null
44
53
  before the first save. The host loads a view in a tab again when the tab
45
54
  comes back after the window discarded its surface, and after a restart.
@@ -52,20 +61,30 @@ A view whose app names `models` in `uses` asks the model with MCP's
52
61
  `sampling/createMessage` (text only, on the app's chat card).
53
62
  `hearthscale/ui/select-files` (`{ accept?, multiple? }`, on a click) answers
54
63
  the files the person picked, which the view reads with `resources/read`;
55
- `hearthscale/ui/upload-file` (`{ name, mediaType, blob }`) keeps bytes as an
56
- asset the view reads back as `hearthscale-asset://<asset>`.
64
+ `hearthscale/ui/upload-file` (`{ name, mediaType, blob }`, `blob` a `Blob`)
65
+ keeps its bytes as an asset the view reads back as
66
+ `hearthscale-asset://<asset>`, or streamed and by byte range at the address
67
+ `hearthscale/assetBytes` in the host context names, followed by the asset's
68
+ id, as a `fetch` or as the source of a picture, a sound or a video.
69
+ `ui/download-file` saves where the person picks on a click; an embedded
70
+ resource's `blob` may be a `Blob`, which streams into the file, beside the
71
+ text and the base64 of MCP Apps, which hold at most 64 MiB.
57
72
 
58
73
  A view that fills a tab has a web page of its tab: the shell loads it on
59
74
  the app's own partition, where it reaches only the hosts of
60
75
  `environment.network`, once the view asks for an address with
61
76
  `hearthscale/web/navigate`. The page lies over the view's `web` slot, and
62
- under the view while the view covers it (`hearthscale/web/cover`), so a
77
+ under the view while the view covers it (`hearthscale/ui/cover`), so a
63
78
  menu the view opens draws over the page and the page shows through where
64
- the view draws nothing. The view drives the page with the other
79
+ the view draws nothing. The same call lays the chat and the composer of the
80
+ view's slots under it; the terminal and the cards stay above. The view drives the page with the other
65
81
  `hearthscale/web/*` methods and hears its state as `hearthscale/web/page`
66
82
  (`WebPageState`). A link the page opens in a new window opens a tab of the
67
- same surface. The page keeps its address through a restart, and the app's
68
- tools drive it through `surface.command`.
83
+ same surface, and a popup with a size of its own opens as a window that
84
+ keeps its opener. The keys the view names with `hearthscale/web/keys` reach
85
+ the view as `hearthscale/web/key` while the page has the keyboard. The page
86
+ keeps its address through a restart, and the app's tools drive it through
87
+ `surface.command`.
69
88
 
70
89
  An app that names `peers` in `uses` talks to itself on other computers in
71
90
  rooms. A view opens a room with `hearthscale/peers/create` and shows the