tuna-agent 0.1.139 → 0.1.140

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.
@@ -103,7 +103,16 @@ export function runClaude(options) {
103
103
  const fileList = options.inputFiles.map(f => `- ${f}`).join('\n');
104
104
  prompt += `\n\n[User attached ${options.inputFiles.length} image(s). Read these files to see the images:]\n${fileList}`;
105
105
  }
106
- const args = ['-p', prompt, '--output-format', format];
106
+ // Interactive runs (permission protocol) must keep stdin free for y/n
107
+ // replies, so the prompt stays an argv. Non-interactive runs pipe the
108
+ // prompt via stdin instead: `claude -p` reads the prompt from stdin when
109
+ // no prompt arg is given. Passing a 40 KB+ clone prompt as an argv blows
110
+ // past ARG_MAX → spawn E2BIG. stdin has no such limit.
111
+ const useInteractiveStdin = !!options.permissionMode && !!options.onPermissionRequest;
112
+ const promptViaStdin = !useInteractiveStdin;
113
+ const args = promptViaStdin
114
+ ? ['-p', '--output-format', format]
115
+ : ['-p', prompt, '--output-format', format];
107
116
  if (options.allowedTools?.length) {
108
117
  args.push('--allowedTools', options.allowedTools.join(','));
109
118
  }
@@ -144,7 +153,6 @@ export function runClaude(options) {
144
153
  args.push('--include-partial-messages');
145
154
  }
146
155
  }
147
- const useInteractiveStdin = !!options.permissionMode && !!options.onPermissionRequest;
148
156
  console.log(`[claude-cli] Spawning with args: ${args.filter(a => !a.startsWith('sk-') && a.length < 200).join(' ')}`);
149
157
  const claudeBin = getClaudeBinPath();
150
158
  // Ensure PATH includes common bin dirs so shebang `#!/usr/bin/env node` resolves
@@ -174,9 +182,22 @@ export function runClaude(options) {
174
182
  }
175
183
  const proc = spawn(claudeBin, args, {
176
184
  cwd: options.cwd,
177
- stdio: [useInteractiveStdin ? 'pipe' : 'ignore', 'pipe', 'pipe'],
185
+ // stdin piped for both: interactive permission replies, or feeding the
186
+ // prompt to a non-interactive `claude -p`.
187
+ stdio: [(useInteractiveStdin || promptViaStdin) ? 'pipe' : 'ignore', 'pipe', 'pipe'],
178
188
  env: spawnEnv,
179
189
  });
190
+ // Feed the prompt via stdin for non-interactive runs (avoids argv E2BIG
191
+ // on large clone prompts). Write then close so `claude -p` starts.
192
+ if (promptViaStdin) {
193
+ try {
194
+ proc.stdin.write(prompt);
195
+ proc.stdin.end();
196
+ }
197
+ catch (e) {
198
+ console.error('[claude-cli] failed writing prompt to stdin:', e.message);
199
+ }
200
+ }
180
201
  // 30-minute timeout by default
181
202
  const timeoutMs = options.timeoutMs ?? 30 * 60 * 1000;
182
203
  const timeoutTimer = setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.139",
3
+ "version": "0.1.140",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"