@execbox/quickjs 0.1.1 → 0.1.2

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.
@@ -5395,10 +5395,23 @@ function injectProviders(context, providers, signal, trustedHostErrorKey, onTool
5395
5395
  function createToolHandle(context, providerName, safeToolName, signal, trustedHostErrorKey, onToolCall) {
5396
5396
  return context.newFunction(safeToolName, (...args) => {
5397
5397
  const deferred = context.newPromise();
5398
- const input = args[0] === void 0 ? void 0 : context.dump(args[0]);
5399
5398
  const disposeDeferred = () => {
5400
5399
  if (context.alive && deferred.alive) deferred.dispose();
5401
5400
  };
5401
+ let input;
5402
+ try {
5403
+ input = args[0] === void 0 ? void 0 : fromGuestHandle(context, args[0]);
5404
+ } catch (error) {
5405
+ const executeError = isExecuteFailure(error) ? error : new ExecuteFailure("serialization_error", "Guest code passed a non-serializable tool input");
5406
+ const errorHandle = createGuestErrorHandle(context, executeError.code, executeError.message, trustedHostErrorKey);
5407
+ try {
5408
+ deferred.reject(errorHandle);
5409
+ return deferred.handle;
5410
+ } finally {
5411
+ errorHandle.dispose();
5412
+ queueMicrotask(disposeDeferred);
5413
+ }
5414
+ }
5402
5415
  const onAbort = () => {
5403
5416
  signal.removeEventListener("abort", onAbort);
5404
5417
  if (!context.alive || !deferred.alive) {
@@ -5554,4 +5567,4 @@ async function runQuickJsSession(request, options = {}) {
5554
5567
 
5555
5568
  //#endregion
5556
5569
  export { runQuickJsSession as t };
5557
- //# sourceMappingURL=runner-DVOLiGt4.js.map
5570
+ //# sourceMappingURL=runner-O4f_FOhI.js.map