mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-17 18:25:42 +02:00
[eric] state: the last seven data.X thunks reject on non-2xx, closing the ENG-277 payload class
This commit is contained in:
@@ -231,6 +231,7 @@ export const launchAgent = createAsyncThunk('agents/launchAgent', async (config:
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(config),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Launch failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
return data.session as AgentSession;
|
||||
});
|
||||
|
||||
@@ -44,6 +44,7 @@ export const createMode = createAsyncThunk(
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Create mode failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
return data.mode as Mode;
|
||||
}
|
||||
@@ -57,6 +58,7 @@ export const updateMode = createAsyncThunk(
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(updates),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Update mode failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
return data.mode as Mode;
|
||||
}
|
||||
@@ -66,6 +68,7 @@ export const resetMode = createAsyncThunk(
|
||||
'modes/reset',
|
||||
async (id: string) => {
|
||||
const res = await fetch(`${MODES_API}/${id}/reset`, { method: 'POST' });
|
||||
if (!res.ok) throw new Error(`Reset mode failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
return data.mode as Mode;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ export const createSkill = createAsyncThunk(
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Create skill failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
return data.skill as Skill;
|
||||
}
|
||||
@@ -64,6 +65,7 @@ export const updateSkill = createAsyncThunk(
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(updates),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Update skill failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
return data.skill as Skill;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ export const createTool = createAsyncThunk(
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Create tool failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
return data.tool as ToolDefinition;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user