feat(agents): add option to inherit main agent workspace when creating new agent (#639)

This commit is contained in:
paisley
2026-03-23 18:00:35 +08:00
committed by GitHub
Unverified
parent 6b82c6ccb4
commit c6021cedf4
7 changed files with 53 additions and 23 deletions

View File

@@ -12,7 +12,7 @@ interface AgentsState {
loading: boolean;
error: string | null;
fetchAgents: () => Promise<void>;
createAgent: (name: string) => Promise<void>;
createAgent: (name: string, options?: { inheritWorkspace?: boolean }) => Promise<void>;
updateAgent: (agentId: string, name: string) => Promise<void>;
deleteAgent: (agentId: string) => Promise<void>;
assignChannel: (agentId: string, channelType: ChannelType) => Promise<void>;
@@ -52,12 +52,12 @@ export const useAgentsStore = create<AgentsState>((set) => ({
}
},
createAgent: async (name: string) => {
createAgent: async (name: string, options?: { inheritWorkspace?: boolean }) => {
set({ error: null });
try {
const snapshot = await hostApiFetch<AgentsSnapshot & { success?: boolean }>('/api/agents', {
method: 'POST',
body: JSON.stringify({ name }),
body: JSON.stringify({ name, inheritWorkspace: options?.inheritWorkspace }),
});
set(applySnapshot(snapshot));
} catch (error) {