feat: Stabilize Company Suite & Self-Reflection logic, integrate new ADRs and bug records
This commit is contained in:
@@ -75,6 +75,9 @@ export async function handleChatMessage(provider: SidebarChatProvider, data: any
|
||||
await provider._sendBrainStatus();
|
||||
return true;
|
||||
case 'stopGeneration':
|
||||
// 1인 기업 모드는 AgentExecutor를 거치지 않으므로 별도 abort 경로.
|
||||
// 두 경로 모두 신호를 보내 두면 중간에 모드 전환되어도 안전.
|
||||
provider.abortCompanyTurn();
|
||||
provider._agent.stop();
|
||||
return true;
|
||||
case 'loadSession':
|
||||
@@ -203,6 +206,21 @@ export async function handleChatMessage(provider: SidebarChatProvider, data: any
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'setCompanyAgentRoleCategory': {
|
||||
// Override an agent's 직군. Empty / null payload value reverts to
|
||||
// the def's own roleCategory. CEO is rejected by the backend.
|
||||
const { setAgentRoleCategory } = await import('../features/company');
|
||||
const agentId = typeof data.agentId === 'string' ? data.agentId : '';
|
||||
if (!agentId) return true;
|
||||
const cat = (typeof data.value === 'string' && data.value.trim()) ? data.value.trim() : null;
|
||||
const result = await setAgentRoleCategory(provider._context, agentId, cat as any);
|
||||
provider._view?.webview.postMessage({
|
||||
type: 'setCompanyAgentRoleCategoryResult',
|
||||
value: result.ok ? { ok: true, agentId } : { ok: false, reason: result.reason },
|
||||
});
|
||||
if (result.ok) await provider._sendCompanyAgents();
|
||||
return true;
|
||||
}
|
||||
case 'setCompanyAgentKnowledgeMix': {
|
||||
// Per-agent Knowledge Mix override. `null`/missing value falls
|
||||
// back to the global slider. The dispatcher reads this on the
|
||||
@@ -238,6 +256,79 @@ export async function handleChatMessage(provider: SidebarChatProvider, data: any
|
||||
await provider._sendCompanyAgents();
|
||||
return true;
|
||||
}
|
||||
case 'addCompanyAgent': {
|
||||
// User-defined agent. Payload: { def: CompanyAgentDef }. Returns
|
||||
// an `addCompanyAgentResult` so the UI overlay can keep its form
|
||||
// open + show an error when validation fails (id collision etc.).
|
||||
const { addCustomAgent } = await import('../features/company');
|
||||
const def = data.def;
|
||||
const result = await addCustomAgent(provider._context, def ?? {});
|
||||
provider._view?.webview.postMessage({
|
||||
type: 'addCompanyAgentResult',
|
||||
value: result.ok
|
||||
? { ok: true, agentId: def?.id }
|
||||
: { ok: false, reason: result.reason },
|
||||
});
|
||||
if (result.ok) {
|
||||
await provider._sendCompanyStatus();
|
||||
await provider._sendCompanyAgents();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'deleteCompanyAgent': {
|
||||
// Drop a user-defined agent. Built-ins refuse — backend enforces.
|
||||
const { removeCustomAgent } = await import('../features/company');
|
||||
const agentId = typeof data.agentId === 'string' ? data.agentId : '';
|
||||
if (!agentId) return true;
|
||||
const result = await removeCustomAgent(provider._context, agentId);
|
||||
provider._view?.webview.postMessage({
|
||||
type: 'deleteCompanyAgentResult',
|
||||
value: result.ok ? { ok: true, agentId } : { ok: false, reason: result.reason },
|
||||
});
|
||||
if (result.ok) {
|
||||
await provider._sendCompanyStatus();
|
||||
await provider._sendCompanyAgents();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'getCompanyPipelines':
|
||||
await provider._sendCompanyPipelines();
|
||||
return true;
|
||||
case 'upsertCompanyPipeline': {
|
||||
const { upsertPipeline } = await import('../features/company');
|
||||
const result = await upsertPipeline(provider._context, data.def ?? {});
|
||||
provider._view?.webview.postMessage({
|
||||
type: 'upsertCompanyPipelineResult',
|
||||
value: result.ok ? { ok: true } : { ok: false, reason: result.reason },
|
||||
});
|
||||
if (result.ok) await provider._sendCompanyPipelines();
|
||||
return true;
|
||||
}
|
||||
case 'deleteCompanyPipeline': {
|
||||
const { deletePipeline } = await import('../features/company');
|
||||
const pid = typeof data.pipelineId === 'string' ? data.pipelineId : '';
|
||||
if (!pid) return true;
|
||||
const result = await deletePipeline(provider._context, pid);
|
||||
provider._view?.webview.postMessage({
|
||||
type: 'deleteCompanyPipelineResult',
|
||||
value: result.ok ? { ok: true, pipelineId: pid } : { ok: false, reason: result.reason },
|
||||
});
|
||||
if (result.ok) await provider._sendCompanyPipelines();
|
||||
return true;
|
||||
}
|
||||
case 'setActiveCompanyPipeline': {
|
||||
const { setActivePipeline } = await import('../features/company');
|
||||
const pid = typeof data.pipelineId === 'string' && data.pipelineId.trim()
|
||||
? data.pipelineId.trim()
|
||||
: null;
|
||||
const result = await setActivePipeline(provider._context, pid);
|
||||
provider._view?.webview.postMessage({
|
||||
type: 'setActiveCompanyPipelineResult',
|
||||
value: result.ok ? { ok: true, pipelineId: pid } : { ok: false, reason: result.reason },
|
||||
});
|
||||
if (result.ok) await provider._sendCompanyPipelines();
|
||||
return true;
|
||||
}
|
||||
case 'proactiveTrigger':
|
||||
await provider._handleProactiveSuggestion(data.context);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user