@xynogen/pix-ssh 0.6.2 → 0.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-ssh",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Pi tool \u2014 ssh_run: run remote commands over SSH with password/key auth and remote sudo",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -266,12 +266,12 @@ function approvalTitle({ action, direction, reason }: SshOperation): string {
266
266
  }
267
267
 
268
268
  function approvalBody(operation: SshOperation, host: string, port?: number): string[] {
269
- const { action, command, destination, direction, reason, recursive, source, sudo } = operation;
269
+ const { action, destination, direction, reason, recursive, source } = operation;
270
270
  return [
271
271
  ...(reason?.trim() ? [] : ["No reason provided by AI"]),
272
272
  `Host: ${host}${port ? ` (port ${port})` : ""}`,
273
273
  ...(action === "command"
274
- ? [`Command: ${sudo ? "sudo " : ""}${command}`]
274
+ ? ["Review the command in the tool card below."]
275
275
  : [
276
276
  `Direction: ${direction === "download" ? "Download" : "Upload"}`,
277
277
  `From: ${source}`,
@@ -799,7 +799,6 @@ export default function (pi: ExtensionAPI): void {
799
799
  const overlayResult = await runOverlay();
800
800
  if (overlayResult.passwordAttemptsExhausted) {
801
801
  const text = `SSH authentication failed after ${MAX_PASSWORD_ATTEMPTS} attempts — wrong password.`;
802
- ctx.ui.notify(`🔐 ${text}`, "error");
803
802
  return {
804
803
  content: [{ type: "text", text }],
805
804
  details: makeDetails(command, host, sudo, reason, {
@@ -814,7 +813,6 @@ export default function (pi: ExtensionAPI): void {
814
813
  ((needLogin && !collected.login) || (needSudo && !collected.sudo));
815
814
  if (overlayResult.action !== "approved" || missing) {
816
815
  const r = cancelResult(command, host, sudo, reason, overlayResult.action);
817
- ctx.ui.notify(`🔐 ${r.content[0]?.text}`, "warning");
818
816
  return r;
819
817
  }
820
818
 
@@ -909,7 +907,6 @@ export default function (pi: ExtensionAPI): void {
909
907
  // next call re-prompts.
910
908
  if (detectSshFailure(result.code, result.stderr)) {
911
909
  credCache.delete(key);
912
- ctx.ui.notify("🔐 SSH authentication failed", "error");
913
910
  return {
914
911
  content: [{ type: "text", text: `SSH authentication failed:\n${result.stderr}` }],
915
912
  details: makeDetails(command, host, sudo, reason, {
@@ -926,7 +923,6 @@ export default function (pi: ExtensionAPI): void {
926
923
  // Remote sudo password failure → drop the bad sudo password.
927
924
  if (sudo && detectSudoFailure(result.stderr)) {
928
925
  credCache.set(key, loginPassword ? { loginPassword } : {});
929
- ctx.ui.notify("🔐 Remote sudo authentication failed", "error");
930
926
  return {
931
927
  content: [{ type: "text", text: `Remote sudo authentication failed:\n${result.stderr}` }],
932
928
  details: makeDetails(command, host, sudo, reason, {
package/src/lib.ts CHANGED
@@ -89,6 +89,7 @@ export function parseHost(spec: string): HostSpec {
89
89
  const colons = rest.split(":").length - 1;
90
90
  if (rest.startsWith("[")) {
91
91
  const end = rest.indexOf("]");
92
+ if (end === -1) throw new Error(`Invalid host: ${spec} (missing "]")`);
92
93
  const hostPart = rest.slice(1, end);
93
94
  const tail = rest.slice(end + 1);
94
95
  if (tail.startsWith(":")) port = parsePort(tail.slice(1));
@@ -100,6 +101,11 @@ export function parseHost(spec: string): HostSpec {
100
101
  }
101
102
 
102
103
  if (!rest) throw new Error(`Invalid host: ${spec}`);
104
+ // The target is a positional argv entry; a leading "-" would make ssh/scp
105
+ // read it as an option (e.g. -oProxyCommand=...), which runs a local command.
106
+ if (rest.startsWith("-") || user?.startsWith("-")) {
107
+ throw new Error(`Invalid host: ${spec} (host and user must not start with "-")`);
108
+ }
103
109
  return { user, host: rest, ...(port !== undefined ? { port } : {}) };
104
110
  }
105
111