holon-ui 0.0.1-dev.27 → 0.0.1-dev.28
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 +9 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://holonlabs.ai/docs/)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`holon-ui` lets a browser page call your MCP server's tools, with type checking. The same page runs in two places. Inside an MCP Apps host, it appears next to a tool's result. On the open web, it is a regular page that can offer tools to the browser's AI agent through WebMCP.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -37,7 +37,7 @@ server.registerTool(
|
|
|
37
37
|
);
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
The page connects and calls it. `holon types check` checks those calls against the server's tools, so a wrong tool name, argument, or result type fails the check:
|
|
41
41
|
|
|
42
42
|
```sh
|
|
43
43
|
npx holon types check
|
|
@@ -51,7 +51,7 @@ const app = await connect();
|
|
|
51
51
|
const { result } = await app.tools.greet({ name: "Ada" });
|
|
52
52
|
|
|
53
53
|
await app.tools.great({ name: "Ada" });
|
|
54
|
-
// error TS2551: Property 'great' does not exist on type '{
|
|
54
|
+
// error TS2551: Property 'great' does not exist on type '{ ... }'. Did you mean 'greet'?
|
|
55
55
|
|
|
56
56
|
await app.tools.greet({ name: 42 });
|
|
57
57
|
// error TS2322: Type 'number' is not assignable to type 'string'.
|
|
@@ -62,7 +62,7 @@ result.toFixed();
|
|
|
62
62
|
|
|
63
63
|
## Tools that run in the page
|
|
64
64
|
|
|
65
|
-
`connect` offers them to whichever agent is present
|
|
65
|
+
A page can define its own tools for an AI agent to use, such as selecting shapes on a board the person is looking at. `connect` offers them to whichever agent is present, the host's agent or the browser's:
|
|
66
66
|
|
|
67
67
|
```ts
|
|
68
68
|
const app = await connect({
|
|
@@ -78,20 +78,18 @@ const app = await connect({
|
|
|
78
78
|
});
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
On a web page, the browser's agent is also offered the server's tools that the generated clients know, leaving out those whose `_meta.ui.visibility` lacks `"model"` and those that need a file argument. In a host, its agent already has them.
|
|
81
|
+
On a web page, the browser's agent can also use your server's tools. Inside a host, the host's agent already has them.
|
|
84
82
|
|
|
85
83
|
## The call that opened a view
|
|
86
84
|
|
|
87
|
-
|
|
85
|
+
Inside an MCP Apps host, a page opens because a tool ran. `app.opened` is that tool call and its result. On a web page it is `undefined`.
|
|
88
86
|
|
|
89
87
|
```ts
|
|
90
88
|
const opened = await app.opened;
|
|
91
89
|
if (opened?.tool === "greet") greeting.value = opened.output.result;
|
|
92
90
|
```
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
Features that only exist inside a host are on `app.view`:
|
|
95
93
|
|
|
96
94
|
```ts
|
|
97
95
|
if (app.view) app.view.onhostcontextchanged = ({ theme }) => { if (theme) document.documentElement.style.colorScheme = theme; };
|
|
@@ -99,7 +97,7 @@ if (app.view) app.view.onhostcontextchanged = ({ theme }) => { if (theme) docume
|
|
|
99
97
|
|
|
100
98
|
## Building the page
|
|
101
99
|
|
|
102
|
-
`holon-ui/vite` builds
|
|
100
|
+
`holon-ui/vite` builds the page twice in one `vite build`, once as a web page and once as a single-file view for MCP Apps hosts:
|
|
103
101
|
|
|
104
102
|
```ts
|
|
105
103
|
import { defineConfig } from "vite";
|
|
@@ -108,7 +106,7 @@ import { holon } from "holon-ui/vite";
|
|
|
108
106
|
export default defineConfig({ plugins: [holon()] });
|
|
109
107
|
```
|
|
110
108
|
|
|
111
|
-
`create-holon-app` sets this up
|
|
109
|
+
`create-holon-app` sets this up for you.
|
|
112
110
|
|
|
113
111
|
## Community
|
|
114
112
|
|