/**
 * Built-in workflow: `debug_incident`
 *
 * Triage an error, stack trace, or log snippet. Parses the signal, fans out
 * parallel hypotheses (config, race, dependency, data, environment), then
 * ranks likely root causes with verification steps.
 *
 * Args:
 *   - error: error message or stack trace
 *   - logs: optional log excerpt
 *   - context: optional extra context (what changed, when it started)
 */
export declare const DEBUG_INCIDENT_SCRIPT = "export const meta = {\n  name: 'debug_incident',\n  description: 'Triage an error or log snippet with parallel hypotheses and ranked root-cause analysis.',\n  whenToUse: 'User reports a bug, crash, error message, or unexpected behavior and wants systematic triage.',\n  examplePrompts: [\n    { field: 'error', text: 'Triage this stack trace from production' },\n    { field: 'error', text: 'Why does the gateway return 502 after deploy?' },\n  ],\n  i18n: {\n    zh: {\n      description: '\u5BF9\u9519\u8BEF\u6216\u65E5\u5FD7\u7247\u6BB5\u505A\u5E76\u884C\u5047\u8BBE\u63A8\u6F14\uFF0C\u5E76\u6392\u5E8F\u6839\u56E0\u4E0E\u9A8C\u8BC1\u6B65\u9AA4\u3002',\n      whenToUse: '\u7528\u6237\u62A5\u544A bug\u3001\u5D29\u6E83\u3001\u62A5\u9519\u6216\u5F02\u5E38\u884C\u4E3A\uFF0C\u9700\u8981\u7CFB\u7EDF\u5316\u6392\u67E5\u65F6\u3002',\n      examplePrompts: [\n        { field: 'error', text: '\u6392\u67E5\u751F\u4EA7\u73AF\u5883\u8FD9\u6761\u5806\u6808' },\n        { field: 'error', text: '\u90E8\u7F72\u540E\u7F51\u5173\u8FD4\u56DE 502\uFF0C\u53EF\u80FD\u662F\u4EC0\u4E48\u539F\u56E0\uFF1F' },\n      ],\n    },\n  },\n  tags: ['debug', 'incident', 'troubleshooting'],\n  estimatedAgents: { min: 7, max: 7 },\n  phases: [\n    { title: 'Triage' },\n    { title: 'Hypotheses' },\n    { title: 'Rank' },\n  ],\n}\n\nconst READ_TOOLS = ['read_file', 'grep', 'find', 'list_dir', 'shell']\n\nconst error = args && typeof args === 'object' && args.error\n  ? String(args.error)\n  : 'Infer the primary error from the most recent user message or conversation context.'\n\nconst logs = args && typeof args === 'object' && args.logs\n  ? String(args.logs)\n  : ''\n\nconst context = args && typeof args === 'object' && args.context\n  ? String(args.context)\n  : ''\n\nphase('Triage')\nconst triage = await agent(\n  'Parse this incident signal. Extract: error type, likely subsystem, affected files/modules if identifiable, and 2\u20133 key facts from logs.\\n\\n' +\n    'ERROR:\\n' + error + '\\n\\n' +\n    (logs ? 'LOGS:\\n' + logs + '\\n\\n' : '') +\n    (context ? 'CONTEXT:\\n' + context + '\\n\\n' : '') +\n    'Use read/grep tools to locate relevant code if the workspace may contain the failing path.',\n  {\n    label: 'incident triage',\n    toolset: READ_TOOLS,\n    schema: {\n      type: 'object',\n      properties: {\n        errorType: { type: 'string' },\n        subsystem: { type: 'string' },\n        affectedPaths: { type: 'array', items: { type: 'string' } },\n        keyFacts: { type: 'array', items: { type: 'string' } },\n      },\n      required: ['errorType', 'keyFacts'],\n    },\n  },\n)\n\nconst HYPOTHESES = [\n  { key: 'config', angle: 'Misconfiguration, missing env vars, wrong defaults, feature flags, stale config cache.' },\n  { key: 'race', angle: 'Concurrency, timing, ordering, partial failure under load, missing locks or awaits.' },\n  { key: 'dependency', angle: 'Version mismatch, breaking upstream change, network/API failure, timeout, auth expiry.' },\n  { key: 'data', angle: 'Bad input, schema drift, null/empty edge case, corrupt state, migration gap.' },\n  { key: 'environment', angle: 'OS, permissions, disk, memory, container/network isolation, platform-specific behavior.' },\n]\n\nphase('Hypotheses')\nconst hypothesisReports = await parallel(\n  HYPOTHESES.map((h) => () =>\n    agent(\n      'Evaluate whether this hypothesis explains the incident. Search the codebase for supporting or refuting evidence.\\n\\n' +\n        'HYPOTHESIS: ' + h.key + ' \u2014 ' + h.angle + '\\n\\n' +\n        'TRIAGE:\\n' + JSON.stringify(triage, null, 2) + '\\n\\n' +\n        'ERROR:\\n' + error + '\\n\\n' +\n        (logs ? 'LOGS:\\n' + logs + '\\n\\n' : '') +\n        'Return: likelihood (low/med/high), evidence (file paths + brief notes), and one verification step.',\n      {\n        label: h.key + ' hypothesis',\n        toolset: READ_TOOLS,\n        schema: {\n          type: 'object',\n          properties: {\n            likelihood: { type: 'string', enum: ['low', 'med', 'high'] },\n            evidence: {\n              type: 'array',\n              items: {\n                type: 'object',\n                properties: {\n                  path: { type: 'string' },\n                  note: { type: 'string' },\n                },\n                required: ['path', 'note'],\n              },\n            },\n            verificationStep: { type: 'string' },\n          },\n          required: ['likelihood', 'evidence', 'verificationStep'],\n        },\n      },\n    ),\n  ),\n)\n\nphase('Rank')\nconst live = hypothesisReports.filter(Boolean)\nconst byHypothesis = {}\nfor (let i = 0; i < HYPOTHESES.length; i++) {\n  byHypothesis[HYPOTHESES[i].key] = live[i] ?? null\n}\n\nconst ranking = await agent(\n  'Rank root causes by likelihood. Pick the top 3 with confidence and concrete next steps to confirm or fix.\\n\\n' +\n    JSON.stringify({ triage, byHypothesis }, null, 2),\n  {\n    label: 'root cause ranking',\n    schema: {\n      type: 'object',\n      properties: {\n        topCauses: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              hypothesis: { type: 'string' },\n              likelihood: { type: 'string', enum: ['low', 'med', 'high'] },\n              summary: { type: 'string' },\n              nextStep: { type: 'string' },\n            },\n            required: ['hypothesis', 'likelihood', 'summary', 'nextStep'],\n          },\n        },\n        immediateActions: { type: 'array', items: { type: 'string' } },\n        summary: { type: 'string' },\n      },\n      required: ['topCauses', 'summary'],\n    },\n  },\n)\n\nreturn {\n  ok: true,\n  triage,\n  ...(ranking ?? { topCauses: [], summary: 'ranking failed', immediateActions: [] }),\n  byHypothesis,\n}\n";
