@execbox/core 0.4.0 → 0.4.1

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 (54) hide show
  1. package/README.md +52 -84
  2. package/dist/_internal/index.cjs +45 -0
  3. package/dist/_internal/index.cjs.map +1 -0
  4. package/dist/_internal/index.d.cts +21 -0
  5. package/dist/_internal/index.d.cts.map +1 -0
  6. package/dist/_internal/index.d.ts +22 -0
  7. package/dist/_internal/index.d.ts.map +1 -0
  8. package/dist/_internal/index.js +30 -0
  9. package/dist/_internal/index.js.map +1 -0
  10. package/dist/errors-B3IY3ID-.d.cts +69 -0
  11. package/dist/errors-B3IY3ID-.d.cts.map +1 -0
  12. package/dist/{errors-CTel18cM.cjs → errors-BGSgVV40.cjs} +1 -1
  13. package/dist/{errors-CTel18cM.cjs.map → errors-BGSgVV40.cjs.map} +1 -1
  14. package/dist/{errors-CgBwm39w.js → errors-BXpyBhCI.js} +1 -1
  15. package/dist/{errors-CgBwm39w.js.map → errors-BXpyBhCI.js.map} +1 -1
  16. package/dist/errors-BbUru7ko.d.ts +69 -0
  17. package/dist/errors-BbUru7ko.d.ts.map +1 -0
  18. package/dist/{executor-C7YjuD7r.d.cts → executor-CEXp0gYP.d.cts} +2 -2
  19. package/dist/{executor-C7YjuD7r.d.cts.map → executor-CEXp0gYP.d.cts.map} +1 -1
  20. package/dist/{executor-B-Qe_q5_.d.ts → executor-_CO7E1U7.d.ts} +2 -2
  21. package/dist/{executor-B-Qe_q5_.d.ts.map → executor-_CO7E1U7.d.ts.map} +1 -1
  22. package/dist/index.cjs +6 -51
  23. package/dist/index.d.cts +3 -62
  24. package/dist/index.d.cts.map +1 -1
  25. package/dist/index.d.ts +3 -62
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +5 -50
  28. package/dist/mcp/index.cjs +2 -2
  29. package/dist/mcp/index.d.cts +2 -2
  30. package/dist/mcp/index.d.ts +2 -2
  31. package/dist/mcp/index.js +2 -2
  32. package/dist/normalize-B80ZCnxe.cjs +54 -0
  33. package/dist/normalize-B80ZCnxe.cjs.map +1 -0
  34. package/dist/normalize-dfQC7HWx.js +48 -0
  35. package/dist/normalize-dfQC7HWx.js.map +1 -0
  36. package/dist/protocol/index.cjs +2 -2
  37. package/dist/protocol/index.d.cts +1 -1
  38. package/dist/protocol/index.d.ts +1 -1
  39. package/dist/protocol/index.js +2 -2
  40. package/dist/{resolveProvider-TuOLZT2_.js → resolveProvider-BHuwOGBm.js} +2 -2
  41. package/dist/{resolveProvider-TuOLZT2_.js.map → resolveProvider-BHuwOGBm.js.map} +1 -1
  42. package/dist/{resolveProvider-D__uEvDj.cjs → resolveProvider-DfcSnwnp.cjs} +2 -2
  43. package/dist/{resolveProvider-D__uEvDj.cjs.map → resolveProvider-DfcSnwnp.cjs.map} +1 -1
  44. package/dist/{runner-Dt--9M2r.cjs → runner-BxbJ5eWb.cjs} +2 -2
  45. package/dist/{runner-Dt--9M2r.cjs.map → runner-BxbJ5eWb.cjs.map} +1 -1
  46. package/dist/{runner-BJu1lZFi.d.cts → runner-DSgvu6Ad.d.cts} +1 -1
  47. package/dist/{runner-BJu1lZFi.d.cts.map → runner-DSgvu6Ad.d.cts.map} +1 -1
  48. package/dist/{runner-CbC-ncVb.d.ts → runner-FSGSGEpx.d.ts} +1 -1
  49. package/dist/{runner-CbC-ncVb.d.ts.map → runner-FSGSGEpx.d.ts.map} +1 -1
  50. package/dist/{runner-8eVWfKxh.js → runner-nUCF59Au.js} +2 -2
  51. package/dist/{runner-8eVWfKxh.js.map → runner-nUCF59Au.js.map} +1 -1
  52. package/package.json +10 -1
  53. package/dist/index.cjs.map +0 -1
  54. package/dist/index.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,52 +1,8 @@
1
- const require_resolveProvider = require('./resolveProvider-D__uEvDj.cjs');
2
- const require_runner = require('./runner-Dt--9M2r.cjs');
3
- const require_errors = require('./errors-CTel18cM.cjs');
4
- let acorn = require("acorn");
1
+ const require_resolveProvider = require('./resolveProvider-DfcSnwnp.cjs');
2
+ const require_runner = require('./runner-BxbJ5eWb.cjs');
3
+ const require_normalize = require('./normalize-B80ZCnxe.cjs');
4
+ const require_errors = require('./errors-BGSgVV40.cjs');
5
5
 
6
- //#region src/normalize.ts
7
- function stripCodeFences(source) {
8
- const match = source.match(/^\s*```[^\n]*\n([\s\S]*?)\n?```\s*$/);
9
- return match ? match[1] : source;
10
- }
11
- function wrapAsync(body) {
12
- if (body.trim().length === 0) return "async () => {}";
13
- return `async () => {\n${body}\n}`;
14
- }
15
- /**
16
- * Normalizes model-produced JavaScript into an executable async function body.
17
- */
18
- function normalizeCode(source) {
19
- const normalizedSource = stripCodeFences(source).trim();
20
- if (normalizedSource.length === 0) return "async () => {}";
21
- try {
22
- const program = (0, acorn.parse)(normalizedSource, {
23
- ecmaVersion: "latest",
24
- sourceType: "module"
25
- });
26
- if (program.body?.length === 1) {
27
- const [statement] = program.body;
28
- if (statement.type === "FunctionDeclaration" && statement.id?.name) return wrapAsync(`${normalizedSource}\nreturn ${statement.id.name}();`);
29
- if (statement.type === "ExpressionStatement" && statement.expression) {
30
- if (statement.expression.type === "ArrowFunctionExpression" && statement.expression.async) return normalizedSource;
31
- return wrapAsync(`return (${normalizedSource});`);
32
- }
33
- }
34
- const lastStatement = (program.body ?? []).at(-1);
35
- if (lastStatement?.type === "ExpressionStatement" && lastStatement.expression) {
36
- const bodyPrefix = normalizedSource.slice(0, lastStatement.start).trimEnd();
37
- const expressionSource = normalizedSource.slice(lastStatement.expression.start, lastStatement.expression.end);
38
- const lines = [];
39
- if (bodyPrefix.length > 0) lines.push(bodyPrefix);
40
- lines.push(`return (${expressionSource});`);
41
- return wrapAsync(lines.join("\n"));
42
- }
43
- return wrapAsync(normalizedSource);
44
- } catch {
45
- return wrapAsync(normalizedSource);
46
- }
47
- }
48
-
49
- //#endregion
50
6
  exports.ExecuteFailure = require_errors.ExecuteFailure;
51
7
  exports.assertValidIdentifier = require_resolveProvider.assertValidIdentifier;
52
8
  exports.createExecutionContext = require_runner.createExecutionContext;
@@ -61,12 +17,11 @@ exports.isJsonSerializable = require_errors.isJsonSerializable;
61
17
  exports.isKnownExecuteErrorCode = require_runner.isKnownExecuteErrorCode;
62
18
  exports.isReservedWord = require_resolveProvider.isReservedWord;
63
19
  exports.isValidIdentifier = require_resolveProvider.isValidIdentifier;
64
- exports.normalizeCode = normalizeCode;
20
+ exports.normalizeCode = require_normalize.normalizeCode;
65
21
  exports.normalizeThrownMessage = require_runner.normalizeThrownMessage;
66
22
  exports.normalizeThrownName = require_runner.normalizeThrownName;
67
23
  exports.resolveProvider = require_resolveProvider.resolveProvider;
68
24
  exports.sanitizeIdentifier = require_resolveProvider.sanitizeIdentifier;
69
25
  exports.sanitizeToolName = require_resolveProvider.sanitizeToolName;
70
26
  exports.serializePropertyName = require_resolveProvider.serializePropertyName;
71
- exports.truncateLogs = require_runner.truncateLogs;
72
- //# sourceMappingURL=index.cjs.map
27
+ exports.truncateLogs = require_runner.truncateLogs;
package/dist/index.d.cts CHANGED
@@ -2,43 +2,10 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { _ as ToolProvider, a as ToolCall, c as extractProviderManifests, 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, s as createToolCallDispatcher, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolSchema, y as TypegenToolDescriptor } from "./runner-BJu1lZFi.cjs";
6
- import { n as ExecutorPoolOptions, t as Executor } from "./executor-C7YjuD7r.cjs";
5
+ import { _ as ToolProvider, a as ToolCall, c as extractProviderManifests, 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, s as createToolCallDispatcher, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolSchema, y as TypegenToolDescriptor } from "./runner-DSgvu6Ad.cjs";
6
+ import { a as createExecutionContext, c as getExecutionTimeoutMessage, d as normalizeThrownName, f as truncateLogs, i as normalizeCode, l as isKnownExecuteErrorCode, n as isExecuteFailure, o as createTimeoutExecuteResult, r as isJsonSerializable, s as formatConsoleLine, t as ExecuteFailure, u as normalizeThrownMessage } from "./errors-B3IY3ID-.cjs";
7
+ import { n as ExecutorPoolOptions, t as Executor } from "./executor-CEXp0gYP.cjs";
7
8
 
8
- //#region src/executor/shared.d.ts
9
- /**
10
- * Returns whether the value is one of execbox's stable execution error codes.
11
- */
12
- declare function isKnownExecuteErrorCode(value: unknown): value is ExecuteErrorCode;
13
- /**
14
- * Returns the stable timeout message used across executor implementations.
15
- */
16
- declare function getExecutionTimeoutMessage(): string;
17
- /**
18
- * Creates the canonical timeout failure result used for preflight cancellation.
19
- */
20
- declare function createTimeoutExecuteResult(durationMs?: number): ExecuteResult;
21
- /**
22
- * Normalizes an unknown thrown value into a human-readable message.
23
- */
24
- declare function normalizeThrownMessage(error: unknown): string;
25
- /**
26
- * Returns the thrown error name when one is available.
27
- */
28
- declare function normalizeThrownName(error: unknown): string | undefined;
29
- /**
30
- * Builds the standard tool execution context passed to resolved tool wrappers.
31
- */
32
- declare function createExecutionContext(signal: AbortSignal, providerName: string, safeToolName: string, originalToolName: string): ToolExecutionContext;
33
- /**
34
- * Truncates captured logs to the configured line and character limits.
35
- */
36
- declare function truncateLogs(logs: string[], maxLogLines: number, maxLogChars: number): string[];
37
- /**
38
- * Formats guest console arguments into a single host-side log line.
39
- */
40
- declare function formatConsoleLine(values: unknown[]): string;
41
- //#endregion
42
9
  //#region src/identifier.d.ts
43
10
  /**
44
11
  * Returns whether the value is a valid JavaScript identifier.
@@ -61,38 +28,12 @@ declare function sanitizeIdentifier(value: string): string;
61
28
  */
62
29
  declare function serializePropertyName(name: string): string;
63
30
  //#endregion
64
- //#region src/normalize.d.ts
65
- /**
66
- * Normalizes model-produced JavaScript into an executable async function body.
67
- */
68
- declare function normalizeCode(source: string): string;
69
- //#endregion
70
31
  //#region src/sanitize.d.ts
71
32
  /**
72
33
  * Converts a raw tool name into a safe JavaScript identifier.
73
34
  */
74
35
  declare function sanitizeToolName(name: string): string;
75
36
  //#endregion
76
- //#region src/errors.d.ts
77
- /**
78
- * Structured failure used internally to propagate executor and tool errors.
79
- */
80
- declare class ExecuteFailure extends Error {
81
- code: ExecuteErrorCode;
82
- /**
83
- * Creates a structured failure with a trusted executor or tool error code.
84
- */
85
- constructor(code: ExecuteErrorCode, message: string);
86
- }
87
- /**
88
- * Returns whether a thrown value is an {@link ExecuteFailure}.
89
- */
90
- declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
91
- /**
92
- * Returns whether a value can be serialized through the JSON-only host/guest boundary.
93
- */
94
- declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
95
- //#endregion
96
37
  //#region src/provider/resolveProvider.d.ts
97
38
  /**
98
39
  * Resolves a tool provider into the validated, sanitized shape consumed by executors.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/executor/shared.ts","../src/identifier.ts","../src/normalize.ts","../src/sanitize.ts","../src/errors.ts","../src/provider/resolveProvider.ts","../src/typegen/jsonSchema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAyBgB,OAAA,CAAA,QAAA,CAAA,uBAAA,CAEJ,KAAA,CAAA,CAAA,OAAgB,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CAAhB,gBAAgB;AAO5B,CAAA,CAAA;AAOA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,OAAA,CAAA,OAAA,CAAA,IAAA,CAAA,MAAA,CAAA,QAAA,CAAA,eAAA;AAeA,CAAA,CAAA;AAkBgB,OAAA,CAAA,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A,CAAA,OAAA,CAAA,GAAA,CAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,KAAA,CAAA,QAAA;AAOA,CAAA,CAAA;AAYgB,OAAA,CAAA,QAAA,CG3DA,kBAAA,CH2DkB,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CGzD1B,GHyD0B,CAAA,MAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CGxD5B,OHwD4B,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,OAAA;;;;;;AD9DlB,OAAA,CAAA,QAAA,CKmBA,eAAA,CLnBuB,QAE3B,CAAA,CKiB8B,YLjBd,CAAA,CAAA,CKiB6B,oBLjB7B;;;AAc5B,CAAA,CAAA;AAeA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CAAA,SAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,IAAA,CAAA,OAAA;AAkBA,CAAA,CAAA;AAkBgB,OAAA,CAAA,QAAA,CMYA,2BAAA,CNXN,YAIP,CAAA,CAAA,MAAA,CAAA,CAAoB,KAAA,CAAA,CMSd,MNTc,CAAA,MAAA,CAAA,CMSC,qBNTD,CAAA,CAAA,CAAA,CAAA,MAAA"}
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"}
package/dist/index.d.ts CHANGED
@@ -2,43 +2,10 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { _ as ToolProvider, a as ToolCall, c as extractProviderManifests, 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, s as createToolCallDispatcher, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolSchema, y as TypegenToolDescriptor } from "./runner-CbC-ncVb.js";
6
- import { n as ExecutorPoolOptions, t as Executor } from "./executor-B-Qe_q5_.js";
5
+ import { _ as ToolProvider, a as ToolCall, c as extractProviderManifests, 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, s as createToolCallDispatcher, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolSchema, y as TypegenToolDescriptor } from "./runner-FSGSGEpx.js";
6
+ import { a as createExecutionContext, c as getExecutionTimeoutMessage, d as normalizeThrownName, f as truncateLogs, i as normalizeCode, l as isKnownExecuteErrorCode, n as isExecuteFailure, o as createTimeoutExecuteResult, r as isJsonSerializable, s as formatConsoleLine, t as ExecuteFailure, u as normalizeThrownMessage } from "./errors-BbUru7ko.js";
7
+ import { n as ExecutorPoolOptions, t as Executor } from "./executor-_CO7E1U7.js";
7
8
 
8
- //#region src/executor/shared.d.ts
9
- /**
10
- * Returns whether the value is one of execbox's stable execution error codes.
11
- */
12
- declare function isKnownExecuteErrorCode(value: unknown): value is ExecuteErrorCode;
13
- /**
14
- * Returns the stable timeout message used across executor implementations.
15
- */
16
- declare function getExecutionTimeoutMessage(): string;
17
- /**
18
- * Creates the canonical timeout failure result used for preflight cancellation.
19
- */
20
- declare function createTimeoutExecuteResult(durationMs?: number): ExecuteResult;
21
- /**
22
- * Normalizes an unknown thrown value into a human-readable message.
23
- */
24
- declare function normalizeThrownMessage(error: unknown): string;
25
- /**
26
- * Returns the thrown error name when one is available.
27
- */
28
- declare function normalizeThrownName(error: unknown): string | undefined;
29
- /**
30
- * Builds the standard tool execution context passed to resolved tool wrappers.
31
- */
32
- declare function createExecutionContext(signal: AbortSignal, providerName: string, safeToolName: string, originalToolName: string): ToolExecutionContext;
33
- /**
34
- * Truncates captured logs to the configured line and character limits.
35
- */
36
- declare function truncateLogs(logs: string[], maxLogLines: number, maxLogChars: number): string[];
37
- /**
38
- * Formats guest console arguments into a single host-side log line.
39
- */
40
- declare function formatConsoleLine(values: unknown[]): string;
41
- //#endregion
42
9
  //#region src/identifier.d.ts
43
10
  /**
44
11
  * Returns whether the value is a valid JavaScript identifier.
@@ -61,38 +28,12 @@ declare function sanitizeIdentifier(value: string): string;
61
28
  */
62
29
  declare function serializePropertyName(name: string): string;
63
30
  //#endregion
64
- //#region src/normalize.d.ts
65
- /**
66
- * Normalizes model-produced JavaScript into an executable async function body.
67
- */
68
- declare function normalizeCode(source: string): string;
69
- //#endregion
70
31
  //#region src/sanitize.d.ts
71
32
  /**
72
33
  * Converts a raw tool name into a safe JavaScript identifier.
73
34
  */
74
35
  declare function sanitizeToolName(name: string): string;
75
36
  //#endregion
76
- //#region src/errors.d.ts
77
- /**
78
- * Structured failure used internally to propagate executor and tool errors.
79
- */
80
- declare class ExecuteFailure extends Error {
81
- code: ExecuteErrorCode;
82
- /**
83
- * Creates a structured failure with a trusted executor or tool error code.
84
- */
85
- constructor(code: ExecuteErrorCode, message: string);
86
- }
87
- /**
88
- * Returns whether a thrown value is an {@link ExecuteFailure}.
89
- */
90
- declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
91
- /**
92
- * Returns whether a value can be serialized through the JSON-only host/guest boundary.
93
- */
94
- declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
95
- //#endregion
96
37
  //#region src/provider/resolveProvider.d.ts
97
38
  /**
98
39
  * Resolves a tool provider into the validated, sanitized shape consumed by executors.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/executor/shared.ts","../src/identifier.ts","../src/normalize.ts","../src/sanitize.ts","../src/errors.ts","../src/provider/resolveProvider.ts","../src/typegen/jsonSchema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAyBgB,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AA;AAkBA,CAAA,CAAA,CAAA,CAAA;EAkBgB,WAAA,CAAA,IAAA,CAAA,CIjFI,gBJiFkB,CAAA,CAC5B,OAAA,CAAA,CAAA,MAIP,CAAA;AAYH;AA8CA,CAAA,CAAA;;;iBItIgB,gBAAA,2BAA2C;AHwC3D,CAAA,CAAA;AAOA,CAAA,CAAA,CAAA,OAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,GAAA,CAAA,EAAA,CAAA,UAAA,CAAA,OAAA,CAAA,GAAA,CAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,KAAA,CAAA,QAAA;AAOA,CAAA,CAAA;AAYgB,OAAA,CAAA,QAAA,CG3DA,kBAAA,CH2DkB,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CGzD1B,GHyD0B,CAAA,MAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CGxD5B,OHwD4B,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,OAAA;;;;;;AD9DlB,OAAA,CAAA,QAAA,CKmBA,eAAA,CLnBuB,QAE3B,CAAA,CKiB8B,YLjBd,CAAA,CAAA,CKiB6B,oBLjB7B;;;AAc5B,CAAA,CAAA;AAeA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CAAA,SAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,IAAA,CAAA,OAAA;AAkBA,CAAA,CAAA;AAkBgB,OAAA,CAAA,QAAA,CMYA,2BAAA,CNXN,YAIP,CAAA,CAAA,MAAA,CAAA,CAAoB,KAAA,CAAA,CMSd,MNTc,CAAA,MAAA,CAAA,CMSC,qBNTD,CAAA,CAAA,CAAA,CAAA,MAAA"}
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":";;;;;;;;;;;;iBA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,CAAA,MAAA"}
package/dist/index.js CHANGED
@@ -1,51 +1,6 @@
1
- import { a as formatConsoleLine, c as normalizeThrownMessage, i as createTimeoutExecuteResult, l as normalizeThrownName, n as extractProviderManifests, o as getExecutionTimeoutMessage, r as createExecutionContext, s as isKnownExecuteErrorCode, t as createToolCallDispatcher, u as truncateLogs } from "./runner-8eVWfKxh.js";
2
- 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-TuOLZT2_.js";
3
- import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-CgBwm39w.js";
4
- import { parse } from "acorn";
1
+ import { a as formatConsoleLine, c as normalizeThrownMessage, i as createTimeoutExecuteResult, l as normalizeThrownName, n as extractProviderManifests, o as getExecutionTimeoutMessage, r as createExecutionContext, s as isKnownExecuteErrorCode, t as createToolCallDispatcher, u as truncateLogs } from "./runner-nUCF59Au.js";
2
+ 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-BHuwOGBm.js";
3
+ import { t as normalizeCode } from "./normalize-dfQC7HWx.js";
4
+ import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-BXpyBhCI.js";
5
5
 
6
- //#region src/normalize.ts
7
- function stripCodeFences(source) {
8
- const match = source.match(/^\s*```[^\n]*\n([\s\S]*?)\n?```\s*$/);
9
- return match ? match[1] : source;
10
- }
11
- function wrapAsync(body) {
12
- if (body.trim().length === 0) return "async () => {}";
13
- return `async () => {\n${body}\n}`;
14
- }
15
- /**
16
- * Normalizes model-produced JavaScript into an executable async function body.
17
- */
18
- function normalizeCode(source) {
19
- const normalizedSource = stripCodeFences(source).trim();
20
- if (normalizedSource.length === 0) return "async () => {}";
21
- try {
22
- const program = parse(normalizedSource, {
23
- ecmaVersion: "latest",
24
- sourceType: "module"
25
- });
26
- if (program.body?.length === 1) {
27
- const [statement] = program.body;
28
- if (statement.type === "FunctionDeclaration" && statement.id?.name) return wrapAsync(`${normalizedSource}\nreturn ${statement.id.name}();`);
29
- if (statement.type === "ExpressionStatement" && statement.expression) {
30
- if (statement.expression.type === "ArrowFunctionExpression" && statement.expression.async) return normalizedSource;
31
- return wrapAsync(`return (${normalizedSource});`);
32
- }
33
- }
34
- const lastStatement = (program.body ?? []).at(-1);
35
- if (lastStatement?.type === "ExpressionStatement" && lastStatement.expression) {
36
- const bodyPrefix = normalizedSource.slice(0, lastStatement.start).trimEnd();
37
- const expressionSource = normalizedSource.slice(lastStatement.expression.start, lastStatement.expression.end);
38
- const lines = [];
39
- if (bodyPrefix.length > 0) lines.push(bodyPrefix);
40
- lines.push(`return (${expressionSource});`);
41
- return wrapAsync(lines.join("\n"));
42
- }
43
- return wrapAsync(normalizedSource);
44
- } catch {
45
- return wrapAsync(normalizedSource);
46
- }
47
- }
48
-
49
- //#endregion
50
- export { ExecuteFailure, assertValidIdentifier, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, generateTypesFromJsonSchema, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, isReservedWord, isValidIdentifier, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveProvider, sanitizeIdentifier, sanitizeToolName, serializePropertyName, truncateLogs };
51
- //# sourceMappingURL=index.js.map
6
+ export { ExecuteFailure, assertValidIdentifier, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, generateTypesFromJsonSchema, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, isReservedWord, isValidIdentifier, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveProvider, sanitizeIdentifier, sanitizeToolName, serializePropertyName, truncateLogs };
@@ -1,5 +1,5 @@
1
- const require_resolveProvider = require('../resolveProvider-D__uEvDj.cjs');
2
- require('../errors-CTel18cM.cjs');
1
+ const require_resolveProvider = require('../resolveProvider-DfcSnwnp.cjs');
2
+ require('../errors-BGSgVV40.cjs');
3
3
  let zod = require("zod");
4
4
  zod = require_resolveProvider.__toESM(zod);
5
5
  let __modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
@@ -2,8 +2,8 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, p as ResolvedToolDescriptor, t as ExecutionOptions, u as ExecuteErrorCode } from "../runner-BJu1lZFi.cjs";
6
- import { t as Executor } from "../executor-C7YjuD7r.cjs";
5
+ import { d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, p as ResolvedToolDescriptor, t as ExecutionOptions, u as ExecuteErrorCode } from "../runner-DSgvu6Ad.cjs";
6
+ import { t as Executor } from "../executor-CEXp0gYP.cjs";
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
8
  import { Implementation } from "@modelcontextprotocol/sdk/types.js";
9
9
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
@@ -2,8 +2,8 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, p as ResolvedToolDescriptor, t as ExecutionOptions, u as ExecuteErrorCode } from "../runner-CbC-ncVb.js";
6
- import { t as Executor } from "../executor-B-Qe_q5_.js";
5
+ import { d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, p as ResolvedToolDescriptor, t as ExecutionOptions, u as ExecuteErrorCode } from "../runner-FSGSGEpx.js";
6
+ import { t as Executor } from "../executor-_CO7E1U7.js";
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
8
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
9
9
  import { Implementation } from "@modelcontextprotocol/sdk/types.js";
package/dist/mcp/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as renderNamespaceDeclaration, i as renderDocComment, r as schemaToType, t as resolveProvider } from "../resolveProvider-TuOLZT2_.js";
2
- import "../errors-CgBwm39w.js";
1
+ import { a as renderNamespaceDeclaration, i as renderDocComment, r as schemaToType, t as resolveProvider } from "../resolveProvider-BHuwOGBm.js";
2
+ import "../errors-BXpyBhCI.js";
3
3
  import * as z from "zod";
4
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
5
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
@@ -0,0 +1,54 @@
1
+ const require_resolveProvider = require('./resolveProvider-DfcSnwnp.cjs');
2
+ let acorn = require("acorn");
3
+
4
+ //#region src/normalize.ts
5
+ function stripCodeFences(source) {
6
+ const match = source.match(/^\s*```[^\n]*\n([\s\S]*?)\n?```\s*$/);
7
+ return match ? match[1] : source;
8
+ }
9
+ function wrapAsync(body) {
10
+ if (body.trim().length === 0) return "async () => {}";
11
+ return `async () => {\n${body}\n}`;
12
+ }
13
+ /**
14
+ * Normalizes model-produced JavaScript into an executable async function body.
15
+ */
16
+ function normalizeCode(source) {
17
+ const normalizedSource = stripCodeFences(source).trim();
18
+ if (normalizedSource.length === 0) return "async () => {}";
19
+ try {
20
+ const program = (0, acorn.parse)(normalizedSource, {
21
+ ecmaVersion: "latest",
22
+ sourceType: "module"
23
+ });
24
+ if (program.body?.length === 1) {
25
+ const [statement] = program.body;
26
+ if (statement.type === "FunctionDeclaration" && statement.id?.name) return wrapAsync(`${normalizedSource}\nreturn ${statement.id.name}();`);
27
+ if (statement.type === "ExpressionStatement" && statement.expression) {
28
+ if (statement.expression.type === "ArrowFunctionExpression" && statement.expression.async) return normalizedSource;
29
+ return wrapAsync(`return (${normalizedSource});`);
30
+ }
31
+ }
32
+ const lastStatement = (program.body ?? []).at(-1);
33
+ if (lastStatement?.type === "ExpressionStatement" && lastStatement.expression) {
34
+ const bodyPrefix = normalizedSource.slice(0, lastStatement.start).trimEnd();
35
+ const expressionSource = normalizedSource.slice(lastStatement.expression.start, lastStatement.expression.end);
36
+ const lines = [];
37
+ if (bodyPrefix.length > 0) lines.push(bodyPrefix);
38
+ lines.push(`return (${expressionSource});`);
39
+ return wrapAsync(lines.join("\n"));
40
+ }
41
+ return wrapAsync(normalizedSource);
42
+ } catch {
43
+ return wrapAsync(normalizedSource);
44
+ }
45
+ }
46
+
47
+ //#endregion
48
+ Object.defineProperty(exports, 'normalizeCode', {
49
+ enumerable: true,
50
+ get: function () {
51
+ return normalizeCode;
52
+ }
53
+ });
54
+ //# sourceMappingURL=normalize-B80ZCnxe.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-B80ZCnxe.cjs","names":[],"sources":["../src/normalize.ts"],"sourcesContent":["import { parse } from \"acorn\";\nimport type { Node } from \"acorn\";\n\ntype PositionedNode = Node & {\n end: number;\n start: number;\n body?: PositionedNode[];\n expression?: PositionedNode;\n async?: boolean;\n id?: {\n name: string;\n };\n};\n\nfunction stripCodeFences(source: string): string {\n const match = source.match(/^\\s*```[^\\n]*\\n([\\s\\S]*?)\\n?```\\s*$/);\n return match ? match[1] : source;\n}\n\nfunction wrapAsync(body: string): string {\n if (body.trim().length === 0) {\n return \"async () => {}\";\n }\n\n return `async () => {\\n${body}\\n}`;\n}\n\n/**\n * Normalizes model-produced JavaScript into an executable async function body.\n */\nexport function normalizeCode(source: string): string {\n const normalizedSource = stripCodeFences(source).trim();\n\n if (normalizedSource.length === 0) {\n return \"async () => {}\";\n }\n\n try {\n const program = parse(normalizedSource, {\n ecmaVersion: \"latest\",\n sourceType: \"module\",\n }) as PositionedNode;\n\n if (program.body?.length === 1) {\n const [statement] = program.body;\n\n if (statement.type === \"FunctionDeclaration\" && statement.id?.name) {\n return wrapAsync(`${normalizedSource}\\nreturn ${statement.id.name}();`);\n }\n\n if (statement.type === \"ExpressionStatement\" && statement.expression) {\n if (\n statement.expression.type === \"ArrowFunctionExpression\" &&\n statement.expression.async\n ) {\n return normalizedSource;\n }\n\n return wrapAsync(`return (${normalizedSource});`);\n }\n }\n\n const body = program.body ?? [];\n const lastStatement = body.at(-1);\n\n if (\n lastStatement?.type === \"ExpressionStatement\" &&\n lastStatement.expression\n ) {\n const bodyPrefix = normalizedSource\n .slice(0, lastStatement.start)\n .trimEnd();\n const expressionSource = normalizedSource.slice(\n lastStatement.expression.start,\n lastStatement.expression.end,\n );\n\n const lines = [];\n\n if (bodyPrefix.length > 0) {\n lines.push(bodyPrefix);\n }\n\n lines.push(`return (${expressionSource});`);\n\n return wrapAsync(lines.join(\"\\n\"));\n }\n\n return wrapAsync(normalizedSource);\n } catch {\n return wrapAsync(normalizedSource);\n }\n}\n"],"mappings":";;;;AAcA,SAAS,gBAAgB,QAAwB;CAC/C,MAAM,QAAQ,OAAO,MAAM,sCAAsC;AACjE,QAAO,QAAQ,MAAM,KAAK;;AAG5B,SAAS,UAAU,MAAsB;AACvC,KAAI,KAAK,MAAM,CAAC,WAAW,EACzB,QAAO;AAGT,QAAO,kBAAkB,KAAK;;;;;AAMhC,SAAgB,cAAc,QAAwB;CACpD,MAAM,mBAAmB,gBAAgB,OAAO,CAAC,MAAM;AAEvD,KAAI,iBAAiB,WAAW,EAC9B,QAAO;AAGT,KAAI;EACF,MAAM,2BAAgB,kBAAkB;GACtC,aAAa;GACb,YAAY;GACb,CAAC;AAEF,MAAI,QAAQ,MAAM,WAAW,GAAG;GAC9B,MAAM,CAAC,aAAa,QAAQ;AAE5B,OAAI,UAAU,SAAS,yBAAyB,UAAU,IAAI,KAC5D,QAAO,UAAU,GAAG,iBAAiB,WAAW,UAAU,GAAG,KAAK,KAAK;AAGzE,OAAI,UAAU,SAAS,yBAAyB,UAAU,YAAY;AACpE,QACE,UAAU,WAAW,SAAS,6BAC9B,UAAU,WAAW,MAErB,QAAO;AAGT,WAAO,UAAU,WAAW,iBAAiB,IAAI;;;EAKrD,MAAM,iBADO,QAAQ,QAAQ,EAAE,EACJ,GAAG,GAAG;AAEjC,MACE,eAAe,SAAS,yBACxB,cAAc,YACd;GACA,MAAM,aAAa,iBAChB,MAAM,GAAG,cAAc,MAAM,CAC7B,SAAS;GACZ,MAAM,mBAAmB,iBAAiB,MACxC,cAAc,WAAW,OACzB,cAAc,WAAW,IAC1B;GAED,MAAM,QAAQ,EAAE;AAEhB,OAAI,WAAW,SAAS,EACtB,OAAM,KAAK,WAAW;AAGxB,SAAM,KAAK,WAAW,iBAAiB,IAAI;AAE3C,UAAO,UAAU,MAAM,KAAK,KAAK,CAAC;;AAGpC,SAAO,UAAU,iBAAiB;SAC5B;AACN,SAAO,UAAU,iBAAiB"}
@@ -0,0 +1,48 @@
1
+ import { parse } from "acorn";
2
+
3
+ //#region src/normalize.ts
4
+ function stripCodeFences(source) {
5
+ const match = source.match(/^\s*```[^\n]*\n([\s\S]*?)\n?```\s*$/);
6
+ return match ? match[1] : source;
7
+ }
8
+ function wrapAsync(body) {
9
+ if (body.trim().length === 0) return "async () => {}";
10
+ return `async () => {\n${body}\n}`;
11
+ }
12
+ /**
13
+ * Normalizes model-produced JavaScript into an executable async function body.
14
+ */
15
+ function normalizeCode(source) {
16
+ const normalizedSource = stripCodeFences(source).trim();
17
+ if (normalizedSource.length === 0) return "async () => {}";
18
+ try {
19
+ const program = parse(normalizedSource, {
20
+ ecmaVersion: "latest",
21
+ sourceType: "module"
22
+ });
23
+ if (program.body?.length === 1) {
24
+ const [statement] = program.body;
25
+ if (statement.type === "FunctionDeclaration" && statement.id?.name) return wrapAsync(`${normalizedSource}\nreturn ${statement.id.name}();`);
26
+ if (statement.type === "ExpressionStatement" && statement.expression) {
27
+ if (statement.expression.type === "ArrowFunctionExpression" && statement.expression.async) return normalizedSource;
28
+ return wrapAsync(`return (${normalizedSource});`);
29
+ }
30
+ }
31
+ const lastStatement = (program.body ?? []).at(-1);
32
+ if (lastStatement?.type === "ExpressionStatement" && lastStatement.expression) {
33
+ const bodyPrefix = normalizedSource.slice(0, lastStatement.start).trimEnd();
34
+ const expressionSource = normalizedSource.slice(lastStatement.expression.start, lastStatement.expression.end);
35
+ const lines = [];
36
+ if (bodyPrefix.length > 0) lines.push(bodyPrefix);
37
+ lines.push(`return (${expressionSource});`);
38
+ return wrapAsync(lines.join("\n"));
39
+ }
40
+ return wrapAsync(normalizedSource);
41
+ } catch {
42
+ return wrapAsync(normalizedSource);
43
+ }
44
+ }
45
+
46
+ //#endregion
47
+ export { normalizeCode as t };
48
+ //# sourceMappingURL=normalize-dfQC7HWx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-dfQC7HWx.js","names":[],"sources":["../src/normalize.ts"],"sourcesContent":["import { parse } from \"acorn\";\nimport type { Node } from \"acorn\";\n\ntype PositionedNode = Node & {\n end: number;\n start: number;\n body?: PositionedNode[];\n expression?: PositionedNode;\n async?: boolean;\n id?: {\n name: string;\n };\n};\n\nfunction stripCodeFences(source: string): string {\n const match = source.match(/^\\s*```[^\\n]*\\n([\\s\\S]*?)\\n?```\\s*$/);\n return match ? match[1] : source;\n}\n\nfunction wrapAsync(body: string): string {\n if (body.trim().length === 0) {\n return \"async () => {}\";\n }\n\n return `async () => {\\n${body}\\n}`;\n}\n\n/**\n * Normalizes model-produced JavaScript into an executable async function body.\n */\nexport function normalizeCode(source: string): string {\n const normalizedSource = stripCodeFences(source).trim();\n\n if (normalizedSource.length === 0) {\n return \"async () => {}\";\n }\n\n try {\n const program = parse(normalizedSource, {\n ecmaVersion: \"latest\",\n sourceType: \"module\",\n }) as PositionedNode;\n\n if (program.body?.length === 1) {\n const [statement] = program.body;\n\n if (statement.type === \"FunctionDeclaration\" && statement.id?.name) {\n return wrapAsync(`${normalizedSource}\\nreturn ${statement.id.name}();`);\n }\n\n if (statement.type === \"ExpressionStatement\" && statement.expression) {\n if (\n statement.expression.type === \"ArrowFunctionExpression\" &&\n statement.expression.async\n ) {\n return normalizedSource;\n }\n\n return wrapAsync(`return (${normalizedSource});`);\n }\n }\n\n const body = program.body ?? [];\n const lastStatement = body.at(-1);\n\n if (\n lastStatement?.type === \"ExpressionStatement\" &&\n lastStatement.expression\n ) {\n const bodyPrefix = normalizedSource\n .slice(0, lastStatement.start)\n .trimEnd();\n const expressionSource = normalizedSource.slice(\n lastStatement.expression.start,\n lastStatement.expression.end,\n );\n\n const lines = [];\n\n if (bodyPrefix.length > 0) {\n lines.push(bodyPrefix);\n }\n\n lines.push(`return (${expressionSource});`);\n\n return wrapAsync(lines.join(\"\\n\"));\n }\n\n return wrapAsync(normalizedSource);\n } catch {\n return wrapAsync(normalizedSource);\n }\n}\n"],"mappings":";;;AAcA,SAAS,gBAAgB,QAAwB;CAC/C,MAAM,QAAQ,OAAO,MAAM,sCAAsC;AACjE,QAAO,QAAQ,MAAM,KAAK;;AAG5B,SAAS,UAAU,MAAsB;AACvC,KAAI,KAAK,MAAM,CAAC,WAAW,EACzB,QAAO;AAGT,QAAO,kBAAkB,KAAK;;;;;AAMhC,SAAgB,cAAc,QAAwB;CACpD,MAAM,mBAAmB,gBAAgB,OAAO,CAAC,MAAM;AAEvD,KAAI,iBAAiB,WAAW,EAC9B,QAAO;AAGT,KAAI;EACF,MAAM,UAAU,MAAM,kBAAkB;GACtC,aAAa;GACb,YAAY;GACb,CAAC;AAEF,MAAI,QAAQ,MAAM,WAAW,GAAG;GAC9B,MAAM,CAAC,aAAa,QAAQ;AAE5B,OAAI,UAAU,SAAS,yBAAyB,UAAU,IAAI,KAC5D,QAAO,UAAU,GAAG,iBAAiB,WAAW,UAAU,GAAG,KAAK,KAAK;AAGzE,OAAI,UAAU,SAAS,yBAAyB,UAAU,YAAY;AACpE,QACE,UAAU,WAAW,SAAS,6BAC9B,UAAU,WAAW,MAErB,QAAO;AAGT,WAAO,UAAU,WAAW,iBAAiB,IAAI;;;EAKrD,MAAM,iBADO,QAAQ,QAAQ,EAAE,EACJ,GAAG,GAAG;AAEjC,MACE,eAAe,SAAS,yBACxB,cAAc,YACd;GACA,MAAM,aAAa,iBAChB,MAAM,GAAG,cAAc,MAAM,CAC7B,SAAS;GACZ,MAAM,mBAAmB,iBAAiB,MACxC,cAAc,WAAW,OACzB,cAAc,WAAW,IAC1B;GAED,MAAM,QAAQ,EAAE;AAEhB,OAAI,WAAW,SAAS,EACtB,OAAM,KAAK,WAAW;AAGxB,SAAM,KAAK,WAAW,iBAAiB,IAAI;AAE3C,UAAO,UAAU,MAAM,KAAK,KAAK,CAAC;;AAGpC,SAAO,UAAU,iBAAiB;SAC5B;AACN,SAAO,UAAU,iBAAiB"}
@@ -1,5 +1,5 @@
1
- const require_runner = require('../runner-Dt--9M2r.cjs');
2
- require('../errors-CTel18cM.cjs');
1
+ const require_runner = require('../runner-BxbJ5eWb.cjs');
2
+ require('../errors-BGSgVV40.cjs');
3
3
 
4
4
  //#region src/protocol/messages.ts
5
5
  function isRecord(value) {
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { a as ToolCall, d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, u as ExecuteErrorCode } from "../runner-BJu1lZFi.cjs";
5
+ import { a as ToolCall, d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, u as ExecuteErrorCode } from "../runner-DSgvu6Ad.cjs";
6
6
 
7
7
  //#region src/protocol/messages.d.ts
8
8
 
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * Public TypeScript declarations for this package entrypoint.
4
4
  */
5
- import { a as ToolCall, d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, u as ExecuteErrorCode } from "../runner-CbC-ncVb.js";
5
+ import { a as ToolCall, d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, u as ExecuteErrorCode } from "../runner-FSGSGEpx.js";
6
6
 
7
7
  //#region src/protocol/messages.d.ts
8
8
 
@@ -1,5 +1,5 @@
1
- import { n as extractProviderManifests, o as getExecutionTimeoutMessage, t as createToolCallDispatcher } from "../runner-8eVWfKxh.js";
2
- import "../errors-CgBwm39w.js";
1
+ import { n as extractProviderManifests, o as getExecutionTimeoutMessage, t as createToolCallDispatcher } from "../runner-nUCF59Au.js";
2
+ import "../errors-BXpyBhCI.js";
3
3
 
4
4
  //#region src/protocol/messages.ts
5
5
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-CgBwm39w.js";
1
+ import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-BXpyBhCI.js";
2
2
  import Ajv from "ajv";
3
3
  import * as zod from "zod";
4
4
 
@@ -285,4 +285,4 @@ function resolveProvider(provider) {
285
285
 
286
286
  //#endregion
287
287
  export { renderNamespaceDeclaration as a, isReservedWord as c, serializePropertyName as d, renderDocComment as i, isValidIdentifier as l, generateTypesFromJsonSchema as n, sanitizeToolName as o, schemaToType as r, assertValidIdentifier as s, resolveProvider as t, sanitizeIdentifier as u };
288
- //# sourceMappingURL=resolveProvider-TuOLZT2_.js.map
288
+ //# sourceMappingURL=resolveProvider-BHuwOGBm.js.map