holon-sh 0.0.1-dev.4 → 0.0.1-dev.6
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/LICENSE +202 -21
- package/README.md +17 -3
- package/package.json +4 -3
- package/protocol.d.ts +10 -11
- package/runtime.d.ts +2 -4
- package/runtime.mjs +22 -12
package/LICENSE
CHANGED
|
@@ -1,21 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Holon Systems, Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/holon-sh/sdk-ts/actions/workflows/ci.yml)
|
|
4
4
|
[](https://nodejs.org/en/download)
|
|
5
|
-
[](https://github.com/holon-sh/sdk-ts/blob/main/LICENSE)
|
|
6
6
|
|
|
7
7
|
This repository contains the Node.js runtime for [`holon`](https://github.com/holon-sh/cli).
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ This repository contains the Node.js runtime for [`holon`](https://github.com/ho
|
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm install holon-sh@dev
|
|
13
|
-
npm install -D holon-types
|
|
13
|
+
npm install -D holon-types@next
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
`holon-types` is the `holon` CLI. `holon types check` brings its own TypeScript compiler and uses the project's `typescript` when one is installed.
|
|
@@ -51,7 +51,6 @@ try {
|
|
|
51
51
|
await apps.bar.tools.greet({ name: "world" });
|
|
52
52
|
} catch (error) {
|
|
53
53
|
if (!(error instanceof ToolCallError)) throw error;
|
|
54
|
-
error.code; // "tool_error" | "input_required"
|
|
55
54
|
error.result; // the original MCP result
|
|
56
55
|
}
|
|
57
56
|
```
|
|
@@ -76,6 +75,21 @@ if (result.resultType === "input_required") {
|
|
|
76
75
|
|
|
77
76
|
</details>
|
|
78
77
|
|
|
78
|
+
<details open>
|
|
79
|
+
<summary><h3>Answer a server's question</h3></summary>
|
|
80
|
+
|
|
81
|
+
A tool can stop and ask for input through an [MCP elicitation](https://modelcontextprotocol.io/specification/2026-07-28/client/elicitation). Pass `elicit` to answer in place, and the call returns its usual typed output:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const greeting = await apps.bar.tools.greet({ name: "world" }, {
|
|
85
|
+
elicit: async ({ message }) => ({ action: "accept", content: await ask(message) }),
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Without `elicit`, the question arrives on `ToolCallError.result`, or as an `input_required` result from `callTool`. To answer later, for example in another request, call again with `inputResponses` and `requestState`.
|
|
90
|
+
|
|
91
|
+
</details>
|
|
92
|
+
|
|
79
93
|
<details open>
|
|
80
94
|
<summary><h3>Read a resource</h3></summary>
|
|
81
95
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "holon-sh",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.6",
|
|
4
4
|
"description": "Typed MCP clients and app view resources for Node.js.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/holon-sh/sdk-ts.git",
|
|
8
8
|
"directory": "packages/node"
|
|
9
9
|
},
|
|
10
|
-
"license": "
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"engines": {
|
|
13
13
|
"node": ">=22"
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"import": "./view.js"
|
|
34
34
|
},
|
|
35
35
|
"./protocol": {
|
|
36
|
-
"types": "./protocol.d.ts"
|
|
36
|
+
"types": "./protocol.d.ts",
|
|
37
|
+
"import": "./runtime.mjs"
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
40
|
"files": [
|
package/protocol.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type { CallToolRequest, CallToolResult,
|
|
1
|
+
import type { CallToolRequest, CallToolResult, ElicitRequestParams, ElicitResult, InputRequiredResult, InputResponses, ListToolsResult, RequestOptions } from "@modelcontextprotocol/client";
|
|
2
2
|
|
|
3
3
|
/** Bearer-token or OAuth provider accepted by the MCP transport. */
|
|
4
4
|
export type AuthProvider =
|
|
5
5
|
| { token(): Promise<string | undefined>; onUnauthorized?(context: unknown): Promise<void> }
|
|
6
6
|
| { tokens(): unknown; redirectUrl: unknown; clientMetadata: unknown };
|
|
7
|
-
/**
|
|
8
|
-
export type
|
|
7
|
+
/** Answers a server's question so the call that asked can complete. `params.mode` tells a form from a URL to open. */
|
|
8
|
+
export type ElicitHandler = (params: ElicitRequestParams) => ElicitResult | Promise<ElicitResult>;
|
|
9
9
|
|
|
10
10
|
/** MCP request options, including AbortSignal and timeout in milliseconds. Input-required responses are enabled by the runtime. */
|
|
11
11
|
export type CallOptions = Omit<RequestOptions, "allowInputRequired">;
|
|
12
|
+
/** Call options for a tool. `elicit` answers its questions in place, so the call returns the completed result. */
|
|
13
|
+
export type ToolCallOptions = CallOptions & { elicit?: ElicitHandler };
|
|
12
14
|
/** MCP request metadata and input continuation fields. Pass inputResponses and requestState when continuing an input-required result. */
|
|
13
15
|
export type CallMetadata = Omit<CallToolRequest["params"], "name" | "arguments"> & { inputResponses?: InputResponses; requestState?: string };
|
|
14
16
|
/** @internal */
|
|
@@ -21,11 +23,8 @@ export type ToolResult<Output> =
|
|
|
21
23
|
| (Omit<Fields<CallToolResult>, "structuredContent" | "isError"> & { resultType: "complete"; isError: true; structuredContent?: unknown })
|
|
22
24
|
| InputRequiredResult;
|
|
23
25
|
|
|
24
|
-
/** Error thrown by the tools convenience methods for
|
|
26
|
+
/** Error thrown by the tools convenience methods for error or input_required results. Inspect the original result; pass elicit to answer questions in place, or continue later through callTool. */
|
|
25
27
|
export declare class ToolCallError extends Error {
|
|
26
|
-
readonly code: "tool_error" | "input_required";
|
|
27
|
-
readonly app: string;
|
|
28
|
-
readonly tool: string;
|
|
29
28
|
readonly result: Extract<ToolResult<unknown>, { isError: true } | { resultType: "input_required" }>;
|
|
30
29
|
constructor(app: string, tool: string, result: ToolCallError["result"]);
|
|
31
30
|
}
|
|
@@ -41,8 +40,8 @@ export interface ToolClient<I, O, R> {
|
|
|
41
40
|
readonly read: (options?: CallOptions) => Promise<R[U]>;
|
|
42
41
|
readonly watch: (onChange: (value: R[U]) => void | Promise<void>, options?: { signal?: AbortSignal }) => Promise<void>;
|
|
43
42
|
} };
|
|
44
|
-
/** Convenience methods returning structured output, or the complete result for a tool without an output schema. Error
|
|
45
|
-
readonly tools: { readonly [K in Exclude<keyof I, "then" | "toJSON" | "toString" | "valueOf" | "toLocaleString">]: (input: I[K], options?:
|
|
46
|
-
/** Return the full MCP result, preserving error and
|
|
47
|
-
readonly callTool: <K extends keyof I & string>(request: CallMetadata & { name: K; arguments: I[K] }, options?:
|
|
43
|
+
/** Convenience methods returning structured output, or the complete result for a tool without an output schema. Error results throw ToolCallError, as do questions left unanswered. Reserved object method names remain callable through callTool. */
|
|
44
|
+
readonly tools: { readonly [K in Exclude<keyof I, "then" | "toJSON" | "toString" | "valueOf" | "toLocaleString">]: (input: I[K], options?: ToolCallOptions) => Promise<K extends keyof O ? O[K] : CompleteResult<unknown>> };
|
|
45
|
+
/** Return the full MCP result, preserving error results and questions left unanswered. Arguments and successful output are contract-validated. */
|
|
46
|
+
readonly callTool: <K extends keyof I & string>(request: CallMetadata & { name: K; arguments: I[K] }, options?: ToolCallOptions) => Promise<ToolResult<K extends keyof O ? O[K] : unknown>>;
|
|
48
47
|
}
|
package/runtime.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AuthProvider, CallOptions,
|
|
1
|
+
import type { AuthProvider, CallOptions, ToolClient } from "./protocol.js";
|
|
2
2
|
export { ToolCallError } from "./protocol.js";
|
|
3
|
-
export type { AuthProvider, CallOptions, CallMetadata,
|
|
3
|
+
export type { AuthProvider, CallOptions, CallMetadata, ElicitHandler, ToolCallOptions, ToolResult, ToolClient } from "./protocol.js";
|
|
4
4
|
|
|
5
5
|
/** Connection settings for an MCP endpoint. */
|
|
6
6
|
export interface Binding {
|
|
@@ -14,8 +14,6 @@ export interface Binding {
|
|
|
14
14
|
installationUID?: string;
|
|
15
15
|
/** Close the session after every call instead of keeping one connection open. */
|
|
16
16
|
scoped?: boolean;
|
|
17
|
-
/** Client capabilities declared to the server. On protocol 2026-07-28 every request carries them in `_meta["io.modelcontextprotocol/clientCapabilities"]` ([spec](https://modelcontextprotocol.io/specification/2026-07-28/client/elicitation#capabilities)); declare `{ elicitation: { form: {} } }` to receive form elicitations in input-required results. */
|
|
18
|
-
capabilities?: ClientCapabilities;
|
|
19
17
|
}
|
|
20
18
|
/** Alias for an endpoint binding. */
|
|
21
19
|
export type EndpointBinding = Binding;
|
package/runtime.mjs
CHANGED
|
@@ -21,13 +21,12 @@ function environment(identity, name) {
|
|
|
21
21
|
|
|
22
22
|
export class ToolCallError extends Error {
|
|
23
23
|
constructor(app, tool, result) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const asking = result.resultType === "input_required";
|
|
25
|
+
const detail = asking
|
|
26
|
+
? Object.values(result.inputRequests ?? {}).flatMap(({ params }) => [params?.message, params?.url]).filter(Boolean).join(" ")
|
|
27
|
+
: result.content?.find(part => part.type === "text")?.text;
|
|
28
|
+
super(`${app}.${tool}: ${asking ? "additional input required" : "tool failed"}${detail ? `: ${detail}` : ""}`);
|
|
27
29
|
this.name = "ToolCallError";
|
|
28
|
-
this.code = code;
|
|
29
|
-
this.app = app;
|
|
30
|
-
this.tool = tool;
|
|
31
30
|
this.result = result;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -71,8 +70,9 @@ export function createApps(identity, contracts, bindings, options) {
|
|
|
71
70
|
const current = () => binding ?? (bindings ? undefined : resolve(name));
|
|
72
71
|
let connection;
|
|
73
72
|
const connect = resolved => {
|
|
73
|
+
// Every client can be asked: a call answers with elicit, or the question reaches its caller. Servers must not assume a client answers: https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/mrtr#server-requirements-basic-workflow
|
|
74
74
|
// On 2026-07-28 the client sends these capabilities in every request's _meta: https://github.com/modelcontextprotocol/typescript-sdk/blob/fcef852f6cdafea07f36cf6fae69b37c8adf85be/packages/client/src/client/client.ts#L700-L711
|
|
75
|
-
const client = new Client({ name: identity.name, version: identity.version }, { capabilities:
|
|
75
|
+
const client = new Client({ name: identity.name, version: identity.version }, { capabilities: { elicitation: { form: {}, url: {} } }, versionNegotiation: { mode: "auto" } });
|
|
76
76
|
const transport = new StreamableHTTPClientTransport(new URL(resolved.endpoint), { authProvider: resolved.authProvider, fetch: resolved.fetch, requestInit: { credentials: "include", redirect: "error", headers: resolved.installationUID ? { "X-Holon-Installation-UID": resolved.installationUID } : {} } });
|
|
77
77
|
const current = { client, close: async () => {
|
|
78
78
|
await transport.close();
|
|
@@ -105,7 +105,7 @@ export function createApps(identity, contracts, bindings, options) {
|
|
|
105
105
|
};
|
|
106
106
|
const tools = Object.create(null);
|
|
107
107
|
const definitions = new Map((contract?.tools ?? []).map(definition => [definition.name, { definition }]));
|
|
108
|
-
const callTool = async (request, options) => {
|
|
108
|
+
const callTool = async (request, { elicit, ...options } = {}) => {
|
|
109
109
|
const tool = definitions.get(request.name);
|
|
110
110
|
if (!tool && contract) throw new Error(`Unknown tool ${name}.${request.name}.`);
|
|
111
111
|
let validation;
|
|
@@ -117,10 +117,20 @@ export function createApps(identity, contracts, bindings, options) {
|
|
|
117
117
|
};
|
|
118
118
|
validate(validation.input, request.arguments, `arguments for ${name}.${request.name}`);
|
|
119
119
|
}
|
|
120
|
-
const result = await session(options, client =>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
const result = await session(options, async client => {
|
|
121
|
+
const send = request => client.callTool(request, {
|
|
122
|
+
...options, allowInputRequired: true,
|
|
123
|
+
...(tool && { toolDefinition: { ...tool.definition, outputSchema: undefined } }),
|
|
124
|
+
});
|
|
125
|
+
let result = await send(request);
|
|
126
|
+
// A server may keep asking, so answering stops after ten rounds, the MCP clients' own limit, and the last question reaches the caller.
|
|
127
|
+
for (let round = 0; elicit && result.resultType === "input_required" && round < 10; round++) {
|
|
128
|
+
const inputResponses = {};
|
|
129
|
+
for (const [key, { params }] of Object.entries(result.inputRequests ?? {})) inputResponses[key] = await elicit(params);
|
|
130
|
+
result = await send({ ...request, inputResponses, requestState: result.requestState });
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
});
|
|
124
134
|
if (result.resultType === "input_required") return result;
|
|
125
135
|
if (!result.isError && validation?.output) {
|
|
126
136
|
validate(validation.output, result.structuredContent, `structured output from ${name}.${request.name}`);
|