| 737 | // (which persists under the remote's ~/.claude/projects/<cwd>/). |
| 738 | // --model controls which model the remote uses. |
| 739 | const extractFlag = (flag: string, opts: { |
| 740 | hasValue?: boolean; |
| 741 | as?: string; |
| 742 | } = {}) => { |
| 743 | const i = rawCliArgs.indexOf(flag); |
| 744 | if (i !== -1) { |
| 745 | _pendingSSH.extraCliArgs.push(opts.as ?? flag); |
| 746 | const val = rawCliArgs[i + 1]; |
| 747 | if (opts.hasValue && val && !val.startsWith('-')) { |
| 748 | _pendingSSH.extraCliArgs.push(val); |
| 749 | rawCliArgs.splice(i, 2); |
| 750 | } else { |
| 751 | rawCliArgs.splice(i, 1); |
| 752 | } |
| 753 | } |
| 754 | const eqI = rawCliArgs.findIndex(a => a.startsWith(`${flag}=`)); |
| 755 | if (eqI !== -1) { |
| 756 | _pendingSSH.extraCliArgs.push(opts.as ?? flag, rawCliArgs[eqI]!.slice(flag.length + 1)); |
| 757 | rawCliArgs.splice(eqI, 1); |
| 758 | } |
| 759 | }; |
| 760 | extractFlag('-c', { |
| 761 | as: '--continue' |
| 762 | }); |