holon-ui 0.0.1-dev.17 → 0.0.1-dev.19
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/package.json +2 -8
- package/runtime.d.ts +3 -3
- package/runtime.web.mjs +16 -17
- package/vite.mjs +1 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "holon-ui",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.19",
|
|
4
4
|
"description": "Typed MCP clients for browser pages: one connect() for MCP Apps views and WebMCP pages.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,13 +40,7 @@
|
|
|
40
40
|
"holon-sh": "^0.0.1-dev.23"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@modelcontextprotocol/ext-apps": "^2.0.0"
|
|
44
|
-
"vite": "^8.0.0"
|
|
45
|
-
},
|
|
46
|
-
"peerDependenciesMeta": {
|
|
47
|
-
"vite": {
|
|
48
|
-
"optional": true
|
|
49
|
-
}
|
|
43
|
+
"@modelcontextprotocol/ext-apps": "^2.0.0"
|
|
50
44
|
},
|
|
51
45
|
"devDependencies": {
|
|
52
46
|
"@modelcontextprotocol/ext-apps": "^2.0.4",
|
package/runtime.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { App, AppOptions } from "@modelcontextprotocol/ext-apps";
|
|
2
|
-
import type { StandardSchemaV1, StandardSchemaWithJSON, ToolAnnotations
|
|
3
|
-
import type {
|
|
2
|
+
import type { StandardSchemaV1, StandardSchemaWithJSON, ToolAnnotations } from "@modelcontextprotocol/client";
|
|
3
|
+
import type { Identity, Contract, RuntimeClient } from "holon-sh/runtime";
|
|
4
4
|
export type { CreateOptions, EndpointBinding, Identity, Contract, RuntimeClient } from "holon-sh/runtime";
|
|
5
5
|
export type { AuthProvider, CallOptions, CallMetadata, ToolResult, ToolClient } from "holon-sh/runtime";
|
|
6
6
|
export { bindApps, ToolCallError } from "holon-sh/runtime";
|
|
@@ -20,7 +20,7 @@ export interface ConnectOptions<S extends Record<string, unknown> = {}> {
|
|
|
20
20
|
/** Page tools by name, offered to the host's agent in an MCP Apps host and to the browser's agent through WebMCP. */
|
|
21
21
|
tools?: { [K in keyof S]: PageTool<S[K]> };
|
|
22
22
|
/** The ext-apps App's options in an MCP Apps host, and the transport to connect it with; ignored on a web page. */
|
|
23
|
-
view?: AppOptions & { transport?:
|
|
23
|
+
view?: AppOptions & { transport?: Parameters<App["connect"]>[0] };
|
|
24
24
|
}
|
|
25
25
|
type Tools<C> = C extends { tools: infer T } ? T : never;
|
|
26
26
|
/** The tool call that opened a view: typed by its tool, or untyped when the host does not say which tool it was. */
|
package/runtime.web.mjs
CHANGED
|
@@ -23,8 +23,9 @@ export async function connect({ identity, contracts, own, endpoint }, { tools =
|
|
|
23
23
|
// MCP Apps: a tool whose visibility omits "model" must not reach the agent; absent means ["model", "app"].
|
|
24
24
|
// https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx#resource-discovery
|
|
25
25
|
// A typed client calls only its contract's tools, and an agent cannot write a file argument.
|
|
26
|
+
if (!(tool._meta?.ui?.visibility ?? ["model"]).includes("model") || !contracted(tool.name)) continue;
|
|
26
27
|
const inputSchema = withoutFiles(tool.inputSchema);
|
|
27
|
-
if (
|
|
28
|
+
if (inputSchema !== FILE) offer(serverTool(own, client, tool, inputSchema));
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
31
|
error => signal.aborted || console.warn(`Could not list the tools of ${own} for WebMCP:`, error),
|
|
@@ -39,8 +40,7 @@ function pageTool(name, { description, inputSchema, annotations, execute }) {
|
|
|
39
40
|
name, title: annotations?.title, description, annotations: hints(annotations),
|
|
40
41
|
inputSchema: standard?.jsonSchema.input({ target: "draft-2020-12" }),
|
|
41
42
|
execute: async (input, { signal }) => {
|
|
42
|
-
|
|
43
|
-
const parsed = await standard.validate(input);
|
|
43
|
+
const parsed = standard ? await standard.validate(input) : { value: {} };
|
|
44
44
|
if (parsed.issues) throw new Error(`Invalid arguments for ${name}: ${JSON.stringify(parsed.issues)}`);
|
|
45
45
|
return execute(parsed.value, { signal });
|
|
46
46
|
},
|
|
@@ -70,22 +70,21 @@ function hints(annotations) {
|
|
|
70
70
|
return { readOnlyHint, consequentialHint: !readOnlyHint && annotations?.destructiveHint !== false, untrustedContentHint: annotations?.openWorldHint !== false };
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const
|
|
73
|
+
const FILE = Symbol("schema requires a file");
|
|
74
74
|
|
|
75
75
|
// An agent writes arguments as tokens, so it is not shown a file argument (x-mcp-file): an anyOf or oneOf branch that
|
|
76
76
|
// holds one is left out, and a tool that still has one is not exposed.
|
|
77
77
|
// https://github.com/modelcontextprotocol/experimental-ext-file-uploads/blob/main/specification/draft/file-uploads.md#file-arguments
|
|
78
|
-
function withoutFiles(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return hasFile(pruned) ? undefined : pruned;
|
|
78
|
+
function withoutFiles(node, key) {
|
|
79
|
+
if (Array.isArray(node)) {
|
|
80
|
+
const items = node.map(item => withoutFiles(item));
|
|
81
|
+
if (!items.includes(FILE)) return items;
|
|
82
|
+
if (key !== "anyOf" && key !== "oneOf") return FILE;
|
|
83
|
+
const kept = items.filter(item => item !== FILE);
|
|
84
|
+
return kept.length ? kept : FILE;
|
|
85
|
+
}
|
|
86
|
+
if (typeof node !== "object" || node === null) return node;
|
|
87
|
+
if (Object.hasOwn(node, "x-mcp-file")) return FILE;
|
|
88
|
+
const entries = Object.entries(node).map(([key, value]) => [key, withoutFiles(value, key)]);
|
|
89
|
+
return entries.some(([, value]) => value === FILE) ? FILE : Object.fromEntries(entries);
|
|
91
90
|
}
|
package/vite.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { defaultClientConditions } from "vite";
|
|
2
|
-
|
|
3
1
|
export function holon() {
|
|
4
2
|
return {
|
|
5
3
|
name: "holon",
|
|
@@ -11,7 +9,6 @@ export function holon() {
|
|
|
11
9
|
environments: {
|
|
12
10
|
mcp: {
|
|
13
11
|
consumer: "client",
|
|
14
|
-
resolve: { conditions: ["mcp-app", ...defaultClientConditions] },
|
|
15
12
|
build: {
|
|
16
13
|
outDir: "../dist/mcp",
|
|
17
14
|
copyPublicDir: false,
|
|
@@ -22,6 +19,7 @@ export function holon() {
|
|
|
22
19
|
},
|
|
23
20
|
}),
|
|
24
21
|
applyToEnvironment: ({ name }) => name === "mcp",
|
|
22
|
+
resolveId: { order: "pre", handler: id => (id === "holon-ui/runtime" ? `${import.meta.dirname}/runtime.host.mjs` : null) },
|
|
25
23
|
generateBundle: {
|
|
26
24
|
order: "post",
|
|
27
25
|
handler(_, bundle) {
|