@execbox/core 0.4.1 → 0.5.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 (60) hide show
  1. package/README.md +5 -0
  2. package/dist/errors-B9ADBuDH.d.cts +29 -0
  3. package/dist/errors-B9ADBuDH.d.cts.map +1 -0
  4. package/dist/errors-DlbJQYs7.d.ts +29 -0
  5. package/dist/errors-DlbJQYs7.d.ts.map +1 -0
  6. package/dist/{errors-BXpyBhCI.js → errors-wS8yjQhS.js} +1 -1
  7. package/dist/{errors-BXpyBhCI.js.map → errors-wS8yjQhS.js.map} +1 -1
  8. package/dist/{errors-BGSgVV40.cjs → errors-xD8r6fCf.cjs} +1 -1
  9. package/dist/{errors-BGSgVV40.cjs.map → errors-xD8r6fCf.cjs.map} +1 -1
  10. package/dist/{executor-_CO7E1U7.d.ts → executor-B7q7K_27.d.ts} +2 -2
  11. package/dist/{executor-_CO7E1U7.d.ts.map → executor-B7q7K_27.d.ts.map} +1 -1
  12. package/dist/{executor-CEXp0gYP.d.cts → executor-BsE5nF-j.d.cts} +1 -1
  13. package/dist/{executor-CEXp0gYP.d.cts.map → executor-BsE5nF-j.d.cts.map} +1 -1
  14. package/dist/index.cjs +3 -16
  15. package/dist/index.d.cts +4 -4
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +3 -5
  18. package/dist/mcp/index.cjs +2 -2
  19. package/dist/mcp/index.d.cts +1 -1
  20. package/dist/mcp/index.d.cts.map +1 -1
  21. package/dist/mcp/index.d.ts +2 -2
  22. package/dist/mcp/index.js +2 -2
  23. package/dist/protocol/index.cjs +2 -2
  24. package/dist/protocol/index.d.ts +1 -1
  25. package/dist/protocol/index.js +2 -2
  26. package/dist/{resolveProvider-DfcSnwnp.cjs → resolveProvider-BZYSw8Qk.cjs} +2 -2
  27. package/dist/{resolveProvider-DfcSnwnp.cjs.map → resolveProvider-BZYSw8Qk.cjs.map} +1 -1
  28. package/dist/{resolveProvider-BHuwOGBm.js → resolveProvider-UqQxdF4j.js} +2 -2
  29. package/dist/{resolveProvider-BHuwOGBm.js.map → resolveProvider-UqQxdF4j.js.map} +1 -1
  30. package/dist/{runner-nUCF59Au.js → runner-6GMM-5ur.js} +2 -2
  31. package/dist/{runner-nUCF59Au.js.map → runner-6GMM-5ur.js.map} +1 -1
  32. package/dist/{runner-FSGSGEpx.d.ts → runner-ClFrFnz9.d.ts} +1 -1
  33. package/dist/{runner-FSGSGEpx.d.ts.map → runner-ClFrFnz9.d.ts.map} +1 -1
  34. package/dist/{runner-BxbJ5eWb.cjs → runner-CsrfDub-.cjs} +2 -2
  35. package/dist/{runner-BxbJ5eWb.cjs.map → runner-CsrfDub-.cjs.map} +1 -1
  36. package/dist/runtime.cjs +90 -0
  37. package/dist/runtime.cjs.map +1 -0
  38. package/dist/runtime.d.cts +65 -0
  39. package/dist/runtime.d.cts.map +1 -0
  40. package/dist/runtime.d.ts +65 -0
  41. package/dist/runtime.d.ts.map +1 -0
  42. package/dist/runtime.js +74 -0
  43. package/dist/runtime.js.map +1 -0
  44. package/package.json +7 -7
  45. package/dist/_internal/index.cjs +0 -45
  46. package/dist/_internal/index.cjs.map +0 -1
  47. package/dist/_internal/index.d.cts +0 -21
  48. package/dist/_internal/index.d.cts.map +0 -1
  49. package/dist/_internal/index.d.ts +0 -22
  50. package/dist/_internal/index.d.ts.map +0 -1
  51. package/dist/_internal/index.js +0 -30
  52. package/dist/_internal/index.js.map +0 -1
  53. package/dist/errors-B3IY3ID-.d.cts +0 -69
  54. package/dist/errors-B3IY3ID-.d.cts.map +0 -1
  55. package/dist/errors-BbUru7ko.d.ts +0 -69
  56. package/dist/errors-BbUru7ko.d.ts.map +0 -1
  57. package/dist/normalize-B80ZCnxe.cjs +0 -54
  58. package/dist/normalize-B80ZCnxe.cjs.map +0 -1
  59. package/dist/normalize-dfQC7HWx.js +0 -48
  60. package/dist/normalize-dfQC7HWx.js.map +0 -1
@@ -1,30 +0,0 @@
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 { t as normalizeCode } from "../normalize-dfQC7HWx.js";
3
- import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "../errors-BXpyBhCI.js";
4
-
5
- //#region src/runtimeOptions.ts
6
- /**
7
- * Default runtime limits shared across the built-in executor implementations.
8
- */
9
- const DEFAULT_EXECUTOR_RUNTIME_OPTIONS = {
10
- maxLogChars: 64e3,
11
- maxLogLines: 100,
12
- memoryLimitBytes: 64 * 1024 * 1024,
13
- timeoutMs: 5e3
14
- };
15
- /**
16
- * Resolves executor runtime limits by applying explicit overrides on top of a
17
- * base options object and finally the shared defaults.
18
- */
19
- function resolveExecutorRuntimeOptions(options = {}, overrides = {}) {
20
- return {
21
- maxLogChars: overrides.maxLogChars ?? options.maxLogChars ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogChars,
22
- maxLogLines: overrides.maxLogLines ?? options.maxLogLines ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogLines,
23
- memoryLimitBytes: overrides.memoryLimitBytes ?? options.memoryLimitBytes ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.memoryLimitBytes,
24
- timeoutMs: overrides.timeoutMs ?? options.timeoutMs ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.timeoutMs
25
- };
26
- }
27
-
28
- //#endregion
29
- export { DEFAULT_EXECUTOR_RUNTIME_OPTIONS, ExecuteFailure, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveExecutorRuntimeOptions, truncateLogs };
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions"],"sources":["../../src/runtimeOptions.ts"],"sourcesContent":["import type { ExecutorRuntimeOptions } from \"./runner.ts\";\n\ntype ResolvedExecutorRuntimeOptions = Readonly<\n Required<ExecutorRuntimeOptions>\n>;\n\n/**\n * Default runtime limits shared across the built-in executor implementations.\n */\nconst DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions = {\n maxLogChars: 64_000,\n maxLogLines: 100,\n memoryLimitBytes: 64 * 1024 * 1024,\n timeoutMs: 5000,\n};\n\nexport { DEFAULT_EXECUTOR_RUNTIME_OPTIONS };\n\n/**\n * Resolves executor runtime limits by applying explicit overrides on top of a\n * base options object and finally the shared defaults.\n */\nexport function resolveExecutorRuntimeOptions(\n options: ExecutorRuntimeOptions = {},\n overrides: ExecutorRuntimeOptions = {},\n): Required<ExecutorRuntimeOptions> {\n return {\n maxLogChars:\n overrides.maxLogChars ??\n options.maxLogChars ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogChars,\n maxLogLines:\n overrides.maxLogLines ??\n options.maxLogLines ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogLines,\n memoryLimitBytes:\n overrides.memoryLimitBytes ??\n options.memoryLimitBytes ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.memoryLimitBytes,\n timeoutMs:\n overrides.timeoutMs ??\n options.timeoutMs ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.timeoutMs,\n };\n}\n"],"mappings":";;;;;;;;AASA,MAAMA,mCAAmE;CACvE,aAAa;CACb,aAAa;CACb,kBAAkB,KAAK,OAAO;CAC9B,WAAW;CACZ;;;;;AAQD,SAAgB,8BACd,UAAkC,EAAE,EACpC,YAAoC,EAAE,EACJ;AAClC,QAAO;EACL,aACE,UAAU,eACV,QAAQ,eACR,iCAAiC;EACnC,aACE,UAAU,eACV,QAAQ,eACR,iCAAiC;EACnC,kBACE,UAAU,oBACV,QAAQ,oBACR,iCAAiC;EACnC,WACE,UAAU,aACV,QAAQ,aACR,iCAAiC;EACpC"}
@@ -1,69 +0,0 @@
1
- /**
2
- * @packageDocumentation
3
- * Public TypeScript declarations for this package entrypoint.
4
- */
5
- import { d as ExecuteResult, g as ToolExecutionContext, u as ExecuteErrorCode } from "./runner-DSgvu6Ad.cjs";
6
-
7
- //#region src/executor/shared.d.ts
8
-
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
- //#region src/normalize.d.ts
43
- /**
44
- * Normalizes model-produced JavaScript into an executable async function body.
45
- */
46
- declare function normalizeCode(source: string): string;
47
- //#endregion
48
- //#region src/errors.d.ts
49
- /**
50
- * Structured failure used internally to propagate executor and tool errors.
51
- */
52
- declare class ExecuteFailure extends Error {
53
- code: ExecuteErrorCode;
54
- /**
55
- * Creates a structured failure with a trusted executor or tool error code.
56
- */
57
- constructor(code: ExecuteErrorCode, message: string);
58
- }
59
- /**
60
- * Returns whether a thrown value is an {@link ExecuteFailure}.
61
- */
62
- declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
63
- /**
64
- * Returns whether a value can be serialized through the JSON-only host/guest boundary.
65
- */
66
- declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
67
- //#endregion
68
- export { createExecutionContext as a, getExecutionTimeoutMessage as c, normalizeThrownName as d, truncateLogs as f, normalizeCode as i, isKnownExecuteErrorCode as l, isExecuteFailure as n, createTimeoutExecuteResult as o, isJsonSerializable as r, formatConsoleLine as s, ExecuteFailure as t, normalizeThrownMessage as u };
69
- //# sourceMappingURL=errors-B3IY3ID-.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-B3IY3ID-.d.cts","names":[],"sources":["../src/executor/shared.ts","../src/normalize.ts","../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAyBA,CAAA,CAAA;AASgB,OAAA,CAAA,QAAA,CATA,uBAAA,CAS0B,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CAP9B,gBAO8B;AAO1C,CAAA,CAAA;AAeA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,OAAA,CAAA,OAAA,CAAA,IAAA,CAAA,MAAA,CAAA,QAAA,CAAA,eAAA;AAkBA,CAAA,CAAA;AAkBgB,OAAA,CAAA,QAAA,CA1DA,0BAAA,CAAA,CA2DN,CAAA,CAIP,MAAA;AAYH,CAAA,CAAA;AA8CA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA,CAAA,OAAA,CAAA,OAAA,CAAA,MAAA,CAAA,IAAA,CAAA,GAAA,CAAA,SAAA,CAAA,YAAA;;iBAlHgB,0BAAA,uBAA4C;;ACX5D,CAAA,CAAA,CAAA,UAAA,CAAA,EAAA,CAAA,OAAA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AA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CCT8B,cDS9B;;;;ACzBhB,OAAA,CAAA,QAAA,CAuBG,kBAAA,CAvBY,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAyBpB,GAzBoB,CAAA,MAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CA0BtB,OA1BsB,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,OAAA"}
@@ -1,69 +0,0 @@
1
- /**
2
- * @packageDocumentation
3
- * Public TypeScript declarations for this package entrypoint.
4
- */
5
- import { d as ExecuteResult, g as ToolExecutionContext, u as ExecuteErrorCode } from "./runner-FSGSGEpx.js";
6
-
7
- //#region src/executor/shared.d.ts
8
-
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
- //#region src/normalize.d.ts
43
- /**
44
- * Normalizes model-produced JavaScript into an executable async function body.
45
- */
46
- declare function normalizeCode(source: string): string;
47
- //#endregion
48
- //#region src/errors.d.ts
49
- /**
50
- * Structured failure used internally to propagate executor and tool errors.
51
- */
52
- declare class ExecuteFailure extends Error {
53
- code: ExecuteErrorCode;
54
- /**
55
- * Creates a structured failure with a trusted executor or tool error code.
56
- */
57
- constructor(code: ExecuteErrorCode, message: string);
58
- }
59
- /**
60
- * Returns whether a thrown value is an {@link ExecuteFailure}.
61
- */
62
- declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
63
- /**
64
- * Returns whether a value can be serialized through the JSON-only host/guest boundary.
65
- */
66
- declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
67
- //#endregion
68
- export { createExecutionContext as a, getExecutionTimeoutMessage as c, normalizeThrownName as d, truncateLogs as f, normalizeCode as i, isKnownExecuteErrorCode as l, isExecuteFailure as n, createTimeoutExecuteResult as o, isJsonSerializable as r, formatConsoleLine as s, ExecuteFailure as t, normalizeThrownMessage as u };
69
- //# sourceMappingURL=errors-BbUru7ko.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-BbUru7ko.d.ts","names":[],"sources":["../src/executor/shared.ts","../src/normalize.ts","../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAyBA,CAAA,CAAA;AASgB,OAAA,CAAA,QAAA,CATA,uBAAA,CAS0B,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CAP9B,gBAO8B;AAO1C,CAAA,CAAA;AAeA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,OAAA,CAAA,OAAA,CAAA,IAAA,CAAA,MAAA,CAAA,QAAA,CAAA,eAAA;AAkBA,CAAA,CAAA;AAkBgB,OAAA,CAAA,QAAA,CA1DA,0BAAA,CAAA,CA2DN,CAAA,CAIP,MAAA;AAYH,CAAA,CAAA;AA8CA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,S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A,CAAA,CAAA,CAAA;EAiBgB,WAAA,CAAA,IAAY,CAAA,CElGR,gBFkGQ,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA;AA8C5B;;;;AC7HgB,OAAA,CAAA,QAAA,CCTA,gBAAA,CDSa,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CCT8B,cDS9B;;;;ACzBhB,OAAA,CAAA,QAAA,CAuBG,kBAAA,CAvBY,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAyBpB,GAzBoB,CAAA,MAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CA0BtB,OA1BsB,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,OAAA"}
@@ -1,54 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,48 +0,0 @@
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
@@ -1 +0,0 @@
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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