@apralabs/apra-fleet 0.4.4 → 0.4.5

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 (268) hide show
  1. package/README.md +49 -4
  2. package/dist/agents/backlog-groomer.md +5 -0
  3. package/dist/agents/ci-watcher.md +5 -0
  4. package/dist/agents/deployer.md +20 -2
  5. package/dist/agents/doer.md +38 -2
  6. package/dist/agents/harvester.md +12 -9
  7. package/dist/agents/integ-test-runner.md +5 -0
  8. package/dist/agents/kb-reconciler.md +6 -0
  9. package/dist/agents/plan-reviewer.md +5 -0
  10. package/dist/agents/planner.md +5 -0
  11. package/dist/agents/regression-test-runner.md +5 -0
  12. package/dist/agents/reviewer.md +67 -15
  13. package/dist/agents/schemas/deployer-output.json +5 -0
  14. package/dist/agents/schemas/doer-output.json +78 -2
  15. package/dist/agents/schemas/reviewer-output.json +104 -2
  16. package/dist/cli/auth.js +5 -1
  17. package/dist/cli/beads-pin.js +6 -7
  18. package/dist/cli/claude-mod.d.ts +75 -0
  19. package/dist/cli/claude-mod.js +288 -0
  20. package/dist/cli/dolt-install.d.ts +1 -1
  21. package/dist/cli/dolt-install.js +5 -1
  22. package/dist/cli/fleet-se-guard.d.ts +8 -0
  23. package/dist/cli/fleet-se-guard.js +19 -3
  24. package/dist/cli/install-guard.d.ts +9 -0
  25. package/dist/cli/install-guard.js +24 -0
  26. package/dist/cli/install.d.ts +12 -0
  27. package/dist/cli/install.js +180 -20
  28. package/dist/cli/kb-profile.d.ts +16 -0
  29. package/dist/cli/kb-profile.js +81 -0
  30. package/dist/cli/start.js +3 -0
  31. package/dist/cli/uninstall.js +13 -3
  32. package/dist/cli/update.d.ts +4 -0
  33. package/dist/cli/update.js +19 -3
  34. package/dist/commands/kb-server.d.ts +10 -1
  35. package/dist/commands/kb-server.js +285 -11
  36. package/dist/index.js +22 -1
  37. package/dist/os/git-executable.d.ts +57 -0
  38. package/dist/os/git-executable.js +85 -0
  39. package/dist/os/go-concurrency.d.ts +44 -0
  40. package/dist/os/go-concurrency.js +53 -0
  41. package/dist/os/index.d.ts +1 -0
  42. package/dist/os/index.js +1 -0
  43. package/dist/os/linux.d.ts +2 -0
  44. package/dist/os/linux.js +10 -1
  45. package/dist/os/os-commands.d.ts +25 -0
  46. package/dist/os/os-commands.js +2 -0
  47. package/dist/os/windows-executable.d.ts +53 -0
  48. package/dist/os/windows-executable.js +185 -0
  49. package/dist/os/windows-gitbash.d.ts +23 -14
  50. package/dist/os/windows-gitbash.js +40 -16
  51. package/dist/os/windows.d.ts +2 -0
  52. package/dist/os/windows.js +37 -6
  53. package/dist/paths.d.ts +10 -1
  54. package/dist/paths.js +19 -2
  55. package/dist/services/agy-project.d.ts +7 -1
  56. package/dist/services/agy-project.js +7 -2
  57. package/dist/services/auth-socket.d.ts +18 -0
  58. package/dist/services/auth-socket.js +30 -4
  59. package/dist/services/credential-store.d.ts +33 -0
  60. package/dist/services/credential-store.js +79 -2
  61. package/dist/services/http-transport.d.ts +29 -0
  62. package/dist/services/http-transport.js +166 -37
  63. package/dist/services/kb-tool-profile.d.ts +36 -0
  64. package/dist/services/kb-tool-profile.js +88 -0
  65. package/dist/services/knowledge/bible-blob-id.js +10 -1
  66. package/dist/services/knowledge/bible-import.d.ts +108 -0
  67. package/dist/services/knowledge/bible-import.js +137 -4
  68. package/dist/services/knowledge/file-hash.js +6 -5
  69. package/dist/services/knowledge/http-provider.d.ts +303 -20
  70. package/dist/services/knowledge/http-provider.js +795 -125
  71. package/dist/services/knowledge/kb-config.d.ts +65 -1
  72. package/dist/services/knowledge/kb-config.js +143 -3
  73. package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
  74. package/dist/services/knowledge/kb-http-auth-state.js +40 -0
  75. package/dist/services/knowledge/kb-providers.d.ts +9 -2
  76. package/dist/services/knowledge/kb-providers.js +67 -37
  77. package/dist/services/knowledge/kb-removed-scope-keys.js +1 -1
  78. package/dist/services/knowledge/kb-self.d.ts +122 -9
  79. package/dist/services/knowledge/kb-self.js +196 -36
  80. package/dist/services/knowledge/member-bible-view.js +16 -3
  81. package/dist/services/knowledge/path-validation.d.ts +7 -0
  82. package/dist/services/knowledge/path-validation.js +11 -0
  83. package/dist/services/knowledge/project-slug.js +3 -2
  84. package/dist/services/knowledge/repository-header.d.ts +77 -0
  85. package/dist/services/knowledge/repository-header.js +233 -0
  86. package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
  87. package/dist/services/knowledge/require-sqlite-project.js +1 -1
  88. package/dist/services/knowledge/sqlite-provider.d.ts +169 -0
  89. package/dist/services/knowledge/sqlite-provider.js +416 -4
  90. package/dist/services/knowledge/types.d.ts +15 -2
  91. package/dist/services/member-busy.d.ts +12 -0
  92. package/dist/services/member-busy.js +20 -0
  93. package/dist/services/member-config-io.d.ts +3 -2
  94. package/dist/services/member-config-io.js +7 -4
  95. package/dist/services/member-fleet-install.js +1 -0
  96. package/dist/services/member-tool-allowlist.d.ts +1 -1
  97. package/dist/services/member-tool-allowlist.js +8 -4
  98. package/dist/services/port-holder.js +2 -1
  99. package/dist/services/service-manager/types.d.ts +17 -1
  100. package/dist/services/service-manager/windows.d.ts +7 -2
  101. package/dist/services/service-manager/windows.js +28 -11
  102. package/dist/services/service-notice.d.ts +7 -0
  103. package/dist/services/service-notice.js +19 -0
  104. package/dist/services/session-registry.d.ts +13 -0
  105. package/dist/services/session-registry.js +13 -0
  106. package/dist/services/session-roots.d.ts +67 -0
  107. package/dist/services/session-roots.js +126 -0
  108. package/dist/services/statusline.d.ts +21 -0
  109. package/dist/services/statusline.js +97 -1
  110. package/dist/services/supervisor-service-cleanup.js +2 -1
  111. package/dist/services/tool-registry.js +108 -20
  112. package/dist/services/tool-scope.d.ts +34 -1
  113. package/dist/services/tool-scope.js +27 -2
  114. package/dist/services/vcs/azure-devops.js +10 -0
  115. package/dist/services/vcs/bitbucket.d.ts +22 -1
  116. package/dist/services/vcs/bitbucket.js +163 -17
  117. package/dist/services/vcs/types.d.ts +25 -2
  118. package/dist/services/watch/project-resolver.js +2 -1
  119. package/dist/skills/pm/cost.md +5 -1
  120. package/dist/skills/pm/index.md +9 -9
  121. package/dist/skills/pm/sprint.md +2 -1
  122. package/dist/tools/check-status.d.ts +51 -0
  123. package/dist/tools/check-status.js +124 -12
  124. package/dist/tools/code-intelligence-freshness.js +1 -1
  125. package/dist/tools/code-intelligence-gitnexus.d.ts +19 -0
  126. package/dist/tools/code-intelligence-gitnexus.js +166 -9
  127. package/dist/tools/code-intelligence-readiness.d.ts +58 -1
  128. package/dist/tools/code-intelligence-readiness.js +93 -8
  129. package/dist/tools/code-intelligence-reindex.d.ts +25 -1
  130. package/dist/tools/code-intelligence-reindex.js +76 -4
  131. package/dist/tools/code-intelligence.d.ts +1 -1
  132. package/dist/tools/code-intelligence.js +1 -1
  133. package/dist/tools/execute-command.js +14 -8
  134. package/dist/tools/execute-prompt.js +6 -2
  135. package/dist/tools/fleet-snapshot.d.ts +21 -0
  136. package/dist/tools/fleet-snapshot.js +78 -0
  137. package/dist/tools/kb-bible-commit.d.ts +25 -11
  138. package/dist/tools/kb-bible-commit.js +142 -33
  139. package/dist/tools/kb-capture.d.ts +2 -2
  140. package/dist/tools/kb-context.js +47 -27
  141. package/dist/tools/kb-demote.d.ts +27 -0
  142. package/dist/tools/kb-demote.js +37 -0
  143. package/dist/tools/kb-export.d.ts +35 -3
  144. package/dist/tools/kb-export.js +56 -13
  145. package/dist/tools/kb-feedback.d.ts +2 -0
  146. package/dist/tools/kb-feedback.js +17 -7
  147. package/dist/tools/kb-harvest.js +28 -9
  148. package/dist/tools/kb-import.d.ts +18 -2
  149. package/dist/tools/kb-import.js +24 -9
  150. package/dist/tools/kb-invalidate.d.ts +11 -3
  151. package/dist/tools/kb-invalidate.js +80 -7
  152. package/dist/tools/kb-list.js +38 -10
  153. package/dist/tools/kb-promote.js +6 -4
  154. package/dist/tools/kb-query.d.ts +3 -0
  155. package/dist/tools/kb-query.js +181 -37
  156. package/dist/tools/kb-session-prime.d.ts +4 -4
  157. package/dist/tools/kb-session-prime.js +89 -9
  158. package/dist/tools/kb-setup.d.ts +20 -0
  159. package/dist/tools/kb-setup.js +149 -11
  160. package/dist/tools/list-members.js +1 -1
  161. package/dist/tools/member-detail.js +7 -3
  162. package/dist/tools/provision-vcs-auth.d.ts +28 -3
  163. package/dist/tools/provision-vcs-auth.js +53 -7
  164. package/dist/tools/receive-files.js +7 -4
  165. package/dist/tools/send-files.js +5 -4
  166. package/dist/tools/send-message.d.ts +3 -0
  167. package/dist/tools/send-message.js +15 -2
  168. package/dist/tools/stop-prompt.js +3 -1
  169. package/dist/tools/vcs-credential-exec.d.ts +45 -3
  170. package/dist/tools/vcs-credential-exec.js +90 -11
  171. package/dist/utils/process-utils.js +5 -1
  172. package/dist/utils/redact-known-secrets.d.ts +17 -0
  173. package/dist/utils/redact-known-secrets.js +70 -0
  174. package/dist/utils/skill-matrix.js +1 -1
  175. package/dist/utils/vcs-provider-detect.js +2 -2
  176. package/dist/workflows/auto-sprint.js +245 -9
  177. package/package.json +10 -7
  178. package/packages/apra-fleet-client/package.json +1 -1
  179. package/packages/apra-fleet-client/src/client/api.mjs +172 -19
  180. package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +35 -2
  181. package/packages/apra-fleet-client/src/client/transport.mjs +6 -0
  182. package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +5 -0
  183. package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +5 -0
  184. package/packages/apra-fleet-se/apra-pm/agents/deployer.md +20 -2
  185. package/packages/apra-fleet-se/apra-pm/agents/doer.md +38 -2
  186. package/packages/apra-fleet-se/apra-pm/agents/harvester.md +12 -9
  187. package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +5 -0
  188. package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +6 -0
  189. package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +5 -0
  190. package/packages/apra-fleet-se/apra-pm/agents/planner.md +5 -0
  191. package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +5 -0
  192. package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +67 -15
  193. package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
  194. package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +78 -2
  195. package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +104 -2
  196. package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
  197. package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +9 -9
  198. package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +2 -1
  199. package/packages/apra-fleet-se/bin/cli.mjs +104 -31
  200. package/packages/apra-fleet-se/bin/serve.mjs +46 -8
  201. package/packages/apra-fleet-se/fleet-sprint/abort.mjs +184 -32
  202. package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
  203. package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +21 -0
  204. package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
  205. package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
  206. package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +158 -1
  207. package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +82 -2
  208. package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +23 -6
  209. package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
  210. package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
  211. package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
  212. package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +44 -11
  213. package/packages/apra-fleet-se/fleet-sprint/docs/README.md +4 -1
  214. package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
  215. package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +314 -19
  216. package/packages/apra-fleet-se/fleet-sprint/errors.mjs +72 -4
  217. package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +7 -1
  218. package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +112 -1
  219. package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +36 -2
  220. package/packages/apra-fleet-se/fleet-sprint/kb.mjs +736 -101
  221. package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +1 -1
  222. package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +7 -1
  223. package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +49 -2
  224. package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +206 -3
  225. package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +61 -3
  226. package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +81 -31
  227. package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +7 -3
  228. package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +39 -14
  229. package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +17 -1
  230. package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +18 -3
  231. package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +14 -1
  232. package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +32 -5
  233. package/packages/apra-fleet-se/fleet-sprint/runner.js +824 -98
  234. package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +4 -2
  235. package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +54 -1
  236. package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +29 -2
  237. package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
  238. package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +3 -2
  239. package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +20 -0
  240. package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +21 -0
  241. package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +9 -0
  242. package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +605 -32
  243. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
  244. package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +89 -1
  245. package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +225 -2
  246. package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
  247. package/packages/apra-fleet-se/src/supervisor/api.mjs +148 -8
  248. package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +6 -3
  249. package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +30 -10
  250. package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +17 -4
  251. package/packages/apra-fleet-se/src/supervisor/history.mjs +8 -1
  252. package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +92 -2
  253. package/packages/apra-fleet-se/src/supervisor/proxy.mjs +26 -1
  254. package/packages/apra-fleet-se/src/supervisor/server.mjs +151 -8
  255. package/packages/apra-fleet-se/src/supervisor/spawner.mjs +11 -9
  256. package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +7 -1
  257. package/packages/apra-fleet-workflow/package.json +2 -1
  258. package/packages/apra-fleet-workflow/src/viewer/index.mjs +86 -5
  259. package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
  260. package/packages/apra-fleet-workflow/src/workflow/index.mjs +34 -2
  261. package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
  262. package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
  263. package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
  264. package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
  265. package/skills/fleet/auth-bitbucket.md +47 -20
  266. package/skills/fleet/onboarding.md +1 -1
  267. package/skills/fleet/skill-matrix.md +3 -3
  268. package/version.json +1 -1
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The git executable every fleet-server git spawn uses.
3
+ *
4
+ * On Windows, CreateProcess (and libuv's own search, which Node's child_process
5
+ * uses) looks in the CURRENT DIRECTORY before PATH when a bare program name is
6
+ * given. Every KB / code-intelligence git call runs with a work folder as its
7
+ * cwd, so `execFileSync('git', ..., { cwd: workFolder })` would run a git.exe
8
+ * planted at the root of that work folder instead of the real git
9
+ * (apra-fleet-rx6b).
10
+ *
11
+ * gitExecutable() therefore resolves git ONCE, on win32, to an absolute path
12
+ * taken ONLY from PATH entries -- never the process cwd or any spawn cwd:
13
+ * - empty and relative PATH entries are skipped (a relative entry, like an
14
+ * empty one, would be resolved against the cwd);
15
+ * - surrounding double quotes on an entry are stripped;
16
+ * - PATHEXT order is honoured, restricted to the extensions a shell-less
17
+ * spawn can run directly (.EXE / .COM). A git.cmd / git.bat shim cannot be
18
+ * spawned without a shell (Node refuses it with EINVAL), so it is never
19
+ * returned; Git for Windows puts cmd\git.exe on PATH.
20
+ * The PATH-only search itself lives in windows-executable.ts (shared with the
21
+ * Windows shells the fleet server starts). The result is cached for the
22
+ * process. A missing git throws GitNotFoundError, one clear error naming PATH, instead of a confusing failure in whichever
23
+ * caller ran first. A failed lookup is not cached, so installing git later
24
+ * starts working without a restart.
25
+ *
26
+ * On every other platform the bare name 'git' is returned unchanged: execvp
27
+ * never searches the cwd unless PATH itself says so.
28
+ *
29
+ * Out of scope: packages/apra-fleet-client git spawns (separate package).
30
+ * Member-bound command STRINGS (src/os/*.ts builders, member-config-io, vcs
31
+ * providers) run on the member through its own shell and are not spawns by
32
+ * the fleet server's own process.
33
+ */
34
+ import { defaultIsFile, envValue, searchWindowsPath, } from './windows-executable.js';
35
+ export const GIT_NOT_FOUND_CODE = 'E-GIT-NOT-FOUND';
36
+ export class GitNotFoundError extends Error {
37
+ searched;
38
+ code = GIT_NOT_FOUND_CODE;
39
+ constructor(searched) {
40
+ super(`${GIT_NOT_FOUND_CODE}: git was not found on PATH (searched ${searched.length} absolute PATH ` +
41
+ `entr${searched.length === 1 ? 'y' : 'ies'}; the current directory is never searched). ` +
42
+ 'Install Git for Windows and make sure its cmd folder (e.g. C:\\Program Files\\Git\\cmd) is on PATH ' +
43
+ 'for the fleet server process, then retry.');
44
+ this.searched = searched;
45
+ this.name = 'GitNotFoundError';
46
+ }
47
+ }
48
+ export function defaultGitResolveDeps() {
49
+ return {
50
+ platform: process.platform,
51
+ pathValue: envValue(process.env, 'PATH'),
52
+ pathext: envValue(process.env, 'PATHEXT'),
53
+ isFile: defaultIsFile,
54
+ };
55
+ }
56
+ /**
57
+ * Pure resolution (no cache). Returns 'git' on non-Windows platforms; on win32
58
+ * returns an absolute path from a PATH entry or throws GitNotFoundError.
59
+ */
60
+ export function resolveGitExecutable(deps) {
61
+ if (deps.platform !== 'win32')
62
+ return 'git';
63
+ const { found, searched } = searchWindowsPath('git', deps);
64
+ if (found !== undefined)
65
+ return found;
66
+ throw new GitNotFoundError(searched);
67
+ }
68
+ let cached;
69
+ /**
70
+ * The git executable for a fleet-server spawn: cached absolute PATH-only
71
+ * resolution on win32, bare 'git' elsewhere. Throws GitNotFoundError on win32
72
+ * when git is not on PATH.
73
+ */
74
+ export function gitExecutable() {
75
+ if (cached !== undefined)
76
+ return cached;
77
+ const resolved = resolveGitExecutable(defaultGitResolveDeps());
78
+ cached = resolved;
79
+ return resolved;
80
+ }
81
+ /** Test hook: forget the cached resolution. */
82
+ export function resetGitExecutableCache() {
83
+ cached = undefined;
84
+ }
85
+ //# sourceMappingURL=git-executable.js.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Go concurrency default for bd / dolt started on WINDOWS members.
3
+ *
4
+ * Why: on Windows, `bd dolt pull/push` (dolt is a Go program) starts one git
5
+ * process per remote chunk at once; enough concurrent CreateProcess calls fail
6
+ * with ERROR_NOT_ENOUGH_MEMORY ("Not enough memory resources are available to
7
+ * process this command") although plenty of RAM is free. Capping the Go
8
+ * runtime to one OS thread (GOMAXPROCS=1) serialises those spawns and was the
9
+ * evidenced mitigation (upstream: https://github.com/gastownhall/beads/issues/7082;
10
+ * precedent: scripts/rekey-beads-memories.mjs). See docs/troubleshooting.md
11
+ * ("Not enough memory resources").
12
+ * Side effect: the default covers the whole fleet-started Windows session, so
13
+ * Go builds and tests run there are serialized too; override via the member's
14
+ * own GOMAXPROCS (see that docs section).
15
+ *
16
+ * THE RULE (one place): a Windows child env / Windows member shell gets
17
+ * GOMAXPROCS=GO_MAXPROCS_WINDOWS_DEFAULT ONLY when GOMAXPROCS is not already
18
+ * set (unset or empty). An operator value is never overridden. POSIX members
19
+ * are untouched.
20
+ *
21
+ * Where it applies:
22
+ * - LOCAL Windows members: the child env object (withGoMaxProcsDefault),
23
+ * used by WindowsCommands.getCleanEnv and WindowsGitBashCommands.cleanExec.
24
+ * - REMOTE Windows members: the agent launch and execute_command wrapper
25
+ * strings, where the member's env is only known to the member's own shell.
26
+ * The snippet is chosen in JS per member shell (PowerShell vs Git Bash),
27
+ * never a POSIX string sent to PowerShell; it references only the
28
+ * member's own GOMAXPROCS variable in that shell's own dialect.
29
+ *
30
+ * ASCII only.
31
+ */
32
+ export declare const GO_MAXPROCS_VAR = "GOMAXPROCS";
33
+ export declare const GO_MAXPROCS_WINDOWS_DEFAULT = "1";
34
+ /**
35
+ * Pure: a copy of `env` with GOMAXPROCS defaulted when absent or empty.
36
+ * The lookup is case-insensitive (Windows env names are), so an existing
37
+ * `GoMaxProcs` is honoured rather than duplicated. The input is not mutated.
38
+ */
39
+ export declare function withGoMaxProcsDefault(env: Record<string, string>): Record<string, string>;
40
+ /** PowerShell statement (with trailing separator) applying the rule in the member's session. */
41
+ export declare const GO_MAXPROCS_DEFAULT_PWSH = "if (-not $env:GOMAXPROCS) { $env:GOMAXPROCS = '1' }; ";
42
+ /** Git Bash (POSIX sh) statement (with trailing separator) applying the rule in the member's shell. */
43
+ export declare const GO_MAXPROCS_DEFAULT_GITBASH = "[ -n \"${GOMAXPROCS:-}\" ] || export GOMAXPROCS=1; ";
44
+ //# sourceMappingURL=go-concurrency.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Go concurrency default for bd / dolt started on WINDOWS members.
3
+ *
4
+ * Why: on Windows, `bd dolt pull/push` (dolt is a Go program) starts one git
5
+ * process per remote chunk at once; enough concurrent CreateProcess calls fail
6
+ * with ERROR_NOT_ENOUGH_MEMORY ("Not enough memory resources are available to
7
+ * process this command") although plenty of RAM is free. Capping the Go
8
+ * runtime to one OS thread (GOMAXPROCS=1) serialises those spawns and was the
9
+ * evidenced mitigation (upstream: https://github.com/gastownhall/beads/issues/7082;
10
+ * precedent: scripts/rekey-beads-memories.mjs). See docs/troubleshooting.md
11
+ * ("Not enough memory resources").
12
+ * Side effect: the default covers the whole fleet-started Windows session, so
13
+ * Go builds and tests run there are serialized too; override via the member's
14
+ * own GOMAXPROCS (see that docs section).
15
+ *
16
+ * THE RULE (one place): a Windows child env / Windows member shell gets
17
+ * GOMAXPROCS=GO_MAXPROCS_WINDOWS_DEFAULT ONLY when GOMAXPROCS is not already
18
+ * set (unset or empty). An operator value is never overridden. POSIX members
19
+ * are untouched.
20
+ *
21
+ * Where it applies:
22
+ * - LOCAL Windows members: the child env object (withGoMaxProcsDefault),
23
+ * used by WindowsCommands.getCleanEnv and WindowsGitBashCommands.cleanExec.
24
+ * - REMOTE Windows members: the agent launch and execute_command wrapper
25
+ * strings, where the member's env is only known to the member's own shell.
26
+ * The snippet is chosen in JS per member shell (PowerShell vs Git Bash),
27
+ * never a POSIX string sent to PowerShell; it references only the
28
+ * member's own GOMAXPROCS variable in that shell's own dialect.
29
+ *
30
+ * ASCII only.
31
+ */
32
+ export const GO_MAXPROCS_VAR = 'GOMAXPROCS';
33
+ export const GO_MAXPROCS_WINDOWS_DEFAULT = '1';
34
+ /**
35
+ * Pure: a copy of `env` with GOMAXPROCS defaulted when absent or empty.
36
+ * The lookup is case-insensitive (Windows env names are), so an existing
37
+ * `GoMaxProcs` is honoured rather than duplicated. The input is not mutated.
38
+ */
39
+ export function withGoMaxProcsDefault(env) {
40
+ const key = Object.keys(env).find((k) => k.toUpperCase() === GO_MAXPROCS_VAR);
41
+ if (key !== undefined && env[key] !== '')
42
+ return { ...env };
43
+ const out = { ...env };
44
+ if (key !== undefined)
45
+ delete out[key];
46
+ out[GO_MAXPROCS_VAR] = GO_MAXPROCS_WINDOWS_DEFAULT;
47
+ return out;
48
+ }
49
+ /** PowerShell statement (with trailing separator) applying the rule in the member's session. */
50
+ export const GO_MAXPROCS_DEFAULT_PWSH = `if (-not $env:${GO_MAXPROCS_VAR}) { $env:${GO_MAXPROCS_VAR} = '${GO_MAXPROCS_WINDOWS_DEFAULT}' }; `;
51
+ /** Git Bash (POSIX sh) statement (with trailing separator) applying the rule in the member's shell. */
52
+ export const GO_MAXPROCS_DEFAULT_GITBASH = `[ -n "\${${GO_MAXPROCS_VAR}:-}" ] || export ${GO_MAXPROCS_VAR}=${GO_MAXPROCS_WINDOWS_DEFAULT}; `;
53
+ //# sourceMappingURL=go-concurrency.js.map
@@ -1,6 +1,7 @@
1
1
  import type { OsCommands, MemberShell } from './os-commands.js';
2
2
  import type { RemoteOS } from '../utils/platform.js';
3
3
  export type { OsCommands, MemberShell } from './os-commands.js';
4
+ export { GIT_LS_REMOTE_OK_MARKER } from './os-commands.js';
4
5
  export { LinuxCommands } from './linux.js';
5
6
  export { MacOSCommands } from './macos.js';
6
7
  export { WindowsCommands } from './windows.js';
package/dist/os/index.js CHANGED
@@ -2,6 +2,7 @@ import { LinuxCommands } from './linux.js';
2
2
  import { MacOSCommands } from './macos.js';
3
3
  import { WindowsCommands } from './windows.js';
4
4
  import { WindowsGitBashCommands } from './windows-gitbash.js';
5
+ export { GIT_LS_REMOTE_OK_MARKER } from './os-commands.js';
5
6
  export { LinuxCommands } from './linux.js';
6
7
  export { MacOSCommands } from './macos.js';
7
8
  export { WindowsCommands } from './windows.js';
@@ -66,6 +66,8 @@ export declare class LinuxCommands implements OsCommands {
66
66
  wrapPidCapture(command: string): string;
67
67
  gitCurrentBranch(folder: string): string;
68
68
  gitRemoteOrigin(folder: string): string;
69
+ gitLsRemoteNonInteractive(url: string): string;
70
+ httpGetStatusWithBearer(url: string, token: string): string;
69
71
  killPid(pid: number): string;
70
72
  gpuProcessCheck(): string;
71
73
  gpuUtilization(): string;
package/dist/os/linux.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { execSync } from 'node:child_process';
2
- import { escapeDoubleQuoted, escapeGrepPattern, sanitizeSessionId } from './os-commands.js';
2
+ import { escapeDoubleQuoted, escapeGrepPattern, sanitizeSessionId, GIT_LS_REMOTE_OK_MARKER } from './os-commands.js';
3
3
  import { escapeShellArg } from '../utils/shell-escape.js';
4
4
  // The member's own fleet bin dir (<home>/.apra-fleet/bin: the member-install
5
5
  // apra-fleet, dolt, and bd when the installer could not place it on the system
@@ -330,6 +330,15 @@ export class LinuxCommands {
330
330
  const f = escapeDoubleQuoted(folder);
331
331
  return `git -C "${f}" remote get-url origin 2>/dev/null || git -C "${f}" config --get remote.origin.url 2>/dev/null || true`;
332
332
  }
333
+ gitLsRemoteNonInteractive(url) {
334
+ return `GIT_TERMINAL_PROMPT=0 GCM_INTERACTIVE=never git ls-remote ${escapeShellArg(url)} HEAD && echo ${GIT_LS_REMOTE_OK_MARKER}`;
335
+ }
336
+ httpGetStatusWithBearer(url, token) {
337
+ // printf is a shell builtin (sh/dash/bash/zsh), so the token is not on
338
+ // curl's argv; curl reads the header from stdin (-H @-). It is still on
339
+ // the outer `bash -c` argv that runs this string (see os-commands.ts).
340
+ return `printf 'Authorization: Bearer %s\\n' ${escapeShellArg(token)} | curl -sS -o /dev/null -w '%{http_code}' -H @- ${escapeShellArg(url)}`;
341
+ }
333
342
  // --- Process management ---
334
343
  // apra-fleet-eft.13.3: `kill -9 <pid>` alone only signals that single
335
344
  // process. A backgrounded child of an abandoned CLI invocation (e.g. a
@@ -3,6 +3,8 @@ import type { ProviderAdapter, PromptOptions as BasePromptOptions } from '../pro
3
3
  import type { Agent } from '../types.js';
4
4
  export { escapeDoubleQuoted, escapeWindowsArg, escapeGrepPattern, sanitizeSessionId };
5
5
  export type { ProviderAdapter };
6
+ /** The line gitLsRemoteNonInteractive() prints after a successful ls-remote. */
7
+ export declare const GIT_LS_REMOTE_OK_MARKER = "FLEET_GIT_LS_REMOTE_OK";
6
8
  /**
7
9
  * apra-fleet-lmtg.2: fork descriptor threaded through buildAgentPromptCommand
8
10
  * so both POSIX and Windows builders can emit a provider's fork invocation
@@ -135,6 +137,29 @@ export interface OsCommands {
135
137
  * git builds that predate `remote get-url`.
136
138
  */
137
139
  gitRemoteOrigin(folder: string): string;
140
+ /**
141
+ * `git ls-remote <url> HEAD` that can never block on a prompt: terminal
142
+ * prompts and Git Credential Manager's interactive UI are both disabled
143
+ * for this one command (GIT_TERMINAL_PROMPT=0, GCM_INTERACTIVE=never), so
144
+ * a missing or rejected credential fails fast instead of hanging. On
145
+ * success the output ends with the line GIT_LS_REMOTE_OK_MARKER; a caller
146
+ * must treat its absence (or a throw) as a failure. `url` must already be
147
+ * validated by the caller -- it is quoted, not trusted.
148
+ */
149
+ gitLsRemoteNonInteractive(url: string): string;
150
+ /**
151
+ * Authenticated HTTPS GET of `url` with `Authorization: Bearer <token>`.
152
+ * Prints ONLY the numeric HTTP status code (e.g. 200, 401) -- never the
153
+ * response body and never the token. On POSIX the header is fed to curl on
154
+ * stdin from the shell's builtin printf, so the token is not on curl's
155
+ * argv; on PowerShell the request runs in-process (no child argv). The
156
+ * command string itself carries the token, so it IS on the argv of the
157
+ * outer `bash -c` / powershell process that runs it, for the length of the
158
+ * request -- the same exposure as gitCredentialHelperWrite. A transport
159
+ * failure prints a non-numeric line or exits non-zero. Only ever run
160
+ * server-side via strategy.execCommand.
161
+ */
162
+ httpGetStatusWithBearer(url: string, token: string): string;
138
163
  gpuProcessCheck(): string;
139
164
  gpuUtilization(): string;
140
165
  parseMemory(stdout: string): string;
@@ -1,3 +1,5 @@
1
1
  import { escapeDoubleQuoted, escapeWindowsArg, escapeGrepPattern, sanitizeSessionId } from '../utils/shell-escape.js';
2
2
  export { escapeDoubleQuoted, escapeWindowsArg, escapeGrepPattern, sanitizeSessionId };
3
+ /** The line gitLsRemoteNonInteractive() prints after a successful ls-remote. */
4
+ export const GIT_LS_REMOTE_OK_MARKER = 'FLEET_GIT_LS_REMOTE_OK';
3
5
  //# sourceMappingURL=os-commands.js.map
@@ -0,0 +1,53 @@
1
+ export declare const WINDOWS_EXECUTABLE_NOT_FOUND_CODE = "E-WINDOWS-EXECUTABLE-NOT-FOUND";
2
+ export interface WindowsExecutableDeps {
3
+ platform: NodeJS.Platform;
4
+ /** The PATH value (on Windows the env key may be spelled Path). */
5
+ pathValue: string | undefined;
6
+ pathext: string | undefined;
7
+ /** True when p is an existing regular file. */
8
+ isFile: (p: string) => boolean;
9
+ /** %SystemRoot% (falls back to %windir% in the defaults). */
10
+ systemRoot?: string;
11
+ /** %ComSpec%. */
12
+ comSpec?: string;
13
+ }
14
+ export declare class WindowsExecutableNotFoundError extends Error {
15
+ readonly program: string;
16
+ readonly preferredTried: readonly string[];
17
+ readonly searched: readonly string[];
18
+ readonly code = "E-WINDOWS-EXECUTABLE-NOT-FOUND";
19
+ constructor(program: string, preferredTried: readonly string[], searched: readonly string[]);
20
+ }
21
+ /** Look up an env var case-insensitively (Windows env keys are case-insensitive). */
22
+ export declare function envValue(env: NodeJS.ProcessEnv, name: string): string | undefined;
23
+ export declare function defaultIsFile(p: string): boolean;
24
+ /** Resolution deps read from an env (default: the fleet server's own process.env). */
25
+ export declare function windowsExecutableDepsFromEnv(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, isFile?: (p: string) => boolean): WindowsExecutableDeps;
26
+ /** An absolute Windows path: drive-letter rooted (C:\...) or UNC (\\server\share). */
27
+ export declare function isAbsoluteWindowsPath(p: string): boolean;
28
+ /**
29
+ * PATH-only search (no preferred locations, no cache, no throw). Returns the
30
+ * first absolute match and the absolute PATH directories that were searched.
31
+ */
32
+ export declare function searchWindowsPath(name: string, deps: Pick<WindowsExecutableDeps, 'pathValue' | 'pathext' | 'isFile'>): {
33
+ found: string | undefined;
34
+ searched: string[];
35
+ };
36
+ /** Preferred absolute locations for a program, checked before PATH. */
37
+ export declare function preferredWindowsLocations(name: string, deps: WindowsExecutableDeps): string[];
38
+ /**
39
+ * Pure resolution (no cache). Returns the name unchanged on non-Windows
40
+ * platforms; on win32 returns an absolute path (preferred location, then PATH)
41
+ * or throws WindowsExecutableNotFoundError.
42
+ */
43
+ export declare function resolveWindowsExecutable(name: string, deps: WindowsExecutableDeps): string;
44
+ /**
45
+ * The executable for a fleet-server spawn of `name` (e.g. 'powershell.exe',
46
+ * 'cmd.exe'): cached absolute resolution on win32, the name unchanged
47
+ * elsewhere. Throws WindowsExecutableNotFoundError on win32 when not found.
48
+ * `deps` is a test seam; production callers pass nothing.
49
+ */
50
+ export declare function windowsExecutable(name: string, deps?: WindowsExecutableDeps): string;
51
+ /** Test hook: forget every cached resolution. */
52
+ export declare function resetWindowsExecutableCache(): void;
53
+ //# sourceMappingURL=windows-executable.d.ts.map
@@ -0,0 +1,185 @@
1
+ /**
2
+ * PATH-only resolution of a Windows executable to an ABSOLUTE path, shared by
3
+ * every fleet-server spawn that would otherwise pass a bare program name.
4
+ *
5
+ * On Windows, CreateProcess (and libuv's own search, which Node's
6
+ * child_process uses) looks in the CURRENT DIRECTORY before PATH when a bare
7
+ * program name is given -- unless NoDefaultCurrentDirectoryInExePath is set in
8
+ * the fleet server's own environment. LocalStrategy spawns a local member's
9
+ * shell with cwd = the member work folder, so a bare 'powershell.exe' or
10
+ * 'bash.exe' would run a same-named exe committed to a cloned repo, as the
11
+ * fleet-server user. git-executable.ts closed that hole for git; this module
12
+ * is the generalized resolver it now delegates to, and the shells use it too.
13
+ *
14
+ * The search, on win32:
15
+ * - a preferred absolute location first, when the program has one:
16
+ * powershell -> %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe,
17
+ * cmd -> an absolute %ComSpec% naming cmd.exe, then %SystemRoot%\System32\cmd.exe.
18
+ * A SystemRoot / ComSpec that is not an absolute drive or UNC path is
19
+ * ignored (a relative one would be resolved against the cwd);
20
+ * - then ONLY absolute PATH entries: empty and relative entries are skipped,
21
+ * surrounding double quotes are stripped;
22
+ * - PATHEXT order is honoured, restricted to the extensions a shell-less
23
+ * spawn can run directly (.EXE / .COM);
24
+ * - the process cwd and any spawn cwd are never searched.
25
+ * windowsExecutable() caches a success per program for the process; a failed
26
+ * lookup throws WindowsExecutableNotFoundError (one error code, naming every
27
+ * location searched) and is not cached, so installing the program later starts
28
+ * working without a restart.
29
+ *
30
+ * On every other platform the name is returned unchanged: execvp never
31
+ * searches the cwd unless PATH itself says so.
32
+ *
33
+ * Absolute shell paths keep Node's quoting: normalizeSpawnArguments picks the
34
+ * cmd.exe form (/d /s /c, verbatim args) by matching the shell against
35
+ * /^(?:.*\\)?cmd(?:\.exe)?$/i, which a backslash-joined absolute cmd.exe path
36
+ * still matches; every other shell gets ['-c', command] by name or by path.
37
+ *
38
+ * Out of scope: member-bound command STRINGS (src/os/*.ts builders sent over
39
+ * SSH) -- they run in the member's own shell, not as fleet-server spawns.
40
+ */
41
+ import fs from 'node:fs';
42
+ import path from 'node:path';
43
+ export const WINDOWS_EXECUTABLE_NOT_FOUND_CODE = 'E-WINDOWS-EXECUTABLE-NOT-FOUND';
44
+ /** Extensions a shell-less CreateProcess spawn can execute directly. */
45
+ const SPAWNABLE_EXTS = new Set(['.EXE', '.COM']);
46
+ const DEFAULT_PATHEXT = '.COM;.EXE;.BAT;.CMD';
47
+ export class WindowsExecutableNotFoundError extends Error {
48
+ program;
49
+ preferredTried;
50
+ searched;
51
+ code = WINDOWS_EXECUTABLE_NOT_FOUND_CODE;
52
+ constructor(program, preferredTried, searched) {
53
+ super(`${WINDOWS_EXECUTABLE_NOT_FOUND_CODE}: ${program} was not found. ` +
54
+ (preferredTried.length > 0 ? `Tried ${preferredTried.join(', ')}; then searched ` : 'Searched ') +
55
+ `${searched.length} absolute PATH entr${searched.length === 1 ? 'y' : 'ies'}` +
56
+ (searched.length > 0 ? ` (${searched.join(', ')})` : '') +
57
+ '; the current directory is never searched. Make sure SystemRoot and PATH are set for the fleet server process, then retry.');
58
+ this.program = program;
59
+ this.preferredTried = preferredTried;
60
+ this.searched = searched;
61
+ this.name = 'WindowsExecutableNotFoundError';
62
+ }
63
+ }
64
+ /** Look up an env var case-insensitively (Windows env keys are case-insensitive). */
65
+ export function envValue(env, name) {
66
+ if (env[name] !== undefined)
67
+ return env[name];
68
+ const upper = name.toUpperCase();
69
+ const key = Object.keys(env).find((k) => k.toUpperCase() === upper);
70
+ return key === undefined ? undefined : env[key];
71
+ }
72
+ export function defaultIsFile(p) {
73
+ try {
74
+ return fs.statSync(p).isFile();
75
+ }
76
+ catch {
77
+ return false;
78
+ }
79
+ }
80
+ /** Resolution deps read from an env (default: the fleet server's own process.env). */
81
+ export function windowsExecutableDepsFromEnv(env = process.env, platform = process.platform, isFile = defaultIsFile) {
82
+ return {
83
+ platform,
84
+ pathValue: envValue(env, 'PATH'),
85
+ pathext: envValue(env, 'PATHEXT'),
86
+ isFile,
87
+ systemRoot: envValue(env, 'SystemRoot') ?? envValue(env, 'windir'),
88
+ comSpec: envValue(env, 'ComSpec'),
89
+ };
90
+ }
91
+ /** An absolute Windows path: drive-letter rooted (C:\...) or UNC (\\server\share). */
92
+ export function isAbsoluteWindowsPath(p) {
93
+ return /^[A-Za-z]:[\\/]/.test(p) || /^[\\/]{2}[^\\/]/.test(p);
94
+ }
95
+ function unquote(raw) {
96
+ return raw.trim().replace(/^"(.*)"$/, '$1').trim();
97
+ }
98
+ /** 'powershell.exe' / 'POWERSHELL' -> 'powershell' (never appends .exe twice). */
99
+ function baseProgramName(name) {
100
+ return name.replace(/\.(exe|com)$/i, '');
101
+ }
102
+ /**
103
+ * PATH-only search (no preferred locations, no cache, no throw). Returns the
104
+ * first absolute match and the absolute PATH directories that were searched.
105
+ */
106
+ export function searchWindowsPath(name, deps) {
107
+ const base = baseProgramName(name);
108
+ const exts = (deps.pathext && deps.pathext.trim() ? deps.pathext : DEFAULT_PATHEXT)
109
+ .split(';')
110
+ .map((e) => e.trim().toUpperCase())
111
+ .filter((e) => SPAWNABLE_EXTS.has(e));
112
+ const extOrder = exts.length > 0 ? [...new Set(exts)] : ['.EXE'];
113
+ const searched = [];
114
+ for (const raw of (deps.pathValue ?? '').split(';')) {
115
+ const dir = unquote(raw);
116
+ if (!dir || !isAbsoluteWindowsPath(dir))
117
+ continue;
118
+ searched.push(dir);
119
+ for (const ext of extOrder) {
120
+ const candidate = path.win32.join(dir, base + ext.toLowerCase());
121
+ if (deps.isFile(candidate))
122
+ return { found: candidate, searched };
123
+ }
124
+ }
125
+ return { found: undefined, searched };
126
+ }
127
+ /** Preferred absolute locations for a program, checked before PATH. */
128
+ export function preferredWindowsLocations(name, deps) {
129
+ const base = baseProgramName(name).toLowerCase();
130
+ const root = deps.systemRoot ? unquote(deps.systemRoot) : '';
131
+ const rootOk = root !== '' && isAbsoluteWindowsPath(root);
132
+ if (base === 'powershell') {
133
+ return rootOk ? [path.win32.join(root, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')] : [];
134
+ }
135
+ if (base === 'cmd') {
136
+ const out = [];
137
+ const comSpec = deps.comSpec ? unquote(deps.comSpec) : '';
138
+ if (comSpec && isAbsoluteWindowsPath(comSpec) && /^cmd\.exe$/i.test(path.win32.basename(comSpec))) {
139
+ out.push(path.win32.normalize(comSpec));
140
+ }
141
+ if (rootOk)
142
+ out.push(path.win32.join(root, 'System32', 'cmd.exe'));
143
+ return out;
144
+ }
145
+ return [];
146
+ }
147
+ /**
148
+ * Pure resolution (no cache). Returns the name unchanged on non-Windows
149
+ * platforms; on win32 returns an absolute path (preferred location, then PATH)
150
+ * or throws WindowsExecutableNotFoundError.
151
+ */
152
+ export function resolveWindowsExecutable(name, deps) {
153
+ if (deps.platform !== 'win32')
154
+ return name;
155
+ const preferred = preferredWindowsLocations(name, deps);
156
+ for (const candidate of preferred) {
157
+ if (deps.isFile(candidate))
158
+ return candidate;
159
+ }
160
+ const { found, searched } = searchWindowsPath(name, deps);
161
+ if (found !== undefined)
162
+ return found;
163
+ throw new WindowsExecutableNotFoundError(name, preferred, searched);
164
+ }
165
+ const cache = new Map();
166
+ /**
167
+ * The executable for a fleet-server spawn of `name` (e.g. 'powershell.exe',
168
+ * 'cmd.exe'): cached absolute resolution on win32, the name unchanged
169
+ * elsewhere. Throws WindowsExecutableNotFoundError on win32 when not found.
170
+ * `deps` is a test seam; production callers pass nothing.
171
+ */
172
+ export function windowsExecutable(name, deps) {
173
+ const key = baseProgramName(name).toLowerCase();
174
+ const hit = cache.get(key);
175
+ if (hit !== undefined)
176
+ return hit;
177
+ const resolved = resolveWindowsExecutable(name, deps ?? windowsExecutableDepsFromEnv());
178
+ cache.set(key, resolved);
179
+ return resolved;
180
+ }
181
+ /** Test hook: forget every cached resolution. */
182
+ export function resetWindowsExecutableCache() {
183
+ cache.clear();
184
+ }
185
+ //# sourceMappingURL=windows-executable.js.map
@@ -1,5 +1,5 @@
1
1
  import { LinuxCommands } from './linux.js';
2
- import type { ProviderAdapter } from './os-commands.js';
2
+ import type { ProviderAdapter, PromptOptions } from './os-commands.js';
3
3
  /**
4
4
  * Dependencies resolveGitBashPath needs, injectable so its logic is testable
5
5
  * on any platform without a real Git-for-Windows install or a real WSL
@@ -7,16 +7,21 @@ import type { ProviderAdapter } from './os-commands.js';
7
7
  * child_process when omitted -- production callers pass nothing.
8
8
  */
9
9
  export interface ResolveGitBashPathDeps {
10
- /** Defaults to process.env. */
10
+ /** Defaults to process.env. Its PATH / PATHEXT drive the PATH fallback. */
11
11
  env?: NodeJS.ProcessEnv;
12
- /** Defaults to fs.existsSync. */
12
+ /** Defaults to fs.existsSync. Checks the well-known candidates only. */
13
13
  exists?: (candidatePath: string) => boolean;
14
14
  /**
15
- * Runs `uname -s` through the PATH-resolved bash.exe (if any) and returns
16
- * its stdout, or undefined if no bash.exe is on PATH / it could not be
17
- * run. Defaults to a real execFileSync('bash.exe', ['-lc', 'uname -s']).
15
+ * True when p is an existing regular file; used by the PATH-only search of
16
+ * the fallback. Defaults to an fs.statSync check.
18
17
  */
19
- probeUname?: () => string | undefined;
18
+ isFile?: (p: string) => boolean;
19
+ /**
20
+ * Runs `uname -s` through the given ABSOLUTE bash.exe path (the first one
21
+ * the PATH-only search found) and returns its stdout, or undefined if it
22
+ * could not be run. Defaults to a real execFileSync(bashPath, ['-lc', 'uname -s']).
23
+ */
24
+ probeUname?: (bashPath: string) => string | undefined;
20
25
  }
21
26
  /**
22
27
  * Resolve the absolute path to the member's Git-for-Windows bash.exe for a
@@ -26,13 +31,15 @@ export interface ResolveGitBashPathDeps {
26
31
  * install location, so the two can never drift apart.
27
32
  *
28
33
  * If none of the known-location candidates exist on disk, this does NOT
29
- * silently trust a bare `bash.exe` resolved off PATH -- Windows also ships
30
- * the WSL launcher under System32/Sysnative/WindowsApps with the identical
31
- * binary name (the same ambiguity isWslLauncherPath/isWindowsPosixUname
32
- * exist to eliminate for the registration probe). Instead it runs `uname -s`
33
- * through whatever bash.exe PATH resolves and only trusts it if that output
34
- * proves a real MSYS/MinGW/Cygwin bash; otherwise it throws, naming every
35
- * candidate path it tried.
34
+ * silently trust a bash.exe found on PATH -- Windows also ships the WSL
35
+ * launcher under System32/Sysnative/WindowsApps with the identical binary
36
+ * name (the same ambiguity isWslLauncherPath/isWindowsPosixUname exist to
37
+ * eliminate for the registration probe). It searches ONLY absolute PATH
38
+ * entries (src/os/windows-executable.ts -- never the cwd, which for
39
+ * LocalStrategy is the member work folder), runs `uname -s` through that
40
+ * absolute path, and returns the absolute path only if the output proves a
41
+ * real MSYS/MinGW/Cygwin bash; otherwise it throws, naming every candidate
42
+ * path it tried. It never returns a bare program name.
36
43
  */
37
44
  export declare function resolveGitBashPath(deps?: ResolveGitBashPathDeps): string;
38
45
  /**
@@ -91,6 +98,8 @@ export declare class WindowsGitBashCommands extends LinuxCommands {
91
98
  env?: Record<string, string>;
92
99
  shell?: string;
93
100
  };
101
+ buildAgentPromptCommand(provider: ProviderAdapter, opts: PromptOptions): string;
102
+ wrapInWorkFolder(folder: string, command: string): string;
94
103
  killPid(pid: number): string;
95
104
  gpuProcessCheck(): string;
96
105
  gpuUtilization(): string;