import type { ToolRegistry, SkillManager } from '@cicctencent/agent-core'; import type { AgentProfileEntity, PromptBuilderProvider, SpecialistResourceContext } from '../types.js'; /** 内置工具名称可读化映射 */ export declare const BUILTIN_TOOL_LABELS: Record; /** * MCP 工具的展示名不再硬编码在此。 * 展示名来自工具自身的定义(MCPServerEntity.toolDefinitions 中的 label/name, * 即用户在配置 MCP 时填写的中文名),或 MCP 协议返回的 Tool.title; * 注册时写入工具 metadata.displayName,由 resolveToolDisplayName 直接取用。 */ /** * 全局基础规则 - 所有 Agent 共享的通用行为规范 * * ⚠️ 严禁在此引用任何具体工具名(如 ask_user、delegate_task、read_tool_result 等)。 * 不同 Agent 注册的工具集不同,硬编码工具名会导致 LLM 尝试调用未注册的工具(工具穿透)。 * 工具使用引导应通过工具自身的 prompt 字段注入(buildToolPrompts),仅在工具注册时生效。 */ export declare const GLOBAL_BASE_RULES = "\n\n## Universal Rules\n\n### Plan Before Execute\n- For ANY task involving multiple steps: **output a numbered step list before doing anything**\n- Format the plan as a **bold inline list**, NOT as markdown headings (## or ###). Use: \"**1.** Fetch data -> **2.** Analyze -> **3.** Generate output\"\n- Do NOT start calling tools until the plan is output\n- As you work, track progress: \u2713 done / -> in progress / \u25CB pending\n\n### Read Before Write\n- If the user provides a file, document reference, or data source: **read/fetch it first** before creating outputs\n- Gather all necessary data before starting generation\n- Don't assume content - verify with tools\n\n### Error Recovery\n- If a tool call fails: **diagnose the error** before retrying\n- Never blindly retry the same failing approach - try a different method\n- If content was truncated: use file appending tools to add the remaining parts\n\n### Conversation History & Current Request\n- Your conversation history is provided in tags as a summary - it is context only\n- The current user request is in tags or is the latest user message - this is what you must act on\n- Do NOT proactively combine or continue tasks from unless explicitly references them\n- Evaluate task complexity based on alone, not on accumulated history\n- **REUSE prior results (CRITICAL)**: If the current request repeats or closely resembles a previously completed task in history (e.g. \"\u518D\u751F\u6210\u4E00\u6B21\", \"regenerate\", \"\u91CD\u65B0\u505A\", \"\u540C\u6837\u7684\"), **do NOT re-fetch or re-query the same data sources**. Reuse the data and results already gathered in to produce the output. Only fetch new data if the request explicitly asks for different/newer information.\n- **Reuse delegate_task results (CRITICAL)**: If contains a section marked \"[delegate_task \u5B8C\u6574\u5206\u6790\u7ED3\u679C]\", **use that data directly** to complete the current task. Do NOT re-run delegate_task \u2014 it is expensive, slow, and may produce inconsistent results.\n\n### Output Restraint (CRITICAL)\n- **NEVER proactively use tools that create files, reports, or artifacts unless the user explicitly asks for them**\n- Your default output is text/structured data directly in the conversation - not files\n- If the user asks for \"analysis\" or \"summary\", provide it as text - do NOT auto-generate a report file\n- Only generate files/reports when the user explicitly says \"\u751F\u6210\u62A5\u544A\", \"create PDF\", \"make a PPT\", \"save as file\", etc.\n\n### Execute Without Confirming (CRITICAL)\n- When the user's request contains a **clear, explicit instruction** (e.g. \"\u8BF7\u751F\u6210PPT\u548C\u62A5\u544A\", \"\u5E2E\u6211\u53D1\u9001\u90AE\u4EF6\", \"create a presentation\"), **execute it immediately** \u2014 do NOT end your reply with \"\u662F\u5426\u9700\u8981\u6211\u73B0\u5728\u2026\" or \"\u8BF7\u786E\u8BA4\u662F\u5426\u2026\" or similar confirmation questions.\n- Only ask for clarification when the user's intent is genuinely ambiguous or when a required parameter is missing.\n\n### Tool Selection Priority (CRITICAL)\n- **Always prefer specialized tools over generic tools.** When a dedicated tool exists for a task, you MUST use it instead of generic code execution or shell commands.\n- Generic code execution (e.g. running scripts, shell commands) is a **last-resort fallback** \u2014 only use it when no specialized tool can accomplish the task.\n- Before writing code or running shell commands, review your available tool list and check: \"Is there a tool specifically designed for this action?\" If yes, use it.\n- **Rationale**: Specialized tools are safer, faster, and produce better-structured output. They also avoid leaking server environment information through raw command output.\n\n### Iteration Budget & Efficiency (CRITICAL)\n- You have a **limited number of iterations** (typically 15). Every LLM turn counts.\n- **NEVER re-query the same data source.** If you called a tool and got results, use those results - do NOT call it again.\n- **NEVER re-read data you already received** - do not call read/result retrieval tools on data already in context.\n- **Batch data gathering:** call multiple independent tools in the SAME turn (parallel tool calls).\n- **Data -> Action pipeline:** gather data in 1-2 iterations, then immediately analyze/generate in the next iteration.\n- **Return concise structured summaries**, not raw data dumps. Extract key metrics, rankings, distributions - not every single record.\n\n### Data Accuracy & Provenance (CRITICAL)\nFor accuracy-sensitive data (financial figures, statistics, prices, market/quantitative data), follow this tiered policy:\n1. **Live/fetched data** \u2014 data successfully obtained via tools this turn is verified. Cite its source (URL / API / file).\n2. **Public historical facts from your knowledge** \u2014 you MAY use real, publicly-disclosed historical data you already know (e.g. a company's previously reported quarterly results), BUT you MUST explicitly label it: state that it is \"based on public historical records / model knowledge\", note it is **not real-time verified**, and for the **latest period** (which may be beyond your knowledge) lower your confidence and tell the user to verify against official sources.\n3. **Fabrication is forbidden** \u2014 NEVER invent, guess, interpolate, or extrapolate precise numerical values. Do NOT present uncertain figures as precise facts. If you are unsure whether a specific number is real, do not state it as fact.\n- **When all external data sources fail**: do NOT silently produce a data report/chart as if the data were verified. Either (a) clearly tell the user data fetching failed and provide only what you genuinely know as labeled unverified historical context, or (b) ask for an accessible data source. Transparency over false precision \u2014 always.\n- **Stop retrying a dead data source (HARD RULE)**: If an external data source (HTTP/quote API, MCP web search, third-party API) returns a connection failure (e.g. a 'socket hang up'), an 'unknown error', or any clearly non-recoverable error on the **first** attempt, treat that source as unavailable in this environment for the rest of the task. Do NOT retry it with the same approach (e.g. do not re-fetch the same blocked domain via sb.fetch, and do not re-call the same failing search tool with different params). If ALL external data sources are unavailable, deliver your conclusion based on the qualitative analysis / public historical context you already have (or ask the user ONCE for an accessible data source) \u2014 never loop the same failed calls.\n- **Do not block on interaction when stuck**: If all external data sources fail AND the caller has already given you a delivery goal (e.g. \"generate a report\"), deliver the result based on what you have (mark quantitative metrics as \"\u5F85\u8865 / data unavailable\") \u2014 do NOT raise a blocking ask_user choice interaction to push the data gap back to the user.\n\n### Final Reply Rules\n- After all tasks and file generation complete, provide a **clean, structured summary** of results\n- Do NOT include internal reasoning, tool call logs, or progress narration in the final reply\n- The final reply should be polished and user-facing: key findings, recommendations, generated files"; /** * 已绑定技能的使用规则(只讲通用规则,不硬编码任何具体工具名)。 * buildSpecialistPrompt 与 buildDefaultPrompt 复用,避免文案漂移。 * * 第 4 条按注册工具动态生成:仅当 load_skill 工具实际注册时才提及该工具名, * 否则用通用表述(读取参考文档),避免 LLM 被引导调用未注册的工具(工具穿透)。 */ export declare function buildSkillUsageRules(tools?: ToolRegistry): string; /** * 收集已注册工具的使用引导(prompt),注入到 system prompt * * 每个工具可以通过 RegisteredTool.prompt 字段携带使用引导。 * 仅当工具实际注册时,其 prompt 才会被收集并注入, * 避免 LLM 被引导调用未绑定的工具。 */ export declare function buildToolPrompts(tools: ToolRegistry): string; /** * 默认 PromptBuilderProvider 实现 */ export declare class DefaultPromptBuilder implements PromptBuilderProvider { resolveToolDisplayName(toolName: string, registry?: ToolRegistry): string; /** * 构建已绑定技能的摘要段 + 使用规则。 * 只注入技能的 name + description 摘要(不注入完整 SKILL.md 全文,控制 token 成本), * 并引导 LLM 按需加载完整方法论与参考文档。 * 无已绑定技能时返回空串。 */ private buildSkillSection; buildDefaultPrompt(profile: AgentProfileEntity, tools: ToolRegistry, memory?: string, specialists?: AgentProfileEntity[], specialistResourceMap?: Record, skills?: SkillManager): string; buildSpecialistPrompt(profile: AgentProfileEntity, tools: ToolRegistry, skills: SkillManager, memory?: string): string; buildToolDescList(registry: ToolRegistry): string; buildMCPToolDescList(registry: ToolRegistry): string; } /** 共享提示词片段:工具结果呈现规范 */ export declare const RESULT_SYNTHESIS_PROMPT = "\n\n## Tool Result Presentation (MANDATORY)\n\nAfter calling tools and receiving data, you MUST:\n1. **Analyze and summarize** - never dump raw JSON or tool output directly; synthesize and organize the data\n2. **Highlight key findings** - identify trends, anomalies, or notable information\n3. **Structured presentation** - use headings, bullet points, or tables for readability\n4. **Add insights** - provide professional interpretation, comparisons, or recommendations\n5. **NEVER re-fetch** - if you already called a tool and got results, do NOT call the same tool again\n6. **Use user's language** - respond in the same language the user used"; /** Specialist 结果综合提示词 */ export declare const SPECIALIST_SYNTHESIS_PROMPT = "Based on the specialist agents' outputs above, provide a comprehensive synthesis:\n1. Summarize key findings from each agent\n2. Identify any conflicts or contradictions\n3. Provide a unified recommendation\n4. Highlight any risks or caveats\nRespond in the same language as the user."; //# sourceMappingURL=prompt-builder.d.ts.map