conductor-node-mcp 14.23.7 → 14.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +10 -7
  2. package/bridge.d.mts +11 -0
  3. package/bridge.d.mts.map +1 -0
  4. package/bridge.d.ts +11 -0
  5. package/bridge.d.ts.map +1 -0
  6. package/bridge.js +92 -0
  7. package/bridge.js.map +1 -0
  8. package/bridge.mjs +89 -0
  9. package/bridge.mjs.map +1 -0
  10. package/code-tool-paths.cjs +6 -0
  11. package/code-tool-paths.cjs.map +1 -1
  12. package/code-tool-paths.d.cts +1 -0
  13. package/code-tool-paths.d.cts.map +1 -1
  14. package/code-tool.d.mts.map +1 -1
  15. package/code-tool.d.ts.map +1 -1
  16. package/code-tool.js +4 -3
  17. package/code-tool.js.map +1 -1
  18. package/code-tool.mjs +3 -2
  19. package/code-tool.mjs.map +1 -1
  20. package/deno-bootstrap/index.ts +72 -0
  21. package/deno-http-worker/DenoHTTPWorker.d.mts +96 -0
  22. package/deno-http-worker/DenoHTTPWorker.d.mts.map +1 -0
  23. package/deno-http-worker/DenoHTTPWorker.d.ts +96 -0
  24. package/deno-http-worker/DenoHTTPWorker.d.ts.map +1 -0
  25. package/deno-http-worker/DenoHTTPWorker.js +310 -0
  26. package/deno-http-worker/DenoHTTPWorker.js.map +1 -0
  27. package/deno-http-worker/DenoHTTPWorker.mjs +302 -0
  28. package/deno-http-worker/DenoHTTPWorker.mjs.map +1 -0
  29. package/deno-http-worker/index.d.mts +2 -0
  30. package/deno-http-worker/index.d.mts.map +1 -0
  31. package/deno-http-worker/index.d.ts +2 -0
  32. package/deno-http-worker/index.d.ts.map +1 -0
  33. package/deno-http-worker/index.js +8 -0
  34. package/deno-http-worker/index.js.map +1 -0
  35. package/deno-http-worker/index.mjs +3 -0
  36. package/deno-http-worker/index.mjs.map +1 -0
  37. package/index.js +4 -3
  38. package/index.js.map +1 -1
  39. package/index.mjs +4 -3
  40. package/index.mjs.map +1 -1
  41. package/package.json +32 -3
  42. package/server.d.mts +1 -0
  43. package/server.d.mts.map +1 -1
  44. package/server.d.ts +1 -0
  45. package/server.d.ts.map +1 -1
  46. package/server.js +3 -2
  47. package/server.js.map +1 -1
  48. package/server.mjs +2 -1
  49. package/server.mjs.map +1 -1
  50. package/src/bridge.ts +113 -0
  51. package/src/code-tool-paths.cts +6 -0
  52. package/src/code-tool.ts +3 -2
  53. package/src/deno-http-worker/DenoHTTPWorker.ts +404 -0
  54. package/src/deno-http-worker/index.ts +8 -0
  55. package/src/index.ts +9 -8
  56. package/src/server.ts +3 -1
  57. package/src/stdio.ts +51 -12
  58. package/stdio.d.mts +3 -2
  59. package/stdio.d.mts.map +1 -1
  60. package/stdio.d.ts +3 -2
  61. package/stdio.d.ts.map +1 -1
  62. package/stdio.js +43 -11
  63. package/stdio.js.map +1 -1
  64. package/stdio.mjs +42 -10
  65. package/stdio.mjs.map +1 -1
@@ -0,0 +1,96 @@
1
+ import { type SpawnOptions } from 'node:child_process';
2
+ import http from 'node:http';
3
+ import type { Readable } from 'node:stream';
4
+ type OnExitListener = (exitCode: number, signal: string) => void;
5
+ export interface MinimalChildProcess {
6
+ stdout: Readable | null;
7
+ stderr: Readable | null;
8
+ readonly pid?: number | undefined;
9
+ readonly exitCode: number | null;
10
+ kill(signal?: NodeJS.Signals | number): boolean;
11
+ on(event: string, listener: (...args: any[]) => void): this;
12
+ on(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
13
+ on(event: 'disconnect', listener: () => void): this;
14
+ on(event: 'error', listener: (err: Error) => void): this;
15
+ on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
16
+ on(event: 'spawn', listener: () => void): this;
17
+ }
18
+ export interface DenoWorkerOptions {
19
+ /**
20
+ * The path to the executable that should be use when spawning the subprocess.
21
+ * Defaults to "deno".
22
+ */
23
+ denoExecutable: string | string[];
24
+ /**
25
+ * The path to the script that bootstraps the worker environment in Deno.
26
+ * Required: this vendored copy ships no default (see deno-bootstrap/index.ts).
27
+ */
28
+ denoBootstrapScriptPath: string;
29
+ /**
30
+ * Flags that are passed to the Deno process. These flags follow the `deno
31
+ * run` command and can be used to enabled/disabled various permissions and
32
+ * features. These flags will be modified to ensure that the deno process can
33
+ * run the http server we'll be connecting to. Toggle the
34
+ * printCommandAndArguments if you need to understand what the final flag
35
+ * values are.
36
+ */
37
+ runFlags: string[];
38
+ /**
39
+ * Print stdout and stderr to the console with a "[deno]" prefix. This is
40
+ * useful for debugging.
41
+ */
42
+ printOutput: boolean;
43
+ /**
44
+ * Print out the command and arguments that are executed.
45
+ */
46
+ printCommandAndArguments: boolean;
47
+ /**
48
+ * Options used to spawn the Deno child process
49
+ */
50
+ spawnOptions: SpawnOptions;
51
+ /**
52
+ * Callback that is called when the process is spawned.
53
+ */
54
+ onSpawn?: (process: MinimalChildProcess) => void;
55
+ /**
56
+ * Provide an alternative spawn functions. Defaults to child_process.spawn.
57
+ */
58
+ spawnFunc: (command: string, args: string[], options: SpawnOptions) => MinimalChildProcess;
59
+ }
60
+ export interface DenoHTTPWorker {
61
+ /**
62
+ * Terminate the worker. This kills the process with SIGKILL if it is still
63
+ * running, closes the http connection, and deletes the socket file.
64
+ */
65
+ terminate(): void;
66
+ /**
67
+ * Gracefully shuts down the worker process and waits for any unresolved
68
+ * promises to exit.
69
+ */
70
+ shutdown(): void;
71
+ /**
72
+ * request calls http.request but patches the options to work with our
73
+ * connection pool and safely handle rewriting various headers.
74
+ */
75
+ request(url: string | URL, options: http.RequestOptions, callback: (response: http.IncomingMessage) => void): http.ClientRequest;
76
+ get stdout(): Readable;
77
+ get stderr(): Readable;
78
+ /**
79
+ * Adds the given listener for the "exit" event.
80
+ */
81
+ addEventListener(type: 'exit', listener: OnExitListener): void;
82
+ }
83
+ export declare class EarlyExitDenoHTTPWorkerError extends Error {
84
+ message: string;
85
+ stderr: string;
86
+ stdout: string;
87
+ code: number;
88
+ signal: string;
89
+ constructor(message: string, stderr: string, stdout: string, code: number, signal: string);
90
+ }
91
+ /**
92
+ * Create a new DenoHTTPWorker. This function will start a worker and being
93
+ */
94
+ export declare const newDenoHTTPWorker: (script: string | URL, options?: Partial<DenoWorkerOptions>) => Promise<DenoHTTPWorker>;
95
+ export {};
96
+ //# sourceMappingURL=DenoHTTPWorker.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DenoHTTPWorker.d.mts","sourceRoot":"","sources":["../src/deno-http-worker/DenoHTTPWorker.ts"],"names":[],"mappings":"AAeA,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEjE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IAChD,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5D,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;IACjG,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,QA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AAI,CAAC,aAAa,CAAC;IACtB,IAAI,MAAM,IAAI,QAAQ,CAAC;IACvB,IAAI,MAAM,IAAI,QAAQ,CAAC;IACvB;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;CAChE;AA2BD,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQ1F;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,GAAG,GAAG,EACpB,UAAS,OAAO,CAAC,iBAAiB,CAAM,KACvC,OAAO,CAAC,cAAc,CAoIxB,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { type SpawnOptions } from 'node:child_process';
2
+ import http from 'node:http';
3
+ import type { Readable } from 'node:stream';
4
+ type OnExitListener = (exitCode: number, signal: string) => void;
5
+ export interface MinimalChildProcess {
6
+ stdout: Readable | null;
7
+ stderr: Readable | null;
8
+ readonly pid?: number | undefined;
9
+ readonly exitCode: number | null;
10
+ kill(signal?: NodeJS.Signals | number): boolean;
11
+ on(event: string, listener: (...args: any[]) => void): this;
12
+ on(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
13
+ on(event: 'disconnect', listener: () => void): this;
14
+ on(event: 'error', listener: (err: Error) => void): this;
15
+ on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
16
+ on(event: 'spawn', listener: () => void): this;
17
+ }
18
+ export interface DenoWorkerOptions {
19
+ /**
20
+ * The path to the executable that should be use when spawning the subprocess.
21
+ * Defaults to "deno".
22
+ */
23
+ denoExecutable: string | string[];
24
+ /**
25
+ * The path to the script that bootstraps the worker environment in Deno.
26
+ * Required: this vendored copy ships no default (see deno-bootstrap/index.ts).
27
+ */
28
+ denoBootstrapScriptPath: string;
29
+ /**
30
+ * Flags that are passed to the Deno process. These flags follow the `deno
31
+ * run` command and can be used to enabled/disabled various permissions and
32
+ * features. These flags will be modified to ensure that the deno process can
33
+ * run the http server we'll be connecting to. Toggle the
34
+ * printCommandAndArguments if you need to understand what the final flag
35
+ * values are.
36
+ */
37
+ runFlags: string[];
38
+ /**
39
+ * Print stdout and stderr to the console with a "[deno]" prefix. This is
40
+ * useful for debugging.
41
+ */
42
+ printOutput: boolean;
43
+ /**
44
+ * Print out the command and arguments that are executed.
45
+ */
46
+ printCommandAndArguments: boolean;
47
+ /**
48
+ * Options used to spawn the Deno child process
49
+ */
50
+ spawnOptions: SpawnOptions;
51
+ /**
52
+ * Callback that is called when the process is spawned.
53
+ */
54
+ onSpawn?: (process: MinimalChildProcess) => void;
55
+ /**
56
+ * Provide an alternative spawn functions. Defaults to child_process.spawn.
57
+ */
58
+ spawnFunc: (command: string, args: string[], options: SpawnOptions) => MinimalChildProcess;
59
+ }
60
+ export interface DenoHTTPWorker {
61
+ /**
62
+ * Terminate the worker. This kills the process with SIGKILL if it is still
63
+ * running, closes the http connection, and deletes the socket file.
64
+ */
65
+ terminate(): void;
66
+ /**
67
+ * Gracefully shuts down the worker process and waits for any unresolved
68
+ * promises to exit.
69
+ */
70
+ shutdown(): void;
71
+ /**
72
+ * request calls http.request but patches the options to work with our
73
+ * connection pool and safely handle rewriting various headers.
74
+ */
75
+ request(url: string | URL, options: http.RequestOptions, callback: (response: http.IncomingMessage) => void): http.ClientRequest;
76
+ get stdout(): Readable;
77
+ get stderr(): Readable;
78
+ /**
79
+ * Adds the given listener for the "exit" event.
80
+ */
81
+ addEventListener(type: 'exit', listener: OnExitListener): void;
82
+ }
83
+ export declare class EarlyExitDenoHTTPWorkerError extends Error {
84
+ message: string;
85
+ stderr: string;
86
+ stdout: string;
87
+ code: number;
88
+ signal: string;
89
+ constructor(message: string, stderr: string, stdout: string, code: number, signal: string);
90
+ }
91
+ /**
92
+ * Create a new DenoHTTPWorker. This function will start a worker and being
93
+ */
94
+ export declare const newDenoHTTPWorker: (script: string | URL, options?: Partial<DenoWorkerOptions>) => Promise<DenoHTTPWorker>;
95
+ export {};
96
+ //# sourceMappingURL=DenoHTTPWorker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DenoHTTPWorker.d.ts","sourceRoot":"","sources":["../src/deno-http-worker/DenoHTTPWorker.ts"],"names":[],"mappings":"AAeA,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAEjE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;IAChD,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5D,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,KAAK,IAAI,G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AAE,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,KAAK,IAAI,GACjD,IAAI,CAAC,aAAa,CAAC;IACtB,IAAI,MAAM,IAAI,QAAQ,CAAC;IACvB,IAAI,MAAM,IAAI,QAAQ,CAAC;IACvB;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;CAChE;AA2BD,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQ1F;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,GAAG,GAAG,EACpB,UAAS,OAAO,CAAC,iBAAiB,CAAM,KACvC,OAAO,CAAC,cAAc,CAoIxB,CAAC"}
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ // Vendored from the Conductor fork of @valtown/deno-http-worker, version
4
+ // 0.0.21-conductor.2 (github.com/conductor-is/deno-http-worker @ 6fab0714c57a,
5
+ // dist/DenoHTTPWorker.js). Upstream: github.com/val-town/deno-http-worker,
6
+ // copyright (c) Val Town, MIT License. Vendored so the package has no git
7
+ // dependency (npx on a machine without git failed with "spawn git ENOENT").
8
+ //
9
+ // Changes from the fork's dist file: the Deno bootstrap script path is passed
10
+ // by the caller (see code-tool-paths.cts and ../../deno-bootstrap/index.ts)
11
+ // instead of being resolved relative to import.meta.url, and the public
12
+ // types from dist/DenoHTTPWorker.d.ts are inlined. The runtime body is
13
+ // otherwise verbatim, including the fork's version-aware unix-socket grant
14
+ // under --allow-net for Deno >= 2.9.
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.newDenoHTTPWorker = exports.EarlyExitDenoHTTPWorkerError = void 0;
20
+ const node_path_1 = __importDefault(require("node:path"));
21
+ const node_child_process_1 = require("node:child_process");
22
+ const node_readline_1 = __importDefault(require("node:readline"));
23
+ const node_http_1 = __importDefault(require("node:http"));
24
+ const promises_1 = __importDefault(require("node:fs/promises"));
25
+ const node_os_1 = __importDefault(require("node:os"));
26
+ const node_url_1 = require("node:url");
27
+ const unixNetGrantCache = new Map();
28
+ async function denoSupportsUnixNetPermission(denoExecutable) {
29
+ const argv = typeof denoExecutable === 'string' ? [denoExecutable] : denoExecutable;
30
+ const key = argv.join('\u0000');
31
+ if (unixNetGrantCache.has(key)) {
32
+ return unixNetGrantCache.get(key);
33
+ }
34
+ let supported = true;
35
+ try {
36
+ const stdout = await new Promise((resolve, reject) => {
37
+ (0, node_child_process_1.execFile)(argv[0], [...argv.slice(1), '--version'], { timeout: 5000 }, (err, out) => err ? reject(err) : resolve(String(out)));
38
+ });
39
+ const m = /deno (\d+)\.(\d+)\./.exec(stdout);
40
+ if (m) {
41
+ supported = Number(m[1]) > 2 || (Number(m[1]) === 2 && Number(m[2]) >= 9);
42
+ }
43
+ }
44
+ catch {
45
+ // Unknown binary; default to the modern grant.
46
+ }
47
+ unixNetGrantCache.set(key, supported);
48
+ return supported;
49
+ }
50
+ class EarlyExitDenoHTTPWorkerError extends Error {
51
+ message;
52
+ stderr;
53
+ stdout;
54
+ code;
55
+ signal;
56
+ constructor(message, stderr, stdout, code, signal) {
57
+ super(message);
58
+ this.message = message;
59
+ this.stderr = stderr;
60
+ this.stdout = stdout;
61
+ this.code = code;
62
+ this.signal = signal;
63
+ }
64
+ }
65
+ exports.EarlyExitDenoHTTPWorkerError = EarlyExitDenoHTTPWorkerError;
66
+ /**
67
+ * Create a new DenoHTTPWorker. This function will start a worker and being
68
+ */
69
+ const newDenoHTTPWorker = async (script, options = {}) => {
70
+ const _options = {
71
+ denoExecutable: 'deno',
72
+ runFlags: [],
73
+ printCommandAndArguments: false,
74
+ spawnOptions: {},
75
+ printOutput: false,
76
+ spawnFunc: node_child_process_1.spawn,
77
+ ...options,
78
+ };
79
+ if (!_options.denoBootstrapScriptPath) {
80
+ throw new Error('denoBootstrapScriptPath is required');
81
+ }
82
+ let scriptArgs;
83
+ // Create the socket location that we'll use to communicate with Deno.
84
+ const socketFile = node_path_1.default.join(node_os_1.default.tmpdir(), `${crypto.randomUUID()}-deno-http.sock`);
85
+ // If we have a file import, make sure we allow read access to the file.
86
+ const allowReadFlagValue = typeof script === 'string' ? socketFile : `${socketFile},${(0, node_url_1.fileURLToPath)(script)}`;
87
+ // Deno >= 2.9 moved unix-socket listening under the net permission, but
88
+ // older Deno rejects "unix:" entries in --allow-net at startup ("invalid
89
+ // port"). Probe the binary once per executable and grant the socket the
90
+ // way this Deno accepts; < 2.9 needs only the read/write grants below.
91
+ const grantUnixNet = await denoSupportsUnixNetPermission(_options.denoExecutable);
92
+ let allowReadFound = false;
93
+ let allowWriteFound = false;
94
+ let allowNetFound = false;
95
+ _options.runFlags = _options.runFlags.map((flag) => {
96
+ if (flag === '--allow-read' || flag === '--allow-all') {
97
+ allowReadFound = true;
98
+ }
99
+ if (flag === '--allow-write' || flag === '--allow-all') {
100
+ allowWriteFound = true;
101
+ }
102
+ if (flag === '--allow-net' || flag === '--allow-all') {
103
+ allowNetFound = true;
104
+ }
105
+ if (flag.startsWith('--allow-read=')) {
106
+ allowReadFound = true;
107
+ return (flag += `,${allowReadFlagValue}`);
108
+ }
109
+ if (flag.startsWith('--allow-write=')) {
110
+ allowWriteFound = true;
111
+ return (flag += `,${socketFile}`);
112
+ }
113
+ if (flag.startsWith('--allow-net=')) {
114
+ allowNetFound = true;
115
+ return grantUnixNet ? (flag += `,unix:${socketFile}`) : flag;
116
+ }
117
+ return flag;
118
+ });
119
+ if (!allowReadFound) {
120
+ _options.runFlags.push(`--allow-read=${allowReadFlagValue}`);
121
+ }
122
+ if (!allowWriteFound) {
123
+ _options.runFlags.push(`--allow-write=${socketFile}`);
124
+ }
125
+ if (!allowNetFound && grantUnixNet) {
126
+ _options.runFlags.push(`--allow-net=unix:${socketFile}`);
127
+ }
128
+ if (typeof script === 'string') {
129
+ scriptArgs = [socketFile, 'script', script];
130
+ }
131
+ else {
132
+ scriptArgs = [socketFile, 'import', script.href];
133
+ }
134
+ if (Array.isArray(_options.denoExecutable) && _options.denoExecutable.length === 0) {
135
+ throw new Error('denoExecutable must not be an empty array');
136
+ }
137
+ const command = typeof _options.denoExecutable === 'string' ? _options.denoExecutable : _options.denoExecutable[0];
138
+ const bootstrap = await promises_1.default.readFile(_options.denoBootstrapScriptPath, 'utf-8');
139
+ return new Promise((resolve, reject) => {
140
+ (async () => {
141
+ const args = [
142
+ ...(typeof _options.denoExecutable === 'string' ? [] : _options.denoExecutable.slice(1)),
143
+ 'run',
144
+ ..._options.runFlags,
145
+ 'data:text/typescript,' + encodeURIComponent(bootstrap),
146
+ ...scriptArgs,
147
+ ];
148
+ if (_options.printCommandAndArguments) {
149
+ console.log('Spawning deno process:', [command, ...args]);
150
+ }
151
+ const process = _options.spawnFunc(command, args, _options.spawnOptions);
152
+ let running = false;
153
+ let exited = false;
154
+ let worker = undefined;
155
+ process.on('exit', (code, signal) => {
156
+ exited = true;
157
+ if (!running) {
158
+ const stderr = process.stderr?.read()?.toString();
159
+ const stdout = process.stdout?.read()?.toString();
160
+ reject(new EarlyExitDenoHTTPWorkerError('Deno exited before being ready', stderr, stdout, code, signal));
161
+ promises_1.default.rm(socketFile).catch(() => { });
162
+ }
163
+ else {
164
+ worker._terminate(code, signal);
165
+ }
166
+ });
167
+ options.onSpawn && options.onSpawn(process);
168
+ const stdout = process.stdout;
169
+ const stderr = process.stderr;
170
+ if (_options.printOutput) {
171
+ node_readline_1.default.createInterface({ input: stdout }).on('line', (line) => {
172
+ console.log('[deno]', line);
173
+ });
174
+ node_readline_1.default.createInterface({ input: stderr }).on('line', (line) => {
175
+ console.error('[deno]', line);
176
+ });
177
+ }
178
+ // Wait for the socket file to be created by the Deno process.
179
+ for (;;) {
180
+ if (exited) {
181
+ break;
182
+ }
183
+ try {
184
+ await promises_1.default.stat(socketFile);
185
+ // File exists
186
+ break;
187
+ }
188
+ catch (err) {
189
+ await new Promise((resolve) => setTimeout(resolve, 20));
190
+ }
191
+ }
192
+ worker = new denoHTTPWorker(socketFile, process, stdout, stderr);
193
+ running = true;
194
+ await worker.warmRequest();
195
+ return worker;
196
+ })()
197
+ .then(resolve)
198
+ .catch(reject);
199
+ });
200
+ };
201
+ exports.newDenoHTTPWorker = newDenoHTTPWorker;
202
+ class denoHTTPWorker {
203
+ #onexitListeners;
204
+ #process;
205
+ #socketFile;
206
+ #stderr;
207
+ #stdout;
208
+ #terminated = false;
209
+ #agent;
210
+ constructor(socketFile, process, stdout, stderr) {
211
+ this.#onexitListeners = [];
212
+ this.#process = process;
213
+ this.#socketFile = socketFile;
214
+ this.#stderr = stderr;
215
+ this.#stdout = stdout;
216
+ this.#agent = new node_http_1.default.Agent({ keepAlive: true });
217
+ }
218
+ _terminate(code, signal) {
219
+ if (this.#terminated) {
220
+ return;
221
+ }
222
+ this.#terminated = true;
223
+ if (this.#process && this.#process.exitCode === null) {
224
+ forceKill(this.#process.pid);
225
+ }
226
+ this.#agent.destroy();
227
+ promises_1.default.rm(this.#socketFile).catch(() => { });
228
+ for (const onexit of this.#onexitListeners) {
229
+ onexit(code ?? 1, signal ?? '');
230
+ }
231
+ }
232
+ terminate() {
233
+ this._terminate();
234
+ }
235
+ shutdown() {
236
+ this.#process.kill('SIGINT');
237
+ }
238
+ request(url, options, callback) {
239
+ options.headers = options.headers || {};
240
+ // TODO: ensure these are handled with the correct casing?
241
+ delete options.headers['x-deno-worker-host'];
242
+ delete options.headers['x-deno-worker-connection'];
243
+ // NodeJS will send both the host and the connection headers
244
+ // (https://nodejs.org/api/http.html#new-agentoptions). We don't want these
245
+ // to make it to Deno unless they are explicitly set by the user. So store
246
+ // them to reconstruct on the other size.
247
+ if (options.headers.host) {
248
+ options.headers['X-Deno-Worker-Host'] = options.headers.host;
249
+ }
250
+ if (options.headers.connection) {
251
+ options.headers['X-Deno-Worker-Connection'] = options.headers.connection;
252
+ }
253
+ options.headers = {
254
+ ...options.headers,
255
+ 'X-Deno-Worker-URL': typeof url === 'string' ? url : url.toString(),
256
+ };
257
+ url = 'http://deno';
258
+ options.agent = this.#agent;
259
+ options.socketPath = this.#socketFile;
260
+ return node_http_1.default.request(url, options, callback);
261
+ }
262
+ // We send this request to Deno so that we get a live connection in the
263
+ // http.Agent and subsequent requests are do not have to wait for a new
264
+ // connection.
265
+ async warmRequest() {
266
+ return new Promise((resolve, reject) => {
267
+ const req = node_http_1.default.request('http://deno', { agent: this.#agent, socketPath: this.#socketFile }, (resp) => {
268
+ resp.on('error', reject);
269
+ resp.on('data', () => { });
270
+ resp.on('close', () => {
271
+ resolve();
272
+ });
273
+ });
274
+ req.on('error', reject);
275
+ req.end();
276
+ });
277
+ }
278
+ get stdout() {
279
+ return this.#stdout;
280
+ }
281
+ get stderr() {
282
+ return this.#stderr;
283
+ }
284
+ addEventListener(type, listener) {
285
+ this.#onexitListeners.push(listener);
286
+ }
287
+ }
288
+ /**
289
+ * Forcefully kills the process with the given ID.
290
+ * On Linux/Unix, this means sending the process the SIGKILL signal.
291
+ */
292
+ function forceKill(pid) {
293
+ return killUnix(pid);
294
+ }
295
+ function killUnix(pid) {
296
+ try {
297
+ const signal = 'SIGKILL';
298
+ process.kill(pid, signal);
299
+ }
300
+ catch (e) {
301
+ // Allow this call to fail with
302
+ // ESRCH, which meant that the process
303
+ // to be killed was already dead.
304
+ // But re-throw on other codes.
305
+ if (e.code !== 'ESRCH') {
306
+ throw e;
307
+ }
308
+ }
309
+ }
310
+ //# sourceMappingURL=DenoHTTPWorker.js.map
@@ -0,0 +1 @@
1
+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