@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.
- package/README.md +49 -4
- package/dist/agents/backlog-groomer.md +5 -0
- package/dist/agents/ci-watcher.md +5 -0
- package/dist/agents/deployer.md +20 -2
- package/dist/agents/doer.md +38 -2
- package/dist/agents/harvester.md +12 -9
- package/dist/agents/integ-test-runner.md +5 -0
- package/dist/agents/kb-reconciler.md +6 -0
- package/dist/agents/plan-reviewer.md +5 -0
- package/dist/agents/planner.md +5 -0
- package/dist/agents/regression-test-runner.md +5 -0
- package/dist/agents/reviewer.md +67 -15
- package/dist/agents/schemas/deployer-output.json +5 -0
- package/dist/agents/schemas/doer-output.json +78 -2
- package/dist/agents/schemas/reviewer-output.json +104 -2
- package/dist/cli/auth.js +5 -1
- package/dist/cli/beads-pin.js +6 -7
- package/dist/cli/claude-mod.d.ts +75 -0
- package/dist/cli/claude-mod.js +288 -0
- package/dist/cli/dolt-install.d.ts +1 -1
- package/dist/cli/dolt-install.js +5 -1
- package/dist/cli/fleet-se-guard.d.ts +8 -0
- package/dist/cli/fleet-se-guard.js +19 -3
- package/dist/cli/install-guard.d.ts +9 -0
- package/dist/cli/install-guard.js +24 -0
- package/dist/cli/install.d.ts +12 -0
- package/dist/cli/install.js +180 -20
- package/dist/cli/kb-profile.d.ts +16 -0
- package/dist/cli/kb-profile.js +81 -0
- package/dist/cli/start.js +3 -0
- package/dist/cli/uninstall.js +13 -3
- package/dist/cli/update.d.ts +4 -0
- package/dist/cli/update.js +19 -3
- package/dist/commands/kb-server.d.ts +10 -1
- package/dist/commands/kb-server.js +285 -11
- package/dist/index.js +22 -1
- package/dist/os/git-executable.d.ts +57 -0
- package/dist/os/git-executable.js +85 -0
- package/dist/os/go-concurrency.d.ts +44 -0
- package/dist/os/go-concurrency.js +53 -0
- package/dist/os/index.d.ts +1 -0
- package/dist/os/index.js +1 -0
- package/dist/os/linux.d.ts +2 -0
- package/dist/os/linux.js +10 -1
- package/dist/os/os-commands.d.ts +25 -0
- package/dist/os/os-commands.js +2 -0
- package/dist/os/windows-executable.d.ts +53 -0
- package/dist/os/windows-executable.js +185 -0
- package/dist/os/windows-gitbash.d.ts +23 -14
- package/dist/os/windows-gitbash.js +40 -16
- package/dist/os/windows.d.ts +2 -0
- package/dist/os/windows.js +37 -6
- package/dist/paths.d.ts +10 -1
- package/dist/paths.js +19 -2
- package/dist/services/agy-project.d.ts +7 -1
- package/dist/services/agy-project.js +7 -2
- package/dist/services/auth-socket.d.ts +18 -0
- package/dist/services/auth-socket.js +30 -4
- package/dist/services/credential-store.d.ts +33 -0
- package/dist/services/credential-store.js +79 -2
- package/dist/services/http-transport.d.ts +29 -0
- package/dist/services/http-transport.js +166 -37
- package/dist/services/kb-tool-profile.d.ts +36 -0
- package/dist/services/kb-tool-profile.js +88 -0
- package/dist/services/knowledge/bible-blob-id.js +10 -1
- package/dist/services/knowledge/bible-import.d.ts +108 -0
- package/dist/services/knowledge/bible-import.js +137 -4
- package/dist/services/knowledge/file-hash.js +6 -5
- package/dist/services/knowledge/http-provider.d.ts +303 -20
- package/dist/services/knowledge/http-provider.js +795 -125
- package/dist/services/knowledge/kb-config.d.ts +65 -1
- package/dist/services/knowledge/kb-config.js +143 -3
- package/dist/services/knowledge/kb-http-auth-state.d.ts +26 -0
- package/dist/services/knowledge/kb-http-auth-state.js +40 -0
- package/dist/services/knowledge/kb-providers.d.ts +9 -2
- package/dist/services/knowledge/kb-providers.js +67 -37
- package/dist/services/knowledge/kb-removed-scope-keys.js +1 -1
- package/dist/services/knowledge/kb-self.d.ts +122 -9
- package/dist/services/knowledge/kb-self.js +196 -36
- package/dist/services/knowledge/member-bible-view.js +16 -3
- package/dist/services/knowledge/path-validation.d.ts +7 -0
- package/dist/services/knowledge/path-validation.js +11 -0
- package/dist/services/knowledge/project-slug.js +3 -2
- package/dist/services/knowledge/repository-header.d.ts +77 -0
- package/dist/services/knowledge/repository-header.js +233 -0
- package/dist/services/knowledge/require-sqlite-project.d.ts +1 -1
- package/dist/services/knowledge/require-sqlite-project.js +1 -1
- package/dist/services/knowledge/sqlite-provider.d.ts +169 -0
- package/dist/services/knowledge/sqlite-provider.js +416 -4
- package/dist/services/knowledge/types.d.ts +15 -2
- package/dist/services/member-busy.d.ts +12 -0
- package/dist/services/member-busy.js +20 -0
- package/dist/services/member-config-io.d.ts +3 -2
- package/dist/services/member-config-io.js +7 -4
- package/dist/services/member-fleet-install.js +1 -0
- package/dist/services/member-tool-allowlist.d.ts +1 -1
- package/dist/services/member-tool-allowlist.js +8 -4
- package/dist/services/port-holder.js +2 -1
- package/dist/services/service-manager/types.d.ts +17 -1
- package/dist/services/service-manager/windows.d.ts +7 -2
- package/dist/services/service-manager/windows.js +28 -11
- package/dist/services/service-notice.d.ts +7 -0
- package/dist/services/service-notice.js +19 -0
- package/dist/services/session-registry.d.ts +13 -0
- package/dist/services/session-registry.js +13 -0
- package/dist/services/session-roots.d.ts +67 -0
- package/dist/services/session-roots.js +126 -0
- package/dist/services/statusline.d.ts +21 -0
- package/dist/services/statusline.js +97 -1
- package/dist/services/supervisor-service-cleanup.js +2 -1
- package/dist/services/tool-registry.js +108 -20
- package/dist/services/tool-scope.d.ts +34 -1
- package/dist/services/tool-scope.js +27 -2
- package/dist/services/vcs/azure-devops.js +10 -0
- package/dist/services/vcs/bitbucket.d.ts +22 -1
- package/dist/services/vcs/bitbucket.js +163 -17
- package/dist/services/vcs/types.d.ts +25 -2
- package/dist/services/watch/project-resolver.js +2 -1
- package/dist/skills/pm/cost.md +5 -1
- package/dist/skills/pm/index.md +9 -9
- package/dist/skills/pm/sprint.md +2 -1
- package/dist/tools/check-status.d.ts +51 -0
- package/dist/tools/check-status.js +124 -12
- package/dist/tools/code-intelligence-freshness.js +1 -1
- package/dist/tools/code-intelligence-gitnexus.d.ts +19 -0
- package/dist/tools/code-intelligence-gitnexus.js +166 -9
- package/dist/tools/code-intelligence-readiness.d.ts +58 -1
- package/dist/tools/code-intelligence-readiness.js +93 -8
- package/dist/tools/code-intelligence-reindex.d.ts +25 -1
- package/dist/tools/code-intelligence-reindex.js +76 -4
- package/dist/tools/code-intelligence.d.ts +1 -1
- package/dist/tools/code-intelligence.js +1 -1
- package/dist/tools/execute-command.js +14 -8
- package/dist/tools/execute-prompt.js +6 -2
- package/dist/tools/fleet-snapshot.d.ts +21 -0
- package/dist/tools/fleet-snapshot.js +78 -0
- package/dist/tools/kb-bible-commit.d.ts +25 -11
- package/dist/tools/kb-bible-commit.js +142 -33
- package/dist/tools/kb-capture.d.ts +2 -2
- package/dist/tools/kb-context.js +47 -27
- package/dist/tools/kb-demote.d.ts +27 -0
- package/dist/tools/kb-demote.js +37 -0
- package/dist/tools/kb-export.d.ts +35 -3
- package/dist/tools/kb-export.js +56 -13
- package/dist/tools/kb-feedback.d.ts +2 -0
- package/dist/tools/kb-feedback.js +17 -7
- package/dist/tools/kb-harvest.js +28 -9
- package/dist/tools/kb-import.d.ts +18 -2
- package/dist/tools/kb-import.js +24 -9
- package/dist/tools/kb-invalidate.d.ts +11 -3
- package/dist/tools/kb-invalidate.js +80 -7
- package/dist/tools/kb-list.js +38 -10
- package/dist/tools/kb-promote.js +6 -4
- package/dist/tools/kb-query.d.ts +3 -0
- package/dist/tools/kb-query.js +181 -37
- package/dist/tools/kb-session-prime.d.ts +4 -4
- package/dist/tools/kb-session-prime.js +89 -9
- package/dist/tools/kb-setup.d.ts +20 -0
- package/dist/tools/kb-setup.js +149 -11
- package/dist/tools/list-members.js +1 -1
- package/dist/tools/member-detail.js +7 -3
- package/dist/tools/provision-vcs-auth.d.ts +28 -3
- package/dist/tools/provision-vcs-auth.js +53 -7
- package/dist/tools/receive-files.js +7 -4
- package/dist/tools/send-files.js +5 -4
- package/dist/tools/send-message.d.ts +3 -0
- package/dist/tools/send-message.js +15 -2
- package/dist/tools/stop-prompt.js +3 -1
- package/dist/tools/vcs-credential-exec.d.ts +45 -3
- package/dist/tools/vcs-credential-exec.js +90 -11
- package/dist/utils/process-utils.js +5 -1
- package/dist/utils/redact-known-secrets.d.ts +17 -0
- package/dist/utils/redact-known-secrets.js +70 -0
- package/dist/utils/skill-matrix.js +1 -1
- package/dist/utils/vcs-provider-detect.js +2 -2
- package/dist/workflows/auto-sprint.js +245 -9
- package/package.json +10 -7
- package/packages/apra-fleet-client/package.json +1 -1
- package/packages/apra-fleet-client/src/client/api.mjs +172 -19
- package/packages/apra-fleet-client/src/client/reconnecting-transport.mjs +35 -2
- package/packages/apra-fleet-client/src/client/transport.mjs +6 -0
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +20 -2
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +38 -2
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +12 -9
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +6 -0
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +67 -15
- package/packages/apra-fleet-se/apra-pm/agents/schemas/deployer-output.json +5 -0
- package/packages/apra-fleet-se/apra-pm/agents/schemas/doer-output.json +78 -2
- package/packages/apra-fleet-se/apra-pm/agents/schemas/reviewer-output.json +104 -2
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +5 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/index.md +9 -9
- package/packages/apra-fleet-se/apra-pm/skills/pm/sprint.md +2 -1
- package/packages/apra-fleet-se/bin/cli.mjs +104 -31
- package/packages/apra-fleet-se/bin/serve.mjs +46 -8
- package/packages/apra-fleet-se/fleet-sprint/abort.mjs +184 -32
- package/packages/apra-fleet-se/fleet-sprint/bd-sync-command.mjs +69 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-children.mjs +21 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-lock-probe.mjs +176 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-reachability.mjs +126 -0
- package/packages/apra-fleet-se/fleet-sprint/beads-scope.mjs +158 -1
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +82 -2
- package/packages/apra-fleet-se/fleet-sprint/coordination.mjs +23 -6
- package/packages/apra-fleet-se/fleet-sprint/decision-notify.mjs +338 -0
- package/packages/apra-fleet-se/fleet-sprint/decision-wait.mjs +731 -0
- package/packages/apra-fleet-se/fleet-sprint/decisions.mjs +372 -0
- package/packages/apra-fleet-se/fleet-sprint/dispatch-role.mjs +44 -11
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +4 -1
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +9 -3
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +314 -19
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +72 -4
- package/packages/apra-fleet-se/fleet-sprint/git-sync.mjs +7 -1
- package/packages/apra-fleet-se/fleet-sprint/git-topology.mjs +112 -1
- package/packages/apra-fleet-se/fleet-sprint/guarded-modules.mjs +36 -2
- package/packages/apra-fleet-se/fleet-sprint/kb.mjs +736 -101
- package/packages/apra-fleet-se/fleet-sprint/member-init-probe.mjs +1 -1
- package/packages/apra-fleet-se/fleet-sprint/member-provisioning.mjs +7 -1
- package/packages/apra-fleet-se/fleet-sprint/phases/deploy.mjs +49 -2
- package/packages/apra-fleet-se/fleet-sprint/phases/develop.mjs +206 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/final-review.mjs +61 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/harvest.mjs +81 -31
- package/packages/apra-fleet-se/fleet-sprint/phases/plan.mjs +7 -3
- package/packages/apra-fleet-se/fleet-sprint/phases/publish-pr.mjs +39 -14
- package/packages/apra-fleet-se/fleet-sprint/phases/re-review.mjs +17 -1
- package/packages/apra-fleet-se/fleet-sprint/phases/review.mjs +18 -3
- package/packages/apra-fleet-se/fleet-sprint/pr-body.mjs +14 -1
- package/packages/apra-fleet-se/fleet-sprint/prompts.mjs +32 -5
- package/packages/apra-fleet-se/fleet-sprint/runner.js +824 -98
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +4 -2
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +54 -1
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +29 -2
- package/packages/apra-fleet-se/fleet-sprint/set-aside.mjs +288 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-supervisor/SKILL.md +3 -2
- package/packages/apra-fleet-se/fleet-sprint/sprint-args.mjs +20 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-report.mjs +21 -0
- package/packages/apra-fleet-se/fleet-sprint/sprint-state.mjs +9 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-auth.mjs +605 -32
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/bitbucket.mjs +811 -17
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +89 -1
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +225 -2
- package/packages/apra-fleet-se/fleet-sprint/worklists.mjs +59 -3
- package/packages/apra-fleet-se/src/supervisor/api.mjs +148 -8
- package/packages/apra-fleet-se/src/supervisor/dashboard.mjs +6 -3
- package/packages/apra-fleet-se/src/supervisor/dolt-mutex.mjs +30 -10
- package/packages/apra-fleet-se/src/supervisor/fleet-members.mjs +17 -4
- package/packages/apra-fleet-se/src/supervisor/history.mjs +8 -1
- package/packages/apra-fleet-se/src/supervisor/id-allocator.mjs +92 -2
- package/packages/apra-fleet-se/src/supervisor/proxy.mjs +26 -1
- package/packages/apra-fleet-se/src/supervisor/server.mjs +151 -8
- package/packages/apra-fleet-se/src/supervisor/spawner.mjs +11 -9
- package/packages/apra-fleet-se/src/supervisor/watchdog.mjs +7 -1
- package/packages/apra-fleet-workflow/package.json +2 -1
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +86 -5
- package/packages/apra-fleet-workflow/src/viewer/request-guard.mjs +222 -0
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +34 -2
- package/plugins/claude-code/fleet-status/.claude-plugin/plugin.json +7 -0
- package/plugins/claude-code/fleet-status/hooks/hooks.json +1 -0
- package/plugins/claude-code/fleet-status/hooks/register.tsx +906 -0
- package/plugins/claude-code/fleet-status/types/index.d.ts +88 -0
- package/skills/fleet/auth-bitbucket.md +47 -20
- package/skills/fleet/onboarding.md +1 -1
- package/skills/fleet/skill-matrix.md +3 -3
- 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
|
package/dist/os/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/os/linux.d.ts
CHANGED
|
@@ -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
|
package/dist/os/os-commands.d.ts
CHANGED
|
@@ -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;
|
package/dist/os/os-commands.js
CHANGED
|
@@ -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
|
-
*
|
|
16
|
-
*
|
|
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
|
-
|
|
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
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
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;
|