tuna-agent 0.1.139 → 0.1.142
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.
|
@@ -33,7 +33,7 @@ export interface AppContext {
|
|
|
33
33
|
isWholeApp: boolean;
|
|
34
34
|
allFeatures: string[];
|
|
35
35
|
}
|
|
36
|
-
export declare function handleClaudePrompt(ws: AgentWebSocketClient, code: string, taskId: string, prompt: string, systemPrompt?: string): Promise<void>;
|
|
36
|
+
export declare function handleClaudePrompt(ws: AgentWebSocketClient, code: string, taskId: string, prompt: string, systemPrompt?: string, timeoutMs?: number): Promise<void>;
|
|
37
37
|
export declare function handleClaudePromptStream(ws: AgentWebSocketClient, code: string, taskId: string, prompt: string, systemPrompt?: string): Promise<void>;
|
|
38
38
|
export declare function handleGenerateIdeas(ws: AgentWebSocketClient, code: string, taskId: string, topic: string, styleName?: string, styleDesc?: string, language?: string, count?: number, ideasInstruction?: string, provider?: string, appContext?: AppContext): Promise<void>;
|
|
39
39
|
export declare function handleGenerateScript(ws: AgentWebSocketClient, code: string, taskId: string, idea: string, topic: string, style?: string, duration?: number, language?: string, styleName?: string, styleGuidance?: string, provider?: string): Promise<void>;
|
|
@@ -65,7 +65,7 @@ function hasContentCreator() {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
// ─── Handler: claude_prompt (generic prompt → JSON result) ──────────────────
|
|
68
|
-
export async function handleClaudePrompt(ws, code, taskId, prompt, systemPrompt) {
|
|
68
|
+
export async function handleClaudePrompt(ws, code, taskId, prompt, systemPrompt, timeoutMs) {
|
|
69
69
|
console.log(`[claude_prompt] Received: ${prompt.substring(0, 100)}...`);
|
|
70
70
|
if (!hasContentCreator()) {
|
|
71
71
|
const error = 'content-creator agent not found on this machine';
|
|
@@ -80,7 +80,9 @@ export async function handleClaudePrompt(ws, code, taskId, prompt, systemPrompt)
|
|
|
80
80
|
cwd: CONTENT_CREATOR_DIR,
|
|
81
81
|
maxTurns: 1,
|
|
82
82
|
outputFormat: 'json',
|
|
83
|
-
|
|
83
|
+
// Caller-provided timeout (channel-manager passes 900000 for clone
|
|
84
|
+
// batches; AI-Suggest etc. omit it → 60s default preserved).
|
|
85
|
+
timeoutMs: timeoutMs && timeoutMs > 0 ? timeoutMs : 60000,
|
|
84
86
|
});
|
|
85
87
|
const text = typeof result === 'string' ? result : result.result || JSON.stringify(result);
|
|
86
88
|
console.log(`[claude_prompt] Result: ${text.substring(0, 200)}`);
|
package/dist/daemon/index.js
CHANGED
|
@@ -561,7 +561,7 @@ ${skillContent.slice(0, 15000)}`;
|
|
|
561
561
|
}
|
|
562
562
|
if (extTask === 'claude_prompt') {
|
|
563
563
|
(async () => {
|
|
564
|
-
await handleClaudePrompt(ws, extCode, extTaskId, msg.prompt, msg.systemPrompt);
|
|
564
|
+
await handleClaudePrompt(ws, extCode, extTaskId, msg.prompt, msg.systemPrompt, typeof msg.timeoutMs === 'number' ? msg.timeoutMs : undefined);
|
|
565
565
|
})();
|
|
566
566
|
break;
|
|
567
567
|
}
|
package/dist/utils/claude-cli.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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(() => {
|