feat(runtime): wire council command and routing integration
This commit is contained in:
+38
-3
@@ -9,10 +9,10 @@ import type { ExternalBackend, ExternalBackendName } from '../backends/index.js'
|
||||
import type { InboundMessage, OutboundMessage } from '../channels/index.js';
|
||||
import { MemoryStore } from '../memory/index.js';
|
||||
import type { Tool } from '../tools/types.js';
|
||||
import { createMediaSendTool, createAgentDelegateTool } from '../tools/index.js';
|
||||
import { createMediaSendTool, createAgentDelegateTool, createCouncilRunTool } from '../tools/index.js';
|
||||
import type { AgentDelegateDeps } from '../tools/index.js';
|
||||
import { createSandboxedShellTool, createSandboxedProcessStartTool, SandboxManager } from '../sandbox/index.js';
|
||||
import { MODEL_PROVIDERS, type Config, type ModelConfig, type ModelProvider } from '../config/index.js';
|
||||
import { MODEL_PROVIDERS, type Config, type CouncilsConfig, type ModelConfig, type ModelProvider } from '../config/index.js';
|
||||
import { ModelRouter, type ModelClient, type ModelTier } from '../models/index.js';
|
||||
import { ToolRegistry, ToolExecutor } from '../tools/index.js';
|
||||
import { SessionManager } from '../session/index.js';
|
||||
@@ -384,7 +384,7 @@ export function createMessageRouter(deps: {
|
||||
effectiveToolRegistry = effectiveToolRegistry.clone();
|
||||
effectiveToolRegistry.register(createMediaSendTool(collector));
|
||||
|
||||
// Register agent.delegate tool with lazy orchestrator reference (resolved after construction)
|
||||
// Register delegation tools with lazy orchestrator reference (resolved after construction)
|
||||
let resolveOrchestrator: ((o: AgentOrchestrator) => void) | undefined;
|
||||
if (deps.agentConfigRegistry && deps.agentConfigRegistry.list().length > 0) {
|
||||
let lazyOrchestrator: AgentOrchestrator | null = null;
|
||||
@@ -398,6 +398,19 @@ export function createMessageRouter(deps: {
|
||||
return lazyOrchestrator;
|
||||
},
|
||||
} as AgentDelegateDeps));
|
||||
|
||||
if (deps.config.councils?.enabled) {
|
||||
effectiveToolRegistry.register(createCouncilRunTool({
|
||||
registry: deps.agentConfigRegistry,
|
||||
config: deps.config.councils as CouncilsConfig,
|
||||
get orchestrator(): AgentOrchestrator {
|
||||
if (!lazyOrchestrator) {
|
||||
throw new Error('Agent orchestrator not yet initialized');
|
||||
}
|
||||
return lazyOrchestrator;
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
const toolPolicyContext = {
|
||||
@@ -814,6 +827,28 @@ export function createMessageRouter(deps: {
|
||||
|
||||
return `[Agent: ${target} | Tier: ${result.tier} | Tokens: ${result.usage.inputTokens}+${result.usage.outputTokens}]\n\n${result.content}`;
|
||||
},
|
||||
runCouncil: async (task: string) => {
|
||||
const message = task.trim();
|
||||
if (!message) {
|
||||
return 'Usage: /council <question or task>';
|
||||
}
|
||||
if (!deps.config.councils?.enabled) {
|
||||
return 'Councils are disabled. Set councils.enabled: true in config.';
|
||||
}
|
||||
if (!deps.agentConfigRegistry || deps.agentConfigRegistry.list().length === 0) {
|
||||
return 'No agent configurations are registered. Add council_* agent_configs first.';
|
||||
}
|
||||
const tool = createCouncilRunTool({
|
||||
registry: deps.agentConfigRegistry,
|
||||
orchestrator: agent,
|
||||
config: deps.config.councils as CouncilsConfig,
|
||||
});
|
||||
const result = await tool.execute({ task: message });
|
||||
if (!result.success) {
|
||||
return `Council run failed: ${result.error ?? 'unknown error'}`;
|
||||
}
|
||||
return result.output;
|
||||
},
|
||||
|
||||
getElevation: () => {
|
||||
return getElevationStatusMessage({
|
||||
|
||||
Reference in New Issue
Block a user