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

@@ -177,10 +177,9 @@ export class AuthService {
async getSession(token: string) {
try {
const session = await this.config.auth.api.getSession({
headers: {
// Better Auth expects the session token in the cookie header
cookie: `better-auth.session_token=${token}`,
},
headers: new Headers({
'Authorization': `Bearer ${token}`,
}),
});
return session;

View File

@@ -264,7 +264,12 @@ export class AgentHarness {
this.mcpClient,
this.availableMCPTools,
this.workspaceManager,
(img) => this.researchImageCapture.push(img)
(img) => this.researchImageCapture.push(img),
(storeName, newState) => {
this.workspaceManager?.setState(storeName, newState).catch((err) =>
this.config.logger.error({ err, storeName }, 'Failed to sync workspace after research mutation')
);
}
);
// Inject web_explore tool if the web-explore subagent is ready
@@ -475,7 +480,11 @@ export class AgentHarness {
this.availableMCPTools,
this.workspaceManager,
undefined,
undefined
(storeName, newState) => {
this.workspaceManager?.setState(storeName, newState).catch((err) =>
this.config.logger.error({ err, storeName }, 'Failed to sync workspace after strategy mutation')
);
}
);
const strategySubagentPath = join(__dirname, 'subagents', 'strategy');

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