@execbox/quickjs 0.1.2 → 0.2.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.
- package/README.md +6 -2
- package/dist/index.cjs +70 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -4
- package/dist/index.js.map +1 -1
- package/dist/runner/index.cjs +1 -1
- package/dist/runner/index.d.cts +11 -77
- package/dist/runner/index.d.cts.map +1 -1
- package/dist/runner/index.d.ts +11 -77
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +1 -1
- package/dist/runner/protocolEndpoint.cjs +5 -1
- package/dist/runner/protocolEndpoint.cjs.map +1 -1
- package/dist/runner/protocolEndpoint.d.cts +4 -0
- package/dist/runner/protocolEndpoint.d.cts.map +1 -1
- package/dist/runner/protocolEndpoint.d.ts +4 -0
- package/dist/runner/protocolEndpoint.d.ts.map +1 -1
- package/dist/runner/protocolEndpoint.js +5 -1
- package/dist/runner/protocolEndpoint.js.map +1 -1
- package/dist/{runner-9_N9h2rp.cjs → runner-BqkDnP0t.cjs} +109 -1
- package/dist/{runner-9_N9h2rp.cjs.map → runner-BqkDnP0t.cjs.map} +1 -1
- package/dist/{runner-O4f_FOhI.js → runner-CVaY4RVQ.js} +68 -2
- package/dist/{runner-O4f_FOhI.js.map → runner-CVaY4RVQ.js.map} +1 -1
- package/dist/{types-BB8mb_-T.d.cts → types-BXi8Lqtk.d.ts} +6 -2
- package/dist/types-BXi8Lqtk.d.ts.map +1 -0
- package/dist/{types-D7uau0GM.d.ts → types-CVE2n2LY.d.cts} +6 -2
- package/dist/types-CVE2n2LY.d.cts.map +1 -0
- package/package.json +15 -6
- package/dist/types-BB8mb_-T.d.cts.map +0 -1
- package/dist/types-D7uau0GM.d.ts.map +0 -1
|
@@ -28,6 +28,20 @@ function getExecutionTimeoutMessage() {
|
|
|
28
28
|
return EXECUTION_TIMEOUT_MESSAGE;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
+
* Creates the canonical timeout failure result used for preflight cancellation.
|
|
32
|
+
*/
|
|
33
|
+
function createTimeoutExecuteResult(durationMs = 0) {
|
|
34
|
+
return {
|
|
35
|
+
durationMs,
|
|
36
|
+
error: {
|
|
37
|
+
code: "timeout",
|
|
38
|
+
message: getExecutionTimeoutMessage()
|
|
39
|
+
},
|
|
40
|
+
logs: [],
|
|
41
|
+
ok: false
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
31
45
|
* Normalizes an unknown thrown value into a human-readable message.
|
|
32
46
|
*/
|
|
33
47
|
function normalizeThrownMessage(error) {
|
|
@@ -39,6 +53,17 @@ function normalizeThrownMessage(error) {
|
|
|
39
53
|
return String(error);
|
|
40
54
|
}
|
|
41
55
|
/**
|
|
56
|
+
* Builds the standard tool execution context passed to resolved tool wrappers.
|
|
57
|
+
*/
|
|
58
|
+
function createExecutionContext(signal, providerName, safeToolName, originalToolName) {
|
|
59
|
+
return {
|
|
60
|
+
originalToolName,
|
|
61
|
+
providerName,
|
|
62
|
+
safeToolName,
|
|
63
|
+
signal
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
42
67
|
* Truncates captured logs to the configured line and character limits.
|
|
43
68
|
*/
|
|
44
69
|
function truncateLogs(logs, maxLogLines, maxLogChars) {
|
|
@@ -5226,6 +5251,42 @@ var ExecuteFailure = class extends Error {
|
|
|
5226
5251
|
function isExecuteFailure(value) {
|
|
5227
5252
|
return value instanceof ExecuteFailure;
|
|
5228
5253
|
}
|
|
5254
|
+
/**
|
|
5255
|
+
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
5256
|
+
*/
|
|
5257
|
+
function isJsonSerializable(value, active = /* @__PURE__ */ new Set(), memo = /* @__PURE__ */ new WeakSet()) {
|
|
5258
|
+
if (value === null) return true;
|
|
5259
|
+
switch (typeof value) {
|
|
5260
|
+
case "string":
|
|
5261
|
+
case "boolean": return true;
|
|
5262
|
+
case "number": return Number.isFinite(value);
|
|
5263
|
+
case "bigint":
|
|
5264
|
+
case "function":
|
|
5265
|
+
case "symbol":
|
|
5266
|
+
case "undefined": return false;
|
|
5267
|
+
case "object": {
|
|
5268
|
+
const objectValue = value;
|
|
5269
|
+
if (memo.has(objectValue)) return true;
|
|
5270
|
+
if (active.has(objectValue)) return false;
|
|
5271
|
+
active.add(objectValue);
|
|
5272
|
+
let isSerializable = false;
|
|
5273
|
+
try {
|
|
5274
|
+
if (Array.isArray(value)) {
|
|
5275
|
+
isSerializable = value.every((item) => isJsonSerializable(item, active, memo));
|
|
5276
|
+
return isSerializable;
|
|
5277
|
+
}
|
|
5278
|
+
const prototype = Object.getPrototypeOf(value);
|
|
5279
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
5280
|
+
isSerializable = Object.values(value).every((item) => isJsonSerializable(item, active, memo));
|
|
5281
|
+
return isSerializable;
|
|
5282
|
+
} finally {
|
|
5283
|
+
active.delete(objectValue);
|
|
5284
|
+
if (isSerializable) memo.add(objectValue);
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
return false;
|
|
5289
|
+
}
|
|
5229
5290
|
|
|
5230
5291
|
//#endregion
|
|
5231
5292
|
//#region src/quickjsBridge.ts
|
|
@@ -5282,6 +5343,10 @@ function toGuestHandle(context, value) {
|
|
|
5282
5343
|
|
|
5283
5344
|
//#endregion
|
|
5284
5345
|
//#region src/runner/index.ts
|
|
5346
|
+
/**
|
|
5347
|
+
* @packageDocumentation
|
|
5348
|
+
* Public API for the `@execbox/quickjs/runner` entrypoint.
|
|
5349
|
+
*/
|
|
5285
5350
|
const DEFAULT_MEMORY_LIMIT_BYTES = 64 * 1024 * 1024;
|
|
5286
5351
|
const DEFAULT_TIMEOUT_MS = 5e3;
|
|
5287
5352
|
const DEFAULT_MAX_LOG_LINES = 100;
|
|
@@ -5480,6 +5545,7 @@ function createToolHandle(context, providerName, safeToolName, signal, trustedHo
|
|
|
5480
5545
|
*/
|
|
5481
5546
|
async function runQuickJsSession(request, options = {}) {
|
|
5482
5547
|
const loadModule = async () => {
|
|
5548
|
+
if (options.module) return options.module;
|
|
5483
5549
|
return options.loadModule ? await options.loadModule() : await loadDefaultModule();
|
|
5484
5550
|
};
|
|
5485
5551
|
const maxLogChars = options.maxLogChars ?? DEFAULT_MAX_LOG_CHARS;
|
|
@@ -5566,5 +5632,5 @@ async function runQuickJsSession(request, options = {}) {
|
|
|
5566
5632
|
}
|
|
5567
5633
|
|
|
5568
5634
|
//#endregion
|
|
5569
|
-
export { runQuickJsSession as t };
|
|
5570
|
-
//# sourceMappingURL=runner-
|
|
5635
|
+
export { createExecutionContext as a, normalizeThrownMessage as c, isJsonSerializable as i, ExecuteFailure as n, createTimeoutExecuteResult as o, isExecuteFailure as r, getExecutionTimeoutMessage as s, runQuickJsSession as t };
|
|
5636
|
+
//# sourceMappingURL=runner-CVaY4RVQ.js.map
|