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