@execbox/core 0.5.0 → 0.7.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 (56) hide show
  1. package/README.md +34 -15
  2. package/dist/{errors-DlbJQYs7.d.ts → errors-BIWv-QIC.d.ts} +2 -2
  3. package/dist/{errors-DlbJQYs7.d.ts.map → errors-BIWv-QIC.d.ts.map} +1 -1
  4. package/dist/{errors-wS8yjQhS.js → errors-DdWVEGU8.js} +1 -1
  5. package/dist/{errors-wS8yjQhS.js.map → errors-DdWVEGU8.js.map} +1 -1
  6. package/dist/{errors-B9ADBuDH.d.cts → errors-y4C-EIWT.d.cts} +2 -2
  7. package/dist/{errors-B9ADBuDH.d.cts.map → errors-y4C-EIWT.d.cts.map} +1 -1
  8. package/dist/{executor-B7q7K_27.d.ts → executor-BOTd9xNK.d.ts} +2 -2
  9. package/dist/{executor-B7q7K_27.d.ts.map → executor-BOTd9xNK.d.ts.map} +1 -1
  10. package/dist/{executor-BsE5nF-j.d.cts → executor-CtbrvTQ_.d.cts} +2 -2
  11. package/dist/{executor-BsE5nF-j.d.cts.map → executor-CtbrvTQ_.d.cts.map} +1 -1
  12. package/dist/index.cjs +2 -10
  13. package/dist/index.d.cts +4 -38
  14. package/dist/index.d.cts.map +1 -1
  15. package/dist/index.d.ts +4 -38
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +3 -3
  18. package/dist/mcp/index.cjs +101 -34
  19. package/dist/mcp/index.cjs.map +1 -1
  20. package/dist/mcp/index.d.cts +24 -4
  21. package/dist/mcp/index.d.cts.map +1 -1
  22. package/dist/mcp/index.d.ts +24 -4
  23. package/dist/mcp/index.d.ts.map +1 -1
  24. package/dist/mcp/index.js +102 -35
  25. package/dist/mcp/index.js.map +1 -1
  26. package/dist/protocol/index.cjs +7 -3
  27. package/dist/protocol/index.cjs.map +1 -1
  28. package/dist/protocol/index.d.cts +4 -4
  29. package/dist/protocol/index.d.cts.map +1 -1
  30. package/dist/protocol/index.d.ts +4 -4
  31. package/dist/protocol/index.d.ts.map +1 -1
  32. package/dist/protocol/index.js +8 -4
  33. package/dist/protocol/index.js.map +1 -1
  34. package/dist/{resolveProvider-UqQxdF4j.js → resolveProvider-CMrXPuTx.js} +14 -3
  35. package/dist/resolveProvider-CMrXPuTx.js.map +1 -0
  36. package/dist/{resolveProvider-BZYSw8Qk.cjs → resolveProvider-DFAg6No5.cjs} +12 -43
  37. package/dist/resolveProvider-DFAg6No5.cjs.map +1 -0
  38. package/dist/{runner-CsrfDub-.cjs → runner-BEY9nWc7.cjs} +2 -1
  39. package/dist/runner-BEY9nWc7.cjs.map +1 -0
  40. package/dist/{runner-6GMM-5ur.js → runner-BWAVLBi6.js} +3 -2
  41. package/dist/runner-BWAVLBi6.js.map +1 -0
  42. package/dist/{runner-ClFrFnz9.d.ts → runner-Cy18Z0u0.d.cts} +26 -2
  43. package/dist/runner-Cy18Z0u0.d.cts.map +1 -0
  44. package/dist/{runner-DSgvu6Ad.d.cts → runner-DXLu0eJV.d.ts} +26 -2
  45. package/dist/runner-DXLu0eJV.d.ts.map +1 -0
  46. package/dist/runtime.cjs +2 -2
  47. package/dist/runtime.d.cts +4 -4
  48. package/dist/runtime.d.ts +4 -4
  49. package/dist/runtime.js +2 -2
  50. package/package.json +1 -1
  51. package/dist/resolveProvider-BZYSw8Qk.cjs.map +0 -1
  52. package/dist/resolveProvider-UqQxdF4j.js.map +0 -1
  53. package/dist/runner-6GMM-5ur.js.map +0 -1
  54. package/dist/runner-ClFrFnz9.d.ts.map +0 -1
  55. package/dist/runner-CsrfDub-.cjs.map +0 -1
  56. package/dist/runner-DSgvu6Ad.d.cts.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @execbox/core
2
2
 
3
- Core execution contract for execbox. Use it to resolve host tools into callable guest namespaces, validate tool boundaries, and bridge MCP servers or clients into the same execution model.
3
+ Provider, schema, and MCP adapter contracts for execbox. Use it to resolve host
4
+ tools into callable guest namespaces before running code with an executor such
5
+ as `@execbox/quickjs`.
4
6
 
5
7
  [![npm version](https://img.shields.io/npm/v/%40execbox%2Fcore?style=flat-square)](https://www.npmjs.com/package/@execbox/core)
6
8
  [![License](https://img.shields.io/github/license/aallam/execbox?style=flat-square)](https://github.com/aallam/execbox/blob/main/LICENSE)
@@ -9,18 +11,17 @@ Core execution contract for execbox. Use it to resolve host tools into callable
9
11
  ## Use `@execbox/core` When
10
12
 
11
13
  - you want to expose host capabilities to guest code through explicit tool providers
12
- - you want one execution contract across QuickJS, remote, or `isolated-vm` runtimes
13
- - you want to wrap MCP servers or clients into callable namespaces instead of exposing raw tool loops
14
+ - you want one execution contract across inline and worker-hosted QuickJS
15
+ - you want to wrap MCP servers or clients into callable namespaces
14
16
 
15
17
  ## Pair It With an Executor
16
18
 
17
- `@execbox/core` defines the provider and tool boundary, but it does not execute guest code on its own.
19
+ `@execbox/core` defines the provider and tool boundary. Guest execution happens
20
+ in an executor package.
18
21
 
19
- | Package | Start here when |
20
- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
21
- | [`@execbox/quickjs`](https://www.npmjs.com/package/@execbox/quickjs) | You want the default path with inline, worker, or process-hosted QuickJS. |
22
- | [`@execbox/remote`](https://www.npmjs.com/package/@execbox/remote) | Your runtime already lives behind an application-owned transport boundary. |
23
- | [`@execbox/isolated-vm`](https://www.npmjs.com/package/@execbox/isolated-vm) | You explicitly want the `isolated-vm` runtime and can support its constraints. |
22
+ | Package | Start here when |
23
+ | -------------------------------------------------------------------- | --------------------------------------------------------------- |
24
+ | [`@execbox/quickjs`](https://www.npmjs.com/package/@execbox/quickjs) | You want the default path with inline or worker-hosted QuickJS. |
24
25
 
25
26
  ## Install
26
27
 
@@ -30,12 +31,28 @@ Most users start with QuickJS:
30
31
  npm install @execbox/core @execbox/quickjs
31
32
  ```
32
33
 
33
- Swap in `@execbox/remote` or `@execbox/isolated-vm` when you need a different runtime boundary.
34
+ ## Provider Boundary
35
+
36
+ Providers are explicit capability grants. `resolveProvider()` validates the
37
+ namespace, normalizes tool schemas, creates guest-safe tool names, wraps tool
38
+ execution with schema checks, and keeps original-to-safe name maps for callers
39
+ that need to explain MCP or generated tool names.
40
+
41
+ Tool inputs and results should be JSON-compatible data. Keep host-only values
42
+ such as clients, handles, secrets, and tenant routing inside the tool
43
+ implementation.
34
44
 
35
45
  ## Runtime Implementer Surface
36
46
 
37
- Application code should usually import from `@execbox/core`, `@execbox/core/mcp`, or `@execbox/core/protocol`.
38
- Executor and runner packages should import shared runtime helpers from `@execbox/core/runtime` instead. That subpath contains the manifest dispatcher, runtime option defaults, timeout helpers, log formatting, code normalization, and error normalization used to keep runtime implementations aligned.
47
+ Most application code can skip this section.
48
+
49
+ Application code should usually import from `@execbox/core` or `@execbox/core/mcp`.
50
+ The `@execbox/core/protocol` and `@execbox/core/runtime` subpaths exist for
51
+ execbox-owned runtime packages. `@execbox/core/protocol` carries the
52
+ worker-hosted QuickJS message contract, while `@execbox/core/runtime` contains
53
+ the manifest dispatcher, runtime option defaults, timeout helpers, log
54
+ formatting, code normalization, and error normalization used to keep runtime
55
+ implementations aligned.
39
56
 
40
57
  ## Smallest Working Usage
41
58
 
@@ -71,7 +88,8 @@ console.log(result);
71
88
 
72
89
  ## MCP Support
73
90
 
74
- Use `@execbox/core/mcp` when you want MCP on either side of the boundary:
91
+ Use `@execbox/core/mcp` when you want MCP on either side of the provider
92
+ boundary:
75
93
 
76
94
  - wrap an upstream MCP server or client into a provider with `createMcpToolProvider()` or `openMcpToolProvider()`
77
95
  - expose execbox code execution back out through an MCP server with `codeMcpServer()`
@@ -86,8 +104,9 @@ Use `@execbox/core/mcp` when you want MCP on either side of the boundary:
86
104
  ## Read Next
87
105
 
88
106
  - [Getting Started](https://execbox.aallam.com/getting-started)
107
+ - [Providers & Tools](https://execbox.aallam.com/providers-and-tools)
108
+ - [Runtime Choices](https://execbox.aallam.com/runtime-choices)
109
+ - [MCP Integration](https://execbox.aallam.com/mcp-integration)
89
110
  - [Examples](https://execbox.aallam.com/examples)
90
111
  - [Security & Boundaries](https://execbox.aallam.com/security)
91
112
  - [Architecture Overview](https://execbox.aallam.com/architecture/)
92
- - [Core Architecture](https://execbox.aallam.com/architecture/execbox-core)
93
- - [MCP And Protocol](https://execbox.aallam.com/architecture/execbox-mcp-and-protocol)
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { u as ExecuteErrorCode } from "./runner-ClFrFnz9.js";
5
+ import { u as ExecuteErrorCode } from "./runner-DXLu0eJV.js";
6
6
 
7
7
  //#region src/errors.d.ts
8
8
 
@@ -26,4 +26,4 @@ declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
26
26
  declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
27
27
  //#endregion
28
28
  export { isExecuteFailure as n, isJsonSerializable as r, ExecuteFailure as t };
29
- //# sourceMappingURL=errors-DlbJQYs7.d.ts.map
29
+ //# sourceMappingURL=errors-BIWv-QIC.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-DlbJQYs7.d.ts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKA,CAAA,CAAA;AACQ,OAAA,CAAA,KAAA,CADK,cAAA,CAAA,OAAA,CAAuB,KAAA,CAC5B;EAKY,IAAA,CAAA,CALZ,gBAKY;EANgB,CAAA,CAAA;;AAgBpC,CAAA,CAAA,CAAA,CAAA;EAOgB,WAAA,CAAA,IAAA,CAAA,CAjBI,gBAmBZ,CAAA,CAAA,OACF,CAAA,CAAA,MAAA,CAAA;;;;;iBAVU,gBAAA,2BAA2C;;;;iBAO3C,kBAAA,0BAER,oBACF"}
1
+ {"version":3,"file":"errors-BIWv-QIC.d.ts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKA,CAAA,CAAA;AACQ,OAAA,CAAA,KAAA,CADK,cAAA,CAAA,OAAA,CAAuB,KAAA,CAC5B;EAKY,IAAA,CAAA,CALZ,gBAKY;EANgB,CAAA,CAAA;;AAgBpC,CAAA,CAAA,CAAA,CAAA;EAOgB,WAAA,CAAA,IAAA,CAAA,CAjBI,gBAmBZ,CAAA,CAAA,OACF,CAAA,CAAA,MAAA,CAAA;;;;;iBAVU,gBAAA,2BAA2C;;;;iBAO3C,kBAAA,0BAER,oBACF"}
@@ -58,4 +58,4 @@ function isJsonSerializable(value, active = /* @__PURE__ */ new Set(), memo = /*
58
58
 
59
59
  //#endregion
60
60
  export { isExecuteFailure as n, isJsonSerializable as r, ExecuteFailure as t };
61
- //# sourceMappingURL=errors-wS8yjQhS.js.map
61
+ //# sourceMappingURL=errors-DdWVEGU8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-wS8yjQhS.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import type { ExecuteErrorCode } from \"./types\";\n\n/**\n * Structured failure used internally to propagate executor and tool errors.\n */\nexport class ExecuteFailure extends Error {\n code: ExecuteErrorCode;\n\n /**\n * Creates a structured failure with a trusted executor or tool error code.\n */\n constructor(code: ExecuteErrorCode, message: string) {\n super(message);\n this.code = code;\n this.name = \"ExecuteFailure\";\n }\n}\n\n/**\n * Returns whether a thrown value is an {@link ExecuteFailure}.\n */\nexport function isExecuteFailure(value: unknown): value is ExecuteFailure {\n return value instanceof ExecuteFailure;\n}\n\n/**\n * Returns whether a value can be serialized through the JSON-only host/guest boundary.\n */\nexport function isJsonSerializable(\n value: unknown,\n active = new Set<object>(),\n memo = new WeakSet<object>(),\n): boolean {\n if (value === null) {\n return true;\n }\n\n switch (typeof value) {\n case \"string\":\n case \"boolean\":\n return true;\n case \"number\":\n return Number.isFinite(value);\n case \"bigint\":\n case \"function\":\n case \"symbol\":\n case \"undefined\":\n return false;\n case \"object\": {\n const objectValue = value as object;\n\n if (memo.has(objectValue)) {\n return true;\n }\n\n if (active.has(objectValue)) {\n return false;\n }\n\n active.add(objectValue);\n let isSerializable = false;\n\n try {\n if (Array.isArray(value)) {\n isSerializable = value.every((item) =>\n isJsonSerializable(item, active, memo),\n );\n return isSerializable;\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return false;\n }\n\n isSerializable = Object.values(value).every((item) =>\n isJsonSerializable(item, active, memo),\n );\n return isSerializable;\n } finally {\n active.delete(objectValue);\n if (isSerializable) {\n memo.add(objectValue);\n }\n }\n }\n }\n\n return false;\n}\n"],"mappings":";;;;AAKA,IAAa,iBAAb,cAAoC,MAAM;CACxC;;;;CAKA,YAAY,MAAwB,SAAiB;AACnD,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;AAOhB,SAAgB,iBAAiB,OAAyC;AACxE,QAAO,iBAAiB;;;;;AAM1B,SAAgB,mBACd,OACA,yBAAS,IAAI,KAAa,EAC1B,uBAAO,IAAI,SAAiB,EACnB;AACT,KAAI,UAAU,KACZ,QAAO;AAGT,SAAQ,OAAO,OAAf;EACE,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,SACH,QAAO,OAAO,SAAS,MAAM;EAC/B,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,YACH,QAAO;EACT,KAAK,UAAU;GACb,MAAM,cAAc;AAEpB,OAAI,KAAK,IAAI,YAAY,CACvB,QAAO;AAGT,OAAI,OAAO,IAAI,YAAY,CACzB,QAAO;AAGT,UAAO,IAAI,YAAY;GACvB,IAAI,iBAAiB;AAErB,OAAI;AACF,QAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,sBAAiB,MAAM,OAAO,SAC5B,mBAAmB,MAAM,QAAQ,KAAK,CACvC;AACD,YAAO;;IAGT,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QAAI,cAAc,OAAO,aAAa,cAAc,KAClD,QAAO;AAGT,qBAAiB,OAAO,OAAO,MAAM,CAAC,OAAO,SAC3C,mBAAmB,MAAM,QAAQ,KAAK,CACvC;AACD,WAAO;aACC;AACR,WAAO,OAAO,YAAY;AAC1B,QAAI,eACF,MAAK,IAAI,YAAY;;;;AAM7B,QAAO"}
1
+ {"version":3,"file":"errors-DdWVEGU8.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import type { ExecuteErrorCode } from \"./types\";\n\n/**\n * Structured failure used internally to propagate executor and tool errors.\n */\nexport class ExecuteFailure extends Error {\n code: ExecuteErrorCode;\n\n /**\n * Creates a structured failure with a trusted executor or tool error code.\n */\n constructor(code: ExecuteErrorCode, message: string) {\n super(message);\n this.code = code;\n this.name = \"ExecuteFailure\";\n }\n}\n\n/**\n * Returns whether a thrown value is an {@link ExecuteFailure}.\n */\nexport function isExecuteFailure(value: unknown): value is ExecuteFailure {\n return value instanceof ExecuteFailure;\n}\n\n/**\n * Returns whether a value can be serialized through the JSON-only host/guest boundary.\n */\nexport function isJsonSerializable(\n value: unknown,\n active = new Set<object>(),\n memo = new WeakSet<object>(),\n): boolean {\n if (value === null) {\n return true;\n }\n\n switch (typeof value) {\n case \"string\":\n case \"boolean\":\n return true;\n case \"number\":\n return Number.isFinite(value);\n case \"bigint\":\n case \"function\":\n case \"symbol\":\n case \"undefined\":\n return false;\n case \"object\": {\n const objectValue = value as object;\n\n if (memo.has(objectValue)) {\n return true;\n }\n\n if (active.has(objectValue)) {\n return false;\n }\n\n active.add(objectValue);\n let isSerializable = false;\n\n try {\n if (Array.isArray(value)) {\n isSerializable = value.every((item) =>\n isJsonSerializable(item, active, memo),\n );\n return isSerializable;\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return false;\n }\n\n isSerializable = Object.values(value).every((item) =>\n isJsonSerializable(item, active, memo),\n );\n return isSerializable;\n } finally {\n active.delete(objectValue);\n if (isSerializable) {\n memo.add(objectValue);\n }\n }\n }\n }\n\n return false;\n}\n"],"mappings":";;;;AAKA,IAAa,iBAAb,cAAoC,MAAM;CACxC;;;;CAKA,YAAY,MAAwB,SAAiB;AACnD,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;AAOhB,SAAgB,iBAAiB,OAAyC;AACxE,QAAO,iBAAiB;;;;;AAM1B,SAAgB,mBACd,OACA,yBAAS,IAAI,KAAa,EAC1B,uBAAO,IAAI,SAAiB,EACnB;AACT,KAAI,UAAU,KACZ,QAAO;AAGT,SAAQ,OAAO,OAAf;EACE,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,SACH,QAAO,OAAO,SAAS,MAAM;EAC/B,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,YACH,QAAO;EACT,KAAK,UAAU;GACb,MAAM,cAAc;AAEpB,OAAI,KAAK,IAAI,YAAY,CACvB,QAAO;AAGT,OAAI,OAAO,IAAI,YAAY,CACzB,QAAO;AAGT,UAAO,IAAI,YAAY;GACvB,IAAI,iBAAiB;AAErB,OAAI;AACF,QAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,sBAAiB,MAAM,OAAO,SAC5B,mBAAmB,MAAM,QAAQ,KAAK,CACvC;AACD,YAAO;;IAGT,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QAAI,cAAc,OAAO,aAAa,cAAc,KAClD,QAAO;AAGT,qBAAiB,OAAO,OAAO,MAAM,CAAC,OAAO,SAC3C,mBAAmB,MAAM,QAAQ,KAAK,CACvC;AACD,WAAO;aACC;AACR,WAAO,OAAO,YAAY;AAC1B,QAAI,eACF,MAAK,IAAI,YAAY;;;;AAM7B,QAAO"}
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { u as ExecuteErrorCode } from "./runner-DSgvu6Ad.cjs";
5
+ import { u as ExecuteErrorCode } from "./runner-Cy18Z0u0.cjs";
6
6
 
7
7
  //#region src/errors.d.ts
8
8
 
@@ -26,4 +26,4 @@ declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
26
26
  declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
27
27
  //#endregion
28
28
  export { isExecuteFailure as n, isJsonSerializable as r, ExecuteFailure as t };
29
- //# sourceMappingURL=errors-B9ADBuDH.d.cts.map
29
+ //# sourceMappingURL=errors-y4C-EIWT.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-B9ADBuDH.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKA,CAAA,CAAA;AACQ,OAAA,CAAA,KAAA,CADK,cAAA,CAAA,OAAA,CAAuB,KAAA,CAC5B;EAKY,IAAA,CAAA,CALZ,gBAKY;EANgB,CAAA,CAAA;;AAgBpC,CAAA,CAAA,CAAA,CAAA;EAOgB,WAAA,CAAA,IAAA,CAAA,CAjBI,gBAmBZ,CAAA,CAAA,OACF,CAAA,CAAA,MAAA,CAAA;;;;;iBAVU,gBAAA,2BAA2C;;;;iBAO3C,kBAAA,0BAER,oBACF"}
1
+ {"version":3,"file":"errors-y4C-EIWT.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKA,CAAA,CAAA;AACQ,OAAA,CAAA,KAAA,CADK,cAAA,CAAA,OAAA,CAAuB,KAAA,CAC5B;EAKY,IAAA,CAAA,CALZ,gBAKY;EANgB,CAAA,CAAA;;AAgBpC,CAAA,CAAA,CAAA,CAAA;EAOgB,WAAA,CAAA,IAAA,CAAA,CAjBI,gBAmBZ,CAAA,CAAA,OACF,CAAA,CAAA,MAAA,CAAA;;;;;iBAVU,gBAAA,2BAA2C;;;;iBAO3C,kBAAA,0BAER,oBACF"}
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { d as ExecuteResult, m as ResolvedToolProvider, t as ExecutionOptions } from "./runner-ClFrFnz9.js";
5
+ import { d as ExecuteResult, m as ResolvedToolProvider, t as ExecutionOptions } from "./runner-DXLu0eJV.js";
6
6
 
7
7
  //#region src/executor/executor.d.ts
8
8
 
@@ -26,4 +26,4 @@ interface Executor {
26
26
  }
27
27
  //#endregion
28
28
  export { ExecutorPoolOptions as n, Executor as t };
29
- //# sourceMappingURL=executor-B7q7K_27.d.ts.map
29
+ //# sourceMappingURL=executor-BOTd9xNK.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"executor-B7q7K_27.d.ts","names":[],"sources":["../src/executor/executor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOA,CAAA,CAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,GAAA,CAAA,QAAA,CAAA,eAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AAUA,CAAA,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,KAAA,CAAA,QAAA,CAAA,CAAA,CAAA,KAAA,CAAA,KAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA;;AAIc,SAAA,CAdG,mBAAA,CAcH;EACD,aAAA,CAAA,CAAA,CAAA,MAAA;EAAR,OAAA,CAAA,CAAA,MAAA;EACS,OAAA,CAAA,CAAA,CAAA,MAAA;EACc,OAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,MAAA;;;;;UAPX,QAAA;mCAGF,kCACD,mBACT,QAAQ;cACC;4BACc"}
1
+ {"version":3,"file":"executor-BOTd9xNK.d.ts","names":[],"sources":["../src/executor/executor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOA,CAAA,CAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,GAAA,CAAA,QAAA,CAAA,eAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AAUA,CAAA,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,KAAA,CAAA,QAAA,CAAA,CAAA,CAAA,KAAA,CAAA,KAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA;;AAIc,SAAA,CAdG,mBAAA,CAcH;EACD,aAAA,CAAA,CAAA,CAAA,MAAA;EAAR,OAAA,CAAA,CAAA,MAAA;EACS,OAAA,CAAA,CAAA,CAAA,MAAA;EACc,OAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,MAAA;;;;;UAPX,QAAA;mCAGF,kCACD,mBACT,QAAQ;cACC;4BACc"}
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { d as ExecuteResult, m as ResolvedToolProvider, t as ExecutionOptions } from "./runner-DSgvu6Ad.cjs";
5
+ import { d as ExecuteResult, m as ResolvedToolProvider, t as ExecutionOptions } from "./runner-Cy18Z0u0.cjs";
6
6
 
7
7
  //#region src/executor/executor.d.ts
8
8
 
@@ -26,4 +26,4 @@ interface Executor {
26
26
  }
27
27
  //#endregion
28
28
  export { ExecutorPoolOptions as n, Executor as t };
29
- //# sourceMappingURL=executor-BsE5nF-j.d.cts.map
29
+ //# sourceMappingURL=executor-CtbrvTQ_.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"executor-BsE5nF-j.d.cts","names":[],"sources":["../src/executor/executor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOA,CAAA,CAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,GAAA,CAAA,QAAA,CAAA,eAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AAUA,CAAA,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,KAAA,CAAA,QAAA,CAAA,CAAA,CAAA,KAAA,CAAA,KAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA;;AAIc,SAAA,CAdG,mBAAA,CAcH;EACD,aAAA,CAAA,CAAA,CAAA,MAAA;EAAR,OAAA,CAAA,CAAA,MAAA;EACS,OAAA,CAAA,CAAA,CAAA,MAAA;EACc,OAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,MAAA;;;;;UAPX,QAAA;mCAGF,kCACD,mBACT,QAAQ;cACC;4BACc"}
1
+ {"version":3,"file":"executor-CtbrvTQ_.d.cts","names":[],"sources":["../src/executor/executor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOA,CAAA,CAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,GAAA,CAAA,QAAA,CAAA,eAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AAUA,CAAA,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,KAAA,CAAA,QAAA,CAAA,CAAA,CAAA,KAAA,CAAA,KAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA;;AAIc,SAAA,CAdG,mBAAA,CAcH;EACD,aAAA,CAAA,CAAA,CAAA,MAAA;EAAR,OAAA,CAAA,CAAA,MAAA;EACS,OAAA,CAAA,CAAA,CAAA,MAAA;EACc,OAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,MAAA;;;;;UAPX,QAAA;mCAGF,kCACD,mBACT,QAAQ;cACC;4BACc"}
package/dist/index.cjs CHANGED
@@ -1,14 +1,6 @@
1
- const require_resolveProvider = require('./resolveProvider-BZYSw8Qk.cjs');
1
+ const require_resolveProvider = require('./resolveProvider-DFAg6No5.cjs');
2
2
  const require_errors = require('./errors-xD8r6fCf.cjs');
3
3
 
4
4
  exports.ExecuteFailure = require_errors.ExecuteFailure;
5
- exports.assertValidIdentifier = require_resolveProvider.assertValidIdentifier;
6
- exports.generateTypesFromJsonSchema = require_resolveProvider.generateTypesFromJsonSchema;
7
5
  exports.isExecuteFailure = require_errors.isExecuteFailure;
8
- exports.isJsonSerializable = require_errors.isJsonSerializable;
9
- exports.isReservedWord = require_resolveProvider.isReservedWord;
10
- exports.isValidIdentifier = require_resolveProvider.isValidIdentifier;
11
- exports.resolveProvider = require_resolveProvider.resolveProvider;
12
- exports.sanitizeIdentifier = require_resolveProvider.sanitizeIdentifier;
13
- exports.sanitizeToolName = require_resolveProvider.sanitizeToolName;
14
- exports.serializePropertyName = require_resolveProvider.serializePropertyName;
6
+ exports.resolveProvider = require_resolveProvider.resolveProvider;
package/dist/index.d.cts CHANGED
@@ -2,49 +2,15 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { _ as ToolProvider, a as ToolCall, d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, h as ToolDescriptor, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolSchema, y as TypegenToolDescriptor } from "./runner-DSgvu6Ad.cjs";
6
- import { n as ExecutorPoolOptions, t as Executor } from "./executor-BsE5nF-j.cjs";
7
- import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-B9ADBuDH.cjs";
5
+ import { _ as ToolExecutionContext, d as ExecuteResult, f as JsonSchema, g as ToolDescriptor, h as ToolAnnotations, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, p as ResolvedToolDescriptor, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolProvider, y as ToolSchema } from "./runner-Cy18Z0u0.cjs";
6
+ import { n as ExecutorPoolOptions, t as Executor } from "./executor-CtbrvTQ_.cjs";
7
+ import { n as isExecuteFailure, t as ExecuteFailure } from "./errors-y4C-EIWT.cjs";
8
8
 
9
- //#region src/identifier.d.ts
10
- /**
11
- * Returns whether the value is a valid JavaScript identifier.
12
- */
13
- declare function isValidIdentifier(value: string): boolean;
14
- /**
15
- * Returns whether the identifier is reserved in JavaScript source.
16
- */
17
- declare function isReservedWord(value: string): boolean;
18
- /**
19
- * Throws when the value cannot be used as a bare JavaScript identifier.
20
- */
21
- declare function assertValidIdentifier(value: string, label?: string): void;
22
- /**
23
- * Converts a raw identifier-like value into a safe JavaScript identifier.
24
- */
25
- declare function sanitizeIdentifier(value: string): string;
26
- /**
27
- * Renders the name as a bare identifier when possible, otherwise as a string literal.
28
- */
29
- declare function serializePropertyName(name: string): string;
30
- //#endregion
31
- //#region src/sanitize.d.ts
32
- /**
33
- * Converts a raw tool name into a safe JavaScript identifier.
34
- */
35
- declare function sanitizeToolName(name: string): string;
36
- //#endregion
37
9
  //#region src/provider/resolveProvider.d.ts
38
10
  /**
39
11
  * Resolves a tool provider into the validated, sanitized shape consumed by executors.
40
12
  */
41
13
  declare function resolveProvider(provider: ToolProvider): ResolvedToolProvider;
42
14
  //#endregion
43
- //#region src/typegen/jsonSchema.d.ts
44
- /**
45
- * Generates a namespace declaration for a provider's tool schemas.
46
- */
47
- declare function generateTypesFromJsonSchema(providerName: string, tools: Record<string, TypegenToolDescriptor>): string;
48
- //#endregion
49
- export { type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorPoolOptions, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, assertValidIdentifier, generateTypesFromJsonSchema, isExecuteFailure, isJsonSerializable, isReservedWord, isValidIdentifier, resolveProvider, sanitizeIdentifier, sanitizeToolName, serializePropertyName };
15
+ export { type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorPoolOptions, type ExecutorRuntimeOptions, type JsonSchema, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolAnnotations, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, isExecuteFailure, resolveProvider };
50
16
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/identifier.ts","../src/sanitize.ts","../src/provider/resolveProvider.ts","../src/typegen/jsonSchema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;iBA6DgB,iBAAA;;AAAhB,CAAA,CAAA,CAAA,OAAA,CAAA,OAAA,CAAA,GAAA,CAAA,UAAA,CAAA,EAAA,CAAA,QAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAAA;AAOA,CAAA,CAAA;AAOgB,OAAA,CAAA,QAAA,CAPA,cAAA,CAOqB,KAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAAA,OAAA;AAYrC,CAAA,CAAA;AAqBA,CAAA,CAAA,CAAA,MAAA,CAAA,IAAA,CAAA,GAAA,CAAA,KAAA,CAAA,MAAA,CAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,UAAA;;iBAjCgB,qBAAA;;ACtEhB,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,GAAA,CAAA,UAAA,CAAA,IAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,UAAA;;iBDkFgB,kBAAA;;AE3ChB,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,IAAA,CAAA,QAAA,CAAA,CAAA,SAAA,CAAA,EAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA;;iBFgEgB,qBAAA;;;;;;iBCvGA,gBAAA;;;;;;iBCuCA,eAAA,WAA0B,eAAe;;;AFwBzD,CAAA,CAAA;AAOA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CAAA,SAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,IAAA,CAAA,OAAA;AAYA,CAAA,CAAA;AAqBgB,OAAA,CAAA,QAAA,CGJA,2BAAA,CHIqB,YAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CGF5B,MHE4B,CAAA,MAAA,CAAA,CGFb,qBHEa,CAAA,CAAA,CAAA,CAAA,MAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/provider/resolveProvider.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;iBAgFgB,eAAA,WAA0B,eAAe"}
package/dist/index.d.ts CHANGED
@@ -2,49 +2,15 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { _ as ToolProvider, a as ToolCall, d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, h as ToolDescriptor, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolSchema, y as TypegenToolDescriptor } from "./runner-ClFrFnz9.js";
6
- import { n as ExecutorPoolOptions, t as Executor } from "./executor-B7q7K_27.js";
7
- import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-DlbJQYs7.js";
5
+ import { _ as ToolExecutionContext, d as ExecuteResult, f as JsonSchema, g as ToolDescriptor, h as ToolAnnotations, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, p as ResolvedToolDescriptor, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolProvider, y as ToolSchema } from "./runner-DXLu0eJV.js";
6
+ import { n as ExecutorPoolOptions, t as Executor } from "./executor-BOTd9xNK.js";
7
+ import { n as isExecuteFailure, t as ExecuteFailure } from "./errors-BIWv-QIC.js";
8
8
 
9
- //#region src/identifier.d.ts
10
- /**
11
- * Returns whether the value is a valid JavaScript identifier.
12
- */
13
- declare function isValidIdentifier(value: string): boolean;
14
- /**
15
- * Returns whether the identifier is reserved in JavaScript source.
16
- */
17
- declare function isReservedWord(value: string): boolean;
18
- /**
19
- * Throws when the value cannot be used as a bare JavaScript identifier.
20
- */
21
- declare function assertValidIdentifier(value: string, label?: string): void;
22
- /**
23
- * Converts a raw identifier-like value into a safe JavaScript identifier.
24
- */
25
- declare function sanitizeIdentifier(value: string): string;
26
- /**
27
- * Renders the name as a bare identifier when possible, otherwise as a string literal.
28
- */
29
- declare function serializePropertyName(name: string): string;
30
- //#endregion
31
- //#region src/sanitize.d.ts
32
- /**
33
- * Converts a raw tool name into a safe JavaScript identifier.
34
- */
35
- declare function sanitizeToolName(name: string): string;
36
- //#endregion
37
9
  //#region src/provider/resolveProvider.d.ts
38
10
  /**
39
11
  * Resolves a tool provider into the validated, sanitized shape consumed by executors.
40
12
  */
41
13
  declare function resolveProvider(provider: ToolProvider): ResolvedToolProvider;
42
14
  //#endregion
43
- //#region src/typegen/jsonSchema.d.ts
44
- /**
45
- * Generates a namespace declaration for a provider's tool schemas.
46
- */
47
- declare function generateTypesFromJsonSchema(providerName: string, tools: Record<string, TypegenToolDescriptor>): string;
48
- //#endregion
49
- export { type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorPoolOptions, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, assertValidIdentifier, generateTypesFromJsonSchema, isExecuteFailure, isJsonSerializable, isReservedWord, isValidIdentifier, resolveProvider, sanitizeIdentifier, sanitizeToolName, serializePropertyName };
15
+ export { type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorPoolOptions, type ExecutorRuntimeOptions, type JsonSchema, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolAnnotations, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, isExecuteFailure, resolveProvider };
50
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/identifier.ts","../src/sanitize.ts","../src/provider/resolveProvider.ts","../src/typegen/jsonSchema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;iBA6DgB,iBAAA;;AAAhB,CAAA,CAAA,CAAA,OAAA,CAAA,OAAA,CAAA,GAAA,CAAA,UAAA,CAAA,EAAA,CAAA,QAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAAA;AAOA,CAAA,CAAA;AAOgB,OAAA,CAAA,QAAA,CAPA,cAAA,CAOqB,KAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAAA,OAAA;AAYrC,CAAA,CAAA;AAqBA,CAAA,CAAA,CAAA,MAAA,CAAA,IAAA,CAAA,GAAA,CAAA,KAAA,CAAA,MAAA,CAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,UAAA;;iBAjCgB,qBAAA;;ACtEhB,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,GAAA,CAAA,UAAA,CAAA,IAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,UAAA;;iBDkFgB,kBAAA;;AE3ChB,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,IAAA,CAAA,QAAA,CAAA,CAAA,SAAA,CAAA,EAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA;;iBFgEgB,qBAAA;;;;;;iBCvGA,gBAAA;;;;;;iBCuCA,eAAA,WAA0B,eAAe;;;AFwBzD,CAAA,CAAA;AAOA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CAAA,SAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,IAAA,CAAA,OAAA;AAYA,CAAA,CAAA;AAqBgB,OAAA,CAAA,QAAA,CGJA,2BAAA,CHIqB,YAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CGF5B,MHE4B,CAAA,MAAA,CAAA,CGFb,qBHEa,CAAA,CAAA,CAAA,CAAA,MAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/provider/resolveProvider.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;iBAgFgB,eAAA,WAA0B,eAAe"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as isReservedWord, d as serializePropertyName, l as isValidIdentifier, n as generateTypesFromJsonSchema, o as sanitizeToolName, s as assertValidIdentifier, t as resolveProvider, u as sanitizeIdentifier } from "./resolveProvider-UqQxdF4j.js";
2
- import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-wS8yjQhS.js";
1
+ import { n as isExecuteFailure, t as ExecuteFailure } from "./errors-DdWVEGU8.js";
2
+ import { t as resolveProvider } from "./resolveProvider-CMrXPuTx.js";
3
3
 
4
- export { ExecuteFailure, assertValidIdentifier, generateTypesFromJsonSchema, isExecuteFailure, isJsonSerializable, isReservedWord, isValidIdentifier, resolveProvider, sanitizeIdentifier, sanitizeToolName, serializePropertyName };
4
+ export { ExecuteFailure, isExecuteFailure, resolveProvider };
@@ -1,4 +1,4 @@
1
- const require_resolveProvider = require('../resolveProvider-BZYSw8Qk.cjs');
1
+ const require_resolveProvider = require('../resolveProvider-DFAg6No5.cjs');
2
2
  require('../errors-xD8r6fCf.cjs');
3
3
  let zod = require("zod");
4
4
  zod = require_resolveProvider.__toESM(zod);
@@ -25,16 +25,26 @@ const MCP_CALL_TOOL_RESULT_TYPE = [
25
25
  "};"
26
26
  ].join("\n");
27
27
  /**
28
+ * Generates one wrapped MCP tool declaration exposed to guest code.
29
+ */
30
+ function generateMcpWrappedToolType(provider, safeName) {
31
+ const tool = provider.tools[safeName];
32
+ if (!tool) throw new Error(`Unknown wrapped MCP tool: ${safeName}`);
33
+ return [require_resolveProvider.renderDocComment([...tool.description ? [tool.description, ""] : [], "Wrapped MCP tool. Inspect structuredContent first, then fall back to content text items."]), `function ${safeName}(input: ${require_resolveProvider.schemaToType(tool.inputSchema)}): Promise<McpCallToolResult>;`].filter(Boolean).join("\n");
34
+ }
35
+ /**
28
36
  * Generates the wrapped MCP tool namespace declarations exposed to guest code.
29
37
  */
30
38
  function generateMcpWrappedToolTypes(provider) {
31
- const declarations = [MCP_CALL_TOOL_RESULT_TYPE];
32
- for (const [safeName, tool] of Object.entries(provider.tools)) {
33
- const comment = require_resolveProvider.renderDocComment([...tool.description ? [tool.description, ""] : [], "Wrapped MCP tool. Inspect structuredContent first, then fall back to content text items."]);
34
- declarations.push([comment, `function ${safeName}(input: ${require_resolveProvider.schemaToType(tool.inputSchema)}): Promise<McpCallToolResult>;`].filter(Boolean).join("\n"));
35
- }
39
+ const declarations = [MCP_CALL_TOOL_RESULT_TYPE, ...Object.keys(provider.tools).map((safeName) => generateMcpWrappedToolType(provider, safeName))];
36
40
  return require_resolveProvider.renderNamespaceDeclaration(provider.name, declarations);
37
41
  }
42
+ /**
43
+ * Generates the wrapped MCP tool namespace declaration for one selected tool.
44
+ */
45
+ function generateMcpWrappedSingleToolTypes(provider, safeName) {
46
+ return require_resolveProvider.renderNamespaceDeclaration(provider.name, [MCP_CALL_TOOL_RESULT_TYPE, generateMcpWrappedToolType(provider, safeName)]);
47
+ }
38
48
 
39
49
  //#endregion
40
50
  //#region src/mcp/createMcpToolProvider.ts
@@ -53,6 +63,9 @@ async function closeAll(closers) {
53
63
  const rejected = (await Promise.allSettled(closers.map((close) => close()))).find((result) => result.status === "rejected");
54
64
  if (rejected) throw rejected.reason;
55
65
  }
66
+ function asJsonSchema(schema) {
67
+ return typeof schema === "object" && schema !== null ? schema : void 0;
68
+ }
56
69
  async function openMcpToolClient(source, clientInfo) {
57
70
  if ("client" in source) return {
58
71
  client: source.client,
@@ -86,11 +99,13 @@ async function openMcpToolProvider(source, options = {}) {
86
99
  const connection = await openMcpToolClient(source, options.clientInfo ?? DEFAULT_MCP_TOOL_CLIENT_INFO);
87
100
  try {
88
101
  const toolsResponse = await connection.client.listTools();
102
+ const toolsByOriginalName = new Map(toolsResponse.tools.map((tool) => [tool.name, tool]));
89
103
  const provider = {
90
104
  name: options.namespace ?? "mcp",
91
105
  tools: {}
92
106
  };
93
107
  for (const tool of toolsResponse.tools) provider.tools[tool.name] = {
108
+ annotations: tool.annotations,
94
109
  description: tool.description,
95
110
  execute: async (input, context) => {
96
111
  const argumentsObject = typeof input === "object" && input !== null ? input : void 0;
@@ -102,13 +117,25 @@ async function openMcpToolProvider(source, options = {}) {
102
117
  inputSchema: tool.inputSchema
103
118
  };
104
119
  const resolvedProvider = require_resolveProvider.resolveProvider(provider);
120
+ const toolDefinitions = Object.fromEntries(Object.entries(resolvedProvider.tools).map(([safeName, descriptor]) => {
121
+ const upstreamTool = toolsByOriginalName.get(descriptor.originalName);
122
+ return [safeName, {
123
+ annotations: descriptor.annotations,
124
+ description: descriptor.description,
125
+ inputSchema: descriptor.inputSchema,
126
+ originalName: descriptor.originalName,
127
+ outputSchema: asJsonSchema(upstreamTool?.outputSchema),
128
+ safeName: descriptor.safeName
129
+ }];
130
+ }));
105
131
  return {
106
132
  close: connection.close,
107
133
  provider: {
108
134
  ...resolvedProvider,
109
135
  types: generateMcpWrappedToolTypes(resolvedProvider)
110
136
  },
111
- serverInfo: getMcpToolSourceServerInfo(source)
137
+ serverInfo: getMcpToolSourceServerInfo(source),
138
+ toolDefinitions
112
139
  };
113
140
  } catch (error) {
114
141
  await connection.close().catch(() => {});
@@ -126,6 +153,18 @@ async function createMcpToolProvider(source, options = {}) {
126
153
  //#endregion
127
154
  //#region src/mcp/codeMcpServer.ts
128
155
  const DEFAULT_MAX_TEXT_CHARS = 24e3;
156
+ const CODE_EXECUTION_TOOL_ANNOTATIONS = {
157
+ destructiveHint: true,
158
+ idempotentHint: false,
159
+ openWorldHint: true,
160
+ readOnlyHint: false
161
+ };
162
+ const READ_ONLY_TOOL_ANNOTATIONS = {
163
+ destructiveHint: false,
164
+ idempotentHint: true,
165
+ openWorldHint: false,
166
+ readOnlyHint: true
167
+ };
129
168
  const DEFAULT_MCP_CODE_WRAPPER_SERVER_INFO = {
130
169
  name: "mcp-code-wrapper",
131
170
  version: "0.0.0"
@@ -136,32 +175,41 @@ function truncateText(text, maxTextChars) {
136
175
  function renderText(value, maxTextChars) {
137
176
  return truncateText(JSON.stringify(value, null, 2), maxTextChars);
138
177
  }
139
- function searchTools(provider, query, limit) {
178
+ function searchTools(toolDefinitions, namespace, query, limit) {
140
179
  const normalizedQuery = query?.toLowerCase().trim();
141
- const matches = Object.entries(provider.tools).map(([safeName, descriptor]) => ({
142
- description: descriptor.description,
143
- inputSchema: descriptor.inputSchema,
144
- originalName: descriptor.originalName,
145
- outputSchema: descriptor.outputSchema,
146
- safeName
147
- })).filter((tool) => {
148
- if (!normalizedQuery) return true;
149
- return [
150
- tool.originalName,
151
- tool.safeName,
152
- tool.description ?? ""
153
- ].some((field) => field.toLowerCase().includes(normalizedQuery));
154
- }).slice(0, limit);
155
180
  return {
156
- namespace: provider.name,
157
- originalToSafeName: provider.originalToSafeName,
158
- safeToOriginalName: provider.safeToOriginalName,
159
- tools: matches,
160
- types: provider.types
181
+ namespace,
182
+ tools: Object.values(toolDefinitions).filter((tool) => {
183
+ if (!normalizedQuery) return true;
184
+ return [
185
+ tool.originalName,
186
+ tool.safeName,
187
+ tool.description ?? ""
188
+ ].some((field) => field.toLowerCase().includes(normalizedQuery));
189
+ }).slice(0, limit).map((tool) => ({
190
+ annotations: tool.annotations,
191
+ description: tool.description,
192
+ originalName: tool.originalName,
193
+ safeName: tool.safeName
194
+ }))
195
+ };
196
+ }
197
+ function getToolDetails(provider, toolDefinitions, safeName) {
198
+ const tool = toolDefinitions[safeName];
199
+ if (!tool) throw new Error(`Unknown wrapped MCP tool: ${safeName}`);
200
+ return {
201
+ annotations: tool.annotations,
202
+ description: tool.description,
203
+ inputSchema: tool.inputSchema,
204
+ originalName: tool.originalName,
205
+ outputSchema: tool.outputSchema,
206
+ safeName: tool.safeName,
207
+ types: generateMcpWrappedSingleToolTypes(provider, safeName)
161
208
  };
162
209
  }
163
210
  function registerExecuteTool(server, name, provider, executor, maxTextChars, description) {
164
211
  server.registerTool.bind(server)(name, {
212
+ annotations: CODE_EXECUTION_TOOL_ANNOTATIONS,
165
213
  description,
166
214
  inputSchema: { code: zod.string() }
167
215
  }, async (args) => {
@@ -176,15 +224,32 @@ function registerExecuteTool(server, name, provider, executor, maxTextChars, des
176
224
  };
177
225
  });
178
226
  }
179
- function registerSearchTool(server, name, provider, maxTextChars) {
227
+ function registerSearchTool(server, name, namespace, toolDefinitions, maxTextChars) {
180
228
  server.registerTool.bind(server)(name, {
181
- description: `Search wrapped MCP tools exposed under the ${provider.name} namespace.`,
229
+ annotations: READ_ONLY_TOOL_ANNOTATIONS,
230
+ description: `Search wrapped MCP tools exposed under the ${namespace} namespace. Returns concise catalog entries only; call the details tool for schemas.`,
182
231
  inputSchema: {
183
232
  limit: zod.number().int().optional(),
184
233
  query: zod.string().optional()
185
234
  }
186
235
  }, async (args) => {
187
- const structuredContent = searchTools(provider, args.query, args.limit ?? 20);
236
+ const structuredContent = searchTools(toolDefinitions, namespace, args.query, args.limit ?? 20);
237
+ return {
238
+ content: [{
239
+ text: renderText(structuredContent, maxTextChars),
240
+ type: "text"
241
+ }],
242
+ structuredContent
243
+ };
244
+ });
245
+ }
246
+ function registerDetailsTool(server, name, provider, toolDefinitions, maxTextChars) {
247
+ server.registerTool.bind(server)(name, {
248
+ annotations: READ_ONLY_TOOL_ANNOTATIONS,
249
+ description: `Return the full schema and generated TypeScript declaration for one wrapped ${provider.name} MCP tool.`,
250
+ inputSchema: { safeName: zod.string() }
251
+ }, async (args) => {
252
+ const structuredContent = getToolDetails(provider, toolDefinitions, args.safeName);
188
253
  return {
189
254
  content: [{
190
255
  text: renderText(structuredContent, maxTextChars),
@@ -211,8 +276,9 @@ function attachOwnedClose(server, closeOwnedResources) {
211
276
  */
212
277
  async function codeMcpServer(source, options) {
213
278
  const maxTextChars = options.maxTextChars ?? DEFAULT_MAX_TEXT_CHARS;
214
- const mode = options.mode ?? "both";
279
+ const mode = options.mode ?? "progressive";
215
280
  const names = {
281
+ details: options.names?.details ?? "mcp_get_tool_details",
216
282
  execute: options.names?.execute ?? "mcp_execute_code",
217
283
  search: options.names?.search ?? "mcp_search_tools",
218
284
  single: options.names?.single ?? "mcp_code"
@@ -224,9 +290,10 @@ async function codeMcpServer(source, options) {
224
290
  const provider = handle.provider;
225
291
  const server = new __modelcontextprotocol_sdk_server_mcp_js.McpServer(options.serverInfo ?? handle.serverInfo ?? DEFAULT_MCP_CODE_WRAPPER_SERVER_INFO);
226
292
  try {
227
- if (mode === "both" || mode === "split") {
228
- registerSearchTool(server, names.search, provider, maxTextChars);
229
- registerExecuteTool(server, names.execute, provider, options.executor, maxTextChars, `Execute JavaScript against the wrapped ${provider.name} MCP tool namespace.`);
293
+ if (mode === "both" || mode === "progressive") {
294
+ registerSearchTool(server, names.search, provider.name, handle.toolDefinitions, maxTextChars);
295
+ registerDetailsTool(server, names.details, provider, handle.toolDefinitions, maxTextChars);
296
+ registerExecuteTool(server, names.execute, provider, options.executor, maxTextChars, `Execute JavaScript against the wrapped ${provider.name} MCP tool namespace. Use the search and details tools before writing code.`);
230
297
  }
231
298
  if (mode === "both" || mode === "single") registerExecuteTool(server, names.single, provider, options.executor, maxTextChars, `Execute JavaScript against the wrapped ${provider.name} MCP tool namespace.\n\n${provider.types}`);
232
299
  return attachOwnedClose(server, handle.close);