bugfixes
This commit is contained in:
@@ -45,21 +45,26 @@ export function createMCPToolWrapper(
|
||||
|
||||
// Fire workspace mutation callback when workspace_patch or workspace_write succeeds.
|
||||
// The sandbox returns {"success": true, "data": <newState>} as a text content item.
|
||||
if (
|
||||
onWorkspaceMutation &&
|
||||
(toolInfo.name === 'workspace_patch' || toolInfo.name === 'workspace_write')
|
||||
) {
|
||||
if (onWorkspaceMutation) {
|
||||
const content = (result as any)?.content;
|
||||
if (Array.isArray(content)) {
|
||||
for (const item of content) {
|
||||
if (item.type === 'text' && item.text) {
|
||||
try {
|
||||
const parsed = JSON.parse(item.text);
|
||||
if (parsed?.success && parsed?.data !== undefined) {
|
||||
// workspace_patch / workspace_write: {"success": true, "data": <state>}
|
||||
if (
|
||||
(toolInfo.name === 'workspace_patch' || toolInfo.name === 'workspace_write') &&
|
||||
parsed?.success && parsed?.data !== undefined
|
||||
) {
|
||||
onWorkspaceMutation((input as any).store_name as string, parsed.data);
|
||||
}
|
||||
// python_write / python_edit / python_delete / python_revert:
|
||||
// {"_workspace_sync": {"store": <name>, "data": <state>}}
|
||||
if (parsed?._workspace_sync?.store && parsed._workspace_sync.data !== undefined) {
|
||||
onWorkspaceMutation(parsed._workspace_sync.store, parsed._workspace_sync.data);
|
||||
}
|
||||
} catch { /* ignore parse errors */ }
|
||||
break; // only need first text item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user