@nervekit/tools 0.1.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/LICENSE +201 -0
- package/NOTICE +5 -0
- package/dist/catalog/core/filesystem.tools.d.ts +140 -0
- package/dist/catalog/core/filesystem.tools.d.ts.map +1 -0
- package/dist/catalog/core/filesystem.tools.js +221 -0
- package/dist/catalog/core/filesystem.tools.js.map +1 -0
- package/dist/catalog/core/interaction.tools.d.ts +37 -0
- package/dist/catalog/core/interaction.tools.d.ts.map +1 -0
- package/dist/catalog/core/interaction.tools.js +55 -0
- package/dist/catalog/core/interaction.tools.js.map +1 -0
- package/dist/catalog/core/python.tools.d.ts +17 -0
- package/dist/catalog/core/python.tools.d.ts.map +1 -0
- package/dist/catalog/core/python.tools.js +32 -0
- package/dist/catalog/core/python.tools.js.map +1 -0
- package/dist/catalog/core/shell.tools.d.ts +14 -0
- package/dist/catalog/core/shell.tools.d.ts.map +1 -0
- package/dist/catalog/core/shell.tools.js +22 -0
- package/dist/catalog/core/shell.tools.js.map +1 -0
- package/dist/catalog/core/web.tools.d.ts +23 -0
- package/dist/catalog/core/web.tools.d.ts.map +1 -0
- package/dist/catalog/core/web.tools.js +34 -0
- package/dist/catalog/core/web.tools.js.map +1 -0
- package/dist/catalog/descriptors.d.ts +4 -0
- package/dist/catalog/descriptors.d.ts.map +1 -0
- package/dist/catalog/descriptors.js +17 -0
- package/dist/catalog/descriptors.js.map +1 -0
- package/dist/catalog/index.d.ts +18 -0
- package/dist/catalog/index.d.ts.map +1 -0
- package/dist/catalog/index.js +44 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/catalog/orchestration/explore.tools.d.ts +20 -0
- package/dist/catalog/orchestration/explore.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/explore.tools.js +42 -0
- package/dist/catalog/orchestration/explore.tools.js.map +1 -0
- package/dist/catalog/orchestration/plan-mode.tools.d.ts +32 -0
- package/dist/catalog/orchestration/plan-mode.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/plan-mode.tools.js +43 -0
- package/dist/catalog/orchestration/plan-mode.tools.js.map +1 -0
- package/dist/catalog/orchestration/process.tools.d.ts +68 -0
- package/dist/catalog/orchestration/process.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/process.tools.js +96 -0
- package/dist/catalog/orchestration/process.tools.js.map +1 -0
- package/dist/catalog/orchestration/subagent.tools.d.ts +16 -0
- package/dist/catalog/orchestration/subagent.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/subagent.tools.js +25 -0
- package/dist/catalog/orchestration/subagent.tools.js.map +1 -0
- package/dist/catalog/orchestration/task.tools.d.ts +107 -0
- package/dist/catalog/orchestration/task.tools.d.ts.map +1 -0
- package/dist/catalog/orchestration/task.tools.js +170 -0
- package/dist/catalog/orchestration/task.tools.js.map +1 -0
- package/dist/catalog/risk.d.ts +3 -0
- package/dist/catalog/risk.d.ts.map +1 -0
- package/dist/catalog/risk.js +29 -0
- package/dist/catalog/risk.js.map +1 -0
- package/dist/catalog/types.d.ts +14 -0
- package/dist/catalog/types.d.ts.map +1 -0
- package/dist/catalog/types.js +2 -0
- package/dist/catalog/types.js.map +1 -0
- package/dist/definitions.d.ts +2 -0
- package/dist/definitions.d.ts.map +1 -0
- package/dist/definitions.js +2 -0
- package/dist/definitions.js.map +1 -0
- package/dist/execution/atomic-write.d.ts +2 -0
- package/dist/execution/atomic-write.d.ts.map +1 -0
- package/dist/execution/atomic-write.js +7 -0
- package/dist/execution/atomic-write.js.map +1 -0
- package/dist/execution/bash.d.ts +3 -0
- package/dist/execution/bash.d.ts.map +1 -0
- package/dist/execution/bash.js +133 -0
- package/dist/execution/bash.js.map +1 -0
- package/dist/execution/common/args.d.ts +2 -0
- package/dist/execution/common/args.d.ts.map +1 -0
- package/dist/execution/common/args.js +6 -0
- package/dist/execution/common/args.js.map +1 -0
- package/dist/execution/common/output-budget.d.ts +61 -0
- package/dist/execution/common/output-budget.d.ts.map +1 -0
- package/dist/execution/common/output-budget.js +140 -0
- package/dist/execution/common/output-budget.js.map +1 -0
- package/dist/execution/common/process-result.d.ts +44 -0
- package/dist/execution/common/process-result.d.ts.map +1 -0
- package/dist/execution/common/process-result.js +322 -0
- package/dist/execution/common/process-result.js.map +1 -0
- package/dist/execution/common/search-utils.d.ts +8 -0
- package/dist/execution/common/search-utils.d.ts.map +1 -0
- package/dist/execution/common/search-utils.js +110 -0
- package/dist/execution/common/search-utils.js.map +1 -0
- package/dist/execution/common/tool-error.d.ts +8 -0
- package/dist/execution/common/tool-error.d.ts.map +1 -0
- package/dist/execution/common/tool-error.js +14 -0
- package/dist/execution/common/tool-error.js.map +1 -0
- package/dist/execution/common/truncate.d.ts +27 -0
- package/dist/execution/common/truncate.d.ts.map +1 -0
- package/dist/execution/common/truncate.js +108 -0
- package/dist/execution/common/truncate.js.map +1 -0
- package/dist/execution/common.d.ts +2 -0
- package/dist/execution/common.d.ts.map +1 -0
- package/dist/execution/common.js +6 -0
- package/dist/execution/common.js.map +1 -0
- package/dist/execution/core-dispatch.d.ts +4 -0
- package/dist/execution/core-dispatch.d.ts.map +1 -0
- package/dist/execution/core-dispatch.js +58 -0
- package/dist/execution/core-dispatch.js.map +1 -0
- package/dist/execution/dispatch.d.ts +4 -0
- package/dist/execution/dispatch.d.ts.map +1 -0
- package/dist/execution/dispatch.js +54 -0
- package/dist/execution/dispatch.js.map +1 -0
- package/dist/execution/edit.d.ts +9 -0
- package/dist/execution/edit.d.ts.map +1 -0
- package/dist/execution/edit.js +175 -0
- package/dist/execution/edit.js.map +1 -0
- package/dist/execution/file-mutation-queue.d.ts +2 -0
- package/dist/execution/file-mutation-queue.d.ts.map +1 -0
- package/dist/execution/file-mutation-queue.js +19 -0
- package/dist/execution/file-mutation-queue.js.map +1 -0
- package/dist/execution/filesystem/atomic-write.d.ts +2 -0
- package/dist/execution/filesystem/atomic-write.d.ts.map +1 -0
- package/dist/execution/filesystem/atomic-write.js +7 -0
- package/dist/execution/filesystem/atomic-write.js.map +1 -0
- package/dist/execution/filesystem/edit-args.d.ts +46 -0
- package/dist/execution/filesystem/edit-args.d.ts.map +1 -0
- package/dist/execution/filesystem/edit-args.js +212 -0
- package/dist/execution/filesystem/edit-args.js.map +1 -0
- package/dist/execution/filesystem/edit-errors.d.ts +4 -0
- package/dist/execution/filesystem/edit-errors.d.ts.map +1 -0
- package/dist/execution/filesystem/edit-errors.js +8 -0
- package/dist/execution/filesystem/edit-errors.js.map +1 -0
- package/dist/execution/filesystem/edit.d.ts +4 -0
- package/dist/execution/filesystem/edit.d.ts.map +1 -0
- package/dist/execution/filesystem/edit.js +330 -0
- package/dist/execution/filesystem/edit.js.map +1 -0
- package/dist/execution/filesystem/file-mutation-queue.d.ts +2 -0
- package/dist/execution/filesystem/file-mutation-queue.d.ts.map +1 -0
- package/dist/execution/filesystem/file-mutation-queue.js +19 -0
- package/dist/execution/filesystem/file-mutation-queue.js.map +1 -0
- package/dist/execution/filesystem/find.d.ts +3 -0
- package/dist/execution/filesystem/find.d.ts.map +1 -0
- package/dist/execution/filesystem/find.js +93 -0
- package/dist/execution/filesystem/find.js.map +1 -0
- package/dist/execution/filesystem/legacy-edit.d.ts +9 -0
- package/dist/execution/filesystem/legacy-edit.d.ts.map +1 -0
- package/dist/execution/filesystem/legacy-edit.js +122 -0
- package/dist/execution/filesystem/legacy-edit.js.map +1 -0
- package/dist/execution/filesystem/list.d.ts +3 -0
- package/dist/execution/filesystem/list.d.ts.map +1 -0
- package/dist/execution/filesystem/list.js +49 -0
- package/dist/execution/filesystem/list.js.map +1 -0
- package/dist/execution/filesystem/path.d.ts +7 -0
- package/dist/execution/filesystem/path.d.ts.map +1 -0
- package/dist/execution/filesystem/path.js +69 -0
- package/dist/execution/filesystem/path.js.map +1 -0
- package/dist/execution/filesystem/read.d.ts +3 -0
- package/dist/execution/filesystem/read.d.ts.map +1 -0
- package/dist/execution/filesystem/read.js +225 -0
- package/dist/execution/filesystem/read.js.map +1 -0
- package/dist/execution/filesystem/search.d.ts +3 -0
- package/dist/execution/filesystem/search.d.ts.map +1 -0
- package/dist/execution/filesystem/search.js +149 -0
- package/dist/execution/filesystem/search.js.map +1 -0
- package/dist/execution/filesystem/smart-match.d.ts +31 -0
- package/dist/execution/filesystem/smart-match.d.ts.map +1 -0
- package/dist/execution/filesystem/smart-match.js +309 -0
- package/dist/execution/filesystem/smart-match.js.map +1 -0
- package/dist/execution/filesystem/text-editing.d.ts +9 -0
- package/dist/execution/filesystem/text-editing.d.ts.map +1 -0
- package/dist/execution/filesystem/text-editing.js +43 -0
- package/dist/execution/filesystem/text-editing.js.map +1 -0
- package/dist/execution/filesystem/write.d.ts +3 -0
- package/dist/execution/filesystem/write.d.ts.map +1 -0
- package/dist/execution/filesystem/write.js +21 -0
- package/dist/execution/filesystem/write.js.map +1 -0
- package/dist/execution/find.d.ts +3 -0
- package/dist/execution/find.d.ts.map +1 -0
- package/dist/execution/find.js +90 -0
- package/dist/execution/find.js.map +1 -0
- package/dist/execution/index.d.ts +18 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +17 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/list.d.ts +3 -0
- package/dist/execution/list.d.ts.map +1 -0
- package/dist/execution/list.js +46 -0
- package/dist/execution/list.js.map +1 -0
- package/dist/execution/path.d.ts +7 -0
- package/dist/execution/path.d.ts.map +1 -0
- package/dist/execution/path.js +69 -0
- package/dist/execution/path.js.map +1 -0
- package/dist/execution/python/python.d.ts +3 -0
- package/dist/execution/python/python.d.ts.map +1 -0
- package/dist/execution/python/python.js +566 -0
- package/dist/execution/python/python.js.map +1 -0
- package/dist/execution/python/runtime.d.ts +22 -0
- package/dist/execution/python/runtime.d.ts.map +1 -0
- package/dist/execution/python/runtime.js +178 -0
- package/dist/execution/python/runtime.js.map +1 -0
- package/dist/execution/read.d.ts +3 -0
- package/dist/execution/read.d.ts.map +1 -0
- package/dist/execution/read.js +97 -0
- package/dist/execution/read.js.map +1 -0
- package/dist/execution/search-utils.d.ts +8 -0
- package/dist/execution/search-utils.d.ts.map +1 -0
- package/dist/execution/search-utils.js +110 -0
- package/dist/execution/search-utils.js.map +1 -0
- package/dist/execution/search.d.ts +3 -0
- package/dist/execution/search.d.ts.map +1 -0
- package/dist/execution/search.js +131 -0
- package/dist/execution/search.js.map +1 -0
- package/dist/execution/shell/bash.d.ts +3 -0
- package/dist/execution/shell/bash.d.ts.map +1 -0
- package/dist/execution/shell/bash.js +134 -0
- package/dist/execution/shell/bash.js.map +1 -0
- package/dist/execution/truncate.d.ts +21 -0
- package/dist/execution/truncate.d.ts.map +1 -0
- package/dist/execution/truncate.js +94 -0
- package/dist/execution/truncate.js.map +1 -0
- package/dist/execution/web/web-fetch.d.ts +3 -0
- package/dist/execution/web/web-fetch.d.ts.map +1 -0
- package/dist/execution/web/web-fetch.js +132 -0
- package/dist/execution/web/web-fetch.js.map +1 -0
- package/dist/execution/web/web-search.d.ts +3 -0
- package/dist/execution/web/web-search.d.ts.map +1 -0
- package/dist/execution/web/web-search.js +59 -0
- package/dist/execution/web/web-search.js.map +1 -0
- package/dist/execution/web-fetch.d.ts +3 -0
- package/dist/execution/web-fetch.d.ts.map +1 -0
- package/dist/execution/web-fetch.js +132 -0
- package/dist/execution/web-fetch.js.map +1 -0
- package/dist/execution/web-search.d.ts +3 -0
- package/dist/execution/web-search.d.ts.map +1 -0
- package/dist/execution/web-search.js +59 -0
- package/dist/execution/web-search.js.map +1 -0
- package/dist/execution/write.d.ts +3 -0
- package/dist/execution/write.d.ts.map +1 -0
- package/dist/execution/write.js +21 -0
- package/dist/execution/write.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/safety/command-policy-git.d.ts +2 -0
- package/dist/safety/command-policy-git.d.ts.map +1 -0
- package/dist/safety/command-policy-git.js +88 -0
- package/dist/safety/command-policy-git.js.map +1 -0
- package/dist/safety/command-policy-options.d.ts +6 -0
- package/dist/safety/command-policy-options.d.ts.map +1 -0
- package/dist/safety/command-policy-options.js +112 -0
- package/dist/safety/command-policy-options.js.map +1 -0
- package/dist/safety/command-policy-packages.d.ts +4 -0
- package/dist/safety/command-policy-packages.d.ts.map +1 -0
- package/dist/safety/command-policy-packages.js +161 -0
- package/dist/safety/command-policy-packages.js.map +1 -0
- package/dist/safety/command-policy-parser.d.ts +11 -0
- package/dist/safety/command-policy-parser.d.ts.map +1 -0
- package/dist/safety/command-policy-parser.js +121 -0
- package/dist/safety/command-policy-parser.js.map +1 -0
- package/dist/safety/command-policy-wrappers.d.ts +6 -0
- package/dist/safety/command-policy-wrappers.d.ts.map +1 -0
- package/dist/safety/command-policy-wrappers.js +95 -0
- package/dist/safety/command-policy-wrappers.js.map +1 -0
- package/dist/safety/command-policy.d.ts +6 -0
- package/dist/safety/command-policy.d.ts.map +1 -0
- package/dist/safety/command-policy.js +118 -0
- package/dist/safety/command-policy.js.map +1 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdir, mkdtemp, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { numberArg } from "../common/args.js";
|
|
6
|
+
import { boundLiveOutputChunk } from "../common/output-budget.js";
|
|
7
|
+
import { buildProcessResult } from "../common/process-result.js";
|
|
8
|
+
import { pathNotFoundMessage, resolveToolPath } from "../filesystem/path.js";
|
|
9
|
+
const DEFAULT_TIMEOUT_SECONDS = 60;
|
|
10
|
+
const MAX_TIMEOUT_SECONDS = 600;
|
|
11
|
+
const FORCE_KILL_AFTER_MS = 2000;
|
|
12
|
+
const MAX_ARTIFACTS = 100;
|
|
13
|
+
const SENSITIVE_ENV_KEY_PATTERN = /authorization|cookie|token|apikey|api_key|password|passwd|secret|credential|private.?key|nerve_daemon_token/i;
|
|
14
|
+
// Guardrails below block ordinary stdin/file-write/network APIs used by agent
|
|
15
|
+
// snippets. They are not a hard security sandbox against malicious Python code,
|
|
16
|
+
// native extensions, interpreter internals, or symlink tricks.
|
|
17
|
+
const RUNNER_SOURCE = `
|
|
18
|
+
import builtins
|
|
19
|
+
import io
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import pathlib
|
|
23
|
+
import runpy
|
|
24
|
+
import shutil
|
|
25
|
+
import socket
|
|
26
|
+
import subprocess
|
|
27
|
+
import sys
|
|
28
|
+
|
|
29
|
+
user_path = sys.argv[1]
|
|
30
|
+
policy = json.loads(sys.argv[2])
|
|
31
|
+
allow_network = bool(policy.get("allowNetwork", True))
|
|
32
|
+
allow_filewrite = bool(policy.get("allowFileWrite", True))
|
|
33
|
+
artifact_dir_value = policy.get("artifactDir")
|
|
34
|
+
artifact_dir = os.path.abspath(artifact_dir_value) if isinstance(artifact_dir_value, str) and artifact_dir_value else None
|
|
35
|
+
|
|
36
|
+
STDIN_ERROR = "stdin is not available to the python tool."
|
|
37
|
+
FILEWRITE_ERROR = "file writes are disabled for the python tool in planning mode. Write generated artifacts under NERVE_PYTHON_ARTIFACT_DIR instead."
|
|
38
|
+
NETWORK_ERROR = "network access is disabled for the python tool."
|
|
39
|
+
|
|
40
|
+
class _NoStdin:
|
|
41
|
+
encoding = "utf-8"
|
|
42
|
+
errors = "strict"
|
|
43
|
+
closed = False
|
|
44
|
+
|
|
45
|
+
def read(self, *args, **kwargs):
|
|
46
|
+
raise RuntimeError(STDIN_ERROR)
|
|
47
|
+
|
|
48
|
+
def readline(self, *args, **kwargs):
|
|
49
|
+
raise RuntimeError(STDIN_ERROR)
|
|
50
|
+
|
|
51
|
+
def readlines(self, *args, **kwargs):
|
|
52
|
+
raise RuntimeError(STDIN_ERROR)
|
|
53
|
+
|
|
54
|
+
def __iter__(self):
|
|
55
|
+
raise RuntimeError(STDIN_ERROR)
|
|
56
|
+
|
|
57
|
+
def fileno(self):
|
|
58
|
+
raise RuntimeError(STDIN_ERROR)
|
|
59
|
+
|
|
60
|
+
def isatty(self):
|
|
61
|
+
return False
|
|
62
|
+
|
|
63
|
+
def readable(self):
|
|
64
|
+
return False
|
|
65
|
+
|
|
66
|
+
def writable(self):
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
def seekable(self):
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
builtins.input = lambda *args, **kwargs: (_ for _ in ()).throw(RuntimeError(STDIN_ERROR))
|
|
73
|
+
sys.stdin = _NoStdin()
|
|
74
|
+
|
|
75
|
+
_WRITE_MODE_CHARS = set("wax+")
|
|
76
|
+
_WRITE_FLAG_BITS = 0
|
|
77
|
+
for _name in ("O_WRONLY", "O_RDWR", "O_CREAT", "O_TRUNC", "O_APPEND"):
|
|
78
|
+
_WRITE_FLAG_BITS |= int(getattr(os, _name, 0) or 0)
|
|
79
|
+
|
|
80
|
+
def _mode_writes(mode):
|
|
81
|
+
if mode is None:
|
|
82
|
+
return False
|
|
83
|
+
return any(ch in str(mode) for ch in _WRITE_MODE_CHARS)
|
|
84
|
+
|
|
85
|
+
def _flags_write(flags):
|
|
86
|
+
try:
|
|
87
|
+
return (int(flags) & _WRITE_FLAG_BITS) != 0
|
|
88
|
+
except Exception:
|
|
89
|
+
return False
|
|
90
|
+
|
|
91
|
+
def _path_in_artifact(path):
|
|
92
|
+
if artifact_dir is None:
|
|
93
|
+
return False
|
|
94
|
+
try:
|
|
95
|
+
target = os.path.abspath(os.fspath(path))
|
|
96
|
+
except Exception:
|
|
97
|
+
return False
|
|
98
|
+
try:
|
|
99
|
+
return os.path.commonpath([artifact_dir, target]) == artifact_dir
|
|
100
|
+
except Exception:
|
|
101
|
+
return False
|
|
102
|
+
|
|
103
|
+
def _check_filewrite_target(path):
|
|
104
|
+
if allow_filewrite:
|
|
105
|
+
return
|
|
106
|
+
if _path_in_artifact(path):
|
|
107
|
+
return
|
|
108
|
+
raise PermissionError(FILEWRITE_ERROR)
|
|
109
|
+
|
|
110
|
+
def _deny_filewrite(*args, **kwargs):
|
|
111
|
+
raise PermissionError(FILEWRITE_ERROR)
|
|
112
|
+
|
|
113
|
+
def _guarded_open_factory(original):
|
|
114
|
+
def _guarded_open(file, mode="r", *args, **kwargs):
|
|
115
|
+
if not allow_filewrite and _mode_writes(mode):
|
|
116
|
+
_check_filewrite_target(file)
|
|
117
|
+
return original(file, mode, *args, **kwargs)
|
|
118
|
+
return _guarded_open
|
|
119
|
+
|
|
120
|
+
def _guarded_path_method(original):
|
|
121
|
+
def _guarded(self, *args, **kwargs):
|
|
122
|
+
_check_filewrite_target(self)
|
|
123
|
+
return original(self, *args, **kwargs)
|
|
124
|
+
return _guarded
|
|
125
|
+
|
|
126
|
+
def _guarded_path_move(original):
|
|
127
|
+
def _guarded(self, target, *args, **kwargs):
|
|
128
|
+
_check_filewrite_target(self)
|
|
129
|
+
_check_filewrite_target(target)
|
|
130
|
+
return original(self, target, *args, **kwargs)
|
|
131
|
+
return _guarded
|
|
132
|
+
|
|
133
|
+
def _guarded_os_one(original):
|
|
134
|
+
def _guarded(path, *args, **kwargs):
|
|
135
|
+
_check_filewrite_target(path)
|
|
136
|
+
return original(path, *args, **kwargs)
|
|
137
|
+
return _guarded
|
|
138
|
+
|
|
139
|
+
def _guarded_os_two(original):
|
|
140
|
+
def _guarded(src, dst, *args, **kwargs):
|
|
141
|
+
_check_filewrite_target(src)
|
|
142
|
+
_check_filewrite_target(dst)
|
|
143
|
+
return original(src, dst, *args, **kwargs)
|
|
144
|
+
return _guarded
|
|
145
|
+
|
|
146
|
+
def _guarded_shutil_copy(original):
|
|
147
|
+
def _guarded(src, dst, *args, **kwargs):
|
|
148
|
+
_check_filewrite_target(dst)
|
|
149
|
+
return original(src, dst, *args, **kwargs)
|
|
150
|
+
return _guarded
|
|
151
|
+
|
|
152
|
+
def _install_filewrite_guards():
|
|
153
|
+
if allow_filewrite:
|
|
154
|
+
return
|
|
155
|
+
|
|
156
|
+
builtins.open = _guarded_open_factory(builtins.open)
|
|
157
|
+
io.open = _guarded_open_factory(io.open)
|
|
158
|
+
|
|
159
|
+
_path_open = pathlib.Path.open
|
|
160
|
+
def _guarded_path_open(self, mode="r", *args, **kwargs):
|
|
161
|
+
if _mode_writes(mode):
|
|
162
|
+
_check_filewrite_target(self)
|
|
163
|
+
return _path_open(self, mode, *args, **kwargs)
|
|
164
|
+
pathlib.Path.open = _guarded_path_open
|
|
165
|
+
|
|
166
|
+
for name in ("write_text", "write_bytes", "mkdir", "unlink", "rmdir", "touch"):
|
|
167
|
+
if hasattr(pathlib.Path, name):
|
|
168
|
+
setattr(pathlib.Path, name, _guarded_path_method(getattr(pathlib.Path, name)))
|
|
169
|
+
for name in ("rename", "replace"):
|
|
170
|
+
if hasattr(pathlib.Path, name):
|
|
171
|
+
setattr(pathlib.Path, name, _guarded_path_move(getattr(pathlib.Path, name)))
|
|
172
|
+
|
|
173
|
+
for module, names in (
|
|
174
|
+
(os, ("remove", "unlink", "rmdir", "mkdir", "makedirs", "removedirs", "truncate")),
|
|
175
|
+
):
|
|
176
|
+
for name in names:
|
|
177
|
+
if hasattr(module, name):
|
|
178
|
+
setattr(module, name, _guarded_os_one(getattr(module, name)))
|
|
179
|
+
for name in ("rename", "replace"):
|
|
180
|
+
if hasattr(os, name):
|
|
181
|
+
setattr(os, name, _guarded_os_two(getattr(os, name)))
|
|
182
|
+
|
|
183
|
+
for name in ("copy", "copy2", "copyfile", "copytree"):
|
|
184
|
+
if hasattr(shutil, name):
|
|
185
|
+
setattr(shutil, name, _guarded_shutil_copy(getattr(shutil, name)))
|
|
186
|
+
for name in ("move",):
|
|
187
|
+
if hasattr(shutil, name):
|
|
188
|
+
setattr(shutil, name, _guarded_os_two(getattr(shutil, name)))
|
|
189
|
+
for name in ("rmtree",):
|
|
190
|
+
if hasattr(shutil, name):
|
|
191
|
+
setattr(shutil, name, _guarded_os_one(getattr(shutil, name)))
|
|
192
|
+
|
|
193
|
+
def _blocked_popen(*args, **kwargs):
|
|
194
|
+
raise PermissionError(FILEWRITE_ERROR)
|
|
195
|
+
subprocess.Popen = _blocked_popen
|
|
196
|
+
subprocess.run = _blocked_popen
|
|
197
|
+
subprocess.call = _blocked_popen
|
|
198
|
+
subprocess.check_call = _blocked_popen
|
|
199
|
+
subprocess.check_output = _blocked_popen
|
|
200
|
+
|
|
201
|
+
def _install_network_guards():
|
|
202
|
+
if allow_network:
|
|
203
|
+
return
|
|
204
|
+
|
|
205
|
+
class _BlockedSocket(socket.socket):
|
|
206
|
+
def __init__(self, *args, **kwargs):
|
|
207
|
+
raise PermissionError(NETWORK_ERROR)
|
|
208
|
+
|
|
209
|
+
def _blocked_create_connection(*args, **kwargs):
|
|
210
|
+
raise PermissionError(NETWORK_ERROR)
|
|
211
|
+
|
|
212
|
+
socket.socket = _BlockedSocket
|
|
213
|
+
socket.create_connection = _blocked_create_connection
|
|
214
|
+
|
|
215
|
+
def _audit(event, args):
|
|
216
|
+
if not allow_filewrite:
|
|
217
|
+
if event == "open":
|
|
218
|
+
path = args[0] if len(args) > 0 else None
|
|
219
|
+
mode = args[1] if len(args) > 1 else None
|
|
220
|
+
flags = args[2] if len(args) > 2 else 0
|
|
221
|
+
if _mode_writes(mode) or _flags_write(flags):
|
|
222
|
+
_check_filewrite_target(path)
|
|
223
|
+
elif event in {
|
|
224
|
+
"os.remove",
|
|
225
|
+
"os.rmdir",
|
|
226
|
+
"os.mkdir",
|
|
227
|
+
"os.truncate",
|
|
228
|
+
"shutil.rmtree",
|
|
229
|
+
}:
|
|
230
|
+
path = args[0] if len(args) > 0 else None
|
|
231
|
+
_check_filewrite_target(path)
|
|
232
|
+
elif event in {"os.rename", "os.replace"}:
|
|
233
|
+
src = args[0] if len(args) > 0 else None
|
|
234
|
+
dst = args[1] if len(args) > 1 else None
|
|
235
|
+
_check_filewrite_target(src)
|
|
236
|
+
_check_filewrite_target(dst)
|
|
237
|
+
elif event == "subprocess.Popen":
|
|
238
|
+
raise PermissionError(FILEWRITE_ERROR)
|
|
239
|
+
if not allow_network and event.startswith("socket."):
|
|
240
|
+
raise PermissionError(NETWORK_ERROR)
|
|
241
|
+
|
|
242
|
+
try:
|
|
243
|
+
sys.addaudithook(_audit)
|
|
244
|
+
except Exception:
|
|
245
|
+
pass
|
|
246
|
+
|
|
247
|
+
_install_filewrite_guards()
|
|
248
|
+
_install_network_guards()
|
|
249
|
+
user_dir = os.path.dirname(os.path.abspath(user_path))
|
|
250
|
+
if user_dir:
|
|
251
|
+
sys.path.insert(0, user_dir)
|
|
252
|
+
runpy.run_path(user_path, run_name="__main__")
|
|
253
|
+
`;
|
|
254
|
+
export async function executePython(args, context) {
|
|
255
|
+
const source = await pythonSourceArg(args, context.cwd);
|
|
256
|
+
const runtime = context.pythonRuntime;
|
|
257
|
+
if (!runtime)
|
|
258
|
+
throw new Error("Python runtime is not available.");
|
|
259
|
+
const timeoutSeconds = clampTimeout(args.timeout);
|
|
260
|
+
const envOverrides = envOverridesArg(args.env);
|
|
261
|
+
const policy = context.pythonPolicy ?? {
|
|
262
|
+
allowNetwork: true,
|
|
263
|
+
allowFileWrite: true,
|
|
264
|
+
};
|
|
265
|
+
const tempDir = await mkdtemp(join(tmpdir(), "nerve-python-"));
|
|
266
|
+
const artifactDir = await createArtifactDir(context.dataDir);
|
|
267
|
+
let keepArtifactDir = false;
|
|
268
|
+
const runnerPath = join(tempDir, "runner.py");
|
|
269
|
+
const userPath = source.kind === "inline" ? join(tempDir, "user.py") : source.path;
|
|
270
|
+
if (source.kind === "inline") {
|
|
271
|
+
await Promise.all([
|
|
272
|
+
writeFile(runnerPath, RUNNER_SOURCE, "utf8"),
|
|
273
|
+
writeFile(userPath, source.code, "utf8"),
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
await writeFile(runnerPath, RUNNER_SOURCE, "utf8");
|
|
278
|
+
}
|
|
279
|
+
try {
|
|
280
|
+
const result = await runPythonProcess({
|
|
281
|
+
runtime,
|
|
282
|
+
policy,
|
|
283
|
+
timeoutSeconds,
|
|
284
|
+
cwd: context.cwd,
|
|
285
|
+
runnerPath,
|
|
286
|
+
userPath,
|
|
287
|
+
artifactDir,
|
|
288
|
+
envOverrides,
|
|
289
|
+
inputMode: source.kind,
|
|
290
|
+
scriptPath: source.kind === "file" ? source.path : undefined,
|
|
291
|
+
dataDir: context.dataDir,
|
|
292
|
+
signal: context.signal,
|
|
293
|
+
onUpdate: context.onUpdate,
|
|
294
|
+
});
|
|
295
|
+
keepArtifactDir = artifactCount(result) > 0;
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
298
|
+
finally {
|
|
299
|
+
await rm(tempDir, { recursive: true, force: true }).catch(() => undefined);
|
|
300
|
+
if (!keepArtifactDir) {
|
|
301
|
+
await rm(artifactDir, { recursive: true, force: true }).catch(() => undefined);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
async function runPythonProcess({ runtime, policy, timeoutSeconds, cwd, runnerPath, userPath, artifactDir, envOverrides, inputMode, scriptPath, dataDir, signal, onUpdate, }) {
|
|
306
|
+
const stdoutChunks = [];
|
|
307
|
+
const stderrChunks = [];
|
|
308
|
+
const combinedChunks = [];
|
|
309
|
+
const startedAt = performance.now();
|
|
310
|
+
return await new Promise((resolve, reject) => {
|
|
311
|
+
if (signal?.aborted) {
|
|
312
|
+
reject(new Error("Python execution aborted."));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const runnerPolicy = {
|
|
316
|
+
...policy,
|
|
317
|
+
artifactDir,
|
|
318
|
+
};
|
|
319
|
+
const child = spawn(runtime.command, [
|
|
320
|
+
...runtime.args,
|
|
321
|
+
"-u",
|
|
322
|
+
"-B",
|
|
323
|
+
runnerPath,
|
|
324
|
+
userPath,
|
|
325
|
+
JSON.stringify(runnerPolicy),
|
|
326
|
+
], {
|
|
327
|
+
cwd,
|
|
328
|
+
shell: false,
|
|
329
|
+
detached: process.platform !== "win32",
|
|
330
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
331
|
+
env: {
|
|
332
|
+
...process.env,
|
|
333
|
+
...envOverrides,
|
|
334
|
+
PYTHONIOENCODING: "utf-8",
|
|
335
|
+
PYTHONDONTWRITEBYTECODE: "1",
|
|
336
|
+
NERVE_PYTHON_ALLOW_NETWORK: policy.allowNetwork ? "1" : "0",
|
|
337
|
+
NERVE_PYTHON_ALLOW_FILEWRITE: policy.allowFileWrite ? "1" : "0",
|
|
338
|
+
NERVE_PYTHON_ARTIFACT_DIR: artifactDir,
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
let settled = false;
|
|
342
|
+
let timedOut = false;
|
|
343
|
+
let timeoutKilled = false;
|
|
344
|
+
let timeout;
|
|
345
|
+
let forceKillTimeout;
|
|
346
|
+
const cleanup = () => {
|
|
347
|
+
if (timeout)
|
|
348
|
+
clearTimeout(timeout);
|
|
349
|
+
if (forceKillTimeout)
|
|
350
|
+
clearTimeout(forceKillTimeout);
|
|
351
|
+
signal?.removeEventListener("abort", onAbort);
|
|
352
|
+
};
|
|
353
|
+
const kill = (killSignal = "SIGTERM") => {
|
|
354
|
+
try {
|
|
355
|
+
if (process.platform !== "win32" && child.pid) {
|
|
356
|
+
process.kill(-child.pid, killSignal);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
child.kill(killSignal);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
catch {
|
|
363
|
+
child.kill(killSignal);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
const onAbort = () => {
|
|
367
|
+
if (settled)
|
|
368
|
+
return;
|
|
369
|
+
kill();
|
|
370
|
+
settled = true;
|
|
371
|
+
cleanup();
|
|
372
|
+
reject(new Error("Python execution aborted."));
|
|
373
|
+
};
|
|
374
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
375
|
+
timeout = setTimeout(() => {
|
|
376
|
+
if (settled)
|
|
377
|
+
return;
|
|
378
|
+
timedOut = true;
|
|
379
|
+
timeoutKilled = true;
|
|
380
|
+
kill("SIGTERM");
|
|
381
|
+
forceKillTimeout = setTimeout(() => {
|
|
382
|
+
if (!settled)
|
|
383
|
+
kill("SIGKILL");
|
|
384
|
+
}, FORCE_KILL_AFTER_MS);
|
|
385
|
+
}, timeoutSeconds * 1000);
|
|
386
|
+
child.stdout?.on("data", (chunk) => {
|
|
387
|
+
stdoutChunks.push(chunk);
|
|
388
|
+
combinedChunks.push(chunk);
|
|
389
|
+
onUpdate?.({
|
|
390
|
+
kind: "output",
|
|
391
|
+
stream: "stdout",
|
|
392
|
+
chunk: boundLiveOutputChunk(chunk.toString("utf8")),
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
child.stderr?.on("data", (chunk) => {
|
|
396
|
+
stderrChunks.push(chunk);
|
|
397
|
+
combinedChunks.push(chunk);
|
|
398
|
+
onUpdate?.({
|
|
399
|
+
kind: "output",
|
|
400
|
+
stream: "stderr",
|
|
401
|
+
chunk: boundLiveOutputChunk(chunk.toString("utf8")),
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
child.on("error", (error) => {
|
|
405
|
+
if (settled)
|
|
406
|
+
return;
|
|
407
|
+
settled = true;
|
|
408
|
+
cleanup();
|
|
409
|
+
reject(error);
|
|
410
|
+
});
|
|
411
|
+
child.on("close", (code, closeSignal) => {
|
|
412
|
+
if (settled)
|
|
413
|
+
return;
|
|
414
|
+
settled = true;
|
|
415
|
+
cleanup();
|
|
416
|
+
const durationMs = Math.round(performance.now() - startedAt);
|
|
417
|
+
void listArtifacts(artifactDir)
|
|
418
|
+
.then((artifacts) => buildProcessResult({
|
|
419
|
+
stdoutChunks,
|
|
420
|
+
stderrChunks,
|
|
421
|
+
combinedChunks,
|
|
422
|
+
code,
|
|
423
|
+
signal: closeSignal,
|
|
424
|
+
outputFilePrefix: "nerve-python",
|
|
425
|
+
exitMessagePrefix: "Python",
|
|
426
|
+
dataDir,
|
|
427
|
+
durationMs,
|
|
428
|
+
timedOut,
|
|
429
|
+
timeoutKilled,
|
|
430
|
+
timeoutMessage: `Python timed out after ${timeoutSeconds}s and ${timeoutKilled ? "was killed" : "was not killed"}.`,
|
|
431
|
+
contentFooterLines: artifactFooterLines(artifacts),
|
|
432
|
+
details: {
|
|
433
|
+
executable: runtime.displayPath,
|
|
434
|
+
version: runtime.version,
|
|
435
|
+
timeoutSeconds,
|
|
436
|
+
allowNetwork: policy.allowNetwork,
|
|
437
|
+
allowFileWrite: policy.allowFileWrite,
|
|
438
|
+
envKeys: Object.keys(envOverrides).sort(),
|
|
439
|
+
inputMode,
|
|
440
|
+
scriptPath,
|
|
441
|
+
artifactDir: artifacts.length > 0 ? artifactDir : undefined,
|
|
442
|
+
artifacts,
|
|
443
|
+
},
|
|
444
|
+
}))
|
|
445
|
+
.then(resolve)
|
|
446
|
+
.catch(reject);
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
async function pythonSourceArg(args, cwd) {
|
|
451
|
+
const hasCode = args.code !== undefined;
|
|
452
|
+
const hasPath = args.path !== undefined;
|
|
453
|
+
if (hasCode && hasPath) {
|
|
454
|
+
throw new Error("Provide exactly one of tool arguments 'code' or 'path'.");
|
|
455
|
+
}
|
|
456
|
+
if (!hasCode && !hasPath) {
|
|
457
|
+
throw new Error("Provide exactly one of tool arguments 'code' or 'path'.");
|
|
458
|
+
}
|
|
459
|
+
if (hasCode) {
|
|
460
|
+
if (typeof args.code !== "string" || args.code.trim().length === 0) {
|
|
461
|
+
throw new Error("Tool argument 'code' must be a non-empty string.");
|
|
462
|
+
}
|
|
463
|
+
return { kind: "inline", code: args.code };
|
|
464
|
+
}
|
|
465
|
+
if (typeof args.path !== "string" || args.path.trim().length === 0) {
|
|
466
|
+
throw new Error("Tool argument 'path' must be a non-empty string.");
|
|
467
|
+
}
|
|
468
|
+
const path = resolveToolPath(cwd, args.path);
|
|
469
|
+
const info = await stat(path).catch((error) => {
|
|
470
|
+
throw new Error(pathNotFoundMessage("python", args.path, path), error instanceof Error ? { cause: error } : undefined);
|
|
471
|
+
});
|
|
472
|
+
if (!info.isFile()) {
|
|
473
|
+
throw new Error(`Tool argument 'path' must point to a Python script file: ${path}`);
|
|
474
|
+
}
|
|
475
|
+
return { kind: "file", path };
|
|
476
|
+
}
|
|
477
|
+
function clampTimeout(value) {
|
|
478
|
+
if (typeof value !== "number")
|
|
479
|
+
return DEFAULT_TIMEOUT_SECONDS;
|
|
480
|
+
const seconds = numberArg(value, DEFAULT_TIMEOUT_SECONDS);
|
|
481
|
+
if (seconds <= 0)
|
|
482
|
+
return DEFAULT_TIMEOUT_SECONDS;
|
|
483
|
+
return Math.min(seconds, MAX_TIMEOUT_SECONDS);
|
|
484
|
+
}
|
|
485
|
+
function envOverridesArg(value) {
|
|
486
|
+
if (value === undefined)
|
|
487
|
+
return {};
|
|
488
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
489
|
+
throw new Error("Tool argument 'env' must be an object of string values.");
|
|
490
|
+
}
|
|
491
|
+
const output = {};
|
|
492
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
493
|
+
if (typeof raw !== "string") {
|
|
494
|
+
throw new Error("Tool argument 'env' must be an object of string values.");
|
|
495
|
+
}
|
|
496
|
+
if (raw.includes("\0")) {
|
|
497
|
+
throw new Error("Tool argument 'env' contains an invalid value.");
|
|
498
|
+
}
|
|
499
|
+
if (key.length === 0 || key.includes("=") || key.includes("\0")) {
|
|
500
|
+
throw new Error("Tool argument 'env' contains an invalid environment key.");
|
|
501
|
+
}
|
|
502
|
+
if (SENSITIVE_ENV_KEY_PATTERN.test(key)) {
|
|
503
|
+
throw new Error(`Tool argument 'env' contains sensitive-looking key '${key}'. The python tool only accepts non-secret env overrides.`);
|
|
504
|
+
}
|
|
505
|
+
output[key] = raw;
|
|
506
|
+
}
|
|
507
|
+
return output;
|
|
508
|
+
}
|
|
509
|
+
async function createArtifactDir(dataDir) {
|
|
510
|
+
const baseDir = dataDir
|
|
511
|
+
? join(dataDir, "tmp", "python-artifacts")
|
|
512
|
+
: join(tmpdir(), "nerve-python-artifacts");
|
|
513
|
+
await mkdir(baseDir, { recursive: true, mode: 0o700 });
|
|
514
|
+
return await mkdtemp(join(baseDir, "run-"));
|
|
515
|
+
}
|
|
516
|
+
async function listArtifacts(root) {
|
|
517
|
+
const artifacts = [];
|
|
518
|
+
await visitArtifactDir(root, artifacts).catch(() => undefined);
|
|
519
|
+
return artifacts.sort((a, b) => a.path.localeCompare(b.path));
|
|
520
|
+
}
|
|
521
|
+
async function visitArtifactDir(dir, artifacts) {
|
|
522
|
+
if (artifacts.length >= MAX_ARTIFACTS)
|
|
523
|
+
return;
|
|
524
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
525
|
+
for (const entry of entries) {
|
|
526
|
+
if (artifacts.length >= MAX_ARTIFACTS)
|
|
527
|
+
return;
|
|
528
|
+
const path = join(dir, entry.name);
|
|
529
|
+
if (entry.isDirectory()) {
|
|
530
|
+
await visitArtifactDir(path, artifacts);
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
if (!entry.isFile())
|
|
534
|
+
continue;
|
|
535
|
+
const info = await stat(path).catch(() => undefined);
|
|
536
|
+
artifacts.push({ path, size: info?.size ?? 0 });
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
function artifactFooterLines(artifacts) {
|
|
540
|
+
if (artifacts.length === 0)
|
|
541
|
+
return [];
|
|
542
|
+
const lines = [
|
|
543
|
+
`Python artifacts (${artifacts.length}):`,
|
|
544
|
+
...artifacts.map((artifact) => `- ${artifact.path} (${formatArtifactSize(artifact.size)})`),
|
|
545
|
+
];
|
|
546
|
+
if (artifacts.length >= MAX_ARTIFACTS) {
|
|
547
|
+
lines.push(`- ... artifact list capped at ${MAX_ARTIFACTS} files`);
|
|
548
|
+
}
|
|
549
|
+
return lines;
|
|
550
|
+
}
|
|
551
|
+
function artifactCount(result) {
|
|
552
|
+
const details = result.details;
|
|
553
|
+
if (!details || typeof details !== "object")
|
|
554
|
+
return 0;
|
|
555
|
+
const artifacts = details.artifacts;
|
|
556
|
+
return Array.isArray(artifacts) ? artifacts.length : 0;
|
|
557
|
+
}
|
|
558
|
+
function formatArtifactSize(bytes) {
|
|
559
|
+
if (bytes < 1024)
|
|
560
|
+
return `${bytes} B`;
|
|
561
|
+
const kb = bytes / 1024;
|
|
562
|
+
if (kb < 1024)
|
|
563
|
+
return `${kb.toFixed(1)} KB`;
|
|
564
|
+
return `${(kb / 1024).toFixed(1)} MB`;
|
|
565
|
+
}
|
|
566
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../../src/execution/python/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7E,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,yBAAyB,GAC7B,8GAA8G,CAAC;AAEjH,8EAA8E;AAC9E,gFAAgF;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AAI,SAAS,CAAC,MAAM,IAAI,aAAa,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,iCAAiC,aAAa,QAAQ,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,aAAa,CAAC,MAA2B;IAChD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACtD,MAAM,SAAS,GAAI,OAAmC,CAAC,SAAS,CAAC;IACjE,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa;IACvC,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5C,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type PythonRuntimeSource = "manual" | "project_venv" | "path" | "windows_launcher" | "uv";
|
|
2
|
+
export type PythonRuntime = {
|
|
3
|
+
command: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
displayPath: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
source: PythonRuntimeSource;
|
|
8
|
+
};
|
|
9
|
+
export type PythonRuntimeStatus = (PythonRuntime & {
|
|
10
|
+
available: true;
|
|
11
|
+
}) | {
|
|
12
|
+
available: false;
|
|
13
|
+
source: "unavailable";
|
|
14
|
+
error: string;
|
|
15
|
+
};
|
|
16
|
+
export type ResolvePythonRuntimeOptions = {
|
|
17
|
+
cwd: string;
|
|
18
|
+
manualPath?: string;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
};
|
|
21
|
+
export declare function resolvePythonRuntime(options: ResolvePythonRuntimeOptions): Promise<PythonRuntimeStatus>;
|
|
22
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/execution/python/runtime.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,GACR,cAAc,GACd,MAAM,GACN,kBAAkB,GAClB,IAAI,CAAC;AAET,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,mBAAmB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,CAAC,aAAa,GAAG;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,GACrC;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,2BAA2B,GAAG;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAiBF,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,CAkC9B"}
|