kernelbot 1.0.18 → 1.0.20
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 +1 -1
- package/src/coder.js +23 -18
package/package.json
CHANGED
package/src/coder.js
CHANGED
|
@@ -146,23 +146,26 @@ export class ClaudeCodeSpawner {
|
|
|
146
146
|
|
|
147
147
|
ensureClaudeCodeSetup();
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
const args = [
|
|
150
|
+
'-p', prompt,
|
|
151
|
+
'--max-turns', String(turns),
|
|
152
|
+
'--output-format', 'stream-json',
|
|
153
|
+
'--verbose',
|
|
154
|
+
'--dangerously-skip-permissions',
|
|
155
|
+
];
|
|
156
|
+
if (this.model) {
|
|
157
|
+
args.push('--model', this.model);
|
|
158
|
+
}
|
|
151
159
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
'--output-format', 'stream-json',
|
|
157
|
-
'--dangerously-skip-permissions',
|
|
158
|
-
];
|
|
159
|
-
if (this.model) {
|
|
160
|
-
args.push('--model', this.model);
|
|
161
|
-
}
|
|
160
|
+
const cmd = `claude ${args.map((a) => a.includes(' ') ? `"${a}"` : a).join(' ')}`;
|
|
161
|
+
logger.info(`Spawning: ${cmd.slice(0, 300)}`);
|
|
162
|
+
logger.info(`CWD: ${workingDirectory}`);
|
|
163
|
+
if (onOutput) onOutput(`⏳ Starting Claude Code...\n\`${cmd.slice(0, 200)}\``).catch(() => {});
|
|
162
164
|
|
|
165
|
+
return new Promise((resolve, reject) => {
|
|
163
166
|
const child = spawn('claude', args, {
|
|
164
167
|
cwd: workingDirectory,
|
|
165
|
-
env: { ...process.env },
|
|
168
|
+
env: { ...process.env, IS_SANDBOX: '1' },
|
|
166
169
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
167
170
|
});
|
|
168
171
|
|
|
@@ -183,7 +186,6 @@ export class ClaudeCodeSpawner {
|
|
|
183
186
|
|
|
184
187
|
fullOutput += trimmed + '\n';
|
|
185
188
|
|
|
186
|
-
// Try to extract result text
|
|
187
189
|
try {
|
|
188
190
|
const event = JSON.parse(trimmed);
|
|
189
191
|
if (event.type === 'result') {
|
|
@@ -196,10 +198,13 @@ export class ClaudeCodeSpawner {
|
|
|
196
198
|
});
|
|
197
199
|
|
|
198
200
|
child.stderr.on('data', (data) => {
|
|
199
|
-
const chunk = data.toString();
|
|
200
|
-
stderr += chunk;
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
const chunk = data.toString().trim();
|
|
202
|
+
stderr += chunk + '\n';
|
|
203
|
+
logger.warn(`Claude Code stderr: ${chunk.slice(0, 300)}`);
|
|
204
|
+
// Forward ALL stderr to Telegram immediately
|
|
205
|
+
if (onOutput && chunk) {
|
|
206
|
+
onOutput(`⚠️ Claude Code: ${chunk.slice(0, 400)}`).catch(() => {});
|
|
207
|
+
}
|
|
203
208
|
});
|
|
204
209
|
|
|
205
210
|
const timer = setTimeout(() => {
|