{"version":3,"file":"dispatch-evaluator.d.ts","sourceRoot":"","sources":["../../src/core/dispatch-evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,WAAW,YAAY;IAC5B,yDAAyD;IACzD,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CAChD;AAoBD,qBAAa,iBAAiB;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAiBnC;CACD","sourcesContent":["/**\n * Subagent dispatch guard + lightweight task telemetry.\n *\n * The parent agent selects which subagent to delegate to (via the Task tool),\n * so this module performs NO keyword routing. It survives for two narrow\n * responsibilities, both cheap and LLM-free:\n *   1. Depth guard — a process may only delegate while its depth is below the\n *      tree-wide cap (HOOCODE_SUBAGENT_MAX_DEPTH, default 1). At the default cap\n *      this means a subagent cannot spawn further subagents.\n *   2. Complexity estimate — a heuristic recorded in the dispatch log for\n *      diagnostics only.\n */\n\nimport { canSpawnSubagent, resolveMaxSubagentDepth } from \"./subagent-depth.js\";\n\nexport interface TaskAnalysis {\n\t/** False only when the depth guard blocks delegation. */\n\tshould_delegate: boolean;\n\treason: string;\n\testimated_complexity: \"low\" | \"medium\" | \"high\";\n}\n\n/** Heuristic complexity estimate from file/line/scope mentions in the task. */\nfunction estimateComplexity(task: string): \"low\" | \"medium\" | \"high\" {\n\tconst fileMatches = task.match(/\\b[\\w/-]+\\.(ts|js|tsx|jsx|py|go|rs|java|cpp|c|h|md|json|yaml|yml|toml)\\b/g);\n\tconst fileCount = fileMatches ? fileMatches.length : 0;\n\n\tconst lineMatch = task.match(/(\\d+)\\s*(lines?|loc)\\b/i);\n\tconst lineCount = lineMatch ? Number.parseInt(lineMatch[1], 10) : 0;\n\n\tconst highScope = /\\b(across|multiple|many|several|all files|rearchitect|redesign|migrate|restructure)\\b/i.test(\n\t\ttask,\n\t);\n\tconst mediumScope = /\\b(2|3|4|5)\\s*files?\\b/i.test(task) || /\\b(few|some|couple)\\b/i.test(task);\n\n\tif (lineCount > 200 || fileCount >= 4 || highScope) return \"high\";\n\tif (lineCount > 50 || fileCount >= 2 || mediumScope) return \"medium\";\n\treturn \"low\";\n}\n\nexport class DispatchEvaluator {\n\tevaluate(task: string): TaskAnalysis {\n\t\tif (!canSpawnSubagent()) {\n\t\t\tconst maxDepth = resolveMaxSubagentDepth();\n\t\t\treturn {\n\t\t\t\tshould_delegate: false,\n\t\t\t\t// Preserve the original message at the default cap; report the depth\n\t\t\t\t// reached when nesting has been opted into.\n\t\t\t\treason: maxDepth <= 1 ? \"Subagents cannot spawn subagents\" : `Maximum subagent depth (${maxDepth}) reached`,\n\t\t\t\testimated_complexity: \"low\",\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tshould_delegate: true,\n\t\t\treason: \"delegated to subagent\",\n\t\t\testimated_complexity: estimateComplexity(task),\n\t\t};\n\t}\n}\n"]}