oh-my-claude-sisyphus 3.2.3 → 3.3.0
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/README.md +37 -2
- package/agents/scientist-high.md +1003 -0
- package/agents/scientist-low.md +232 -0
- package/agents/scientist.md +1180 -0
- package/bridge/__pycache__/gyoshu_bridge.cpython-310.pyc +0 -0
- package/bridge/gyoshu_bridge.py +846 -0
- package/commands/autopilot.md +51 -3
- package/commands/ralph.md +17 -2
- package/commands/ultrawork.md +18 -1
- package/dist/__tests__/installer.test.js +1 -1
- package/dist/agents/definitions.d.ts +9 -0
- package/dist/agents/definitions.d.ts.map +1 -1
- package/dist/agents/definitions.js +25 -0
- package/dist/agents/definitions.js.map +1 -1
- package/dist/agents/index.d.ts +2 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +2 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/scientist.d.ts +16 -0
- package/dist/agents/scientist.d.ts.map +1 -0
- package/dist/agents/scientist.js +370 -0
- package/dist/agents/scientist.js.map +1 -0
- package/dist/hooks/omc-orchestrator/audit.d.ts +30 -0
- package/dist/hooks/omc-orchestrator/audit.d.ts.map +1 -0
- package/dist/hooks/omc-orchestrator/audit.js +66 -0
- package/dist/hooks/omc-orchestrator/audit.js.map +1 -0
- package/dist/hooks/omc-orchestrator/constants.d.ts +6 -2
- package/dist/hooks/omc-orchestrator/constants.d.ts.map +1 -1
- package/dist/hooks/omc-orchestrator/constants.js +37 -1
- package/dist/hooks/omc-orchestrator/constants.js.map +1 -1
- package/dist/hooks/omc-orchestrator/index.d.ts +4 -0
- package/dist/hooks/omc-orchestrator/index.d.ts.map +1 -1
- package/dist/hooks/omc-orchestrator/index.js +34 -3
- package/dist/hooks/omc-orchestrator/index.js.map +1 -1
- package/dist/installer/hooks.d.ts +18 -0
- package/dist/installer/hooks.d.ts.map +1 -1
- package/dist/installer/hooks.js +24 -0
- package/dist/installer/hooks.js.map +1 -1
- package/dist/installer/index.d.ts +1 -1
- package/dist/installer/index.js +1 -1
- package/dist/lib/atomic-write.d.ts +29 -0
- package/dist/lib/atomic-write.d.ts.map +1 -0
- package/dist/lib/atomic-write.js +111 -0
- package/dist/lib/atomic-write.js.map +1 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/python-repl/bridge-manager.d.ts +65 -0
- package/dist/tools/python-repl/bridge-manager.d.ts.map +1 -0
- package/dist/tools/python-repl/bridge-manager.js +478 -0
- package/dist/tools/python-repl/bridge-manager.js.map +1 -0
- package/dist/tools/python-repl/index.d.ts +40 -0
- package/dist/tools/python-repl/index.d.ts.map +1 -0
- package/dist/tools/python-repl/index.js +36 -0
- package/dist/tools/python-repl/index.js.map +1 -0
- package/dist/tools/python-repl/paths.d.ts +84 -0
- package/dist/tools/python-repl/paths.d.ts.map +1 -0
- package/dist/tools/python-repl/paths.js +213 -0
- package/dist/tools/python-repl/paths.js.map +1 -0
- package/dist/tools/python-repl/session-lock.d.ts +111 -0
- package/dist/tools/python-repl/session-lock.d.ts.map +1 -0
- package/dist/tools/python-repl/session-lock.js +510 -0
- package/dist/tools/python-repl/session-lock.js.map +1 -0
- package/dist/tools/python-repl/socket-client.d.ts +42 -0
- package/dist/tools/python-repl/socket-client.d.ts.map +1 -0
- package/dist/tools/python-repl/socket-client.js +157 -0
- package/dist/tools/python-repl/socket-client.js.map +1 -0
- package/dist/tools/python-repl/tool.d.ts +100 -0
- package/dist/tools/python-repl/tool.d.ts.map +1 -0
- package/dist/tools/python-repl/tool.js +575 -0
- package/dist/tools/python-repl/tool.js.map +1 -0
- package/dist/tools/python-repl/types.d.ts +95 -0
- package/dist/tools/python-repl/types.d.ts.map +1 -0
- package/dist/tools/python-repl/types.js +2 -0
- package/dist/tools/python-repl/types.js.map +1 -0
- package/docs/CLAUDE.md +31 -0
- package/package.json +2 -1
- package/skills/deepinit/SKILL.md +1 -1
- package/skills/hud/SKILL.md +2 -0
- package/skills/research/SKILL.md +511 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python REPL Tool - Main handler implementation
|
|
3
|
+
*
|
|
4
|
+
* Provides a persistent Python REPL environment for code execution.
|
|
5
|
+
* JSON-RPC 2.0 over Unix socket with session locking and timeout escalation.
|
|
6
|
+
*
|
|
7
|
+
* Actions:
|
|
8
|
+
* - execute: Run Python code in the persistent environment
|
|
9
|
+
* - interrupt: Send interrupt to running code with signal escalation
|
|
10
|
+
* - reset: Clear the execution namespace
|
|
11
|
+
* - get_state: Get memory usage and variable list
|
|
12
|
+
*
|
|
13
|
+
* @module python-repl/tool
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import { validatePathSegment } from './paths.js';
|
|
17
|
+
import { SessionLock, LockTimeoutError } from './session-lock.js';
|
|
18
|
+
import { sendSocketRequest, SocketConnectionError, SocketTimeoutError, JsonRpcError } from './socket-client.js';
|
|
19
|
+
import { ensureBridge, killBridgeWithEscalation, spawnBridgeServer } from './bridge-manager.js';
|
|
20
|
+
// =============================================================================
|
|
21
|
+
// CONSTANTS
|
|
22
|
+
// =============================================================================
|
|
23
|
+
const DEFAULT_EXECUTION_TIMEOUT_MS = 300000; // 5 minutes
|
|
24
|
+
const DEFAULT_QUEUE_TIMEOUT_MS = 30000; // 30 seconds
|
|
25
|
+
// JSON-RPC error codes
|
|
26
|
+
const ERROR_INVALID_ACTION = -32600;
|
|
27
|
+
const ERROR_QUEUE_TIMEOUT = -32004;
|
|
28
|
+
const ERROR_BRIDGE_FAILED = -32005;
|
|
29
|
+
// =============================================================================
|
|
30
|
+
// ZOD SCHEMA
|
|
31
|
+
// =============================================================================
|
|
32
|
+
/**
|
|
33
|
+
* Input schema for the Python REPL tool.
|
|
34
|
+
* Validates and types all input parameters.
|
|
35
|
+
*/
|
|
36
|
+
export const pythonReplSchema = z.object({
|
|
37
|
+
action: z
|
|
38
|
+
.enum(['execute', 'interrupt', 'reset', 'get_state'])
|
|
39
|
+
.describe('Action to perform: ' +
|
|
40
|
+
'execute (run Python code), ' +
|
|
41
|
+
'interrupt (stop running code), ' +
|
|
42
|
+
'reset (clear namespace), ' +
|
|
43
|
+
'get_state (memory and variables)'),
|
|
44
|
+
researchSessionID: z
|
|
45
|
+
.string()
|
|
46
|
+
.min(1, 'researchSessionID is required')
|
|
47
|
+
.describe('Unique identifier for the research session'),
|
|
48
|
+
code: z
|
|
49
|
+
.string()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('Python code to execute (required for "execute" action)'),
|
|
52
|
+
executionLabel: z
|
|
53
|
+
.string()
|
|
54
|
+
.optional()
|
|
55
|
+
.describe('Human-readable label for this code execution. ' +
|
|
56
|
+
'Examples: "Load dataset", "Train model", "Generate plot"'),
|
|
57
|
+
executionTimeout: z
|
|
58
|
+
.number()
|
|
59
|
+
.positive()
|
|
60
|
+
.default(DEFAULT_EXECUTION_TIMEOUT_MS)
|
|
61
|
+
.describe('Timeout for code execution in milliseconds (default: 300000 = 5 min)'),
|
|
62
|
+
queueTimeout: z
|
|
63
|
+
.number()
|
|
64
|
+
.positive()
|
|
65
|
+
.default(DEFAULT_QUEUE_TIMEOUT_MS)
|
|
66
|
+
.describe('Timeout for acquiring session lock in milliseconds (default: 30000 = 30 sec)'),
|
|
67
|
+
projectDir: z
|
|
68
|
+
.string()
|
|
69
|
+
.optional()
|
|
70
|
+
.describe('Project directory containing .venv/. Defaults to current working directory.'),
|
|
71
|
+
});
|
|
72
|
+
// =============================================================================
|
|
73
|
+
// EXECUTION COUNTER
|
|
74
|
+
// =============================================================================
|
|
75
|
+
const executionCounters = new Map();
|
|
76
|
+
/**
|
|
77
|
+
* Get and increment the execution counter for a session.
|
|
78
|
+
* Used for tracking execution order in a session.
|
|
79
|
+
*/
|
|
80
|
+
function getNextExecutionCount(sessionId) {
|
|
81
|
+
const current = executionCounters.get(sessionId) || 0;
|
|
82
|
+
const next = current + 1;
|
|
83
|
+
executionCounters.set(sessionId, next);
|
|
84
|
+
return next;
|
|
85
|
+
}
|
|
86
|
+
// =============================================================================
|
|
87
|
+
// OUTPUT FORMATTING
|
|
88
|
+
// =============================================================================
|
|
89
|
+
/**
|
|
90
|
+
* Format execution result into a readable string for Claude.
|
|
91
|
+
*/
|
|
92
|
+
function formatExecuteResult(result, sessionId, executionLabel, executionCount) {
|
|
93
|
+
const lines = [];
|
|
94
|
+
lines.push('=== Python REPL Execution ===');
|
|
95
|
+
lines.push(`Session: ${sessionId}`);
|
|
96
|
+
if (executionLabel) {
|
|
97
|
+
lines.push(`Label: ${executionLabel}`);
|
|
98
|
+
}
|
|
99
|
+
if (executionCount !== undefined) {
|
|
100
|
+
lines.push(`Execution #: ${executionCount}`);
|
|
101
|
+
}
|
|
102
|
+
lines.push('');
|
|
103
|
+
// Output section
|
|
104
|
+
if (result.stdout) {
|
|
105
|
+
lines.push('--- Output ---');
|
|
106
|
+
lines.push(result.stdout.trimEnd());
|
|
107
|
+
lines.push('');
|
|
108
|
+
}
|
|
109
|
+
// Errors section
|
|
110
|
+
if (result.stderr) {
|
|
111
|
+
lines.push('--- Errors ---');
|
|
112
|
+
lines.push(result.stderr.trimEnd());
|
|
113
|
+
lines.push('');
|
|
114
|
+
}
|
|
115
|
+
// Markers section (scientific findings, statistics, etc.)
|
|
116
|
+
if (result.markers && result.markers.length > 0) {
|
|
117
|
+
lines.push('--- Markers ---');
|
|
118
|
+
for (const marker of result.markers) {
|
|
119
|
+
const subtypeStr = marker.subtype ? `:${marker.subtype}` : '';
|
|
120
|
+
lines.push(`[${marker.type}${subtypeStr}] ${marker.content}`);
|
|
121
|
+
}
|
|
122
|
+
lines.push('');
|
|
123
|
+
}
|
|
124
|
+
// Timing section
|
|
125
|
+
if (result.timing) {
|
|
126
|
+
lines.push('--- Timing ---');
|
|
127
|
+
const durationSec = (result.timing.duration_ms / 1000).toFixed(3);
|
|
128
|
+
lines.push(`Duration: ${durationSec}s`);
|
|
129
|
+
lines.push(`Started: ${result.timing.started_at}`);
|
|
130
|
+
lines.push('');
|
|
131
|
+
}
|
|
132
|
+
// Memory section
|
|
133
|
+
if (result.memory) {
|
|
134
|
+
lines.push('--- Memory ---');
|
|
135
|
+
lines.push(`RSS: ${result.memory.rss_mb.toFixed(1)} MB`);
|
|
136
|
+
lines.push(`VMS: ${result.memory.vms_mb.toFixed(1)} MB`);
|
|
137
|
+
lines.push('');
|
|
138
|
+
}
|
|
139
|
+
// Error details section (for failed executions)
|
|
140
|
+
if (result.error) {
|
|
141
|
+
lines.push('=== Execution Failed ===');
|
|
142
|
+
lines.push(`Error Type: ${result.error.type}`);
|
|
143
|
+
lines.push(`Message: ${result.error.message}`);
|
|
144
|
+
if (result.error.traceback) {
|
|
145
|
+
lines.push('');
|
|
146
|
+
lines.push('Traceback:');
|
|
147
|
+
lines.push(result.error.traceback);
|
|
148
|
+
}
|
|
149
|
+
lines.push('');
|
|
150
|
+
}
|
|
151
|
+
lines.push(result.success ? '=== Execution Complete ===' : '=== Execution Failed ===');
|
|
152
|
+
return lines.join('\n');
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Format state result into a readable string.
|
|
156
|
+
*/
|
|
157
|
+
function formatStateResult(result, sessionId) {
|
|
158
|
+
const lines = [];
|
|
159
|
+
lines.push('=== Python REPL State ===');
|
|
160
|
+
lines.push(`Session: ${sessionId}`);
|
|
161
|
+
lines.push('');
|
|
162
|
+
lines.push('--- Memory ---');
|
|
163
|
+
lines.push(`RSS: ${result.memory.rss_mb.toFixed(1)} MB`);
|
|
164
|
+
lines.push(`VMS: ${result.memory.vms_mb.toFixed(1)} MB`);
|
|
165
|
+
lines.push('');
|
|
166
|
+
lines.push('--- Variables ---');
|
|
167
|
+
lines.push(`Count: ${result.variable_count}`);
|
|
168
|
+
if (result.variables.length > 0) {
|
|
169
|
+
lines.push('');
|
|
170
|
+
// Group variables, max 10 per line for readability
|
|
171
|
+
const chunks = [];
|
|
172
|
+
for (let i = 0; i < result.variables.length; i += 10) {
|
|
173
|
+
chunks.push(result.variables.slice(i, i + 10));
|
|
174
|
+
}
|
|
175
|
+
for (const chunk of chunks) {
|
|
176
|
+
lines.push(chunk.join(', '));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
lines.push('(no user variables defined)');
|
|
181
|
+
}
|
|
182
|
+
lines.push('');
|
|
183
|
+
lines.push('=== State Retrieved ===');
|
|
184
|
+
return lines.join('\n');
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Format reset result into a readable string.
|
|
188
|
+
*/
|
|
189
|
+
function formatResetResult(result, sessionId) {
|
|
190
|
+
const lines = [];
|
|
191
|
+
lines.push('=== Python REPL Reset ===');
|
|
192
|
+
lines.push(`Session: ${sessionId}`);
|
|
193
|
+
lines.push(`Status: ${result.status}`);
|
|
194
|
+
lines.push('');
|
|
195
|
+
lines.push('--- Memory After Reset ---');
|
|
196
|
+
lines.push(`RSS: ${result.memory.rss_mb.toFixed(1)} MB`);
|
|
197
|
+
lines.push(`VMS: ${result.memory.vms_mb.toFixed(1)} MB`);
|
|
198
|
+
lines.push('');
|
|
199
|
+
lines.push('=== Namespace Cleared ===');
|
|
200
|
+
return lines.join('\n');
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Format interrupt result into a readable string.
|
|
204
|
+
*/
|
|
205
|
+
function formatInterruptResult(result, sessionId) {
|
|
206
|
+
const lines = [];
|
|
207
|
+
lines.push('=== Python REPL Interrupt ===');
|
|
208
|
+
lines.push(`Session: ${sessionId}`);
|
|
209
|
+
lines.push(`Status: ${result.status}`);
|
|
210
|
+
if (result.terminatedBy) {
|
|
211
|
+
lines.push(`Terminated By: ${result.terminatedBy}`);
|
|
212
|
+
}
|
|
213
|
+
if (result.terminationTimeMs !== undefined) {
|
|
214
|
+
lines.push(`Termination Time: ${result.terminationTimeMs}ms`);
|
|
215
|
+
}
|
|
216
|
+
lines.push('');
|
|
217
|
+
lines.push('=== Execution Interrupted ===');
|
|
218
|
+
return lines.join('\n');
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Format a lock timeout error into a readable string.
|
|
222
|
+
*/
|
|
223
|
+
function formatLockTimeoutError(error, sessionId) {
|
|
224
|
+
const lines = [];
|
|
225
|
+
lines.push('=== Session Busy ===');
|
|
226
|
+
lines.push(`Session: ${sessionId}`);
|
|
227
|
+
lines.push('');
|
|
228
|
+
lines.push('The session is currently busy processing another request.');
|
|
229
|
+
lines.push(`Queue timeout: ${error.timeout}ms`);
|
|
230
|
+
lines.push('');
|
|
231
|
+
if (error.lastHolder) {
|
|
232
|
+
lines.push('Current holder:');
|
|
233
|
+
lines.push(` PID: ${error.lastHolder.pid}`);
|
|
234
|
+
lines.push(` Host: ${error.lastHolder.hostname}`);
|
|
235
|
+
lines.push(` Since: ${error.lastHolder.acquiredAt}`);
|
|
236
|
+
lines.push('');
|
|
237
|
+
}
|
|
238
|
+
lines.push('Suggestions:');
|
|
239
|
+
lines.push(' 1. Wait and retry later');
|
|
240
|
+
lines.push(' 2. Use the "interrupt" action to stop the current execution');
|
|
241
|
+
lines.push(' 3. Use the "reset" action to clear the session');
|
|
242
|
+
return lines.join('\n');
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Format a socket connection error into a readable string.
|
|
246
|
+
*/
|
|
247
|
+
function formatSocketError(error, sessionId) {
|
|
248
|
+
const lines = [];
|
|
249
|
+
lines.push('=== Connection Error ===');
|
|
250
|
+
lines.push(`Session: ${sessionId}`);
|
|
251
|
+
lines.push('');
|
|
252
|
+
lines.push(`Error: ${error.message}`);
|
|
253
|
+
lines.push(`Socket: ${error.socketPath}`);
|
|
254
|
+
lines.push('');
|
|
255
|
+
lines.push('Troubleshooting:');
|
|
256
|
+
lines.push(' 1. The bridge process may have crashed - retry will auto-restart');
|
|
257
|
+
lines.push(' 2. Use "reset" action to force restart the bridge');
|
|
258
|
+
lines.push(' 3. Ensure .venv exists with Python installed');
|
|
259
|
+
return lines.join('\n');
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Format a general error into a readable string.
|
|
263
|
+
*/
|
|
264
|
+
function formatGeneralError(error, sessionId, action) {
|
|
265
|
+
const lines = [];
|
|
266
|
+
lines.push('=== Error ===');
|
|
267
|
+
lines.push(`Session: ${sessionId}`);
|
|
268
|
+
lines.push(`Action: ${action}`);
|
|
269
|
+
lines.push('');
|
|
270
|
+
lines.push(`Type: ${error.name}`);
|
|
271
|
+
lines.push(`Message: ${error.message}`);
|
|
272
|
+
if (error.stack) {
|
|
273
|
+
lines.push('');
|
|
274
|
+
lines.push('Stack trace:');
|
|
275
|
+
lines.push(error.stack);
|
|
276
|
+
}
|
|
277
|
+
return lines.join('\n');
|
|
278
|
+
}
|
|
279
|
+
// =============================================================================
|
|
280
|
+
// ACTION HANDLERS
|
|
281
|
+
// =============================================================================
|
|
282
|
+
/**
|
|
283
|
+
* Handle the 'execute' action - run Python code.
|
|
284
|
+
*/
|
|
285
|
+
async function handleExecute(sessionId, socketPath, code, executionTimeout, executionLabel) {
|
|
286
|
+
const executionCount = getNextExecutionCount(sessionId);
|
|
287
|
+
try {
|
|
288
|
+
// Send execute request with extra time for response
|
|
289
|
+
const result = await sendSocketRequest(socketPath, 'execute', { code, timeout: executionTimeout / 1000 }, executionTimeout + 10000 // Allow extra time for response
|
|
290
|
+
);
|
|
291
|
+
return formatExecuteResult(result, sessionId, executionLabel, executionCount);
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
// Handle specific socket errors that might be recoverable
|
|
295
|
+
if (error instanceof SocketConnectionError) {
|
|
296
|
+
throw error; // Let the main handler retry with a new bridge
|
|
297
|
+
}
|
|
298
|
+
if (error instanceof SocketTimeoutError) {
|
|
299
|
+
// Execution timeout - the code took too long
|
|
300
|
+
return [
|
|
301
|
+
'=== Execution Timeout ===',
|
|
302
|
+
`Session: ${sessionId}`,
|
|
303
|
+
`Label: ${executionLabel || '(none)'}`,
|
|
304
|
+
'',
|
|
305
|
+
`The code execution exceeded the timeout of ${executionTimeout / 1000} seconds.`,
|
|
306
|
+
'',
|
|
307
|
+
'The execution is still running in the background.',
|
|
308
|
+
'Use the "interrupt" action to stop it.',
|
|
309
|
+
].join('\n');
|
|
310
|
+
}
|
|
311
|
+
if (error instanceof JsonRpcError) {
|
|
312
|
+
return [
|
|
313
|
+
'=== Execution Failed ===',
|
|
314
|
+
`Session: ${sessionId}`,
|
|
315
|
+
'',
|
|
316
|
+
`Error Code: ${error.code}`,
|
|
317
|
+
`Message: ${error.message}`,
|
|
318
|
+
error.data ? `Data: ${JSON.stringify(error.data, null, 2)}` : '',
|
|
319
|
+
]
|
|
320
|
+
.filter(Boolean)
|
|
321
|
+
.join('\n');
|
|
322
|
+
}
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Handle the 'reset' action - clear the namespace.
|
|
328
|
+
*/
|
|
329
|
+
async function handleReset(sessionId, socketPath) {
|
|
330
|
+
try {
|
|
331
|
+
const result = await sendSocketRequest(socketPath, 'reset', {}, 10000);
|
|
332
|
+
return formatResetResult(result, sessionId);
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
// If reset fails, try to kill and restart the bridge
|
|
336
|
+
await killBridgeWithEscalation(sessionId);
|
|
337
|
+
return [
|
|
338
|
+
'=== Bridge Restarted ===',
|
|
339
|
+
`Session: ${sessionId}`,
|
|
340
|
+
'',
|
|
341
|
+
'The bridge was unresponsive and has been terminated.',
|
|
342
|
+
'A new bridge will be spawned on the next request.',
|
|
343
|
+
'',
|
|
344
|
+
'Memory has been cleared.',
|
|
345
|
+
].join('\n');
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Handle the 'get_state' action - retrieve memory and variables.
|
|
350
|
+
*/
|
|
351
|
+
async function handleGetState(sessionId, socketPath) {
|
|
352
|
+
try {
|
|
353
|
+
const result = await sendSocketRequest(socketPath, 'get_state', {}, 5000);
|
|
354
|
+
return formatStateResult(result, sessionId);
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
if (error instanceof SocketConnectionError) {
|
|
358
|
+
throw error; // Let main handler deal with connection issues
|
|
359
|
+
}
|
|
360
|
+
if (error instanceof SocketTimeoutError) {
|
|
361
|
+
return [
|
|
362
|
+
'=== State Retrieval Timeout ===',
|
|
363
|
+
`Session: ${sessionId}`,
|
|
364
|
+
'',
|
|
365
|
+
'Could not retrieve state within timeout.',
|
|
366
|
+
'The bridge may be busy with a long-running execution.',
|
|
367
|
+
].join('\n');
|
|
368
|
+
}
|
|
369
|
+
throw error;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Handle the 'interrupt' action - stop running code with signal escalation.
|
|
374
|
+
*/
|
|
375
|
+
async function handleInterrupt(sessionId, socketPath, gracePeriodMs = 5000) {
|
|
376
|
+
// First try graceful interrupt via socket
|
|
377
|
+
try {
|
|
378
|
+
const result = await sendSocketRequest(socketPath, 'interrupt', {}, Math.min(gracePeriodMs, 5000));
|
|
379
|
+
return formatInterruptResult({
|
|
380
|
+
...result,
|
|
381
|
+
status: result.status || 'interrupted',
|
|
382
|
+
terminatedBy: 'graceful',
|
|
383
|
+
}, sessionId);
|
|
384
|
+
}
|
|
385
|
+
catch {
|
|
386
|
+
// Graceful interrupt failed - escalate with signals
|
|
387
|
+
const escalationResult = await killBridgeWithEscalation(sessionId, { gracePeriodMs });
|
|
388
|
+
return formatInterruptResult({
|
|
389
|
+
status: 'force_killed',
|
|
390
|
+
terminatedBy: escalationResult.terminatedBy,
|
|
391
|
+
terminationTimeMs: escalationResult.terminationTimeMs,
|
|
392
|
+
}, sessionId);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// =============================================================================
|
|
396
|
+
// MAIN HANDLER
|
|
397
|
+
// =============================================================================
|
|
398
|
+
/**
|
|
399
|
+
* Main handler for the Python REPL tool.
|
|
400
|
+
*
|
|
401
|
+
* @param input - Validated input from the tool call
|
|
402
|
+
* @returns Formatted string output for Claude
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```typescript
|
|
406
|
+
* const output = await pythonReplHandler({
|
|
407
|
+
* action: 'execute',
|
|
408
|
+
* researchSessionID: 'my-session',
|
|
409
|
+
* code: 'print("Hello, World!")',
|
|
410
|
+
* });
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
export async function pythonReplHandler(input) {
|
|
414
|
+
// Step 1: Validate input with Zod
|
|
415
|
+
const parseResult = pythonReplSchema.safeParse(input);
|
|
416
|
+
if (!parseResult.success) {
|
|
417
|
+
const errors = parseResult.error.errors.map((e) => `${e.path.join('.')}: ${e.message}`);
|
|
418
|
+
return [
|
|
419
|
+
'=== Validation Error ===',
|
|
420
|
+
'',
|
|
421
|
+
'Invalid input parameters:',
|
|
422
|
+
...errors.map((e) => ` - ${e}`),
|
|
423
|
+
].join('\n');
|
|
424
|
+
}
|
|
425
|
+
const { action, researchSessionID: sessionId, code, executionLabel, executionTimeout, queueTimeout, projectDir, } = parseResult.data;
|
|
426
|
+
// Step 2: Validate session ID (path traversal protection)
|
|
427
|
+
try {
|
|
428
|
+
validatePathSegment(sessionId, 'researchSessionID');
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
return [
|
|
432
|
+
'=== Invalid Session ID ===',
|
|
433
|
+
'',
|
|
434
|
+
`Error: ${error.message}`,
|
|
435
|
+
'',
|
|
436
|
+
'Session IDs must be safe path segments without:',
|
|
437
|
+
' - Path separators (/ or \\)',
|
|
438
|
+
' - Parent directory references (..)',
|
|
439
|
+
' - Null bytes',
|
|
440
|
+
' - Windows reserved names (CON, PRN, etc.)',
|
|
441
|
+
].join('\n');
|
|
442
|
+
}
|
|
443
|
+
// Step 3: Validate action-specific requirements
|
|
444
|
+
if (action === 'execute' && !code) {
|
|
445
|
+
return [
|
|
446
|
+
'=== Missing Code ===',
|
|
447
|
+
'',
|
|
448
|
+
'The "execute" action requires the "code" parameter.',
|
|
449
|
+
'',
|
|
450
|
+
'Example:',
|
|
451
|
+
' action: "execute"',
|
|
452
|
+
' code: "print(\'Hello!\')"',
|
|
453
|
+
].join('\n');
|
|
454
|
+
}
|
|
455
|
+
// Step 4: Acquire session lock
|
|
456
|
+
const lock = new SessionLock(sessionId);
|
|
457
|
+
try {
|
|
458
|
+
await lock.acquire(queueTimeout);
|
|
459
|
+
}
|
|
460
|
+
catch (error) {
|
|
461
|
+
if (error instanceof LockTimeoutError) {
|
|
462
|
+
return formatLockTimeoutError(error, sessionId);
|
|
463
|
+
}
|
|
464
|
+
return formatGeneralError(error, sessionId, action);
|
|
465
|
+
}
|
|
466
|
+
try {
|
|
467
|
+
// Step 5: Ensure bridge is running
|
|
468
|
+
let meta;
|
|
469
|
+
try {
|
|
470
|
+
meta = await ensureBridge(sessionId, projectDir);
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
return [
|
|
474
|
+
'=== Bridge Startup Failed ===',
|
|
475
|
+
`Session: ${sessionId}`,
|
|
476
|
+
'',
|
|
477
|
+
`Error: ${error.message}`,
|
|
478
|
+
'',
|
|
479
|
+
'Ensure you have a Python virtual environment:',
|
|
480
|
+
' python -m venv .venv',
|
|
481
|
+
' .venv/bin/pip install pandas numpy matplotlib',
|
|
482
|
+
].join('\n');
|
|
483
|
+
}
|
|
484
|
+
// Step 6: Dispatch to action handler
|
|
485
|
+
switch (action) {
|
|
486
|
+
case 'execute':
|
|
487
|
+
try {
|
|
488
|
+
return await handleExecute(sessionId, meta.socketPath, code, executionTimeout, executionLabel);
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
// On connection error, try respawning the bridge once
|
|
492
|
+
if (error instanceof SocketConnectionError) {
|
|
493
|
+
try {
|
|
494
|
+
meta = await spawnBridgeServer(sessionId, projectDir);
|
|
495
|
+
return await handleExecute(sessionId, meta.socketPath, code, executionTimeout, executionLabel);
|
|
496
|
+
}
|
|
497
|
+
catch (retryError) {
|
|
498
|
+
return formatSocketError(retryError instanceof SocketConnectionError
|
|
499
|
+
? retryError
|
|
500
|
+
: new SocketConnectionError(retryError.message, meta.socketPath), sessionId);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return formatGeneralError(error, sessionId, action);
|
|
504
|
+
}
|
|
505
|
+
case 'reset':
|
|
506
|
+
return await handleReset(sessionId, meta.socketPath);
|
|
507
|
+
case 'get_state':
|
|
508
|
+
try {
|
|
509
|
+
return await handleGetState(sessionId, meta.socketPath);
|
|
510
|
+
}
|
|
511
|
+
catch (error) {
|
|
512
|
+
if (error instanceof SocketConnectionError) {
|
|
513
|
+
return formatSocketError(error, sessionId);
|
|
514
|
+
}
|
|
515
|
+
return formatGeneralError(error, sessionId, action);
|
|
516
|
+
}
|
|
517
|
+
case 'interrupt':
|
|
518
|
+
return await handleInterrupt(sessionId, meta.socketPath);
|
|
519
|
+
default:
|
|
520
|
+
return [
|
|
521
|
+
'=== Unknown Action ===',
|
|
522
|
+
'',
|
|
523
|
+
`Received action: ${action}`,
|
|
524
|
+
'',
|
|
525
|
+
'Valid actions are:',
|
|
526
|
+
' - execute: Run Python code',
|
|
527
|
+
' - interrupt: Stop running code',
|
|
528
|
+
' - reset: Clear the namespace',
|
|
529
|
+
' - get_state: Get memory and variable info',
|
|
530
|
+
].join('\n');
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
finally {
|
|
534
|
+
// Step 7: Always release lock
|
|
535
|
+
await lock.release();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
// =============================================================================
|
|
539
|
+
// TOOL DEFINITION FOR REGISTRATION
|
|
540
|
+
// =============================================================================
|
|
541
|
+
/**
|
|
542
|
+
* Tool definition for registration with the tool registry.
|
|
543
|
+
*/
|
|
544
|
+
export const pythonReplTool = {
|
|
545
|
+
name: 'python_repl',
|
|
546
|
+
description: 'Execute Python code in a persistent REPL environment. ' +
|
|
547
|
+
'Variables and state persist between calls within the same session. ' +
|
|
548
|
+
'Actions: execute (run code), interrupt (stop execution), reset (clear state), get_state (view memory/variables). ' +
|
|
549
|
+
'Supports scientific computing with pandas, numpy, matplotlib.',
|
|
550
|
+
schema: pythonReplSchema.shape,
|
|
551
|
+
handler: async (args) => {
|
|
552
|
+
const output = await pythonReplHandler(args);
|
|
553
|
+
return {
|
|
554
|
+
content: [{ type: 'text', text: output }],
|
|
555
|
+
};
|
|
556
|
+
},
|
|
557
|
+
};
|
|
558
|
+
// =============================================================================
|
|
559
|
+
// EXPORTS
|
|
560
|
+
// =============================================================================
|
|
561
|
+
export { getNextExecutionCount };
|
|
562
|
+
/**
|
|
563
|
+
* Reset the execution counter for a session.
|
|
564
|
+
* Useful for testing or when manually resetting state.
|
|
565
|
+
*/
|
|
566
|
+
export function resetExecutionCounter(sessionId) {
|
|
567
|
+
executionCounters.delete(sessionId);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Get the current execution count for a session without incrementing.
|
|
571
|
+
*/
|
|
572
|
+
export function getExecutionCount(sessionId) {
|
|
573
|
+
return executionCounters.get(sessionId) || 0;
|
|
574
|
+
}
|
|
575
|
+
//# sourceMappingURL=tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/tools/python-repl/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChH,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,iBAAiB,EAAE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