@execbox/quickjs 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/runner/index.cjs +1 -1
- package/dist/runner/index.d.cts +4 -1
- package/dist/runner/index.d.cts.map +1 -1
- package/dist/runner/index.d.ts +4 -1
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +1 -1
- package/dist/runner/protocolEndpoint.cjs +38 -1
- package/dist/runner/protocolEndpoint.cjs.map +1 -1
- package/dist/runner/protocolEndpoint.d.cts.map +1 -1
- package/dist/runner/protocolEndpoint.d.ts.map +1 -1
- package/dist/runner/protocolEndpoint.js +38 -1
- package/dist/runner/protocolEndpoint.js.map +1 -1
- package/dist/{runner-DVOLiGt4.js → runner-B4UG88h1.js} +16 -2
- package/dist/runner-B4UG88h1.js.map +1 -0
- package/dist/{runner-CYXIVOmJ.cjs → runner-DhOZH9xz.cjs} +16 -2
- package/dist/runner-DhOZH9xz.cjs.map +1 -0
- package/package.json +3 -3
- package/dist/runner-CYXIVOmJ.cjs.map +0 -1
- package/dist/runner-DVOLiGt4.js.map +0 -1
package/README.md
CHANGED
|
@@ -63,3 +63,5 @@ const result = await executor.execute("await codemode.echo({ ok: true })", [
|
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
Each execution runs in a fresh QuickJS runtime with timeout handling, captured logs, and JSON-only result and tool boundaries.
|
|
66
|
+
|
|
67
|
+
`QuickJsExecutor` intentionally stays ephemeral. Every `execute()` call creates a fresh QuickJS runtime/context, and the package does not expose a pooling API.
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const require_runner = require('./runner-
|
|
1
|
+
const require_runner = require('./runner-DhOZH9xz.cjs');
|
|
2
2
|
let __execbox_core = require("@execbox/core");
|
|
3
3
|
|
|
4
4
|
//#region src/quickjsExecutor.ts
|
|
5
5
|
/**
|
|
6
|
-
* QuickJS-backed executor for
|
|
6
|
+
* QuickJS-backed executor for ephemeral sandboxed JavaScript runs.
|
|
7
7
|
*/
|
|
8
8
|
var QuickJsExecutor = class {
|
|
9
9
|
options;
|
|
10
10
|
/**
|
|
11
|
-
* Creates a QuickJS executor with
|
|
11
|
+
* Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.
|
|
12
12
|
*/
|
|
13
13
|
constructor(options = {}) {
|
|
14
14
|
this.options = options;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["runQuickJsSession"],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":["import {\n createTimeoutExecuteResult,\n createToolCallDispatcher,\n extractProviderManifests,\n type ExecutionOptions,\n type ExecuteResult,\n type Executor,\n type ResolvedToolProvider,\n} from \"@execbox/core\";\n\nimport { runQuickJsSession } from \"./runner/index\";\nimport type { QuickJsExecutorOptions } from \"./types\";\n\n/**\n * QuickJS-backed executor for
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["runQuickJsSession"],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":["import {\n createTimeoutExecuteResult,\n createToolCallDispatcher,\n extractProviderManifests,\n type ExecutionOptions,\n type ExecuteResult,\n type Executor,\n type ResolvedToolProvider,\n} from \"@execbox/core\";\n\nimport { runQuickJsSession } from \"./runner/index\";\nimport type { QuickJsExecutorOptions } from \"./types\";\n\n/**\n * QuickJS-backed executor for ephemeral sandboxed JavaScript runs.\n */\nexport class QuickJsExecutor implements Executor {\n private readonly options: QuickJsExecutorOptions;\n\n /**\n * Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.\n */\n constructor(options: QuickJsExecutorOptions = {}) {\n this.options = options;\n }\n\n /**\n * Executes JavaScript against the provided tool namespaces in a fresh QuickJS runtime.\n */\n async execute(\n code: string,\n providers: ResolvedToolProvider[],\n options: ExecutionOptions = {},\n ): Promise<ExecuteResult> {\n if (options.signal?.aborted) {\n return createTimeoutExecuteResult();\n }\n\n const abortController = new AbortController();\n const onToolCall = createToolCallDispatcher(\n providers,\n abortController.signal,\n );\n const onAbort = () => {\n abortController.abort();\n };\n\n options.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n try {\n return await runQuickJsSession(\n {\n abortController,\n code,\n onToolCall,\n providers: extractProviderManifests(providers),\n },\n {\n ...this.options,\n ...options,\n },\n );\n } finally {\n options.signal?.removeEventListener(\"abort\", onAbort);\n abortController.abort();\n }\n }\n}\n"],"mappings":";;;;;;;AAgBA,IAAa,kBAAb,MAAiD;CAC/C,AAAiB;;;;CAKjB,YAAY,UAAkC,EAAE,EAAE;AAChD,OAAK,UAAU;;;;;CAMjB,MAAM,QACJ,MACA,WACA,UAA4B,EAAE,EACN;AACxB,MAAI,QAAQ,QAAQ,QAClB,wDAAmC;EAGrC,MAAM,kBAAkB,IAAI,iBAAiB;EAC7C,MAAM,0DACJ,WACA,gBAAgB,OACjB;EACD,MAAM,gBAAgB;AACpB,mBAAgB,OAAO;;AAGzB,UAAQ,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;AAElE,MAAI;AACF,UAAO,MAAMA,iCACX;IACE;IACA;IACA;IACA,wDAAoC,UAAU;IAC/C,EACD;IACE,GAAG,KAAK;IACR,GAAG;IACJ,CACF;YACO;AACR,WAAQ,QAAQ,oBAAoB,SAAS,QAAQ;AACrD,mBAAgB,OAAO"}
|
package/dist/index.d.cts
CHANGED
|
@@ -4,12 +4,12 @@ import { ExecuteResult, ExecutionOptions, Executor, ResolvedToolProvider } from
|
|
|
4
4
|
//#region src/quickjsExecutor.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* QuickJS-backed executor for
|
|
7
|
+
* QuickJS-backed executor for ephemeral sandboxed JavaScript runs.
|
|
8
8
|
*/
|
|
9
9
|
declare class QuickJsExecutor implements Executor {
|
|
10
10
|
private readonly options;
|
|
11
11
|
/**
|
|
12
|
-
* Creates a QuickJS executor with
|
|
12
|
+
* Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.
|
|
13
13
|
*/
|
|
14
14
|
constructor(options?: QuickJsExecutorOptions);
|
|
15
15
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { ExecuteResult, ExecutionOptions, Executor, ResolvedToolProvider } from
|
|
|
4
4
|
//#region src/quickjsExecutor.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* QuickJS-backed executor for
|
|
7
|
+
* QuickJS-backed executor for ephemeral sandboxed JavaScript runs.
|
|
8
8
|
*/
|
|
9
9
|
declare class QuickJsExecutor implements Executor {
|
|
10
10
|
private readonly options;
|
|
11
11
|
/**
|
|
12
|
-
* Creates a QuickJS executor with
|
|
12
|
+
* Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.
|
|
13
13
|
*/
|
|
14
14
|
constructor(options?: QuickJsExecutorOptions);
|
|
15
15
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { t as runQuickJsSession } from "./runner-
|
|
1
|
+
import { t as runQuickJsSession } from "./runner-B4UG88h1.js";
|
|
2
2
|
import { createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests } from "@execbox/core";
|
|
3
3
|
|
|
4
4
|
//#region src/quickjsExecutor.ts
|
|
5
5
|
/**
|
|
6
|
-
* QuickJS-backed executor for
|
|
6
|
+
* QuickJS-backed executor for ephemeral sandboxed JavaScript runs.
|
|
7
7
|
*/
|
|
8
8
|
var QuickJsExecutor = class {
|
|
9
9
|
options;
|
|
10
10
|
/**
|
|
11
|
-
* Creates a QuickJS executor with
|
|
11
|
+
* Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.
|
|
12
12
|
*/
|
|
13
13
|
constructor(options = {}) {
|
|
14
14
|
this.options = options;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":["import {\n createTimeoutExecuteResult,\n createToolCallDispatcher,\n extractProviderManifests,\n type ExecutionOptions,\n type ExecuteResult,\n type Executor,\n type ResolvedToolProvider,\n} from \"@execbox/core\";\n\nimport { runQuickJsSession } from \"./runner/index\";\nimport type { QuickJsExecutorOptions } from \"./types\";\n\n/**\n * QuickJS-backed executor for
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":["import {\n createTimeoutExecuteResult,\n createToolCallDispatcher,\n extractProviderManifests,\n type ExecutionOptions,\n type ExecuteResult,\n type Executor,\n type ResolvedToolProvider,\n} from \"@execbox/core\";\n\nimport { runQuickJsSession } from \"./runner/index\";\nimport type { QuickJsExecutorOptions } from \"./types\";\n\n/**\n * QuickJS-backed executor for ephemeral sandboxed JavaScript runs.\n */\nexport class QuickJsExecutor implements Executor {\n private readonly options: QuickJsExecutorOptions;\n\n /**\n * Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.\n */\n constructor(options: QuickJsExecutorOptions = {}) {\n this.options = options;\n }\n\n /**\n * Executes JavaScript against the provided tool namespaces in a fresh QuickJS runtime.\n */\n async execute(\n code: string,\n providers: ResolvedToolProvider[],\n options: ExecutionOptions = {},\n ): Promise<ExecuteResult> {\n if (options.signal?.aborted) {\n return createTimeoutExecuteResult();\n }\n\n const abortController = new AbortController();\n const onToolCall = createToolCallDispatcher(\n providers,\n abortController.signal,\n );\n const onAbort = () => {\n abortController.abort();\n };\n\n options.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n try {\n return await runQuickJsSession(\n {\n abortController,\n code,\n onToolCall,\n providers: extractProviderManifests(providers),\n },\n {\n ...this.options,\n ...options,\n },\n );\n } finally {\n options.signal?.removeEventListener(\"abort\", onAbort);\n abortController.abort();\n }\n }\n}\n"],"mappings":";;;;;;;AAgBA,IAAa,kBAAb,MAAiD;CAC/C,AAAiB;;;;CAKjB,YAAY,UAAkC,EAAE,EAAE;AAChD,OAAK,UAAU;;;;;CAMjB,MAAM,QACJ,MACA,WACA,UAA4B,EAAE,EACN;AACxB,MAAI,QAAQ,QAAQ,QAClB,QAAO,4BAA4B;EAGrC,MAAM,kBAAkB,IAAI,iBAAiB;EAC7C,MAAM,aAAa,yBACjB,WACA,gBAAgB,OACjB;EACD,MAAM,gBAAgB;AACpB,mBAAgB,OAAO;;AAGzB,UAAQ,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;AAElE,MAAI;AACF,UAAO,MAAM,kBACX;IACE;IACA;IACA;IACA,WAAW,yBAAyB,UAAU;IAC/C,EACD;IACE,GAAG,KAAK;IACR,GAAG;IACJ,CACF;YACO;AACR,WAAQ,QAAQ,oBAAoB,SAAS,QAAQ;AACrD,mBAAgB,OAAO"}
|
package/dist/runner/index.cjs
CHANGED
package/dist/runner/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as QuickJsExecutorOptions } from "../types-BB8mb_-T.cjs";
|
|
2
|
+
import { QuickJSWASMModule } from "quickjs-emscripten";
|
|
2
3
|
|
|
3
4
|
//#region ../core/src/types.d.ts
|
|
4
5
|
|
|
@@ -94,7 +95,9 @@ interface QuickJsSessionRequest {
|
|
|
94
95
|
/**
|
|
95
96
|
* Options controlling one transport-backed QuickJS session.
|
|
96
97
|
*/
|
|
97
|
-
type QuickJsSessionOptions = QuickJsExecutorOptions & ExecutorRuntimeOptions
|
|
98
|
+
type QuickJsSessionOptions = QuickJsExecutorOptions & ExecutorRuntimeOptions & {
|
|
99
|
+
module?: QuickJSWASMModule;
|
|
100
|
+
};
|
|
98
101
|
/**
|
|
99
102
|
* Runs one QuickJS-backed execution session using a transport-neutral tool callback.
|
|
100
103
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../core/src/types.ts","../../../core/src/runner.ts","../../src/runner/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../core/src/types.ts","../../../core/src/runner.ts","../../src/runner/index.ts"],"sourcesContent":[],"mappings":";;;;;;ACeA;AASA;AASiB,KDlBL,gBAAA,GCkB2B,SAAA,GAAA,cAAA,GAAA,kBAAA,GAAA,YAAA,GAAA,eAAA,GAAA,qBAAA,GAAA,gBAAA;AAiBvC;AASA;;UDhCiB,YAAA;;EEuBL,IAAA,EFrBJ,gBEqBI;EAKK;EACG,OAAA,EAAA,MAAA;;;;;AAIP,KFvBD,aEuBC,CAAA,IAAA,OAAA,CAAA,GAAA;EACF,UAAA,EAAA,MAAA;EAAW,IAAA,EAAA,MAAA,EAAA;EAMV,EAAA,EAAA,IAAA;EAAwB,MAAA,EFzBtB,CEyBsB;CAClC,GAAA;EACW,UAAA,EAAA,MAAA;EAAiB,KAAA,EFvBjB,YEuBiB;EA4TR,IAAA,EAAA,MAAA,EAAA;EACX,EAAA,EAAA,KAAA;CACA;;;;;;AFpXC,UCAK,oBAAA,CDAW;EAYX,WAAA,CAAA,EAAA,MAAY;EAUjB,YAAA,EAAA,MAAa;;;;ACtBzB;AASA;AASiB,UATA,gBAAA,CASsB;EAiBtB,IAAA,EAAA,MAAQ;EASb,KAAA,EAjCH,MAiCG,CAAA,MAAc,EAjCF,oBAuCC,CAAA;;;;ACfzB;AAKA;AACoB,UDvBH,sBAAA,CCuBG;EAEC,WAAA,CAAA,EAAA,MAAA;EAAqB,WAAA,CAAA,EAAA,MAAA;EAAR,gBAAA,CAAA,EAAA,MAAA;EAA0B,SAAA,CAAA,EAAA,MAAA;;;AAuU5D;;AAEW,UDjVM,QAAA,CCiVN;EACA,KAAA,EAAA,OAAA;EAAR,YAAA,EAAA,MAAA;EAAO,YAAA,EAAA,MAAA;;;;;KDzUE,cAAA;;;;SAMC;;;;;;ADlDb;AAYA;AAUY,KEaA,sBAAA,GAAyB,QFJxB;;;;AC/BI,UCwCA,qBAAA,CDxCoB;EASpB,eAAA,CAAA,ECgCG,eD9BI;EAOP,IAAA,EAAA,MAAA;EAiBA,UAAA,EAAQ,CAAA,IAAA,ECQJ,QDRI,EAAA,GCQS,ODRT,CCQiB,cDRjB,CAAA,GCQmC,cDRnC;EASb,SAAA,CAAA,EAAA,GAAA,GAAc,IAAA;aCCb;WACF;;AAXX;AAKA;;AAGqB,KAST,qBAAA,GAAwB,sBATf,GAUnB,sBAVmB,GAAA;EAAqB,MAAA,CAAA,EAW7B,iBAX6B;CAAR;;;;AAGZ,iBAoUA,iBAAA,CApUA,OAAA,EAqUX,qBArUW,EAAA,OAAA,CAAA,EAsUX,qBAtUW,CAAA,EAuUnB,OAvUmB,CAuUX,aAvUW,CAAA"}
|
package/dist/runner/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as QuickJsExecutorOptions } from "../types-D7uau0GM.js";
|
|
2
|
+
import { QuickJSWASMModule } from "quickjs-emscripten";
|
|
2
3
|
|
|
3
4
|
//#region ../core/src/types.d.ts
|
|
4
5
|
|
|
@@ -94,7 +95,9 @@ interface QuickJsSessionRequest {
|
|
|
94
95
|
/**
|
|
95
96
|
* Options controlling one transport-backed QuickJS session.
|
|
96
97
|
*/
|
|
97
|
-
type QuickJsSessionOptions = QuickJsExecutorOptions & ExecutorRuntimeOptions
|
|
98
|
+
type QuickJsSessionOptions = QuickJsExecutorOptions & ExecutorRuntimeOptions & {
|
|
99
|
+
module?: QuickJSWASMModule;
|
|
100
|
+
};
|
|
98
101
|
/**
|
|
99
102
|
* Runs one QuickJS-backed execution session using a transport-neutral tool callback.
|
|
100
103
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../core/src/types.ts","../../../core/src/runner.ts","../../src/runner/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../core/src/types.ts","../../../core/src/runner.ts","../../src/runner/index.ts"],"sourcesContent":[],"mappings":";;;;;;ACeA;AASA;AASiB,KDlBL,gBAAA,GCkB2B,SAAA,GAAA,cAAA,GAAA,kBAAA,GAAA,YAAA,GAAA,eAAA,GAAA,qBAAA,GAAA,gBAAA;AAiBvC;AASA;;UDhCiB,YAAA;;EEuBL,IAAA,EFrBJ,gBEqBI;EAKK;EACG,OAAA,EAAA,MAAA;;;;;AAIP,KFvBD,aEuBC,CAAA,IAAA,OAAA,CAAA,GAAA;EACF,UAAA,EAAA,MAAA;EAAW,IAAA,EAAA,MAAA,EAAA;EAMV,EAAA,EAAA,IAAA;EAAwB,MAAA,EFzBtB,CEyBsB;CAClC,GAAA;EACW,UAAA,EAAA,MAAA;EAAiB,KAAA,EFvBjB,YEuBiB;EA4TR,IAAA,EAAA,MAAA,EAAA;EACX,EAAA,EAAA,KAAA;CACA;;;;;;AFpXC,UCAK,oBAAA,CDAW;EAYX,WAAA,CAAA,EAAA,MAAY;EAUjB,YAAA,EAAA,MAAa;;;;ACtBzB;AASA;AASiB,UATA,gBAAA,CASsB;EAiBtB,IAAA,EAAA,MAAQ;EASb,KAAA,EAjCH,MAiCG,CAAA,MAAc,EAjCF,oBAuCC,CAAA;;;;ACfzB;AAKA;AACoB,UDvBH,sBAAA,CCuBG;EAEC,WAAA,CAAA,EAAA,MAAA;EAAqB,WAAA,CAAA,EAAA,MAAA;EAAR,gBAAA,CAAA,EAAA,MAAA;EAA0B,SAAA,CAAA,EAAA,MAAA;;;AAuU5D;;AAEW,UDjVM,QAAA,CCiVN;EACA,KAAA,EAAA,OAAA;EAAR,YAAA,EAAA,MAAA;EAAO,YAAA,EAAA,MAAA;;;;;KDzUE,cAAA;;;;SAMC;;;;;;ADlDb;AAYA;AAUY,KEaA,sBAAA,GAAyB,QFJxB;;;;AC/BI,UCwCA,qBAAA,CDxCoB;EASpB,eAAA,CAAA,ECgCG,eD9BI;EAOP,IAAA,EAAA,MAAA;EAiBA,UAAA,EAAQ,CAAA,IAAA,ECQJ,QDRI,EAAA,GCQS,ODRT,CCQiB,cDRjB,CAAA,GCQmC,cDRnC;EASb,SAAA,CAAA,EAAA,GAAA,GAAc,IAAA;aCCb;WACF;;AAXX;AAKA;;AAGqB,KAST,qBAAA,GAAwB,sBATf,GAUnB,sBAVmB,GAAA;EAAqB,MAAA,CAAA,EAW7B,iBAX6B;CAAR;;;;AAGZ,iBAoUA,iBAAA,CApUA,OAAA,EAqUX,qBArUW,EAAA,OAAA,CAAA,EAsUX,qBAtUW,CAAA,EAuUnB,OAvUmB,CAuUX,aAvUW,CAAA"}
|
package/dist/runner/index.js
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
|
-
const require_runner = require('../runner-
|
|
1
|
+
const require_runner = require('../runner-DhOZH9xz.cjs');
|
|
2
2
|
let node_crypto = require("node:crypto");
|
|
3
3
|
|
|
4
|
+
//#region ../protocol/src/messages.ts
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return typeof value === "object" && value !== null;
|
|
7
|
+
}
|
|
8
|
+
function isFiniteNumber(value) {
|
|
9
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
10
|
+
}
|
|
11
|
+
function isRuntimeOptions(value) {
|
|
12
|
+
if (!isRecord(value)) return false;
|
|
13
|
+
return isFiniteNumber(value.maxLogChars) && isFiniteNumber(value.maxLogLines) && isFiniteNumber(value.memoryLimitBytes) && isFiniteNumber(value.timeoutMs);
|
|
14
|
+
}
|
|
15
|
+
function isProviderManifest(value) {
|
|
16
|
+
if (!isRecord(value) || typeof value.name !== "string") return false;
|
|
17
|
+
if (!isRecord(value.tools) || typeof value.types !== "string") return false;
|
|
18
|
+
return Object.values(value.tools).every((tool) => isRecord(tool) && typeof tool.originalName === "string" && typeof tool.safeName === "string" && (tool.description === void 0 || typeof tool.description === "string"));
|
|
19
|
+
}
|
|
20
|
+
function isExecuteError(value) {
|
|
21
|
+
return isRecord(value) && typeof value.code === "string" && typeof value.message === "string";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns whether an unknown value is a dispatcher-to-runner message.
|
|
25
|
+
*/
|
|
26
|
+
function isDispatcherMessage(value) {
|
|
27
|
+
if (!isRecord(value) || typeof value.type !== "string") return false;
|
|
28
|
+
switch (value.type) {
|
|
29
|
+
case "cancel": return typeof value.id === "string";
|
|
30
|
+
case "execute": return typeof value.code === "string" && typeof value.id === "string" && isRuntimeOptions(value.options) && Array.isArray(value.providers) && value.providers.every(isProviderManifest);
|
|
31
|
+
case "tool_result":
|
|
32
|
+
if (typeof value.callId !== "string" || typeof value.ok !== "boolean") return false;
|
|
33
|
+
if (value.ok) return "result" in value;
|
|
34
|
+
return isExecuteError(value.error);
|
|
35
|
+
default: return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
4
40
|
//#region src/runner/protocolEndpoint.ts
|
|
5
41
|
/**
|
|
6
42
|
* Attaches the shared QuickJS protocol loop to a worker/process messaging port.
|
|
@@ -72,6 +108,7 @@ function attachQuickJsProtocolEndpoint(port) {
|
|
|
72
108
|
}
|
|
73
109
|
}
|
|
74
110
|
const maybeDetach = port.onMessage((message) => {
|
|
111
|
+
if (!isDispatcherMessage(message)) return;
|
|
75
112
|
switch (message.type) {
|
|
76
113
|
case "cancel":
|
|
77
114
|
if (message.id === activeExecutionId) activeAbortController?.abort();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocolEndpoint.cjs","names":["activeAbortController: AbortController | undefined","activeExecutionId: string | undefined","runQuickJsSession"],"sources":["../../src/runner/protocolEndpoint.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\n\nimport type {\n DispatcherMessage,\n ExecuteMessage,\n RunnerMessage,\n ToolCallResult,\n} from \"@execbox/protocol\";\n\nimport { runQuickJsSession } from \"./index.ts\";\n\n/**\n * Minimal worker/process-side port used by the shared QuickJS protocol endpoint.\n */\nexport interface QuickJsProtocolPort {\n onMessage(handler: (message: DispatcherMessage) => void): void | (() => void);\n send(message: RunnerMessage): void;\n}\n\n/**\n * Attaches the shared QuickJS protocol loop to a worker/process messaging port.\n */\nexport function attachQuickJsProtocolEndpoint(\n port: QuickJsProtocolPort,\n): () => void {\n const pendingToolCalls = new Map<string, (result: ToolCallResult) => void>();\n let activeAbortController: AbortController | undefined;\n let activeExecutionId: string | undefined;\n\n async function startExecution(message: ExecuteMessage): Promise<void> {\n if (activeExecutionId) {\n port.send({\n durationMs: 0,\n error: {\n code: \"internal_error\",\n message: \"QuickJS endpoint already has an active execution\",\n },\n id: message.id,\n logs: [],\n ok: false,\n type: \"done\",\n });\n return;\n }\n\n const abortController = new AbortController();\n activeAbortController = abortController;\n activeExecutionId = message.id;\n\n try {\n const result = await runQuickJsSession(\n {\n abortController,\n code: message.code,\n onStarted: () => {\n port.send({\n id: message.id,\n type: \"started\",\n });\n },\n onToolCall: (call) =>\n new Promise<ToolCallResult>((resolve) => {\n const callId = randomUUID();\n pendingToolCalls.set(callId, resolve);\n port.send({\n ...call,\n callId,\n type: \"tool_call\",\n });\n }),\n providers: message.providers,\n },\n message.options,\n );\n\n port.send({\n ...result,\n id: message.id,\n type: \"done\",\n });\n } catch (error) {\n port.send({\n durationMs: 0,\n error: {\n code: \"internal_error\",\n message: error instanceof Error ? error.message : String(error),\n },\n id: message.id,\n logs: [],\n ok: false,\n type: \"done\",\n });\n } finally {\n pendingToolCalls.clear();\n activeAbortController = undefined;\n activeExecutionId = undefined;\n }\n }\n\n const maybeDetach = port.onMessage((message: DispatcherMessage) => {\n switch (message.type) {\n case \"cancel\":\n if (message.id === activeExecutionId) {\n activeAbortController?.abort();\n }\n break;\n case \"execute\":\n void startExecution(message);\n break;\n case \"tool_result\": {\n const resolve = pendingToolCalls.get(message.callId);\n pendingToolCalls.delete(message.callId);\n resolve?.(message);\n break;\n }\n }\n });\n\n return () => {\n if (typeof maybeDetach === \"function\") {\n maybeDetach();\n }\n pendingToolCalls.clear();\n activeAbortController?.abort();\n activeAbortController = undefined;\n activeExecutionId = undefined;\n };\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,8BACd,MACY;CACZ,MAAM,mCAAmB,IAAI,KAA+C;CAC5E,IAAIA;CACJ,IAAIC;CAEJ,eAAe,eAAe,SAAwC;AACpE,MAAI,mBAAmB;AACrB,QAAK,KAAK;IACR,YAAY;IACZ,OAAO;KACL,MAAM;KACN,SAAS;KACV;IACD,IAAI,QAAQ;IACZ,MAAM,EAAE;IACR,IAAI;IACJ,MAAM;IACP,CAAC;AACF;;EAGF,MAAM,kBAAkB,IAAI,iBAAiB;AAC7C,0BAAwB;AACxB,sBAAoB,QAAQ;AAE5B,MAAI;GACF,MAAM,SAAS,MAAMC,iCACnB;IACE;IACA,MAAM,QAAQ;IACd,iBAAiB;AACf,UAAK,KAAK;MACR,IAAI,QAAQ;MACZ,MAAM;MACP,CAAC;;IAEJ,aAAa,SACX,IAAI,SAAyB,YAAY;KACvC,MAAM,sCAAqB;AAC3B,sBAAiB,IAAI,QAAQ,QAAQ;AACrC,UAAK,KAAK;MACR,GAAG;MACH;MACA,MAAM;MACP,CAAC;MACF;IACJ,WAAW,QAAQ;IACpB,EACD,QAAQ,QACT;AAED,QAAK,KAAK;IACR,GAAG;IACH,IAAI,QAAQ;IACZ,MAAM;IACP,CAAC;WACK,OAAO;AACd,QAAK,KAAK;IACR,YAAY;IACZ,OAAO;KACL,MAAM;KACN,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;KAChE;IACD,IAAI,QAAQ;IACZ,MAAM,EAAE;IACR,IAAI;IACJ,MAAM;IACP,CAAC;YACM;AACR,oBAAiB,OAAO;AACxB,2BAAwB;AACxB,uBAAoB;;;CAIxB,MAAM,cAAc,KAAK,WAAW,YAA+B;AACjE,UAAQ,QAAQ,MAAhB;GACE,KAAK;AACH,QAAI,QAAQ,OAAO,kBACjB,wBAAuB,OAAO;AAEhC;GACF,KAAK;AACH,IAAK,eAAe,QAAQ;AAC5B;GACF,KAAK,eAAe;IAClB,MAAM,UAAU,iBAAiB,IAAI,QAAQ,OAAO;AACpD,qBAAiB,OAAO,QAAQ,OAAO;AACvC,cAAU,QAAQ;AAClB;;;GAGJ;AAEF,cAAa;AACX,MAAI,OAAO,gBAAgB,WACzB,cAAa;AAEf,mBAAiB,OAAO;AACxB,yBAAuB,OAAO;AAC9B,0BAAwB;AACxB,sBAAoB"}
|
|
1
|
+
{"version":3,"file":"protocolEndpoint.cjs","names":["activeAbortController: AbortController | undefined","activeExecutionId: string | undefined","runQuickJsSession"],"sources":["../../../protocol/src/messages.ts","../../src/runner/protocolEndpoint.ts"],"sourcesContent":["import type {\n ExecuteResult,\n ExecutorRuntimeOptions,\n ProviderManifest,\n ToolCall,\n ToolCallResult,\n} from \"@execbox/core\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value);\n}\n\nfunction isRuntimeOptions(value: unknown): value is ExecutorRuntimeOptions {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n isFiniteNumber(value.maxLogChars) &&\n isFiniteNumber(value.maxLogLines) &&\n isFiniteNumber(value.memoryLimitBytes) &&\n isFiniteNumber(value.timeoutMs)\n );\n}\n\nfunction isProviderManifest(value: unknown): value is ProviderManifest {\n if (!isRecord(value) || typeof value.name !== \"string\") {\n return false;\n }\n\n if (!isRecord(value.tools) || typeof value.types !== \"string\") {\n return false;\n }\n\n return Object.values(value.tools).every(\n (tool) =>\n isRecord(tool) &&\n typeof tool.originalName === \"string\" &&\n typeof tool.safeName === \"string\" &&\n (tool.description === undefined || typeof tool.description === \"string\"),\n );\n}\n\nfunction isExecuteError(\n value: unknown,\n): value is { code: string; message: string } {\n return (\n isRecord(value) &&\n typeof value.code === \"string\" &&\n typeof value.message === \"string\"\n );\n}\n\nfunction isDonePayload(value: unknown): value is DoneMessage {\n if (!isRecord(value) || !isFiniteNumber(value.durationMs)) {\n return false;\n }\n\n if (\n !Array.isArray(value.logs) ||\n !value.logs.every((log) => typeof log === \"string\")\n ) {\n return false;\n }\n\n if (typeof value.ok !== \"boolean\") {\n return false;\n }\n\n return value.ok ? true : isExecuteError(value.error);\n}\n\n/**\n * Message sent from dispatcher to runner to start one execution session.\n */\nexport interface ExecuteMessage {\n code: string;\n id: string;\n options: ExecutorRuntimeOptions;\n providers: ProviderManifest[];\n type: \"execute\";\n}\n\n/**\n * Message sent from dispatcher to request prompt cancellation.\n */\nexport interface CancelMessage {\n id: string;\n type: \"cancel\";\n}\n\n/**\n * Message sent from a runner when guest code invokes a host tool.\n */\nexport interface ToolCallMessage extends ToolCall {\n callId: string;\n type: \"tool_call\";\n}\n\n/**\n * Message carrying a trusted host tool result back to the runner.\n */\nexport type ToolResultMessage = {\n callId: string;\n type: \"tool_result\";\n} & ToolCallResult;\n\n/**\n * Message indicating the runner has finished bootstrapping guest execution timing.\n */\nexport interface StartedMessage {\n id: string;\n type: \"started\";\n}\n\n/**\n * Final successful execution result returned by a runner.\n *\n * Node IPC can omit `undefined` fields during serialization, so `result`\n * remains optional at the protocol boundary and is normalized by the host.\n */\nexport type DoneSuccessMessage<T = unknown> = {\n durationMs: number;\n id: string;\n logs: string[];\n ok: true;\n result?: T;\n type: \"done\";\n};\n\n/**\n * Final failed execution result returned by a runner.\n */\nexport type DoneFailureMessage = {\n id: string;\n type: \"done\";\n} & Extract<ExecuteResult, { ok: false }>;\n\n/**\n * Final execution result returned by a runner.\n */\nexport type DoneMessage = DoneSuccessMessage | DoneFailureMessage;\n\n/**\n * Messages accepted by a runner transport endpoint.\n */\nexport type DispatcherMessage =\n | CancelMessage\n | ExecuteMessage\n | ToolResultMessage;\n\n/**\n * Messages emitted by a runner transport endpoint.\n */\nexport type RunnerMessage = DoneMessage | StartedMessage | ToolCallMessage;\n\n/**\n * Returns whether an unknown value is a dispatcher-to-runner message.\n */\nexport function isDispatcherMessage(\n value: unknown,\n): value is DispatcherMessage {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case \"cancel\":\n return typeof value.id === \"string\";\n case \"execute\":\n return (\n typeof value.code === \"string\" &&\n typeof value.id === \"string\" &&\n isRuntimeOptions(value.options) &&\n Array.isArray(value.providers) &&\n value.providers.every(isProviderManifest)\n );\n case \"tool_result\":\n if (typeof value.callId !== \"string\" || typeof value.ok !== \"boolean\") {\n return false;\n }\n\n if (value.ok) {\n return \"result\" in value;\n }\n\n return isExecuteError(value.error);\n default:\n return false;\n }\n}\n\n/**\n * Returns whether an unknown value is a runner-to-dispatcher message.\n */\nexport function isRunnerMessage(value: unknown): value is RunnerMessage {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case \"started\":\n return typeof value.id === \"string\";\n case \"tool_call\":\n return (\n typeof value.callId === \"string\" &&\n typeof value.providerName === \"string\" &&\n typeof value.safeToolName === \"string\" &&\n \"input\" in value\n );\n case \"done\":\n return typeof value.id === \"string\" && isDonePayload(value);\n default:\n return false;\n }\n}\n","import { randomUUID } from \"node:crypto\";\n\nimport type {\n DispatcherMessage,\n ExecuteMessage,\n RunnerMessage,\n ToolCallResult,\n} from \"@execbox/protocol\";\nimport { isDispatcherMessage } from \"../../../protocol/src/messages.ts\";\n\nimport { runQuickJsSession } from \"./index.ts\";\n\n/**\n * Minimal worker/process-side port used by the shared QuickJS protocol endpoint.\n */\nexport interface QuickJsProtocolPort {\n onMessage(handler: (message: DispatcherMessage) => void): void | (() => void);\n send(message: RunnerMessage): void;\n}\n\n/**\n * Attaches the shared QuickJS protocol loop to a worker/process messaging port.\n */\nexport function attachQuickJsProtocolEndpoint(\n port: QuickJsProtocolPort,\n): () => void {\n const pendingToolCalls = new Map<string, (result: ToolCallResult) => void>();\n let activeAbortController: AbortController | undefined;\n let activeExecutionId: string | undefined;\n\n async function startExecution(message: ExecuteMessage): Promise<void> {\n if (activeExecutionId) {\n port.send({\n durationMs: 0,\n error: {\n code: \"internal_error\",\n message: \"QuickJS endpoint already has an active execution\",\n },\n id: message.id,\n logs: [],\n ok: false,\n type: \"done\",\n });\n return;\n }\n\n const abortController = new AbortController();\n activeAbortController = abortController;\n activeExecutionId = message.id;\n\n try {\n const result = await runQuickJsSession(\n {\n abortController,\n code: message.code,\n onStarted: () => {\n port.send({\n id: message.id,\n type: \"started\",\n });\n },\n onToolCall: (call) =>\n new Promise<ToolCallResult>((resolve) => {\n const callId = randomUUID();\n pendingToolCalls.set(callId, resolve);\n port.send({\n ...call,\n callId,\n type: \"tool_call\",\n });\n }),\n providers: message.providers,\n },\n message.options,\n );\n\n port.send({\n ...result,\n id: message.id,\n type: \"done\",\n });\n } catch (error) {\n port.send({\n durationMs: 0,\n error: {\n code: \"internal_error\",\n message: error instanceof Error ? error.message : String(error),\n },\n id: message.id,\n logs: [],\n ok: false,\n type: \"done\",\n });\n } finally {\n pendingToolCalls.clear();\n activeAbortController = undefined;\n activeExecutionId = undefined;\n }\n }\n\n const maybeDetach = port.onMessage((message: DispatcherMessage) => {\n if (!isDispatcherMessage(message)) {\n return;\n }\n\n switch (message.type) {\n case \"cancel\":\n if (message.id === activeExecutionId) {\n activeAbortController?.abort();\n }\n break;\n case \"execute\":\n void startExecution(message);\n break;\n case \"tool_result\": {\n const resolve = pendingToolCalls.get(message.callId);\n pendingToolCalls.delete(message.callId);\n resolve?.(message);\n break;\n }\n }\n });\n\n return () => {\n if (typeof maybeDetach === \"function\") {\n maybeDetach();\n }\n pendingToolCalls.clear();\n activeAbortController?.abort();\n activeAbortController = undefined;\n activeExecutionId = undefined;\n };\n}\n"],"mappings":";;;;AAQA,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,eAAe,OAAiC;AACvD,QAAO,OAAO,UAAU,YAAY,OAAO,SAAS,MAAM;;AAG5D,SAAS,iBAAiB,OAAiD;AACzE,KAAI,CAAC,SAA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O;AACxB,yBAAuB,OAAO;AAC9B,0BAAwB;AACxB,sBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocolEndpoint.d.cts","names":[],"sources":["../../src/runner/protocolEndpoint.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"protocolEndpoint.d.cts","names":[],"sources":["../../src/runner/protocolEndpoint.ts"],"sourcesContent":[],"mappings":";;;;;;AAeA;AAQgB,UARC,mBAAA,CAQ4B;+BAPd;gBACf;;;;;iBAMA,6BAAA,OACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocolEndpoint.d.ts","names":[],"sources":["../../src/runner/protocolEndpoint.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"protocolEndpoint.d.ts","names":[],"sources":["../../src/runner/protocolEndpoint.ts"],"sourcesContent":[],"mappings":";;;;;;AAeA;AAQgB,UARC,mBAAA,CAQ4B;+BAPd;gBACf;;;;;iBAMA,6BAAA,OACR"}
|
|
@@ -1,6 +1,42 @@
|
|
|
1
|
-
import { t as runQuickJsSession } from "../runner-
|
|
1
|
+
import { t as runQuickJsSession } from "../runner-B4UG88h1.js";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
|
|
4
|
+
//#region ../protocol/src/messages.ts
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return typeof value === "object" && value !== null;
|
|
7
|
+
}
|
|
8
|
+
function isFiniteNumber(value) {
|
|
9
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
10
|
+
}
|
|
11
|
+
function isRuntimeOptions(value) {
|
|
12
|
+
if (!isRecord(value)) return false;
|
|
13
|
+
return isFiniteNumber(value.maxLogChars) && isFiniteNumber(value.maxLogLines) && isFiniteNumber(value.memoryLimitBytes) && isFiniteNumber(value.timeoutMs);
|
|
14
|
+
}
|
|
15
|
+
function isProviderManifest(value) {
|
|
16
|
+
if (!isRecord(value) || typeof value.name !== "string") return false;
|
|
17
|
+
if (!isRecord(value.tools) || typeof value.types !== "string") return false;
|
|
18
|
+
return Object.values(value.tools).every((tool) => isRecord(tool) && typeof tool.originalName === "string" && typeof tool.safeName === "string" && (tool.description === void 0 || typeof tool.description === "string"));
|
|
19
|
+
}
|
|
20
|
+
function isExecuteError(value) {
|
|
21
|
+
return isRecord(value) && typeof value.code === "string" && typeof value.message === "string";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns whether an unknown value is a dispatcher-to-runner message.
|
|
25
|
+
*/
|
|
26
|
+
function isDispatcherMessage(value) {
|
|
27
|
+
if (!isRecord(value) || typeof value.type !== "string") return false;
|
|
28
|
+
switch (value.type) {
|
|
29
|
+
case "cancel": return typeof value.id === "string";
|
|
30
|
+
case "execute": return typeof value.code === "string" && typeof value.id === "string" && isRuntimeOptions(value.options) && Array.isArray(value.providers) && value.providers.every(isProviderManifest);
|
|
31
|
+
case "tool_result":
|
|
32
|
+
if (typeof value.callId !== "string" || typeof value.ok !== "boolean") return false;
|
|
33
|
+
if (value.ok) return "result" in value;
|
|
34
|
+
return isExecuteError(value.error);
|
|
35
|
+
default: return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
4
40
|
//#region src/runner/protocolEndpoint.ts
|
|
5
41
|
/**
|
|
6
42
|
* Attaches the shared QuickJS protocol loop to a worker/process messaging port.
|
|
@@ -72,6 +108,7 @@ function attachQuickJsProtocolEndpoint(port) {
|
|
|
72
108
|
}
|
|
73
109
|
}
|
|
74
110
|
const maybeDetach = port.onMessage((message) => {
|
|
111
|
+
if (!isDispatcherMessage(message)) return;
|
|
75
112
|
switch (message.type) {
|
|
76
113
|
case "cancel":
|
|
77
114
|
if (message.id === activeExecutionId) activeAbortController?.abort();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocolEndpoint.js","names":["activeAbortController: AbortController | undefined","activeExecutionId: string | undefined"],"sources":["../../src/runner/protocolEndpoint.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\n\nimport type {\n DispatcherMessage,\n ExecuteMessage,\n RunnerMessage,\n ToolCallResult,\n} from \"@execbox/protocol\";\n\nimport { runQuickJsSession } from \"./index.ts\";\n\n/**\n * Minimal worker/process-side port used by the shared QuickJS protocol endpoint.\n */\nexport interface QuickJsProtocolPort {\n onMessage(handler: (message: DispatcherMessage) => void): void | (() => void);\n send(message: RunnerMessage): void;\n}\n\n/**\n * Attaches the shared QuickJS protocol loop to a worker/process messaging port.\n */\nexport function attachQuickJsProtocolEndpoint(\n port: QuickJsProtocolPort,\n): () => void {\n const pendingToolCalls = new Map<string, (result: ToolCallResult) => void>();\n let activeAbortController: AbortController | undefined;\n let activeExecutionId: string | undefined;\n\n async function startExecution(message: ExecuteMessage): Promise<void> {\n if (activeExecutionId) {\n port.send({\n durationMs: 0,\n error: {\n code: \"internal_error\",\n message: \"QuickJS endpoint already has an active execution\",\n },\n id: message.id,\n logs: [],\n ok: false,\n type: \"done\",\n });\n return;\n }\n\n const abortController = new AbortController();\n activeAbortController = abortController;\n activeExecutionId = message.id;\n\n try {\n const result = await runQuickJsSession(\n {\n abortController,\n code: message.code,\n onStarted: () => {\n port.send({\n id: message.id,\n type: \"started\",\n });\n },\n onToolCall: (call) =>\n new Promise<ToolCallResult>((resolve) => {\n const callId = randomUUID();\n pendingToolCalls.set(callId, resolve);\n port.send({\n ...call,\n callId,\n type: \"tool_call\",\n });\n }),\n providers: message.providers,\n },\n message.options,\n );\n\n port.send({\n ...result,\n id: message.id,\n type: \"done\",\n });\n } catch (error) {\n port.send({\n durationMs: 0,\n error: {\n code: \"internal_error\",\n message: error instanceof Error ? error.message : String(error),\n },\n id: message.id,\n logs: [],\n ok: false,\n type: \"done\",\n });\n } finally {\n pendingToolCalls.clear();\n activeAbortController = undefined;\n activeExecutionId = undefined;\n }\n }\n\n const maybeDetach = port.onMessage((message: DispatcherMessage) => {\n switch (message.type) {\n case \"cancel\":\n if (message.id === activeExecutionId) {\n activeAbortController?.abort();\n }\n break;\n case \"execute\":\n void startExecution(message);\n break;\n case \"tool_result\": {\n const resolve = pendingToolCalls.get(message.callId);\n pendingToolCalls.delete(message.callId);\n resolve?.(message);\n break;\n }\n }\n });\n\n return () => {\n if (typeof maybeDetach === \"function\") {\n maybeDetach();\n }\n pendingToolCalls.clear();\n activeAbortController?.abort();\n activeAbortController = undefined;\n activeExecutionId = undefined;\n };\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,8BACd,MACY;CACZ,MAAM,mCAAmB,IAAI,KAA+C;CAC5E,IAAIA;CACJ,IAAIC;CAEJ,eAAe,eAAe,SAAwC;AACpE,MAAI,mBAAmB;AACrB,QAAK,KAAK;IACR,YAAY;IACZ,OAAO;KACL,MAAM;KACN,SAAS;KACV;IACD,IAAI,QAAQ;IACZ,MAAM,EAAE;IACR,IAAI;IACJ,MAAM;IACP,CAAC;AACF;;EAGF,MAAM,kBAAkB,IAAI,iBAAiB;AAC7C,0BAAwB;AACxB,sBAAoB,QAAQ;AAE5B,MAAI;GACF,MAAM,SAAS,MAAM,kBACnB;IACE;IACA,MAAM,QAAQ;IACd,iBAAiB;AACf,UAAK,KAAK;MACR,IAAI,QAAQ;MACZ,MAAM;MACP,CAAC;;IAEJ,aAAa,SACX,IAAI,SAAyB,YAAY;KACvC,MAAM,SAAS,YAAY;AAC3B,sBAAiB,IAAI,QAAQ,QAAQ;AACrC,UAAK,KAAK;MACR,GAAG;MACH;MACA,MAAM;MACP,CAAC;MACF;IACJ,WAAW,QAAQ;IACpB,EACD,QAAQ,QACT;AAED,QAAK,KAAK;IACR,GAAG;IACH,IAAI,QAAQ;IACZ,MAAM;IACP,CAAC;WACK,OAAO;AACd,QAAK,KAAK;IACR,YAAY;IACZ,OAAO;KACL,MAAM;KACN,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;KAChE;IACD,IAAI,QAAQ;IACZ,MAAM,EAAE;IACR,IAAI;IACJ,MAAM;IACP,CAAC;YACM;AACR,oBAAiB,OAAO;AACxB,2BAAwB;AACxB,uBAAoB;;;CAIxB,MAAM,cAAc,KAAK,WAAW,YAA+B;AACjE,UAAQ,QAAQ,MAAhB;GACE,KAAK;AACH,QAAI,QAAQ,OAAO,kBACjB,wBAAuB,OAAO;AAEhC;GACF,KAAK;AACH,IAAK,eAAe,QAAQ;AAC5B;GACF,KAAK,eAAe;IAClB,MAAM,UAAU,iBAAiB,IAAI,QAAQ,OAAO;AACpD,qBAAiB,OAAO,QAAQ,OAAO;AACvC,cAAU,QAAQ;AAClB;;;GAGJ;AAEF,cAAa;AACX,MAAI,OAAO,gBAAgB,WACzB,cAAa;AAEf,mBAAiB,OAAO;AACxB,yBAAuB,OAAO;AAC9B,0BAAwB;AACxB,sBAAoB"}
|
|
1
|
+
{"version":3,"file":"protocolEndpoint.js","names":["activeAbortController: AbortController | undefined","activeExecutionId: string | undefined"],"sources":["../../../protocol/src/messages.ts","../../src/runner/protocolEndpoint.ts"],"sourcesContent":["import type {\n ExecuteResult,\n ExecutorRuntimeOptions,\n ProviderManifest,\n ToolCall,\n ToolCallResult,\n} from \"@execbox/core\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value);\n}\n\nfunction isRuntimeOptions(value: unknown): value is ExecutorRuntimeOptions {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n isFiniteNumber(value.maxLogChars) &&\n isFiniteNumber(value.maxLogLines) &&\n isFiniteNumber(value.memoryLimitBytes) &&\n isFiniteNumber(value.timeoutMs)\n );\n}\n\nfunction isProviderManifest(value: unknown): value is ProviderManifest {\n if (!isRecord(value) || typeof value.name !== \"string\") {\n return false;\n }\n\n if (!isRecord(value.tools) || typeof value.types !== \"string\") {\n return false;\n }\n\n return Object.values(value.tools).every(\n (tool) =>\n isRecord(tool) &&\n typeof tool.originalName === \"string\" &&\n typeof tool.safeName === \"string\" &&\n (tool.description === undefined || typeof tool.description === \"string\"),\n );\n}\n\nfunction isExecuteError(\n value: unknown,\n): value is { code: string; message: string } {\n return (\n isRecord(value) &&\n typeof value.code === \"string\" &&\n typeof value.message === \"string\"\n );\n}\n\nfunction isDonePayload(value: unknown): value is DoneMessage {\n if (!isRecord(value) || !isFiniteNumber(value.durationMs)) {\n return false;\n }\n\n if (\n !Array.isArray(value.logs) ||\n !value.logs.every((log) => typeof log === \"string\")\n ) {\n return false;\n }\n\n if (typeof value.ok !== \"boolean\") {\n return false;\n }\n\n return value.ok ? true : isExecuteError(value.error);\n}\n\n/**\n * Message sent from dispatcher to runner to start one execution session.\n */\nexport interface ExecuteMessage {\n code: string;\n id: string;\n options: ExecutorRuntimeOptions;\n providers: ProviderManifest[];\n type: \"execute\";\n}\n\n/**\n * Message sent from dispatcher to request prompt cancellation.\n */\nexport interface CancelMessage {\n id: string;\n type: \"cancel\";\n}\n\n/**\n * Message sent from a runner when guest code invokes a host tool.\n */\nexport interface ToolCallMessage extends ToolCall {\n callId: string;\n type: \"tool_call\";\n}\n\n/**\n * Message carrying a trusted host tool result back to the runner.\n */\nexport type ToolResultMessage = {\n callId: string;\n type: \"tool_result\";\n} & ToolCallResult;\n\n/**\n * Message indicating the runner has finished bootstrapping guest execution timing.\n */\nexport interface StartedMessage {\n id: string;\n type: \"started\";\n}\n\n/**\n * Final successful execution result returned by a runner.\n *\n * Node IPC can omit `undefined` fields during serialization, so `result`\n * remains optional at the protocol boundary and is normalized by the host.\n */\nexport type DoneSuccessMessage<T = unknown> = {\n durationMs: number;\n id: string;\n logs: string[];\n ok: true;\n result?: T;\n type: \"done\";\n};\n\n/**\n * Final failed execution result returned by a runner.\n */\nexport type DoneFailureMessage = {\n id: string;\n type: \"done\";\n} & Extract<ExecuteResult, { ok: false }>;\n\n/**\n * Final execution result returned by a runner.\n */\nexport type DoneMessage = DoneSuccessMessage | DoneFailureMessage;\n\n/**\n * Messages accepted by a runner transport endpoint.\n */\nexport type DispatcherMessage =\n | CancelMessage\n | ExecuteMessage\n | ToolResultMessage;\n\n/**\n * Messages emitted by a runner transport endpoint.\n */\nexport type RunnerMessage = DoneMessage | StartedMessage | ToolCallMessage;\n\n/**\n * Returns whether an unknown value is a dispatcher-to-runner message.\n */\nexport function isDispatcherMessage(\n value: unknown,\n): value is DispatcherMessage {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case \"cancel\":\n return typeof value.id === \"string\";\n case \"execute\":\n return (\n typeof value.code === \"string\" &&\n typeof value.id === \"string\" &&\n isRuntimeOptions(value.options) &&\n Array.isArray(value.providers) &&\n value.providers.every(isProviderManifest)\n );\n case \"tool_result\":\n if (typeof value.callId !== \"string\" || typeof value.ok !== \"boolean\") {\n return false;\n }\n\n if (value.ok) {\n return \"result\" in value;\n }\n\n return isExecuteError(value.error);\n default:\n return false;\n }\n}\n\n/**\n * Returns whether an unknown value is a runner-to-dispatcher message.\n */\nexport function isRunnerMessage(value: unknown): value is RunnerMessage {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n switch (value.type) {\n case \"started\":\n return typeof value.id === \"string\";\n case \"tool_call\":\n return (\n typeof value.callId === \"string\" &&\n typeof value.providerName === \"string\" &&\n typeof value.safeToolName === \"string\" &&\n \"input\" in value\n );\n case \"done\":\n return typeof value.id === \"string\" && isDonePayload(value);\n default:\n return false;\n }\n}\n","import { randomUUID } from \"node:crypto\";\n\nimport type {\n DispatcherMessage,\n ExecuteMessage,\n RunnerMessage,\n ToolCallResult,\n} from \"@execbox/protocol\";\nimport { isDispatcherMessage } from \"../../../protocol/src/messages.ts\";\n\nimport { runQuickJsSession } from \"./index.ts\";\n\n/**\n * Minimal worker/process-side port used by the shared QuickJS protocol endpoint.\n */\nexport interface QuickJsProtocolPort {\n onMessage(handler: (message: DispatcherMessage) => void): void | (() => void);\n send(message: RunnerMessage): void;\n}\n\n/**\n * Attaches the shared QuickJS protocol loop to a worker/process messaging port.\n */\nexport function attachQuickJsProtocolEndpoint(\n port: QuickJsProtocolPort,\n): () => void {\n const pendingToolCalls = new Map<string, (result: ToolCallResult) => void>();\n let activeAbortController: AbortController | undefined;\n let activeExecutionId: string | undefined;\n\n async function startExecution(message: ExecuteMessage): Promise<void> {\n if (activeExecutionId) {\n port.send({\n durationMs: 0,\n error: {\n code: \"internal_error\",\n message: \"QuickJS endpoint already has an active execution\",\n },\n id: message.id,\n logs: [],\n ok: false,\n type: \"done\",\n });\n return;\n }\n\n const abortController = new AbortController();\n activeAbortController = abortController;\n activeExecutionId = message.id;\n\n try {\n const result = await runQuickJsSession(\n {\n abortController,\n code: message.code,\n onStarted: () => {\n port.send({\n id: message.id,\n type: \"started\",\n });\n },\n onToolCall: (call) =>\n new Promise<ToolCallResult>((resolve) => {\n const callId = randomUUID();\n pendingToolCalls.set(callId, resolve);\n port.send({\n ...call,\n callId,\n type: \"tool_call\",\n });\n }),\n providers: message.providers,\n },\n message.options,\n );\n\n port.send({\n ...result,\n id: message.id,\n type: \"done\",\n });\n } catch (error) {\n port.send({\n durationMs: 0,\n error: {\n code: \"internal_error\",\n message: error instanceof Error ? error.message : String(error),\n },\n id: message.id,\n logs: [],\n ok: false,\n type: \"done\",\n });\n } finally {\n pendingToolCalls.clear();\n activeAbortController = undefined;\n activeExecutionId = undefined;\n }\n }\n\n const maybeDetach = port.onMessage((message: DispatcherMessage) => {\n if (!isDispatcherMessage(message)) {\n return;\n }\n\n switch (message.type) {\n case \"cancel\":\n if (message.id === activeExecutionId) {\n activeAbortController?.abort();\n }\n break;\n case \"execute\":\n void startExecution(message);\n break;\n case \"tool_result\": {\n const resolve = pendingToolCalls.get(message.callId);\n pendingToolCalls.delete(message.callId);\n resolve?.(message);\n break;\n }\n }\n });\n\n return () => {\n if (typeof maybeDetach === \"function\") {\n maybeDetach();\n }\n pendingToolCalls.clear();\n activeAbortController?.abort();\n activeAbortController = undefined;\n activeExecutionId = undefined;\n };\n}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;AAC5B;GACF,KAAK,eAAe;IAClB,MAAM,UAAU,iBAAiB,IAAI,QAAQ,OAAO;AACpD,qBAAiB,OAAO,QAAQ,OAAO;AACvC,cAAU,QAAQ;AAClB;;;GAGJ;AAEF,cAAa;AACX,MAAI,OAAO,gBAAgB,WACzB,cAAa;AAEf,mBAAiB,OAAO;AACxB,yBAAuB,OAAO;AAC9B,0BAAwB;AACxB,sBAAoB"}
|
|
@@ -5395,10 +5395,23 @@ function injectProviders(context, providers, signal, trustedHostErrorKey, onTool
|
|
|
5395
5395
|
function createToolHandle(context, providerName, safeToolName, signal, trustedHostErrorKey, onToolCall) {
|
|
5396
5396
|
return context.newFunction(safeToolName, (...args) => {
|
|
5397
5397
|
const deferred = context.newPromise();
|
|
5398
|
-
const input = args[0] === void 0 ? void 0 : context.dump(args[0]);
|
|
5399
5398
|
const disposeDeferred = () => {
|
|
5400
5399
|
if (context.alive && deferred.alive) deferred.dispose();
|
|
5401
5400
|
};
|
|
5401
|
+
let input;
|
|
5402
|
+
try {
|
|
5403
|
+
input = args[0] === void 0 ? void 0 : fromGuestHandle(context, args[0]);
|
|
5404
|
+
} catch (error) {
|
|
5405
|
+
const executeError = isExecuteFailure(error) ? error : new ExecuteFailure("serialization_error", "Guest code passed a non-serializable tool input");
|
|
5406
|
+
const errorHandle = createGuestErrorHandle(context, executeError.code, executeError.message, trustedHostErrorKey);
|
|
5407
|
+
try {
|
|
5408
|
+
deferred.reject(errorHandle);
|
|
5409
|
+
return deferred.handle;
|
|
5410
|
+
} finally {
|
|
5411
|
+
errorHandle.dispose();
|
|
5412
|
+
queueMicrotask(disposeDeferred);
|
|
5413
|
+
}
|
|
5414
|
+
}
|
|
5402
5415
|
const onAbort = () => {
|
|
5403
5416
|
signal.removeEventListener("abort", onAbort);
|
|
5404
5417
|
if (!context.alive || !deferred.alive) {
|
|
@@ -5467,6 +5480,7 @@ function createToolHandle(context, providerName, safeToolName, signal, trustedHo
|
|
|
5467
5480
|
*/
|
|
5468
5481
|
async function runQuickJsSession(request, options = {}) {
|
|
5469
5482
|
const loadModule = async () => {
|
|
5483
|
+
if (options.module) return options.module;
|
|
5470
5484
|
return options.loadModule ? await options.loadModule() : await loadDefaultModule();
|
|
5471
5485
|
};
|
|
5472
5486
|
const maxLogChars = options.maxLogChars ?? DEFAULT_MAX_LOG_CHARS;
|
|
@@ -5554,4 +5568,4 @@ async function runQuickJsSession(request, options = {}) {
|
|
|
5554
5568
|
|
|
5555
5569
|
//#endregion
|
|
5556
5570
|
export { runQuickJsSession as t };
|
|
5557
|
-
//# sourceMappingURL=runner-
|
|
5571
|
+
//# sourceMappingURL=runner-B4UG88h1.js.map
|