This commit is contained in:
2026-04-17 20:49:21 -04:00
parent 4e243751b2
commit bbddd58f98
6 changed files with 106 additions and 19 deletions

View File

@@ -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
}
}
}