feat(councils): add preflight, schema-driven outputs, and artifact reporting
This commit is contained in:
+16
-1
@@ -1,5 +1,6 @@
|
||||
import type { Command } from 'commander';
|
||||
import type { Config, CouncilsConfig, ModelConfig, ModelProvider } from '../config/index.js';
|
||||
import type { ChatResponseFormat } from '../models/types.js';
|
||||
import { loadConfigSafe, getConfigPath } from './shared.js';
|
||||
import { existsSync, mkdirSync, readFileSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
@@ -118,6 +119,7 @@ export function registerTuiCommand(program: Command): void {
|
||||
const { createModelRouter } = await import('../daemon/index.js');
|
||||
const { AgentConfigRegistry } = await import('../agents/index.js');
|
||||
const { loadCouncilScaffoldSafe } = await import('../councils/scaffold.js');
|
||||
const { buildCouncilPreflightReport, shouldRunCouncilPreflight } = await import('../councils/preflight.js');
|
||||
|
||||
const dataDir = process.env.FLYNN_DATA_DIR ?? resolve(homedir(), '.local/share/flynn');
|
||||
mkdirSync(dataDir, { recursive: true });
|
||||
@@ -190,11 +192,13 @@ export function registerTuiCommand(program: Command): void {
|
||||
systemPrompt: string;
|
||||
message: string;
|
||||
maxTokens?: number;
|
||||
responseFormat?: ChatResponseFormat;
|
||||
}) {
|
||||
const response = await modelRouter.chat({
|
||||
messages: [{ role: 'user', content: request.message }],
|
||||
system: request.systemPrompt,
|
||||
maxTokens: request.maxTokens,
|
||||
responseFormat: request.responseFormat,
|
||||
}, request.tier);
|
||||
return {
|
||||
content: response.content,
|
||||
@@ -325,6 +329,7 @@ export function registerTuiCommand(program: Command): void {
|
||||
if (!message) {
|
||||
return 'Usage: /research <question or task>';
|
||||
}
|
||||
modelRouter.clearAbort();
|
||||
const agentConfig = agentConfigRegistry.get('research');
|
||||
if (!agentConfig) {
|
||||
return 'Agent "research" not found. Configure agent_configs.research first.';
|
||||
@@ -344,11 +349,21 @@ export function registerTuiCommand(program: Command): void {
|
||||
const runCouncilTask = async (task: string): Promise<string> => {
|
||||
const message = task.trim();
|
||||
if (!message) {
|
||||
return 'Usage: /council <question or task>';
|
||||
return 'Usage: /council <question or task> | /council preflight';
|
||||
}
|
||||
modelRouter.clearAbort();
|
||||
if (!config.councils?.enabled) {
|
||||
return 'Councils are disabled. Set councils.enabled: true in config.';
|
||||
}
|
||||
if (shouldRunCouncilPreflight(message)) {
|
||||
return buildCouncilPreflightReport({
|
||||
config,
|
||||
registry: agentConfigRegistry,
|
||||
delegateRunner,
|
||||
activeTier: modelRouter.getTier(),
|
||||
includeLiveProbe: true,
|
||||
});
|
||||
}
|
||||
const tool = toolRegistry.get('council.run');
|
||||
if (!tool) {
|
||||
return 'Council tool is not registered. Verify councils config and restart Flynn.';
|
||||
|
||||
Reference in New Issue
Block a user