/** * Shared session-turn core. * * Chat runs as a single conversational agent turn, spawned from two places: * - the `edsger session-turn` CLI command (desktop "Chats") * - the edsger-agents worker (`session-runner`) * * Both used to hand-roll the same system prompt, tool policy, and SDK `query` * options — so every capability tweak had to be made twice and drifted. This * module is the single source of truth for all of that. Each caller keeps only * its own transport glue (how it fetches/sends/marks messages, resume vs * abort, repo cloning) and feeds the shared pieces here. */ import type { McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk'; import type { ExternalMcpServerConfig } from '../mcp/external-servers.js'; /** * Chat is the most capable surface: it gets the full in-process toolbelt (all * edsger-* MCP tools + CLI launchers), any user-configured external MCP * servers, and the SDK's native read/research/orchestration built-ins. We * still withhold the code-mutating built-ins (Edit/Write/Bash/NotebookEdit) * and subagent spawning (Agent): code changes are handed off to the * engineering pipeline via create_issue, not written here. */ export declare const CHAT_NATIVE_TOOLS: string[]; export declare const CHAT_DISALLOWED_TOOLS: string[]; export declare const SESSION_MAX_TURNS = 40; export interface SessionPromptInput { channelId: string; productId: string; repositoryIds: string[]; /** Where each repo is checked out locally (omit when nothing was cloned). */ repoScopeNote?: string; /** Names of connected external MCP servers, for the toolbelt note. */ externalMcpNames?: string[]; /** Persona name — when set the prompt is first-person as this agent. */ agentName?: string; /** Long-term memories to surface (worker runs only). */ memories?: { memory_type: string; content: string; }[]; } /** The single source of truth for the session agent's system prompt. */ export declare function buildSessionSystemPrompt(input: SessionPromptInput): string; export interface SessionPendingMessage { sender_name: string | null; sender_agent_id: string | null; content: string; } /** The single source of truth for the turn's user prompt. */ export declare function buildSessionUserPrompt(messages: SessionPendingMessage[]): string; export interface SessionToolWiring { /** The in-process edsger session MCP server instance. */ sessionServer: McpSdkServerConfigWithInstance; /** External MCP servers to merge in (from loadExternalMcpServers). */ externalServers?: Record; /** Names of those external servers, for the agent's mcpServers allowlist. */ externalNames?: string[]; /** cwd for native file tools (the cloned session dir), when available. */ sessionDir?: string; /** When false, the agent gets no native tools at all. Default true. */ enableCodeTools?: boolean; maxTurns?: number; } /** * Build the shared `query` options for a session turn — the agent definition, * tool policy, MCP wiring (in-process + external), and cwd. Callers spread * this and add `model` plus their own `resume` or `abortController`. */ export declare function buildSessionAgentOptions(systemPrompt: string, wiring: SessionToolWiring): { cwd?: string | undefined; agent: string; agents: { 'session-agent': { disallowedTools: string[]; mcpServers: string[]; maxTurns?: number | undefined; description: string; prompt: string; } | { tools: never[]; mcpServers: string[]; maxTurns?: number | undefined; description: string; prompt: string; }; }; mcpServers: { 'edsger-session': McpSdkServerConfigWithInstance; }; tools: string[]; permissionMode: "bypassPermissions"; allowDangerouslySkipPermissions: boolean; };