@bevel-software/platform-mcp-core 0.26.0 → 0.27.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.
Files changed (50) hide show
  1. package/dist/call-guards.d.ts +47 -0
  2. package/dist/call-guards.d.ts.map +1 -0
  3. package/dist/call-guards.js +215 -0
  4. package/dist/call-guards.js.map +1 -0
  5. package/dist/dispatch.d.ts +5 -1
  6. package/dist/dispatch.d.ts.map +1 -1
  7. package/dist/dispatch.js +19 -2
  8. package/dist/dispatch.js.map +1 -1
  9. package/dist/get-has-no-body.d.ts +49 -0
  10. package/dist/get-has-no-body.d.ts.map +1 -0
  11. package/dist/get-has-no-body.js +104 -0
  12. package/dist/get-has-no-body.js.map +1 -0
  13. package/dist/index.d.ts +6 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +6 -2
  16. package/dist/index.js.map +1 -1
  17. package/dist/mcp-app.d.ts +118 -0
  18. package/dist/mcp-app.d.ts.map +1 -0
  19. package/dist/mcp-app.js +126 -0
  20. package/dist/mcp-app.js.map +1 -0
  21. package/dist/meta-tools.d.ts.map +1 -1
  22. package/dist/meta-tools.js +27 -5
  23. package/dist/meta-tools.js.map +1 -1
  24. package/dist/proxied-tool.d.ts +11 -0
  25. package/dist/proxied-tool.d.ts.map +1 -1
  26. package/dist/proxied-tool.js +13 -1
  27. package/dist/proxied-tool.js.map +1 -1
  28. package/dist/results.d.ts +20 -1
  29. package/dist/results.d.ts.map +1 -1
  30. package/dist/results.js +117 -3
  31. package/dist/results.js.map +1 -1
  32. package/dist/tool-interface.d.ts +137 -0
  33. package/dist/tool-interface.d.ts.map +1 -0
  34. package/dist/tool-interface.js +640 -0
  35. package/dist/tool-interface.js.map +1 -0
  36. package/dist/utcp-namespace.d.ts +14 -0
  37. package/dist/utcp-namespace.d.ts.map +1 -1
  38. package/dist/utcp-namespace.js +7 -2
  39. package/dist/utcp-namespace.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/call-guards.ts +237 -0
  42. package/src/dispatch.ts +18 -1
  43. package/src/get-has-no-body.ts +110 -0
  44. package/src/index.ts +39 -0
  45. package/src/mcp-app.ts +194 -0
  46. package/src/meta-tools.ts +30 -5
  47. package/src/proxied-tool.ts +23 -1
  48. package/src/results.ts +129 -3
  49. package/src/tool-interface.ts +673 -0
  50. package/src/utcp-namespace.ts +7 -2
@@ -0,0 +1,47 @@
1
+ import type { CodeModeUtcpClient } from '@utcp/code-mode';
2
+ /**
3
+ * The refusal a call that does not match its tool gets: a 400 carrying
4
+ * `arguments-do-not-match`, the mismatches, the tool's interface and the call
5
+ * example.
6
+ *
7
+ * Shaped like the typed refusals the platform's REST tools return, so it
8
+ * reaches an agent the same way they do: `response.data` is what
9
+ * `describeToolFailure` reads, and the enumerable `status` / `data` are what a
10
+ * chain sees on the thrown error.
11
+ */
12
+ export declare class ArgumentsDoNotMatchError extends Error {
13
+ readonly status = 400;
14
+ readonly kind = "arguments-do-not-match";
15
+ readonly data: {
16
+ error: string;
17
+ kind: string;
18
+ status: number;
19
+ };
20
+ readonly response: {
21
+ status: number;
22
+ data: {
23
+ error: string;
24
+ kind: string;
25
+ status: number;
26
+ };
27
+ };
28
+ constructor(message: string);
29
+ }
30
+ /**
31
+ * Check `args` against the tool registered as `toolName`, returning the
32
+ * refusal message when they do not match and `null` when they do (or when the
33
+ * tool's schema cannot be used for checking, which is logged once).
34
+ *
35
+ * Exported for the surfaces' tests; the guards below are the only caller in
36
+ * production.
37
+ */
38
+ export declare function argumentRefusal(client: CodeModeUtcpClient, toolName: string, args: Record<string, unknown>): Promise<string | null>;
39
+ /**
40
+ * Install the guards on `client`. Idempotent per client, and ORDER-PROOF: when
41
+ * another layer (the downstream router, session recovery, the audit
42
+ * instrumentation) has re-wrapped the call methods since, the guards are
43
+ * wrapped around that one too, so they stay outermost and a routed call cannot
44
+ * slip past them. Checking twice is free — the check is pure and compiled once.
45
+ */
46
+ export declare function installCallGuards(client: CodeModeUtcpClient): void;
47
+ //# sourceMappingURL=call-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-guards.d.ts","sourceRoot":"","sources":["../src/call-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAoC1D;;;;;;;;;GASG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,MAAM,OAAO;IACtB,QAAQ,CAAC,IAAI,4BAA+B;IAC5C,QAAQ,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,QAAQ,CAAC,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;gBAEjF,OAAO,EAAE,MAAM;CAM5B;AAgED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6BxB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAyDlE"}
@@ -0,0 +1,215 @@
1
+ import { ARGUMENTS_DO_NOT_MATCH_KIND, argumentsDoNotMatchMessage, checkFor } from './tool-interface.js';
2
+ import { NOT_JSON_KIND, pageInsteadOfJson } from './results.js';
3
+ import { isPlatformHostedUrl } from './utcp-namespace.js';
4
+ /**
5
+ * The guards the tool client puts in front of a call to a tool THIS SERVER DOES
6
+ * NOT HOST: its arguments are checked against the tool's own input schema before
7
+ * anything leaves, and an answer that is a web page where JSON was expected is
8
+ * cut to something an agent can read.
9
+ *
10
+ * The check lives where the tool lives. A tool the platform (or a deployment)
11
+ * hosts as a route of its own is checked IN THAT ROUTE's handler, so every
12
+ * caller gets the same answer — an agent over MCP, a chain, and a script
13
+ * calling `POST /api/agent/tools/<name>` with a connection key alike. What is
14
+ * left for the client are the tools with no route here: a connected server's
15
+ * tools, and an http tool that calls another service directly. Those are
16
+ * checked here, before the call leaves, and route-hosted tools are skipped so
17
+ * they are not checked twice and so the route's own answer is what comes back.
18
+ *
19
+ * Installed on the UTCP client, which is the one place both of ITS call paths
20
+ * meet: `callToolStreaming` is the MCP dispatch path and `callTool` is what
21
+ * `call_tool_chain` bridges every in-isolate tool function to.
22
+ *
23
+ * Nothing here changes a call. A call that matches its schema is passed on with
24
+ * exactly the arguments that were given — no argument is added, removed,
25
+ * renamed or coerced — because a checker that repaired calls would hide the
26
+ * mistake it was built to report, and would be wrong for at least one protocol.
27
+ */
28
+ /** Marks the client's call methods as already wrapped by THESE guards. */
29
+ const GUARDED = Symbol.for('bevel.mcp-core.callGuards');
30
+ /** Tools whose schema could not be used for checking, so the reason is logged once each. */
31
+ const unchecked = new Set();
32
+ /**
33
+ * The refusal a call that does not match its tool gets: a 400 carrying
34
+ * `arguments-do-not-match`, the mismatches, the tool's interface and the call
35
+ * example.
36
+ *
37
+ * Shaped like the typed refusals the platform's REST tools return, so it
38
+ * reaches an agent the same way they do: `response.data` is what
39
+ * `describeToolFailure` reads, and the enumerable `status` / `data` are what a
40
+ * chain sees on the thrown error.
41
+ */
42
+ export class ArgumentsDoNotMatchError extends Error {
43
+ status = 400;
44
+ kind = ARGUMENTS_DO_NOT_MATCH_KIND;
45
+ data;
46
+ response;
47
+ constructor(message) {
48
+ super(message);
49
+ this.name = 'ArgumentsDoNotMatchError';
50
+ this.data = { error: message, kind: ARGUMENTS_DO_NOT_MATCH_KIND, status: 400 };
51
+ this.response = { status: 400, data: this.data };
52
+ }
53
+ }
54
+ /** The error a tool's non-JSON answer becomes: short, with the page left behind. */
55
+ class NotJsonError extends Error {
56
+ kind = NOT_JSON_KIND;
57
+ data;
58
+ response;
59
+ constructor(message) {
60
+ super(message);
61
+ this.name = 'NotJsonError';
62
+ this.data = { error: message, kind: NOT_JSON_KIND };
63
+ this.response = { data: this.data };
64
+ }
65
+ }
66
+ /** The protocols whose answer is an HTTP response, and so can be a web page. */
67
+ const HTTP_PROTOCOLS = new Set(['http', 'streamable_http', 'sse']);
68
+ /**
69
+ * Where this server mounts the tools it hosts itself: one route per tool, under
70
+ * one prefix, which is what `toolDef` builds every platform (and deployment)
71
+ * tool's URL from.
72
+ */
73
+ const AGENT_TOOL_ROUTE_PREFIX = '/api/agent/tools/';
74
+ /** The length of the `${API_URL}` origin template, so the path can be read past it. */
75
+ const PLATFORM_ORIGIN_TEMPLATE_LENGTH = '${API_URL}'.length;
76
+ /**
77
+ * Is this tool a route THIS server hosts? Such a tool is checked by its own
78
+ * route handler — which sees the flat arguments the handler really takes and
79
+ * answers every caller, not only the ones that came through a client — so the
80
+ * client must leave it alone: checking it here would check it twice, and the
81
+ * first refusal would replace the route's answer with one of our own.
82
+ *
83
+ * Decided on two things together: `${API_URL}` as the template's ORIGIN, which
84
+ * expands to this server's own loopback and which a tool definition cannot fake
85
+ * (a third-party `.tool` can put that literal in a path or a query but cannot
86
+ * make it the authority without pointing the request back at us — the same rule
87
+ * as the credential seeding in `utcp-namespace.ts`), AND the agent-tool route
88
+ * prefix every such tool is served under. Both are needed: a `.tool` an
89
+ * administrator wrote may legitimately point at some OTHER endpoint of this
90
+ * same backend, and that one has no tool handler to check it, so the client
91
+ * must.
92
+ */
93
+ function isHostedAsARouteHere(tool) {
94
+ const template = tool.tool_call_template;
95
+ if (!template)
96
+ return false;
97
+ const type = typeof template.call_template_type === 'string' ? template.call_template_type : '';
98
+ if (!HTTP_PROTOCOLS.has(type))
99
+ return false;
100
+ const url = template.url;
101
+ if (typeof url !== 'string' || !isPlatformHostedUrl(url))
102
+ return false;
103
+ return url.slice(PLATFORM_ORIGIN_TEMPLATE_LENGTH).startsWith(AGENT_TOOL_ROUTE_PREFIX);
104
+ }
105
+ /**
106
+ * Check `args` against the tool registered as `toolName`, returning the
107
+ * refusal message when they do not match and `null` when they do (or when the
108
+ * tool's schema cannot be used for checking, which is logged once).
109
+ *
110
+ * Exported for the surfaces' tests; the guards below are the only caller in
111
+ * production.
112
+ */
113
+ export async function argumentRefusal(client, toolName, args) {
114
+ const tool = (await client.config.tool_repository.getTool(toolName));
115
+ // Not registered: the client's own "not found in the repository" is the
116
+ // honest answer, and inventing a mismatch for a tool that does not exist
117
+ // would bury it.
118
+ if (!tool)
119
+ return null;
120
+ // Hosted here as a route: its handler does the checking, and its answer is
121
+ // what the caller must get (see `isHostedAsARouteHere`).
122
+ if (isHostedAsARouteHere(tool))
123
+ return null;
124
+ const check = checkFor(tool.inputs);
125
+ if (!check.checkable) {
126
+ // Once per tool, not once per call: a tool with an unusable schema is
127
+ // called on every turn, and the reason is a property of the schema.
128
+ if (!unchecked.has(toolName)) {
129
+ unchecked.add(toolName);
130
+ console.warn(`[mcp] calling "${toolName}" without checking its arguments — ${check.reason}. ` +
131
+ 'Its calls are passed through as they are.');
132
+ }
133
+ return null;
134
+ }
135
+ const mismatches = check.check(args ?? {});
136
+ if (mismatches.length === 0)
137
+ return null;
138
+ // The name the agent used is the bare tool name, not the `<manual>.<tool>`
139
+ // the registry keys on — but the call example has to show the namespace, so
140
+ // both go in: the sentence names the tool, the example names the call.
141
+ const bare = toolName.includes('.') ? toolName.slice(toolName.lastIndexOf('.') + 1) : toolName;
142
+ return argumentsDoNotMatchMessage(bare, toolName, tool.inputs, mismatches);
143
+ }
144
+ /**
145
+ * Install the guards on `client`. Idempotent per client, and ORDER-PROOF: when
146
+ * another layer (the downstream router, session recovery, the audit
147
+ * instrumentation) has re-wrapped the call methods since, the guards are
148
+ * wrapped around that one too, so they stay outermost and a routed call cannot
149
+ * slip past them. Checking twice is free — the check is pure and compiled once.
150
+ */
151
+ export function installCallGuards(client) {
152
+ // Each call method is guarded on its own: a client with only one of them
153
+ // can still call tools through it, and that one path is checked all the
154
+ // same. A client with neither cannot call a tool, so there is nothing to
155
+ // guard. (A test double that only registers manuals is exactly that.)
156
+ const hasCallTool = typeof client.callTool === 'function';
157
+ const hasStreaming = typeof client.callToolStreaming === 'function';
158
+ if (!hasCallTool && !hasStreaming)
159
+ return;
160
+ const repositoryTool = async (toolName) => (await client.config.tool_repository.getTool(toolName));
161
+ const guardResult = async (toolName, value) => {
162
+ if (typeof value !== 'string')
163
+ return;
164
+ const short = pageInsteadOfJson(value);
165
+ if (!short)
166
+ return;
167
+ const tool = await repositoryTool(toolName);
168
+ const type = tool?.tool_call_template?.call_template_type;
169
+ if (!HTTP_PROTOCOLS.has(typeof type === 'string' ? type : ''))
170
+ return;
171
+ // A tool that DECLARES a string answer may answer with markup: by the
172
+ // time the value is here the transport has decoded it, and a JSON string
173
+ // that holds a page looks exactly like a page. Only a tool that promised
174
+ // structured data is held to it.
175
+ if (declaresStringOutput(tool?.outputs))
176
+ return;
177
+ const bare = toolName.includes('.') ? toolName.slice(toolName.lastIndexOf('.') + 1) : toolName;
178
+ throw new NotJsonError(`The "${bare}" tool answered with a page, not JSON: ${short}`);
179
+ };
180
+ if (hasCallTool && client.callTool[GUARDED] !== true) {
181
+ const callTool = client.callTool.bind(client);
182
+ const guarded = async function guardedCallTool(toolName, toolArgs) {
183
+ const refusal = await argumentRefusal(client, toolName, toolArgs);
184
+ if (refusal)
185
+ throw new ArgumentsDoNotMatchError(refusal);
186
+ const result = await callTool(toolName, toolArgs);
187
+ await guardResult(toolName, result);
188
+ return result;
189
+ };
190
+ guarded[GUARDED] = true;
191
+ client.callTool = guarded;
192
+ }
193
+ if (hasStreaming && client.callToolStreaming[GUARDED] !== true) {
194
+ const callToolStreaming = client.callToolStreaming.bind(client);
195
+ const guardedStreaming = async function* guardedCallToolStreaming(toolName, toolArgs) {
196
+ const refusal = await argumentRefusal(client, toolName, toolArgs);
197
+ if (refusal)
198
+ throw new ArgumentsDoNotMatchError(refusal);
199
+ for await (const chunk of callToolStreaming(toolName, toolArgs)) {
200
+ await guardResult(toolName, chunk);
201
+ yield chunk;
202
+ }
203
+ };
204
+ guardedStreaming[GUARDED] = true;
205
+ client.callToolStreaming = guardedStreaming;
206
+ }
207
+ }
208
+ /** Does this output schema say the tool answers with a string? */
209
+ function declaresStringOutput(outputs) {
210
+ if (typeof outputs !== 'object' || outputs === null)
211
+ return false;
212
+ const type = outputs.type;
213
+ return type === 'string' || (Array.isArray(type) && type.includes('string'));
214
+ }
215
+ //# sourceMappingURL=call-guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-guards.js","sourceRoot":"","sources":["../src/call-guards.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,0EAA0E;AAC1E,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAExD,4FAA4F;AAC5F,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACxC,MAAM,GAAG,GAAG,CAAC;IACb,IAAI,GAAG,2BAA2B,CAAC;IACnC,IAAI,CAAkD;IACtD,QAAQ,CAA4E;IAE7F,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,EAAE,MAAM,EAAE,GAAG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AwB,CAC/D,QAAgB,EAChB,QAAiC;YAEjC,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAClE,IAAI,OAAO;gBAAE,MAAM,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;YACzD,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;gBAChE,MAAM,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACnC,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CAAC;QACD,gBAAuD,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;QACzE,MAAM,CAAC,iBAAiB,GAAG,gBAAmD,CAAC;IACjF,CAAC;AACH,CAAC;AAED,kEAAkE;AAClE,SAAS,oBAAoB,CAAC,OAAgB;IAC5C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,IAAI,GAAI,OAA8B,CAAC,IAAI,CAAC;IAClD,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC/E,CAAC"}
@@ -40,5 +40,9 @@ export declare function registerManual(client: CodeModeUtcpClient, manual: CallT
40
40
  * MCP `arguments`), and the advertised schema is the tool's UTCP `inputs`
41
41
  * verbatim too, so any reshaping here would be wrong for at least one protocol.
42
42
  */
43
- export declare function dispatchToolCall(client: CodeModeUtcpClient, tool: ProxiedTool, args: Record<string, unknown>, onProgress?: (progress: number, message: string) => Promise<void>): Promise<CallToolResult>;
43
+ export declare function dispatchToolCall(client: CodeModeUtcpClient, tool: ProxiedTool, args: Record<string, unknown>, onProgress?: (progress: number, message: string) => Promise<void>,
44
+ /** See {@link toCallToolResult}'s `structured`. */
45
+ options?: {
46
+ structured?: boolean;
47
+ }): Promise<CallToolResult>;
44
48
  //# sourceMappingURL=dispatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAWtD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAChE,OAAO,CAAC,cAAc,CAAC,CA4BzB"}
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAwBtD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;AACjE,mDAAmD;AACnD,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GACjC,OAAO,CAAC,cAAc,CAAC,CA4BzB"}
package/dist/dispatch.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { toCallToolResult, toolError, describeToolFailure, renderProgress } from './results.js';
2
+ import { installCallGuards } from './call-guards.js';
3
+ import { installGetHasNoBody } from './get-has-no-body.js';
2
4
  /**
3
5
  * Register one manual on a client, reduced to a verdict.
4
6
  *
@@ -13,6 +15,19 @@ import { toCallToolResult, toolError, describeToolFailure, renderProgress } from
13
15
  * here — so it comes back as `{ ok: false }` for the caller to police.
14
16
  */
15
17
  export async function registerManual(client, manual) {
18
+ // A tool must be registered before it can be called, so registration is the
19
+ // one point every tool of every surface passes through — and therefore where
20
+ // the client's guards are installed. A deployment that registers manuals of
21
+ // its own gets the argument check and the GET-sends-no-body rule for its
22
+ // tools without writing a line for either. Both are idempotent.
23
+ //
24
+ // The client checks the tools with no route HERE — a connected server's, and
25
+ // an http tool that calls another service. A tool this server hosts as a
26
+ // route is checked in that route's own handler instead, so every caller gets
27
+ // the same answer and the route's answer is what comes back
28
+ // (`call-guards.ts`).
29
+ installGetHasNoBody();
30
+ installCallGuards(client);
16
31
  try {
17
32
  const result = await client.registerManual(manual);
18
33
  if (result && result.success === false) {
@@ -44,7 +59,9 @@ export async function registerManual(client, manual) {
44
59
  * MCP `arguments`), and the advertised schema is the tool's UTCP `inputs`
45
60
  * verbatim too, so any reshaping here would be wrong for at least one protocol.
46
61
  */
47
- export async function dispatchToolCall(client, tool, args, onProgress) {
62
+ export async function dispatchToolCall(client, tool, args, onProgress,
63
+ /** See {@link toCallToolResult}'s `structured`. */
64
+ options) {
48
65
  let prev;
49
66
  let hasPrev = false;
50
67
  let progress = 0;
@@ -67,6 +84,6 @@ export async function dispatchToolCall(client, tool, args, onProgress) {
67
84
  if (!hasPrev) {
68
85
  return toolError(`The "${tool.mcpName}" tool produced no output: its stream ended without a result.`);
69
86
  }
70
- return toCallToolResult(prev);
87
+ return toCallToolResult(prev, options);
71
88
  }
72
89
  //# sourceMappingURL=dispatch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEhG;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA0B,EAC1B,MAAoB;IAEpB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACnD,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC;YACzF,OAAO,EAAE,EAAE,EAAE,KAAK,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AED,OAAO,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * A GET tool never sends a request body — whatever it is called with, and
3
+ * whoever registered it.
4
+ *
5
+ * A UTCP http tool sends the one argument named by its template's `body_field`
6
+ * (which DEFAULTS to `body`) as the request body, for any method. So a flat GET
7
+ * tool called with its arguments wrapped in `body` — the shape the platform's
8
+ * own tools take, and the mistake an agent makes most often — sends a GET with
9
+ * a body. Services answer that with whatever their edge does: three users of
10
+ * the enterprise deployment got an HTML error page where a search result was
11
+ * expected.
12
+ *
13
+ * The fix is in the request client rather than in each tool's definition,
14
+ * because the definitions come from three places (the platform's own
15
+ * `toolDef`, a deployment's tools, and an administrator's tool manual) and a
16
+ * rule enforced in three places is a rule that holds in two. Here, the
17
+ * protocol that would send the body is handed a template whose `body_field`
18
+ * names an argument no tool declares, so there is nothing to put in the body;
19
+ * the argument itself is untouched and travels as a query parameter, exactly as
20
+ * every other argument does.
21
+ */
22
+ /**
23
+ * The `body_field` a GET template is given. Deliberately not a name any schema
24
+ * would declare: the leading `__` and the markers make it unreachable from a
25
+ * generated call example or a described interface, so no agent is ever told to
26
+ * send it. The tail is drawn once per process, so a manual cannot write the
27
+ * name into its own template and have an argument of that name sent as the
28
+ * body after all: the name it would have to guess does not exist until the
29
+ * server starts.
30
+ */
31
+ export declare const NO_BODY_FIELD: string;
32
+ /**
33
+ * The template a GET tool is actually called with. Returns the template
34
+ * unchanged for anything that is not an http-family GET, so a POST tool, an
35
+ * `mcp` tool and a template with no method at all all pass through untouched.
36
+ */
37
+ export declare function withoutBodyOnGet<T>(template: T): T;
38
+ /**
39
+ * Install the guard over every communication protocol registered in this
40
+ * process, instances and factories alike — the registry the UTCP SDK documents
41
+ * as "the right home for a registry a decorator writes into".
42
+ *
43
+ * Process-wide and idempotent, so every client built afterwards is covered
44
+ * without being told to be: the hosted proxy's per-request clients, the pooled
45
+ * downstream clients, the local server's client, and a client a deployment
46
+ * builds on top of Hexis.
47
+ */
48
+ export declare function installGetHasNoBody(): void;
49
+ //# sourceMappingURL=get-has-no-body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-has-no-body.d.ts","sourceRoot":"","sources":["../src/get-has-no-body.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAAiE,CAAC;AAU5F;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAOlD;AA2BD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAgB1C"}
@@ -0,0 +1,104 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { CommunicationProtocol } from '@utcp/sdk';
3
+ /**
4
+ * A GET tool never sends a request body — whatever it is called with, and
5
+ * whoever registered it.
6
+ *
7
+ * A UTCP http tool sends the one argument named by its template's `body_field`
8
+ * (which DEFAULTS to `body`) as the request body, for any method. So a flat GET
9
+ * tool called with its arguments wrapped in `body` — the shape the platform's
10
+ * own tools take, and the mistake an agent makes most often — sends a GET with
11
+ * a body. Services answer that with whatever their edge does: three users of
12
+ * the enterprise deployment got an HTML error page where a search result was
13
+ * expected.
14
+ *
15
+ * The fix is in the request client rather than in each tool's definition,
16
+ * because the definitions come from three places (the platform's own
17
+ * `toolDef`, a deployment's tools, and an administrator's tool manual) and a
18
+ * rule enforced in three places is a rule that holds in two. Here, the
19
+ * protocol that would send the body is handed a template whose `body_field`
20
+ * names an argument no tool declares, so there is nothing to put in the body;
21
+ * the argument itself is untouched and travels as a query parameter, exactly as
22
+ * every other argument does.
23
+ */
24
+ /**
25
+ * The `body_field` a GET template is given. Deliberately not a name any schema
26
+ * would declare: the leading `__` and the markers make it unreachable from a
27
+ * generated call example or a described interface, so no agent is ever told to
28
+ * send it. The tail is drawn once per process, so a manual cannot write the
29
+ * name into its own template and have an argument of that name sent as the
30
+ * body after all: the name it would have to guess does not exist until the
31
+ * server starts.
32
+ */
33
+ export const NO_BODY_FIELD = `__utcp_get_sends_no_body_${randomUUID().replace(/-/g, '')}__`;
34
+ /** Marks a protocol instance as already decorated, so installing twice is free. */
35
+ const GUARDED = Symbol.for('bevel.mcp-core.getHasNoBody');
36
+ /**
37
+ * The template a GET tool is actually called with. Returns the template
38
+ * unchanged for anything that is not an http-family GET, so a POST tool, an
39
+ * `mcp` tool and a template with no method at all all pass through untouched.
40
+ */
41
+ export function withoutBodyOnGet(template) {
42
+ const t = template;
43
+ if (!t || typeof t !== 'object')
44
+ return template;
45
+ const method = typeof t.http_method === 'string' ? t.http_method.toUpperCase() : undefined;
46
+ if (method !== 'GET')
47
+ return template;
48
+ if (t.body_field === NO_BODY_FIELD)
49
+ return template;
50
+ return { ...template, body_field: NO_BODY_FIELD };
51
+ }
52
+ /** Decorate one protocol instance in place. Returns it, decorated or already so. */
53
+ function decorate(protocol) {
54
+ const p = protocol;
55
+ if (!p || p[GUARDED] === true)
56
+ return protocol;
57
+ p[GUARDED] = true;
58
+ // The template is the LAST argument of both methods (`caller, toolName,
59
+ // toolArgs, toolCallTemplate`), already variable-substituted by the client.
60
+ // Replacing it here is the last moment before the request is built, and the
61
+ // only one where every registration path has converged.
62
+ for (const name of ['callTool', 'callToolStreaming']) {
63
+ const original = p[name];
64
+ if (typeof original !== 'function')
65
+ continue;
66
+ p[name] = function guardedCall(...args) {
67
+ if (args.length > 0)
68
+ args[args.length - 1] = withoutBodyOnGet(args[args.length - 1]);
69
+ return original.apply(this, args);
70
+ };
71
+ }
72
+ return protocol;
73
+ }
74
+ /**
75
+ * Install the guard over every communication protocol registered in this
76
+ * process, instances and factories alike — the registry the UTCP SDK documents
77
+ * as "the right home for a registry a decorator writes into".
78
+ *
79
+ * Process-wide and idempotent, so every client built afterwards is covered
80
+ * without being told to be: the hosted proxy's per-request clients, the pooled
81
+ * downstream clients, the local server's client, and a client a deployment
82
+ * builds on top of Hexis.
83
+ */
84
+ export function installGetHasNoBody() {
85
+ const instances = CommunicationProtocol.communicationProtocols;
86
+ for (const type of Object.keys(instances)) {
87
+ const instance = instances[type];
88
+ if (instance)
89
+ decorate(instance);
90
+ }
91
+ const factories = CommunicationProtocol.communicationProtocolFactories;
92
+ for (const type of Object.keys(factories)) {
93
+ const factory = factories[type];
94
+ if (!factory)
95
+ continue;
96
+ const marked = factory;
97
+ if (marked[GUARDED] === true)
98
+ continue;
99
+ const wrapped = (() => decorate(factory()));
100
+ wrapped[GUARDED] = true;
101
+ factories[type] = wrapped;
102
+ }
103
+ }
104
+ //# sourceMappingURL=get-has-no-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-has-no-body.js","sourceRoot":"","sources":["../src/get-has-no-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,4BAA4B,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;AAE5F,mFAAmF;AACnF,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAO1D;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAI,QAAW;IAC7C,MAAM,CAAC,GAAG,QAAkC,CAAC;IAC7C,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IACjD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,QAAQ,CAAC;IACtC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AI,QAAQ;YAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IACD,MAAM,SAAS,GAAG,qBAAqB,CAAC,8BAA8B,CAAC;IACvE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO;YAAE,SAAS;QACvB,MAAM,MAAM,GAAG,OAAmD,CAAC;QACnE,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI;YAAE,SAAS;QACvC,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAA6C,CAAC;QACxF,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;QACxB,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAC5B,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -27,15 +27,19 @@
27
27
  */
28
28
  export { type ProxiedTool, toListedTool, sanitizeInputSchema, flattenManualTool, flattenDiscoveredTool, } from './proxied-tool.js';
29
29
  export { type SchemaDefect, inputSchemaDefect, schemaDefectMarker, } from './schema-validity.js';
30
- export { describeToolFailure, withTransportDetail, toCallToolResult, renderProgress, toolError, needsAuthorizationResult, MCP_IMAGE_RESULT_KIND, type McpImageResult, mcpImageResult, isMcpImageResult, omitImagePayloads, } from './results.js';
30
+ export { MCP_APP_UI_META_KEY, MCP_APP_MIME_TYPE, MCP_APP_URI_SCHEME, type McpAppToolUi, type McpAppResourceUi, type McpAppResource, type McpAppManifest, toolUiMeta, resourceUiMeta, toListedResource, toReadResourceResult, parseMcpAppManifest, } from './mcp-app.js';
31
+ export { describeToolFailure, withTransportDetail, toCallToolResult, renderProgress, toolError, needsAuthorizationResult, MCP_IMAGE_RESULT_KIND, type McpImageResult, mcpImageResult, isMcpImageResult, omitImagePayloads, NOT_JSON_KIND, pageInsteadOfJson, } from './results.js';
31
32
  export { codeModeMetaTools, chainNamespaceExample, META_TOOL_NAMES, CALL_TOOL_CHAIN_MAX_OUTPUT, CALL_TOOL_CHAIN_NAME, CHAIN_FAILURES_RULE, CHAIN_LARGE_RESULTS_RULE, type CodeModeMetaToolsOptions, type SpillPort, dispatchMetaTool, } from './meta-tools.js';
32
33
  export { CHAIN_RUNTIME_PRELUDE, CHAIN_TIMEOUT_DEFAULT_MS, CHAIN_TIMEOUT_MAX_MS, CHAIN_TIMEOUT_MIN_MS, type ChainNamespaces, type ToolChainOutcome, chainNamespaces, chainOutOfMemoryMessage, chainTimeoutMessage, describeChainFailure, runToolChain, unknownNamespaceMessage, withChainRuntime, } from './chain-runtime.js';
33
34
  export { type ChainExample, type ChainExampleTool, chainExample, } from './chain-example.js';
34
35
  export { registerManual, dispatchToolCall } from './dispatch.js';
36
+ export { CALL_LINE_PREFIX, ARGUMENTS_DO_NOT_MATCH_KIND, BODY_AT_TOP_LEVEL_LINE, ARGS_UNDER_BODY_LINE, callExample, exampleArguments, callLine, withCallExample, splitCallLine, describeInterface, argumentsDoNotMatchMessage, compileCheck, checkFor, type CompiledCheck, } from './tool-interface.js';
37
+ export { installCallGuards, argumentRefusal, ArgumentsDoNotMatchError } from './call-guards.js';
38
+ export { installGetHasNoBody, withoutBodyOnGet, NO_BODY_FIELD } from './get-has-no-body.js';
35
39
  export { RETIRED_TOOL_MESSAGES, RETIRED_TOOL_NAMES, retiredToolMessage, retiredToolInFailure, } from './retired-tools.js';
36
40
  export { isSessionLoss, installSessionRecovery, noteManualReregistered, type SessionRecoveryOptions, } from './session-recovery.js';
37
41
  export { type SkillSummary, type LoadedSkill, skillPromptText, } from './skills.js';
38
- export { utcpNamespacePrefix, utcpNamespacedKey, seedBevelHostedManualVars, } from './utcp-namespace.js';
42
+ export { utcpNamespacePrefix, utcpNamespacedKey, seedBevelHostedManualVars, isPlatformHostedUrl, } from './utcp-namespace.js';
39
43
  export { sanitizeIdentifier, utcpNameToTsInterfaceName, findToolByName, findToolsByNames, AmbiguousToolNameError, } from './code-mode-names.js';
40
44
  export { printable } from './printable.js';
41
45
  export { GOOGLE_SERVICE_ACCOUNT_AUTH_TYPE, GOOGLE_TOKEN_URL, GoogleAuthHttpProtocol, GoogleServiceAccountTokenSource, ServiceAccountAuthError, findUnservedGoogleServiceAccountAuth, holdsLiteralGoogleServiceAccountKey, installGoogleServiceAccountAuth, isGoogleServiceAccountAuth, type GoogleServiceAccountAuth, type IServiceAccountTokenSource, } from './google-service-account/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,YAAY,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,cAAc,EACnB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,SAAS,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,uBAAuB,EACvB,gBAA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AAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAEhG,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5F,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAM3C,OAAO,EACL,gCAAgC,EAChC,gBAAgB,EAChB,sBAAsB,EACtB,+BAA+B,EAC/B,uBAAuB,EACvB,oCAAoC,EACpC,mCAAmC,EACnC,+BAA+B,EAC/B,0BAA0B,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,GAChC,MAAM,mCAAmC,CAAC"}
package/dist/index.js CHANGED
@@ -27,15 +27,19 @@
27
27
  */
28
28
  export { toListedTool, sanitizeInputSchema, flattenManualTool, flattenDiscoveredTool, } from './proxied-tool.js';
29
29
  export { inputSchemaDefect, schemaDefectMarker, } from './schema-validity.js';
30
- export { describeToolFailure, withTransportDetail, toCallToolResult, renderProgress, toolError, needsAuthorizationResult, MCP_IMAGE_RESULT_KIND, mcpImageResult, isMcpImageResult, omitImagePayloads, } from './results.js';
30
+ export { MCP_APP_UI_META_KEY, MCP_APP_MIME_TYPE, MCP_APP_URI_SCHEME, toolUiMeta, resourceUiMeta, toListedResource, toReadResourceResult, parseMcpAppManifest, } from './mcp-app.js';
31
+ export { describeToolFailure, withTransportDetail, toCallToolResult, renderProgress, toolError, needsAuthorizationResult, MCP_IMAGE_RESULT_KIND, mcpImageResult, isMcpImageResult, omitImagePayloads, NOT_JSON_KIND, pageInsteadOfJson, } from './results.js';
31
32
  export { codeModeMetaTools, chainNamespaceExample, META_TOOL_NAMES, CALL_TOOL_CHAIN_MAX_OUTPUT, CALL_TOOL_CHAIN_NAME, CHAIN_FAILURES_RULE, CHAIN_LARGE_RESULTS_RULE, dispatchMetaTool, } from './meta-tools.js';
32
33
  export { CHAIN_RUNTIME_PRELUDE, CHAIN_TIMEOUT_DEFAULT_MS, CHAIN_TIMEOUT_MAX_MS, CHAIN_TIMEOUT_MIN_MS, chainNamespaces, chainOutOfMemoryMessage, chainTimeoutMessage, describeChainFailure, runToolChain, unknownNamespaceMessage, withChainRuntime, } from './chain-runtime.js';
33
34
  export { chainExample, } from './chain-example.js';
34
35
  export { registerManual, dispatchToolCall } from './dispatch.js';
36
+ export { CALL_LINE_PREFIX, ARGUMENTS_DO_NOT_MATCH_KIND, BODY_AT_TOP_LEVEL_LINE, ARGS_UNDER_BODY_LINE, callExample, exampleArguments, callLine, withCallExample, splitCallLine, describeInterface, argumentsDoNotMatchMessage, compileCheck, checkFor, } from './tool-interface.js';
37
+ export { installCallGuards, argumentRefusal, ArgumentsDoNotMatchError } from './call-guards.js';
38
+ export { installGetHasNoBody, withoutBodyOnGet, NO_BODY_FIELD } from './get-has-no-body.js';
35
39
  export { RETIRED_TOOL_MESSAGES, RETIRED_TOOL_NAMES, retiredToolMessage, retiredToolInFailure, } from './retired-tools.js';
36
40
  export { isSessionLoss, installSessionRecovery, noteManualReregistered, } from './session-recovery.js';
37
41
  export { skillPromptText, } from './skills.js';
38
- export { utcpNamespacePrefix, utcpNamespacedKey, seedBevelHostedManualVars, } from './utcp-namespace.js';
42
+ export { utcpNamespacePrefix, utcpNamespacedKey, seedBevelHostedManualVars, isPlatformHostedUrl, } from './utcp-namespace.js';
39
43
  export { sanitizeIdentifier, utcpNameToTsInterfaceName, findToolByName, findToolsByNames, AmbiguousToolNameError, } from './code-mode-names.js';
40
44
  export { printable } from './printable.js';
41
45
  // Loading this package teaches UTCP `auth_type: google_service_account`, on
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAEL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EAErB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EAGxB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EAGpB,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAGL,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM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