@apralabs/apra-fleet 0.4.1 → 0.4.2
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 +16 -8
- package/dist/agents/backlog-groomer.md +17 -21
- package/dist/agents/ci-watcher.md +3 -0
- package/dist/agents/deployer.md +22 -44
- package/dist/agents/doer.md +131 -132
- package/dist/agents/harvester.md +20 -32
- package/dist/agents/integ-test-runner.md +81 -113
- package/dist/agents/kb-reconciler.md +31 -42
- package/dist/agents/plan-reviewer.md +32 -44
- package/dist/agents/planner.md +51 -63
- package/dist/agents/regression-test-runner.md +65 -80
- package/dist/agents/reviewer.md +56 -83
- package/dist/agents/schemas/integ-test-runner-output.json +1 -1
- package/dist/agents/schemas/regression-test-runner-output.json +4 -17
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +1 -2
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.d.ts +3 -3
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +4 -13
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +5 -39
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/register-member.js +1 -1
- package/dist/cli/start.d.ts.map +1 -1
- package/dist/cli/start.js +7 -0
- package/dist/cli/start.js.map +1 -1
- package/dist/cli/uninstall.d.ts.map +1 -1
- package/dist/cli/uninstall.js +5 -3
- package/dist/cli/uninstall.js.map +1 -1
- package/dist/cli/watch.d.ts +26 -3
- package/dist/cli/watch.d.ts.map +1 -1
- package/dist/cli/watch.js +41 -9
- package/dist/cli/watch.js.map +1 -1
- package/dist/os/git-bash-candidates.d.ts +35 -0
- package/dist/os/git-bash-candidates.d.ts.map +1 -0
- package/dist/os/git-bash-candidates.js +46 -0
- package/dist/os/git-bash-candidates.js.map +1 -0
- package/dist/os/index.d.ts +13 -4
- package/dist/os/index.d.ts.map +1 -1
- package/dist/os/index.js +17 -2
- package/dist/os/index.js.map +1 -1
- package/dist/os/linux.js +1 -1
- package/dist/os/linux.js.map +1 -1
- package/dist/os/os-commands.d.ts +7 -0
- package/dist/os/os-commands.d.ts.map +1 -1
- package/dist/os/os-commands.js.map +1 -1
- package/dist/os/windows-gitbash.d.ts +93 -0
- package/dist/os/windows-gitbash.d.ts.map +1 -0
- package/dist/os/windows-gitbash.js +244 -0
- package/dist/os/windows-gitbash.js.map +1 -0
- package/dist/os/windows.d.ts.map +1 -1
- package/dist/os/windows.js +27 -5
- package/dist/os/windows.js.map +1 -1
- package/dist/providers/agy.d.ts +3 -2
- package/dist/providers/agy.d.ts.map +1 -1
- package/dist/providers/agy.js +11 -2
- package/dist/providers/agy.js.map +1 -1
- package/dist/providers/claude.d.ts +3 -2
- package/dist/providers/claude.d.ts.map +1 -1
- package/dist/providers/claude.js +22 -3
- package/dist/providers/claude.js.map +1 -1
- package/dist/providers/codex.d.ts +3 -2
- package/dist/providers/codex.d.ts.map +1 -1
- package/dist/providers/codex.js +5 -2
- package/dist/providers/codex.js.map +1 -1
- package/dist/providers/copilot.d.ts +3 -2
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +7 -2
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +0 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/none.d.ts +3 -2
- package/dist/providers/none.d.ts.map +1 -1
- package/dist/providers/none.js +5 -2
- package/dist/providers/none.js.map +1 -1
- package/dist/providers/opencode.d.ts +3 -2
- package/dist/providers/opencode.d.ts.map +1 -1
- package/dist/providers/opencode.js +5 -2
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/provider.d.ts +16 -7
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/provider.js +2 -2
- package/dist/providers/provider.js.map +1 -1
- package/dist/services/agent-provisioner.js +2 -2
- package/dist/services/agent-provisioner.js.map +1 -1
- package/dist/services/cloud/activity.js +2 -2
- package/dist/services/cloud/activity.js.map +1 -1
- package/dist/services/context-admission.d.ts.map +1 -1
- package/dist/services/context-admission.js +9 -7
- package/dist/services/context-admission.js.map +1 -1
- package/dist/services/credential-cleanup.d.ts.map +1 -1
- package/dist/services/credential-cleanup.js +22 -3
- package/dist/services/credential-cleanup.js.map +1 -1
- package/dist/services/member-home.d.ts +1 -1
- package/dist/services/member-home.d.ts.map +1 -1
- package/dist/services/member-home.js +15 -12
- package/dist/services/member-home.js.map +1 -1
- package/dist/services/model-pricing.d.ts.map +1 -1
- package/dist/services/model-pricing.js +0 -5
- package/dist/services/model-pricing.js.map +1 -1
- package/dist/services/orphan-recovery.d.ts +6 -3
- package/dist/services/orphan-recovery.d.ts.map +1 -1
- package/dist/services/orphan-recovery.js +17 -14
- package/dist/services/orphan-recovery.js.map +1 -1
- package/dist/services/preflight-check.js +2 -2
- package/dist/services/preflight-check.js.map +1 -1
- package/dist/services/shell-probe.d.ts +131 -0
- package/dist/services/shell-probe.d.ts.map +1 -0
- package/dist/services/shell-probe.js +210 -0
- package/dist/services/shell-probe.js.map +1 -0
- package/dist/services/singleton.d.ts +2 -0
- package/dist/services/singleton.d.ts.map +1 -1
- package/dist/services/singleton.js +1 -1
- package/dist/services/singleton.js.map +1 -1
- package/dist/services/ssh.js +2 -2
- package/dist/services/ssh.js.map +1 -1
- package/dist/services/stall/find-log-file.d.ts.map +1 -1
- package/dist/services/stall/find-log-file.js +22 -16
- package/dist/services/stall/find-log-file.js.map +1 -1
- package/dist/services/stall/read-log-tail.d.ts.map +1 -1
- package/dist/services/stall/read-log-tail.js +6 -5
- package/dist/services/stall/read-log-tail.js.map +1 -1
- package/dist/services/stall/stall-poller.d.ts.map +1 -1
- package/dist/services/stall/stall-poller.js +35 -42
- package/dist/services/stall/stall-poller.js.map +1 -1
- package/dist/services/strategy.d.ts +9 -0
- package/dist/services/strategy.d.ts.map +1 -1
- package/dist/services/strategy.js +40 -6
- package/dist/services/strategy.js.map +1 -1
- package/dist/services/user-config.js +1 -1
- package/dist/services/user-config.js.map +1 -1
- package/dist/services/vcs/azure-devops.d.ts +1 -1
- package/dist/services/vcs/azure-devops.d.ts.map +1 -1
- package/dist/services/vcs/azure-devops.js +105 -10
- package/dist/services/vcs/azure-devops.js.map +1 -1
- package/dist/services/vcs/bitbucket.d.ts.map +1 -1
- package/dist/services/vcs/bitbucket.js +16 -0
- package/dist/services/vcs/bitbucket.js.map +1 -1
- package/dist/services/vcs/github.d.ts.map +1 -1
- package/dist/services/vcs/github.js +24 -0
- package/dist/services/vcs/github.js.map +1 -1
- package/dist/services/vcs/types.d.ts +123 -2
- package/dist/services/vcs/types.d.ts.map +1 -1
- package/dist/skills/fleet-sprint-cli/SKILL.md +2 -1
- package/dist/skills/pm/SKILL.md +0 -1
- package/dist/skills/pm/cost.md +0 -1
- package/dist/skills/pm/fleet-addendum.md +0 -1
- package/dist/tools/check-status.js +3 -3
- package/dist/tools/check-status.js.map +1 -1
- package/dist/tools/cloud-control.js +2 -2
- package/dist/tools/cloud-control.js.map +1 -1
- package/dist/tools/compose-permissions.d.ts.map +1 -1
- package/dist/tools/compose-permissions.js +37 -24
- package/dist/tools/compose-permissions.js.map +1 -1
- package/dist/tools/execute-command.d.ts.map +1 -1
- package/dist/tools/execute-command.js +28 -12
- package/dist/tools/execute-command.js.map +1 -1
- package/dist/tools/execute-prompt.d.ts.map +1 -1
- package/dist/tools/execute-prompt.js +55 -18
- package/dist/tools/execute-prompt.js.map +1 -1
- package/dist/tools/list-members.d.ts.map +1 -1
- package/dist/tools/list-members.js +6 -2
- package/dist/tools/list-members.js.map +1 -1
- package/dist/tools/member-detail.d.ts.map +1 -1
- package/dist/tools/member-detail.js +5 -3
- package/dist/tools/member-detail.js.map +1 -1
- package/dist/tools/member-reservation.d.ts.map +1 -1
- package/dist/tools/member-reservation.js +13 -1
- package/dist/tools/member-reservation.js.map +1 -1
- package/dist/tools/monitor-task.d.ts.map +1 -1
- package/dist/tools/monitor-task.js +17 -2
- package/dist/tools/monitor-task.js.map +1 -1
- package/dist/tools/provision-auth.js +5 -5
- package/dist/tools/provision-auth.js.map +1 -1
- package/dist/tools/provision-vcs-auth.d.ts +5 -2
- package/dist/tools/provision-vcs-auth.d.ts.map +1 -1
- package/dist/tools/provision-vcs-auth.js +58 -52
- package/dist/tools/provision-vcs-auth.js.map +1 -1
- package/dist/tools/register-member.d.ts +18 -12
- package/dist/tools/register-member.d.ts.map +1 -1
- package/dist/tools/register-member.js +42 -4
- package/dist/tools/register-member.js.map +1 -1
- package/dist/tools/remove-member.js +2 -2
- package/dist/tools/remove-member.js.map +1 -1
- package/dist/tools/revoke-vcs-auth.js +2 -2
- package/dist/tools/revoke-vcs-auth.js.map +1 -1
- package/dist/tools/setup-ssh-key.d.ts.map +1 -1
- package/dist/tools/setup-ssh-key.js +2 -1
- package/dist/tools/setup-ssh-key.js.map +1 -1
- package/dist/tools/stop-prompt.js +2 -2
- package/dist/tools/stop-prompt.js.map +1 -1
- package/dist/tools/update-agent-cli.js +2 -2
- package/dist/tools/update-agent-cli.js.map +1 -1
- package/dist/tools/update-member.d.ts +18 -12
- package/dist/tools/update-member.d.ts.map +1 -1
- package/dist/tools/update-member.js +18 -1
- package/dist/tools/update-member.js.map +1 -1
- package/dist/types.d.ts +11 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agent-helpers.d.ts +36 -0
- package/dist/utils/agent-helpers.d.ts.map +1 -1
- package/dist/utils/agent-helpers.js +39 -1
- package/dist/utils/agent-helpers.js.map +1 -1
- package/dist/utils/platform.d.ts +7 -0
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js +11 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/workspace-trust.d.ts.map +1 -1
- package/dist/utils/workspace-trust.js +5 -1
- package/dist/utils/workspace-trust.js.map +1 -1
- package/dist/workflows/auto-sprint.js +4 -17
- package/package.json +2 -2
- package/packages/apra-fleet-client/src/client/api.mjs +92 -3
- package/packages/apra-fleet-se/apra-pm/agents/backlog-groomer.md +17 -21
- package/packages/apra-fleet-se/apra-pm/agents/ci-watcher.md +3 -0
- package/packages/apra-fleet-se/apra-pm/agents/deployer.md +22 -44
- package/packages/apra-fleet-se/apra-pm/agents/doer.md +131 -132
- package/packages/apra-fleet-se/apra-pm/agents/harvester.md +20 -32
- package/packages/apra-fleet-se/apra-pm/agents/integ-test-runner.md +81 -113
- package/packages/apra-fleet-se/apra-pm/agents/kb-reconciler.md +31 -42
- package/packages/apra-fleet-se/apra-pm/agents/plan-reviewer.md +32 -44
- package/packages/apra-fleet-se/apra-pm/agents/planner.md +51 -63
- package/packages/apra-fleet-se/apra-pm/agents/regression-test-runner.md +65 -80
- package/packages/apra-fleet-se/apra-pm/agents/reviewer.md +56 -83
- package/packages/apra-fleet-se/apra-pm/agents/schemas/integ-test-runner-output.json +1 -1
- package/packages/apra-fleet-se/apra-pm/agents/schemas/regression-test-runner-output.json +4 -17
- package/packages/apra-fleet-se/apra-pm/skills/pm/SKILL.md +0 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/cost.md +0 -1
- package/packages/apra-fleet-se/apra-pm/skills/pm/fleet-addendum.md +0 -1
- package/packages/apra-fleet-se/bin/cli.mjs +132 -3
- package/packages/apra-fleet-se/bin/serve.mjs +36 -1
- package/packages/apra-fleet-se/fleet-sprint/contracts.mjs +151 -33
- package/packages/apra-fleet-se/fleet-sprint/docs/README.md +22 -7
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-manual-recovery-verified.md +10 -8
- package/packages/apra-fleet-se/fleet-sprint/docs/dolt-sync-redesign.md +9 -4
- package/packages/apra-fleet-se/fleet-sprint/docs/escalate-to-llm-design.md +2 -2
- package/packages/apra-fleet-se/fleet-sprint/docs/shared-orchestrator-reservation-design.md +12 -12
- package/packages/apra-fleet-se/fleet-sprint/docs/stabilization-log.md +14 -4
- package/packages/apra-fleet-se/fleet-sprint/dolt-settle.mjs +275 -99
- package/packages/apra-fleet-se/fleet-sprint/dolt-sync.mjs +67 -16
- package/packages/apra-fleet-se/fleet-sprint/errors.mjs +41 -0
- package/packages/apra-fleet-se/fleet-sprint/runner.js +1140 -209
- package/packages/apra-fleet-se/fleet-sprint/se-os-commands.mjs +134 -0
- package/packages/apra-fleet-se/fleet-sprint/se-posix.mjs +154 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows-gitbash.mjs +97 -0
- package/packages/apra-fleet-se/fleet-sprint/se-windows.mjs +143 -0
- package/packages/apra-fleet-se/fleet-sprint/skills/fleet-sprint-cli/SKILL.md +2 -1
- package/packages/apra-fleet-se/fleet-sprint/vcs-module.mjs +51 -0
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/azure-devops.mjs +657 -12
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/dolt.mjs +33 -4
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/github.mjs +60 -43
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/index.mjs +205 -2
- package/packages/apra-fleet-se/fleet-sprint/vcs-providers/shell-helpers.mjs +164 -0
- package/packages/apra-fleet-se/fleet-sprint/viewer-extensions.mjs +92 -37
- package/packages/apra-fleet-workflow/src/viewer/index.mjs +167 -1
- package/packages/apra-fleet-workflow/src/workflow/index.mjs +435 -31
- package/skills/fleet/SKILL.md +20 -9
- package/skills/fleet/auth-azdevops.md +44 -5
- package/skills/fleet/auth-bitbucket.md +3 -3
- package/skills/fleet/auth-github.md +2 -2
- package/skills/fleet/beads-conflict-resolution.md +141 -0
- package/skills/fleet/beads.md +16 -12
- package/skills/fleet/onboarding.md +4 -4
- package/skills/fleet/permissions.md +6 -6
- package/skills/fleet/skill-matrix.md +1 -1
- package/skills/fleet/troubleshooting.md +2 -1
- package/version.json +1 -1
- package/dist/providers/gemini.d.ts +0 -52
- package/dist/providers/gemini.d.ts.map +0 -1
- package/dist/providers/gemini.js +0 -236
- package/dist/providers/gemini.js.map +0 -1
- package/packages/apra-fleet-se/fleet-sprint/docs/coach-role-design.md +0 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentStrategy } from './strategy.js';
|
|
2
|
-
import type { OsCommands } from '../os/os-commands.js';
|
|
2
|
+
import type { OsCommands, MemberShell } from '../os/os-commands.js';
|
|
3
3
|
import type { LogScope } from '../utils/log-helpers.js';
|
|
4
4
|
import type { RemoteOS } from '../utils/platform.js';
|
|
5
5
|
export type OrphanRecoveryStatus =
|
|
@@ -34,6 +34,9 @@ export interface OrphanRecoveryOptions {
|
|
|
34
34
|
unsupported?: boolean;
|
|
35
35
|
/** Remote member's OS, for building an OS-appropriate probe command. Defaults to 'linux'. */
|
|
36
36
|
os?: RemoteOS;
|
|
37
|
+
/** Remote member's registered shell (only meaningful for Windows). A
|
|
38
|
+
* gitbash member gets POSIX probe commands instead of PowerShell ones. */
|
|
39
|
+
shell?: MemberShell;
|
|
37
40
|
/** Upper bound on the wait; defaults to the remaining max_total_s, else a ceiling. */
|
|
38
41
|
maxWaitMs?: number;
|
|
39
42
|
pollIntervalMs?: number;
|
|
@@ -48,9 +51,9 @@ export interface OrphanRecoveryOptions {
|
|
|
48
51
|
* marker counts as dead; a failed/garbled probe is reported as alive so the
|
|
49
52
|
* caller waits rather than declaring a false failure.
|
|
50
53
|
*/
|
|
51
|
-
export declare function isRemoteProcessAlive(strategy: AgentStrategy, pid: number, os?: RemoteOS): Promise<boolean>;
|
|
54
|
+
export declare function isRemoteProcessAlive(strategy: AgentStrategy, pid: number, os?: RemoteOS, shell?: MemberShell): Promise<boolean>;
|
|
52
55
|
/** Read the durable per-invocation output file back over a fresh exec. */
|
|
53
|
-
export declare function readDurableOutput(strategy: AgentStrategy, durablePath: string, os?: RemoteOS): Promise<string | null>;
|
|
56
|
+
export declare function readDurableOutput(strategy: AgentStrategy, durablePath: string, os?: RemoteOS, shell?: MemberShell): Promise<string | null>;
|
|
54
57
|
/**
|
|
55
58
|
* Lease-of-life gate. Returns 'dead' whenever the pre-existing empty_response
|
|
56
59
|
* behavior should apply verbatim, so the caller's fallback path is unchanged.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orphan-recovery.d.ts","sourceRoot":"","sources":["../../src/services/orphan-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"orphan-recovery.d.ts","sourceRoot":"","sources":["../../src/services/orphan-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA+BrD,MAAM,MAAM,oBAAoB;AAC9B,8EAA8E;AAC5E,WAAW;AACb;2DAC2D;GACzD,MAAM;AACR;kDACkD;GAChD,OAAO;AACT;oEACoE;GAClE,SAAS;AACX;0DAC0D;GACxD,aAAa,CAAC;AAElB,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,UAAU,CAAC;IACjB,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6FAA6F;IAC7F,EAAE,CAAC,EAAE,QAAQ,CAAC;IACd;+EAC2E;IAC3E,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAWD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,MAAM,EACX,EAAE,GAAE,QAAkB,EACtB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAmBlB;AAED,0EAA0E;AAC1E,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,aAAa,EACvB,WAAW,EAAE,MAAM,EACnB,EAAE,GAAE,QAAkB,EACtB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcxB;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAuCxG"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { wrapPowerShellEncoded } from '../os/windows.js';
|
|
2
|
+
import { isPosixShell } from '../utils/agent-helpers.js';
|
|
2
3
|
/**
|
|
3
4
|
* Lease-of-life recovery for a false-alarm "exit 0 / empty output" dispatch
|
|
4
5
|
* (apra-fleet-6z8.1, Part A+C of apra-fleet-6z8).
|
|
@@ -39,13 +40,14 @@ const defaultSleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
|
39
40
|
* marker counts as dead; a failed/garbled probe is reported as alive so the
|
|
40
41
|
* caller waits rather than declaring a false failure.
|
|
41
42
|
*/
|
|
42
|
-
export async function isRemoteProcessAlive(strategy, pid, os = 'linux') {
|
|
43
|
+
export async function isRemoteProcessAlive(strategy, pid, os = 'linux', shell) {
|
|
43
44
|
try {
|
|
44
45
|
// Windows has no `kill -0`; mirror the Get-Process idiom monitor-task.ts
|
|
45
|
-
// already uses for the same pid-alive check.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
// already uses for the same pid-alive check. A gitbash member gets the
|
|
47
|
+
// POSIX form instead -- it has a real `kill` (apra-fleet-7dir.2.4).
|
|
48
|
+
const cmd = isPosixShell(os, shell)
|
|
49
|
+
? `kill -0 ${pid} 2>/dev/null && echo ALIVE || echo DEAD`
|
|
50
|
+
: wrapPowerShellEncoded(`if (Get-Process -Id ${pid} -ErrorAction SilentlyContinue) { echo ALIVE } else { echo DEAD }`);
|
|
49
51
|
const res = await strategy.execCommand(cmd, PROBE_TIMEOUT_MS);
|
|
50
52
|
const out = (res.stdout || '').trim();
|
|
51
53
|
if (/\bDEAD\b/.test(out))
|
|
@@ -62,13 +64,14 @@ export async function isRemoteProcessAlive(strategy, pid, os = 'linux') {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
/** Read the durable per-invocation output file back over a fresh exec. */
|
|
65
|
-
export async function readDurableOutput(strategy, durablePath, os = 'linux') {
|
|
67
|
+
export async function readDurableOutput(strategy, durablePath, os = 'linux', shell) {
|
|
66
68
|
try {
|
|
67
69
|
// Windows has no `cat`; mirror the Get-Content idiom monitor-task.ts
|
|
68
|
-
// already uses for reading a possibly-missing remote file.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
// already uses for reading a possibly-missing remote file. A gitbash
|
|
71
|
+
// member gets the POSIX form instead (apra-fleet-7dir.2.4).
|
|
72
|
+
const cmd = isPosixShell(os, shell)
|
|
73
|
+
? `cat "${durablePath}" 2>/dev/null`
|
|
74
|
+
: wrapPowerShellEncoded(`if (Test-Path "${durablePath}") { Get-Content -Path "${durablePath}" -Raw } else { echo '' }`);
|
|
72
75
|
const res = await strategy.execCommand(cmd, PROBE_TIMEOUT_MS);
|
|
73
76
|
const out = res.stdout ?? '';
|
|
74
77
|
return out.trim() === '' ? null : out;
|
|
@@ -82,14 +85,14 @@ export async function readDurableOutput(strategy, durablePath, os = 'linux') {
|
|
|
82
85
|
* behavior should apply verbatim, so the caller's fallback path is unchanged.
|
|
83
86
|
*/
|
|
84
87
|
export async function recoverOrphanedDispatch(opts) {
|
|
85
|
-
const { strategy, cmds, pid, durablePath, unsupported, scope, os = 'linux' } = opts;
|
|
88
|
+
const { strategy, cmds, pid, durablePath, unsupported, scope, os = 'linux', shell } = opts;
|
|
86
89
|
if (unsupported || pid === undefined || !durablePath)
|
|
87
90
|
return { status: 'unsupported' };
|
|
88
91
|
const pollIntervalMs = opts.pollIntervalMs
|
|
89
92
|
?? envInt('ORPHAN_RECOVERY_POLL_MS', envInt('STALL_POLL_INTERVAL_MS', DEFAULT_POLL_INTERVAL_MS));
|
|
90
93
|
const maxWaitMs = opts.maxWaitMs ?? envInt('ORPHAN_RECOVERY_MAX_WAIT_MS', DEFAULT_MAX_WAIT_MS);
|
|
91
94
|
const sleep = opts.sleep ?? defaultSleep;
|
|
92
|
-
if (!(await isRemoteProcessAlive(strategy, pid, os))) {
|
|
95
|
+
if (!(await isRemoteProcessAlive(strategy, pid, os, shell))) {
|
|
93
96
|
// Confirmed dead: today's behavior, unchanged.
|
|
94
97
|
return { status: 'dead', waitedMs: 0 };
|
|
95
98
|
}
|
|
@@ -108,10 +111,10 @@ export async function recoverOrphanedDispatch(opts) {
|
|
|
108
111
|
const remaining = maxWaitMs - waitedMs;
|
|
109
112
|
await sleep(Math.min(pollIntervalMs, remaining));
|
|
110
113
|
waitedMs = Math.max(Date.now() - start, waitedMs + Math.min(pollIntervalMs, remaining));
|
|
111
|
-
if (!(await isRemoteProcessAlive(strategy, pid, os)))
|
|
114
|
+
if (!(await isRemoteProcessAlive(strategy, pid, os, shell)))
|
|
112
115
|
break;
|
|
113
116
|
}
|
|
114
|
-
const stdout = await readDurableOutput(strategy, durablePath, os);
|
|
117
|
+
const stdout = await readDurableOutput(strategy, durablePath, os, shell);
|
|
115
118
|
if (stdout === null) {
|
|
116
119
|
scope?.info(`[orphan-recovery] pid=${pid} exited but ${durablePath} is missing/empty -- a genuine empty response`);
|
|
117
120
|
return { status: 'empty', waitedMs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orphan-recovery.js","sourceRoot":"","sources":["../../src/services/orphan-recovery.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AAEH;;oFAEoF;AACpF,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,EAAE,GAAG,MAAM,CAAC;AACxC;4CAC4C;AAC5C,MAAM,gBAAgB,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"orphan-recovery.js","sourceRoot":"","sources":["../../src/services/orphan-recovery.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AAEH;;oFAEoF;AACpF,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,EAAE,GAAG,MAAM,CAAC;AACxC;4CAC4C;AAC5C,MAAM,gBAAgB,GAAG,MAAM,CAAC;AA+ChC,SAAS,MAAM,CAAC,IAAY,EAAE,QAAgB;IAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG;QAAE,OAAO,QAAQ,CAAC;IAC1B,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,C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KAAK,EAAE,IAAI,CAAC,yBAAyB,GAAG,eAAe,WAAW,+CAA+C,CAAC,CAAC;QACnH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IACvC,CAAC;IACD,KAAK,EAAE,IAAI,CAAC,+BAA+B,MAAM,CAAC,MAAM,oCAAoC,GAAG,UAAU,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACzI,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getStrategy } from './strategy.js';
|
|
2
2
|
import { getOsCommands } from '../os/index.js';
|
|
3
3
|
import { getProvider } from '../providers/index.js';
|
|
4
|
-
import { getAgentOS } from '../utils/agent-helpers.js';
|
|
4
|
+
import { getAgentOS, getAgentShell } from '../utils/agent-helpers.js';
|
|
5
5
|
import { validateCredentials } from '../utils/credential-validation.js';
|
|
6
6
|
import { logLine } from '../utils/log-helpers.js';
|
|
7
7
|
/** Members that passed preflight within the last CACHE_TTL_MS do not need a
|
|
@@ -116,7 +116,7 @@ export async function preflightCheck(agent, options) {
|
|
|
116
116
|
evictOldestEntries();
|
|
117
117
|
return { ok: true, connectivity: true, authValid: true, latencyMs };
|
|
118
118
|
}
|
|
119
|
-
const cmds = getOsCommands(getAgentOS(agent));
|
|
119
|
+
const cmds = getOsCommands(getAgentOS(agent), getAgentShell(agent));
|
|
120
120
|
let oauthFilePresent = false;
|
|
121
121
|
let apiKeyPresent = false;
|
|
122
122
|
let credentialStatus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight-check.js","sourceRoot":"","sources":["../../src/services/preflight-check.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,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,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows member shell probe (apra-fleet-7dir.1.3).
|
|
3
|
+
*
|
|
4
|
+
* Registration needs to know WHICH Windows shell a member's command strings
|
|
5
|
+
* should target -- Git-for-Windows bash, PowerShell 7, or Windows PowerShell
|
|
6
|
+
* 5.1 -- because the three are not interchangeable (PS7 vs PS5.1 module
|
|
7
|
+
* resolution differences are an already-known bug source here, and gitbash
|
|
8
|
+
* members want POSIX command strings entirely).
|
|
9
|
+
*
|
|
10
|
+
* Two hard-won constraints shape every probe below:
|
|
11
|
+
*
|
|
12
|
+
* 1. PowerShell reports false success on non-terminating errors, so an
|
|
13
|
+
* exit-code-only check is NOT evidence a candidate shell works. Every
|
|
14
|
+
* probe therefore asserts on a prefixed stdout marker as well as exit 0.
|
|
15
|
+
* 2. A `bash.exe` on PATH is not necessarily Git bash: Windows ships the WSL
|
|
16
|
+
* launcher under System32 (and WindowsApps) with the same binary name. It
|
|
17
|
+
* exits 0 and prints "Linux" for `uname -s`, so only the MINGW/MSYS/CYGWIN
|
|
18
|
+
* uname check disambiguates it. Verified on a real box: Git's bash prints
|
|
19
|
+
* "MINGW64_NT-10.0-19045", System32's prints "Linux".
|
|
20
|
+
*
|
|
21
|
+
* Every probe is issued through `powershell -EncodedCommand` (base64 UTF-16LE)
|
|
22
|
+
* so it survives regardless of whether the member's SSH default shell is
|
|
23
|
+
* cmd.exe or PowerShell -- no quoting of ours ever reaches an unknown parser.
|
|
24
|
+
*/
|
|
25
|
+
import type { MemberShell } from '../os/os-commands.js';
|
|
26
|
+
import type { RemoteOS } from '../utils/platform.js';
|
|
27
|
+
/** Result shape of a single probe command execution. */
|
|
28
|
+
export interface ProbeExecResult {
|
|
29
|
+
stdout: string;
|
|
30
|
+
stderr: string;
|
|
31
|
+
code: number;
|
|
32
|
+
}
|
|
33
|
+
/** Minimal command runner the probe needs (AgentStrategy.execCommand shaped). */
|
|
34
|
+
export type ProbeExec = (command: string, timeoutMs: number) => Promise<ProbeExecResult>;
|
|
35
|
+
export interface ShellProbeResult {
|
|
36
|
+
shell: MemberShell;
|
|
37
|
+
/** Present only when the probe could not prove anything and fell back. */
|
|
38
|
+
warning?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Per-probe budget. Short on purpose: an unprovisioned WSL bash.exe can sit
|
|
41
|
+
* there printing a store URL instead of exiting. */
|
|
42
|
+
export declare const SHELL_PROBE_TIMEOUT_MS = 15000;
|
|
43
|
+
/**
|
|
44
|
+
* Whether registration should probe for a shell at all.
|
|
45
|
+
*
|
|
46
|
+
* Windows members only, and never when the operator supplied one explicitly --
|
|
47
|
+
* an explicit shell always wins over the probe result.
|
|
48
|
+
*/
|
|
49
|
+
export declare function shouldProbeShell(os: RemoteOS | undefined, explicitShell?: MemberShell): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Reject bash.exe paths that are Windows' own WSL launcher rather than a real
|
|
52
|
+
* Git-for-Windows / MSYS install. Belt and braces: the uname check below is
|
|
53
|
+
* what actually proves the candidate, this just avoids spending a probe (and
|
|
54
|
+
* possibly a WSL first-run stall) on a known-bad path.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isWslLauncherPath(candidatePath: string): boolean;
|
|
57
|
+
/** One round trip that lists every plausible Git-bash path that actually exists
|
|
58
|
+
* on the member: well-known install locations plus anything named bash.exe on
|
|
59
|
+
* PATH. Each line is prefixed so echoed-back input can never be mistaken for a
|
|
60
|
+
* result.
|
|
61
|
+
*
|
|
62
|
+
* The machine-wide well-known locations come from GIT_BASH_MACHINE_CANDIDATES
|
|
63
|
+
* (src/os/git-bash-candidates.ts), the SAME list windows-gitbash.ts's
|
|
64
|
+
* resolveGitBashPath consults for a local member -- one literal, two
|
|
65
|
+
* consumers, so the two can never drift apart again (apra-fleet-7dir.7). The
|
|
66
|
+
* LOCALAPPDATA (user-scope) candidate is still built with a PowerShell
|
|
67
|
+
* `Join-Path $env:LOCALAPPDATA ...` expression rather than a JS-side value,
|
|
68
|
+
* because it must resolve against the REMOTE member's LOCALAPPDATA, not this
|
|
69
|
+
* process's own. */
|
|
70
|
+
export declare function buildGitBashDiscoveryCommand(): string;
|
|
71
|
+
/** Smoke command for one Git-bash candidate: run the real binary and ask it what
|
|
72
|
+
* it is. `&` is the call operator -- without it PowerShell would merely echo the
|
|
73
|
+
* quoted path back, exit 0, and look like a success. */
|
|
74
|
+
export declare function buildGitBashProbeCommand(bashPath: string): string;
|
|
75
|
+
/** Smoke command for PowerShell 7. Nested -EncodedCommand so neither our outer
|
|
76
|
+
* wrapper nor a cmd.exe default shell can eat the `$` before pwsh sees it. */
|
|
77
|
+
export declare function buildPwsh7ProbeCommand(): string;
|
|
78
|
+
/** Smoke command for Windows PowerShell 5.1. */
|
|
79
|
+
export declare function buildPowerShell5ProbeCommand(): string;
|
|
80
|
+
/** Parse the discovery output into candidate paths, dropping WSL launchers. */
|
|
81
|
+
export declare function parseGitBashCandidates(stdout: string): string[];
|
|
82
|
+
/** Exit code AND stdout must both check out -- see constraint (1) above. */
|
|
83
|
+
export declare function isProvenGitBash(result: ProbeExecResult): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Proves the RAW (unwrapped) exec channel itself is interpreted by a genuine
|
|
86
|
+
* Git-for-Windows/MSYS bash -- not merely that a bash.exe binary exists
|
|
87
|
+
* somewhere on the machine. This distinction only matters for a REMOTE (SSH)
|
|
88
|
+
* member: `ssh.ts`'s execCommand hands the command string straight to the
|
|
89
|
+
* member's sshd, which runs it through whatever ITS OWN DefaultShell is
|
|
90
|
+
* configured to be -- a Git-bash binary being installed proves nothing about
|
|
91
|
+
* that, since every other probe above (isProvenGitBash included) is
|
|
92
|
+
* deliberately wrapped in `powershell -EncodedCommand ...` so it survives
|
|
93
|
+
* regardless of the connection's real default shell. A local member has no
|
|
94
|
+
* such gap (LocalStrategy spawns the resolved bash.exe path directly, see
|
|
95
|
+
* strategy.ts), so this check is remote-transport-only.
|
|
96
|
+
*
|
|
97
|
+
* Deliberately NOT wrapPowerShellEncoded -- wrapping would defeat the whole
|
|
98
|
+
* point of testing what interprets an unwrapped string. Heredoc syntax
|
|
99
|
+
* (`<<`) is rejected outright by both cmd.exe and PowerShell, making it a
|
|
100
|
+
* clean interpreter discriminator; chaining `&& uname -s` onto it in the
|
|
101
|
+
* SAME round trip reuses the existing MINGW/MSYS/CYGWIN-vs-WSL uname check
|
|
102
|
+
* (isWindowsPosixUname) to rule out a WSL bash.exe DefaultShell the same way
|
|
103
|
+
* the binary-existence path above already does for local members.
|
|
104
|
+
*/
|
|
105
|
+
export declare function buildRemoteBashChannelProbeCommand(): string;
|
|
106
|
+
/** Exit code, the literal marker line, AND a proven-POSIX uname line right
|
|
107
|
+
* after it must all be present -- tolerates CRLF/blank-line noise a real
|
|
108
|
+
* SSH round trip can introduce. */
|
|
109
|
+
export declare function isProvenRemoteBashChannel(result: ProbeExecResult): boolean;
|
|
110
|
+
export declare function isProvenPwsh7(result: ProbeExecResult): boolean;
|
|
111
|
+
export declare function isProvenPowerShell5(result: ProbeExecResult): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Probe a Windows member for its shell, in order: Git bash, then PowerShell 7,
|
|
114
|
+
* then PowerShell 5.1. Returns the FIRST candidate proven working by a real
|
|
115
|
+
* smoke command (exit code AND stdout both checked).
|
|
116
|
+
*
|
|
117
|
+
* `transport` distinguishes a local member (LocalStrategy spawns the
|
|
118
|
+
* resolved bash.exe path directly -- binary existence is sufficient proof)
|
|
119
|
+
* from a remote/SSH member (raw command strings are handed straight to the
|
|
120
|
+
* member's own sshd DefaultShell -- binary existence proves nothing about
|
|
121
|
+
* what that connection actually executes; see isProvenRemoteBashChannel's
|
|
122
|
+
* doc comment). Defaults to 'local' so every existing local-member call site
|
|
123
|
+
* and test keeps its current behaviour unchanged.
|
|
124
|
+
*
|
|
125
|
+
* Never throws and never fails registration: if nothing can be proven it
|
|
126
|
+
* degrades to powershell5 -- the shell Windows always has and the value that
|
|
127
|
+
* yields byte-identical command strings to the pre-probe behaviour -- with a
|
|
128
|
+
* warning for the caller to surface.
|
|
129
|
+
*/
|
|
130
|
+
export declare function probeWindowsShell(exec: ProbeExec, transport?: 'local' | 'ssh'): Promise<ShellProbeResult>;
|
|
131
|
+
//# sourceMappingURL=shell-probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-probe.d.ts","sourceRoot":"","sources":["../../src/services/shell-probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKrD,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,iFAAiF;AACjF,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAEzF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;qDACqD;AACrD,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAQ5C;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,SAAS,EAAE,aAAa,CAAC,EAAE,WAAW,GAAG,OAAO,CAE/F;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED;;;;;;;;;;;;qBAYqB;AACrB,wBAAgB,4BAA4B,IAAI,MAAM,CAWrD;AAED;;yDAEyD;AACzD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED;+EAC+E;AAC/E,wBAAgB,sBAAsB,IAAI,MAAM,CAM/C;AAED,gDAAgD;AAChD,wBAAgB,4BAA4B,IAAI,MAAM,CAMrD;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAc/D;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAEhE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kCAAkC,IAAI,MAAM,CAE3D;AAED;;oCAEoC;AACpC,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAM1E;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAE9D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAEpE;AAaD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,GAAE,OAAO,GAAG,KAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA+CxH"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { isWindowsPosixUname } from '../utils/platform.js';
|
|
2
|
+
import { wrapPowerShellEncoded } from '../os/windows.js';
|
|
3
|
+
import { GIT_BASH_MACHINE_CANDIDATES, GIT_BASH_USER_SUFFIX } from '../os/git-bash-candidates.js';
|
|
4
|
+
/** Per-probe budget. Short on purpose: an unprovisioned WSL bash.exe can sit
|
|
5
|
+
* there printing a store URL instead of exiting. */
|
|
6
|
+
export const SHELL_PROBE_TIMEOUT_MS = 15000;
|
|
7
|
+
const BASH_CANDIDATE_MARKER = 'BASHCAND:';
|
|
8
|
+
const PS_EDITION_MARKER = 'PSEDITION:';
|
|
9
|
+
const PS_MAJOR_MARKER = 'PSMAJOR:';
|
|
10
|
+
const BASH_CHANNEL_MARKER_LINE = 'FLEET_BASH_CHANNEL_MARKER';
|
|
11
|
+
const BASH_CHANNEL_HEREDOC_DELIM = 'FLEET_BASH_CHANNEL_EOF';
|
|
12
|
+
/**
|
|
13
|
+
* Whether registration should probe for a shell at all.
|
|
14
|
+
*
|
|
15
|
+
* Windows members only, and never when the operator supplied one explicitly --
|
|
16
|
+
* an explicit shell always wins over the probe result.
|
|
17
|
+
*/
|
|
18
|
+
export function shouldProbeShell(os, explicitShell) {
|
|
19
|
+
return os === 'windows' && !explicitShell;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reject bash.exe paths that are Windows' own WSL launcher rather than a real
|
|
23
|
+
* Git-for-Windows / MSYS install. Belt and braces: the uname check below is
|
|
24
|
+
* what actually proves the candidate, this just avoids spending a probe (and
|
|
25
|
+
* possibly a WSL first-run stall) on a known-bad path.
|
|
26
|
+
*/
|
|
27
|
+
export function isWslLauncherPath(candidatePath) {
|
|
28
|
+
const segments = candidatePath.replace(/\//g, '\\').toLowerCase().split('\\');
|
|
29
|
+
return segments.includes('system32') || segments.includes('sysnative') || segments.includes('windowsapps');
|
|
30
|
+
}
|
|
31
|
+
/** One round trip that lists every plausible Git-bash path that actually exists
|
|
32
|
+
* on the member: well-known install locations plus anything named bash.exe on
|
|
33
|
+
* PATH. Each line is prefixed so echoed-back input can never be mistaken for a
|
|
34
|
+
* result.
|
|
35
|
+
*
|
|
36
|
+
* The machine-wide well-known locations come from GIT_BASH_MACHINE_CANDIDATES
|
|
37
|
+
* (src/os/git-bash-candidates.ts), the SAME list windows-gitbash.ts's
|
|
38
|
+
* resolveGitBashPath consults for a local member -- one literal, two
|
|
39
|
+
* consumers, so the two can never drift apart again (apra-fleet-7dir.7). The
|
|
40
|
+
* LOCALAPPDATA (user-scope) candidate is still built with a PowerShell
|
|
41
|
+
* `Join-Path $env:LOCALAPPDATA ...` expression rather than a JS-side value,
|
|
42
|
+
* because it must resolve against the REMOTE member's LOCALAPPDATA, not this
|
|
43
|
+
* process's own. */
|
|
44
|
+
export function buildGitBashDiscoveryCommand() {
|
|
45
|
+
const machineCandidates = GIT_BASH_MACHINE_CANDIDATES
|
|
46
|
+
.map((p) => `'${p.replace(/'/g, "''")}'`)
|
|
47
|
+
.join(',');
|
|
48
|
+
const ps = [
|
|
49
|
+
`$c = @(${machineCandidates})`,
|
|
50
|
+
`if ($env:LOCALAPPDATA) { $c += (Join-Path $env:LOCALAPPDATA '${GIT_BASH_USER_SUFFIX.replace(/'/g, "''")}') }`,
|
|
51
|
+
`$c += @(Get-Command bash.exe -All -ErrorAction SilentlyContinue | ForEach-Object { $_.Source })`,
|
|
52
|
+
`$c | Where-Object { $_ -and (Test-Path -LiteralPath $_) } | Select-Object -Unique | ForEach-Object { Write-Output ('${BASH_CANDIDATE_MARKER}' + $_) }`,
|
|
53
|
+
].join('; ');
|
|
54
|
+
return wrapPowerShellEncoded(ps);
|
|
55
|
+
}
|
|
56
|
+
/** Smoke command for one Git-bash candidate: run the real binary and ask it what
|
|
57
|
+
* it is. `&` is the call operator -- without it PowerShell would merely echo the
|
|
58
|
+
* quoted path back, exit 0, and look like a success. */
|
|
59
|
+
export function buildGitBashProbeCommand(bashPath) {
|
|
60
|
+
const quoted = bashPath.replace(/'/g, "''");
|
|
61
|
+
return wrapPowerShellEncoded(`& '${quoted}' -lc 'uname -s'`);
|
|
62
|
+
}
|
|
63
|
+
/** Smoke command for PowerShell 7. Nested -EncodedCommand so neither our outer
|
|
64
|
+
* wrapper nor a cmd.exe default shell can eat the `$` before pwsh sees it. */
|
|
65
|
+
export function buildPwsh7ProbeCommand() {
|
|
66
|
+
const inner = Buffer.from(`Write-Output ('${PS_EDITION_MARKER}' + $PSVersionTable.PSEdition)`, 'utf16le').toString('base64');
|
|
67
|
+
return wrapPowerShellEncoded(`& pwsh -NoProfile -EncodedCommand ${inner}`);
|
|
68
|
+
}
|
|
69
|
+
/** Smoke command for Windows PowerShell 5.1. */
|
|
70
|
+
export function buildPowerShell5ProbeCommand() {
|
|
71
|
+
const inner = Buffer.from(`Write-Output ('${PS_MAJOR_MARKER}' + $PSVersionTable.PSVersion.Major)`, 'utf16le').toString('base64');
|
|
72
|
+
return wrapPowerShellEncoded(`& powershell -NoProfile -EncodedCommand ${inner}`);
|
|
73
|
+
}
|
|
74
|
+
/** Parse the discovery output into candidate paths, dropping WSL launchers. */
|
|
75
|
+
export function parseGitBashCandidates(stdout) {
|
|
76
|
+
const seen = new Set();
|
|
77
|
+
const out = [];
|
|
78
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
79
|
+
const trimmed = line.trim();
|
|
80
|
+
if (!trimmed.startsWith(BASH_CANDIDATE_MARKER))
|
|
81
|
+
continue;
|
|
82
|
+
const candidate = trimmed.slice(BASH_CANDIDATE_MARKER.length).trim();
|
|
83
|
+
if (!candidate || isWslLauncherPath(candidate))
|
|
84
|
+
continue;
|
|
85
|
+
const key = candidate.toLowerCase();
|
|
86
|
+
if (seen.has(key))
|
|
87
|
+
continue;
|
|
88
|
+
seen.add(key);
|
|
89
|
+
out.push(candidate);
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** Exit code AND stdout must both check out -- see constraint (1) above. */
|
|
94
|
+
export function isProvenGitBash(result) {
|
|
95
|
+
return result.code === 0 && isWindowsPosixUname(result.stdout);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Proves the RAW (unwrapped) exec channel itself is interpreted by a genuine
|
|
99
|
+
* Git-for-Windows/MSYS bash -- not merely that a bash.exe binary exists
|
|
100
|
+
* somewhere on the machine. This distinction only matters for a REMOTE (SSH)
|
|
101
|
+
* member: `ssh.ts`'s execCommand hands the command string straight to the
|
|
102
|
+
* member's sshd, which runs it through whatever ITS OWN DefaultShell is
|
|
103
|
+
* configured to be -- a Git-bash binary being installed proves nothing about
|
|
104
|
+
* that, since every other probe above (isProvenGitBash included) is
|
|
105
|
+
* deliberately wrapped in `powershell -EncodedCommand ...` so it survives
|
|
106
|
+
* regardless of the connection's real default shell. A local member has no
|
|
107
|
+
* such gap (LocalStrategy spawns the resolved bash.exe path directly, see
|
|
108
|
+
* strategy.ts), so this check is remote-transport-only.
|
|
109
|
+
*
|
|
110
|
+
* Deliberately NOT wrapPowerShellEncoded -- wrapping would defeat the whole
|
|
111
|
+
* point of testing what interprets an unwrapped string. Heredoc syntax
|
|
112
|
+
* (`<<`) is rejected outright by both cmd.exe and PowerShell, making it a
|
|
113
|
+
* clean interpreter discriminator; chaining `&& uname -s` onto it in the
|
|
114
|
+
* SAME round trip reuses the existing MINGW/MSYS/CYGWIN-vs-WSL uname check
|
|
115
|
+
* (isWindowsPosixUname) to rule out a WSL bash.exe DefaultShell the same way
|
|
116
|
+
* the binary-existence path above already does for local members.
|
|
117
|
+
*/
|
|
118
|
+
export function buildRemoteBashChannelProbeCommand() {
|
|
119
|
+
return `cat <<'${BASH_CHANNEL_HEREDOC_DELIM}' && uname -s\n${BASH_CHANNEL_MARKER_LINE}\n${BASH_CHANNEL_HEREDOC_DELIM}`;
|
|
120
|
+
}
|
|
121
|
+
/** Exit code, the literal marker line, AND a proven-POSIX uname line right
|
|
122
|
+
* after it must all be present -- tolerates CRLF/blank-line noise a real
|
|
123
|
+
* SSH round trip can introduce. */
|
|
124
|
+
export function isProvenRemoteBashChannel(result) {
|
|
125
|
+
if (result.code !== 0)
|
|
126
|
+
return false;
|
|
127
|
+
const lines = result.stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
128
|
+
const markerIdx = lines.indexOf(BASH_CHANNEL_MARKER_LINE);
|
|
129
|
+
if (markerIdx === -1 || markerIdx + 1 >= lines.length)
|
|
130
|
+
return false;
|
|
131
|
+
return isWindowsPosixUname(lines[markerIdx + 1]);
|
|
132
|
+
}
|
|
133
|
+
export function isProvenPwsh7(result) {
|
|
134
|
+
return result.code === 0 && /PSEDITION:\s*Core/i.test(result.stdout);
|
|
135
|
+
}
|
|
136
|
+
export function isProvenPowerShell5(result) {
|
|
137
|
+
return result.code === 0 && /PSMAJOR:\s*5/.test(result.stdout);
|
|
138
|
+
}
|
|
139
|
+
const FAILED = { stdout: '', stderr: '', code: 1 };
|
|
140
|
+
async function safeExec(exec, command) {
|
|
141
|
+
try {
|
|
142
|
+
const r = await exec(command, SHELL_PROBE_TIMEOUT_MS);
|
|
143
|
+
return { stdout: r?.stdout ?? '', stderr: r?.stderr ?? '', code: r?.code ?? 1 };
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return FAILED;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Probe a Windows member for its shell, in order: Git bash, then PowerShell 7,
|
|
151
|
+
* then PowerShell 5.1. Returns the FIRST candidate proven working by a real
|
|
152
|
+
* smoke command (exit code AND stdout both checked).
|
|
153
|
+
*
|
|
154
|
+
* `transport` distinguishes a local member (LocalStrategy spawns the
|
|
155
|
+
* resolved bash.exe path directly -- binary existence is sufficient proof)
|
|
156
|
+
* from a remote/SSH member (raw command strings are handed straight to the
|
|
157
|
+
* member's own sshd DefaultShell -- binary existence proves nothing about
|
|
158
|
+
* what that connection actually executes; see isProvenRemoteBashChannel's
|
|
159
|
+
* doc comment). Defaults to 'local' so every existing local-member call site
|
|
160
|
+
* and test keeps its current behaviour unchanged.
|
|
161
|
+
*
|
|
162
|
+
* Never throws and never fails registration: if nothing can be proven it
|
|
163
|
+
* degrades to powershell5 -- the shell Windows always has and the value that
|
|
164
|
+
* yields byte-identical command strings to the pre-probe behaviour -- with a
|
|
165
|
+
* warning for the caller to surface.
|
|
166
|
+
*/
|
|
167
|
+
export async function probeWindowsShell(exec, transport = 'local') {
|
|
168
|
+
const discovery = await safeExec(exec, buildGitBashDiscoveryCommand());
|
|
169
|
+
const candidates = discovery.code === 0 ? parseGitBashCandidates(discovery.stdout) : [];
|
|
170
|
+
let gitBashBinaryProven = false;
|
|
171
|
+
for (const candidate of candidates) {
|
|
172
|
+
if (isProvenGitBash(await safeExec(exec, buildGitBashProbeCommand(candidate)))) {
|
|
173
|
+
gitBashBinaryProven = true;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (gitBashBinaryProven) {
|
|
178
|
+
const channelConfirmed = transport === 'local'
|
|
179
|
+
|| isProvenRemoteBashChannel(await safeExec(exec, buildRemoteBashChannelProbeCommand()));
|
|
180
|
+
if (channelConfirmed)
|
|
181
|
+
return { shell: 'gitbash' };
|
|
182
|
+
}
|
|
183
|
+
// Reached only when gitbash could not be confirmed for this transport --
|
|
184
|
+
// either no binary was proven at all, or (ssh only) one was proven but the
|
|
185
|
+
// connection's own default shell isn't actually bash. Fall through to
|
|
186
|
+
// PowerShell 7 / 5.1 below as before; if this specifically was the
|
|
187
|
+
// "binary exists but wrong default shell" case, attach a warning
|
|
188
|
+
// identifying that even when a shell IS successfully proven, since it is
|
|
189
|
+
// operator-actionable information the plain success path would otherwise
|
|
190
|
+
// swallow silently.
|
|
191
|
+
const gitBashUnreachableWarning = (transport === 'ssh' && gitBashBinaryProven)
|
|
192
|
+
? 'Git bash is installed on this member but is not this connection\'s default shell '
|
|
193
|
+
+ '(its SSH server\'s configured DefaultShell) -- using PowerShell dialect instead. To use '
|
|
194
|
+
+ 'gitbash command strings, set the remote SSH DefaultShell to bash.exe, or set shell '
|
|
195
|
+
+ 'explicitly with update_member.'
|
|
196
|
+
: undefined;
|
|
197
|
+
if (isProvenPwsh7(await safeExec(exec, buildPwsh7ProbeCommand()))) {
|
|
198
|
+
return gitBashUnreachableWarning ? { shell: 'pwsh7', warning: gitBashUnreachableWarning } : { shell: 'pwsh7' };
|
|
199
|
+
}
|
|
200
|
+
if (isProvenPowerShell5(await safeExec(exec, buildPowerShell5ProbeCommand()))) {
|
|
201
|
+
return gitBashUnreachableWarning ? { shell: 'powershell5', warning: gitBashUnreachableWarning } : { shell: 'powershell5' };
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
shell: 'powershell5',
|
|
205
|
+
warning: gitBashUnreachableWarning
|
|
206
|
+
?? ('Could not verify which Windows shell this member uses -- assuming Windows PowerShell 5.1. '
|
|
207
|
+
+ 'If this member should use Git bash or PowerShell 7, set it explicitly with update_member.'),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=shell-probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-probe.js","sourceRoot":"","sources":["../../src/services/shell-probe.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAkBjG;qDACqD;AACrD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAC1C,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,eAAe,GAAG,UAAU,CAAC;AACnC,MAAM,wBAAwB,GAAG,2BAA2B,CAAC;AAC7D,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAwB,EAAE,aAA2B;IACpF,OAAO,EAAE,KAAK,SAAS,IAAI,CAAC,aAAa,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAqB;IACrD,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9E,OAAO,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAC7G,CAAC;AAED;;;;;;;;;;;;qBAYqB;AAC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K,EAAE,OAAO,EAAE,CAAC;IACjH,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,4BAA4B,EAAE,CAAC,CAAC,EAAE,CAAC;QAC9E,OAAO,yBAAyB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IAC7H,CAAC;IAED,OAAO;QACL,KAAK,EAAE,aAAa;QACpB,OAAO,EAAE,yBAAyB;eAC7B,CAAC,4FAA4F;kBAC5F,2FAA2F,CAAC;KACnG,CAAC;AACJ,CAAC"}
|
|
@@ -2,6 +2,8 @@ export interface RunningInstance {
|
|
|
2
2
|
running: true;
|
|
3
3
|
url: string;
|
|
4
4
|
pid: number;
|
|
5
|
+
/** Version reported by the running server's server.json, or undefined if it predates this field. */
|
|
6
|
+
version?: string;
|
|
5
7
|
}
|
|
6
8
|
export type InstanceCheckResult = RunningInstance | {
|
|
7
9
|
running: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/services/singleton.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,IAAI,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/services/singleton.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,IAAI,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAcD,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAwBzE;AAED,wBAAgB,gBAAgB,IAAI,WAAW,CAmC9C"}
|
|
@@ -52,7 +52,7 @@ export async function checkRunningInstance() {
|
|
|
52
52
|
catch { }
|
|
53
53
|
return { running: false };
|
|
54
54
|
}
|
|
55
|
-
return { running: true, url: info.url, pid: info.pid };
|
|
55
|
+
return { running: true, url: info.url, pid: info.pid, version: info.version };
|
|
56
56
|
}
|
|
57
57
|
export function claimStartupLock() {
|
|
58
58
|
const fleetDir = getFleetDir();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.js","sourceRoot":"","sources":["../../src/services/singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,8FAA8F;AAC9F,SAAS,WAAW;IAClB,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;AAC3F,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,iBAAiB,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"singleton.js","sourceRoot":"","sources":["../../src/services/singleton.ts"],"names":[],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;oBACP,sEAAsE;gBACxE,CAAC;YACH,CAAC;YACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/services/ssh.js
CHANGED
|
@@ -5,7 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import { v4 as uuid } from 'uuid';
|
|
6
6
|
import { decryptPassword } from '../utils/crypto.js';
|
|
7
7
|
import { verifyHostKey, replaceKnownHost, HostKeyMismatchError } from './known-hosts.js';
|
|
8
|
-
import { setStoredPid, clearStoredPid, getAgentOS } from '../utils/agent-helpers.js';
|
|
8
|
+
import { setStoredPid, clearStoredPid, getAgentOS, getAgentShell } from '../utils/agent-helpers.js';
|
|
9
9
|
import { getOsCommands } from '../os/index.js';
|
|
10
10
|
const MAX_OUTPUT_BYTES = 10 * 1024 * 1024; // 10 MB
|
|
11
11
|
const pool = new Map();
|
|
@@ -152,7 +152,7 @@ export async function execCommand(agent, command, timeoutMs = 30000, maxTotalMs,
|
|
|
152
152
|
if (capturedPid === undefined)
|
|
153
153
|
return;
|
|
154
154
|
try {
|
|
155
|
-
const killCmd = getOsCommands(getAgentOS(agent)).killPid(capturedPid);
|
|
155
|
+
const killCmd = getOsCommands(getAgentOS(agent), getAgentShell(agent)).killPid(capturedPid);
|
|
156
156
|
// Best-effort, fire-and-forget on a FRESH channel -- the timed-out
|
|
157
157
|
// command's own channel may itself be wedged and must not be relied
|
|
158
158
|
// on to carry the kill.
|