@nervekit/desktop 0.16.2 → 0.17.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 (140) hide show
  1. package/README.md +8 -1
  2. package/node_modules/@nervekit/contracts/dist/domains/agents/agent.events.schema.d.ts.map +1 -1
  3. package/node_modules/@nervekit/contracts/dist/domains/agents/agent.events.schema.js +47 -0
  4. package/node_modules/@nervekit/contracts/dist/domains/agents/agent.events.schema.js.map +1 -1
  5. package/node_modules/@nervekit/contracts/dist/domains/agents/agent.operations.schema.d.ts +5 -0
  6. package/node_modules/@nervekit/contracts/dist/domains/agents/agent.operations.schema.d.ts.map +1 -1
  7. package/node_modules/@nervekit/contracts/dist/domains/agents/agent.operations.schema.js +6 -0
  8. package/node_modules/@nervekit/contracts/dist/domains/agents/agent.operations.schema.js.map +1 -1
  9. package/node_modules/@nervekit/contracts/dist/domains/agents/index.d.ts +1 -0
  10. package/node_modules/@nervekit/contracts/dist/domains/agents/index.d.ts.map +1 -1
  11. package/node_modules/@nervekit/contracts/dist/domains/agents/index.js +1 -0
  12. package/node_modules/@nervekit/contracts/dist/domains/agents/index.js.map +1 -1
  13. package/node_modules/@nervekit/contracts/dist/domains/agents/run.operations.schema.d.ts +8 -8
  14. package/node_modules/@nervekit/contracts/dist/domains/agents/subagent-transcript.schema.d.ts +72 -0
  15. package/node_modules/@nervekit/contracts/dist/domains/agents/subagent-transcript.schema.d.ts.map +1 -0
  16. package/node_modules/@nervekit/contracts/dist/domains/agents/subagent-transcript.schema.js +77 -0
  17. package/node_modules/@nervekit/contracts/dist/domains/agents/subagent-transcript.schema.js.map +1 -0
  18. package/node_modules/@nervekit/contracts/dist/domains/auth/auth.schema.d.ts +2 -2
  19. package/node_modules/@nervekit/contracts/dist/domains/conversations/conversation.schema.d.ts +2 -2
  20. package/node_modules/@nervekit/contracts/dist/domains/models/model.operations.schema.d.ts +4 -0
  21. package/node_modules/@nervekit/contracts/dist/domains/models/model.operations.schema.d.ts.map +1 -1
  22. package/node_modules/@nervekit/contracts/dist/domains/models/models.schema.d.ts +9 -0
  23. package/node_modules/@nervekit/contracts/dist/domains/models/models.schema.d.ts.map +1 -1
  24. package/node_modules/@nervekit/contracts/dist/domains/models/models.schema.js +3 -0
  25. package/node_modules/@nervekit/contracts/dist/domains/models/models.schema.js.map +1 -1
  26. package/node_modules/@nervekit/contracts/dist/domains/protocol/http.schema.d.ts +4 -0
  27. package/node_modules/@nervekit/contracts/dist/domains/protocol/http.schema.d.ts.map +1 -1
  28. package/node_modules/@nervekit/contracts/dist/domains/protocol/messages.schema.d.ts +2 -0
  29. package/node_modules/@nervekit/contracts/dist/domains/protocol/messages.schema.d.ts.map +1 -1
  30. package/node_modules/@nervekit/contracts/dist/domains/protocol/operation-catalog.schema.d.ts +17 -7
  31. package/node_modules/@nervekit/contracts/dist/domains/protocol/operation-catalog.schema.d.ts.map +1 -1
  32. package/node_modules/@nervekit/contracts/dist/domains/protocol/snapshot.schema.d.ts +1 -1
  33. package/node_modules/@nervekit/contracts/dist/domains/providers/providers.schema.d.ts +0 -5
  34. package/node_modules/@nervekit/contracts/dist/domains/providers/providers.schema.d.ts.map +1 -1
  35. package/node_modules/@nervekit/contracts/dist/domains/providers/providers.schema.js +1 -2
  36. package/node_modules/@nervekit/contracts/dist/domains/providers/providers.schema.js.map +1 -1
  37. package/node_modules/@nervekit/contracts/dist/domains/runs/run-runtime.schema.d.ts +3 -3
  38. package/node_modules/@nervekit/contracts/dist/domains/snapshots/snapshot.operations.schema.d.ts +1 -1
  39. package/node_modules/@nervekit/contracts/dist/domains/status/status.schema.d.ts +1 -0
  40. package/node_modules/@nervekit/contracts/dist/domains/status/status.schema.d.ts.map +1 -1
  41. package/node_modules/@nervekit/contracts/dist/domains/status/status.schema.js +1 -0
  42. package/node_modules/@nervekit/contracts/dist/domains/status/status.schema.js.map +1 -1
  43. package/node_modules/@nervekit/contracts/package.json +1 -1
  44. package/node_modules/@nervekit/harness/dist/models/resolution.d.ts.map +1 -1
  45. package/node_modules/@nervekit/harness/dist/models/resolution.js +1 -0
  46. package/node_modules/@nervekit/harness/dist/models/resolution.js.map +1 -1
  47. package/node_modules/@nervekit/harness/dist/models/types.d.ts +2 -0
  48. package/node_modules/@nervekit/harness/dist/models/types.d.ts.map +1 -1
  49. package/node_modules/@nervekit/harness/package.json +2 -2
  50. package/node_modules/@nervekit/protocol/package.json +2 -2
  51. package/node_modules/@nervekit/tools/dist/execution/executable/executable.d.ts +33 -0
  52. package/node_modules/@nervekit/tools/dist/execution/executable/executable.d.ts.map +1 -0
  53. package/node_modules/@nervekit/tools/dist/execution/executable/executable.js +249 -0
  54. package/node_modules/@nervekit/tools/dist/execution/executable/executable.js.map +1 -0
  55. package/node_modules/@nervekit/tools/dist/execution/index.d.ts +1 -0
  56. package/node_modules/@nervekit/tools/dist/execution/index.d.ts.map +1 -1
  57. package/node_modules/@nervekit/tools/dist/execution/index.js +1 -0
  58. package/node_modules/@nervekit/tools/dist/execution/index.js.map +1 -1
  59. package/node_modules/@nervekit/tools/dist/execution/python/runtime.d.ts +3 -0
  60. package/node_modules/@nervekit/tools/dist/execution/python/runtime.d.ts.map +1 -1
  61. package/node_modules/@nervekit/tools/dist/execution/python/runtime.js +134 -94
  62. package/node_modules/@nervekit/tools/dist/execution/python/runtime.js.map +1 -1
  63. package/node_modules/@nervekit/tools/dist/index.d.ts +1 -1
  64. package/node_modules/@nervekit/tools/dist/index.d.ts.map +1 -1
  65. package/node_modules/@nervekit/tools/dist/index.js +1 -1
  66. package/node_modules/@nervekit/tools/dist/index.js.map +1 -1
  67. package/node_modules/@nervekit/tools/package.json +3 -2
  68. package/node_modules/@nervekit/workbench-server/dist/app/orchestrator-state.d.ts.map +1 -1
  69. package/node_modules/@nervekit/workbench-server/dist/app/orchestrator-state.js +1 -0
  70. package/node_modules/@nervekit/workbench-server/dist/app/orchestrator-state.js.map +1 -1
  71. package/node_modules/@nervekit/workbench-server/dist/domains/agents/prompting/agent-browser-skills.d.ts +10 -0
  72. package/node_modules/@nervekit/workbench-server/dist/domains/agents/prompting/agent-browser-skills.d.ts.map +1 -1
  73. package/node_modules/@nervekit/workbench-server/dist/domains/agents/prompting/agent-browser-skills.js +28 -8
  74. package/node_modules/@nervekit/workbench-server/dist/domains/agents/prompting/agent-browser-skills.js.map +1 -1
  75. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/explore-helpers.d.ts.map +1 -1
  76. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/explore-helpers.js +2 -71
  77. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/explore-helpers.js.map +1 -1
  78. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/explore-tool-summary.d.ts +2 -0
  79. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/explore-tool-summary.d.ts.map +1 -0
  80. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/explore-tool-summary.js +189 -0
  81. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/explore-tool-summary.js.map +1 -0
  82. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/message-mirror.d.ts +8 -1
  83. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/message-mirror.d.ts.map +1 -1
  84. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/message-mirror.js +20 -0
  85. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/message-mirror.js.map +1 -1
  86. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/subagent-runner.d.ts +2 -0
  87. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/subagent-runner.d.ts.map +1 -1
  88. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/subagent-runner.js +28 -15
  89. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/subagent-runner.js.map +1 -1
  90. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/workbench-agent-mechanics.d.ts +2 -0
  91. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/workbench-agent-mechanics.d.ts.map +1 -1
  92. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/workbench-agent-mechanics.js +1 -0
  93. package/node_modules/@nervekit/workbench-server/dist/domains/agents/run/workbench-agent-mechanics.js.map +1 -1
  94. package/node_modules/@nervekit/workbench-server/dist/domains/agents/subagent-transcript-live.service.d.ts +20 -0
  95. package/node_modules/@nervekit/workbench-server/dist/domains/agents/subagent-transcript-live.service.d.ts.map +1 -0
  96. package/node_modules/@nervekit/workbench-server/dist/domains/agents/subagent-transcript-live.service.js +214 -0
  97. package/node_modules/@nervekit/workbench-server/dist/domains/agents/subagent-transcript-live.service.js.map +1 -0
  98. package/node_modules/@nervekit/workbench-server/dist/domains/agents/subagent-transcript.service.d.ts +20 -0
  99. package/node_modules/@nervekit/workbench-server/dist/domains/agents/subagent-transcript.service.d.ts.map +1 -0
  100. package/node_modules/@nervekit/workbench-server/dist/domains/agents/subagent-transcript.service.js +184 -0
  101. package/node_modules/@nervekit/workbench-server/dist/domains/agents/subagent-transcript.service.js.map +1 -0
  102. package/node_modules/@nervekit/workbench-server/dist/domains/projects/project-editor.service.d.ts +5 -2
  103. package/node_modules/@nervekit/workbench-server/dist/domains/projects/project-editor.service.d.ts.map +1 -1
  104. package/node_modules/@nervekit/workbench-server/dist/domains/projects/project-editor.service.js +14 -39
  105. package/node_modules/@nervekit/workbench-server/dist/domains/projects/project-editor.service.js.map +1 -1
  106. package/node_modules/@nervekit/workbench-server/dist/domains/tools/tool-service.d.ts +3 -1
  107. package/node_modules/@nervekit/workbench-server/dist/domains/tools/tool-service.d.ts.map +1 -1
  108. package/node_modules/@nervekit/workbench-server/dist/domains/tools/tool-service.js.map +1 -1
  109. package/node_modules/@nervekit/workbench-server/dist/infrastructure/storage/paths.d.ts +2 -0
  110. package/node_modules/@nervekit/workbench-server/dist/infrastructure/storage/paths.d.ts.map +1 -1
  111. package/node_modules/@nervekit/workbench-server/dist/infrastructure/storage/paths.js +1 -0
  112. package/node_modules/@nervekit/workbench-server/dist/infrastructure/storage/paths.js.map +1 -1
  113. package/node_modules/@nervekit/workbench-server/dist/main.js +2 -0
  114. package/node_modules/@nervekit/workbench-server/dist/main.js.map +1 -1
  115. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers/conversation-agent-method-handlers.d.ts +6 -0
  116. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers/conversation-agent-method-handlers.d.ts.map +1 -1
  117. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers/conversation-agent-method-handlers.js +3 -0
  118. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers/conversation-agent-method-handlers.js.map +1 -1
  119. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers/git-method-handlers.d.ts +1 -1
  120. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers/platform-method-handlers.d.ts +1 -0
  121. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers/platform-method-handlers.d.ts.map +1 -1
  122. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers.d.ts +1 -1
  123. package/node_modules/@nervekit/workbench-server/dist/protocol/method-handlers.d.ts.map +1 -1
  124. package/node_modules/@nervekit/workbench-server/dist/runtime/runtime-composition.d.ts +4 -0
  125. package/node_modules/@nervekit/workbench-server/dist/runtime/runtime-composition.d.ts.map +1 -1
  126. package/node_modules/@nervekit/workbench-server/dist/runtime/runtime-composition.js +12 -0
  127. package/node_modules/@nervekit/workbench-server/dist/runtime/runtime-composition.js.map +1 -1
  128. package/node_modules/@nervekit/workbench-server/dist/runtime/runtime-registry.d.ts +3 -0
  129. package/node_modules/@nervekit/workbench-server/dist/runtime/runtime-registry.d.ts.map +1 -1
  130. package/node_modules/@nervekit/workbench-server/dist/runtime/runtime-registry.js +22 -9
  131. package/node_modules/@nervekit/workbench-server/dist/runtime/runtime-registry.js.map +1 -1
  132. package/node_modules/@nervekit/workbench-server/dist/web/assets/{dist-_--zIOwq.js → dist-Cpy8QsNT.js} +1 -1
  133. package/node_modules/@nervekit/workbench-server/dist/web/assets/index-CK9u3bt5.js +264 -0
  134. package/node_modules/@nervekit/workbench-server/dist/web/assets/index-Dt2kEvYE.css +1 -0
  135. package/node_modules/@nervekit/workbench-server/dist/web/index.html +2 -2
  136. package/node_modules/@nervekit/workbench-server/dist/web/sw.js +1 -1
  137. package/node_modules/@nervekit/workbench-server/package.json +5 -5
  138. package/package.json +7 -6
  139. package/node_modules/@nervekit/workbench-server/dist/web/assets/index-Dboh6jC8.js +0 -261
  140. package/node_modules/@nervekit/workbench-server/dist/web/assets/index-dBcMgZ94.css +0 -1
@@ -0,0 +1,249 @@
1
+ import { constants } from "node:fs";
2
+ import { access, readdir } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import { dirname, extname, isAbsolute, join, resolve } from "node:path";
5
+ import crossSpawn from "cross-spawn";
6
+ const WINDOWS_EXECUTABLE_EXTENSIONS = [".com", ".exe", ".bat", ".cmd"];
7
+ const DEFAULT_MAX_BUFFER = 4 * 1024 * 1024;
8
+ export async function locateExecutable(command, options = {}) {
9
+ const value = command.trim();
10
+ if (!value)
11
+ return undefined;
12
+ const platform = options.platform ?? process.platform;
13
+ const env = options.env ?? process.env;
14
+ const candidates = executableNames(value, platform, env);
15
+ if (isAbsolute(value) || value.includes("/") || value.includes("\\")) {
16
+ const base = isAbsolute(value)
17
+ ? value
18
+ : resolve(options.cwd ?? process.cwd(), value);
19
+ for (const candidate of executableNames(base, platform, env)) {
20
+ if (await isExecutableFile(candidate, platform)) {
21
+ return resolvedExecutable(candidate, platform);
22
+ }
23
+ }
24
+ return undefined;
25
+ }
26
+ const directories = await executableSearchDirectories(options);
27
+ for (const directory of directories) {
28
+ for (const candidate of candidates) {
29
+ const path = join(directory, candidate);
30
+ if (await isExecutableFile(path, platform)) {
31
+ return resolvedExecutable(path, platform);
32
+ }
33
+ }
34
+ }
35
+ for (const path of options.additionalPaths ?? []) {
36
+ for (const candidate of executableNames(path, platform, env)) {
37
+ if (await isExecutableFile(candidate, platform)) {
38
+ return resolvedExecutable(candidate, platform);
39
+ }
40
+ }
41
+ }
42
+ return undefined;
43
+ }
44
+ export async function executableSearchDirectories(options = {}) {
45
+ const platform = options.platform ?? process.platform;
46
+ const env = options.env ?? process.env;
47
+ const home = options.homeDir ?? homeFromEnvironment(env) ?? homedir();
48
+ const delimiter = platform === "win32" ? ";" : ":";
49
+ const inheritedPath = environmentValue(env, "PATH") ?? "";
50
+ const directories = [
51
+ ...inheritedPath.split(delimiter),
52
+ ...(options.additionalDirectories ?? []),
53
+ ...conventionalDirectories(platform, env, home),
54
+ ];
55
+ directories.push(...(await versionManagerDirectories(platform, home)));
56
+ return deduplicatePaths(directories, platform);
57
+ }
58
+ export function spawnExecutable(executable, args, options = {}) {
59
+ const path = typeof executable === "string" ? executable : executable.path;
60
+ return crossSpawn(path, [...args], {
61
+ windowsHide: true,
62
+ ...options,
63
+ env: executableEnvironment(path, options.env ?? process.env),
64
+ });
65
+ }
66
+ export async function runExecutable(executable, args, options = {}) {
67
+ return await new Promise((resolveResult) => {
68
+ let stdout = "";
69
+ let stderr = "";
70
+ let error;
71
+ let timedOut = false;
72
+ let settled = false;
73
+ const maxBuffer = options.maxBuffer ?? DEFAULT_MAX_BUFFER;
74
+ const child = spawnExecutable(executable, args, {
75
+ cwd: options.cwd,
76
+ env: options.env,
77
+ stdio: ["ignore", "pipe", "pipe"],
78
+ windowsHide: options.windowsHide ?? true,
79
+ });
80
+ const timer = options.timeoutMs
81
+ ? setTimeout(() => {
82
+ timedOut = true;
83
+ child.kill("SIGTERM");
84
+ }, options.timeoutMs)
85
+ : undefined;
86
+ timer?.unref();
87
+ const finish = (status) => {
88
+ if (settled)
89
+ return;
90
+ settled = true;
91
+ if (timer)
92
+ clearTimeout(timer);
93
+ resolveResult({ stdout, stderr, status, error, timedOut });
94
+ };
95
+ const append = (current, chunk) => {
96
+ const remaining = Math.max(0, maxBuffer - Buffer.byteLength(current));
97
+ if (remaining === 0)
98
+ return current;
99
+ return (current + Buffer.from(chunk).subarray(0, remaining).toString("utf8"));
100
+ };
101
+ child.stdout?.setEncoding("utf8");
102
+ child.stderr?.setEncoding("utf8");
103
+ child.stdout?.on("data", (chunk) => {
104
+ stdout = append(stdout, chunk);
105
+ });
106
+ child.stderr?.on("data", (chunk) => {
107
+ stderr = append(stderr, chunk);
108
+ });
109
+ child.once("error", (cause) => {
110
+ error = cause;
111
+ });
112
+ child.once("close", finish);
113
+ });
114
+ }
115
+ function executableEnvironment(executable, env) {
116
+ const result = { ...env };
117
+ const key = environmentKey(result, "PATH") ?? "PATH";
118
+ const delimiter = process.platform === "win32" ? ";" : ":";
119
+ const parent = dirname(executable);
120
+ if (parent && parent !== ".") {
121
+ const existing = result[key];
122
+ result[key] = existing ? `${parent}${delimiter}${existing}` : parent;
123
+ }
124
+ return result;
125
+ }
126
+ function executableNames(command, platform, env) {
127
+ if (platform !== "win32")
128
+ return [command];
129
+ const extension = extname(command).toLowerCase();
130
+ if (WINDOWS_EXECUTABLE_EXTENSIONS.includes(extension))
131
+ return [command];
132
+ const pathExt = environmentValue(env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
133
+ const extensions = pathExt
134
+ .split(";")
135
+ .map((value) => value.trim().toLowerCase())
136
+ .filter((value) => WINDOWS_EXECUTABLE_EXTENSIONS.includes(value));
137
+ return [...new Set(extensions.map((value) => `${command}${value}`))];
138
+ }
139
+ function resolvedExecutable(path, platform) {
140
+ const extension = extname(path).toLowerCase();
141
+ return {
142
+ path,
143
+ kind: platform === "win32" && (extension === ".cmd" || extension === ".bat")
144
+ ? "windows_script"
145
+ : "native",
146
+ };
147
+ }
148
+ async function isExecutableFile(path, platform) {
149
+ try {
150
+ await access(path, platform === "win32" ? constants.F_OK : constants.X_OK);
151
+ return true;
152
+ }
153
+ catch {
154
+ return false;
155
+ }
156
+ }
157
+ function conventionalDirectories(platform, env, home) {
158
+ const explicit = [
159
+ env.PNPM_HOME,
160
+ env.VOLTA_HOME ? join(env.VOLTA_HOME, "bin") : undefined,
161
+ env.BUN_INSTALL ? join(env.BUN_INSTALL, "bin") : undefined,
162
+ env.UV_INSTALL_DIR,
163
+ ];
164
+ if (platform === "win32") {
165
+ return compact([
166
+ ...explicit,
167
+ join(home, ".local", "bin"),
168
+ env.APPDATA ? join(env.APPDATA, "npm") : undefined,
169
+ env.LOCALAPPDATA ? join(env.LOCALAPPDATA, "pnpm") : undefined,
170
+ join(home, ".bun", "bin"),
171
+ join(home, ".volta", "bin"),
172
+ join(home, "scoop", "shims"),
173
+ env.ChocolateyInstall ? join(env.ChocolateyInstall, "bin") : undefined,
174
+ env.LOCALAPPDATA
175
+ ? join(env.LOCALAPPDATA, "Microsoft", "WindowsApps")
176
+ : undefined,
177
+ ]);
178
+ }
179
+ return compact([
180
+ ...explicit,
181
+ join(home, ".local", "bin"),
182
+ join(home, ".cargo", "bin"),
183
+ join(home, ".bun", "bin"),
184
+ join(home, ".volta", "bin"),
185
+ join(home, ".asdf", "shims"),
186
+ join(home, ".pyenv", "shims"),
187
+ join(home, ".local", "share", "mise", "shims"),
188
+ platform === "darwin" ? join(home, "Library", "pnpm") : undefined,
189
+ platform === "darwin" ? "/opt/homebrew/bin" : undefined,
190
+ "/usr/local/bin",
191
+ "/usr/bin",
192
+ "/bin",
193
+ ]);
194
+ }
195
+ async function versionManagerDirectories(platform, home) {
196
+ if (platform === "win32")
197
+ return [];
198
+ const roots = [
199
+ { root: join(home, ".nvm", "versions", "node"), suffix: ["bin"] },
200
+ {
201
+ root: join(home, ".fnm", "node-versions"),
202
+ suffix: ["installation", "bin"],
203
+ },
204
+ ];
205
+ const result = [];
206
+ for (const { root, suffix } of roots) {
207
+ try {
208
+ const entries = await readdir(root, { withFileTypes: true });
209
+ result.push(...entries
210
+ .filter((entry) => entry.isDirectory())
211
+ .map((entry) => join(root, entry.name, ...suffix))
212
+ .sort((left, right) => right.localeCompare(left, undefined, { numeric: true })));
213
+ }
214
+ catch {
215
+ // Optional version-manager root.
216
+ }
217
+ }
218
+ return result;
219
+ }
220
+ function environmentKey(env, name) {
221
+ const target = name.toLowerCase();
222
+ return Object.keys(env).find((key) => key.toLowerCase() === target);
223
+ }
224
+ function environmentValue(env, name) {
225
+ const key = environmentKey(env, name);
226
+ return key ? env[key] : undefined;
227
+ }
228
+ function homeFromEnvironment(env) {
229
+ return env.HOME ?? env.USERPROFILE;
230
+ }
231
+ function deduplicatePaths(paths, platform) {
232
+ const seen = new Set();
233
+ const result = [];
234
+ for (const raw of paths) {
235
+ const path = raw?.trim();
236
+ if (!path)
237
+ continue;
238
+ const key = platform === "win32" ? path.toLowerCase() : path;
239
+ if (seen.has(key))
240
+ continue;
241
+ seen.add(key);
242
+ result.push(path);
243
+ }
244
+ return result;
245
+ }
246
+ function compact(values) {
247
+ return values.filter((value) => Boolean(value));
248
+ }
249
+ //# sourceMappingURL=executable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable.js","sourceRoot":"","sources":["../../../src/execution/executable/executable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,UAAU,MAAM,aAAa,CAAC;AAkCrC,MAAM,6BAA6B,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvE,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,UAAoC,EAAE;IAEtC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,QAAQ,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,CAAC,CAAC,IAAI,CAAC;QAC7D,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,MAAuC;IACtD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACnE,CAAC"}
@@ -4,6 +4,7 @@ export { type LiveOutputObserver, LiveOutputDelivery, } from "./common/live-outp
4
4
  export { buildProcessResult, buildProcessTextResult, } from "./common/process-result.js";
5
5
  export { ToolExecutionError } from "./common/tool-error.js";
6
6
  export { executeTool } from "./core-dispatch.js";
7
+ export { type ExecutableLocatorOptions, type ExecutablePlatform, type ExecutableRunOptions, type ExecutableRunResult, executableSearchDirectories, locateExecutable, type ResolvedExecutable, runExecutable, spawnExecutable, } from "./executable/executable.js";
7
8
  export { executeEdit, normalizeEditArgs } from "./filesystem/edit.js";
8
9
  export { executeFind } from "./filesystem/find.js";
9
10
  export { executeLs } from "./filesystem/list.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,SAAS,EACT,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,2BAA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OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,KAAK,6BAA6B,EAClC,sBAAsB,EACtB,KAAK,WAAW,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -4,6 +4,7 @@ export { LiveOutputDelivery, } from "./common/live-output.js";
4
4
  export { buildProcessResult, buildProcessTextResult, } from "./common/process-result.js";
5
5
  export { ToolExecutionError } from "./common/tool-error.js";
6
6
  export { executeTool } from "./core-dispatch.js";
7
+ export { executableSearchDirectories, locateExecutable, runExecutable, spawnExecutable, } from "./executable/executable.js";
7
8
  export { executeEdit, normalizeEditArgs } from "./filesystem/edit.js";
8
9
  export { executeFind } from "./filesystem/find.js";
9
10
  export { executeLs } from "./filesystem/list.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAElB,qBAAqB,EACrB,SAAS,EACT,0BAA0B,EAC1B,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,EAC3B,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAG7B,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;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,EAC3B,gBAAgB,EAEhB,aAAa,EACb,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAEL,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -17,6 +17,9 @@ export type ResolvePythonRuntimeOptions = {
17
17
  cwd: string;
18
18
  manualPath?: string;
19
19
  timeoutMs?: number;
20
+ platform?: NodeJS.Platform;
21
+ env?: NodeJS.ProcessEnv;
22
+ homeDir?: string;
20
23
  };
21
24
  export declare function resolvePythonRuntime(options: ResolvePythonRuntimeOptions): Promise<PythonRuntimeStatus>;
22
25
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/execution/python/runtime.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAAC;AAEhF,MAAM,MAAM,aAAa,GAAG;IAC1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AE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAiBF,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,CA0D9B"}
@@ -1,84 +1,156 @@
1
- import { spawn } from "node:child_process";
2
- import { access } from "node:fs/promises";
1
+ import { readdir } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { locateExecutable, runExecutable, } from "../executable/executable.js";
3
5
  const MIN_VERSION = [3, 9];
4
6
  export async function resolvePythonRuntime(options) {
5
7
  const timeoutMs = options.timeoutMs ?? 5000;
6
- const candidates = await pythonCandidates(options.cwd, options.manualPath);
8
+ const locatorOptions = executableLocatorOptions(options);
7
9
  let lastError = "No Python executable found.";
8
- for (const candidate of candidates) {
9
- if (candidate.mustExist && !(await pathExists(candidate.command))) {
10
- lastError = `Python executable not found: ${candidate.command}`;
11
- continue;
10
+ if (options.manualPath?.trim()) {
11
+ const manualPath = options.manualPath.trim();
12
+ const executable = await locateExecutable(manualPath, locatorOptions);
13
+ if (!executable) {
14
+ return {
15
+ available: false,
16
+ source: "unavailable",
17
+ error: `Python executable not found: ${manualPath}`,
18
+ };
12
19
  }
13
- const probe = await probePython(candidate.command, candidate.args, timeoutMs);
14
- if (!probe.ok) {
15
- lastError = probe.error;
16
- continue;
20
+ return await probeCandidate(executable, [], "manual", timeoutMs, options.env);
21
+ }
22
+ const uvPython = await findUvPython(options, locatorOptions, timeoutMs);
23
+ if (uvPython) {
24
+ const executable = await locateExecutable(uvPython, locatorOptions);
25
+ if (executable) {
26
+ const status = await probeCandidate(executable, [], "uv", timeoutMs, options.env);
27
+ if (status.available)
28
+ return status;
29
+ lastError = status.error;
17
30
  }
18
- if (!supportedVersion(probe.value.versionInfo)) {
19
- lastError = `Python ${probe.value.version} is too old; Python ${MIN_VERSION[0]}.${MIN_VERSION[1]}+ is required.`;
31
+ }
32
+ for (const candidate of await pythonCandidates(options)) {
33
+ const executable = await locateExecutable(candidate.command, {
34
+ ...locatorOptions,
35
+ additionalPaths: candidate.knownPaths,
36
+ });
37
+ if (!executable)
20
38
  continue;
21
- }
22
- return {
23
- available: true,
24
- command: candidate.command,
25
- args: candidate.args,
26
- displayPath: probe.value.executable || candidate.command,
27
- version: probe.value.version,
28
- source: candidate.source,
29
- };
39
+ const status = await probeCandidate(executable, candidate.args, candidate.source, timeoutMs, options.env);
40
+ if (status.available)
41
+ return status;
42
+ lastError = status.error;
30
43
  }
31
44
  return { available: false, source: "unavailable", error: lastError };
32
45
  }
33
- async function pythonCandidates(cwd, manualPath) {
34
- if (manualPath?.trim()) {
46
+ async function findUvPython(options, locatorOptions, timeoutMs) {
47
+ const uv = await locateExecutable("uv", locatorOptions);
48
+ if (!uv)
49
+ return undefined;
50
+ const result = await runExecutable(uv, ["python", "find", "--no-project"], {
51
+ timeoutMs,
52
+ cwd: options.cwd,
53
+ env: { ...(options.env ?? process.env), UV_PYTHON_DOWNLOADS: "never" },
54
+ });
55
+ if (result.error || result.status !== 0)
56
+ return undefined;
57
+ return result.stdout
58
+ .split(/\r?\n/)
59
+ .map((line) => line.trim())
60
+ .find(Boolean);
61
+ }
62
+ async function pythonCandidates(options) {
63
+ const platform = options.platform ?? process.platform;
64
+ if (platform === "win32") {
65
+ const knownPaths = await windowsPythonPaths(options);
35
66
  return [
36
67
  {
37
- command: manualPath.trim(),
68
+ command: "python.exe",
38
69
  args: [],
39
- source: "manual",
40
- mustExist: true,
70
+ source: "path",
71
+ knownPaths,
41
72
  },
73
+ { command: "python3.exe", args: [], source: "path" },
74
+ { command: "py.exe", args: ["-3"], source: "windows_launcher" },
75
+ { command: "py", args: ["-3"], source: "windows_launcher" },
42
76
  ];
43
77
  }
44
- const candidates = [];
45
- const uvPython = await findUvPython(cwd);
46
- if (uvPython) {
47
- candidates.push({
48
- command: uvPython,
49
- args: [],
50
- source: "uv",
51
- mustExist: true,
52
- });
53
- }
54
- if (process.platform === "win32") {
55
- candidates.push({ command: "python.exe", args: [], source: "path" }, { command: "python3.exe", args: [], source: "path" }, { command: "py.exe", args: ["-3"], source: "windows_launcher" }, { command: "py", args: ["-3"], source: "windows_launcher" });
78
+ const knownPaths = platform === "darwin"
79
+ ? [
80
+ "/opt/homebrew/bin/python3",
81
+ "/usr/local/bin/python3",
82
+ "/usr/bin/python3",
83
+ "/Library/Frameworks/Python.framework/Versions/Current/bin/python3",
84
+ ]
85
+ : ["/usr/local/bin/python3", "/usr/bin/python3", "/bin/python3"];
86
+ return [
87
+ { command: "python3", args: [], source: "path", knownPaths },
88
+ { command: "python", args: [], source: "path" },
89
+ ];
90
+ }
91
+ async function windowsPythonPaths(options) {
92
+ const env = options.env ?? process.env;
93
+ const home = options.homeDir ?? env.USERPROFILE ?? env.HOME ?? homedir();
94
+ const roots = [
95
+ env.LOCALAPPDATA ? join(env.LOCALAPPDATA, "Programs", "Python") : undefined,
96
+ env.ProgramFiles,
97
+ env["ProgramFiles(x86)"],
98
+ ].filter((value) => Boolean(value));
99
+ const paths = [];
100
+ for (const root of roots) {
101
+ try {
102
+ const directories = (await readdir(root, { withFileTypes: true }))
103
+ .filter((entry) => entry.isDirectory() && /^Python3\d+/i.test(entry.name))
104
+ .map((entry) => entry.name)
105
+ .sort((left, right) => right.localeCompare(left, undefined, { numeric: true }));
106
+ paths.push(...directories.map((directory) => join(root, directory, "python.exe")));
107
+ }
108
+ catch {
109
+ // Optional installation root.
110
+ }
56
111
  }
57
- else {
58
- candidates.push({ command: "python3", args: [], source: "path" }, { command: "python", args: [], source: "path" });
112
+ if (env.LOCALAPPDATA) {
113
+ paths.push(join(env.LOCALAPPDATA, "Microsoft", "WindowsApps", "python.exe"));
59
114
  }
60
- return candidates;
115
+ paths.push(join(home, ".local", "bin", "python.exe"));
116
+ return paths;
61
117
  }
62
- async function findUvPython(cwd) {
63
- const result = await runCommand("uv", ["python", "find", "--no-project"], 5000, cwd, {
64
- UV_PYTHON_DOWNLOADS: "never",
65
- });
66
- if (result.status !== 0)
67
- return undefined;
68
- const first = result.stdout.trim().split(/\r?\n/)[0]?.trim();
69
- return first || undefined;
118
+ async function probeCandidate(executable, args, source, timeoutMs, env) {
119
+ const probe = await probePython(executable, args, timeoutMs, env);
120
+ if (!probe.ok) {
121
+ return { available: false, source: "unavailable", error: probe.error };
122
+ }
123
+ if (!supportedVersion(probe.value.versionInfo)) {
124
+ return {
125
+ available: false,
126
+ source: "unavailable",
127
+ error: `Python ${probe.value.version} is too old; Python ${MIN_VERSION[0]}.${MIN_VERSION[1]}+ is required.`,
128
+ };
129
+ }
130
+ return {
131
+ available: true,
132
+ command: executable.path,
133
+ args,
134
+ displayPath: probe.value.executable || executable.path,
135
+ version: probe.value.version,
136
+ source,
137
+ };
70
138
  }
71
- async function probePython(command, args, timeoutMs) {
139
+ async function probePython(executable, args, timeoutMs, env) {
72
140
  const script = [
73
141
  "import json, sys",
74
142
  "print(json.dumps({'executable': sys.executable, 'version': sys.version.split()[0], 'versionInfo': list(sys.version_info[:3])}))",
75
143
  ].join("; ");
76
- const result = await runCommand(command, [...args, "-c", script], timeoutMs);
77
- if (result.status !== 0) {
144
+ const result = await runExecutable(executable, [...args, "-c", script], {
145
+ timeoutMs,
146
+ env,
147
+ });
148
+ if (result.error || result.status !== 0) {
78
149
  return {
79
150
  ok: false,
80
151
  error: result.stderr.trim() ||
81
- `Python probe failed for ${command} with status ${String(result.status)}`,
152
+ result.error?.message ||
153
+ `Python probe failed for ${executable.path} with status ${String(result.status)}`,
82
154
  };
83
155
  }
84
156
  try {
@@ -90,7 +162,7 @@ async function probePython(command, args, timeoutMs) {
90
162
  typeof parsed.version !== "string" ||
91
163
  versionInfo.length < 3 ||
92
164
  versionInfo.some((part) => !Number.isInteger(part))) {
93
- return { ok: false, error: `Python probe returned invalid metadata.` };
165
+ return { ok: false, error: "Python probe returned invalid metadata." };
94
166
  }
95
167
  return {
96
168
  ok: true,
@@ -112,44 +184,12 @@ function supportedVersion([major, minor]) {
112
184
  return (major > MIN_VERSION[0] ||
113
185
  (major === MIN_VERSION[0] && minor >= MIN_VERSION[1]));
114
186
  }
115
- async function runCommand(command, args, timeoutMs, cwd, env) {
116
- return await new Promise((resolve) => {
117
- let stdout = "";
118
- let stderr = "";
119
- const child = spawn(command, args, {
120
- cwd,
121
- shell: false,
122
- stdio: ["ignore", "pipe", "pipe"],
123
- env: { ...process.env, ...(env ?? {}) },
124
- });
125
- const timeout = setTimeout(() => {
126
- child.kill("SIGTERM");
127
- }, timeoutMs);
128
- child.stdout?.setEncoding("utf8");
129
- child.stderr?.setEncoding("utf8");
130
- child.stdout?.on("data", (chunk) => {
131
- stdout += chunk;
132
- });
133
- child.stderr?.on("data", (chunk) => {
134
- stderr += chunk;
135
- });
136
- child.on("error", (error) => {
137
- clearTimeout(timeout);
138
- resolve({ stdout, stderr: error.message, status: null });
139
- });
140
- child.on("close", (status) => {
141
- clearTimeout(timeout);
142
- resolve({ stdout, stderr, status });
143
- });
144
- });
145
- }
146
- async function pathExists(path) {
147
- try {
148
- await access(path);
149
- return true;
150
- }
151
- catch {
152
- return false;
153
- }
187
+ function executableLocatorOptions(options) {
188
+ return {
189
+ platform: options.platform,
190
+ env: options.env,
191
+ homeDir: options.homeDir,
192
+ cwd: options.cwd,
193
+ };
154
194
  }
155
195
  //# sourceMappingURL=runtime.js.map