Unified · Split
| @@ -1 +0,0 @@ | |||
| 1 | {"version":"3.2.4","results":[[":convex/executor.test.ts",{"duration":212.67722300000014,"failed":false}],[":convex/sources.test.ts",{"duration":235.0589490000002,"failed":false}]]} | ||
| @@ -1,11 +0,0 @@ | |||
| 1 | import worker, * as OTHER_EXPORTS from "/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/src/index.ts"; | ||
| 2 | import * as __MIDDLEWARE_0__ from "/home/rhys/assistant/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts"; | ||
| 3 | import * as __MIDDLEWARE_1__ from "/home/rhys/assistant/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts"; | ||
| 4 | |||
| 5 | export * from "/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/src/index.ts"; | ||
| 6 | const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__"; | ||
| 7 | export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [ | ||
| 8 | |||
| 9 | __MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default | ||
| 10 | ] | ||
| 11 | export default worker; | ||
| @@ -1,134 +0,0 @@ | |||
| 1 | // This loads all middlewares exposed on the middleware object and then starts | ||
| 2 | // the invocation chain. The big idea is that we can add these to the middleware | ||
| 3 | // export dynamically through wrangler, or we can potentially let users directly | ||
| 4 | // add them as a sort of "plugin" system. | ||
| 5 | |||
| 6 | import ENTRY, { __INTERNAL_WRANGLER_MIDDLEWARE__ } from "/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-Fog3Kp/middleware-insertion-facade.js"; | ||
| 7 | import { __facade_invoke__, __facade_register__, Dispatcher } from "/home/rhys/assistant/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/common.ts"; | ||
| 8 | import type { WorkerEntrypointConstructor } from "/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-Fog3Kp/middleware-insertion-facade.js"; | ||
| 9 | |||
| 10 | // Preserve all the exports from the worker | ||
| 11 | export * from "/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-Fog3Kp/middleware-insertion-facade.js"; | ||
| 12 | |||
| 13 | class __Facade_ScheduledController__ implements ScheduledController { | ||
| 14 | readonly #noRetry: ScheduledController["noRetry"]; | ||
| 15 | |||
| 16 | constructor( | ||
| 17 | readonly scheduledTime: number, | ||
| 18 | readonly cron: string, | ||
| 19 | noRetry: ScheduledController["noRetry"] | ||
| 20 | ) { | ||
| 21 | this.#noRetry = noRetry; | ||
| 22 | } | ||
| 23 | |||
| 24 | noRetry() { | ||
| 25 | if (!(this instanceof __Facade_ScheduledController__)) { | ||
| 26 | throw new TypeError("Illegal invocation"); | ||
| 27 | } | ||
| 28 | // Need to call native method immediately in case uncaught error thrown | ||
| 29 | this.#noRetry(); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | function wrapExportedHandler(worker: ExportedHandler): ExportedHandler { | ||
| 34 | // If we don't have any middleware defined, just return the handler as is | ||
| 35 | if ( | ||
| 36 | __INTERNAL_WRANGLER_MIDDLEWARE__ === undefined || | ||
| 37 | __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0 | ||
| 38 | ) { | ||
| 39 | return worker; | ||
| 40 | } | ||
| 41 | // Otherwise, register all middleware once | ||
| 42 | for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) { | ||
| 43 | __facade_register__(middleware); | ||
| 44 | } | ||
| 45 | |||
| 46 | const fetchDispatcher: ExportedHandlerFetchHandler = function ( | ||
| 47 | request, | ||
| 48 | env, | ||
| 49 | ctx | ||
| 50 | ) { | ||
| 51 | if (worker.fetch === undefined) { | ||
| 52 | throw new Error("Handler does not export a fetch() function."); | ||
| 53 | } | ||
| 54 | return worker.fetch(request, env, ctx); | ||
| 55 | }; | ||
| 56 | |||
| 57 | return { | ||
| 58 | ...worker, | ||
| 59 | fetch(request, env, ctx) { | ||
| 60 | const dispatcher: Dispatcher = function (type, init) { | ||
| 61 | if (type === "scheduled" && worker.scheduled !== undefined) { | ||
| 62 | const controller = new __Facade_ScheduledController__( | ||
| 63 | Date.now(), | ||
| 64 | init.cron ?? "", | ||
| 65 | () => {} | ||
| 66 | ); | ||
| 67 | return worker.scheduled(controller, env, ctx); | ||
| 68 | } | ||
| 69 | }; | ||
| 70 | return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher); | ||
| 71 | }, | ||
| 72 | }; | ||
| 73 | } | ||
| 74 | |||
| 75 | function wrapWorkerEntrypoint( | ||
| 76 | klass: WorkerEntrypointConstructor | ||
| 77 | ): WorkerEntrypointConstructor { | ||
| 78 | // If we don't have any middleware defined, just return the handler as is | ||
| 79 | if ( | ||
| 80 | __INTERNAL_WRANGLER_MIDDLEWARE__ === undefined || | ||
| 81 | __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0 | ||
| 82 | ) { | ||
| 83 | return klass; | ||
| 84 | } | ||
| 85 | // Otherwise, register all middleware once | ||
| 86 | for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) { | ||
| 87 | __facade_register__(middleware); | ||
| 88 | } | ||
| 89 | |||
| 90 | // `extend`ing `klass` here so other RPC methods remain callable | ||
| 91 | return class extends klass { | ||
| 92 | #fetchDispatcher: ExportedHandlerFetchHandler<Record<string, unknown>> = ( | ||
| 93 | request, | ||
| 94 | env, | ||
| 95 | ctx | ||
| 96 | ) => { | ||
| 97 | this.env = env; | ||
| 98 | this.ctx = ctx; | ||
| 99 | if (super.fetch === undefined) { | ||
| 100 | throw new Error("Entrypoint class does not define a fetch() function."); | ||
| 101 | } | ||
| 102 | return super.fetch(request); | ||
| 103 | }; | ||
| 104 | |||
| 105 | #dispatcher: Dispatcher = (type, init) => { | ||
| 106 | if (type === "scheduled" && super.scheduled !== undefined) { | ||
| 107 | const controller = new __Facade_ScheduledController__( | ||
| 108 | Date.now(), | ||
| 109 | init.cron ?? "", | ||
| 110 | () => {} | ||
| 111 | ); | ||
| 112 | return super.scheduled(controller); | ||
| 113 | } | ||
| 114 | }; | ||
| 115 | |||
| 116 | fetch(request: Request<unknown, IncomingRequestCfProperties>) { | ||
| 117 | return __facade_invoke__( | ||
| 118 | request, | ||
| 119 | this.env, | ||
| 120 | this.ctx, | ||
| 121 | this.#dispatcher, | ||
| 122 | this.#fetchDispatcher | ||
| 123 | ); | ||
| 124 | } | ||
| 125 | }; | ||
| 126 | } | ||
| 127 | |||
| 128 | let WRAPPED_ENTRY: ExportedHandler | WorkerEntrypointConstructor | undefined; | ||
| 129 | if (typeof ENTRY === "object") { | ||
| 130 | WRAPPED_ENTRY = wrapExportedHandler(ENTRY); | ||
| 131 | } else if (typeof ENTRY === "function") { | ||
| 132 | WRAPPED_ENTRY = wrapWorkerEntrypoint(ENTRY); | ||
| 133 | } | ||
| 134 | export default WRAPPED_ENTRY; | ||
| @@ -1,11 +0,0 @@ | |||
| 1 | import worker, * as OTHER_EXPORTS from "/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/src/index.ts"; | ||
| 2 | import * as __MIDDLEWARE_0__ from "/home/rhys/assistant/v2/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts"; | ||
| 3 | import * as __MIDDLEWARE_1__ from "/home/rhys/assistant/v2/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts"; | ||
| 4 | |||
| 5 | export * from "/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/src/index.ts"; | ||
| 6 | const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__"; | ||
| 7 | export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [ | ||
| 8 | |||
| 9 | __MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default | ||
| 10 | ] | ||
| 11 | export default worker; | ||
| @@ -1,134 +0,0 @@ | |||
| 1 | // This loads all middlewares exposed on the middleware object and then starts | ||
| 2 | // the invocation chain. The big idea is that we can add these to the middleware | ||
| 3 | // export dynamically through wrangler, or we can potentially let users directly | ||
| 4 | // add them as a sort of "plugin" system. | ||
| 5 | |||
| 6 | import ENTRY, { __INTERNAL_WRANGLER_MIDDLEWARE__ } from "/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-gLJWNP/middleware-insertion-facade.js"; | ||
| 7 | import { __facade_invoke__, __facade_register__, Dispatcher } from "/home/rhys/assistant/v2/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/common.ts"; | ||
| 8 | import type { WorkerEntrypointConstructor } from "/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-gLJWNP/middleware-insertion-facade.js"; | ||
| 9 | |||
| 10 | // Preserve all the exports from the worker | ||
| 11 | export * from "/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-gLJWNP/middleware-insertion-facade.js"; | ||
| 12 | |||
| 13 | class __Facade_ScheduledController__ implements ScheduledController { | ||
| 14 | readonly #noRetry: ScheduledController["noRetry"]; | ||
| 15 | |||
| 16 | constructor( | ||
| 17 | readonly scheduledTime: number, | ||
| 18 | readonly cron: string, | ||
| 19 | noRetry: ScheduledController["noRetry"] | ||
| 20 | ) { | ||
| 21 | this.#noRetry = noRetry; | ||
| 22 | } | ||
| 23 | |||
| 24 | noRetry() { | ||
| 25 | if (!(this instanceof __Facade_ScheduledController__)) { | ||
| 26 | throw new TypeError("Illegal invocation"); | ||
| 27 | } | ||
| 28 | // Need to call native method immediately in case uncaught error thrown | ||
| 29 | this.#noRetry(); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | function wrapExportedHandler(worker: ExportedHandler): ExportedHandler { | ||
| 34 | // If we don't have any middleware defined, just return the handler as is | ||
| 35 | if ( | ||
| 36 | __INTERNAL_WRANGLER_MIDDLEWARE__ === undefined || | ||
| 37 | __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0 | ||
| 38 | ) { | ||
| 39 | return worker; | ||
| 40 | } | ||
| 41 | // Otherwise, register all middleware once | ||
| 42 | for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) { | ||
| 43 | __facade_register__(middleware); | ||
| 44 | } | ||
| 45 | |||
| 46 | const fetchDispatcher: ExportedHandlerFetchHandler = function ( | ||
| 47 | request, | ||
| 48 | env, | ||
| 49 | ctx | ||
| 50 | ) { | ||
| 51 | if (worker.fetch === undefined) { | ||
| 52 | throw new Error("Handler does not export a fetch() function."); | ||
| 53 | } | ||
| 54 | return worker.fetch(request, env, ctx); | ||
| 55 | }; | ||
| 56 | |||
| 57 | return { | ||
| 58 | ...worker, | ||
| 59 | fetch(request, env, ctx) { | ||
| 60 | const dispatcher: Dispatcher = function (type, init) { | ||
| 61 | if (type === "scheduled" && worker.scheduled !== undefined) { | ||
| 62 | const controller = new __Facade_ScheduledController__( | ||
| 63 | Date.now(), | ||
| 64 | init.cron ?? "", | ||
| 65 | () => {} | ||
| 66 | ); | ||
| 67 | return worker.scheduled(controller, env, ctx); | ||
| 68 | } | ||
| 69 | }; | ||
| 70 | return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher); | ||
| 71 | }, | ||
| 72 | }; | ||
| 73 | } | ||
| 74 | |||
| 75 | function wrapWorkerEntrypoint( | ||
| 76 | klass: WorkerEntrypointConstructor | ||
| 77 | ): WorkerEntrypointConstructor { | ||
| 78 | // If we don't have any middleware defined, just return the handler as is | ||
| 79 | if ( | ||
| 80 | __INTERNAL_WRANGLER_MIDDLEWARE__ === undefined || | ||
| 81 | __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0 | ||
| 82 | ) { | ||
| 83 | return klass; | ||
| 84 | } | ||
| 85 | // Otherwise, register all middleware once | ||
| 86 | for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) { | ||
| 87 | __facade_register__(middleware); | ||
| 88 | } | ||
| 89 | |||
| 90 | // `extend`ing `klass` here so other RPC methods remain callable | ||
| 91 | return class extends klass { | ||
| 92 | #fetchDispatcher: ExportedHandlerFetchHandler<Record<string, unknown>> = ( | ||
| 93 | request, | ||
| 94 | env, | ||
| 95 | ctx | ||
| 96 | ) => { | ||
| 97 | this.env = env; | ||
| 98 | this.ctx = ctx; | ||
| 99 | if (super.fetch === undefined) { | ||
| 100 | throw new Error("Entrypoint class does not define a fetch() function."); | ||
| 101 | } | ||
| 102 | return super.fetch(request); | ||
| 103 | }; | ||
| 104 | |||
| 105 | #dispatcher: Dispatcher = (type, init) => { | ||
| 106 | if (type === "scheduled" && super.scheduled !== undefined) { | ||
| 107 | const controller = new __Facade_ScheduledController__( | ||
| 108 | Date.now(), | ||
| 109 | init.cron ?? "", | ||
| 110 | () => {} | ||
| 111 | ); | ||
| 112 | return super.scheduled(controller); | ||
| 113 | } | ||
| 114 | }; | ||
| 115 | |||
| 116 | fetch(request: Request<unknown, IncomingRequestCfProperties>) { | ||
| 117 | return __facade_invoke__( | ||
| 118 | request, | ||
| 119 | this.env, | ||
| 120 | this.ctx, | ||
| 121 | this.#dispatcher, | ||
| 122 | this.#fetchDispatcher | ||
| 123 | ); | ||
| 124 | } | ||
| 125 | }; | ||
| 126 | } | ||
| 127 | |||
| 128 | let WRAPPED_ENTRY: ExportedHandler | WorkerEntrypointConstructor | undefined; | ||
| 129 | if (typeof ENTRY === "object") { | ||
| 130 | WRAPPED_ENTRY = wrapExportedHandler(ENTRY); | ||
| 131 | } else if (typeof ENTRY === "function") { | ||
| 132 | WRAPPED_ENTRY = wrapWorkerEntrypoint(ENTRY); | ||
| 133 | } | ||
| 134 | export default WRAPPED_ENTRY; | ||
| @@ -1,199 +0,0 @@ | |||
| 1 | import { WorkerEntrypoint } from "cloudflare:workers"; | ||
| 2 | |||
| 3 | import { run } from "./user-code.js"; | ||
| 4 | |||
| 5 | const APPROVAL_DENIED_PREFIX = "APPROVAL_DENIED:"; | ||
| 6 | |||
| 7 | function isObjectRecord(value) { | ||
| 8 | return typeof value === "object" && value !== null && !Array.isArray(value); | ||
| 9 | } | ||
| 10 | |||
| 11 | function decodeToolBridgeResult(rawResult) { | ||
| 12 | if (!isObjectRecord(rawResult)) { | ||
| 13 | return { | ||
| 14 | ok: false, | ||
| 15 | kind: "failed", | ||
| 16 | error: "Tool bridge returned a non-object payload", | ||
| 17 | }; | ||
| 18 | } | ||
| 19 | |||
| 20 | if (rawResult.ok === true) { | ||
| 21 | return { | ||
| 22 | ok: true, | ||
| 23 | value: rawResult.value, | ||
| 24 | }; | ||
| 25 | } | ||
| 26 | |||
| 27 | if ( | ||
| 28 | rawResult.ok === false | ||
| 29 | && rawResult.kind === "pending" | ||
| 30 | && typeof rawResult.approvalId === "string" | ||
| 31 | && typeof rawResult.retryAfterMs === "number" | ||
| 32 | ) { | ||
| 33 | return { | ||
| 34 | ok: false, | ||
| 35 | kind: "pending", | ||
| 36 | approvalId: rawResult.approvalId, | ||
| 37 | retryAfterMs: rawResult.retryAfterMs, | ||
| 38 | ...(typeof rawResult.error === "string" ? { error: rawResult.error } : {}), | ||
| 39 | }; | ||
| 40 | } | ||
| 41 | |||
| 42 | if ( | ||
| 43 | rawResult.ok === false | ||
| 44 | && rawResult.kind === "denied" | ||
| 45 | && typeof rawResult.error === "string" | ||
| 46 | ) { | ||
| 47 | return { | ||
| 48 | ok: false, | ||
| 49 | kind: "denied", | ||
| 50 | error: rawResult.error, | ||
| 51 | }; | ||
| 52 | } | ||
| 53 | |||
| 54 | if ( | ||
| 55 | rawResult.ok === false | ||
| 56 | && rawResult.kind === "failed" | ||
| 57 | && typeof rawResult.error === "string" | ||
| 58 | ) { | ||
| 59 | return { | ||
| 60 | ok: false, | ||
| 61 | kind: "failed", | ||
| 62 | error: rawResult.error, | ||
| 63 | }; | ||
| 64 | } | ||
| 65 | |||
| 66 | return { | ||
| 67 | ok: false, | ||
| 68 | kind: "failed", | ||
| 69 | error: "Tool bridge returned a malformed payload", | ||
| 70 | }; | ||
| 71 | } | ||
| 72 | |||
| 73 | function describeExecutionError(error) { | ||
| 74 | if (error instanceof Error) { | ||
| 75 | const message = typeof error.message === "string" ? error.message.trim() : ""; | ||
| 76 | if (message.length > 0) { | ||
| 77 | return message; | ||
| 78 | } | ||
| 79 | |||
| 80 | const stack = typeof error.stack === "string" ? error.stack.trim() : ""; | ||
| 81 | if (stack.length > 0) { | ||
| 82 | return stack; | ||
| 83 | } | ||
| 84 | |||
| 85 | return "Execution failed with an empty Error object"; | ||
| 86 | } | ||
| 87 | |||
| 88 | const text = String(error).trim(); | ||
| 89 | if (text.length > 0) { | ||
| 90 | return text; | ||
| 91 | } | ||
| 92 | |||
| 93 | return "Execution failed with an empty non-Error throw value"; | ||
| 94 | } | ||
| 95 | |||
| 96 | function createToolsProxy(bridge, path = []) { | ||
| 97 | const callable = () => {}; | ||
| 98 | |||
| 99 | return new Proxy(callable, { | ||
| 100 | get(_target, prop) { | ||
| 101 | if (prop === "then") { | ||
| 102 | return undefined; | ||
| 103 | } | ||
| 104 | |||
| 105 | if (typeof prop !== "string") { | ||
| 106 | return undefined; | ||
| 107 | } | ||
| 108 | |||
| 109 | return createToolsProxy(bridge, [...path, prop]); | ||
| 110 | }, | ||
| 111 | |||
| 112 | async apply(_target, _thisArg, args) { | ||
| 113 | const toolPath = path.join("."); | ||
| 114 | if (!toolPath) { | ||
| 115 | throw new Error("Tool path missing"); | ||
| 116 | } | ||
| 117 | |||
| 118 | const input = args.length > 0 ? args[0] : {}; | ||
| 119 | const callId = `call_${crypto.randomUUID()}`; | ||
| 120 | const result = decodeToolBridgeResult( | ||
| 121 | await bridge.callTool(toolPath, input, callId), | ||
| 122 | ); | ||
| 123 | |||
| 124 | if (result.ok) { | ||
| 125 | return result.value; | ||
| 126 | } | ||
| 127 | |||
| 128 | if (result.kind === "pending") { | ||
| 129 | throw new Error( | ||
| 130 | `Tool call is unexpectedly pending approval (${result.approvalId})`, | ||
| 131 | ); | ||
| 132 | } | ||
| 133 | |||
| 134 | if (result.kind === "denied") { | ||
| 135 | throw new Error(APPROVAL_DENIED_PREFIX + result.error); | ||
| 136 | } | ||
| 137 | |||
| 138 | const errorText = typeof result.error === "string" ? result.error.trim() : ""; | ||
| 139 | throw new Error( | ||
| 140 | errorText.length > 0 | ||
| 141 | ? errorText | ||
| 142 | : `Tool call failed without an error message (${toolPath})`, | ||
| 143 | ); | ||
| 144 | }, | ||
| 145 | }); | ||
| 146 | } | ||
| 147 | |||
| 148 | function sanitizeExecutionResult(value) { | ||
| 149 | if (value === undefined) { | ||
| 150 | return undefined; | ||
| 151 | } | ||
| 152 | |||
| 153 | try { | ||
| 154 | const serialized = JSON.stringify(value); | ||
| 155 | if (serialized === undefined) { | ||
| 156 | return null; | ||
| 157 | } | ||
| 158 | |||
| 159 | return JSON.parse(serialized); | ||
| 160 | } catch { | ||
| 161 | return String(value); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | export default class SandboxHarness extends WorkerEntrypoint { | ||
| 166 | async evaluate(bridge) { | ||
| 167 | const tools = createToolsProxy(bridge); | ||
| 168 | const console = { | ||
| 169 | log: (..._args) => {}, | ||
| 170 | info: (..._args) => {}, | ||
| 171 | warn: (..._args) => {}, | ||
| 172 | error: (..._args) => {}, | ||
| 173 | }; | ||
| 174 | |||
| 175 | try { | ||
| 176 | const value = await run(tools, console); | ||
| 177 | return { | ||
| 178 | status: "completed", | ||
| 179 | result: sanitizeExecutionResult(value), | ||
| 180 | exitCode: 0, | ||
| 181 | }; | ||
| 182 | } catch (error) { | ||
| 183 | const message = describeExecutionError(error); | ||
| 184 | |||
| 185 | if (message.startsWith(APPROVAL_DENIED_PREFIX)) { | ||
| 186 | const denied = message.replace(APPROVAL_DENIED_PREFIX, "").trim(); | ||
| 187 | return { | ||
| 188 | status: "denied", | ||
| 189 | error: denied, | ||
| 190 | }; | ||
| 191 | } | ||
| 192 | |||
| 193 | return { | ||
| 194 | status: "failed", | ||
| 195 | error: message, | ||
| 196 | }; | ||
| 197 | } | ||
| 198 | } | ||
| 199 | } | ||
| @@ -1,1298 +0,0 @@ | |||
| 1 | var __defProp = Object.defineProperty; | ||
| 2 | var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
| 3 | |||
| 4 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/_internal/utils.mjs | ||
| 5 | // @__NO_SIDE_EFFECTS__ | ||
| 6 | function createNotImplementedError(name) { | ||
| 7 | return new Error(`[unenv] ${name} is not implemented yet!`); | ||
| 8 | } | ||
| 9 | __name(createNotImplementedError, "createNotImplementedError"); | ||
| 10 | // @__NO_SIDE_EFFECTS__ | ||
| 11 | function notImplemented(name) { | ||
| 12 | const fn = /* @__PURE__ */ __name(() => { | ||
| 13 | throw /* @__PURE__ */ createNotImplementedError(name); | ||
| 14 | }, "fn"); | ||
| 15 | return Object.assign(fn, { __unenv__: true }); | ||
| 16 | } | ||
| 17 | __name(notImplemented, "notImplemented"); | ||
| 18 | // @__NO_SIDE_EFFECTS__ | ||
| 19 | function notImplementedClass(name) { | ||
| 20 | return class { | ||
| 21 | __unenv__ = true; | ||
| 22 | constructor() { | ||
| 23 | throw new Error(`[unenv] ${name} is not implemented yet!`); | ||
| 24 | } | ||
| 25 | }; | ||
| 26 | } | ||
| 27 | __name(notImplementedClass, "notImplementedClass"); | ||
| 28 | |||
| 29 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/perf_hooks/performance.mjs | ||
| 30 | var _timeOrigin = globalThis.performance?.timeOrigin ?? Date.now(); | ||
| 31 | var _performanceNow = globalThis.performance?.now ? globalThis.performance.now.bind(globalThis.performance) : () => Date.now() - _timeOrigin; | ||
| 32 | var nodeTiming = { | ||
| 33 | name: "node", | ||
| 34 | entryType: "node", | ||
| 35 | startTime: 0, | ||
| 36 | duration: 0, | ||
| 37 | nodeStart: 0, | ||
| 38 | v8Start: 0, | ||
| 39 | bootstrapComplete: 0, | ||
| 40 | environment: 0, | ||
| 41 | loopStart: 0, | ||
| 42 | loopExit: 0, | ||
| 43 | idleTime: 0, | ||
| 44 | uvMetricsInfo: { | ||
| 45 | loopCount: 0, | ||
| 46 | events: 0, | ||
| 47 | eventsWaiting: 0 | ||
| 48 | }, | ||
| 49 | detail: void 0, | ||
| 50 | toJSON() { | ||
| 51 | return this; | ||
| 52 | } | ||
| 53 | }; | ||
| 54 | var PerformanceEntry = class { | ||
| 55 | static { | ||
| 56 | __name(this, "PerformanceEntry"); | ||
| 57 | } | ||
| 58 | __unenv__ = true; | ||
| 59 | detail; | ||
| 60 | entryType = "event"; | ||
| 61 | name; | ||
| 62 | startTime; | ||
| 63 | constructor(name, options) { | ||
| 64 | this.name = name; | ||
| 65 | this.startTime = options?.startTime || _performanceNow(); | ||
| 66 | this.detail = options?.detail; | ||
| 67 | } | ||
| 68 | get duration() { | ||
| 69 | return _performanceNow() - this.startTime; | ||
| 70 | } | ||
| 71 | toJSON() { | ||
| 72 | return { | ||
| 73 | name: this.name, | ||
| 74 | entryType: this.entryType, | ||
| 75 | startTime: this.startTime, | ||
| 76 | duration: this.duration, | ||
| 77 | detail: this.detail | ||
| 78 | }; | ||
| 79 | } | ||
| 80 | }; | ||
| 81 | var PerformanceMark = class PerformanceMark2 extends PerformanceEntry { | ||
| 82 | static { | ||
| 83 | __name(this, "PerformanceMark"); | ||
| 84 | } | ||
| 85 | entryType = "mark"; | ||
| 86 | constructor() { | ||
| 87 | super(...arguments); | ||
| 88 | } | ||
| 89 | get duration() { | ||
| 90 | return 0; | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | var PerformanceMeasure = class extends PerformanceEntry { | ||
| 94 | static { | ||
| 95 | __name(this, "PerformanceMeasure"); | ||
| 96 | } | ||
| 97 | entryType = "measure"; | ||
| 98 | }; | ||
| 99 | var PerformanceResourceTiming = class extends PerformanceEntry { | ||
| 100 | static { | ||
| 101 | __name(this, "PerformanceResourceTiming"); | ||
| 102 | } | ||
| 103 | entryType = "resource"; | ||
| 104 | serverTiming = []; | ||
| 105 | connectEnd = 0; | ||
| 106 | connectStart = 0; | ||
| 107 | decodedBodySize = 0; | ||
| 108 | domainLookupEnd = 0; | ||
| 109 | domainLookupStart = 0; | ||
| 110 | encodedBodySize = 0; | ||
| 111 | fetchStart = 0; | ||
| 112 | initiatorType = ""; | ||
| 113 | name = ""; | ||
| 114 | nextHopProtocol = ""; | ||
| 115 | redirectEnd = 0; | ||
| 116 | redirectStart = 0; | ||
| 117 | requestStart = 0; | ||
| 118 | responseEnd = 0; | ||
| 119 | responseStart = 0; | ||
| 120 | secureConnectionStart = 0; | ||
| 121 | startTime = 0; | ||
| 122 | transferSize = 0; | ||
| 123 | workerStart = 0; | ||
| 124 | responseStatus = 0; | ||
| 125 | }; | ||
| 126 | var PerformanceObserverEntryList = class { | ||
| 127 | static { | ||
| 128 | __name(this, "PerformanceObserverEntryList"); | ||
| 129 | } | ||
| 130 | __unenv__ = true; | ||
| 131 | getEntries() { | ||
| 132 | return []; | ||
| 133 | } | ||
| 134 | getEntriesByName(_name, _type) { | ||
| 135 | return []; | ||
| 136 | } | ||
| 137 | getEntriesByType(type) { | ||
| 138 | return []; | ||
| 139 | } | ||
| 140 | }; | ||
| 141 | var Performance = class { | ||
| 142 | static { | ||
| 143 | __name(this, "Performance"); | ||
| 144 | } | ||
| 145 | __unenv__ = true; | ||
| 146 | timeOrigin = _timeOrigin; | ||
| 147 | eventCounts = /* @__PURE__ */ new Map(); | ||
| 148 | _entries = []; | ||
| 149 | _resourceTimingBufferSize = 0; | ||
| 150 | navigation = void 0; | ||
| 151 | timing = void 0; | ||
| 152 | timerify(_fn, _options) { | ||
| 153 | throw createNotImplementedError("Performance.timerify"); | ||
| 154 | } | ||
| 155 | get nodeTiming() { | ||
| 156 | return nodeTiming; | ||
| 157 | } | ||
| 158 | eventLoopUtilization() { | ||
| 159 | return {}; | ||
| 160 | } | ||
| 161 | markResourceTiming() { | ||
| 162 | return new PerformanceResourceTiming(""); | ||
| 163 | } | ||
| 164 | onresourcetimingbufferfull = null; | ||
| 165 | now() { | ||
| 166 | if (this.timeOrigin === _timeOrigin) { | ||
| 167 | return _performanceNow(); | ||
| 168 | } | ||
| 169 | return Date.now() - this.timeOrigin; | ||
| 170 | } | ||
| 171 | clearMarks(markName) { | ||
| 172 | this._entries = markName ? this._entries.filter((e) => e.name !== markName) : this._entries.filter((e) => e.entryType !== "mark"); | ||
| 173 | } | ||
| 174 | clearMeasures(measureName) { | ||
| 175 | this._entries = measureName ? this._entries.filter((e) => e.name !== measureName) : this._entries.filter((e) => e.entryType !== "measure"); | ||
| 176 | } | ||
| 177 | clearResourceTimings() { | ||
| 178 | this._entries = this._entries.filter((e) => e.entryType !== "resource" || e.entryType !== "navigation"); | ||
| 179 | } | ||
| 180 | getEntries() { | ||
| 181 | return this._entries; | ||
| 182 | } | ||
| 183 | getEntriesByName(name, type) { | ||
| 184 | return this._entries.filter((e) => e.name === name && (!type || e.entryType === type)); | ||
| 185 | } | ||
| 186 | getEntriesByType(type) { | ||
| 187 | return this._entries.filter((e) => e.entryType === type); | ||
| 188 | } | ||
| 189 | mark(name, options) { | ||
| 190 | const entry = new PerformanceMark(name, options); | ||
| 191 | this._entries.push(entry); | ||
| 192 | return entry; | ||
| 193 | } | ||
| 194 | measure(measureName, startOrMeasureOptions, endMark) { | ||
| 195 | let start; | ||
| 196 | let end; | ||
| 197 | if (typeof startOrMeasureOptions === "string") { | ||
| 198 | start = this.getEntriesByName(startOrMeasureOptions, "mark")[0]?.startTime; | ||
| 199 | end = this.getEntriesByName(endMark, "mark")[0]?.startTime; | ||
| 200 | } else { | ||
| 201 | start = Number.parseFloat(startOrMeasureOptions?.start) || this.now(); | ||
| 202 | end = Number.parseFloat(startOrMeasureOptions?.end) || this.now(); | ||
| 203 | } | ||
| 204 | const entry = new PerformanceMeasure(measureName, { | ||
| 205 | startTime: start, | ||
| 206 | detail: { | ||
| 207 | start, | ||
| 208 | end | ||
| 209 | } | ||
| 210 | }); | ||
| 211 | this._entries.push(entry); | ||
| 212 | return entry; | ||
| 213 | } | ||
| 214 | setResourceTimingBufferSize(maxSize) { | ||
| 215 | this._resourceTimingBufferSize = maxSize; | ||
| 216 | } | ||
| 217 | addEventListener(type, listener, options) { | ||
| 218 | throw createNotImplementedError("Performance.addEventListener"); | ||
| 219 | } | ||
| 220 | removeEventListener(type, listener, options) { | ||
| 221 | throw createNotImplementedError("Performance.removeEventListener"); | ||
| 222 | } | ||
| 223 | dispatchEvent(event) { | ||
| 224 | throw createNotImplementedError("Performance.dispatchEvent"); | ||
| 225 | } | ||
| 226 | toJSON() { | ||
| 227 | return this; | ||
| 228 | } | ||
| 229 | }; | ||
| 230 | var PerformanceObserver = class { | ||
| 231 | static { | ||
| 232 | __name(this, "PerformanceObserver"); | ||
| 233 | } | ||
| 234 | __unenv__ = true; | ||
| 235 | static supportedEntryTypes = []; | ||
| 236 | _callback = null; | ||
| 237 | constructor(callback) { | ||
| 238 | this._callback = callback; | ||
| 239 | } | ||
| 240 | takeRecords() { | ||
| 241 | return []; | ||
| 242 | } | ||
| 243 | disconnect() { | ||
| 244 | throw createNotImplementedError("PerformanceObserver.disconnect"); | ||
| 245 | } | ||
| 246 | observe(options) { | ||
| 247 | throw createNotImplementedError("PerformanceObserver.observe"); | ||
| 248 | } | ||
| 249 | bind(fn) { | ||
| 250 | return fn; | ||
| 251 | } | ||
| 252 | runInAsyncScope(fn, thisArg, ...args) { | ||
| 253 | return fn.call(thisArg, ...args); | ||
| 254 | } | ||
| 255 | asyncId() { | ||
| 256 | return 0; | ||
| 257 | } | ||
| 258 | triggerAsyncId() { | ||
| 259 | return 0; | ||
| 260 | } | ||
| 261 | emitDestroy() { | ||
| 262 | return this; | ||
| 263 | } | ||
| 264 | }; | ||
| 265 | var performance = globalThis.performance && "addEventListener" in globalThis.performance ? globalThis.performance : new Performance(); | ||
| 266 | |||
| 267 | // ../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/polyfill/performance.mjs | ||
| 268 | globalThis.performance = performance; | ||
| 269 | globalThis.Performance = Performance; | ||
| 270 | globalThis.PerformanceEntry = PerformanceEntry; | ||
| 271 | globalThis.PerformanceMark = PerformanceMark; | ||
| 272 | globalThis.PerformanceMeasure = PerformanceMeasure; | ||
| 273 | globalThis.PerformanceObserver = PerformanceObserver; | ||
| 274 | globalThis.PerformanceObserverEntryList = PerformanceObserverEntryList; | ||
| 275 | globalThis.PerformanceResourceTiming = PerformanceResourceTiming; | ||
| 276 | |||
| 277 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/console.mjs | ||
| 278 | import { Writable } from "node:stream"; | ||
| 279 | |||
| 280 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/mock/noop.mjs | ||
| 281 | var noop_default = Object.assign(() => { | ||
| 282 | }, { __unenv__: true }); | ||
| 283 | |||
| 284 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/console.mjs | ||
| 285 | var _console = globalThis.console; | ||
| 286 | var _ignoreErrors = true; | ||
| 287 | var _stderr = new Writable(); | ||
| 288 | var _stdout = new Writable(); | ||
| 289 | var log = _console?.log ?? noop_default; | ||
| 290 | var info = _console?.info ?? log; | ||
| 291 | var trace = _console?.trace ?? info; | ||
| 292 | var debug = _console?.debug ?? log; | ||
| 293 | var table = _console?.table ?? log; | ||
| 294 | var error = _console?.error ?? log; | ||
| 295 | var warn = _console?.warn ?? error; | ||
| 296 | var createTask = _console?.createTask ?? /* @__PURE__ */ notImplemented("console.createTask"); | ||
| 297 | var clear = _console?.clear ?? noop_default; | ||
| 298 | var count = _console?.count ?? noop_default; | ||
| 299 | var countReset = _console?.countReset ?? noop_default; | ||
| 300 | var dir = _console?.dir ?? noop_default; | ||
| 301 | var dirxml = _console?.dirxml ?? noop_default; | ||
| 302 | var group = _console?.group ?? noop_default; | ||
| 303 | var groupEnd = _console?.groupEnd ?? noop_default; | ||
| 304 | var groupCollapsed = _console?.groupCollapsed ?? noop_default; | ||
| 305 | var profile = _console?.profile ?? noop_default; | ||
| 306 | var profileEnd = _console?.profileEnd ?? noop_default; | ||
| 307 | var time = _console?.time ?? noop_default; | ||
| 308 | var timeEnd = _console?.timeEnd ?? noop_default; | ||
| 309 | var timeLog = _console?.timeLog ?? noop_default; | ||
| 310 | var timeStamp = _console?.timeStamp ?? noop_default; | ||
| 311 | var Console = _console?.Console ?? /* @__PURE__ */ notImplementedClass("console.Console"); | ||
| 312 | var _times = /* @__PURE__ */ new Map(); | ||
| 313 | var _stdoutErrorHandler = noop_default; | ||
| 314 | var _stderrErrorHandler = noop_default; | ||
| 315 | |||
| 316 | // ../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/node/console.mjs | ||
| 317 | var workerdConsole = globalThis["console"]; | ||
| 318 | var { | ||
| 319 | assert, | ||
| 320 | clear: clear2, | ||
| 321 | // @ts-expect-error undocumented public API | ||
| 322 | context, | ||
| 323 | count: count2, | ||
| 324 | countReset: countReset2, | ||
| 325 | // @ts-expect-error undocumented public API | ||
| 326 | createTask: createTask2, | ||
| 327 | debug: debug2, | ||
| 328 | dir: dir2, | ||
| 329 | dirxml: dirxml2, | ||
| 330 | error: error2, | ||
| 331 | group: group2, | ||
| 332 | groupCollapsed: groupCollapsed2, | ||
| 333 | groupEnd: groupEnd2, | ||
| 334 | info: info2, | ||
| 335 | log: log2, | ||
| 336 | profile: profile2, | ||
| 337 | profileEnd: profileEnd2, | ||
| 338 | table: table2, | ||
| 339 | time: time2, | ||
| 340 | timeEnd: timeEnd2, | ||
| 341 | timeLog: timeLog2, | ||
| 342 | timeStamp: timeStamp2, | ||
| 343 | trace: trace2, | ||
| 344 | warn: warn2 | ||
| 345 | } = workerdConsole; | ||
| 346 | Object.assign(workerdConsole, { | ||
| 347 | Console, | ||
| 348 | _ignoreErrors, | ||
| 349 | _stderr, | ||
| 350 | _stderrErrorHandler, | ||
| 351 | _stdout, | ||
| 352 | _stdoutErrorHandler, | ||
| 353 | _times | ||
| 354 | }); | ||
| 355 | var console_default = workerdConsole; | ||
| 356 | |||
| 357 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-console | ||
| 358 | globalThis.console = console_default; | ||
| 359 | |||
| 360 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/hrtime.mjs | ||
| 361 | var hrtime = /* @__PURE__ */ Object.assign(/* @__PURE__ */ __name(function hrtime2(startTime) { | ||
| 362 | const now = Date.now(); | ||
| 363 | const seconds = Math.trunc(now / 1e3); | ||
| 364 | const nanos = now % 1e3 * 1e6; | ||
| 365 | if (startTime) { | ||
| 366 | let diffSeconds = seconds - startTime[0]; | ||
| 367 | let diffNanos = nanos - startTime[0]; | ||
| 368 | if (diffNanos < 0) { | ||
| 369 | diffSeconds = diffSeconds - 1; | ||
| 370 | diffNanos = 1e9 + diffNanos; | ||
| 371 | } | ||
| 372 | return [diffSeconds, diffNanos]; | ||
| 373 | } | ||
| 374 | return [seconds, nanos]; | ||
| 375 | }, "hrtime"), { bigint: /* @__PURE__ */ __name(function bigint() { | ||
| 376 | return BigInt(Date.now() * 1e6); | ||
| 377 | }, "bigint") }); | ||
| 378 | |||
| 379 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/process.mjs | ||
| 380 | import { EventEmitter } from "node:events"; | ||
| 381 | |||
| 382 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/read-stream.mjs | ||
| 383 | var ReadStream = class { | ||
| 384 | static { | ||
| 385 | __name(this, "ReadStream"); | ||
| 386 | } | ||
| 387 | fd; | ||
| 388 | isRaw = false; | ||
| 389 | isTTY = false; | ||
| 390 | constructor(fd) { | ||
| 391 | this.fd = fd; | ||
| 392 | } | ||
| 393 | setRawMode(mode) { | ||
| 394 | this.isRaw = mode; | ||
| 395 | return this; | ||
| 396 | } | ||
| 397 | }; | ||
| 398 | |||
| 399 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/write-stream.mjs | ||
| 400 | var WriteStream = class { | ||
| 401 | static { | ||
| 402 | __name(this, "WriteStream"); | ||
| 403 | } | ||
| 404 | fd; | ||
| 405 | columns = 80; | ||
| 406 | rows = 24; | ||
| 407 | isTTY = false; | ||
| 408 | constructor(fd) { | ||
| 409 | this.fd = fd; | ||
| 410 | } | ||
| 411 | clearLine(dir3, callback) { | ||
| 412 | callback && callback(); | ||
| 413 | return false; | ||
| 414 | } | ||
| 415 | clearScreenDown(callback) { | ||
| 416 | callback && callback(); | ||
| 417 | return false; | ||
| 418 | } | ||
| 419 | cursorTo(x, y, callback) { | ||
| 420 | callback && typeof callback === "function" && callback(); | ||
| 421 | return false; | ||
| 422 | } | ||
| 423 | moveCursor(dx, dy, callback) { | ||
| 424 | callback && callback(); | ||
| 425 | return false; | ||
| 426 | } | ||
| 427 | getColorDepth(env2) { | ||
| 428 | return 1; | ||
| 429 | } | ||
| 430 | hasColors(count3, env2) { | ||
| 431 | return false; | ||
| 432 | } | ||
| 433 | getWindowSize() { | ||
| 434 | return [this.columns, this.rows]; | ||
| 435 | } | ||
| 436 | write(str, encoding, cb) { | ||
| 437 | if (str instanceof Uint8Array) { | ||
| 438 | str = new TextDecoder().decode(str); | ||
| 439 | } | ||
| 440 | try { | ||
| 441 | console.log(str); | ||
| 442 | } catch { | ||
| 443 | } | ||
| 444 | cb && typeof cb === "function" && cb(); | ||
| 445 | return false; | ||
| 446 | } | ||
| 447 | }; | ||
| 448 | |||
| 449 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/node-version.mjs | ||
| 450 | var NODE_VERSION = "22.14.0"; | ||
| 451 | |||
| 452 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/process.mjs | ||
| 453 | var Process = class _Process extends EventEmitter { | ||
| 454 | static { | ||
| 455 | __name(this, "Process"); | ||
| 456 | } | ||
| 457 | env; | ||
| 458 | hrtime; | ||
| 459 | nextTick; | ||
| 460 | constructor(impl) { | ||
| 461 | super(); | ||
| 462 | this.env = impl.env; | ||
| 463 | this.hrtime = impl.hrtime; | ||
| 464 | this.nextTick = impl.nextTick; | ||
| 465 | for (const prop of [...Object.getOwnPropertyNames(_Process.prototype), ...Object.getOwnPropertyNames(EventEmitter.prototype)]) { | ||
| 466 | const value = this[prop]; | ||
| 467 | if (typeof value === "function") { | ||
| 468 | this[prop] = value.bind(this); | ||
| 469 | } | ||
| 470 | } | ||
| 471 | } | ||
| 472 | // --- event emitter --- | ||
| 473 | emitWarning(warning, type, code) { | ||
| 474 | console.warn(`${code ? `[${code}] ` : ""}${type ? `${type}: ` : ""}${warning}`); | ||
| 475 | } | ||
| 476 | emit(...args) { | ||
| 477 | return super.emit(...args); | ||
| 478 | } | ||
| 479 | listeners(eventName) { | ||
| 480 | return super.listeners(eventName); | ||
| 481 | } | ||
| 482 | // --- stdio (lazy initializers) --- | ||
| 483 | #stdin; | ||
| 484 | #stdout; | ||
| 485 | #stderr; | ||
| 486 | get stdin() { | ||
| 487 | return this.#stdin ??= new ReadStream(0); | ||
| 488 | } | ||
| 489 | get stdout() { | ||
| 490 | return this.#stdout ??= new WriteStream(1); | ||
| 491 | } | ||
| 492 | get stderr() { | ||
| 493 | return this.#stderr ??= new WriteStream(2); | ||
| 494 | } | ||
| 495 | // --- cwd --- | ||
| 496 | #cwd = "/"; | ||
| 497 | chdir(cwd2) { | ||
| 498 | this.#cwd = cwd2; | ||
| 499 | } | ||
| 500 | cwd() { | ||
| 501 | return this.#cwd; | ||
| 502 | } | ||
| 503 | // --- dummy props and getters --- | ||
| 504 | arch = ""; | ||
| 505 | platform = ""; | ||
| 506 | argv = []; | ||
| 507 | argv0 = ""; | ||
| 508 | execArgv = []; | ||
| 509 | execPath = ""; | ||
| 510 | title = ""; | ||
| 511 | pid = 200; | ||
| 512 | ppid = 100; | ||
| 513 | get version() { | ||
| 514 | return `v${NODE_VERSION}`; | ||
| 515 | } | ||
| 516 | get versions() { | ||
| 517 | return { node: NODE_VERSION }; | ||
| 518 | } | ||
| 519 | get allowedNodeEnvironmentFlags() { | ||
| 520 | return /* @__PURE__ */ new Set(); | ||
| 521 | } | ||
| 522 | get sourceMapsEnabled() { | ||
| 523 | return false; | ||
| 524 | } | ||
| 525 | get debugPort() { | ||
| 526 | return 0; | ||
| 527 | } | ||
| 528 | get throwDeprecation() { | ||
| 529 | return false; | ||
| 530 | } | ||
| 531 | get traceDeprecation() { | ||
| 532 | return false; | ||
| 533 | } | ||
| 534 | get features() { | ||
| 535 | return {}; | ||
| 536 | } | ||
| 537 | get release() { | ||
| 538 | return {}; | ||
| 539 | } | ||
| 540 | get connected() { | ||
| 541 | return false; | ||
| 542 | } | ||
| 543 | get config() { | ||
| 544 | return {}; | ||
| 545 | } | ||
| 546 | get moduleLoadList() { | ||
| 547 | return []; | ||
| 548 | } | ||
| 549 | constrainedMemory() { | ||
| 550 | return 0; | ||
| 551 | } | ||
| 552 | availableMemory() { | ||
| 553 | return 0; | ||
| 554 | } | ||
| 555 | uptime() { | ||
| 556 | return 0; | ||
| 557 | } | ||
| 558 | resourceUsage() { | ||
| 559 | return {}; | ||
| 560 | } | ||
| 561 | // --- noop methods --- | ||
| 562 | ref() { | ||
| 563 | } | ||
| 564 | unref() { | ||
| 565 | } | ||
| 566 | // --- unimplemented methods --- | ||
| 567 | umask() { | ||
| 568 | throw createNotImplementedError("process.umask"); | ||
| 569 | } | ||
| 570 | getBuiltinModule() { | ||
| 571 | return void 0; | ||
| 572 | } | ||
| 573 | getActiveResourcesInfo() { | ||
| 574 | throw createNotImplementedError("process.getActiveResourcesInfo"); | ||
| 575 | } | ||
| 576 | exit() { | ||
| 577 | throw createNotImplementedError("process.exit"); | ||
| 578 | } | ||
| 579 | reallyExit() { | ||
| 580 | throw createNotImplementedError("process.reallyExit"); | ||
| 581 | } | ||
| 582 | kill() { | ||
| 583 | throw createNotImplementedError("process.kill"); | ||
| 584 | } | ||
| 585 | abort() { | ||
| 586 | throw createNotImplementedError("process.abort"); | ||
| 587 | } | ||
| 588 | dlopen() { | ||
| 589 | throw createNotImplementedError("process.dlopen"); | ||
| 590 | } | ||
| 591 | setSourceMapsEnabled() { | ||
| 592 | throw createNotImplementedError("process.setSourceMapsEnabled"); | ||
| 593 | } | ||
| 594 | loadEnvFile() { | ||
| 595 | throw createNotImplementedError("process.loadEnvFile"); | ||
| 596 | } | ||
| 597 | disconnect() { | ||
| 598 | throw createNotImplementedError("process.disconnect"); | ||
| 599 | } | ||
| 600 | cpuUsage() { | ||
| 601 | throw createNotImplementedError("process.cpuUsage"); | ||
| 602 | } | ||
| 603 | setUncaughtExceptionCaptureCallback() { | ||
| 604 | throw createNotImplementedError("process.setUncaughtExceptionCaptureCallback"); | ||
| 605 | } | ||
| 606 | hasUncaughtExceptionCaptureCallback() { | ||
| 607 | throw createNotImplementedError("process.hasUncaughtExceptionCaptureCallback"); | ||
| 608 | } | ||
| 609 | initgroups() { | ||
| 610 | throw createNotImplementedError("process.initgroups"); | ||
| 611 | } | ||
| 612 | openStdin() { | ||
| 613 | throw createNotImplementedError("process.openStdin"); | ||
| 614 | } | ||
| 615 | assert() { | ||
| 616 | throw createNotImplementedError("process.assert"); | ||
| 617 | } | ||
| 618 | binding() { | ||
| 619 | throw createNotImplementedError("process.binding"); | ||
| 620 | } | ||
| 621 | // --- attached interfaces --- | ||
| 622 | permission = { has: /* @__PURE__ */ notImplemented("process.permission.has") }; | ||
| 623 | report = { | ||
| 624 | directory: "", | ||
| 625 | filename: "", | ||
| 626 | signal: "SIGUSR2", | ||
| 627 | compact: false, | ||
| 628 | reportOnFatalError: false, | ||
| 629 | reportOnSignal: false, | ||
| 630 | reportOnUncaughtException: false, | ||
| 631 | getReport: /* @__PURE__ */ notImplemented("process.report.getReport"), | ||
| 632 | writeReport: /* @__PURE__ */ notImplemented("process.report.writeReport") | ||
| 633 | }; | ||
| 634 | finalization = { | ||
| 635 | register: /* @__PURE__ */ notImplemented("process.finalization.register"), | ||
| 636 | unregister: /* @__PURE__ */ notImplemented("process.finalization.unregister"), | ||
| 637 | registerBeforeExit: /* @__PURE__ */ notImplemented("process.finalization.registerBeforeExit") | ||
| 638 | }; | ||
| 639 | memoryUsage = Object.assign(() => ({ | ||
| 640 | arrayBuffers: 0, | ||
| 641 | rss: 0, | ||
| 642 | external: 0, | ||
| 643 | heapTotal: 0, | ||
| 644 | heapUsed: 0 | ||
| 645 | }), { rss: /* @__PURE__ */ __name(() => 0, "rss") }); | ||
| 646 | // --- undefined props --- | ||
| 647 | mainModule = void 0; | ||
| 648 | domain = void 0; | ||
| 649 | // optional | ||
| 650 | send = void 0; | ||
| 651 | exitCode = void 0; | ||
| 652 | channel = void 0; | ||
| 653 | getegid = void 0; | ||
| 654 | geteuid = void 0; | ||
| 655 | getgid = void 0; | ||
| 656 | getgroups = void 0; | ||
| 657 | getuid = void 0; | ||
| 658 | setegid = void 0; | ||
| 659 | seteuid = void 0; | ||
| 660 | setgid = void 0; | ||
| 661 | setgroups = void 0; | ||
| 662 | setuid = void 0; | ||
| 663 | // internals | ||
| 664 | _events = void 0; | ||
| 665 | _eventsCount = void 0; | ||
| 666 | _exiting = void 0; | ||
| 667 | _maxListeners = void 0; | ||
| 668 | _debugEnd = void 0; | ||
| 669 | _debugProcess = void 0; | ||
| 670 | _fatalException = void 0; | ||
| 671 | _getActiveHandles = void 0; | ||
| 672 | _getActiveRequests = void 0; | ||
| 673 | _kill = void 0; | ||
| 674 | _preload_modules = void 0; | ||
| 675 | _rawDebug = void 0; | ||
| 676 | _startProfilerIdleNotifier = void 0; | ||
| 677 | _stopProfilerIdleNotifier = void 0; | ||
| 678 | _tickCallback = void 0; | ||
| 679 | _disconnect = void 0; | ||
| 680 | _handleQueue = void 0; | ||
| 681 | _pendingMessage = void 0; | ||
| 682 | _channel = void 0; | ||
| 683 | _send = void 0; | ||
| 684 | _linkedBinding = void 0; | ||
| 685 | }; | ||
| 686 | |||
| 687 | // ../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/node/process.mjs | ||
| 688 | var globalProcess = globalThis["process"]; | ||
| 689 | var getBuiltinModule = globalProcess.getBuiltinModule; | ||
| 690 | var workerdProcess = getBuiltinModule("node:process"); | ||
| 691 | var unenvProcess = new Process({ | ||
| 692 | env: globalProcess.env, | ||
| 693 | hrtime, | ||
| 694 | // `nextTick` is available from workerd process v1 | ||
| 695 | nextTick: workerdProcess.nextTick | ||
| 696 | }); | ||
| 697 | var { exit, features, platform } = workerdProcess; | ||
| 698 | var { | ||
| 699 | _channel, | ||
| 700 | _debugEnd, | ||
| 701 | _debugProcess, | ||
| 702 | _disconnect, | ||
| 703 | _events, | ||
| 704 | _eventsCount, | ||
| 705 | _exiting, | ||
| 706 | _fatalException, | ||
| 707 | _getActiveHandles, | ||
| 708 | _getActiveRequests, | ||
| 709 | _handleQueue, | ||
| 710 | _kill, | ||
| 711 | _linkedBinding, | ||
| 712 | _maxListeners, | ||
| 713 | _pendingMessage, | ||
| 714 | _preload_modules, | ||
| 715 | _rawDebug, | ||
| 716 | _send, | ||
| 717 | _startProfilerIdleNotifier, | ||
| 718 | _stopProfilerIdleNotifier, | ||
| 719 | _tickCallback, | ||
| 720 | abort, | ||
| 721 | addListener, | ||
| 722 | allowedNodeEnvironmentFlags, | ||
| 723 | arch, | ||
| 724 | argv, | ||
| 725 | argv0, | ||
| 726 | assert: assert2, | ||
| 727 | availableMemory, | ||
| 728 | binding, | ||
| 729 | channel, | ||
| 730 | chdir, | ||
| 731 | config, | ||
| 732 | connected, | ||
| 733 | constrainedMemory, | ||
| 734 | cpuUsage, | ||
| 735 | cwd, | ||
| 736 | debugPort, | ||
| 737 | disconnect, | ||
| 738 | dlopen, | ||
| 739 | domain, | ||
| 740 | emit, | ||
| 741 | emitWarning, | ||
| 742 | env, | ||
| 743 | eventNames, | ||
| 744 | execArgv, | ||
| 745 | execPath, | ||
| 746 | exitCode, | ||
| 747 | finalization, | ||
| 748 | getActiveResourcesInfo, | ||
| 749 | getegid, | ||
| 750 | geteuid, | ||
| 751 | getgid, | ||
| 752 | getgroups, | ||
| 753 | getMaxListeners, | ||
| 754 | getuid, | ||
| 755 | hasUncaughtExceptionCaptureCallback, | ||
| 756 | hrtime: hrtime3, | ||
| 757 | initgroups, | ||
| 758 | kill, | ||
| 759 | listenerCount, | ||
| 760 | listeners, | ||
| 761 | loadEnvFile, | ||
| 762 | mainModule, | ||
| 763 | memoryUsage, | ||
| 764 | moduleLoadList, | ||
| 765 | nextTick, | ||
| 766 | off, | ||
| 767 | on, | ||
| 768 | once, | ||
| 769 | openStdin, | ||
| 770 | permission, | ||
| 771 | pid, | ||
| 772 | ppid, | ||
| 773 | prependListener, | ||
| 774 | prependOnceListener, | ||
| 775 | rawListeners, | ||
| 776 | reallyExit, | ||
| 777 | ref, | ||
| 778 | release, | ||
| 779 | removeAllListeners, | ||
| 780 | removeListener, | ||
| 781 | report, | ||
| 782 | resourceUsage, | ||
| 783 | send, | ||
| 784 | setegid, | ||
| 785 | seteuid, | ||
| 786 | setgid, | ||
| 787 | setgroups, | ||
| 788 | setMaxListeners, | ||
| 789 | setSourceMapsEnabled, | ||
| 790 | setuid, | ||
| 791 | setUncaughtExceptionCaptureCallback, | ||
| 792 | sourceMapsEnabled, | ||
| 793 | stderr, | ||
| 794 | stdin, | ||
| 795 | stdout, | ||
| 796 | throwDeprecation, | ||
| 797 | title, | ||
| 798 | traceDeprecation, | ||
| 799 | umask, | ||
| 800 | unref, | ||
| 801 | uptime, | ||
| 802 | version, | ||
| 803 | versions | ||
| 804 | } = unenvProcess; | ||
| 805 | var _process = { | ||
| 806 | abort, | ||
| 807 | addListener, | ||
| 808 | allowedNodeEnvironmentFlags, | ||
| 809 | hasUncaughtExceptionCaptureCallback, | ||
| 810 | setUncaughtExceptionCaptureCallback, | ||
| 811 | loadEnvFile, | ||
| 812 | sourceMapsEnabled, | ||
| 813 | arch, | ||
| 814 | argv, | ||
| 815 | argv0, | ||
| 816 | chdir, | ||
| 817 | config, | ||
| 818 | connected, | ||
| 819 | constrainedMemory, | ||
| 820 | availableMemory, | ||
| 821 | cpuUsage, | ||
| 822 | cwd, | ||
| 823 | debugPort, | ||
| 824 | dlopen, | ||
| 825 | disconnect, | ||
| 826 | emit, | ||
| 827 | emitWarning, | ||
| 828 | env, | ||
| 829 | eventNames, | ||
| 830 | execArgv, | ||
| 831 | execPath, | ||
| 832 | exit, | ||
| 833 | finalization, | ||
| 834 | features, | ||
| 835 | getBuiltinModule, | ||
| 836 | getActiveResourcesInfo, | ||
| 837 | getMaxListeners, | ||
| 838 | hrtime: hrtime3, | ||
| 839 | kill, | ||
| 840 | listeners, | ||
| 841 | listenerCount, | ||
| 842 | memoryUsage, | ||
| 843 | nextTick, | ||
| 844 | on, | ||
| 845 | off, | ||
| 846 | once, | ||
| 847 | pid, | ||
| 848 | platform, | ||
| 849 | ppid, | ||
| 850 | prependListener, | ||
| 851 | prependOnceListener, | ||
| 852 | rawListeners, | ||
| 853 | release, | ||
| 854 | removeAllListeners, | ||
| 855 | removeListener, | ||
| 856 | report, | ||
| 857 | resourceUsage, | ||
| 858 | setMaxListeners, | ||
| 859 | setSourceMapsEnabled, | ||
| 860 | stderr, | ||
| 861 | stdin, | ||
| 862 | stdout, | ||
| 863 | title, | ||
| 864 | throwDeprecation, | ||
| 865 | traceDeprecation, | ||
| 866 | umask, | ||
| 867 | uptime, | ||
| 868 | version, | ||
| 869 | versions, | ||
| 870 | // @ts-expect-error old API | ||
| 871 | domain, | ||
| 872 | initgroups, | ||
| 873 | moduleLoadList, | ||
| 874 | reallyExit, | ||
| 875 | openStdin, | ||
| 876 | assert: assert2, | ||
| 877 | binding, | ||
| 878 | send, | ||
| 879 | exitCode, | ||
| 880 | channel, | ||
| 881 | getegid, | ||
| 882 | geteuid, | ||
| 883 | getgid, | ||
| 884 | getgroups, | ||
| 885 | getuid, | ||
| 886 | setegid, | ||
| 887 | seteuid, | ||
| 888 | setgid, | ||
| 889 | setgroups, | ||
| 890 | setuid, | ||
| 891 | permission, | ||
| 892 | mainModule, | ||
| 893 | _events, | ||
| 894 | _eventsCount, | ||
| 895 | _exiting, | ||
| 896 | _maxListeners, | ||
| 897 | _debugEnd, | ||
| 898 | _debugProcess, | ||
| 899 | _fatalException, | ||
| 900 | _getActiveHandles, | ||
| 901 | _getActiveRequests, | ||
| 902 | _kill, | ||
| 903 | _preload_modules, | ||
| 904 | _rawDebug, | ||
| 905 | _startProfilerIdleNotifier, | ||
| 906 | _stopProfilerIdleNotifier, | ||
| 907 | _tickCallback, | ||
| 908 | _disconnect, | ||
| 909 | _handleQueue, | ||
| 910 | _pendingMessage, | ||
| 911 | _channel, | ||
| 912 | _send, | ||
| 913 | _linkedBinding | ||
| 914 | }; | ||
| 915 | var process_default = _process; | ||
| 916 | |||
| 917 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-process | ||
| 918 | globalThis.process = process_default; | ||
| 919 | |||
| 920 | // src/index.ts | ||
| 921 | import { RpcTarget } from "cloudflare:workers"; | ||
| 922 | import HARNESS_CODE from "./61f783ce8adbc6fed3842c6828ff2e4660585772-harness.isolate.js"; | ||
| 923 | var DEFAULT_TIMEOUT_MS = 3e4; | ||
| 924 | var MAX_TIMEOUT_MS = 12e4; | ||
| 925 | var json = /* @__PURE__ */ __name((value, status = 200) => new Response(JSON.stringify(value), { | ||
| 926 | status, | ||
| 927 | headers: { | ||
| 928 | "content-type": "application/json" | ||
| 929 | } | ||
| 930 | }), "json"); | ||
| 931 | var isObjectRecord = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isObjectRecord"); | ||
| 932 | var isRuntimeToolCallResult = /* @__PURE__ */ __name((value) => { | ||
| 933 | if (!isObjectRecord(value)) { | ||
| 934 | return false; | ||
| 935 | } | ||
| 936 | if (value.ok === true) { | ||
| 937 | return Object.prototype.hasOwnProperty.call(value, "value"); | ||
| 938 | } | ||
| 939 | if (value.ok === false && value.kind === "pending") { | ||
| 940 | return typeof value.approvalId === "string" && typeof value.retryAfterMs === "number"; | ||
| 941 | } | ||
| 942 | if (value.ok === false && value.kind === "denied") { | ||
| 943 | return typeof value.error === "string"; | ||
| 944 | } | ||
| 945 | if (value.ok === false && value.kind === "failed") { | ||
| 946 | return typeof value.error === "string"; | ||
| 947 | } | ||
| 948 | return false; | ||
| 949 | }, "isRuntimeToolCallResult"); | ||
| 950 | var isRunResult = /* @__PURE__ */ __name((value) => { | ||
| 951 | if (!isObjectRecord(value)) { | ||
| 952 | return false; | ||
| 953 | } | ||
| 954 | if (value.status !== "completed" && value.status !== "failed" && value.status !== "timed_out" && value.status !== "denied") { | ||
| 955 | return false; | ||
| 956 | } | ||
| 957 | if (value.error !== void 0 && typeof value.error !== "string") { | ||
| 958 | return false; | ||
| 959 | } | ||
| 960 | if (value.exitCode !== void 0 && typeof value.exitCode !== "number") { | ||
| 961 | return false; | ||
| 962 | } | ||
| 963 | return true; | ||
| 964 | }, "isRunResult"); | ||
| 965 | var toFailedResult = /* @__PURE__ */ __name((error3) => ({ | ||
| 966 | status: "failed", | ||
| 967 | error: error3 | ||
| 968 | }), "toFailedResult"); | ||
| 969 | var validateRunRequest = /* @__PURE__ */ __name((value) => { | ||
| 970 | if (!isObjectRecord(value)) { | ||
| 971 | return null; | ||
| 972 | } | ||
| 973 | if (typeof value.runId !== "string" || typeof value.taskId !== "string" || typeof value.code !== "string") { | ||
| 974 | return null; | ||
| 975 | } | ||
| 976 | if (!isObjectRecord(value.callback) || typeof value.callback.url !== "string") { | ||
| 977 | return null; | ||
| 978 | } | ||
| 979 | if (value.callback.internalSecret !== void 0 && typeof value.callback.internalSecret !== "string") { | ||
| 980 | return null; | ||
| 981 | } | ||
| 982 | if (value.timeoutMs !== void 0 && typeof value.timeoutMs !== "number") { | ||
| 983 | return null; | ||
| 984 | } | ||
| 985 | return { | ||
| 986 | runId: value.runId, | ||
| 987 | taskId: value.taskId, | ||
| 988 | code: value.code, | ||
| 989 | timeoutMs: value.timeoutMs, | ||
| 990 | callback: { | ||
| 991 | url: value.callback.url, | ||
| 992 | internalSecret: value.callback.internalSecret | ||
| 993 | } | ||
| 994 | }; | ||
| 995 | }, "validateRunRequest"); | ||
| 996 | var buildUserModule = /* @__PURE__ */ __name((userCode) => `export async function run(tools, console) { | ||
| 997 | "use strict"; | ||
| 998 | ${userCode} | ||
| 999 | } | ||
| 1000 | `, "buildUserModule"); | ||
| 1001 | var ToolBridge = class extends RpcTarget { | ||
| 1002 | static { | ||
| 1003 | __name(this, "ToolBridge"); | ||
| 1004 | } | ||
| 1005 | #props; | ||
| 1006 | constructor(props) { | ||
| 1007 | super(); | ||
| 1008 | this.#props = props; | ||
| 1009 | } | ||
| 1010 | async callTool(toolPath, input, callId) { | ||
| 1011 | const headers = new Headers({ | ||
| 1012 | "content-type": "application/json" | ||
| 1013 | }); | ||
| 1014 | if (this.#props.callbackInternalSecret) { | ||
| 1015 | headers.set("x-internal-secret", this.#props.callbackInternalSecret); | ||
| 1016 | } | ||
| 1017 | const response = await fetch(this.#props.callbackUrl, { | ||
| 1018 | method: "POST", | ||
| 1019 | headers, | ||
| 1020 | body: JSON.stringify({ | ||
| 1021 | runId: this.#props.runId, | ||
| 1022 | callId, | ||
| 1023 | toolPath, | ||
| 1024 | input | ||
| 1025 | }) | ||
| 1026 | }).catch((error3) => { | ||
| 1027 | throw new Error( | ||
| 1028 | `Tool callback transport failed: ${error3 instanceof Error ? error3.message : String(error3)}` | ||
| 1029 | ); | ||
| 1030 | }); | ||
| 1031 | if (response.status !== 200) { | ||
| 1032 | return { | ||
| 1033 | ok: false, | ||
| 1034 | kind: "failed", | ||
| 1035 | error: `Tool callback returned ${response.status}` | ||
| 1036 | }; | ||
| 1037 | } | ||
| 1038 | const payload = await response.json().catch(() => null); | ||
| 1039 | if (!isRuntimeToolCallResult(payload)) { | ||
| 1040 | return { | ||
| 1041 | ok: false, | ||
| 1042 | kind: "failed", | ||
| 1043 | error: "Tool callback returned invalid result payload" | ||
| 1044 | }; | ||
| 1045 | } | ||
| 1046 | return payload; | ||
| 1047 | } | ||
| 1048 | }; | ||
| 1049 | var executeSandboxRun = /* @__PURE__ */ __name(async (request, env2) => { | ||
| 1050 | const timeoutMsRaw = request.timeoutMs ?? DEFAULT_TIMEOUT_MS; | ||
| 1051 | const timeoutMs = Math.max(1, Math.min(MAX_TIMEOUT_MS, Math.floor(timeoutMsRaw))); | ||
| 1052 | const toolBridge = new ToolBridge({ | ||
| 1053 | callbackUrl: request.callback.url, | ||
| 1054 | callbackInternalSecret: request.callback.internalSecret ?? null, | ||
| 1055 | runId: request.runId | ||
| 1056 | }); | ||
| 1057 | const worker = env2.LOADER.get(request.taskId, async () => ({ | ||
| 1058 | compatibilityDate: "2025-06-01", | ||
| 1059 | mainModule: "harness.js", | ||
| 1060 | modules: { | ||
| 1061 | "harness.js": HARNESS_CODE, | ||
| 1062 | "user-code.js": buildUserModule(request.code) | ||
| 1063 | }, | ||
| 1064 | env: {}, | ||
| 1065 | globalOutbound: null | ||
| 1066 | })); | ||
| 1067 | const entrypoint = worker.getEntrypoint(); | ||
| 1068 | let timer = null; | ||
| 1069 | let payload; | ||
| 1070 | try { | ||
| 1071 | const timeoutResult = new Promise((resolve) => { | ||
| 1072 | timer = setTimeout(() => { | ||
| 1073 | resolve({ | ||
| 1074 | status: "timed_out", | ||
| 1075 | error: `Execution timed out after ${timeoutMs}ms` | ||
| 1076 | }); | ||
| 1077 | }, timeoutMs); | ||
| 1078 | }); | ||
| 1079 | payload = await Promise.race([ | ||
| 1080 | entrypoint.evaluate(toolBridge), | ||
| 1081 | timeoutResult | ||
| 1082 | ]); | ||
| 1083 | } catch (error3) { | ||
| 1084 | if (timer) { | ||
| 1085 | clearTimeout(timer); | ||
| 1086 | } | ||
| 1087 | return toFailedResult( | ||
| 1088 | `Sandbox isolate execution failed: ${error3 instanceof Error ? error3.message : String(error3)}` | ||
| 1089 | ); | ||
| 1090 | } | ||
| 1091 | if (timer) { | ||
| 1092 | clearTimeout(timer); | ||
| 1093 | } | ||
| 1094 | if (!isRunResult(payload)) { | ||
| 1095 | return toFailedResult("Sandbox isolate returned invalid response payload"); | ||
| 1096 | } | ||
| 1097 | return payload; | ||
| 1098 | }, "executeSandboxRun"); | ||
| 1099 | var src_default = { | ||
| 1100 | async fetch(request, env2, _ctx) { | ||
| 1101 | const url = new URL(request.url); | ||
| 1102 | if (url.pathname === "/health") { | ||
| 1103 | return new Response("ok", { status: 200 }); | ||
| 1104 | } | ||
| 1105 | if (url.pathname !== "/v1/runs" || request.method !== "POST") { | ||
| 1106 | return json({ error: "not_found" }, 404); | ||
| 1107 | } | ||
| 1108 | if (typeof env2.AUTH_TOKEN !== "string" || env2.AUTH_TOKEN.length === 0) { | ||
| 1109 | return json({ error: "misconfigured_auth_token" }, 500); | ||
| 1110 | } | ||
| 1111 | if (request.headers.get("authorization") !== `Bearer ${env2.AUTH_TOKEN}`) { | ||
| 1112 | return json({ error: "unauthorized" }, 401); | ||
| 1113 | } | ||
| 1114 | const payloadRaw = await request.json().catch(() => null); | ||
| 1115 | const payload = validateRunRequest(payloadRaw); | ||
| 1116 | if (!payload) { | ||
| 1117 | return json({ error: "invalid_payload" }, 400); | ||
| 1118 | } | ||
| 1119 | const runResult = await executeSandboxRun(payload, env2); | ||
| 1120 | return json(runResult, 200); | ||
| 1121 | } | ||
| 1122 | }; | ||
| 1123 | |||
| 1124 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts | ||
| 1125 | var drainBody = /* @__PURE__ */ __name(async (request, env2, _ctx, middlewareCtx) => { | ||
| 1126 | try { | ||
| 1127 | return await middlewareCtx.next(request, env2); | ||
| 1128 | } finally { | ||
| 1129 | try { | ||
| 1130 | if (request.body !== null && !request.bodyUsed) { | ||
| 1131 | const reader = request.body.getReader(); | ||
| 1132 | while (!(await reader.read()).done) { | ||
| 1133 | } | ||
| 1134 | } | ||
| 1135 | } catch (e) { | ||
| 1136 | console.error("Failed to drain the unused request body.", e); | ||
| 1137 | } | ||
| 1138 | } | ||
| 1139 | }, "drainBody"); | ||
| 1140 | var middleware_ensure_req_body_drained_default = drainBody; | ||
| 1141 | |||
| 1142 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts | ||
| 1143 | function reduceError(e) { | ||
| 1144 | return { | ||
| 1145 | name: e?.name, | ||
| 1146 | message: e?.message ?? String(e), | ||
| 1147 | stack: e?.stack, | ||
| 1148 | cause: e?.cause === void 0 ? void 0 : reduceError(e.cause) | ||
| 1149 | }; | ||
| 1150 | } | ||
| 1151 | __name(reduceError, "reduceError"); | ||
| 1152 | var jsonError = /* @__PURE__ */ __name(async (request, env2, _ctx, middlewareCtx) => { | ||
| 1153 | try { | ||
| 1154 | return await middlewareCtx.next(request, env2); | ||
| 1155 | } catch (e) { | ||
| 1156 | const error3 = reduceError(e); | ||
| 1157 | return Response.json(error3, { | ||
| 1158 | status: 500, | ||
| 1159 | headers: { "MF-Experimental-Error-Stack": "true" } | ||
| 1160 | }); | ||
| 1161 | } | ||
| 1162 | }, "jsonError"); | ||
| 1163 | var middleware_miniflare3_json_error_default = jsonError; | ||
| 1164 | |||
| 1165 | // .wrangler/tmp/bundle-Fog3Kp/middleware-insertion-facade.js | ||
| 1166 | var __INTERNAL_WRANGLER_MIDDLEWARE__ = [ | ||
| 1167 | middleware_ensure_req_body_drained_default, | ||
| 1168 | middleware_miniflare3_json_error_default | ||
| 1169 | ]; | ||
| 1170 | var middleware_insertion_facade_default = src_default; | ||
| 1171 | |||
| 1172 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/common.ts | ||
| 1173 | var __facade_middleware__ = []; | ||
| 1174 | function __facade_register__(...args) { | ||
| 1175 | __facade_middleware__.push(...args.flat()); | ||
| 1176 | } | ||
| 1177 | __name(__facade_register__, "__facade_register__"); | ||
| 1178 | function __facade_invokeChain__(request, env2, ctx, dispatch, middlewareChain) { | ||
| 1179 | const [head, ...tail] = middlewareChain; | ||
| 1180 | const middlewareCtx = { | ||
| 1181 | dispatch, | ||
| 1182 | next(newRequest, newEnv) { | ||
| 1183 | return __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail); | ||
| 1184 | } | ||
| 1185 | }; | ||
| 1186 | return head(request, env2, ctx, middlewareCtx); | ||
| 1187 | } | ||
| 1188 | __name(__facade_invokeChain__, "__facade_invokeChain__"); | ||
| 1189 | function __facade_invoke__(request, env2, ctx, dispatch, finalMiddleware) { | ||
| 1190 | return __facade_invokeChain__(request, env2, ctx, dispatch, [ | ||
| 1191 | ...__facade_middleware__, | ||
| 1192 | finalMiddleware | ||
| 1193 | ]); | ||
| 1194 | } | ||
| 1195 | __name(__facade_invoke__, "__facade_invoke__"); | ||
| 1196 | |||
| 1197 | // .wrangler/tmp/bundle-Fog3Kp/middleware-loader.entry.ts | ||
| 1198 | var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ { | ||
| 1199 | constructor(scheduledTime, cron, noRetry) { | ||
| 1200 | this.scheduledTime = scheduledTime; | ||
| 1201 | this.cron = cron; | ||
| 1202 | this.#noRetry = noRetry; | ||
| 1203 | } | ||
| 1204 | static { | ||
| 1205 | __name(this, "__Facade_ScheduledController__"); | ||
| 1206 | } | ||
| 1207 | #noRetry; | ||
| 1208 | noRetry() { | ||
| 1209 | if (!(this instanceof ___Facade_ScheduledController__)) { | ||
| 1210 | throw new TypeError("Illegal invocation"); | ||
| 1211 | } | ||
| 1212 | this.#noRetry(); | ||
| 1213 | } | ||
| 1214 | }; | ||
| 1215 | function wrapExportedHandler(worker) { | ||
| 1216 | if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) { | ||
| 1217 | return worker; | ||
| 1218 | } | ||
| 1219 | for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) { | ||
| 1220 | __facade_register__(middleware); | ||
| 1221 | } | ||
| 1222 | const fetchDispatcher = /* @__PURE__ */ __name(function(request, env2, ctx) { | ||
| 1223 | if (worker.fetch === void 0) { | ||
| 1224 | throw new Error("Handler does not export a fetch() function."); | ||
| 1225 | } | ||
| 1226 | return worker.fetch(request, env2, ctx); | ||
| 1227 | }, "fetchDispatcher"); | ||
| 1228 | return { | ||
| 1229 | ...worker, | ||
| 1230 | fetch(request, env2, ctx) { | ||
| 1231 | const dispatcher = /* @__PURE__ */ __name(function(type, init) { | ||
| 1232 | if (type === "scheduled" && worker.scheduled !== void 0) { | ||
| 1233 | const controller = new __Facade_ScheduledController__( | ||
| 1234 | Date.now(), | ||
| 1235 | init.cron ?? "", | ||
| 1236 | () => { | ||
| 1237 | } | ||
| 1238 | ); | ||
| 1239 | return worker.scheduled(controller, env2, ctx); | ||
| 1240 | } | ||
| 1241 | }, "dispatcher"); | ||
| 1242 | return __facade_invoke__(request, env2, ctx, dispatcher, fetchDispatcher); | ||
| 1243 | } | ||
| 1244 | }; | ||
| 1245 | } | ||
| 1246 | __name(wrapExportedHandler, "wrapExportedHandler"); | ||
| 1247 | function wrapWorkerEntrypoint(klass) { | ||
| 1248 | if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) { | ||
| 1249 | return klass; | ||
| 1250 | } | ||
| 1251 | for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) { | ||
| 1252 | __facade_register__(middleware); | ||
| 1253 | } | ||
| 1254 | return class extends klass { | ||
| 1255 | #fetchDispatcher = /* @__PURE__ */ __name((request, env2, ctx) => { | ||
| 1256 | this.env = env2; | ||
| 1257 | this.ctx = ctx; | ||
| 1258 | if (super.fetch === void 0) { | ||
| 1259 | throw new Error("Entrypoint class does not define a fetch() function."); | ||
| 1260 | } | ||
| 1261 | return super.fetch(request); | ||
| 1262 | }, "#fetchDispatcher"); | ||
| 1263 | #dispatcher = /* @__PURE__ */ __name((type, init) => { | ||
| 1264 | if (type === "scheduled" && super.scheduled !== void 0) { | ||
| 1265 | const controller = new __Facade_ScheduledController__( | ||
| 1266 | Date.now(), | ||
| 1267 | init.cron ?? "", | ||
| 1268 | () => { | ||
| 1269 | } | ||
| 1270 | ); | ||
| 1271 | return super.scheduled(controller); | ||
| 1272 | } | ||
| 1273 | }, "#dispatcher"); | ||
| 1274 | fetch(request) { | ||
| 1275 | return __facade_invoke__( | ||
| 1276 | request, | ||
| 1277 | this.env, | ||
| 1278 | this.ctx, | ||
| 1279 | this.#dispatcher, | ||
| 1280 | this.#fetchDispatcher | ||
| 1281 | ); | ||
| 1282 | } | ||
| 1283 | }; | ||
| 1284 | } | ||
| 1285 | __name(wrapWorkerEntrypoint, "wrapWorkerEntrypoint"); | ||
| 1286 | var WRAPPED_ENTRY; | ||
| 1287 | if (typeof middleware_insertion_facade_default === "object") { | ||
| 1288 | WRAPPED_ENTRY = wrapExportedHandler(middleware_insertion_facade_default); | ||
| 1289 | } else if (typeof middleware_insertion_facade_default === "function") { | ||
| 1290 | WRAPPED_ENTRY = wrapWorkerEntrypoint(middleware_insertion_facade_default); | ||
| 1291 | } | ||
| 1292 | var middleware_loader_entry_default = WRAPPED_ENTRY; | ||
| 1293 | export { | ||
| 1294 | ToolBridge, | ||
| 1295 | __INTERNAL_WRANGLER_MIDDLEWARE__, | ||
| 1296 | middleware_loader_entry_default as default | ||
| 1297 | }; | ||
| 1298 | //# sourceMappingURL=index.js.map | ||
| @@ -1,8 +0,0 @@ | |||
| 1 | { | ||
| 2 | "version": 3, | ||
| 3 | "sources": ["../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/_internal/utils.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/perf_hooks/performance.mjs", "../../../../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/polyfill/performance.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/console.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/mock/noop.mjs", "../../../../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/node/console.mjs", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-console", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/hrtime.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/process.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/read-stream.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/write-stream.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/node-version.mjs", "../../../../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/node/process.mjs", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-process", "../../../src/index.ts", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts", "../bundle-Fog3Kp/middleware-insertion-facade.js", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/common.ts", "../bundle-Fog3Kp/middleware-loader.entry.ts"], | ||
| 4 | "sourceRoot": "/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/dev-hQR5NZ", | ||
| 5 | "sourcesContent": ["/* @__NO_SIDE_EFFECTS__ */\nexport function rawHeaders(headers) {\n\tconst rawHeaders = [];\n\tfor (const key in headers) {\n\t\tif (Array.isArray(headers[key])) {\n\t\t\tfor (const h of headers[key]) {\n\t\t\t\trawHeaders.push(key, h);\n\t\t\t}\n\t\t} else {\n\t\t\trawHeaders.push(key, headers[key]);\n\t\t}\n\t}\n\treturn rawHeaders;\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function mergeFns(...functions) {\n\treturn function(...args) {\n\t\tfor (const fn of functions) {\n\t\t\tfn(...args);\n\t\t}\n\t};\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function createNotImplementedError(name) {\n\treturn new Error(`[unenv] ${name} is not implemented yet!`);\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function notImplemented(name) {\n\tconst fn = () => {\n\t\tthrow createNotImplementedError(name);\n\t};\n\treturn Object.assign(fn, { __unenv__: true });\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function notImplementedAsync(name) {\n\tconst fn = notImplemented(name);\n\tfn.__promisify__ = () => notImplemented(name + \".__promisify__\");\n\tfn.native = fn;\n\treturn fn;\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function notImplementedClass(name) {\n\treturn class {\n\t\t__unenv__ = true;\n\t\tconstructor() {\n\t\t\tthrow new Error(`[unenv] ${name} is not implemented yet!`);\n\t\t}\n\t};\n}\n", "import { createNotImplementedError } from \"../../../_internal/utils.mjs\";\nconst _timeOrigin = globalThis.performance?.timeOrigin ?? Date.now();\nconst _performanceNow = globalThis.performance?.now ? globalThis.performance.now.bind(globalThis.performance) : () => Date.now() - _timeOrigin;\nconst nodeTiming = {\n\tname: \"node\",\n\tentryType: \"node\",\n\tstartTime: 0,\n\tduration: 0,\n\tnodeStart: 0,\n\tv8Start: 0,\n\tbootstrapComplete: 0,\n\tenvironment: 0,\n\tloopStart: 0,\n\tloopExit: 0,\n\tidleTime: 0,\n\tuvMetricsInfo: {\n\t\tloopCount: 0,\n\t\tevents: 0,\n\t\teventsWaiting: 0\n\t},\n\tdetail: undefined,\n\ttoJSON() {\n\t\treturn this;\n\t}\n};\n// PerformanceEntry\nexport class PerformanceEntry {\n\t__unenv__ = true;\n\tdetail;\n\tentryType = \"event\";\n\tname;\n\tstartTime;\n\tconstructor(name, options) {\n\t\tthis.name = name;\n\t\tthis.startTime = options?.startTime || _performanceNow();\n\t\tthis.detail = options?.detail;\n\t}\n\tget duration() {\n\t\treturn _performanceNow() - this.startTime;\n\t}\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tentryType: this.entryType,\n\t\t\tstartTime: this.startTime,\n\t\t\tduration: this.duration,\n\t\t\tdetail: this.detail\n\t\t};\n\t}\n}\n// PerformanceMark\nexport const PerformanceMark = class PerformanceMark extends PerformanceEntry {\n\tentryType = \"mark\";\n\tconstructor() {\n\t\t// @ts-ignore\n\t\tsuper(...arguments);\n\t}\n\tget duration() {\n\t\treturn 0;\n\t}\n};\n// PerformanceMark\nexport class PerformanceMeasure extends PerformanceEntry {\n\tentryType = \"measure\";\n}\n// PerformanceResourceTiming\nexport class PerformanceResourceTiming extends PerformanceEntry {\n\tentryType = \"resource\";\n\tserverTiming = [];\n\tconnectEnd = 0;\n\tconnectStart = 0;\n\tdecodedBodySize = 0;\n\tdomainLookupEnd = 0;\n\tdomainLookupStart = 0;\n\tencodedBodySize = 0;\n\tfetchStart = 0;\n\tinitiatorType = \"\";\n\tname = \"\";\n\tnextHopProtocol = \"\";\n\tredirectEnd = 0;\n\tredirectStart = 0;\n\trequestStart = 0;\n\tresponseEnd = 0;\n\tresponseStart = 0;\n\tsecureConnectionStart = 0;\n\tstartTime = 0;\n\ttransferSize = 0;\n\tworkerStart = 0;\n\tresponseStatus = 0;\n}\n// PerformanceObserverEntryList\nexport class PerformanceObserverEntryList {\n\t__unenv__ = true;\n\tgetEntries() {\n\t\treturn [];\n\t}\n\tgetEntriesByName(_name, _type) {\n\t\treturn [];\n\t}\n\tgetEntriesByType(type) {\n\t\treturn [];\n\t}\n}\n// Performance\nexport class Performance {\n\t__unenv__ = true;\n\ttimeOrigin = _timeOrigin;\n\teventCounts = new Map();\n\t_entries = [];\n\t_resourceTimingBufferSize = 0;\n\tnavigation = undefined;\n\ttiming = undefined;\n\ttimerify(_fn, _options) {\n\t\tthrow createNotImplementedError(\"Performance.timerify\");\n\t}\n\tget nodeTiming() {\n\t\treturn nodeTiming;\n\t}\n\teventLoopUtilization() {\n\t\treturn {};\n\t}\n\tmarkResourceTiming() {\n\t\t// TODO: create a new PerformanceResourceTiming entry\n\t\t// so that performance.getEntries, getEntriesByName, and getEntriesByType return it\n\t\t// see: https://nodejs.org/api/perf_hooks.html#performancemarkresourcetimingtiminginfo-requestedurl-initiatortype-global-cachemode-bodyinfo-responsestatus-deliverytype\n\t\treturn new PerformanceResourceTiming(\"\");\n\t}\n\tonresourcetimingbufferfull = null;\n\tnow() {\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Performance/now\n\t\tif (this.timeOrigin === _timeOrigin) {\n\t\t\treturn _performanceNow();\n\t\t}\n\t\treturn Date.now() - this.timeOrigin;\n\t}\n\tclearMarks(markName) {\n\t\tthis._entries = markName ? this._entries.filter((e) => e.name !== markName) : this._entries.filter((e) => e.entryType !== \"mark\");\n\t}\n\tclearMeasures(measureName) {\n\t\tthis._entries = measureName ? this._entries.filter((e) => e.name !== measureName) : this._entries.filter((e) => e.entryType !== \"measure\");\n\t}\n\tclearResourceTimings() {\n\t\tthis._entries = this._entries.filter((e) => e.entryType !== \"resource\" || e.entryType !== \"navigation\");\n\t}\n\tgetEntries() {\n\t\treturn this._entries;\n\t}\n\tgetEntriesByName(name, type) {\n\t\treturn this._entries.filter((e) => e.name === name && (!type || e.entryType === type));\n\t}\n\tgetEntriesByType(type) {\n\t\treturn this._entries.filter((e) => e.entryType === type);\n\t}\n\tmark(name, options) {\n\t\t// @ts-expect-error constructor is not protected\n\t\tconst entry = new PerformanceMark(name, options);\n\t\tthis._entries.push(entry);\n\t\treturn entry;\n\t}\n\tmeasure(measureName, startOrMeasureOptions, endMark) {\n\t\tlet start;\n\t\tlet end;\n\t\tif (typeof startOrMeasureOptions === \"string\") {\n\t\t\tstart = this.getEntriesByName(startOrMeasureOptions, \"mark\")[0]?.startTime;\n\t\t\tend = this.getEntriesByName(endMark, \"mark\")[0]?.startTime;\n\t\t} else {\n\t\t\tstart = Number.parseFloat(startOrMeasureOptions?.start) || this.now();\n\t\t\tend = Number.parseFloat(startOrMeasureOptions?.end) || this.now();\n\t\t}\n\t\tconst entry = new PerformanceMeasure(measureName, {\n\t\t\tstartTime: start,\n\t\t\tdetail: {\n\t\t\t\tstart,\n\t\t\t\tend\n\t\t\t}\n\t\t});\n\t\tthis._entries.push(entry);\n\t\treturn entry;\n\t}\n\tsetResourceTimingBufferSize(maxSize) {\n\t\tthis._resourceTimingBufferSize = maxSize;\n\t}\n\taddEventListener(type, listener, options) {\n\t\tthrow createNotImplementedError(\"Performance.addEventListener\");\n\t}\n\tremoveEventListener(type, listener, options) {\n\t\tthrow createNotImplementedError(\"Performance.removeEventListener\");\n\t}\n\tdispatchEvent(event) {\n\t\tthrow createNotImplementedError(\"Performance.dispatchEvent\");\n\t}\n\ttoJSON() {\n\t\treturn this;\n\t}\n}\n// PerformanceObserver\nexport class PerformanceObserver {\n\t__unenv__ = true;\n\tstatic supportedEntryTypes = [];\n\t_callback = null;\n\tconstructor(callback) {\n\t\tthis._callback = callback;\n\t}\n\ttakeRecords() {\n\t\treturn [];\n\t}\n\tdisconnect() {\n\t\tthrow createNotImplementedError(\"PerformanceObserver.disconnect\");\n\t}\n\tobserve(options) {\n\t\tthrow createNotImplementedError(\"PerformanceObserver.observe\");\n\t}\n\tbind(fn) {\n\t\treturn fn;\n\t}\n\trunInAsyncScope(fn, thisArg, ...args) {\n\t\treturn fn.call(thisArg, ...args);\n\t}\n\tasyncId() {\n\t\treturn 0;\n\t}\n\ttriggerAsyncId() {\n\t\treturn 0;\n\t}\n\temitDestroy() {\n\t\treturn this;\n\t}\n}\n// workerd implements a subset of globalThis.performance (as of last check, only timeOrigin set to 0 + now() implemented)\n// We already use performance.now() from globalThis.performance, if provided (see top of this file)\n// If we detect this condition, we can just use polyfill instead.\nexport const performance = globalThis.performance && \"addEventListener\" in globalThis.performance ? globalThis.performance : new Performance();\n", "import {\n performance,\n Performance,\n PerformanceEntry,\n PerformanceMark,\n PerformanceMeasure,\n PerformanceObserver,\n PerformanceObserverEntryList,\n PerformanceResourceTiming\n} from \"node:perf_hooks\";\nglobalThis.performance = performance;\nglobalThis.Performance = Performance;\nglobalThis.PerformanceEntry = PerformanceEntry;\nglobalThis.PerformanceMark = PerformanceMark;\nglobalThis.PerformanceMeasure = PerformanceMeasure;\nglobalThis.PerformanceObserver = PerformanceObserver;\nglobalThis.PerformanceObserverEntryList = PerformanceObserverEntryList;\nglobalThis.PerformanceResourceTiming = PerformanceResourceTiming;\n", "import { Writable } from \"node:stream\";\nimport noop from \"../mock/noop.mjs\";\nimport { notImplemented, notImplementedClass } from \"../_internal/utils.mjs\";\nconst _console = globalThis.console;\n// undocumented public APIs\nexport const _ignoreErrors = true;\nexport const _stderr = new Writable();\nexport const _stdout = new Writable();\nexport const log = _console?.log ?? noop;\nexport const info = _console?.info ?? log;\nexport const trace = _console?.trace ?? info;\nexport const debug = _console?.debug ?? log;\nexport const table = _console?.table ?? log;\nexport const error = _console?.error ?? log;\nexport const warn = _console?.warn ?? error;\n// https://developer.chrome.com/docs/devtools/console/api#createtask\nexport const createTask = _console?.createTask ?? /* @__PURE__ */ notImplemented(\"console.createTask\");\nexport const assert = /* @__PURE__ */ notImplemented(\"console.assert\");\n// noop\nexport const clear = _console?.clear ?? noop;\nexport const count = _console?.count ?? noop;\nexport const countReset = _console?.countReset ?? noop;\nexport const dir = _console?.dir ?? noop;\nexport const dirxml = _console?.dirxml ?? noop;\nexport const group = _console?.group ?? noop;\nexport const groupEnd = _console?.groupEnd ?? noop;\nexport const groupCollapsed = _console?.groupCollapsed ?? noop;\nexport const profile = _console?.profile ?? noop;\nexport const profileEnd = _console?.profileEnd ?? noop;\nexport const time = _console?.time ?? noop;\nexport const timeEnd = _console?.timeEnd ?? noop;\nexport const timeLog = _console?.timeLog ?? noop;\nexport const timeStamp = _console?.timeStamp ?? noop;\nexport const Console = _console?.Console ?? /* @__PURE__ */ notImplementedClass(\"console.Console\");\nexport const _times = /* @__PURE__ */ new Map();\nexport function context() {\n\t// TODO: Should be Console with all the methods\n\treturn _console;\n}\nexport const _stdoutErrorHandler = noop;\nexport const _stderrErrorHandler = noop;\nexport default {\n\t_times,\n\t_ignoreErrors,\n\t_stdoutErrorHandler,\n\t_stderrErrorHandler,\n\t_stdout,\n\t_stderr,\n\tassert,\n\tclear,\n\tConsole,\n\tcount,\n\tcountReset,\n\tdebug,\n\tdir,\n\tdirxml,\n\terror,\n\tcontext,\n\tcreateTask,\n\tgroup,\n\tgroupEnd,\n\tgroupCollapsed,\n\tinfo,\n\tlog,\n\tprofile,\n\tprofileEnd,\n\ttable,\n\ttime,\n\ttimeEnd,\n\ttimeLog,\n\ttimeStamp,\n\ttrace,\n\twarn\n};\n", "export default Object.assign(() => {}, { __unenv__: true });\n", "import {\n _ignoreErrors,\n _stderr,\n _stderrErrorHandler,\n _stdout,\n _stdoutErrorHandler,\n _times,\n Console\n} from \"unenv/node/console\";\nexport {\n Console,\n _ignoreErrors,\n _stderr,\n _stderrErrorHandler,\n _stdout,\n _stdoutErrorHandler,\n _times\n} from \"unenv/node/console\";\nconst workerdConsole = globalThis[\"console\"];\nexport const {\n assert,\n clear,\n // @ts-expect-error undocumented public API\n context,\n count,\n countReset,\n // @ts-expect-error undocumented public API\n createTask,\n debug,\n dir,\n dirxml,\n error,\n group,\n groupCollapsed,\n groupEnd,\n info,\n log,\n profile,\n profileEnd,\n table,\n time,\n timeEnd,\n timeLog,\n timeStamp,\n trace,\n warn\n} = workerdConsole;\nObject.assign(workerdConsole, {\n Console,\n _ignoreErrors,\n _stderr,\n _stderrErrorHandler,\n _stdout,\n _stdoutErrorHandler,\n _times\n});\nexport default workerdConsole;\n", "import { default as defaultExport } from \"@cloudflare/unenv-preset/node/console\";\nglobalThis.console = defaultExport;", "// https://nodejs.org/api/process.html#processhrtime\nexport const hrtime = /* @__PURE__ */ Object.assign(function hrtime(startTime) {\n\tconst now = Date.now();\n\t// millis to seconds\n\tconst seconds = Math.trunc(now / 1e3);\n\t// convert millis to nanos\n\tconst nanos = now % 1e3 * 1e6;\n\tif (startTime) {\n\t\tlet diffSeconds = seconds - startTime[0];\n\t\tlet diffNanos = nanos - startTime[0];\n\t\tif (diffNanos < 0) {\n\t\t\tdiffSeconds = diffSeconds - 1;\n\t\t\tdiffNanos = 1e9 + diffNanos;\n\t\t}\n\t\treturn [diffSeconds, diffNanos];\n\t}\n\treturn [seconds, nanos];\n}, { bigint: function bigint() {\n\t// Convert milliseconds to nanoseconds\n\treturn BigInt(Date.now() * 1e6);\n} });\n", "import { EventEmitter } from \"node:events\";\nimport { ReadStream, WriteStream } from \"node:tty\";\nimport { notImplemented, createNotImplementedError } from \"../../../_internal/utils.mjs\";\n// node-version.ts is generated at build time\nimport { NODE_VERSION } from \"./node-version.mjs\";\nexport class Process extends EventEmitter {\n\tenv;\n\thrtime;\n\tnextTick;\n\tconstructor(impl) {\n\t\tsuper();\n\t\tthis.env = impl.env;\n\t\tthis.hrtime = impl.hrtime;\n\t\tthis.nextTick = impl.nextTick;\n\t\tfor (const prop of [...Object.getOwnPropertyNames(Process.prototype), ...Object.getOwnPropertyNames(EventEmitter.prototype)]) {\n\t\t\tconst value = this[prop];\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tthis[prop] = value.bind(this);\n\t\t\t}\n\t\t}\n\t}\n\t// --- event emitter ---\n\temitWarning(warning, type, code) {\n\t\tconsole.warn(`${code ? `[${code}] ` : \"\"}${type ? `${type}: ` : \"\"}${warning}`);\n\t}\n\temit(...args) {\n\t\t// @ts-ignore\n\t\treturn super.emit(...args);\n\t}\n\tlisteners(eventName) {\n\t\treturn super.listeners(eventName);\n\t}\n\t// --- stdio (lazy initializers) ---\n\t#stdin;\n\t#stdout;\n\t#stderr;\n\tget stdin() {\n\t\treturn this.#stdin ??= new ReadStream(0);\n\t}\n\tget stdout() {\n\t\treturn this.#stdout ??= new WriteStream(1);\n\t}\n\tget stderr() {\n\t\treturn this.#stderr ??= new WriteStream(2);\n\t}\n\t// --- cwd ---\n\t#cwd = \"/\";\n\tchdir(cwd) {\n\t\tthis.#cwd = cwd;\n\t}\n\tcwd() {\n\t\treturn this.#cwd;\n\t}\n\t// --- dummy props and getters ---\n\tarch = \"\";\n\tplatform = \"\";\n\targv = [];\n\targv0 = \"\";\n\texecArgv = [];\n\texecPath = \"\";\n\ttitle = \"\";\n\tpid = 200;\n\tppid = 100;\n\tget version() {\n\t\treturn `v${NODE_VERSION}`;\n\t}\n\tget versions() {\n\t\treturn { node: NODE_VERSION };\n\t}\n\tget allowedNodeEnvironmentFlags() {\n\t\treturn new Set();\n\t}\n\tget sourceMapsEnabled() {\n\t\treturn false;\n\t}\n\tget debugPort() {\n\t\treturn 0;\n\t}\n\tget throwDeprecation() {\n\t\treturn false;\n\t}\n\tget traceDeprecation() {\n\t\treturn false;\n\t}\n\tget features() {\n\t\treturn {};\n\t}\n\tget release() {\n\t\treturn {};\n\t}\n\tget connected() {\n\t\treturn false;\n\t}\n\tget config() {\n\t\treturn {};\n\t}\n\tget moduleLoadList() {\n\t\treturn [];\n\t}\n\tconstrainedMemory() {\n\t\treturn 0;\n\t}\n\tavailableMemory() {\n\t\treturn 0;\n\t}\n\tuptime() {\n\t\treturn 0;\n\t}\n\tresourceUsage() {\n\t\treturn {};\n\t}\n\t// --- noop methods ---\n\tref() {\n\t\t// noop\n\t}\n\tunref() {\n\t\t// noop\n\t}\n\t// --- unimplemented methods ---\n\tumask() {\n\t\tthrow createNotImplementedError(\"process.umask\");\n\t}\n\tgetBuiltinModule() {\n\t\treturn undefined;\n\t}\n\tgetActiveResourcesInfo() {\n\t\tthrow createNotImplementedError(\"process.getActiveResourcesInfo\");\n\t}\n\texit() {\n\t\tthrow createNotImplementedError(\"process.exit\");\n\t}\n\treallyExit() {\n\t\tthrow createNotImplementedError(\"process.reallyExit\");\n\t}\n\tkill() {\n\t\tthrow createNotImplementedError(\"process.kill\");\n\t}\n\tabort() {\n\t\tthrow createNotImplementedError(\"process.abort\");\n\t}\n\tdlopen() {\n\t\tthrow createNotImplementedError(\"process.dlopen\");\n\t}\n\tsetSourceMapsEnabled() {\n\t\tthrow createNotImplementedError(\"process.setSourceMapsEnabled\");\n\t}\n\tloadEnvFile() {\n\t\tthrow createNotImplementedError(\"process.loadEnvFile\");\n\t}\n\tdisconnect() {\n\t\tthrow createNotImplementedError(\"process.disconnect\");\n\t}\n\tcpuUsage() {\n\t\tthrow createNotImplementedError(\"process.cpuUsage\");\n\t}\n\tsetUncaughtExceptionCaptureCallback() {\n\t\tthrow createNotImplementedError(\"process.setUncaughtExceptionCaptureCallback\");\n\t}\n\thasUncaughtExceptionCaptureCallback() {\n\t\tthrow createNotImplementedError(\"process.hasUncaughtExceptionCaptureCallback\");\n\t}\n\tinitgroups() {\n\t\tthrow createNotImplementedError(\"process.initgroups\");\n\t}\n\topenStdin() {\n\t\tthrow createNotImplementedError(\"process.openStdin\");\n\t}\n\tassert() {\n\t\tthrow createNotImplementedError(\"process.assert\");\n\t}\n\tbinding() {\n\t\tthrow createNotImplementedError(\"process.binding\");\n\t}\n\t// --- attached interfaces ---\n\tpermission = { has: /* @__PURE__ */ notImplemented(\"process.permission.has\") };\n\treport = {\n\t\tdirectory: \"\",\n\t\tfilename: \"\",\n\t\tsignal: \"SIGUSR2\",\n\t\tcompact: false,\n\t\treportOnFatalError: false,\n\t\treportOnSignal: false,\n\t\treportOnUncaughtException: false,\n\t\tgetReport: /* @__PURE__ */ notImplemented(\"process.report.getReport\"),\n\t\twriteReport: /* @__PURE__ */ notImplemented(\"process.report.writeReport\")\n\t};\n\tfinalization = {\n\t\tregister: /* @__PURE__ */ notImplemented(\"process.finalization.register\"),\n\t\tunregister: /* @__PURE__ */ notImplemented(\"process.finalization.unregister\"),\n\t\tregisterBeforeExit: /* @__PURE__ */ notImplemented(\"process.finalization.registerBeforeExit\")\n\t};\n\tmemoryUsage = Object.assign(() => ({\n\t\tarrayBuffers: 0,\n\t\trss: 0,\n\t\texternal: 0,\n\t\theapTotal: 0,\n\t\theapUsed: 0\n\t}), { rss: () => 0 });\n\t// --- undefined props ---\n\tmainModule = undefined;\n\tdomain = undefined;\n\t// optional\n\tsend = undefined;\n\texitCode = undefined;\n\tchannel = undefined;\n\tgetegid = undefined;\n\tgeteuid = undefined;\n\tgetgid = undefined;\n\tgetgroups = undefined;\n\tgetuid = undefined;\n\tsetegid = undefined;\n\tseteuid = undefined;\n\tsetgid = undefined;\n\tsetgroups = undefined;\n\tsetuid = undefined;\n\t// internals\n\t_events = undefined;\n\t_eventsCount = undefined;\n\t_exiting = undefined;\n\t_maxListeners = undefined;\n\t_debugEnd = undefined;\n\t_debugProcess = undefined;\n\t_fatalException = undefined;\n\t_getActiveHandles = undefined;\n\t_getActiveRequests = undefined;\n\t_kill = undefined;\n\t_preload_modules = undefined;\n\t_rawDebug = undefined;\n\t_startProfilerIdleNotifier = undefined;\n\t_stopProfilerIdleNotifier = undefined;\n\t_tickCallback = undefined;\n\t_disconnect = undefined;\n\t_handleQueue = undefined;\n\t_pendingMessage = undefined;\n\t_channel = undefined;\n\t_send = undefined;\n\t_linkedBinding = undefined;\n}\n", "export class ReadStream {\n\tfd;\n\tisRaw = false;\n\tisTTY = false;\n\tconstructor(fd) {\n\t\tthis.fd = fd;\n\t}\n\tsetRawMode(mode) {\n\t\tthis.isRaw = mode;\n\t\treturn this;\n\t}\n}\n", "export class WriteStream {\n\tfd;\n\tcolumns = 80;\n\trows = 24;\n\tisTTY = false;\n\tconstructor(fd) {\n\t\tthis.fd = fd;\n\t}\n\tclearLine(dir, callback) {\n\t\tcallback && callback();\n\t\treturn false;\n\t}\n\tclearScreenDown(callback) {\n\t\tcallback && callback();\n\t\treturn false;\n\t}\n\tcursorTo(x, y, callback) {\n\t\tcallback && typeof callback === \"function\" && callback();\n\t\treturn false;\n\t}\n\tmoveCursor(dx, dy, callback) {\n\t\tcallback && callback();\n\t\treturn false;\n\t}\n\tgetColorDepth(env) {\n\t\treturn 1;\n\t}\n\thasColors(count, env) {\n\t\treturn false;\n\t}\n\tgetWindowSize() {\n\t\treturn [this.columns, this.rows];\n\t}\n\twrite(str, encoding, cb) {\n\t\tif (str instanceof Uint8Array) {\n\t\t\tstr = new TextDecoder().decode(str);\n\t\t}\n\t\ttry {\n\t\t\tconsole.log(str);\n\t\t} catch {}\n\t\tcb && typeof cb === \"function\" && cb();\n\t\treturn false;\n\t}\n}\n", "// Extracted from .nvmrc\nexport const NODE_VERSION = \"22.14.0\";\n", "import { hrtime as UnenvHrTime } from \"unenv/node/internal/process/hrtime\";\nimport { Process as UnenvProcess } from \"unenv/node/internal/process/process\";\nconst globalProcess = globalThis[\"process\"];\nexport const getBuiltinModule = globalProcess.getBuiltinModule;\nconst workerdProcess = getBuiltinModule(\"node:process\");\nconst unenvProcess = new UnenvProcess({\n env: globalProcess.env,\n hrtime: UnenvHrTime,\n // `nextTick` is available from workerd process v1\n nextTick: workerdProcess.nextTick\n});\nexport const { exit, features, platform } = workerdProcess;\nexport const {\n _channel,\n _debugEnd,\n _debugProcess,\n _disconnect,\n _events,\n _eventsCount,\n _exiting,\n _fatalException,\n _getActiveHandles,\n _getActiveRequests,\n _handleQueue,\n _kill,\n _linkedBinding,\n _maxListeners,\n _pendingMessage,\n _preload_modules,\n _rawDebug,\n _send,\n _startProfilerIdleNotifier,\n _stopProfilerIdleNotifier,\n _tickCallback,\n abort,\n addListener,\n allowedNodeEnvironmentFlags,\n arch,\n argv,\n argv0,\n assert,\n availableMemory,\n binding,\n channel,\n chdir,\n config,\n connected,\n constrainedMemory,\n cpuUsage,\n cwd,\n debugPort,\n disconnect,\n dlopen,\n domain,\n emit,\n emitWarning,\n env,\n eventNames,\n execArgv,\n execPath,\n exitCode,\n finalization,\n getActiveResourcesInfo,\n getegid,\n geteuid,\n getgid,\n getgroups,\n getMaxListeners,\n getuid,\n hasUncaughtExceptionCaptureCallback,\n hrtime,\n initgroups,\n kill,\n listenerCount,\n listeners,\n loadEnvFile,\n mainModule,\n memoryUsage,\n moduleLoadList,\n nextTick,\n off,\n on,\n once,\n openStdin,\n permission,\n pid,\n ppid,\n prependListener,\n prependOnceListener,\n rawListeners,\n reallyExit,\n ref,\n release,\n removeAllListeners,\n removeListener,\n report,\n resourceUsage,\n send,\n setegid,\n seteuid,\n setgid,\n setgroups,\n setMaxListeners,\n setSourceMapsEnabled,\n setuid,\n setUncaughtExceptionCaptureCallback,\n sourceMapsEnabled,\n stderr,\n stdin,\n stdout,\n throwDeprecation,\n title,\n traceDeprecation,\n umask,\n unref,\n uptime,\n version,\n versions\n} = unenvProcess;\nconst _process = {\n abort,\n addListener,\n allowedNodeEnvironmentFlags,\n hasUncaughtExceptionCaptureCallback,\n setUncaughtExceptionCaptureCallback,\n loadEnvFile,\n sourceMapsEnabled,\n arch,\n argv,\n argv0,\n chdir,\n config,\n connected,\n constrainedMemory,\n availableMemory,\n cpuUsage,\n cwd,\n debugPort,\n dlopen,\n disconnect,\n emit,\n emitWarning,\n env,\n eventNames,\n execArgv,\n execPath,\n exit,\n finalization,\n features,\n getBuiltinModule,\n getActiveResourcesInfo,\n getMaxListeners,\n hrtime,\n kill,\n listeners,\n listenerCount,\n memoryUsage,\n nextTick,\n on,\n off,\n once,\n pid,\n platform,\n ppid,\n prependListener,\n prependOnceListener,\n rawListeners,\n release,\n removeAllListeners,\n removeListener,\n report,\n resourceUsage,\n setMaxListeners,\n setSourceMapsEnabled,\n stderr,\n stdin,\n stdout,\n title,\n throwDeprecation,\n traceDeprecation,\n umask,\n uptime,\n version,\n versions,\n // @ts-expect-error old API\n domain,\n initgroups,\n moduleLoadList,\n reallyExit,\n openStdin,\n assert,\n binding,\n send,\n exitCode,\n channel,\n getegid,\n geteuid,\n getgid,\n getgroups,\n getuid,\n setegid,\n seteuid,\n setgid,\n setgroups,\n setuid,\n permission,\n mainModule,\n _events,\n _eventsCount,\n _exiting,\n _maxListeners,\n _debugEnd,\n _debugProcess,\n _fatalException,\n _getActiveHandles,\n _getActiveRequests,\n _kill,\n _preload_modules,\n _rawDebug,\n _startProfilerIdleNotifier,\n _stopProfilerIdleNotifier,\n _tickCallback,\n _disconnect,\n _handleQueue,\n _pendingMessage,\n _channel,\n _send,\n _linkedBinding\n};\nexport default _process;\n", "import { default as defaultExport } from \"@cloudflare/unenv-preset/node/process\";\nglobalThis.process = defaultExport;", "import { RpcTarget } from \"cloudflare:workers\";\n\nimport HARNESS_CODE from \"./isolate/harness.isolate.js\";\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst MAX_TIMEOUT_MS = 120_000;\n\ntype RuntimeToolCallResult =\n | {\n ok: true;\n value: unknown;\n }\n | {\n ok: false;\n kind: \"pending\";\n approvalId: string;\n retryAfterMs: number;\n error?: string;\n }\n | {\n ok: false;\n kind: \"denied\";\n error: string;\n }\n | {\n ok: false;\n kind: \"failed\";\n error: string;\n };\n\ntype RunRequest = {\n runId: string;\n taskId: string;\n code: string;\n timeoutMs?: number;\n callback: {\n url: string;\n internalSecret?: string;\n };\n};\n\ntype RunResult = {\n status: \"completed\" | \"failed\" | \"timed_out\" | \"denied\";\n result?: unknown;\n error?: string;\n exitCode?: number;\n};\n\ntype BridgeProps = {\n callbackUrl: string;\n callbackInternalSecret: string | null;\n runId: string;\n};\n\ntype SandboxEntrypoint = {\n evaluate: (bridge: ToolBridge) => Promise<RunResult>;\n};\n\ntype Env = {\n AUTH_TOKEN: string;\n LOADER: {\n get: (\n id: string,\n init: () => Promise<{\n compatibilityDate: string;\n mainModule: string;\n modules: Record<string, string>;\n env: Record<string, unknown>;\n globalOutbound: null;\n }>,\n ) => {\n getEntrypoint: () => SandboxEntrypoint;\n };\n };\n};\n\nconst json = (value: unknown, status = 200): Response =>\n new Response(JSON.stringify(value), {\n status,\n headers: {\n \"content-type\": \"application/json\",\n },\n });\n\nconst isObjectRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isRuntimeToolCallResult = (value: unknown): value is RuntimeToolCallResult => {\n if (!isObjectRecord(value)) {\n return false;\n }\n\n if (value.ok === true) {\n return Object.prototype.hasOwnProperty.call(value, \"value\");\n }\n\n if (value.ok === false && value.kind === \"pending\") {\n return (\n typeof value.approvalId === \"string\" &&\n typeof value.retryAfterMs === \"number\"\n );\n }\n\n if (value.ok === false && value.kind === \"denied\") {\n return typeof value.error === \"string\";\n }\n\n if (value.ok === false && value.kind === \"failed\") {\n return typeof value.error === \"string\";\n }\n\n return false;\n};\n\nconst isRunResult = (value: unknown): value is RunResult => {\n if (!isObjectRecord(value)) {\n return false;\n }\n\n if (\n value.status !== \"completed\" &&\n value.status !== \"failed\" &&\n value.status !== \"timed_out\" &&\n value.status !== \"denied\"\n ) {\n return false;\n }\n\n if (value.error !== undefined && typeof value.error !== \"string\") {\n return false;\n }\n\n if (value.exitCode !== undefined && typeof value.exitCode !== \"number\") {\n return false;\n }\n\n return true;\n};\n\nconst toFailedResult = (error: string): RunResult => ({\n status: \"failed\",\n error,\n});\n\nconst validateRunRequest = (value: unknown): RunRequest | null => {\n if (!isObjectRecord(value)) {\n return null;\n }\n\n if (\n typeof value.runId !== \"string\" ||\n typeof value.taskId !== \"string\" ||\n typeof value.code !== \"string\"\n ) {\n return null;\n }\n\n if (!isObjectRecord(value.callback) || typeof value.callback.url !== \"string\") {\n return null;\n }\n\n if (\n value.callback.internalSecret !== undefined &&\n typeof value.callback.internalSecret !== \"string\"\n ) {\n return null;\n }\n\n if (value.timeoutMs !== undefined && typeof value.timeoutMs !== \"number\") {\n return null;\n }\n\n return {\n runId: value.runId,\n taskId: value.taskId,\n code: value.code,\n timeoutMs: value.timeoutMs,\n callback: {\n url: value.callback.url,\n internalSecret: value.callback.internalSecret,\n },\n };\n};\n\nconst buildUserModule = (userCode: string): string =>\n `export async function run(tools, console) {\\n\"use strict\";\\n${userCode}\\n}\\n`;\n\nclass ToolBridge extends RpcTarget {\n readonly #props: BridgeProps;\n\n constructor(props: BridgeProps) {\n super();\n this.#props = props;\n }\n\n async callTool(\n toolPath: string,\n input: unknown,\n callId: string,\n ): Promise<RuntimeToolCallResult> {\n const headers = new Headers({\n \"content-type\": \"application/json\",\n });\n\n if (this.#props.callbackInternalSecret) {\n headers.set(\"x-internal-secret\", this.#props.callbackInternalSecret);\n }\n\n const response = await fetch(this.#props.callbackUrl, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n runId: this.#props.runId,\n callId,\n toolPath,\n input,\n }),\n }).catch((error: unknown) => {\n throw new Error(\n `Tool callback transport failed: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n });\n\n if (response.status !== 200) {\n return {\n ok: false,\n kind: \"failed\",\n error: `Tool callback returned ${response.status}`,\n };\n }\n\n const payload = await response.json().catch(() => null);\n if (!isRuntimeToolCallResult(payload)) {\n return {\n ok: false,\n kind: \"failed\",\n error: \"Tool callback returned invalid result payload\",\n };\n }\n\n return payload;\n }\n}\n\nconst executeSandboxRun = async (\n request: RunRequest,\n env: Env,\n): Promise<RunResult> => {\n const timeoutMsRaw = request.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const timeoutMs = Math.max(1, Math.min(MAX_TIMEOUT_MS, Math.floor(timeoutMsRaw)));\n\n const toolBridge = new ToolBridge({\n callbackUrl: request.callback.url,\n callbackInternalSecret: request.callback.internalSecret ?? null,\n runId: request.runId,\n });\n\n const worker = env.LOADER.get(request.taskId, async () => ({\n compatibilityDate: \"2025-06-01\",\n mainModule: \"harness.js\",\n modules: {\n \"harness.js\": HARNESS_CODE,\n \"user-code.js\": buildUserModule(request.code),\n },\n env: {},\n globalOutbound: null,\n }));\n\n const entrypoint = worker.getEntrypoint();\n let timer: ReturnType<typeof setTimeout> | null = null;\n\n let payload: RunResult;\n try {\n const timeoutResult = new Promise<RunResult>((resolve) => {\n timer = setTimeout(() => {\n resolve({\n status: \"timed_out\",\n error: `Execution timed out after ${timeoutMs}ms`,\n });\n }, timeoutMs);\n });\n\n payload = await Promise.race([\n entrypoint.evaluate(toolBridge),\n timeoutResult,\n ]);\n } catch (error) {\n if (timer) {\n clearTimeout(timer);\n }\n return toFailedResult(\n `Sandbox isolate execution failed: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n if (timer) {\n clearTimeout(timer);\n }\n\n if (!isRunResult(payload)) {\n return toFailedResult(\"Sandbox isolate returned invalid response payload\");\n }\n\n return payload;\n};\n\nexport { ToolBridge };\n\nexport default {\n async fetch(request: Request, env: Env, _ctx: ExecutionContext): Promise<Response> {\n const url = new URL(request.url);\n\n if (url.pathname === \"/health\") {\n return new Response(\"ok\", { status: 200 });\n }\n\n if (url.pathname !== \"/v1/runs\" || request.method !== \"POST\") {\n return json({ error: \"not_found\" }, 404);\n }\n\n if (typeof env.AUTH_TOKEN !== \"string\" || env.AUTH_TOKEN.length === 0) {\n return json({ error: \"misconfigured_auth_token\" }, 500);\n }\n\n if (request.headers.get(\"authorization\") !== `Bearer ${env.AUTH_TOKEN}`) {\n return json({ error: \"unauthorized\" }, 401);\n }\n\n const payloadRaw = await request.json().catch(() => null);\n const payload = validateRunRequest(payloadRaw);\n if (!payload) {\n return json({ error: \"invalid_payload\" }, 400);\n }\n\n const runResult = await executeSandboxRun(payload, env);\n return json(runResult, 200);\n },\n};\n", "import type { Middleware } from \"./common\";\n\nconst drainBody: Middleware = async (request, env, _ctx, middlewareCtx) => {\n\ttry {\n\t\treturn await middlewareCtx.next(request, env);\n\t} finally {\n\t\ttry {\n\t\t\tif (request.body !== null && !request.bodyUsed) {\n\t\t\t\tconst reader = request.body.getReader();\n\t\t\t\twhile (!(await reader.read()).done) {}\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error(\"Failed to drain the unused request body.\", e);\n\t\t}\n\t}\n};\n\nexport default drainBody;\n", "import type { Middleware } from \"./common\";\n\ninterface JsonError {\n\tmessage?: string;\n\tname?: string;\n\tstack?: string;\n\tcause?: JsonError;\n}\n\nfunction reduceError(e: any): JsonError {\n\treturn {\n\t\tname: e?.name,\n\t\tmessage: e?.message ?? String(e),\n\t\tstack: e?.stack,\n\t\tcause: e?.cause === undefined ? undefined : reduceError(e.cause),\n\t};\n}\n\n// See comment in `bundle.ts` for details on why this is needed\nconst jsonError: Middleware = async (request, env, _ctx, middlewareCtx) => {\n\ttry {\n\t\treturn await middlewareCtx.next(request, env);\n\t} catch (e: any) {\n\t\tconst error = reduceError(e);\n\t\treturn Response.json(error, {\n\t\t\tstatus: 500,\n\t\t\theaders: { \"MF-Experimental-Error-Stack\": \"true\" },\n\t\t});\n\t}\n};\n\nexport default jsonError;\n", "\t\t\t\timport worker, * as OTHER_EXPORTS from \"/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/src/index.ts\";\n\t\t\t\timport * as __MIDDLEWARE_0__ from \"/home/rhys/assistant/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts\";\nimport * as __MIDDLEWARE_1__ from \"/home/rhys/assistant/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts\";\n\n\t\t\t\texport * from \"/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/src/index.ts\";\n\t\t\t\tconst MIDDLEWARE_TEST_INJECT = \"__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__\";\n\t\t\t\texport const __INTERNAL_WRANGLER_MIDDLEWARE__ = [\n\t\t\t\t\t\n\t\t\t\t\t__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default\n\t\t\t\t]\n\t\t\t\texport default worker;", "export type Awaitable<T> = T | Promise<T>;\n// TODO: allow dispatching more events?\nexport type Dispatcher = (\n\ttype: \"scheduled\",\n\tinit: { cron?: string }\n) => Awaitable<void>;\n\nexport type IncomingRequest = Request<\n\tunknown,\n\tIncomingRequestCfProperties<unknown>\n>;\n\nexport interface MiddlewareContext {\n\tdispatch: Dispatcher;\n\tnext(request: IncomingRequest, env: any): Awaitable<Response>;\n}\n\nexport type Middleware = (\n\trequest: IncomingRequest,\n\tenv: any,\n\tctx: ExecutionContext,\n\tmiddlewareCtx: MiddlewareContext\n) => Awaitable<Response>;\n\nconst __facade_middleware__: Middleware[] = [];\n\n// The register functions allow for the insertion of one or many middleware,\n// We register internal middleware first in the stack, but have no way of controlling\n// the order that addMiddleware is run in service workers so need an internal function.\nexport function __facade_register__(...args: (Middleware | Middleware[])[]) {\n\t__facade_middleware__.push(...args.flat());\n}\nexport function __facade_registerInternal__(\n\t...args: (Middleware | Middleware[])[]\n) {\n\t__facade_middleware__.unshift(...args.flat());\n}\n\nfunction __facade_invokeChain__(\n\trequest: IncomingRequest,\n\tenv: any,\n\tctx: ExecutionContext,\n\tdispatch: Dispatcher,\n\tmiddlewareChain: Middleware[]\n): Awaitable<Response> {\n\tconst [head, ...tail] = middlewareChain;\n\tconst middlewareCtx: MiddlewareContext = {\n\t\tdispatch,\n\t\tnext(newRequest, newEnv) {\n\t\t\treturn __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail);\n\t\t},\n\t};\n\treturn head(request, env, ctx, middlewareCtx);\n}\n\nexport function __facade_invoke__(\n\trequest: IncomingRequest,\n\tenv: any,\n\tctx: ExecutionContext,\n\tdispatch: Dispatcher,\n\tfinalMiddleware: Middleware\n): Awaitable<Response> {\n\treturn __facade_invokeChain__(request, env, ctx, dispatch, [\n\t\t...__facade_middleware__,\n\t\tfinalMiddleware,\n\t]);\n}\n", "// This loads all middlewares exposed on the middleware object and then starts\n// the invocation chain. The big idea is that we can add these to the middleware\n// export dynamically through wrangler, or we can potentially let users directly\n// add them as a sort of \"plugin\" system.\n\nimport ENTRY, { __INTERNAL_WRANGLER_MIDDLEWARE__ } from \"/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-Fog3Kp/middleware-insertion-facade.js\";\nimport { __facade_invoke__, __facade_register__, Dispatcher } from \"/home/rhys/assistant/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/common.ts\";\nimport type { WorkerEntrypointConstructor } from \"/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-Fog3Kp/middleware-insertion-facade.js\";\n\n// Preserve all the exports from the worker\nexport * from \"/home/rhys/assistant/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-Fog3Kp/middleware-insertion-facade.js\";\n\nclass __Facade_ScheduledController__ implements ScheduledController {\n\treadonly #noRetry: ScheduledController[\"noRetry\"];\n\n\tconstructor(\n\t\treadonly scheduledTime: number,\n\t\treadonly cron: string,\n\t\tnoRetry: ScheduledController[\"noRetry\"]\n\t) {\n\t\tthis.#noRetry = noRetry;\n\t}\n\n\tnoRetry() {\n\t\tif (!(this instanceof __Facade_ScheduledController__)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\t// Need to call native method immediately in case uncaught error thrown\n\t\tthis.#noRetry();\n\t}\n}\n\nfunction wrapExportedHandler(worker: ExportedHandler): ExportedHandler {\n\t// If we don't have any middleware defined, just return the handler as is\n\tif (\n\t\t__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||\n\t\t__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0\n\t) {\n\t\treturn worker;\n\t}\n\t// Otherwise, register all middleware once\n\tfor (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {\n\t\t__facade_register__(middleware);\n\t}\n\n\tconst fetchDispatcher: ExportedHandlerFetchHandler = function (\n\t\trequest,\n\t\tenv,\n\t\tctx\n\t) {\n\t\tif (worker.fetch === undefined) {\n\t\t\tthrow new Error(\"Handler does not export a fetch() function.\");\n\t\t}\n\t\treturn worker.fetch(request, env, ctx);\n\t};\n\n\treturn {\n\t\t...worker,\n\t\tfetch(request, env, ctx) {\n\t\t\tconst dispatcher: Dispatcher = function (type, init) {\n\t\t\t\tif (type === \"scheduled\" && worker.scheduled !== undefined) {\n\t\t\t\t\tconst controller = new __Facade_ScheduledController__(\n\t\t\t\t\t\tDate.now(),\n\t\t\t\t\t\tinit.cron ?? \"\",\n\t\t\t\t\t\t() => {}\n\t\t\t\t\t);\n\t\t\t\t\treturn worker.scheduled(controller, env, ctx);\n\t\t\t\t}\n\t\t\t};\n\t\t\treturn __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);\n\t\t},\n\t};\n}\n\nfunction wrapWorkerEntrypoint(\n\tklass: WorkerEntrypointConstructor\n): WorkerEntrypointConstructor {\n\t// If we don't have any middleware defined, just return the handler as is\n\tif (\n\t\t__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||\n\t\t__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0\n\t) {\n\t\treturn klass;\n\t}\n\t// Otherwise, register all middleware once\n\tfor (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {\n\t\t__facade_register__(middleware);\n\t}\n\n\t// `extend`ing `klass` here so other RPC methods remain callable\n\treturn class extends klass {\n\t\t#fetchDispatcher: ExportedHandlerFetchHandler<Record<string, unknown>> = (\n\t\t\trequest,\n\t\t\tenv,\n\t\t\tctx\n\t\t) => {\n\t\t\tthis.env = env;\n\t\t\tthis.ctx = ctx;\n\t\t\tif (super.fetch === undefined) {\n\t\t\t\tthrow new Error(\"Entrypoint class does not define a fetch() function.\");\n\t\t\t}\n\t\t\treturn super.fetch(request);\n\t\t};\n\n\t\t#dispatcher: Dispatcher = (type, init) => {\n\t\t\tif (type === \"scheduled\" && super.scheduled !== undefined) {\n\t\t\t\tconst controller = new __Facade_ScheduledController__(\n\t\t\t\t\tDate.now(),\n\t\t\t\t\tinit.cron ?? \"\",\n\t\t\t\t\t() => {}\n\t\t\t\t);\n\t\t\t\treturn super.scheduled(controller);\n\t\t\t}\n\t\t};\n\n\t\tfetch(request: Request<unknown, IncomingRequestCfProperties>) {\n\t\t\treturn __facade_invoke__(\n\t\t\t\trequest,\n\t\t\t\tthis.env,\n\t\t\t\tthis.ctx,\n\t\t\t\tthis.#dispatcher,\n\t\t\t\tthis.#fetchDispatcher\n\t\t\t);\n\t\t}\n\t};\n}\n\nlet WRAPPED_ENTRY: ExportedHandler | WorkerEntrypointConstructor | undefined;\nif (typeof ENTRY === \"object\") {\n\tWRAPPED_ENTRY = wrapExportedHandler(ENTRY);\n} else if (typeof ENTRY === \"function\") {\n\tWRAPPED_ENTRY = wrapWorkerEntrypoint(ENTRY);\n}\nexport default WRAPPED_ENTRY;\n"], | ||
| 6 | "mappings": ";;;;;AAuBO,SAAS,0BAA0B,MAAM;AAC/C,SAAO,IAAI,MAAM,WAAW,IAAI,0BAA0B;AAC3D;AAFgB;AAAA;AAIT,SAAS,eAAe,MAAM;AACpC,QAAM,KAAK,6BAAM;AAChB,UAAM,0CAA0B,IAAI;AAAA,EACrC,GAFW;AAGX,SAAO,OAAO,OAAO,IAAI,EAAE,WAAW,KAAK,CAAC;AAC7C;AALgB;;AAcT,SAAS,oBAAoB,MAA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EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAI;AACJ,IAAM,WAAW;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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AK;AAC3C;AACA,IAAO,kCAAQ;", | ||
| 7 | "names": ["PerformanceMark", "clear", "count", "countReset", "createTask", "debug", "dir", "dirxml", "error", "group", "groupCollapsed", "groupEnd", "info", "log", "profile", "profileEnd", "table", "time", "timeEnd", "timeLog", "timeStamp", "trace", "warn", "hrtime", "dir", "env", "count", "cwd", "assert", "hrtime", "error", "env", "env", "env", "env", "error", "env", "env"] | ||
| 8 | } | ||
| @@ -1,199 +0,0 @@ | |||
| 1 | import { WorkerEntrypoint } from "cloudflare:workers"; | ||
| 2 | |||
| 3 | import { run } from "./user-code.js"; | ||
| 4 | |||
| 5 | const APPROVAL_DENIED_PREFIX = "APPROVAL_DENIED:"; | ||
| 6 | |||
| 7 | function isObjectRecord(value) { | ||
| 8 | return typeof value === "object" && value !== null && !Array.isArray(value); | ||
| 9 | } | ||
| 10 | |||
| 11 | function decodeToolBridgeResult(rawResult) { | ||
| 12 | if (!isObjectRecord(rawResult)) { | ||
| 13 | return { | ||
| 14 | ok: false, | ||
| 15 | kind: "failed", | ||
| 16 | error: "Tool bridge returned a non-object payload", | ||
| 17 | }; | ||
| 18 | } | ||
| 19 | |||
| 20 | if (rawResult.ok === true) { | ||
| 21 | return { | ||
| 22 | ok: true, | ||
| 23 | value: rawResult.value, | ||
| 24 | }; | ||
| 25 | } | ||
| 26 | |||
| 27 | if ( | ||
| 28 | rawResult.ok === false | ||
| 29 | && rawResult.kind === "pending" | ||
| 30 | && typeof rawResult.approvalId === "string" | ||
| 31 | && typeof rawResult.retryAfterMs === "number" | ||
| 32 | ) { | ||
| 33 | return { | ||
| 34 | ok: false, | ||
| 35 | kind: "pending", | ||
| 36 | approvalId: rawResult.approvalId, | ||
| 37 | retryAfterMs: rawResult.retryAfterMs, | ||
| 38 | ...(typeof rawResult.error === "string" ? { error: rawResult.error } : {}), | ||
| 39 | }; | ||
| 40 | } | ||
| 41 | |||
| 42 | if ( | ||
| 43 | rawResult.ok === false | ||
| 44 | && rawResult.kind === "denied" | ||
| 45 | && typeof rawResult.error === "string" | ||
| 46 | ) { | ||
| 47 | return { | ||
| 48 | ok: false, | ||
| 49 | kind: "denied", | ||
| 50 | error: rawResult.error, | ||
| 51 | }; | ||
| 52 | } | ||
| 53 | |||
| 54 | if ( | ||
| 55 | rawResult.ok === false | ||
| 56 | && rawResult.kind === "failed" | ||
| 57 | && typeof rawResult.error === "string" | ||
| 58 | ) { | ||
| 59 | return { | ||
| 60 | ok: false, | ||
| 61 | kind: "failed", | ||
| 62 | error: rawResult.error, | ||
| 63 | }; | ||
| 64 | } | ||
| 65 | |||
| 66 | return { | ||
| 67 | ok: false, | ||
| 68 | kind: "failed", | ||
| 69 | error: "Tool bridge returned a malformed payload", | ||
| 70 | }; | ||
| 71 | } | ||
| 72 | |||
| 73 | function describeExecutionError(error) { | ||
| 74 | if (error instanceof Error) { | ||
| 75 | const message = typeof error.message === "string" ? error.message.trim() : ""; | ||
| 76 | if (message.length > 0) { | ||
| 77 | return message; | ||
| 78 | } | ||
| 79 | |||
| 80 | const stack = typeof error.stack === "string" ? error.stack.trim() : ""; | ||
| 81 | if (stack.length > 0) { | ||
| 82 | return stack; | ||
| 83 | } | ||
| 84 | |||
| 85 | return "Execution failed with an empty Error object"; | ||
| 86 | } | ||
| 87 | |||
| 88 | const text = String(error).trim(); | ||
| 89 | if (text.length > 0) { | ||
| 90 | return text; | ||
| 91 | } | ||
| 92 | |||
| 93 | return "Execution failed with an empty non-Error throw value"; | ||
| 94 | } | ||
| 95 | |||
| 96 | function createToolsProxy(bridge, path = []) { | ||
| 97 | const callable = () => {}; | ||
| 98 | |||
| 99 | return new Proxy(callable, { | ||
| 100 | get(_target, prop) { | ||
| 101 | if (prop === "then") { | ||
| 102 | return undefined; | ||
| 103 | } | ||
| 104 | |||
| 105 | if (typeof prop !== "string") { | ||
| 106 | return undefined; | ||
| 107 | } | ||
| 108 | |||
| 109 | return createToolsProxy(bridge, [...path, prop]); | ||
| 110 | }, | ||
| 111 | |||
| 112 | async apply(_target, _thisArg, args) { | ||
| 113 | const toolPath = path.join("."); | ||
| 114 | if (!toolPath) { | ||
| 115 | throw new Error("Tool path missing"); | ||
| 116 | } | ||
| 117 | |||
| 118 | const input = args.length > 0 ? args[0] : {}; | ||
| 119 | const callId = `call_${crypto.randomUUID()}`; | ||
| 120 | const result = decodeToolBridgeResult( | ||
| 121 | await bridge.callTool(toolPath, input, callId), | ||
| 122 | ); | ||
| 123 | |||
| 124 | if (result.ok) { | ||
| 125 | return result.value; | ||
| 126 | } | ||
| 127 | |||
| 128 | if (result.kind === "pending") { | ||
| 129 | throw new Error( | ||
| 130 | `Tool call is unexpectedly pending approval (${result.approvalId})`, | ||
| 131 | ); | ||
| 132 | } | ||
| 133 | |||
| 134 | if (result.kind === "denied") { | ||
| 135 | throw new Error(APPROVAL_DENIED_PREFIX + result.error); | ||
| 136 | } | ||
| 137 | |||
| 138 | const errorText = typeof result.error === "string" ? result.error.trim() : ""; | ||
| 139 | throw new Error( | ||
| 140 | errorText.length > 0 | ||
| 141 | ? errorText | ||
| 142 | : `Tool call failed without an error message (${toolPath})`, | ||
| 143 | ); | ||
| 144 | }, | ||
| 145 | }); | ||
| 146 | } | ||
| 147 | |||
| 148 | function sanitizeExecutionResult(value) { | ||
| 149 | if (value === undefined) { | ||
| 150 | return undefined; | ||
| 151 | } | ||
| 152 | |||
| 153 | try { | ||
| 154 | const serialized = JSON.stringify(value); | ||
| 155 | if (serialized === undefined) { | ||
| 156 | return null; | ||
| 157 | } | ||
| 158 | |||
| 159 | return JSON.parse(serialized); | ||
| 160 | } catch { | ||
| 161 | return String(value); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | export default class SandboxHarness extends WorkerEntrypoint { | ||
| 166 | async evaluate(bridge) { | ||
| 167 | const tools = createToolsProxy(bridge); | ||
| 168 | const console = { | ||
| 169 | log: (..._args) => {}, | ||
| 170 | info: (..._args) => {}, | ||
| 171 | warn: (..._args) => {}, | ||
| 172 | error: (..._args) => {}, | ||
| 173 | }; | ||
| 174 | |||
| 175 | try { | ||
| 176 | const value = await run(tools, console); | ||
| 177 | return { | ||
| 178 | status: "completed", | ||
| 179 | result: sanitizeExecutionResult(value), | ||
| 180 | exitCode: 0, | ||
| 181 | }; | ||
| 182 | } catch (error) { | ||
| 183 | const message = describeExecutionError(error); | ||
| 184 | |||
| 185 | if (message.startsWith(APPROVAL_DENIED_PREFIX)) { | ||
| 186 | const denied = message.replace(APPROVAL_DENIED_PREFIX, "").trim(); | ||
| 187 | return { | ||
| 188 | status: "denied", | ||
| 189 | error: denied, | ||
| 190 | }; | ||
| 191 | } | ||
| 192 | |||
| 193 | return { | ||
| 194 | status: "failed", | ||
| 195 | error: message, | ||
| 196 | }; | ||
| 197 | } | ||
| 198 | } | ||
| 199 | } | ||
| @@ -1,1298 +0,0 @@ | |||
| 1 | var __defProp = Object.defineProperty; | ||
| 2 | var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
| 3 | |||
| 4 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/_internal/utils.mjs | ||
| 5 | // @__NO_SIDE_EFFECTS__ | ||
| 6 | function createNotImplementedError(name) { | ||
| 7 | return new Error(`[unenv] ${name} is not implemented yet!`); | ||
| 8 | } | ||
| 9 | __name(createNotImplementedError, "createNotImplementedError"); | ||
| 10 | // @__NO_SIDE_EFFECTS__ | ||
| 11 | function notImplemented(name) { | ||
| 12 | const fn = /* @__PURE__ */ __name(() => { | ||
| 13 | throw /* @__PURE__ */ createNotImplementedError(name); | ||
| 14 | }, "fn"); | ||
| 15 | return Object.assign(fn, { __unenv__: true }); | ||
| 16 | } | ||
| 17 | __name(notImplemented, "notImplemented"); | ||
| 18 | // @__NO_SIDE_EFFECTS__ | ||
| 19 | function notImplementedClass(name) { | ||
| 20 | return class { | ||
| 21 | __unenv__ = true; | ||
| 22 | constructor() { | ||
| 23 | throw new Error(`[unenv] ${name} is not implemented yet!`); | ||
| 24 | } | ||
| 25 | }; | ||
| 26 | } | ||
| 27 | __name(notImplementedClass, "notImplementedClass"); | ||
| 28 | |||
| 29 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/perf_hooks/performance.mjs | ||
| 30 | var _timeOrigin = globalThis.performance?.timeOrigin ?? Date.now(); | ||
| 31 | var _performanceNow = globalThis.performance?.now ? globalThis.performance.now.bind(globalThis.performance) : () => Date.now() - _timeOrigin; | ||
| 32 | var nodeTiming = { | ||
| 33 | name: "node", | ||
| 34 | entryType: "node", | ||
| 35 | startTime: 0, | ||
| 36 | duration: 0, | ||
| 37 | nodeStart: 0, | ||
| 38 | v8Start: 0, | ||
| 39 | bootstrapComplete: 0, | ||
| 40 | environment: 0, | ||
| 41 | loopStart: 0, | ||
| 42 | loopExit: 0, | ||
| 43 | idleTime: 0, | ||
| 44 | uvMetricsInfo: { | ||
| 45 | loopCount: 0, | ||
| 46 | events: 0, | ||
| 47 | eventsWaiting: 0 | ||
| 48 | }, | ||
| 49 | detail: void 0, | ||
| 50 | toJSON() { | ||
| 51 | return this; | ||
| 52 | } | ||
| 53 | }; | ||
| 54 | var PerformanceEntry = class { | ||
| 55 | static { | ||
| 56 | __name(this, "PerformanceEntry"); | ||
| 57 | } | ||
| 58 | __unenv__ = true; | ||
| 59 | detail; | ||
| 60 | entryType = "event"; | ||
| 61 | name; | ||
| 62 | startTime; | ||
| 63 | constructor(name, options) { | ||
| 64 | this.name = name; | ||
| 65 | this.startTime = options?.startTime || _performanceNow(); | ||
| 66 | this.detail = options?.detail; | ||
| 67 | } | ||
| 68 | get duration() { | ||
| 69 | return _performanceNow() - this.startTime; | ||
| 70 | } | ||
| 71 | toJSON() { | ||
| 72 | return { | ||
| 73 | name: this.name, | ||
| 74 | entryType: this.entryType, | ||
| 75 | startTime: this.startTime, | ||
| 76 | duration: this.duration, | ||
| 77 | detail: this.detail | ||
| 78 | }; | ||
| 79 | } | ||
| 80 | }; | ||
| 81 | var PerformanceMark = class PerformanceMark2 extends PerformanceEntry { | ||
| 82 | static { | ||
| 83 | __name(this, "PerformanceMark"); | ||
| 84 | } | ||
| 85 | entryType = "mark"; | ||
| 86 | constructor() { | ||
| 87 | super(...arguments); | ||
| 88 | } | ||
| 89 | get duration() { | ||
| 90 | return 0; | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | var PerformanceMeasure = class extends PerformanceEntry { | ||
| 94 | static { | ||
| 95 | __name(this, "PerformanceMeasure"); | ||
| 96 | } | ||
| 97 | entryType = "measure"; | ||
| 98 | }; | ||
| 99 | var PerformanceResourceTiming = class extends PerformanceEntry { | ||
| 100 | static { | ||
| 101 | __name(this, "PerformanceResourceTiming"); | ||
| 102 | } | ||
| 103 | entryType = "resource"; | ||
| 104 | serverTiming = []; | ||
| 105 | connectEnd = 0; | ||
| 106 | connectStart = 0; | ||
| 107 | decodedBodySize = 0; | ||
| 108 | domainLookupEnd = 0; | ||
| 109 | domainLookupStart = 0; | ||
| 110 | encodedBodySize = 0; | ||
| 111 | fetchStart = 0; | ||
| 112 | initiatorType = ""; | ||
| 113 | name = ""; | ||
| 114 | nextHopProtocol = ""; | ||
| 115 | redirectEnd = 0; | ||
| 116 | redirectStart = 0; | ||
| 117 | requestStart = 0; | ||
| 118 | responseEnd = 0; | ||
| 119 | responseStart = 0; | ||
| 120 | secureConnectionStart = 0; | ||
| 121 | startTime = 0; | ||
| 122 | transferSize = 0; | ||
| 123 | workerStart = 0; | ||
| 124 | responseStatus = 0; | ||
| 125 | }; | ||
| 126 | var PerformanceObserverEntryList = class { | ||
| 127 | static { | ||
| 128 | __name(this, "PerformanceObserverEntryList"); | ||
| 129 | } | ||
| 130 | __unenv__ = true; | ||
| 131 | getEntries() { | ||
| 132 | return []; | ||
| 133 | } | ||
| 134 | getEntriesByName(_name, _type) { | ||
| 135 | return []; | ||
| 136 | } | ||
| 137 | getEntriesByType(type) { | ||
| 138 | return []; | ||
| 139 | } | ||
| 140 | }; | ||
| 141 | var Performance = class { | ||
| 142 | static { | ||
| 143 | __name(this, "Performance"); | ||
| 144 | } | ||
| 145 | __unenv__ = true; | ||
| 146 | timeOrigin = _timeOrigin; | ||
| 147 | eventCounts = /* @__PURE__ */ new Map(); | ||
| 148 | _entries = []; | ||
| 149 | _resourceTimingBufferSize = 0; | ||
| 150 | navigation = void 0; | ||
| 151 | timing = void 0; | ||
| 152 | timerify(_fn, _options) { | ||
| 153 | throw createNotImplementedError("Performance.timerify"); | ||
| 154 | } | ||
| 155 | get nodeTiming() { | ||
| 156 | return nodeTiming; | ||
| 157 | } | ||
| 158 | eventLoopUtilization() { | ||
| 159 | return {}; | ||
| 160 | } | ||
| 161 | markResourceTiming() { | ||
| 162 | return new PerformanceResourceTiming(""); | ||
| 163 | } | ||
| 164 | onresourcetimingbufferfull = null; | ||
| 165 | now() { | ||
| 166 | if (this.timeOrigin === _timeOrigin) { | ||
| 167 | return _performanceNow(); | ||
| 168 | } | ||
| 169 | return Date.now() - this.timeOrigin; | ||
| 170 | } | ||
| 171 | clearMarks(markName) { | ||
| 172 | this._entries = markName ? this._entries.filter((e) => e.name !== markName) : this._entries.filter((e) => e.entryType !== "mark"); | ||
| 173 | } | ||
| 174 | clearMeasures(measureName) { | ||
| 175 | this._entries = measureName ? this._entries.filter((e) => e.name !== measureName) : this._entries.filter((e) => e.entryType !== "measure"); | ||
| 176 | } | ||
| 177 | clearResourceTimings() { | ||
| 178 | this._entries = this._entries.filter((e) => e.entryType !== "resource" || e.entryType !== "navigation"); | ||
| 179 | } | ||
| 180 | getEntries() { | ||
| 181 | return this._entries; | ||
| 182 | } | ||
| 183 | getEntriesByName(name, type) { | ||
| 184 | return this._entries.filter((e) => e.name === name && (!type || e.entryType === type)); | ||
| 185 | } | ||
| 186 | getEntriesByType(type) { | ||
| 187 | return this._entries.filter((e) => e.entryType === type); | ||
| 188 | } | ||
| 189 | mark(name, options) { | ||
| 190 | const entry = new PerformanceMark(name, options); | ||
| 191 | this._entries.push(entry); | ||
| 192 | return entry; | ||
| 193 | } | ||
| 194 | measure(measureName, startOrMeasureOptions, endMark) { | ||
| 195 | let start; | ||
| 196 | let end; | ||
| 197 | if (typeof startOrMeasureOptions === "string") { | ||
| 198 | start = this.getEntriesByName(startOrMeasureOptions, "mark")[0]?.startTime; | ||
| 199 | end = this.getEntriesByName(endMark, "mark")[0]?.startTime; | ||
| 200 | } else { | ||
| 201 | start = Number.parseFloat(startOrMeasureOptions?.start) || this.now(); | ||
| 202 | end = Number.parseFloat(startOrMeasureOptions?.end) || this.now(); | ||
| 203 | } | ||
| 204 | const entry = new PerformanceMeasure(measureName, { | ||
| 205 | startTime: start, | ||
| 206 | detail: { | ||
| 207 | start, | ||
| 208 | end | ||
| 209 | } | ||
| 210 | }); | ||
| 211 | this._entries.push(entry); | ||
| 212 | return entry; | ||
| 213 | } | ||
| 214 | setResourceTimingBufferSize(maxSize) { | ||
| 215 | this._resourceTimingBufferSize = maxSize; | ||
| 216 | } | ||
| 217 | addEventListener(type, listener, options) { | ||
| 218 | throw createNotImplementedError("Performance.addEventListener"); | ||
| 219 | } | ||
| 220 | removeEventListener(type, listener, options) { | ||
| 221 | throw createNotImplementedError("Performance.removeEventListener"); | ||
| 222 | } | ||
| 223 | dispatchEvent(event) { | ||
| 224 | throw createNotImplementedError("Performance.dispatchEvent"); | ||
| 225 | } | ||
| 226 | toJSON() { | ||
| 227 | return this; | ||
| 228 | } | ||
| 229 | }; | ||
| 230 | var PerformanceObserver = class { | ||
| 231 | static { | ||
| 232 | __name(this, "PerformanceObserver"); | ||
| 233 | } | ||
| 234 | __unenv__ = true; | ||
| 235 | static supportedEntryTypes = []; | ||
| 236 | _callback = null; | ||
| 237 | constructor(callback) { | ||
| 238 | this._callback = callback; | ||
| 239 | } | ||
| 240 | takeRecords() { | ||
| 241 | return []; | ||
| 242 | } | ||
| 243 | disconnect() { | ||
| 244 | throw createNotImplementedError("PerformanceObserver.disconnect"); | ||
| 245 | } | ||
| 246 | observe(options) { | ||
| 247 | throw createNotImplementedError("PerformanceObserver.observe"); | ||
| 248 | } | ||
| 249 | bind(fn) { | ||
| 250 | return fn; | ||
| 251 | } | ||
| 252 | runInAsyncScope(fn, thisArg, ...args) { | ||
| 253 | return fn.call(thisArg, ...args); | ||
| 254 | } | ||
| 255 | asyncId() { | ||
| 256 | return 0; | ||
| 257 | } | ||
| 258 | triggerAsyncId() { | ||
| 259 | return 0; | ||
| 260 | } | ||
| 261 | emitDestroy() { | ||
| 262 | return this; | ||
| 263 | } | ||
| 264 | }; | ||
| 265 | var performance = globalThis.performance && "addEventListener" in globalThis.performance ? globalThis.performance : new Performance(); | ||
| 266 | |||
| 267 | // ../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/polyfill/performance.mjs | ||
| 268 | globalThis.performance = performance; | ||
| 269 | globalThis.Performance = Performance; | ||
| 270 | globalThis.PerformanceEntry = PerformanceEntry; | ||
| 271 | globalThis.PerformanceMark = PerformanceMark; | ||
| 272 | globalThis.PerformanceMeasure = PerformanceMeasure; | ||
| 273 | globalThis.PerformanceObserver = PerformanceObserver; | ||
| 274 | globalThis.PerformanceObserverEntryList = PerformanceObserverEntryList; | ||
| 275 | globalThis.PerformanceResourceTiming = PerformanceResourceTiming; | ||
| 276 | |||
| 277 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/console.mjs | ||
| 278 | import { Writable } from "node:stream"; | ||
| 279 | |||
| 280 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/mock/noop.mjs | ||
| 281 | var noop_default = Object.assign(() => { | ||
| 282 | }, { __unenv__: true }); | ||
| 283 | |||
| 284 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/console.mjs | ||
| 285 | var _console = globalThis.console; | ||
| 286 | var _ignoreErrors = true; | ||
| 287 | var _stderr = new Writable(); | ||
| 288 | var _stdout = new Writable(); | ||
| 289 | var log = _console?.log ?? noop_default; | ||
| 290 | var info = _console?.info ?? log; | ||
| 291 | var trace = _console?.trace ?? info; | ||
| 292 | var debug = _console?.debug ?? log; | ||
| 293 | var table = _console?.table ?? log; | ||
| 294 | var error = _console?.error ?? log; | ||
| 295 | var warn = _console?.warn ?? error; | ||
| 296 | var createTask = _console?.createTask ?? /* @__PURE__ */ notImplemented("console.createTask"); | ||
| 297 | var clear = _console?.clear ?? noop_default; | ||
| 298 | var count = _console?.count ?? noop_default; | ||
| 299 | var countReset = _console?.countReset ?? noop_default; | ||
| 300 | var dir = _console?.dir ?? noop_default; | ||
| 301 | var dirxml = _console?.dirxml ?? noop_default; | ||
| 302 | var group = _console?.group ?? noop_default; | ||
| 303 | var groupEnd = _console?.groupEnd ?? noop_default; | ||
| 304 | var groupCollapsed = _console?.groupCollapsed ?? noop_default; | ||
| 305 | var profile = _console?.profile ?? noop_default; | ||
| 306 | var profileEnd = _console?.profileEnd ?? noop_default; | ||
| 307 | var time = _console?.time ?? noop_default; | ||
| 308 | var timeEnd = _console?.timeEnd ?? noop_default; | ||
| 309 | var timeLog = _console?.timeLog ?? noop_default; | ||
| 310 | var timeStamp = _console?.timeStamp ?? noop_default; | ||
| 311 | var Console = _console?.Console ?? /* @__PURE__ */ notImplementedClass("console.Console"); | ||
| 312 | var _times = /* @__PURE__ */ new Map(); | ||
| 313 | var _stdoutErrorHandler = noop_default; | ||
| 314 | var _stderrErrorHandler = noop_default; | ||
| 315 | |||
| 316 | // ../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/node/console.mjs | ||
| 317 | var workerdConsole = globalThis["console"]; | ||
| 318 | var { | ||
| 319 | assert, | ||
| 320 | clear: clear2, | ||
| 321 | // @ts-expect-error undocumented public API | ||
| 322 | context, | ||
| 323 | count: count2, | ||
| 324 | countReset: countReset2, | ||
| 325 | // @ts-expect-error undocumented public API | ||
| 326 | createTask: createTask2, | ||
| 327 | debug: debug2, | ||
| 328 | dir: dir2, | ||
| 329 | dirxml: dirxml2, | ||
| 330 | error: error2, | ||
| 331 | group: group2, | ||
| 332 | groupCollapsed: groupCollapsed2, | ||
| 333 | groupEnd: groupEnd2, | ||
| 334 | info: info2, | ||
| 335 | log: log2, | ||
| 336 | profile: profile2, | ||
| 337 | profileEnd: profileEnd2, | ||
| 338 | table: table2, | ||
| 339 | time: time2, | ||
| 340 | timeEnd: timeEnd2, | ||
| 341 | timeLog: timeLog2, | ||
| 342 | timeStamp: timeStamp2, | ||
| 343 | trace: trace2, | ||
| 344 | warn: warn2 | ||
| 345 | } = workerdConsole; | ||
| 346 | Object.assign(workerdConsole, { | ||
| 347 | Console, | ||
| 348 | _ignoreErrors, | ||
| 349 | _stderr, | ||
| 350 | _stderrErrorHandler, | ||
| 351 | _stdout, | ||
| 352 | _stdoutErrorHandler, | ||
| 353 | _times | ||
| 354 | }); | ||
| 355 | var console_default = workerdConsole; | ||
| 356 | |||
| 357 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-console | ||
| 358 | globalThis.console = console_default; | ||
| 359 | |||
| 360 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/hrtime.mjs | ||
| 361 | var hrtime = /* @__PURE__ */ Object.assign(/* @__PURE__ */ __name(function hrtime2(startTime) { | ||
| 362 | const now = Date.now(); | ||
| 363 | const seconds = Math.trunc(now / 1e3); | ||
| 364 | const nanos = now % 1e3 * 1e6; | ||
| 365 | if (startTime) { | ||
| 366 | let diffSeconds = seconds - startTime[0]; | ||
| 367 | let diffNanos = nanos - startTime[0]; | ||
| 368 | if (diffNanos < 0) { | ||
| 369 | diffSeconds = diffSeconds - 1; | ||
| 370 | diffNanos = 1e9 + diffNanos; | ||
| 371 | } | ||
| 372 | return [diffSeconds, diffNanos]; | ||
| 373 | } | ||
| 374 | return [seconds, nanos]; | ||
| 375 | }, "hrtime"), { bigint: /* @__PURE__ */ __name(function bigint() { | ||
| 376 | return BigInt(Date.now() * 1e6); | ||
| 377 | }, "bigint") }); | ||
| 378 | |||
| 379 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/process.mjs | ||
| 380 | import { EventEmitter } from "node:events"; | ||
| 381 | |||
| 382 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/read-stream.mjs | ||
| 383 | var ReadStream = class { | ||
| 384 | static { | ||
| 385 | __name(this, "ReadStream"); | ||
| 386 | } | ||
| 387 | fd; | ||
| 388 | isRaw = false; | ||
| 389 | isTTY = false; | ||
| 390 | constructor(fd) { | ||
| 391 | this.fd = fd; | ||
| 392 | } | ||
| 393 | setRawMode(mode) { | ||
| 394 | this.isRaw = mode; | ||
| 395 | return this; | ||
| 396 | } | ||
| 397 | }; | ||
| 398 | |||
| 399 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/write-stream.mjs | ||
| 400 | var WriteStream = class { | ||
| 401 | static { | ||
| 402 | __name(this, "WriteStream"); | ||
| 403 | } | ||
| 404 | fd; | ||
| 405 | columns = 80; | ||
| 406 | rows = 24; | ||
| 407 | isTTY = false; | ||
| 408 | constructor(fd) { | ||
| 409 | this.fd = fd; | ||
| 410 | } | ||
| 411 | clearLine(dir3, callback) { | ||
| 412 | callback && callback(); | ||
| 413 | return false; | ||
| 414 | } | ||
| 415 | clearScreenDown(callback) { | ||
| 416 | callback && callback(); | ||
| 417 | return false; | ||
| 418 | } | ||
| 419 | cursorTo(x, y, callback) { | ||
| 420 | callback && typeof callback === "function" && callback(); | ||
| 421 | return false; | ||
| 422 | } | ||
| 423 | moveCursor(dx, dy, callback) { | ||
| 424 | callback && callback(); | ||
| 425 | return false; | ||
| 426 | } | ||
| 427 | getColorDepth(env2) { | ||
| 428 | return 1; | ||
| 429 | } | ||
| 430 | hasColors(count3, env2) { | ||
| 431 | return false; | ||
| 432 | } | ||
| 433 | getWindowSize() { | ||
| 434 | return [this.columns, this.rows]; | ||
| 435 | } | ||
| 436 | write(str, encoding, cb) { | ||
| 437 | if (str instanceof Uint8Array) { | ||
| 438 | str = new TextDecoder().decode(str); | ||
| 439 | } | ||
| 440 | try { | ||
| 441 | console.log(str); | ||
| 442 | } catch { | ||
| 443 | } | ||
| 444 | cb && typeof cb === "function" && cb(); | ||
| 445 | return false; | ||
| 446 | } | ||
| 447 | }; | ||
| 448 | |||
| 449 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/node-version.mjs | ||
| 450 | var NODE_VERSION = "22.14.0"; | ||
| 451 | |||
| 452 | // ../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/process.mjs | ||
| 453 | var Process = class _Process extends EventEmitter { | ||
| 454 | static { | ||
| 455 | __name(this, "Process"); | ||
| 456 | } | ||
| 457 | env; | ||
| 458 | hrtime; | ||
| 459 | nextTick; | ||
| 460 | constructor(impl) { | ||
| 461 | super(); | ||
| 462 | this.env = impl.env; | ||
| 463 | this.hrtime = impl.hrtime; | ||
| 464 | this.nextTick = impl.nextTick; | ||
| 465 | for (const prop of [...Object.getOwnPropertyNames(_Process.prototype), ...Object.getOwnPropertyNames(EventEmitter.prototype)]) { | ||
| 466 | const value = this[prop]; | ||
| 467 | if (typeof value === "function") { | ||
| 468 | this[prop] = value.bind(this); | ||
| 469 | } | ||
| 470 | } | ||
| 471 | } | ||
| 472 | // --- event emitter --- | ||
| 473 | emitWarning(warning, type, code) { | ||
| 474 | console.warn(`${code ? `[${code}] ` : ""}${type ? `${type}: ` : ""}${warning}`); | ||
| 475 | } | ||
| 476 | emit(...args) { | ||
| 477 | return super.emit(...args); | ||
| 478 | } | ||
| 479 | listeners(eventName) { | ||
| 480 | return super.listeners(eventName); | ||
| 481 | } | ||
| 482 | // --- stdio (lazy initializers) --- | ||
| 483 | #stdin; | ||
| 484 | #stdout; | ||
| 485 | #stderr; | ||
| 486 | get stdin() { | ||
| 487 | return this.#stdin ??= new ReadStream(0); | ||
| 488 | } | ||
| 489 | get stdout() { | ||
| 490 | return this.#stdout ??= new WriteStream(1); | ||
| 491 | } | ||
| 492 | get stderr() { | ||
| 493 | return this.#stderr ??= new WriteStream(2); | ||
| 494 | } | ||
| 495 | // --- cwd --- | ||
| 496 | #cwd = "/"; | ||
| 497 | chdir(cwd2) { | ||
| 498 | this.#cwd = cwd2; | ||
| 499 | } | ||
| 500 | cwd() { | ||
| 501 | return this.#cwd; | ||
| 502 | } | ||
| 503 | // --- dummy props and getters --- | ||
| 504 | arch = ""; | ||
| 505 | platform = ""; | ||
| 506 | argv = []; | ||
| 507 | argv0 = ""; | ||
| 508 | execArgv = []; | ||
| 509 | execPath = ""; | ||
| 510 | title = ""; | ||
| 511 | pid = 200; | ||
| 512 | ppid = 100; | ||
| 513 | get version() { | ||
| 514 | return `v${NODE_VERSION}`; | ||
| 515 | } | ||
| 516 | get versions() { | ||
| 517 | return { node: NODE_VERSION }; | ||
| 518 | } | ||
| 519 | get allowedNodeEnvironmentFlags() { | ||
| 520 | return /* @__PURE__ */ new Set(); | ||
| 521 | } | ||
| 522 | get sourceMapsEnabled() { | ||
| 523 | return false; | ||
| 524 | } | ||
| 525 | get debugPort() { | ||
| 526 | return 0; | ||
| 527 | } | ||
| 528 | get throwDeprecation() { | ||
| 529 | return false; | ||
| 530 | } | ||
| 531 | get traceDeprecation() { | ||
| 532 | return false; | ||
| 533 | } | ||
| 534 | get features() { | ||
| 535 | return {}; | ||
| 536 | } | ||
| 537 | get release() { | ||
| 538 | return {}; | ||
| 539 | } | ||
| 540 | get connected() { | ||
| 541 | return false; | ||
| 542 | } | ||
| 543 | get config() { | ||
| 544 | return {}; | ||
| 545 | } | ||
| 546 | get moduleLoadList() { | ||
| 547 | return []; | ||
| 548 | } | ||
| 549 | constrainedMemory() { | ||
| 550 | return 0; | ||
| 551 | } | ||
| 552 | availableMemory() { | ||
| 553 | return 0; | ||
| 554 | } | ||
| 555 | uptime() { | ||
| 556 | return 0; | ||
| 557 | } | ||
| 558 | resourceUsage() { | ||
| 559 | return {}; | ||
| 560 | } | ||
| 561 | // --- noop methods --- | ||
| 562 | ref() { | ||
| 563 | } | ||
| 564 | unref() { | ||
| 565 | } | ||
| 566 | // --- unimplemented methods --- | ||
| 567 | umask() { | ||
| 568 | throw createNotImplementedError("process.umask"); | ||
| 569 | } | ||
| 570 | getBuiltinModule() { | ||
| 571 | return void 0; | ||
| 572 | } | ||
| 573 | getActiveResourcesInfo() { | ||
| 574 | throw createNotImplementedError("process.getActiveResourcesInfo"); | ||
| 575 | } | ||
| 576 | exit() { | ||
| 577 | throw createNotImplementedError("process.exit"); | ||
| 578 | } | ||
| 579 | reallyExit() { | ||
| 580 | throw createNotImplementedError("process.reallyExit"); | ||
| 581 | } | ||
| 582 | kill() { | ||
| 583 | throw createNotImplementedError("process.kill"); | ||
| 584 | } | ||
| 585 | abort() { | ||
| 586 | throw createNotImplementedError("process.abort"); | ||
| 587 | } | ||
| 588 | dlopen() { | ||
| 589 | throw createNotImplementedError("process.dlopen"); | ||
| 590 | } | ||
| 591 | setSourceMapsEnabled() { | ||
| 592 | throw createNotImplementedError("process.setSourceMapsEnabled"); | ||
| 593 | } | ||
| 594 | loadEnvFile() { | ||
| 595 | throw createNotImplementedError("process.loadEnvFile"); | ||
| 596 | } | ||
| 597 | disconnect() { | ||
| 598 | throw createNotImplementedError("process.disconnect"); | ||
| 599 | } | ||
| 600 | cpuUsage() { | ||
| 601 | throw createNotImplementedError("process.cpuUsage"); | ||
| 602 | } | ||
| 603 | setUncaughtExceptionCaptureCallback() { | ||
| 604 | throw createNotImplementedError("process.setUncaughtExceptionCaptureCallback"); | ||
| 605 | } | ||
| 606 | hasUncaughtExceptionCaptureCallback() { | ||
| 607 | throw createNotImplementedError("process.hasUncaughtExceptionCaptureCallback"); | ||
| 608 | } | ||
| 609 | initgroups() { | ||
| 610 | throw createNotImplementedError("process.initgroups"); | ||
| 611 | } | ||
| 612 | openStdin() { | ||
| 613 | throw createNotImplementedError("process.openStdin"); | ||
| 614 | } | ||
| 615 | assert() { | ||
| 616 | throw createNotImplementedError("process.assert"); | ||
| 617 | } | ||
| 618 | binding() { | ||
| 619 | throw createNotImplementedError("process.binding"); | ||
| 620 | } | ||
| 621 | // --- attached interfaces --- | ||
| 622 | permission = { has: /* @__PURE__ */ notImplemented("process.permission.has") }; | ||
| 623 | report = { | ||
| 624 | directory: "", | ||
| 625 | filename: "", | ||
| 626 | signal: "SIGUSR2", | ||
| 627 | compact: false, | ||
| 628 | reportOnFatalError: false, | ||
| 629 | reportOnSignal: false, | ||
| 630 | reportOnUncaughtException: false, | ||
| 631 | getReport: /* @__PURE__ */ notImplemented("process.report.getReport"), | ||
| 632 | writeReport: /* @__PURE__ */ notImplemented("process.report.writeReport") | ||
| 633 | }; | ||
| 634 | finalization = { | ||
| 635 | register: /* @__PURE__ */ notImplemented("process.finalization.register"), | ||
| 636 | unregister: /* @__PURE__ */ notImplemented("process.finalization.unregister"), | ||
| 637 | registerBeforeExit: /* @__PURE__ */ notImplemented("process.finalization.registerBeforeExit") | ||
| 638 | }; | ||
| 639 | memoryUsage = Object.assign(() => ({ | ||
| 640 | arrayBuffers: 0, | ||
| 641 | rss: 0, | ||
| 642 | external: 0, | ||
| 643 | heapTotal: 0, | ||
| 644 | heapUsed: 0 | ||
| 645 | }), { rss: /* @__PURE__ */ __name(() => 0, "rss") }); | ||
| 646 | // --- undefined props --- | ||
| 647 | mainModule = void 0; | ||
| 648 | domain = void 0; | ||
| 649 | // optional | ||
| 650 | send = void 0; | ||
| 651 | exitCode = void 0; | ||
| 652 | channel = void 0; | ||
| 653 | getegid = void 0; | ||
| 654 | geteuid = void 0; | ||
| 655 | getgid = void 0; | ||
| 656 | getgroups = void 0; | ||
| 657 | getuid = void 0; | ||
| 658 | setegid = void 0; | ||
| 659 | seteuid = void 0; | ||
| 660 | setgid = void 0; | ||
| 661 | setgroups = void 0; | ||
| 662 | setuid = void 0; | ||
| 663 | // internals | ||
| 664 | _events = void 0; | ||
| 665 | _eventsCount = void 0; | ||
| 666 | _exiting = void 0; | ||
| 667 | _maxListeners = void 0; | ||
| 668 | _debugEnd = void 0; | ||
| 669 | _debugProcess = void 0; | ||
| 670 | _fatalException = void 0; | ||
| 671 | _getActiveHandles = void 0; | ||
| 672 | _getActiveRequests = void 0; | ||
| 673 | _kill = void 0; | ||
| 674 | _preload_modules = void 0; | ||
| 675 | _rawDebug = void 0; | ||
| 676 | _startProfilerIdleNotifier = void 0; | ||
| 677 | _stopProfilerIdleNotifier = void 0; | ||
| 678 | _tickCallback = void 0; | ||
| 679 | _disconnect = void 0; | ||
| 680 | _handleQueue = void 0; | ||
| 681 | _pendingMessage = void 0; | ||
| 682 | _channel = void 0; | ||
| 683 | _send = void 0; | ||
| 684 | _linkedBinding = void 0; | ||
| 685 | }; | ||
| 686 | |||
| 687 | // ../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/node/process.mjs | ||
| 688 | var globalProcess = globalThis["process"]; | ||
| 689 | var getBuiltinModule = globalProcess.getBuiltinModule; | ||
| 690 | var workerdProcess = getBuiltinModule("node:process"); | ||
| 691 | var unenvProcess = new Process({ | ||
| 692 | env: globalProcess.env, | ||
| 693 | hrtime, | ||
| 694 | // `nextTick` is available from workerd process v1 | ||
| 695 | nextTick: workerdProcess.nextTick | ||
| 696 | }); | ||
| 697 | var { exit, features, platform } = workerdProcess; | ||
| 698 | var { | ||
| 699 | _channel, | ||
| 700 | _debugEnd, | ||
| 701 | _debugProcess, | ||
| 702 | _disconnect, | ||
| 703 | _events, | ||
| 704 | _eventsCount, | ||
| 705 | _exiting, | ||
| 706 | _fatalException, | ||
| 707 | _getActiveHandles, | ||
| 708 | _getActiveRequests, | ||
| 709 | _handleQueue, | ||
| 710 | _kill, | ||
| 711 | _linkedBinding, | ||
| 712 | _maxListeners, | ||
| 713 | _pendingMessage, | ||
| 714 | _preload_modules, | ||
| 715 | _rawDebug, | ||
| 716 | _send, | ||
| 717 | _startProfilerIdleNotifier, | ||
| 718 | _stopProfilerIdleNotifier, | ||
| 719 | _tickCallback, | ||
| 720 | abort, | ||
| 721 | addListener, | ||
| 722 | allowedNodeEnvironmentFlags, | ||
| 723 | arch, | ||
| 724 | argv, | ||
| 725 | argv0, | ||
| 726 | assert: assert2, | ||
| 727 | availableMemory, | ||
| 728 | binding, | ||
| 729 | channel, | ||
| 730 | chdir, | ||
| 731 | config, | ||
| 732 | connected, | ||
| 733 | constrainedMemory, | ||
| 734 | cpuUsage, | ||
| 735 | cwd, | ||
| 736 | debugPort, | ||
| 737 | disconnect, | ||
| 738 | dlopen, | ||
| 739 | domain, | ||
| 740 | emit, | ||
| 741 | emitWarning, | ||
| 742 | env, | ||
| 743 | eventNames, | ||
| 744 | execArgv, | ||
| 745 | execPath, | ||
| 746 | exitCode, | ||
| 747 | finalization, | ||
| 748 | getActiveResourcesInfo, | ||
| 749 | getegid, | ||
| 750 | geteuid, | ||
| 751 | getgid, | ||
| 752 | getgroups, | ||
| 753 | getMaxListeners, | ||
| 754 | getuid, | ||
| 755 | hasUncaughtExceptionCaptureCallback, | ||
| 756 | hrtime: hrtime3, | ||
| 757 | initgroups, | ||
| 758 | kill, | ||
| 759 | listenerCount, | ||
| 760 | listeners, | ||
| 761 | loadEnvFile, | ||
| 762 | mainModule, | ||
| 763 | memoryUsage, | ||
| 764 | moduleLoadList, | ||
| 765 | nextTick, | ||
| 766 | off, | ||
| 767 | on, | ||
| 768 | once, | ||
| 769 | openStdin, | ||
| 770 | permission, | ||
| 771 | pid, | ||
| 772 | ppid, | ||
| 773 | prependListener, | ||
| 774 | prependOnceListener, | ||
| 775 | rawListeners, | ||
| 776 | reallyExit, | ||
| 777 | ref, | ||
| 778 | release, | ||
| 779 | removeAllListeners, | ||
| 780 | removeListener, | ||
| 781 | report, | ||
| 782 | resourceUsage, | ||
| 783 | send, | ||
| 784 | setegid, | ||
| 785 | seteuid, | ||
| 786 | setgid, | ||
| 787 | setgroups, | ||
| 788 | setMaxListeners, | ||
| 789 | setSourceMapsEnabled, | ||
| 790 | setuid, | ||
| 791 | setUncaughtExceptionCaptureCallback, | ||
| 792 | sourceMapsEnabled, | ||
| 793 | stderr, | ||
| 794 | stdin, | ||
| 795 | stdout, | ||
| 796 | throwDeprecation, | ||
| 797 | title, | ||
| 798 | traceDeprecation, | ||
| 799 | umask, | ||
| 800 | unref, | ||
| 801 | uptime, | ||
| 802 | version, | ||
| 803 | versions | ||
| 804 | } = unenvProcess; | ||
| 805 | var _process = { | ||
| 806 | abort, | ||
| 807 | addListener, | ||
| 808 | allowedNodeEnvironmentFlags, | ||
| 809 | hasUncaughtExceptionCaptureCallback, | ||
| 810 | setUncaughtExceptionCaptureCallback, | ||
| 811 | loadEnvFile, | ||
| 812 | sourceMapsEnabled, | ||
| 813 | arch, | ||
| 814 | argv, | ||
| 815 | argv0, | ||
| 816 | chdir, | ||
| 817 | config, | ||
| 818 | connected, | ||
| 819 | constrainedMemory, | ||
| 820 | availableMemory, | ||
| 821 | cpuUsage, | ||
| 822 | cwd, | ||
| 823 | debugPort, | ||
| 824 | dlopen, | ||
| 825 | disconnect, | ||
| 826 | emit, | ||
| 827 | emitWarning, | ||
| 828 | env, | ||
| 829 | eventNames, | ||
| 830 | execArgv, | ||
| 831 | execPath, | ||
| 832 | exit, | ||
| 833 | finalization, | ||
| 834 | features, | ||
| 835 | getBuiltinModule, | ||
| 836 | getActiveResourcesInfo, | ||
| 837 | getMaxListeners, | ||
| 838 | hrtime: hrtime3, | ||
| 839 | kill, | ||
| 840 | listeners, | ||
| 841 | listenerCount, | ||
| 842 | memoryUsage, | ||
| 843 | nextTick, | ||
| 844 | on, | ||
| 845 | off, | ||
| 846 | once, | ||
| 847 | pid, | ||
| 848 | platform, | ||
| 849 | ppid, | ||
| 850 | prependListener, | ||
| 851 | prependOnceListener, | ||
| 852 | rawListeners, | ||
| 853 | release, | ||
| 854 | removeAllListeners, | ||
| 855 | removeListener, | ||
| 856 | report, | ||
| 857 | resourceUsage, | ||
| 858 | setMaxListeners, | ||
| 859 | setSourceMapsEnabled, | ||
| 860 | stderr, | ||
| 861 | stdin, | ||
| 862 | stdout, | ||
| 863 | title, | ||
| 864 | throwDeprecation, | ||
| 865 | traceDeprecation, | ||
| 866 | umask, | ||
| 867 | uptime, | ||
| 868 | version, | ||
| 869 | versions, | ||
| 870 | // @ts-expect-error old API | ||
| 871 | domain, | ||
| 872 | initgroups, | ||
| 873 | moduleLoadList, | ||
| 874 | reallyExit, | ||
| 875 | openStdin, | ||
| 876 | assert: assert2, | ||
| 877 | binding, | ||
| 878 | send, | ||
| 879 | exitCode, | ||
| 880 | channel, | ||
| 881 | getegid, | ||
| 882 | geteuid, | ||
| 883 | getgid, | ||
| 884 | getgroups, | ||
| 885 | getuid, | ||
| 886 | setegid, | ||
| 887 | seteuid, | ||
| 888 | setgid, | ||
| 889 | setgroups, | ||
| 890 | setuid, | ||
| 891 | permission, | ||
| 892 | mainModule, | ||
| 893 | _events, | ||
| 894 | _eventsCount, | ||
| 895 | _exiting, | ||
| 896 | _maxListeners, | ||
| 897 | _debugEnd, | ||
| 898 | _debugProcess, | ||
| 899 | _fatalException, | ||
| 900 | _getActiveHandles, | ||
| 901 | _getActiveRequests, | ||
| 902 | _kill, | ||
| 903 | _preload_modules, | ||
| 904 | _rawDebug, | ||
| 905 | _startProfilerIdleNotifier, | ||
| 906 | _stopProfilerIdleNotifier, | ||
| 907 | _tickCallback, | ||
| 908 | _disconnect, | ||
| 909 | _handleQueue, | ||
| 910 | _pendingMessage, | ||
| 911 | _channel, | ||
| 912 | _send, | ||
| 913 | _linkedBinding | ||
| 914 | }; | ||
| 915 | var process_default = _process; | ||
| 916 | |||
| 917 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-process | ||
| 918 | globalThis.process = process_default; | ||
| 919 | |||
| 920 | // src/index.ts | ||
| 921 | import { RpcTarget } from "cloudflare:workers"; | ||
| 922 | import HARNESS_CODE from "./4ee7f16d990518b04642acba35a710043684a1d7-harness.isolate.js"; | ||
| 923 | var DEFAULT_TIMEOUT_MS = 3e4; | ||
| 924 | var MAX_TIMEOUT_MS = 12e4; | ||
| 925 | var json = /* @__PURE__ */ __name((value, status = 200) => new Response(JSON.stringify(value), { | ||
| 926 | status, | ||
| 927 | headers: { | ||
| 928 | "content-type": "application/json" | ||
| 929 | } | ||
| 930 | }), "json"); | ||
| 931 | var isObjectRecord = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isObjectRecord"); | ||
| 932 | var isRuntimeToolCallResult = /* @__PURE__ */ __name((value) => { | ||
| 933 | if (!isObjectRecord(value)) { | ||
| 934 | return false; | ||
| 935 | } | ||
| 936 | if (value.ok === true) { | ||
| 937 | return Object.prototype.hasOwnProperty.call(value, "value"); | ||
| 938 | } | ||
| 939 | if (value.ok === false && value.kind === "pending") { | ||
| 940 | return typeof value.approvalId === "string" && typeof value.retryAfterMs === "number"; | ||
| 941 | } | ||
| 942 | if (value.ok === false && value.kind === "denied") { | ||
| 943 | return typeof value.error === "string"; | ||
| 944 | } | ||
| 945 | if (value.ok === false && value.kind === "failed") { | ||
| 946 | return typeof value.error === "string"; | ||
| 947 | } | ||
| 948 | return false; | ||
| 949 | }, "isRuntimeToolCallResult"); | ||
| 950 | var isRunResult = /* @__PURE__ */ __name((value) => { | ||
| 951 | if (!isObjectRecord(value)) { | ||
| 952 | return false; | ||
| 953 | } | ||
| 954 | if (value.status !== "completed" && value.status !== "failed" && value.status !== "timed_out" && value.status !== "denied") { | ||
| 955 | return false; | ||
| 956 | } | ||
| 957 | if (value.error !== void 0 && typeof value.error !== "string") { | ||
| 958 | return false; | ||
| 959 | } | ||
| 960 | if (value.exitCode !== void 0 && typeof value.exitCode !== "number") { | ||
| 961 | return false; | ||
| 962 | } | ||
| 963 | return true; | ||
| 964 | }, "isRunResult"); | ||
| 965 | var toFailedResult = /* @__PURE__ */ __name((error3) => ({ | ||
| 966 | status: "failed", | ||
| 967 | error: error3 | ||
| 968 | }), "toFailedResult"); | ||
| 969 | var validateRunRequest = /* @__PURE__ */ __name((value) => { | ||
| 970 | if (!isObjectRecord(value)) { | ||
| 971 | return null; | ||
| 972 | } | ||
| 973 | if (typeof value.runId !== "string" || typeof value.taskId !== "string" || typeof value.code !== "string") { | ||
| 974 | return null; | ||
| 975 | } | ||
| 976 | if (!isObjectRecord(value.callback) || typeof value.callback.url !== "string") { | ||
| 977 | return null; | ||
| 978 | } | ||
| 979 | if (value.callback.internalSecret !== void 0 && typeof value.callback.internalSecret !== "string") { | ||
| 980 | return null; | ||
| 981 | } | ||
| 982 | if (value.timeoutMs !== void 0 && typeof value.timeoutMs !== "number") { | ||
| 983 | return null; | ||
| 984 | } | ||
| 985 | return { | ||
| 986 | runId: value.runId, | ||
| 987 | taskId: value.taskId, | ||
| 988 | code: value.code, | ||
| 989 | timeoutMs: value.timeoutMs, | ||
| 990 | callback: { | ||
| 991 | url: value.callback.url, | ||
| 992 | internalSecret: value.callback.internalSecret | ||
| 993 | } | ||
| 994 | }; | ||
| 995 | }, "validateRunRequest"); | ||
| 996 | var buildUserModule = /* @__PURE__ */ __name((userCode) => `export async function run(tools, console) { | ||
| 997 | "use strict"; | ||
| 998 | ${userCode} | ||
| 999 | } | ||
| 1000 | `, "buildUserModule"); | ||
| 1001 | var ToolBridge = class extends RpcTarget { | ||
| 1002 | static { | ||
| 1003 | __name(this, "ToolBridge"); | ||
| 1004 | } | ||
| 1005 | #props; | ||
| 1006 | constructor(props) { | ||
| 1007 | super(); | ||
| 1008 | this.#props = props; | ||
| 1009 | } | ||
| 1010 | async callTool(toolPath, input, callId) { | ||
| 1011 | const headers = new Headers({ | ||
| 1012 | "content-type": "application/json" | ||
| 1013 | }); | ||
| 1014 | if (this.#props.callbackInternalSecret) { | ||
| 1015 | headers.set("x-internal-secret", this.#props.callbackInternalSecret); | ||
| 1016 | } | ||
| 1017 | const response = await fetch(this.#props.callbackUrl, { | ||
| 1018 | method: "POST", | ||
| 1019 | headers, | ||
| 1020 | body: JSON.stringify({ | ||
| 1021 | runId: this.#props.runId, | ||
| 1022 | callId, | ||
| 1023 | toolPath, | ||
| 1024 | input | ||
| 1025 | }) | ||
| 1026 | }).catch((error3) => { | ||
| 1027 | throw new Error( | ||
| 1028 | `Tool callback transport failed: ${error3 instanceof Error ? error3.message : String(error3)}` | ||
| 1029 | ); | ||
| 1030 | }); | ||
| 1031 | if (response.status !== 200) { | ||
| 1032 | return { | ||
| 1033 | ok: false, | ||
| 1034 | kind: "failed", | ||
| 1035 | error: `Tool callback returned ${response.status}` | ||
| 1036 | }; | ||
| 1037 | } | ||
| 1038 | const payload = await response.json().catch(() => null); | ||
| 1039 | if (!isRuntimeToolCallResult(payload)) { | ||
| 1040 | return { | ||
| 1041 | ok: false, | ||
| 1042 | kind: "failed", | ||
| 1043 | error: "Tool callback returned invalid result payload" | ||
| 1044 | }; | ||
| 1045 | } | ||
| 1046 | return payload; | ||
| 1047 | } | ||
| 1048 | }; | ||
| 1049 | var executeSandboxRun = /* @__PURE__ */ __name(async (request, env2) => { | ||
| 1050 | const timeoutMsRaw = request.timeoutMs ?? DEFAULT_TIMEOUT_MS; | ||
| 1051 | const timeoutMs = Math.max(1, Math.min(MAX_TIMEOUT_MS, Math.floor(timeoutMsRaw))); | ||
| 1052 | const toolBridge = new ToolBridge({ | ||
| 1053 | callbackUrl: request.callback.url, | ||
| 1054 | callbackInternalSecret: request.callback.internalSecret ?? null, | ||
| 1055 | runId: request.runId | ||
| 1056 | }); | ||
| 1057 | const worker = env2.LOADER.get(request.taskId, async () => ({ | ||
| 1058 | compatibilityDate: "2025-06-01", | ||
| 1059 | mainModule: "harness.js", | ||
| 1060 | modules: { | ||
| 1061 | "harness.js": HARNESS_CODE, | ||
| 1062 | "user-code.js": buildUserModule(request.code) | ||
| 1063 | }, | ||
| 1064 | env: {}, | ||
| 1065 | globalOutbound: null | ||
| 1066 | })); | ||
| 1067 | const entrypoint = worker.getEntrypoint(); | ||
| 1068 | let timer = null; | ||
| 1069 | let payload; | ||
| 1070 | try { | ||
| 1071 | const timeoutResult = new Promise((resolve) => { | ||
| 1072 | timer = setTimeout(() => { | ||
| 1073 | resolve({ | ||
| 1074 | status: "timed_out", | ||
| 1075 | error: `Execution timed out after ${timeoutMs}ms` | ||
| 1076 | }); | ||
| 1077 | }, timeoutMs); | ||
| 1078 | }); | ||
| 1079 | payload = await Promise.race([ | ||
| 1080 | entrypoint.evaluate(toolBridge), | ||
| 1081 | timeoutResult | ||
| 1082 | ]); | ||
| 1083 | } catch (error3) { | ||
| 1084 | if (timer) { | ||
| 1085 | clearTimeout(timer); | ||
| 1086 | } | ||
| 1087 | return toFailedResult( | ||
| 1088 | `Sandbox isolate execution failed: ${error3 instanceof Error ? error3.message : String(error3)}` | ||
| 1089 | ); | ||
| 1090 | } | ||
| 1091 | if (timer) { | ||
| 1092 | clearTimeout(timer); | ||
| 1093 | } | ||
| 1094 | if (!isRunResult(payload)) { | ||
| 1095 | return toFailedResult("Sandbox isolate returned invalid response payload"); | ||
| 1096 | } | ||
| 1097 | return payload; | ||
| 1098 | }, "executeSandboxRun"); | ||
| 1099 | var src_default = { | ||
| 1100 | async fetch(request, env2, _ctx) { | ||
| 1101 | const url = new URL(request.url); | ||
| 1102 | if (url.pathname === "/health") { | ||
| 1103 | return new Response("ok", { status: 200 }); | ||
| 1104 | } | ||
| 1105 | if (url.pathname !== "/v1/runs" || request.method !== "POST") { | ||
| 1106 | return json({ error: "not_found" }, 404); | ||
| 1107 | } | ||
| 1108 | if (typeof env2.AUTH_TOKEN !== "string" || env2.AUTH_TOKEN.length === 0) { | ||
| 1109 | return json({ error: "misconfigured_auth_token" }, 500); | ||
| 1110 | } | ||
| 1111 | if (request.headers.get("authorization") !== `Bearer ${env2.AUTH_TOKEN}`) { | ||
| 1112 | return json({ error: "unauthorized" }, 401); | ||
| 1113 | } | ||
| 1114 | const payloadRaw = await request.json().catch(() => null); | ||
| 1115 | const payload = validateRunRequest(payloadRaw); | ||
| 1116 | if (!payload) { | ||
| 1117 | return json({ error: "invalid_payload" }, 400); | ||
| 1118 | } | ||
| 1119 | const runResult = await executeSandboxRun(payload, env2); | ||
| 1120 | return json(runResult, 200); | ||
| 1121 | } | ||
| 1122 | }; | ||
| 1123 | |||
| 1124 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts | ||
| 1125 | var drainBody = /* @__PURE__ */ __name(async (request, env2, _ctx, middlewareCtx) => { | ||
| 1126 | try { | ||
| 1127 | return await middlewareCtx.next(request, env2); | ||
| 1128 | } finally { | ||
| 1129 | try { | ||
| 1130 | if (request.body !== null && !request.bodyUsed) { | ||
| 1131 | const reader = request.body.getReader(); | ||
| 1132 | while (!(await reader.read()).done) { | ||
| 1133 | } | ||
| 1134 | } | ||
| 1135 | } catch (e) { | ||
| 1136 | console.error("Failed to drain the unused request body.", e); | ||
| 1137 | } | ||
| 1138 | } | ||
| 1139 | }, "drainBody"); | ||
| 1140 | var middleware_ensure_req_body_drained_default = drainBody; | ||
| 1141 | |||
| 1142 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts | ||
| 1143 | function reduceError(e) { | ||
| 1144 | return { | ||
| 1145 | name: e?.name, | ||
| 1146 | message: e?.message ?? String(e), | ||
| 1147 | stack: e?.stack, | ||
| 1148 | cause: e?.cause === void 0 ? void 0 : reduceError(e.cause) | ||
| 1149 | }; | ||
| 1150 | } | ||
| 1151 | __name(reduceError, "reduceError"); | ||
| 1152 | var jsonError = /* @__PURE__ */ __name(async (request, env2, _ctx, middlewareCtx) => { | ||
| 1153 | try { | ||
| 1154 | return await middlewareCtx.next(request, env2); | ||
| 1155 | } catch (e) { | ||
| 1156 | const error3 = reduceError(e); | ||
| 1157 | return Response.json(error3, { | ||
| 1158 | status: 500, | ||
| 1159 | headers: { "MF-Experimental-Error-Stack": "true" } | ||
| 1160 | }); | ||
| 1161 | } | ||
| 1162 | }, "jsonError"); | ||
| 1163 | var middleware_miniflare3_json_error_default = jsonError; | ||
| 1164 | |||
| 1165 | // .wrangler/tmp/bundle-gLJWNP/middleware-insertion-facade.js | ||
| 1166 | var __INTERNAL_WRANGLER_MIDDLEWARE__ = [ | ||
| 1167 | middleware_ensure_req_body_drained_default, | ||
| 1168 | middleware_miniflare3_json_error_default | ||
| 1169 | ]; | ||
| 1170 | var middleware_insertion_facade_default = src_default; | ||
| 1171 | |||
| 1172 | // ../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/common.ts | ||
| 1173 | var __facade_middleware__ = []; | ||
| 1174 | function __facade_register__(...args) { | ||
| 1175 | __facade_middleware__.push(...args.flat()); | ||
| 1176 | } | ||
| 1177 | __name(__facade_register__, "__facade_register__"); | ||
| 1178 | function __facade_invokeChain__(request, env2, ctx, dispatch, middlewareChain) { | ||
| 1179 | const [head, ...tail] = middlewareChain; | ||
| 1180 | const middlewareCtx = { | ||
| 1181 | dispatch, | ||
| 1182 | next(newRequest, newEnv) { | ||
| 1183 | return __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail); | ||
| 1184 | } | ||
| 1185 | }; | ||
| 1186 | return head(request, env2, ctx, middlewareCtx); | ||
| 1187 | } | ||
| 1188 | __name(__facade_invokeChain__, "__facade_invokeChain__"); | ||
| 1189 | function __facade_invoke__(request, env2, ctx, dispatch, finalMiddleware) { | ||
| 1190 | return __facade_invokeChain__(request, env2, ctx, dispatch, [ | ||
| 1191 | ...__facade_middleware__, | ||
| 1192 | finalMiddleware | ||
| 1193 | ]); | ||
| 1194 | } | ||
| 1195 | __name(__facade_invoke__, "__facade_invoke__"); | ||
| 1196 | |||
| 1197 | // .wrangler/tmp/bundle-gLJWNP/middleware-loader.entry.ts | ||
| 1198 | var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ { | ||
| 1199 | constructor(scheduledTime, cron, noRetry) { | ||
| 1200 | this.scheduledTime = scheduledTime; | ||
| 1201 | this.cron = cron; | ||
| 1202 | this.#noRetry = noRetry; | ||
| 1203 | } | ||
| 1204 | static { | ||
| 1205 | __name(this, "__Facade_ScheduledController__"); | ||
| 1206 | } | ||
| 1207 | #noRetry; | ||
| 1208 | noRetry() { | ||
| 1209 | if (!(this instanceof ___Facade_ScheduledController__)) { | ||
| 1210 | throw new TypeError("Illegal invocation"); | ||
| 1211 | } | ||
| 1212 | this.#noRetry(); | ||
| 1213 | } | ||
| 1214 | }; | ||
| 1215 | function wrapExportedHandler(worker) { | ||
| 1216 | if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) { | ||
| 1217 | return worker; | ||
| 1218 | } | ||
| 1219 | for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) { | ||
| 1220 | __facade_register__(middleware); | ||
| 1221 | } | ||
| 1222 | const fetchDispatcher = /* @__PURE__ */ __name(function(request, env2, ctx) { | ||
| 1223 | if (worker.fetch === void 0) { | ||
| 1224 | throw new Error("Handler does not export a fetch() function."); | ||
| 1225 | } | ||
| 1226 | return worker.fetch(request, env2, ctx); | ||
| 1227 | }, "fetchDispatcher"); | ||
| 1228 | return { | ||
| 1229 | ...worker, | ||
| 1230 | fetch(request, env2, ctx) { | ||
| 1231 | const dispatcher = /* @__PURE__ */ __name(function(type, init) { | ||
| 1232 | if (type === "scheduled" && worker.scheduled !== void 0) { | ||
| 1233 | const controller = new __Facade_ScheduledController__( | ||
| 1234 | Date.now(), | ||
| 1235 | init.cron ?? "", | ||
| 1236 | () => { | ||
| 1237 | } | ||
| 1238 | ); | ||
| 1239 | return worker.scheduled(controller, env2, ctx); | ||
| 1240 | } | ||
| 1241 | }, "dispatcher"); | ||
| 1242 | return __facade_invoke__(request, env2, ctx, dispatcher, fetchDispatcher); | ||
| 1243 | } | ||
| 1244 | }; | ||
| 1245 | } | ||
| 1246 | __name(wrapExportedHandler, "wrapExportedHandler"); | ||
| 1247 | function wrapWorkerEntrypoint(klass) { | ||
| 1248 | if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) { | ||
| 1249 | return klass; | ||
| 1250 | } | ||
| 1251 | for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) { | ||
| 1252 | __facade_register__(middleware); | ||
| 1253 | } | ||
| 1254 | return class extends klass { | ||
| 1255 | #fetchDispatcher = /* @__PURE__ */ __name((request, env2, ctx) => { | ||
| 1256 | this.env = env2; | ||
| 1257 | this.ctx = ctx; | ||
| 1258 | if (super.fetch === void 0) { | ||
| 1259 | throw new Error("Entrypoint class does not define a fetch() function."); | ||
| 1260 | } | ||
| 1261 | return super.fetch(request); | ||
| 1262 | }, "#fetchDispatcher"); | ||
| 1263 | #dispatcher = /* @__PURE__ */ __name((type, init) => { | ||
| 1264 | if (type === "scheduled" && super.scheduled !== void 0) { | ||
| 1265 | const controller = new __Facade_ScheduledController__( | ||
| 1266 | Date.now(), | ||
| 1267 | init.cron ?? "", | ||
| 1268 | () => { | ||
| 1269 | } | ||
| 1270 | ); | ||
| 1271 | return super.scheduled(controller); | ||
| 1272 | } | ||
| 1273 | }, "#dispatcher"); | ||
| 1274 | fetch(request) { | ||
| 1275 | return __facade_invoke__( | ||
| 1276 | request, | ||
| 1277 | this.env, | ||
| 1278 | this.ctx, | ||
| 1279 | this.#dispatcher, | ||
| 1280 | this.#fetchDispatcher | ||
| 1281 | ); | ||
| 1282 | } | ||
| 1283 | }; | ||
| 1284 | } | ||
| 1285 | __name(wrapWorkerEntrypoint, "wrapWorkerEntrypoint"); | ||
| 1286 | var WRAPPED_ENTRY; | ||
| 1287 | if (typeof middleware_insertion_facade_default === "object") { | ||
| 1288 | WRAPPED_ENTRY = wrapExportedHandler(middleware_insertion_facade_default); | ||
| 1289 | } else if (typeof middleware_insertion_facade_default === "function") { | ||
| 1290 | WRAPPED_ENTRY = wrapWorkerEntrypoint(middleware_insertion_facade_default); | ||
| 1291 | } | ||
| 1292 | var middleware_loader_entry_default = WRAPPED_ENTRY; | ||
| 1293 | export { | ||
| 1294 | ToolBridge, | ||
| 1295 | __INTERNAL_WRANGLER_MIDDLEWARE__, | ||
| 1296 | middleware_loader_entry_default as default | ||
| 1297 | }; | ||
| 1298 | //# sourceMappingURL=index.js.map | ||
| @@ -1,8 +0,0 @@ | |||
| 1 | { | ||
| 2 | "version": 3, | ||
| 3 | "sources": ["../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/_internal/utils.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/perf_hooks/performance.mjs", "../../../../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/polyfill/performance.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/console.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/mock/noop.mjs", "../../../../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/node/console.mjs", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-console", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/hrtime.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/process.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/read-stream.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/write-stream.mjs", "../../../../../../node_modules/.bun/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/process/node-version.mjs", "../../../../../../node_modules/.bun/@cloudflare+unenv-preset@2.14.0+0c8c89b48980e762/node_modules/@cloudflare/unenv-preset/dist/runtime/node/process.mjs", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-process", "../../../src/index.ts", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts", "../bundle-gLJWNP/middleware-insertion-facade.js", "../../../../../../node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/common.ts", "../bundle-gLJWNP/middleware-loader.entry.ts"], | ||
| 4 | "sourceRoot": "/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/dev-sFpjNV", | ||
| 5 | "sourcesContent": ["/* @__NO_SIDE_EFFECTS__ */\nexport function rawHeaders(headers) {\n\tconst rawHeaders = [];\n\tfor (const key in headers) {\n\t\tif (Array.isArray(headers[key])) {\n\t\t\tfor (const h of headers[key]) {\n\t\t\t\trawHeaders.push(key, h);\n\t\t\t}\n\t\t} else {\n\t\t\trawHeaders.push(key, headers[key]);\n\t\t}\n\t}\n\treturn rawHeaders;\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function mergeFns(...functions) {\n\treturn function(...args) {\n\t\tfor (const fn of functions) {\n\t\t\tfn(...args);\n\t\t}\n\t};\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function createNotImplementedError(name) {\n\treturn new Error(`[unenv] ${name} is not implemented yet!`);\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function notImplemented(name) {\n\tconst fn = () => {\n\t\tthrow createNotImplementedError(name);\n\t};\n\treturn Object.assign(fn, { __unenv__: true });\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function notImplementedAsync(name) {\n\tconst fn = notImplemented(name);\n\tfn.__promisify__ = () => notImplemented(name + \".__promisify__\");\n\tfn.native = fn;\n\treturn fn;\n}\n/* @__NO_SIDE_EFFECTS__ */\nexport function notImplementedClass(name) {\n\treturn class {\n\t\t__unenv__ = true;\n\t\tconstructor() {\n\t\t\tthrow new Error(`[unenv] ${name} is not implemented yet!`);\n\t\t}\n\t};\n}\n", "import { createNotImplementedError } from \"../../../_internal/utils.mjs\";\nconst _timeOrigin = globalThis.performance?.timeOrigin ?? Date.now();\nconst _performanceNow = globalThis.performance?.now ? globalThis.performance.now.bind(globalThis.performance) : () => Date.now() - _timeOrigin;\nconst nodeTiming = {\n\tname: \"node\",\n\tentryType: \"node\",\n\tstartTime: 0,\n\tduration: 0,\n\tnodeStart: 0,\n\tv8Start: 0,\n\tbootstrapComplete: 0,\n\tenvironment: 0,\n\tloopStart: 0,\n\tloopExit: 0,\n\tidleTime: 0,\n\tuvMetricsInfo: {\n\t\tloopCount: 0,\n\t\tevents: 0,\n\t\teventsWaiting: 0\n\t},\n\tdetail: undefined,\n\ttoJSON() {\n\t\treturn this;\n\t}\n};\n// PerformanceEntry\nexport class PerformanceEntry {\n\t__unenv__ = true;\n\tdetail;\n\tentryType = \"event\";\n\tname;\n\tstartTime;\n\tconstructor(name, options) {\n\t\tthis.name = name;\n\t\tthis.startTime = options?.startTime || _performanceNow();\n\t\tthis.detail = options?.detail;\n\t}\n\tget duration() {\n\t\treturn _performanceNow() - this.startTime;\n\t}\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tentryType: this.entryType,\n\t\t\tstartTime: this.startTime,\n\t\t\tduration: this.duration,\n\t\t\tdetail: this.detail\n\t\t};\n\t}\n}\n// PerformanceMark\nexport const PerformanceMark = class PerformanceMark extends PerformanceEntry {\n\tentryType = \"mark\";\n\tconstructor() {\n\t\t// @ts-ignore\n\t\tsuper(...arguments);\n\t}\n\tget duration() {\n\t\treturn 0;\n\t}\n};\n// PerformanceMark\nexport class PerformanceMeasure extends PerformanceEntry {\n\tentryType = \"measure\";\n}\n// PerformanceResourceTiming\nexport class PerformanceResourceTiming extends PerformanceEntry {\n\tentryType = \"resource\";\n\tserverTiming = [];\n\tconnectEnd = 0;\n\tconnectStart = 0;\n\tdecodedBodySize = 0;\n\tdomainLookupEnd = 0;\n\tdomainLookupStart = 0;\n\tencodedBodySize = 0;\n\tfetchStart = 0;\n\tinitiatorType = \"\";\n\tname = \"\";\n\tnextHopProtocol = \"\";\n\tredirectEnd = 0;\n\tredirectStart = 0;\n\trequestStart = 0;\n\tresponseEnd = 0;\n\tresponseStart = 0;\n\tsecureConnectionStart = 0;\n\tstartTime = 0;\n\ttransferSize = 0;\n\tworkerStart = 0;\n\tresponseStatus = 0;\n}\n// PerformanceObserverEntryList\nexport class PerformanceObserverEntryList {\n\t__unenv__ = true;\n\tgetEntries() {\n\t\treturn [];\n\t}\n\tgetEntriesByName(_name, _type) {\n\t\treturn [];\n\t}\n\tgetEntriesByType(type) {\n\t\treturn [];\n\t}\n}\n// Performance\nexport class Performance {\n\t__unenv__ = true;\n\ttimeOrigin = _timeOrigin;\n\teventCounts = new Map();\n\t_entries = [];\n\t_resourceTimingBufferSize = 0;\n\tnavigation = undefined;\n\ttiming = undefined;\n\ttimerify(_fn, _options) {\n\t\tthrow createNotImplementedError(\"Performance.timerify\");\n\t}\n\tget nodeTiming() {\n\t\treturn nodeTiming;\n\t}\n\teventLoopUtilization() {\n\t\treturn {};\n\t}\n\tmarkResourceTiming() {\n\t\t// TODO: create a new PerformanceResourceTiming entry\n\t\t// so that performance.getEntries, getEntriesByName, and getEntriesByType return it\n\t\t// see: https://nodejs.org/api/perf_hooks.html#performancemarkresourcetimingtiminginfo-requestedurl-initiatortype-global-cachemode-bodyinfo-responsestatus-deliverytype\n\t\treturn new PerformanceResourceTiming(\"\");\n\t}\n\tonresourcetimingbufferfull = null;\n\tnow() {\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Performance/now\n\t\tif (this.timeOrigin === _timeOrigin) {\n\t\t\treturn _performanceNow();\n\t\t}\n\t\treturn Date.now() - this.timeOrigin;\n\t}\n\tclearMarks(markName) {\n\t\tthis._entries = markName ? this._entries.filter((e) => e.name !== markName) : this._entries.filter((e) => e.entryType !== \"mark\");\n\t}\n\tclearMeasures(measureName) {\n\t\tthis._entries = measureName ? this._entries.filter((e) => e.name !== measureName) : this._entries.filter((e) => e.entryType !== \"measure\");\n\t}\n\tclearResourceTimings() {\n\t\tthis._entries = this._entries.filter((e) => e.entryType !== \"resource\" || e.entryType !== \"navigation\");\n\t}\n\tgetEntries() {\n\t\treturn this._entries;\n\t}\n\tgetEntriesByName(name, type) {\n\t\treturn this._entries.filter((e) => e.name === name && (!type || e.entryType === type));\n\t}\n\tgetEntriesByType(type) {\n\t\treturn this._entries.filter((e) => e.entryType === type);\n\t}\n\tmark(name, options) {\n\t\t// @ts-expect-error constructor is not protected\n\t\tconst entry = new PerformanceMark(name, options);\n\t\tthis._entries.push(entry);\n\t\treturn entry;\n\t}\n\tmeasure(measureName, startOrMeasureOptions, endMark) {\n\t\tlet start;\n\t\tlet end;\n\t\tif (typeof startOrMeasureOptions === \"string\") {\n\t\t\tstart = this.getEntriesByName(startOrMeasureOptions, \"mark\")[0]?.startTime;\n\t\t\tend = this.getEntriesByName(endMark, \"mark\")[0]?.startTime;\n\t\t} else {\n\t\t\tstart = Number.parseFloat(startOrMeasureOptions?.start) || this.now();\n\t\t\tend = Number.parseFloat(startOrMeasureOptions?.end) || this.now();\n\t\t}\n\t\tconst entry = new PerformanceMeasure(measureName, {\n\t\t\tstartTime: start,\n\t\t\tdetail: {\n\t\t\t\tstart,\n\t\t\t\tend\n\t\t\t}\n\t\t});\n\t\tthis._entries.push(entry);\n\t\treturn entry;\n\t}\n\tsetResourceTimingBufferSize(maxSize) {\n\t\tthis._resourceTimingBufferSize = maxSize;\n\t}\n\taddEventListener(type, listener, options) {\n\t\tthrow createNotImplementedError(\"Performance.addEventListener\");\n\t}\n\tremoveEventListener(type, listener, options) {\n\t\tthrow createNotImplementedError(\"Performance.removeEventListener\");\n\t}\n\tdispatchEvent(event) {\n\t\tthrow createNotImplementedError(\"Performance.dispatchEvent\");\n\t}\n\ttoJSON() {\n\t\treturn this;\n\t}\n}\n// PerformanceObserver\nexport class PerformanceObserver {\n\t__unenv__ = true;\n\tstatic supportedEntryTypes = [];\n\t_callback = null;\n\tconstructor(callback) {\n\t\tthis._callback = callback;\n\t}\n\ttakeRecords() {\n\t\treturn [];\n\t}\n\tdisconnect() {\n\t\tthrow createNotImplementedError(\"PerformanceObserver.disconnect\");\n\t}\n\tobserve(options) {\n\t\tthrow createNotImplementedError(\"PerformanceObserver.observe\");\n\t}\n\tbind(fn) {\n\t\treturn fn;\n\t}\n\trunInAsyncScope(fn, thisArg, ...args) {\n\t\treturn fn.call(thisArg, ...args);\n\t}\n\tasyncId() {\n\t\treturn 0;\n\t}\n\ttriggerAsyncId() {\n\t\treturn 0;\n\t}\n\temitDestroy() {\n\t\treturn this;\n\t}\n}\n// workerd implements a subset of globalThis.performance (as of last check, only timeOrigin set to 0 + now() implemented)\n// We already use performance.now() from globalThis.performance, if provided (see top of this file)\n// If we detect this condition, we can just use polyfill instead.\nexport const performance = globalThis.performance && \"addEventListener\" in globalThis.performance ? globalThis.performance : new Performance();\n", "import {\n performance,\n Performance,\n PerformanceEntry,\n PerformanceMark,\n PerformanceMeasure,\n PerformanceObserver,\n PerformanceObserverEntryList,\n PerformanceResourceTiming\n} from \"node:perf_hooks\";\nglobalThis.performance = performance;\nglobalThis.Performance = Performance;\nglobalThis.PerformanceEntry = PerformanceEntry;\nglobalThis.PerformanceMark = PerformanceMark;\nglobalThis.PerformanceMeasure = PerformanceMeasure;\nglobalThis.PerformanceObserver = PerformanceObserver;\nglobalThis.PerformanceObserverEntryList = PerformanceObserverEntryList;\nglobalThis.PerformanceResourceTiming = PerformanceResourceTiming;\n", "import { Writable } from \"node:stream\";\nimport noop from \"../mock/noop.mjs\";\nimport { notImplemented, notImplementedClass } from \"../_internal/utils.mjs\";\nconst _console = globalThis.console;\n// undocumented public APIs\nexport const _ignoreErrors = true;\nexport const _stderr = new Writable();\nexport const _stdout = new Writable();\nexport const log = _console?.log ?? noop;\nexport const info = _console?.info ?? log;\nexport const trace = _console?.trace ?? info;\nexport const debug = _console?.debug ?? log;\nexport const table = _console?.table ?? log;\nexport const error = _console?.error ?? log;\nexport const warn = _console?.warn ?? error;\n// https://developer.chrome.com/docs/devtools/console/api#createtask\nexport const createTask = _console?.createTask ?? /* @__PURE__ */ notImplemented(\"console.createTask\");\nexport const assert = /* @__PURE__ */ notImplemented(\"console.assert\");\n// noop\nexport const clear = _console?.clear ?? noop;\nexport const count = _console?.count ?? noop;\nexport const countReset = _console?.countReset ?? noop;\nexport const dir = _console?.dir ?? noop;\nexport const dirxml = _console?.dirxml ?? noop;\nexport const group = _console?.group ?? noop;\nexport const groupEnd = _console?.groupEnd ?? noop;\nexport const groupCollapsed = _console?.groupCollapsed ?? noop;\nexport const profile = _console?.profile ?? noop;\nexport const profileEnd = _console?.profileEnd ?? noop;\nexport const time = _console?.time ?? noop;\nexport const timeEnd = _console?.timeEnd ?? noop;\nexport const timeLog = _console?.timeLog ?? noop;\nexport const timeStamp = _console?.timeStamp ?? noop;\nexport const Console = _console?.Console ?? /* @__PURE__ */ notImplementedClass(\"console.Console\");\nexport const _times = /* @__PURE__ */ new Map();\nexport function context() {\n\t// TODO: Should be Console with all the methods\n\treturn _console;\n}\nexport const _stdoutErrorHandler = noop;\nexport const _stderrErrorHandler = noop;\nexport default {\n\t_times,\n\t_ignoreErrors,\n\t_stdoutErrorHandler,\n\t_stderrErrorHandler,\n\t_stdout,\n\t_stderr,\n\tassert,\n\tclear,\n\tConsole,\n\tcount,\n\tcountReset,\n\tdebug,\n\tdir,\n\tdirxml,\n\terror,\n\tcontext,\n\tcreateTask,\n\tgroup,\n\tgroupEnd,\n\tgroupCollapsed,\n\tinfo,\n\tlog,\n\tprofile,\n\tprofileEnd,\n\ttable,\n\ttime,\n\ttimeEnd,\n\ttimeLog,\n\ttimeStamp,\n\ttrace,\n\twarn\n};\n", "export default Object.assign(() => {}, { __unenv__: true });\n", "import {\n _ignoreErrors,\n _stderr,\n _stderrErrorHandler,\n _stdout,\n _stdoutErrorHandler,\n _times,\n Console\n} from \"unenv/node/console\";\nexport {\n Console,\n _ignoreErrors,\n _stderr,\n _stderrErrorHandler,\n _stdout,\n _stdoutErrorHandler,\n _times\n} from \"unenv/node/console\";\nconst workerdConsole = globalThis[\"console\"];\nexport const {\n assert,\n clear,\n // @ts-expect-error undocumented public API\n context,\n count,\n countReset,\n // @ts-expect-error undocumented public API\n createTask,\n debug,\n dir,\n dirxml,\n error,\n group,\n groupCollapsed,\n groupEnd,\n info,\n log,\n profile,\n profileEnd,\n table,\n time,\n timeEnd,\n timeLog,\n timeStamp,\n trace,\n warn\n} = workerdConsole;\nObject.assign(workerdConsole, {\n Console,\n _ignoreErrors,\n _stderr,\n _stderrErrorHandler,\n _stdout,\n _stdoutErrorHandler,\n _times\n});\nexport default workerdConsole;\n", "import { default as defaultExport } from \"@cloudflare/unenv-preset/node/console\";\nglobalThis.console = defaultExport;", "// https://nodejs.org/api/process.html#processhrtime\nexport const hrtime = /* @__PURE__ */ Object.assign(function hrtime(startTime) {\n\tconst now = Date.now();\n\t// millis to seconds\n\tconst seconds = Math.trunc(now / 1e3);\n\t// convert millis to nanos\n\tconst nanos = now % 1e3 * 1e6;\n\tif (startTime) {\n\t\tlet diffSeconds = seconds - startTime[0];\n\t\tlet diffNanos = nanos - startTime[0];\n\t\tif (diffNanos < 0) {\n\t\t\tdiffSeconds = diffSeconds - 1;\n\t\t\tdiffNanos = 1e9 + diffNanos;\n\t\t}\n\t\treturn [diffSeconds, diffNanos];\n\t}\n\treturn [seconds, nanos];\n}, { bigint: function bigint() {\n\t// Convert milliseconds to nanoseconds\n\treturn BigInt(Date.now() * 1e6);\n} });\n", "import { EventEmitter } from \"node:events\";\nimport { ReadStream, WriteStream } from \"node:tty\";\nimport { notImplemented, createNotImplementedError } from \"../../../_internal/utils.mjs\";\n// node-version.ts is generated at build time\nimport { NODE_VERSION } from \"./node-version.mjs\";\nexport class Process extends EventEmitter {\n\tenv;\n\thrtime;\n\tnextTick;\n\tconstructor(impl) {\n\t\tsuper();\n\t\tthis.env = impl.env;\n\t\tthis.hrtime = impl.hrtime;\n\t\tthis.nextTick = impl.nextTick;\n\t\tfor (const prop of [...Object.getOwnPropertyNames(Process.prototype), ...Object.getOwnPropertyNames(EventEmitter.prototype)]) {\n\t\t\tconst value = this[prop];\n\t\t\tif (typeof value === \"function\") {\n\t\t\t\tthis[prop] = value.bind(this);\n\t\t\t}\n\t\t}\n\t}\n\t// --- event emitter ---\n\temitWarning(warning, type, code) {\n\t\tconsole.warn(`${code ? `[${code}] ` : \"\"}${type ? `${type}: ` : \"\"}${warning}`);\n\t}\n\temit(...args) {\n\t\t// @ts-ignore\n\t\treturn super.emit(...args);\n\t}\n\tlisteners(eventName) {\n\t\treturn super.listeners(eventName);\n\t}\n\t// --- stdio (lazy initializers) ---\n\t#stdin;\n\t#stdout;\n\t#stderr;\n\tget stdin() {\n\t\treturn this.#stdin ??= new ReadStream(0);\n\t}\n\tget stdout() {\n\t\treturn this.#stdout ??= new WriteStream(1);\n\t}\n\tget stderr() {\n\t\treturn this.#stderr ??= new WriteStream(2);\n\t}\n\t// --- cwd ---\n\t#cwd = \"/\";\n\tchdir(cwd) {\n\t\tthis.#cwd = cwd;\n\t}\n\tcwd() {\n\t\treturn this.#cwd;\n\t}\n\t// --- dummy props and getters ---\n\tarch = \"\";\n\tplatform = \"\";\n\targv = [];\n\targv0 = \"\";\n\texecArgv = [];\n\texecPath = \"\";\n\ttitle = \"\";\n\tpid = 200;\n\tppid = 100;\n\tget version() {\n\t\treturn `v${NODE_VERSION}`;\n\t}\n\tget versions() {\n\t\treturn { node: NODE_VERSION };\n\t}\n\tget allowedNodeEnvironmentFlags() {\n\t\treturn new Set();\n\t}\n\tget sourceMapsEnabled() {\n\t\treturn false;\n\t}\n\tget debugPort() {\n\t\treturn 0;\n\t}\n\tget throwDeprecation() {\n\t\treturn false;\n\t}\n\tget traceDeprecation() {\n\t\treturn false;\n\t}\n\tget features() {\n\t\treturn {};\n\t}\n\tget release() {\n\t\treturn {};\n\t}\n\tget connected() {\n\t\treturn false;\n\t}\n\tget config() {\n\t\treturn {};\n\t}\n\tget moduleLoadList() {\n\t\treturn [];\n\t}\n\tconstrainedMemory() {\n\t\treturn 0;\n\t}\n\tavailableMemory() {\n\t\treturn 0;\n\t}\n\tuptime() {\n\t\treturn 0;\n\t}\n\tresourceUsage() {\n\t\treturn {};\n\t}\n\t// --- noop methods ---\n\tref() {\n\t\t// noop\n\t}\n\tunref() {\n\t\t// noop\n\t}\n\t// --- unimplemented methods ---\n\tumask() {\n\t\tthrow createNotImplementedError(\"process.umask\");\n\t}\n\tgetBuiltinModule() {\n\t\treturn undefined;\n\t}\n\tgetActiveResourcesInfo() {\n\t\tthrow createNotImplementedError(\"process.getActiveResourcesInfo\");\n\t}\n\texit() {\n\t\tthrow createNotImplementedError(\"process.exit\");\n\t}\n\treallyExit() {\n\t\tthrow createNotImplementedError(\"process.reallyExit\");\n\t}\n\tkill() {\n\t\tthrow createNotImplementedError(\"process.kill\");\n\t}\n\tabort() {\n\t\tthrow createNotImplementedError(\"process.abort\");\n\t}\n\tdlopen() {\n\t\tthrow createNotImplementedError(\"process.dlopen\");\n\t}\n\tsetSourceMapsEnabled() {\n\t\tthrow createNotImplementedError(\"process.setSourceMapsEnabled\");\n\t}\n\tloadEnvFile() {\n\t\tthrow createNotImplementedError(\"process.loadEnvFile\");\n\t}\n\tdisconnect() {\n\t\tthrow createNotImplementedError(\"process.disconnect\");\n\t}\n\tcpuUsage() {\n\t\tthrow createNotImplementedError(\"process.cpuUsage\");\n\t}\n\tsetUncaughtExceptionCaptureCallback() {\n\t\tthrow createNotImplementedError(\"process.setUncaughtExceptionCaptureCallback\");\n\t}\n\thasUncaughtExceptionCaptureCallback() {\n\t\tthrow createNotImplementedError(\"process.hasUncaughtExceptionCaptureCallback\");\n\t}\n\tinitgroups() {\n\t\tthrow createNotImplementedError(\"process.initgroups\");\n\t}\n\topenStdin() {\n\t\tthrow createNotImplementedError(\"process.openStdin\");\n\t}\n\tassert() {\n\t\tthrow createNotImplementedError(\"process.assert\");\n\t}\n\tbinding() {\n\t\tthrow createNotImplementedError(\"process.binding\");\n\t}\n\t// --- attached interfaces ---\n\tpermission = { has: /* @__PURE__ */ notImplemented(\"process.permission.has\") };\n\treport = {\n\t\tdirectory: \"\",\n\t\tfilename: \"\",\n\t\tsignal: \"SIGUSR2\",\n\t\tcompact: false,\n\t\treportOnFatalError: false,\n\t\treportOnSignal: false,\n\t\treportOnUncaughtException: false,\n\t\tgetReport: /* @__PURE__ */ notImplemented(\"process.report.getReport\"),\n\t\twriteReport: /* @__PURE__ */ notImplemented(\"process.report.writeReport\")\n\t};\n\tfinalization = {\n\t\tregister: /* @__PURE__ */ notImplemented(\"process.finalization.register\"),\n\t\tunregister: /* @__PURE__ */ notImplemented(\"process.finalization.unregister\"),\n\t\tregisterBeforeExit: /* @__PURE__ */ notImplemented(\"process.finalization.registerBeforeExit\")\n\t};\n\tmemoryUsage = Object.assign(() => ({\n\t\tarrayBuffers: 0,\n\t\trss: 0,\n\t\texternal: 0,\n\t\theapTotal: 0,\n\t\theapUsed: 0\n\t}), { rss: () => 0 });\n\t// --- undefined props ---\n\tmainModule = undefined;\n\tdomain = undefined;\n\t// optional\n\tsend = undefined;\n\texitCode = undefined;\n\tchannel = undefined;\n\tgetegid = undefined;\n\tgeteuid = undefined;\n\tgetgid = undefined;\n\tgetgroups = undefined;\n\tgetuid = undefined;\n\tsetegid = undefined;\n\tseteuid = undefined;\n\tsetgid = undefined;\n\tsetgroups = undefined;\n\tsetuid = undefined;\n\t// internals\n\t_events = undefined;\n\t_eventsCount = undefined;\n\t_exiting = undefined;\n\t_maxListeners = undefined;\n\t_debugEnd = undefined;\n\t_debugProcess = undefined;\n\t_fatalException = undefined;\n\t_getActiveHandles = undefined;\n\t_getActiveRequests = undefined;\n\t_kill = undefined;\n\t_preload_modules = undefined;\n\t_rawDebug = undefined;\n\t_startProfilerIdleNotifier = undefined;\n\t_stopProfilerIdleNotifier = undefined;\n\t_tickCallback = undefined;\n\t_disconnect = undefined;\n\t_handleQueue = undefined;\n\t_pendingMessage = undefined;\n\t_channel = undefined;\n\t_send = undefined;\n\t_linkedBinding = undefined;\n}\n", "export class ReadStream {\n\tfd;\n\tisRaw = false;\n\tisTTY = false;\n\tconstructor(fd) {\n\t\tthis.fd = fd;\n\t}\n\tsetRawMode(mode) {\n\t\tthis.isRaw = mode;\n\t\treturn this;\n\t}\n}\n", "export class WriteStream {\n\tfd;\n\tcolumns = 80;\n\trows = 24;\n\tisTTY = false;\n\tconstructor(fd) {\n\t\tthis.fd = fd;\n\t}\n\tclearLine(dir, callback) {\n\t\tcallback && callback();\n\t\treturn false;\n\t}\n\tclearScreenDown(callback) {\n\t\tcallback && callback();\n\t\treturn false;\n\t}\n\tcursorTo(x, y, callback) {\n\t\tcallback && typeof callback === \"function\" && callback();\n\t\treturn false;\n\t}\n\tmoveCursor(dx, dy, callback) {\n\t\tcallback && callback();\n\t\treturn false;\n\t}\n\tgetColorDepth(env) {\n\t\treturn 1;\n\t}\n\thasColors(count, env) {\n\t\treturn false;\n\t}\n\tgetWindowSize() {\n\t\treturn [this.columns, this.rows];\n\t}\n\twrite(str, encoding, cb) {\n\t\tif (str instanceof Uint8Array) {\n\t\t\tstr = new TextDecoder().decode(str);\n\t\t}\n\t\ttry {\n\t\t\tconsole.log(str);\n\t\t} catch {}\n\t\tcb && typeof cb === \"function\" && cb();\n\t\treturn false;\n\t}\n}\n", "// Extracted from .nvmrc\nexport const NODE_VERSION = \"22.14.0\";\n", "import { hrtime as UnenvHrTime } from \"unenv/node/internal/process/hrtime\";\nimport { Process as UnenvProcess } from \"unenv/node/internal/process/process\";\nconst globalProcess = globalThis[\"process\"];\nexport const getBuiltinModule = globalProcess.getBuiltinModule;\nconst workerdProcess = getBuiltinModule(\"node:process\");\nconst unenvProcess = new UnenvProcess({\n env: globalProcess.env,\n hrtime: UnenvHrTime,\n // `nextTick` is available from workerd process v1\n nextTick: workerdProcess.nextTick\n});\nexport const { exit, features, platform } = workerdProcess;\nexport const {\n _channel,\n _debugEnd,\n _debugProcess,\n _disconnect,\n _events,\n _eventsCount,\n _exiting,\n _fatalException,\n _getActiveHandles,\n _getActiveRequests,\n _handleQueue,\n _kill,\n _linkedBinding,\n _maxListeners,\n _pendingMessage,\n _preload_modules,\n _rawDebug,\n _send,\n _startProfilerIdleNotifier,\n _stopProfilerIdleNotifier,\n _tickCallback,\n abort,\n addListener,\n allowedNodeEnvironmentFlags,\n arch,\n argv,\n argv0,\n assert,\n availableMemory,\n binding,\n channel,\n chdir,\n config,\n connected,\n constrainedMemory,\n cpuUsage,\n cwd,\n debugPort,\n disconnect,\n dlopen,\n domain,\n emit,\n emitWarning,\n env,\n eventNames,\n execArgv,\n execPath,\n exitCode,\n finalization,\n getActiveResourcesInfo,\n getegid,\n geteuid,\n getgid,\n getgroups,\n getMaxListeners,\n getuid,\n hasUncaughtExceptionCaptureCallback,\n hrtime,\n initgroups,\n kill,\n listenerCount,\n listeners,\n loadEnvFile,\n mainModule,\n memoryUsage,\n moduleLoadList,\n nextTick,\n off,\n on,\n once,\n openStdin,\n permission,\n pid,\n ppid,\n prependListener,\n prependOnceListener,\n rawListeners,\n reallyExit,\n ref,\n release,\n removeAllListeners,\n removeListener,\n report,\n resourceUsage,\n send,\n setegid,\n seteuid,\n setgid,\n setgroups,\n setMaxListeners,\n setSourceMapsEnabled,\n setuid,\n setUncaughtExceptionCaptureCallback,\n sourceMapsEnabled,\n stderr,\n stdin,\n stdout,\n throwDeprecation,\n title,\n traceDeprecation,\n umask,\n unref,\n uptime,\n version,\n versions\n} = unenvProcess;\nconst _process = {\n abort,\n addListener,\n allowedNodeEnvironmentFlags,\n hasUncaughtExceptionCaptureCallback,\n setUncaughtExceptionCaptureCallback,\n loadEnvFile,\n sourceMapsEnabled,\n arch,\n argv,\n argv0,\n chdir,\n config,\n connected,\n constrainedMemory,\n availableMemory,\n cpuUsage,\n cwd,\n debugPort,\n dlopen,\n disconnect,\n emit,\n emitWarning,\n env,\n eventNames,\n execArgv,\n execPath,\n exit,\n finalization,\n features,\n getBuiltinModule,\n getActiveResourcesInfo,\n getMaxListeners,\n hrtime,\n kill,\n listeners,\n listenerCount,\n memoryUsage,\n nextTick,\n on,\n off,\n once,\n pid,\n platform,\n ppid,\n prependListener,\n prependOnceListener,\n rawListeners,\n release,\n removeAllListeners,\n removeListener,\n report,\n resourceUsage,\n setMaxListeners,\n setSourceMapsEnabled,\n stderr,\n stdin,\n stdout,\n title,\n throwDeprecation,\n traceDeprecation,\n umask,\n uptime,\n version,\n versions,\n // @ts-expect-error old API\n domain,\n initgroups,\n moduleLoadList,\n reallyExit,\n openStdin,\n assert,\n binding,\n send,\n exitCode,\n channel,\n getegid,\n geteuid,\n getgid,\n getgroups,\n getuid,\n setegid,\n seteuid,\n setgid,\n setgroups,\n setuid,\n permission,\n mainModule,\n _events,\n _eventsCount,\n _exiting,\n _maxListeners,\n _debugEnd,\n _debugProcess,\n _fatalException,\n _getActiveHandles,\n _getActiveRequests,\n _kill,\n _preload_modules,\n _rawDebug,\n _startProfilerIdleNotifier,\n _stopProfilerIdleNotifier,\n _tickCallback,\n _disconnect,\n _handleQueue,\n _pendingMessage,\n _channel,\n _send,\n _linkedBinding\n};\nexport default _process;\n", "import { default as defaultExport } from \"@cloudflare/unenv-preset/node/process\";\nglobalThis.process = defaultExport;", "import { RpcTarget } from \"cloudflare:workers\";\n\nimport HARNESS_CODE from \"./isolate/harness.isolate.js\";\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst MAX_TIMEOUT_MS = 120_000;\n\ntype RuntimeToolCallResult =\n | {\n ok: true;\n value: unknown;\n }\n | {\n ok: false;\n kind: \"pending\";\n approvalId: string;\n retryAfterMs: number;\n error?: string;\n }\n | {\n ok: false;\n kind: \"denied\";\n error: string;\n }\n | {\n ok: false;\n kind: \"failed\";\n error: string;\n };\n\ntype RunRequest = {\n runId: string;\n taskId: string;\n code: string;\n timeoutMs?: number;\n callback: {\n url: string;\n internalSecret?: string;\n };\n};\n\ntype RunResult = {\n status: \"completed\" | \"failed\" | \"timed_out\" | \"denied\";\n result?: unknown;\n error?: string;\n exitCode?: number;\n};\n\ntype BridgeProps = {\n callbackUrl: string;\n callbackInternalSecret: string | null;\n runId: string;\n};\n\ntype SandboxEntrypoint = {\n evaluate: (bridge: ToolBridge) => Promise<RunResult>;\n};\n\ntype Env = {\n AUTH_TOKEN: string;\n LOADER: {\n get: (\n id: string,\n init: () => Promise<{\n compatibilityDate: string;\n mainModule: string;\n modules: Record<string, string>;\n env: Record<string, unknown>;\n globalOutbound: null;\n }>,\n ) => {\n getEntrypoint: () => SandboxEntrypoint;\n };\n };\n};\n\nconst json = (value: unknown, status = 200): Response =>\n new Response(JSON.stringify(value), {\n status,\n headers: {\n \"content-type\": \"application/json\",\n },\n });\n\nconst isObjectRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isRuntimeToolCallResult = (value: unknown): value is RuntimeToolCallResult => {\n if (!isObjectRecord(value)) {\n return false;\n }\n\n if (value.ok === true) {\n return Object.prototype.hasOwnProperty.call(value, \"value\");\n }\n\n if (value.ok === false && value.kind === \"pending\") {\n return (\n typeof value.approvalId === \"string\" &&\n typeof value.retryAfterMs === \"number\"\n );\n }\n\n if (value.ok === false && value.kind === \"denied\") {\n return typeof value.error === \"string\";\n }\n\n if (value.ok === false && value.kind === \"failed\") {\n return typeof value.error === \"string\";\n }\n\n return false;\n};\n\nconst isRunResult = (value: unknown): value is RunResult => {\n if (!isObjectRecord(value)) {\n return false;\n }\n\n if (\n value.status !== \"completed\" &&\n value.status !== \"failed\" &&\n value.status !== \"timed_out\" &&\n value.status !== \"denied\"\n ) {\n return false;\n }\n\n if (value.error !== undefined && typeof value.error !== \"string\") {\n return false;\n }\n\n if (value.exitCode !== undefined && typeof value.exitCode !== \"number\") {\n return false;\n }\n\n return true;\n};\n\nconst toFailedResult = (error: string): RunResult => ({\n status: \"failed\",\n error,\n});\n\nconst validateRunRequest = (value: unknown): RunRequest | null => {\n if (!isObjectRecord(value)) {\n return null;\n }\n\n if (\n typeof value.runId !== \"string\" ||\n typeof value.taskId !== \"string\" ||\n typeof value.code !== \"string\"\n ) {\n return null;\n }\n\n if (!isObjectRecord(value.callback) || typeof value.callback.url !== \"string\") {\n return null;\n }\n\n if (\n value.callback.internalSecret !== undefined &&\n typeof value.callback.internalSecret !== \"string\"\n ) {\n return null;\n }\n\n if (value.timeoutMs !== undefined && typeof value.timeoutMs !== \"number\") {\n return null;\n }\n\n return {\n runId: value.runId,\n taskId: value.taskId,\n code: value.code,\n timeoutMs: value.timeoutMs,\n callback: {\n url: value.callback.url,\n internalSecret: value.callback.internalSecret,\n },\n };\n};\n\nconst buildUserModule = (userCode: string): string =>\n `export async function run(tools, console) {\\n\"use strict\";\\n${userCode}\\n}\\n`;\n\nclass ToolBridge extends RpcTarget {\n readonly #props: BridgeProps;\n\n constructor(props: BridgeProps) {\n super();\n this.#props = props;\n }\n\n async callTool(\n toolPath: string,\n input: unknown,\n callId: string,\n ): Promise<RuntimeToolCallResult> {\n const headers = new Headers({\n \"content-type\": \"application/json\",\n });\n\n if (this.#props.callbackInternalSecret) {\n headers.set(\"x-internal-secret\", this.#props.callbackInternalSecret);\n }\n\n const response = await fetch(this.#props.callbackUrl, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n runId: this.#props.runId,\n callId,\n toolPath,\n input,\n }),\n }).catch((error: unknown) => {\n throw new Error(\n `Tool callback transport failed: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n });\n\n if (response.status !== 200) {\n return {\n ok: false,\n kind: \"failed\",\n error: `Tool callback returned ${response.status}`,\n };\n }\n\n const payload = await response.json().catch(() => null);\n if (!isRuntimeToolCallResult(payload)) {\n return {\n ok: false,\n kind: \"failed\",\n error: \"Tool callback returned invalid result payload\",\n };\n }\n\n return payload;\n }\n}\n\nconst executeSandboxRun = async (\n request: RunRequest,\n env: Env,\n): Promise<RunResult> => {\n const timeoutMsRaw = request.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const timeoutMs = Math.max(1, Math.min(MAX_TIMEOUT_MS, Math.floor(timeoutMsRaw)));\n\n const toolBridge = new ToolBridge({\n callbackUrl: request.callback.url,\n callbackInternalSecret: request.callback.internalSecret ?? null,\n runId: request.runId,\n });\n\n const worker = env.LOADER.get(request.taskId, async () => ({\n compatibilityDate: \"2025-06-01\",\n mainModule: \"harness.js\",\n modules: {\n \"harness.js\": HARNESS_CODE,\n \"user-code.js\": buildUserModule(request.code),\n },\n env: {},\n globalOutbound: null,\n }));\n\n const entrypoint = worker.getEntrypoint();\n let timer: ReturnType<typeof setTimeout> | null = null;\n\n let payload: RunResult;\n try {\n const timeoutResult = new Promise<RunResult>((resolve) => {\n timer = setTimeout(() => {\n resolve({\n status: \"timed_out\",\n error: `Execution timed out after ${timeoutMs}ms`,\n });\n }, timeoutMs);\n });\n\n payload = await Promise.race([\n entrypoint.evaluate(toolBridge),\n timeoutResult,\n ]);\n } catch (error) {\n if (timer) {\n clearTimeout(timer);\n }\n return toFailedResult(\n `Sandbox isolate execution failed: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n if (timer) {\n clearTimeout(timer);\n }\n\n if (!isRunResult(payload)) {\n return toFailedResult(\"Sandbox isolate returned invalid response payload\");\n }\n\n return payload;\n};\n\nexport { ToolBridge };\n\nexport default {\n async fetch(request: Request, env: Env, _ctx: ExecutionContext): Promise<Response> {\n const url = new URL(request.url);\n\n if (url.pathname === \"/health\") {\n return new Response(\"ok\", { status: 200 });\n }\n\n if (url.pathname !== \"/v1/runs\" || request.method !== \"POST\") {\n return json({ error: \"not_found\" }, 404);\n }\n\n if (typeof env.AUTH_TOKEN !== \"string\" || env.AUTH_TOKEN.length === 0) {\n return json({ error: \"misconfigured_auth_token\" }, 500);\n }\n\n if (request.headers.get(\"authorization\") !== `Bearer ${env.AUTH_TOKEN}`) {\n return json({ error: \"unauthorized\" }, 401);\n }\n\n const payloadRaw = await request.json().catch(() => null);\n const payload = validateRunRequest(payloadRaw);\n if (!payload) {\n return json({ error: \"invalid_payload\" }, 400);\n }\n\n const runResult = await executeSandboxRun(payload, env);\n return json(runResult, 200);\n },\n};\n", "import type { Middleware } from \"./common\";\n\nconst drainBody: Middleware = async (request, env, _ctx, middlewareCtx) => {\n\ttry {\n\t\treturn await middlewareCtx.next(request, env);\n\t} finally {\n\t\ttry {\n\t\t\tif (request.body !== null && !request.bodyUsed) {\n\t\t\t\tconst reader = request.body.getReader();\n\t\t\t\twhile (!(await reader.read()).done) {}\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error(\"Failed to drain the unused request body.\", e);\n\t\t}\n\t}\n};\n\nexport default drainBody;\n", "import type { Middleware } from \"./common\";\n\ninterface JsonError {\n\tmessage?: string;\n\tname?: string;\n\tstack?: string;\n\tcause?: JsonError;\n}\n\nfunction reduceError(e: any): JsonError {\n\treturn {\n\t\tname: e?.name,\n\t\tmessage: e?.message ?? String(e),\n\t\tstack: e?.stack,\n\t\tcause: e?.cause === undefined ? undefined : reduceError(e.cause),\n\t};\n}\n\n// See comment in `bundle.ts` for details on why this is needed\nconst jsonError: Middleware = async (request, env, _ctx, middlewareCtx) => {\n\ttry {\n\t\treturn await middlewareCtx.next(request, env);\n\t} catch (e: any) {\n\t\tconst error = reduceError(e);\n\t\treturn Response.json(error, {\n\t\t\tstatus: 500,\n\t\t\theaders: { \"MF-Experimental-Error-Stack\": \"true\" },\n\t\t});\n\t}\n};\n\nexport default jsonError;\n", "\t\t\t\timport worker, * as OTHER_EXPORTS from \"/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/src/index.ts\";\n\t\t\t\timport * as __MIDDLEWARE_0__ from \"/home/rhys/assistant/v2/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts\";\nimport * as __MIDDLEWARE_1__ from \"/home/rhys/assistant/v2/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts\";\n\n\t\t\t\texport * from \"/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/src/index.ts\";\n\t\t\t\tconst MIDDLEWARE_TEST_INJECT = \"__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__\";\n\t\t\t\texport const __INTERNAL_WRANGLER_MIDDLEWARE__ = [\n\t\t\t\t\t\n\t\t\t\t\t__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default\n\t\t\t\t]\n\t\t\t\texport default worker;", "export type Awaitable<T> = T | Promise<T>;\n// TODO: allow dispatching more events?\nexport type Dispatcher = (\n\ttype: \"scheduled\",\n\tinit: { cron?: string }\n) => Awaitable<void>;\n\nexport type IncomingRequest = Request<\n\tunknown,\n\tIncomingRequestCfProperties<unknown>\n>;\n\nexport interface MiddlewareContext {\n\tdispatch: Dispatcher;\n\tnext(request: IncomingRequest, env: any): Awaitable<Response>;\n}\n\nexport type Middleware = (\n\trequest: IncomingRequest,\n\tenv: any,\n\tctx: ExecutionContext,\n\tmiddlewareCtx: MiddlewareContext\n) => Awaitable<Response>;\n\nconst __facade_middleware__: Middleware[] = [];\n\n// The register functions allow for the insertion of one or many middleware,\n// We register internal middleware first in the stack, but have no way of controlling\n// the order that addMiddleware is run in service workers so need an internal function.\nexport function __facade_register__(...args: (Middleware | Middleware[])[]) {\n\t__facade_middleware__.push(...args.flat());\n}\nexport function __facade_registerInternal__(\n\t...args: (Middleware | Middleware[])[]\n) {\n\t__facade_middleware__.unshift(...args.flat());\n}\n\nfunction __facade_invokeChain__(\n\trequest: IncomingRequest,\n\tenv: any,\n\tctx: ExecutionContext,\n\tdispatch: Dispatcher,\n\tmiddlewareChain: Middleware[]\n): Awaitable<Response> {\n\tconst [head, ...tail] = middlewareChain;\n\tconst middlewareCtx: MiddlewareContext = {\n\t\tdispatch,\n\t\tnext(newRequest, newEnv) {\n\t\t\treturn __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail);\n\t\t},\n\t};\n\treturn head(request, env, ctx, middlewareCtx);\n}\n\nexport function __facade_invoke__(\n\trequest: IncomingRequest,\n\tenv: any,\n\tctx: ExecutionContext,\n\tdispatch: Dispatcher,\n\tfinalMiddleware: Middleware\n): Awaitable<Response> {\n\treturn __facade_invokeChain__(request, env, ctx, dispatch, [\n\t\t...__facade_middleware__,\n\t\tfinalMiddleware,\n\t]);\n}\n", "// This loads all middlewares exposed on the middleware object and then starts\n// the invocation chain. The big idea is that we can add these to the middleware\n// export dynamically through wrangler, or we can potentially let users directly\n// add them as a sort of \"plugin\" system.\n\nimport ENTRY, { __INTERNAL_WRANGLER_MIDDLEWARE__ } from \"/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-gLJWNP/middleware-insertion-facade.js\";\nimport { __facade_invoke__, __facade_register__, Dispatcher } from \"/home/rhys/assistant/v2/node_modules/.bun/wrangler@4.69.0+43cd165320f4af71/node_modules/wrangler/templates/middleware/common.ts\";\nimport type { WorkerEntrypointConstructor } from \"/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-gLJWNP/middleware-insertion-facade.js\";\n\n// Preserve all the exports from the worker\nexport * from \"/home/rhys/assistant/v2/packages/runtime-cloudflare-worker-loader/worker/.wrangler/tmp/bundle-gLJWNP/middleware-insertion-facade.js\";\n\nclass __Facade_ScheduledController__ implements ScheduledController {\n\treadonly #noRetry: ScheduledController[\"noRetry\"];\n\n\tconstructor(\n\t\treadonly scheduledTime: number,\n\t\treadonly cron: string,\n\t\tnoRetry: ScheduledController[\"noRetry\"]\n\t) {\n\t\tthis.#noRetry = noRetry;\n\t}\n\n\tnoRetry() {\n\t\tif (!(this instanceof __Facade_ScheduledController__)) {\n\t\t\tthrow new TypeError(\"Illegal invocation\");\n\t\t}\n\t\t// Need to call native method immediately in case uncaught error thrown\n\t\tthis.#noRetry();\n\t}\n}\n\nfunction wrapExportedHandler(worker: ExportedHandler): ExportedHandler {\n\t// If we don't have any middleware defined, just return the handler as is\n\tif (\n\t\t__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||\n\t\t__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0\n\t) {\n\t\treturn worker;\n\t}\n\t// Otherwise, register all middleware once\n\tfor (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {\n\t\t__facade_register__(middleware);\n\t}\n\n\tconst fetchDispatcher: ExportedHandlerFetchHandler = function (\n\t\trequest,\n\t\tenv,\n\t\tctx\n\t) {\n\t\tif (worker.fetch === undefined) {\n\t\t\tthrow new Error(\"Handler does not export a fetch() function.\");\n\t\t}\n\t\treturn worker.fetch(request, env, ctx);\n\t};\n\n\treturn {\n\t\t...worker,\n\t\tfetch(request, env, ctx) {\n\t\t\tconst dispatcher: Dispatcher = function (type, init) {\n\t\t\t\tif (type === \"scheduled\" && worker.scheduled !== undefined) {\n\t\t\t\t\tconst controller = new __Facade_ScheduledController__(\n\t\t\t\t\t\tDate.now(),\n\t\t\t\t\t\tinit.cron ?? \"\",\n\t\t\t\t\t\t() => {}\n\t\t\t\t\t);\n\t\t\t\t\treturn worker.scheduled(controller, env, ctx);\n\t\t\t\t}\n\t\t\t};\n\t\t\treturn __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);\n\t\t},\n\t};\n}\n\nfunction wrapWorkerEntrypoint(\n\tklass: WorkerEntrypointConstructor\n): WorkerEntrypointConstructor {\n\t// If we don't have any middleware defined, just return the handler as is\n\tif (\n\t\t__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||\n\t\t__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0\n\t) {\n\t\treturn klass;\n\t}\n\t// Otherwise, register all middleware once\n\tfor (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {\n\t\t__facade_register__(middleware);\n\t}\n\n\t// `extend`ing `klass` here so other RPC methods remain callable\n\treturn class extends klass {\n\t\t#fetchDispatcher: ExportedHandlerFetchHandler<Record<string, unknown>> = (\n\t\t\trequest,\n\t\t\tenv,\n\t\t\tctx\n\t\t) => {\n\t\t\tthis.env = env;\n\t\t\tthis.ctx = ctx;\n\t\t\tif (super.fetch === undefined) {\n\t\t\t\tthrow new Error(\"Entrypoint class does not define a fetch() function.\");\n\t\t\t}\n\t\t\treturn super.fetch(request);\n\t\t};\n\n\t\t#dispatcher: Dispatcher = (type, init) => {\n\t\t\tif (type === \"scheduled\" && super.scheduled !== undefined) {\n\t\t\t\tconst controller = new __Facade_ScheduledController__(\n\t\t\t\t\tDate.now(),\n\t\t\t\t\tinit.cron ?? \"\",\n\t\t\t\t\t() => {}\n\t\t\t\t);\n\t\t\t\treturn super.scheduled(controller);\n\t\t\t}\n\t\t};\n\n\t\tfetch(request: Request<unknown, IncomingRequestCfProperties>) {\n\t\t\treturn __facade_invoke__(\n\t\t\t\trequest,\n\t\t\t\tthis.env,\n\t\t\t\tthis.ctx,\n\t\t\t\tthis.#dispatcher,\n\t\t\t\tthis.#fetchDispatcher\n\t\t\t);\n\t\t}\n\t};\n}\n\nlet WRAPPED_ENTRY: ExportedHandler | WorkerEntrypointConstructor | undefined;\nif (typeof ENTRY === \"object\") {\n\tWRAPPED_ENTRY = wrapExportedHandler(ENTRY);\n} else if (typeof ENTRY === \"function\") {\n\tWRAPPED_ENTRY = wrapWorkerEntrypoint(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EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAI;AACJ,IAAM,WAAW;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAAD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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,UAAU,UAAU;AAAA,MAClC;AAAA,IACD,GAT0B;AAAA,IAW1B,MAAM,SAAwD;AAC7D,aAAO;AAAA,QACN;AAAA,QACA,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,MACN;AAAA,IACD;AAAA,EACD;AACD;AAnDS;AAqDT,IAAI;AACJ,IAAI,OAAO,wCAAU,UAAU;AAC9B,kBAAgB,oBAAoB,mCAAK;AAC1C,WAAW,OAAO,wCAAU,YAAY;AACvC,kBAAgB,qBAAqB,mCAAK;AAC3C;AACA,IAAO,kCAAQ;", | ||
| 7 | "names": ["PerformanceMark", "clear", "count", "countReset", "createTask", "debug", "dir", "dirxml", "error", "group", "groupCollapsed", "groupEnd", "info", "log", "profile", "profileEnd", "table", "time", "timeEnd", "timeLog", "timeStamp", "trace", "warn", "hrtime", "dir", "env", "count", "cwd", "assert", "hrtime", "error", "env", "env", "env", "env", "error", "env", "env"] | ||
| 8 | } | ||