holon-ui 0.0.1-dev.21 → 0.0.1-dev.22

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holon-ui",
3
- "version": "0.0.1-dev.21",
3
+ "version": "0.0.1-dev.22",
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",
package/runtime.d.ts CHANGED
@@ -19,6 +19,7 @@ export interface PageTool<S = undefined> {
19
19
  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
+ /** On a web page, also offer call_tools, which runs several of the other offered tools in one call. Ignored in an MCP Apps host, whose agent calls the app's tools itself. */
22
23
  batch?: "call_tools" extends keyof S ? false : boolean;
23
24
  /** The ext-apps App's options in an MCP Apps host, and the transport to connect it with; ignored on a web page. */
24
25
  view?: AppOptions & { transport?: Parameters<App["connect"]>[0] };
package/runtime.web.mjs CHANGED
@@ -17,10 +17,9 @@ export async function connect({ identity, contracts, own, endpoint }, { tools =
17
17
  const offered = new Map();
18
18
  const register = tool => context.registerTool(tool, { signal }).then(() => true, error => console.warn(`WebMCP did not accept the tool ${tool.name}:`, error));
19
19
  const offer = async tool => await register(tool) && offered.set(tool.name, tool);
20
- if (batch) register(batchTool(offered));
21
- for (const [name, tool] of Object.entries(tools)) offer(pageTool(name, tool));
20
+ const offers = Object.entries(tools).map(([name, tool]) => offer(pageTool(name, tool)));
22
21
  const contracted = name => !contracts[own] || contracts[own].tools.some(tool => tool.name === name);
23
- client.listTools({ signal }).then(
22
+ const listed = client.listTools({ signal }).then(
24
23
  ({ tools: listed }) => {
25
24
  for (const tool of listed) {
26
25
  // MCP Apps: a tool whose visibility omits "model" must not reach the agent; absent means ["model", "app"].
@@ -28,11 +27,12 @@ export async function connect({ identity, contracts, own, endpoint }, { tools =
28
27
  // A typed client calls only its contract's tools, and an agent cannot write a file argument.
29
28
  if (!(tool._meta?.ui?.visibility ?? ["model"]).includes("model") || !contracted(tool.name)) continue;
30
29
  const inputSchema = withoutFiles(tool.inputSchema);
31
- if (inputSchema !== FILE) offer(serverTool(own, client, tool, inputSchema));
30
+ if (inputSchema !== FILE) offers.push(offer(serverTool(own, client, tool, inputSchema)));
32
31
  }
33
32
  },
34
33
  error => signal.aborted || console.warn(`Could not list the tools of ${own} for WebMCP:`, error),
35
34
  );
35
+ if (batch) listed.then(() => Promise.all(offers)).then(() => offered.size && register(batchTool(offered)));
36
36
  }
37
37
  return Object.freeze({ ...client, view: undefined, opened: undefined, close: async () => { lifetime.abort(); await client.close(); } });
38
38
  }
@@ -65,12 +65,17 @@ function serverTool(own, client, tool, inputSchema) {
65
65
  }
66
66
 
67
67
  function batchTool(offered) {
68
- const call = { type: "object", properties: { tool: { type: "string" }, input: { type: "object" } }, required: ["tool", "input"] };
68
+ const call = { type: "object", properties: { tool: { enum: [...offered.keys()] }, input: { type: "object" } }, required: ["tool", "input"] };
69
+ const members = [...offered.values()].map(tool => tool.annotations);
69
70
  return {
70
71
  name: "call_tools",
71
72
  description: "Run several of this page's tools in order, in one call. Stops at the first that fails, and returns the outputs before it and its error.",
72
73
  inputSchema: { type: "object", properties: { calls: { type: "array", items: call } }, required: ["calls"] },
73
- annotations: hints(),
74
+ annotations: {
75
+ readOnlyHint: members.every(hint => hint.readOnlyHint),
76
+ consequentialHint: members.some(hint => hint.consequentialHint),
77
+ untrustedContentHint: members.some(hint => hint.untrustedContentHint),
78
+ },
74
79
  execute: async ({ calls }, client) => {
75
80
  const outputs = [];
76
81
  try {