feat(server): inference state-graph + supervisor, memory tools, MCP client, schema, routes

- Add state-graph.ts: typed state machine for inference lifecycle
- Add supervisor.ts: agent supervisor pattern for multi-agent coordination
- Add export-formatter.ts: structured export formatting
- Add manage_memory.ts: memory CRUD tool for agent persistence
- Add get_wiki_article.ts: codecontext wiki article retrieval
- Extend memory/index.ts: 3-tier memory (context/daily/core)
- Extend MCP client: mcp-config.ts env-var substitution
- Update schema.sql: agent_sessions, tasks, pending_changes extensions
- Update API types: MessageMetadata, ErrorReason, AgentSessionConfig
- Update routes: chats, messages, sessions — column renames and agent_session_id
- Update inference: error handler, payload builder, stream phase, turn orchestrator
This commit is contained in:
2026-06-08 03:48:47 +00:00
parent 9e2b0a7dc0
commit 381b97f78a
19 changed files with 1546 additions and 230 deletions

View File

@@ -0,0 +1,61 @@
import { z } from 'zod';
import type { ToolDef } from '../types.js';
import { callBoocontext } from '../../boocontext_client.js';
export const GetWikiArticleInput = z.object({
article: z.string().min(1).describe('Article name (e.g. "auth", "database", "routes")'),
directory: z.string().optional().describe('Project directory'),
});
export type GetWikiArticleInputT = z.infer<typeof GetWikiArticleInput>;
const DESCRIPTION =
'Returns a persistent codebase wiki article by name (auth, database, routes, etc.). ' +
'Generated on first request and cached to disk. Avoids running expensive full-scan tools for targeted documentation.';
/**
* Standalone execute function — calls the boocontext MCP server's
* codesight_get_wiki_article tool and returns the article text.
*
* Structured for direct test access: accepts input + projectPath,
* no side effects beyond the MCP call.
*/
export async function executeGetWikiArticle(
input: GetWikiArticleInputT,
projectPath: string,
): Promise<string> {
const args: Record<string, unknown> = { article: input.article };
if (input.directory) args['directory'] = input.directory!;
const resp = await callBoocontext({ toolName: 'codesight_get_wiki_article', args });
return resp.result;
}
export const getWikiArticle: ToolDef<GetWikiArticleInputT> = {
name: 'get_wiki_article',
description: DESCRIPTION,
inputSchema: GetWikiArticleInput,
jsonSchema: {
type: 'function',
function: {
name: 'get_wiki_article',
description: DESCRIPTION,
parameters: {
type: 'object',
properties: {
article: {
type: 'string',
description: 'Article name (e.g. "auth", "database", "routes")',
},
directory: {
type: 'string',
description: 'Project directory',
},
},
required: ['article'],
additionalProperties: false,
},
},
},
async execute(input, projectRoot) {
return executeGetWikiArticle(input, projectRoot);
},
};