repoburg 1.3.126 → 1.3.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/backend/.env +2 -0
  2. package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.d.ts +3 -13
  3. package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.js +65 -187
  4. package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.js.map +1 -1
  5. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +3 -12
  6. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -1
  7. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.d.ts +1 -3
  8. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +2 -33
  9. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
  10. package/backend/dist/src/seeding/data/sub-agents/explore-codebase.d.ts +3 -3
  11. package/backend/dist/src/seeding/data/sub-agents/explore-codebase.js +3 -3
  12. package/backend/dist/src/seeding/data/sub-agents/explore-codebase.js.map +1 -1
  13. package/backend/dist/src/seeding/data/system-prompts/default_native_tool_agent.d.ts +1 -1
  14. package/backend/dist/src/seeding/data/system-prompts/default_native_tool_agent.js +5 -5
  15. package/backend/dist/src/seeding/data/system-prompts/master-agent.d.ts +1 -1
  16. package/backend/dist/src/seeding/data/system-prompts/master-agent.js +14 -3
  17. package/backend/dist/src/seeding/data/system-prompts/master-agent.js.map +1 -1
  18. package/backend/dist/src/sub-agents/sub-agent-runner.service.d.ts +46 -0
  19. package/backend/dist/src/sub-agents/sub-agent-runner.service.js +471 -0
  20. package/backend/dist/src/sub-agents/sub-agent-runner.service.js.map +1 -0
  21. package/backend/dist/src/sub-agents/sub-agent-runs.controller.d.ts +4 -3
  22. package/backend/dist/src/sub-agents/sub-agent-runs.controller.js +10 -5
  23. package/backend/dist/src/sub-agents/sub-agent-runs.controller.js.map +1 -1
  24. package/backend/dist/src/sub-agents/sub-agents.module.js +16 -5
  25. package/backend/dist/src/sub-agents/sub-agents.module.js.map +1 -1
  26. package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
  27. package/package.json +1 -1
  28. package/backend/dist/src/llm-orchestration/hooks/sub-agent-final-response.hook.d.ts +0 -14
  29. package/backend/dist/src/llm-orchestration/hooks/sub-agent-final-response.hook.js +0 -80
  30. package/backend/dist/src/llm-orchestration/hooks/sub-agent-final-response.hook.js.map +0 -1
  31. package/backend/dist/src/seeding/data/sub-agents/handover-session.d.ts +0 -8
  32. package/backend/dist/src/seeding/data/sub-agents/handover-session.js +0 -18
  33. package/backend/dist/src/seeding/data/sub-agents/handover-session.js.map +0 -1
  34. package/backend/dist/src/seeding/data/system-prompts/handover-agent.d.ts +0 -3
  35. package/backend/dist/src/seeding/data/system-prompts/handover-agent.js +0 -69
  36. package/backend/dist/src/seeding/data/system-prompts/handover-agent.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"explore-codebase.js","sourceRoot":"","sources":["../../../../../src/seeding/data/sub-agents/explore-codebase.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,kBAAkB,CAAC;AAC1B,QAAA,WAAW,GACtB,sEAAsE,CAAC;AAC5D,QAAA,kBAAkB,GAAG,wBAAwB,CAAC;AAC9C,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAC7B,QAAA,8BAA8B,GAAG,IAAI,CAAC;AACtC,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,cAAc;IACd,gBAAgB;IAChB,OAAO;CACR,CAAC;AACW,QAAA,QAAQ,GAAG,IAAI,CAAC;AAChB,QAAA,SAAS,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"explore-codebase.js","sourceRoot":"","sources":["../../../../../src/seeding/data/sub-agents/explore-codebase.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,kBAAkB,CAAC;AAC1B,QAAA,WAAW,GACtB,sEAAsE,CAAC;AAC5D,QAAA,kBAAkB,GAAG,wBAAwB,CAAC;AAC9C,QAAA,qBAAqB,GAAG,sCAAsC,CAAC;AAC/D,QAAA,8BAA8B,GACzC,yCAAyC,CAAC;AAC/B,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,cAAc;IACd,gBAAgB;IAChB,OAAO;CACR,CAAC;AACW,QAAA,QAAQ,GAAG,IAAI,CAAC;AAChB,QAAA,SAAS,GAAG,IAAI,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export declare const name = "Native Tool Agent";
2
2
  export declare const enabled_tools: string[];
3
- export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Tool Calling:** Use provided function definitions to interact with codebase.\n6. **Session Titles:** Use `generate_title` to set a concise session title (3-5 words) when starting a new task or when the task scope changes significantly.\n\n## Sub-Agents\nSpecialized agents available for delegation.\n\n\n\n**Tools:**\n- `list_sub_agents` - Discover available sub-agents\n- `invoke_subagent` - Delegate a task to a sub-agent\n\n**Available Sub-Agents:**\n- `handover-session` - Session compression, summarization, and handover. Use for \"new session\" or \"handover\" requests.\n- `explore-codebase` - Read-only codebase exploration. Use when you need to understand project structure.\n\n**Sub Agent Rules**\n\n- Never send followup message to an existing subagent. you must wait until it finishes its work. you can invoke a new one but never send followup message to existing subagent\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Gather context -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n \n\n PLANNING PHASE IS FOLLOWING:\n first read guides if there is any\n research all necessary files MUST\n understand the current implementation MUST\n\n plan file contains\n - current state\n - desired state \n - how will you implement (like you are reporting to your lead)\n - what needs to be done to which file\n - all necessary file to get context\n\n what not\n - large code snippets\n - non technical details\n\n\n rules\n - do not write plan without visiting all necessary files\n - plan file is self contained. it should not require reading other files to understand the plan. if you need to reference other files, summarize them in the plan file.\n - mention your exploration briefly and put dead end in the plan file. \n\n\n ### Codebase Exploration\n If context is insufficient:\n 1. delegate exploration via `explore-codebase` sub-agent. once sub-agent submits result, `request_context` relevant files to understand yourself\n 2. Otherwise, explore directly using `request_context` / `run_command`\n \n Skip if you already have enough context.\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Use native function calls to read, write, and execute.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\nTool definitions are provided in the API request. Use the native tool calling interface to perform operations.\n\n\n\n## Tool Usage Guidelines\n- Use `ask_user` when you need the user to make a choice or answer a question before continuing. This pauses the loop and waits for their response. Always provide selections.\n- Use `final` when you are done and have a conclusion or summary for the user.\n\n";
3
+ export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Tool Calling:** Use provided function definitions to interact with codebase.\n6. **Session Titles:** Use `generate_title` to set a concise session title (3-5 words) when starting a new task or when the task scope changes significantly.\n\n## Sub-Agents\nSpecialized agents available for delegation.\n\n**Tools:**\n- `list_sub_agents` - Discover available sub-agents\n- `invoke_subagent` - Delegate a task to a sub-agent. Pass optional `session_id` to continue a prior sub-agent session.\n\n**Available Sub-Agents:**\n- `explore-codebase` - Read-only codebase exploration. Use when you need to understand project structure.\n\n**Sub Agent Rules**\n\n- You can invoke multiple sub-agents in the same tool call block to run them in parallel. Use this when tasks are independent of each other.\n- Each invocation returns a `[Session ID: ...]`. Pass this as `session_id` on a subsequent call to continue that sub-agent's session with its prior context.\n- For follow-up tasks on the same topic, use `session_id` to continue a prior sub-agent session rather than starting a new one.\n\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Gather context -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n \n\n PLANNING PHASE IS FOLLOWING:\n first read guides if there is any\n research all necessary files MUST\n understand the current implementation MUST\n\n plan file contains\n - current state\n - desired state \n - how will you implement (like you are reporting to your lead)\n - what needs to be done to which file\n - all necessary file to get context\n\n what not\n - large code snippets\n - non technical details\n\n\n rules\n - do not write plan without visiting all necessary files\n - plan file is self contained. it should not require reading other files to understand the plan. if you need to reference other files, summarize them in the plan file.\n - mention your exploration briefly and put dead end in the plan file. \n\n\n ### Codebase Exploration\n If context is insufficient:\n 1. delegate exploration via `explore-codebase` sub-agent. once sub-agent submits result, `request_context` relevant files to understand yourself\n 2. Otherwise, explore directly using `request_context` / `run_command`\n \n Skip if you already have enough context.\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Use native function calls to read, write, and execute.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\nTool definitions are provided in the API request. Use the native tool calling interface to perform operations.\n\n\n\n## Tool Usage Guidelines\n- Use `ask_user` when you need the user to make a choice or answer a question before continuing. This pauses the loop and waits for their response. Always provide selections.\n- Use `final` when you are done and have a conclusion or summary for the user.\n\n";
@@ -32,19 +32,19 @@ exports.content = `You are an expert software engineer. You write clean, efficie
32
32
  ## Sub-Agents
33
33
  Specialized agents available for delegation.
34
34
 
35
-
36
-
37
35
  **Tools:**
38
36
  - \`list_sub_agents\` - Discover available sub-agents
39
- - \`invoke_subagent\` - Delegate a task to a sub-agent
37
+ - \`invoke_subagent\` - Delegate a task to a sub-agent. Pass optional \`session_id\` to continue a prior sub-agent session.
40
38
 
41
39
  **Available Sub-Agents:**
42
- - \`handover-session\` - Session compression, summarization, and handover. Use for "new session" or "handover" requests.
43
40
  - \`explore-codebase\` - Read-only codebase exploration. Use when you need to understand project structure.
44
41
 
45
42
  **Sub Agent Rules**
46
43
 
47
- - Never send followup message to an existing subagent. you must wait until it finishes its work. you can invoke a new one but never send followup message to existing subagent
44
+ - You can invoke multiple sub-agents in the same tool call block to run them in parallel. Use this when tasks are independent of each other.
45
+ - Each invocation returns a \`[Session ID: ...]\`. Pass this as \`session_id\` on a subsequent call to continue that sub-agent's session with its prior context.
46
+ - For follow-up tasks on the same topic, use \`session_id\` to continue a prior sub-agent session rather than starting a new one.
47
+
48
48
 
49
49
  ## Current State
50
50
  Session: <%= it.VAR.METADATA.session_name %>
@@ -1,3 +1,3 @@
1
1
  export declare const name = "Master Agent";
2
2
  export declare const enabled_tools: string[];
3
- export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze the request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Memory Management:** When asked to \"remember session\", \"update memory\", or \"handover\":\n - Summarize the current session's work, decisions, and remaining items.\n - Store this in a Markdown file within `.repoburg/memory/` (e.g., `.repoburg/memory/session-summary.md` or a specific topic file).\n - If the file exists, update it. If not, create it.\n - Use `create_file` or `overwrite_file` for this purpose.\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Explore codebase -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Prioritize `patch`. If `patch` fails twice, fallback to `overwrite_file`.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\n<%~ it.tools.howto %>\n\n### Read Tools (Always Available)\n<%~ it.tools.request_context %>\n<%~ it.tools.run_command %>\n<%~ it.tools.write_todo %>\n\n### Write Tools (Dev Mode Only)\n<% if (!it.VAR.PLAN_MODE && !it.VAR.QUESTION_MODE) { %>\n<%~ it.tools.patch %>\n<%~ it.tools.create_file %>\n<%~ it.tools.delete_file %>\n<%~ it.tools.overwrite_file %>\n<%~ it.tools.execute_code %>\n\n<% } %>\n### Context Management Tools\n<%~ it.tools.get_messages %>\n<%~ it.tools.discard_messages %>\n\n**Context Discard Strategy:** Call `get_messages` first. If `total_est_tokens` < 70,000: only discard clearly redundant messages. If \u2265 70,000: target ~50,000 tokens. Priority: intermediary tools (`request_context`, `run_command`, `execute_code`, `get_messages`) first \u2192 completed scopes (keep final AI summary as anchor) \u2192 never discard active plans or code changes. Reason must name topics discarded/kept.\n\n**Note:** `discard_messages` is terminal \u2014 no tools after it.\n## Available Sub-Agents\n<%~ it.tools.list_sub_agents %>\n<%~ it.tools.invoke_subagent %>\n";
3
+ export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze the request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Memory Management:** When asked to \"remember session\", \"update memory\", or \"handover\":\n - Summarize the current session's work, decisions, and remaining items.\n - Store this in a Markdown file within `.repoburg/memory/` (e.g., `.repoburg/memory/session-summary.md` or a specific topic file).\n - If the file exists, update it. If not, create it.\n - Use `create_file` or `overwrite_file` for this purpose.\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Explore codebase -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Prioritize `patch`. If `patch` fails twice, fallback to `overwrite_file`.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\n<%~ it.tools.howto %>\n\n### Read Tools (Always Available)\n<%~ it.tools.request_context %>\n<%~ it.tools.run_command %>\n<%~ it.tools.write_todo %>\n\n### Write Tools (Dev Mode Only)\n<% if (!it.VAR.PLAN_MODE && !it.VAR.QUESTION_MODE) { %>\n<%~ it.tools.patch %>\n<%~ it.tools.create_file %>\n<%~ it.tools.delete_file %>\n<%~ it.tools.overwrite_file %>\n<%~ it.tools.execute_code %>\n\n<% } %>\n### Context Management Tools\n<%~ it.tools.get_messages %>\n<%~ it.tools.discard_messages %>\n\n:**Context Discard Strategy:** Call `get_messages` first. If `total_est_tokens` < 70,000: only discard clearly redundant messages. If \u2265 70,000: target ~50,000 tokens. Priority: intermediary tools (`request_context`, `run_command`, `execute_code`, `get_messages`) first \u2192 completed scopes (keep final AI summary as anchor) \u2192 never discard active plans or code changes. Reason must name topics discarded/kept.\n\n:**Note:** `discard_messages` is terminal \u2014 no tools after it.\n## Available Sub-Agents\n<%~ it.tools.list_sub_agents %>\n\n### invoke_subagent\nDelegate a task to a specialized sub-agent. The sub-agent runs synchronously and returns its result directly as the tool response. No follow-up or session management needed.\n\n**Parameters:**- **agent_name** (required): The name of the sub-agent to invoke (e.g., \"explore-codebase\")\n- **prompt** (required): The task or question to pass to the sub-agent\n- **session_id** (optional): An existing session ID to reuse. If provided, the sub-agent continues in that session with prior history.\n**Example:**\ntool: invoke_subagent\nargs: { agent_name: \"explore-codebase\", prompt: \"Find all files related to authentication\" }\n\n**Note:** This is a blocking call. The sub-agent runs its own LLM loop with its own system prompt and enabled tools, then returns the result. You cannot use other tools while waiting.\n";
@@ -80,11 +80,22 @@ ID: <%= it.VAR.METADATA.session_id %>
80
80
  <%~ it.tools.get_messages %>
81
81
  <%~ it.tools.discard_messages %>
82
82
 
83
- **Context Discard Strategy:** Call \`get_messages\` first. If \`total_est_tokens\` < 70,000: only discard clearly redundant messages. If ≥ 70,000: target ~50,000 tokens. Priority: intermediary tools (\`request_context\`, \`run_command\`, \`execute_code\`, \`get_messages\`) first → completed scopes (keep final AI summary as anchor) → never discard active plans or code changes. Reason must name topics discarded/kept.
83
+ :**Context Discard Strategy:** Call \`get_messages\` first. If \`total_est_tokens\` < 70,000: only discard clearly redundant messages. If ≥ 70,000: target ~50,000 tokens. Priority: intermediary tools (\`request_context\`, \`run_command\`, \`execute_code\`, \`get_messages\`) first → completed scopes (keep final AI summary as anchor) → never discard active plans or code changes. Reason must name topics discarded/kept.
84
84
 
85
- **Note:** \`discard_messages\` is terminal — no tools after it.
85
+ :**Note:** \`discard_messages\` is terminal — no tools after it.
86
86
  ## Available Sub-Agents
87
87
  <%~ it.tools.list_sub_agents %>
88
- <%~ it.tools.invoke_subagent %>
88
+
89
+ ### invoke_subagent
90
+ Delegate a task to a specialized sub-agent. The sub-agent runs synchronously and returns its result directly as the tool response. No follow-up or session management needed.
91
+
92
+ **Parameters:**- **agent_name** (required): The name of the sub-agent to invoke (e.g., "explore-codebase")
93
+ - **prompt** (required): The task or question to pass to the sub-agent
94
+ - **session_id** (optional): An existing session ID to reuse. If provided, the sub-agent continues in that session with prior history.
95
+ **Example:**
96
+ tool: invoke_subagent
97
+ args: { agent_name: "explore-codebase", prompt: "Find all files related to authentication" }
98
+
99
+ **Note:** This is a blocking call. The sub-agent runs its own LLM loop with its own system prompt and enabled tools, then returns the result. You cannot use other tools while waiting.
89
100
  `;
90
101
  //# sourceMappingURL=master-agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"master-agent.js","sourceRoot":"","sources":["../../../../../src/seeding/data/system-prompts/master-agent.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,cAAc,CAAC;AACtB,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,OAAO;IACP,aAAa;IACb,aAAa;IACb,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;IACb,cAAc;IACd,kBAAkB;CACnB,CAAC;AACW,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkEtB,CAAC"}
1
+ {"version":3,"file":"master-agent.js","sourceRoot":"","sources":["../../../../../src/seeding/data/system-prompts/master-agent.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,cAAc,CAAC;AACtB,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,OAAO;IACP,aAAa;IACb,aAAa;IACb,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;IACb,cAAc;IACd,kBAAkB;CACnB,CAAC;AACW,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6EtB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { ModuleRef } from '@nestjs/core';
2
+ import { LlmProvider } from '../llm-provider/llm-provider.interface';
3
+ import { SubAgentsService } from './sub-agents.service';
4
+ import { SubAgentRunsService } from './sub-agent-runs.service';
5
+ import { SessionsService } from '../sessions/sessions.service';
6
+ import { ApplicationStateService } from '../application-state/application-state.service';
7
+ import { Repository } from 'typeorm';
8
+ import { SessionInput } from '../core-entities/session-input.entity';
9
+ import { AIAction } from '../core-entities/ai-action.entity';
10
+ import { ExecutionLogsService } from '../execution-logs/execution-logs.service';
11
+ import { EventsGateway } from '../events/events.gateway';
12
+ export interface RunAgentOptions {
13
+ passContext?: boolean;
14
+ contextFiles?: string[];
15
+ masterContextDefinition?: any;
16
+ sessionId?: string;
17
+ }
18
+ export interface RunAgentResult {
19
+ content: string;
20
+ success: boolean;
21
+ iterations: number;
22
+ childSessionId: string;
23
+ }
24
+ export declare class SubAgentRunner {
25
+ private readonly subAgentsService;
26
+ private readonly subAgentRunsService;
27
+ private readonly sessionsService;
28
+ private readonly applicationStateService;
29
+ private readonly executionLogsService;
30
+ private readonly eventsGateway;
31
+ private readonly llmProvider;
32
+ private readonly moduleRef;
33
+ private readonly sessionInputsRepository;
34
+ private readonly aiActionsRepository;
35
+ private readonly logger;
36
+ constructor(subAgentsService: SubAgentsService, subAgentRunsService: SubAgentRunsService, sessionsService: SessionsService, applicationStateService: ApplicationStateService, executionLogsService: ExecutionLogsService, eventsGateway: EventsGateway, llmProvider: LlmProvider, moduleRef: ModuleRef, sessionInputsRepository: Repository<SessionInput>, aiActionsRepository: Repository<AIAction>);
37
+ private getHandlerRegistry;
38
+ private getToolSchemaService;
39
+ private getHistoryCompressionService;
40
+ private getSystemPromptsService;
41
+ runAgent(agentName: string, prompt: string, parentSessionId: string, options?: RunAgentOptions): Promise<RunAgentResult>;
42
+ private reconstructHistory;
43
+ private callWithRetry;
44
+ private isRetryableError;
45
+ private getSuccessStatusForStrategy;
46
+ }
@@ -0,0 +1,471 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var SubAgentRunner_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.SubAgentRunner = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const core_1 = require("@nestjs/core");
19
+ const llm_provider_interface_1 = require("../llm-provider/llm-provider.interface");
20
+ const sub_agents_service_1 = require("./sub-agents.service");
21
+ const sub_agent_runs_service_1 = require("./sub-agent-runs.service");
22
+ const sessions_service_1 = require("../sessions/sessions.service");
23
+ const system_prompts_service_1 = require("../system-prompts/system-prompts.service");
24
+ const tool_schema_service_1 = require("../llm-orchestration/tool-schema.service");
25
+ const history_compression_service_1 = require("../llm-orchestration/history-compression.service");
26
+ const application_state_service_1 = require("../application-state/application-state.service");
27
+ const llm_orchestration_interfaces_1 = require("../llm-orchestration/llm-orchestration.interfaces");
28
+ const typeorm_1 = require("@nestjs/typeorm");
29
+ const typeorm_2 = require("typeorm");
30
+ const session_input_entity_1 = require("../core-entities/session-input.entity");
31
+ const ai_action_entity_1 = require("../core-entities/ai-action.entity");
32
+ const ai_actions_service_1 = require("../ai-actions/ai-actions.service");
33
+ const execution_logs_service_1 = require("../execution-logs/execution-logs.service");
34
+ const events_gateway_1 = require("../events/events.gateway");
35
+ const MAX_ITERATIONS = 60;
36
+ let SubAgentRunner = SubAgentRunner_1 = class SubAgentRunner {
37
+ constructor(subAgentsService, subAgentRunsService, sessionsService, applicationStateService, executionLogsService, eventsGateway, llmProvider, moduleRef, sessionInputsRepository, aiActionsRepository) {
38
+ this.subAgentsService = subAgentsService;
39
+ this.subAgentRunsService = subAgentRunsService;
40
+ this.sessionsService = sessionsService;
41
+ this.applicationStateService = applicationStateService;
42
+ this.executionLogsService = executionLogsService;
43
+ this.eventsGateway = eventsGateway;
44
+ this.llmProvider = llmProvider;
45
+ this.moduleRef = moduleRef;
46
+ this.sessionInputsRepository = sessionInputsRepository;
47
+ this.aiActionsRepository = aiActionsRepository;
48
+ this.logger = new common_1.Logger(SubAgentRunner_1.name);
49
+ }
50
+ getHandlerRegistry() {
51
+ return this.moduleRef.get('ACTION_HANDLER_REGISTRY', { strict: false });
52
+ }
53
+ getToolSchemaService() {
54
+ return this.moduleRef.get(tool_schema_service_1.ToolSchemaService, { strict: false });
55
+ }
56
+ getHistoryCompressionService() {
57
+ return this.moduleRef.get(history_compression_service_1.HistoryCompressionService, { strict: false });
58
+ }
59
+ getSystemPromptsService() {
60
+ return this.moduleRef.get(system_prompts_service_1.SystemPromptsService, { strict: false });
61
+ }
62
+ async runAgent(agentName, prompt, parentSessionId, options) {
63
+ this.logger.log(`runAgent called for "${agentName}" from parent session ${parentSessionId}`);
64
+ const subAgent = await this.subAgentsService.getAgentByName(agentName);
65
+ if (!subAgent) {
66
+ const availableAgents = (await this.subAgentsService.findActive())
67
+ .map((a) => a.name)
68
+ .join(', ');
69
+ return {
70
+ content: `Sub-agent "${agentName}" not found or not active. Available: ${availableAgents}`,
71
+ success: false,
72
+ iterations: 0,
73
+ childSessionId: '',
74
+ };
75
+ }
76
+ const startTime = Date.now();
77
+ const handlerRegistry = this.getHandlerRegistry();
78
+ const toolSchemaService = this.getToolSchemaService();
79
+ const historyCompressionService = this.getHistoryCompressionService();
80
+ const systemPromptsService = this.getSystemPromptsService();
81
+ let childSession;
82
+ let existingHistory = [];
83
+ if (options?.sessionId) {
84
+ childSession = await this.sessionsService.findOne(options.sessionId);
85
+ if (!childSession) {
86
+ return {
87
+ content: `Session "${options.sessionId}" not found. Cannot reuse a non-existent session.`,
88
+ success: false,
89
+ iterations: 0,
90
+ childSessionId: options.sessionId,
91
+ };
92
+ }
93
+ this.logger.log(`Reusing existing session ${childSession.id} for sub-agent "${agentName}"`);
94
+ const existingInputs = await this.sessionInputsRepository.find({
95
+ where: { session: { id: childSession.id } },
96
+ order: { sequence_number: 'ASC' },
97
+ });
98
+ existingHistory = this.reconstructHistory(existingInputs);
99
+ }
100
+ else {
101
+ childSession = await this.sessionsService.create({
102
+ session_title: `Sub-Agent: ${agentName}`,
103
+ system_prompt_id: subAgent.system_prompt_id || undefined,
104
+ default_initial_context_template_id: subAgent.context_template_id || undefined,
105
+ default_followup_context_template_id: subAgent.followup_context_template_id || undefined,
106
+ model_id: subAgent.model_id || undefined,
107
+ sub_agent_id: subAgent.id,
108
+ parent_session_id: parentSessionId,
109
+ });
110
+ this.logger.log(`Created child session ${childSession.id} for sub-agent "${agentName}"`);
111
+ }
112
+ await this.subAgentRunsService.create({
113
+ parent_session_id: parentSessionId,
114
+ child_session_id: childSession.id,
115
+ sub_agent_id: subAgent.id,
116
+ agent_name: agentName,
117
+ initial_prompt: prompt,
118
+ });
119
+ let systemInstruction = '';
120
+ if (subAgent.system_prompt_id) {
121
+ const rendered = await systemPromptsService.findOneWithSession(subAgent.system_prompt_id, childSession.id, childSession.session_title);
122
+ systemInstruction = rendered?.prompt_content || '';
123
+ }
124
+ else {
125
+ const defaultPrompt = await systemPromptsService.findDefaultWithSession(childSession.id, childSession.session_title);
126
+ systemInstruction = defaultPrompt?.prompt_content || '';
127
+ }
128
+ let tools;
129
+ if (subAgent.enabled_tools && subAgent.enabled_tools.length > 0) {
130
+ const filteredHandlers = new Map();
131
+ for (const toolName of subAgent.enabled_tools) {
132
+ const handler = handlerRegistry.get(toolName);
133
+ if (handler) {
134
+ filteredHandlers.set(toolName, handler);
135
+ }
136
+ }
137
+ tools = toolSchemaService.generateToolDefinitions(filteredHandlers);
138
+ }
139
+ const history = [
140
+ ...existingHistory,
141
+ { role: 'user', parts: [{ text: prompt }] },
142
+ ];
143
+ await this.sessionInputsRepository.save(this.sessionInputsRepository.create({
144
+ session: { id: childSession.id },
145
+ role: 'user',
146
+ user_prompt: prompt,
147
+ execution_strategy: 'auto_apply',
148
+ }));
149
+ let iterations = 0;
150
+ let finalContent = '';
151
+ let success = true;
152
+ try {
153
+ const abortController = new AbortController();
154
+ const executionStrategy = await this.applicationStateService.getExecutionStrategy();
155
+ while (iterations < MAX_ITERATIONS) {
156
+ iterations++;
157
+ this.logger.log(`Sub-agent "${agentName}" iteration ${iterations}/${MAX_ITERATIONS}`);
158
+ const compressedHistory = await historyCompressionService.compress(history);
159
+ const llmResponse = await this.callWithRetry({
160
+ prompt: '',
161
+ systemInstruction,
162
+ history: compressedHistory,
163
+ modelId: childSession.model_id || undefined,
164
+ tools,
165
+ abortController,
166
+ }, childSession.id);
167
+ if (!llmResponse.text &&
168
+ (!llmResponse.tool_calls || llmResponse.tool_calls.length === 0)) {
169
+ this.logger.log(`Sub-agent "${agentName}" returned empty response with no tool calls. Ending loop.`);
170
+ finalContent = llmResponse.text || '(No response from sub-agent)';
171
+ break;
172
+ }
173
+ const modelMessage = {
174
+ role: 'model',
175
+ parts: [{ text: llmResponse.text || '' }],
176
+ };
177
+ if (llmResponse.tool_calls && llmResponse.tool_calls.length > 0) {
178
+ modelMessage.tool_calls = llmResponse.tool_calls;
179
+ }
180
+ if (llmResponse.thoughts) {
181
+ modelMessage.thoughts = llmResponse.thoughts;
182
+ }
183
+ history.push(modelMessage);
184
+ const modelInput = this.sessionInputsRepository.create({
185
+ session: { id: childSession.id },
186
+ role: 'model',
187
+ raw_llm_response: llmResponse.text || '',
188
+ tool_calls: llmResponse.tool_calls
189
+ ? JSON.stringify(llmResponse.tool_calls)
190
+ : null,
191
+ thoughts: llmResponse.thoughts || null,
192
+ input_token_count: llmResponse.usage?.inputTokens || null,
193
+ output_token_count: llmResponse.usage?.outputTokens || null,
194
+ cached_token_count: llmResponse.usage?.cachedTokens || null,
195
+ execution_strategy: 'auto_apply',
196
+ });
197
+ await this.sessionInputsRepository.save(modelInput);
198
+ if (!llmResponse.tool_calls || llmResponse.tool_calls.length === 0) {
199
+ this.logger.log(`Sub-agent "${agentName}" returned text with no tool calls. Ending loop.`);
200
+ finalContent = llmResponse.text || '';
201
+ break;
202
+ }
203
+ const executionContext = new llm_orchestration_interfaces_1.PlanExecutionContext();
204
+ executionContext.session_id = childSession.id;
205
+ executionContext.system_prompt_id = subAgent.system_prompt_id || null;
206
+ let shouldBreak = false;
207
+ const toolResults = [];
208
+ for (const toolCall of llmResponse.tool_calls) {
209
+ const toolName = toolCall.function.name;
210
+ const args = typeof toolCall.function.arguments === 'string'
211
+ ? JSON.parse(toolCall.function.arguments)
212
+ : toolCall.function.arguments;
213
+ this.logger.log(`Sub-agent "${agentName}" calling tool: ${toolName}`);
214
+ if (toolName === 'final') {
215
+ const plainText = args.plain || args.content || '';
216
+ finalContent = plainText;
217
+ shouldBreak = true;
218
+ const actionEntity = this.aiActionsRepository.create({
219
+ input_id: modelInput.id,
220
+ sessionInput: { id: modelInput.id },
221
+ action_type: 'final',
222
+ status: ai_actions_service_1.AIActionStatus.CONFIRMED_KEPT,
223
+ order_of_execution: toolResults.length,
224
+ original_content_for_revert: null,
225
+ tool_call_id: toolCall.id || null,
226
+ plain: plainText,
227
+ selections: args.selections || null,
228
+ });
229
+ await this.aiActionsRepository.save(actionEntity);
230
+ toolResults.push({
231
+ toolCallId: toolCall.id || '',
232
+ toolName,
233
+ result: 'Task completed.',
234
+ });
235
+ continue;
236
+ }
237
+ const handler = handlerRegistry.get(toolName);
238
+ if (!handler) {
239
+ this.logger.warn(`No handler found for tool: ${toolName}. Skipping.`);
240
+ const errorMsg = `Tool '${toolName}' is not a valid tool. Please use a valid tool.`;
241
+ toolResults.push({
242
+ toolCallId: toolCall.id || '',
243
+ toolName,
244
+ result: errorMsg,
245
+ });
246
+ const actionEntity = this.aiActionsRepository.create({
247
+ input_id: modelInput.id,
248
+ sessionInput: { id: modelInput.id },
249
+ action_type: toolName,
250
+ status: ai_actions_service_1.AIActionStatus.EXECUTION_FAILED,
251
+ order_of_execution: toolResults.length,
252
+ original_content_for_revert: null,
253
+ tool_call_id: toolCall.id || null,
254
+ });
255
+ await this.aiActionsRepository.save(actionEntity);
256
+ continue;
257
+ }
258
+ let result;
259
+ try {
260
+ result = await handler.execute(args, executionContext);
261
+ }
262
+ catch (error) {
263
+ this.logger.error(`Handler for ${toolName} failed: ${error.message}`);
264
+ result = {
265
+ status: 'FAILURE',
266
+ summary: `An unexpected error occurred: ${error.message}`,
267
+ error_message: error.message,
268
+ persisted_args: args,
269
+ };
270
+ }
271
+ const successStatus = this.getSuccessStatusForStrategy(executionStrategy);
272
+ const actionEntity = this.aiActionsRepository.create({
273
+ input_id: modelInput.id,
274
+ sessionInput: { id: modelInput.id },
275
+ action_type: toolName,
276
+ status: result.status === 'SUCCESS'
277
+ ? successStatus
278
+ : ai_actions_service_1.AIActionStatus.EXECUTION_FAILED,
279
+ order_of_execution: toolResults.length,
280
+ original_content_for_revert: result.original_content_for_revert || null,
281
+ tool_call_id: toolCall.id || null,
282
+ ...result.persisted_args,
283
+ });
284
+ const savedAction = await this.aiActionsRepository.save(actionEntity);
285
+ if (result.execution_log) {
286
+ await this.executionLogsService.createLog({
287
+ action_id: savedAction.id,
288
+ output: result.execution_log.output,
289
+ error_message: result.execution_log.error_message,
290
+ });
291
+ }
292
+ const output = result.execution_log?.output || '';
293
+ const error = result.execution_log?.error_message || result.error_message || '';
294
+ const combinedResult = error
295
+ ? `${output}\n\nError: ${error}`.trim()
296
+ : output;
297
+ toolResults.push({
298
+ toolCallId: toolCall.id || '',
299
+ toolName,
300
+ result: combinedResult,
301
+ });
302
+ if (executionContext.flags.should_halt) {
303
+ this.logger.log(`Execution context halted. Ending sub-agent loop.`);
304
+ shouldBreak = true;
305
+ break;
306
+ }
307
+ }
308
+ for (const tr of toolResults) {
309
+ history.push({
310
+ role: 'tool',
311
+ tool_call_id: tr.toolCallId,
312
+ tool_name: tr.toolName,
313
+ parts: [{ text: tr.result }],
314
+ });
315
+ }
316
+ await this.sessionInputsRepository.save(this.sessionInputsRepository.create({
317
+ session: { id: childSession.id },
318
+ role: 'user',
319
+ user_prompt: '',
320
+ execution_strategy: 'auto_apply',
321
+ raw_llm_response: null,
322
+ tool_calls: JSON.stringify(toolResults.map((tr) => ({
323
+ id: tr.toolCallId,
324
+ type: 'function',
325
+ function: { name: tr.toolName, arguments: '{}' },
326
+ }))),
327
+ }));
328
+ if (shouldBreak) {
329
+ break;
330
+ }
331
+ }
332
+ if (iterations >= MAX_ITERATIONS) {
333
+ this.logger.warn(`Sub-agent "${agentName}" reached max iterations (${MAX_ITERATIONS}).`);
334
+ if (!finalContent) {
335
+ finalContent =
336
+ 'Sub-agent reached maximum iterations without completing.';
337
+ success = false;
338
+ }
339
+ }
340
+ await this.subAgentRunsService.markCompleted(childSession.id, finalContent.substring(0, 5000));
341
+ }
342
+ catch (error) {
343
+ this.logger.error(`Sub-agent "${agentName}" failed: ${error.message}`, error.stack);
344
+ success = false;
345
+ finalContent = `Sub-agent "${agentName}" encountered an error: ${error.message}`;
346
+ await this.subAgentRunsService.markFailed(childSession.id, error.message);
347
+ }
348
+ const durationMs = Date.now() - startTime;
349
+ this.logger.log(`Sub-agent "${agentName}" completed in ${durationMs}ms, ${iterations} iterations, success: ${success}`);
350
+ return {
351
+ content: finalContent,
352
+ success,
353
+ iterations,
354
+ childSessionId: childSession.id,
355
+ };
356
+ }
357
+ reconstructHistory(inputs) {
358
+ const history = [];
359
+ for (const input of inputs) {
360
+ if (input.role === 'user') {
361
+ const content = {
362
+ role: 'user',
363
+ parts: [{ text: input.user_prompt || input.raw_llm_response || '' }],
364
+ };
365
+ history.push(content);
366
+ }
367
+ else if (input.role === 'model') {
368
+ const content = {
369
+ role: 'model',
370
+ parts: [{ text: input.raw_llm_response || '' }],
371
+ };
372
+ if (input.tool_calls) {
373
+ try {
374
+ const parsed = JSON.parse(input.tool_calls);
375
+ if (Array.isArray(parsed)) {
376
+ content.tool_calls = parsed;
377
+ }
378
+ }
379
+ catch {
380
+ }
381
+ }
382
+ history.push(content);
383
+ }
384
+ }
385
+ return history;
386
+ }
387
+ async callWithRetry(request, sessionId) {
388
+ const retryEnabled = await this.applicationStateService.getLlmRetryEnabled();
389
+ const maxAttempts = await this.applicationStateService.getLlmRetryMaxAttempts();
390
+ let lastError;
391
+ let attempt = 1;
392
+ while (attempt <= maxAttempts) {
393
+ try {
394
+ if (attempt > 1) {
395
+ this.logger.log(`Retry attempt ${attempt}/${maxAttempts} for sub-agent session ${sessionId}`);
396
+ }
397
+ return await this.llmProvider.generateContent({
398
+ ...request,
399
+ abortController: request.abortController,
400
+ });
401
+ }
402
+ catch (error) {
403
+ lastError = error;
404
+ if (error.name === 'AbortError' || error.code === 'ABORT_ERR') {
405
+ throw error;
406
+ }
407
+ const shouldRetry = retryEnabled && attempt < maxAttempts && this.isRetryableError(error);
408
+ if (!shouldRetry) {
409
+ throw error;
410
+ }
411
+ const backoffMs = Math.pow(2, attempt - 1) * 1000;
412
+ this.logger.log(`LLM call failed (attempt ${attempt}/${maxAttempts}): ${error.message}. Retrying in ${backoffMs}ms...`);
413
+ await new Promise((resolve) => setTimeout(resolve, backoffMs));
414
+ attempt++;
415
+ }
416
+ }
417
+ throw lastError;
418
+ }
419
+ isRetryableError(error) {
420
+ const errorMessage = error.message?.toLowerCase() || '';
421
+ const errorCode = error.code;
422
+ const status = error.status;
423
+ if (error.name === 'AbortError' || error.code === 'ABORT_ERR')
424
+ return false;
425
+ const networkErrors = [
426
+ 'ECONNRESET',
427
+ 'ETIMEDOUT',
428
+ 'ENOTFOUND',
429
+ 'ENETUNREACH',
430
+ 'ECONNREFUSED',
431
+ ];
432
+ if (errorCode && networkErrors.includes(errorCode))
433
+ return true;
434
+ if (status === 429 ||
435
+ errorMessage.includes('rate limit') ||
436
+ errorMessage.includes('too many requests'))
437
+ return true;
438
+ if (status >= 500 && status < 600)
439
+ return true;
440
+ if (errorMessage.includes('empty response') ||
441
+ errorMessage.includes('timeout'))
442
+ return true;
443
+ return false;
444
+ }
445
+ getSuccessStatusForStrategy(strategy) {
446
+ switch (strategy) {
447
+ case 'auto_apply':
448
+ return ai_actions_service_1.AIActionStatus.CONFIRMED_KEPT;
449
+ case 'review_first':
450
+ case 'apply_revert':
451
+ default:
452
+ return ai_actions_service_1.AIActionStatus.APPLIED_PENDING_REVIEW;
453
+ }
454
+ }
455
+ };
456
+ exports.SubAgentRunner = SubAgentRunner;
457
+ exports.SubAgentRunner = SubAgentRunner = SubAgentRunner_1 = __decorate([
458
+ (0, common_1.Injectable)(),
459
+ __param(6, (0, common_1.Inject)(llm_provider_interface_1.LLM_PROVIDER)),
460
+ __param(8, (0, typeorm_1.InjectRepository)(session_input_entity_1.SessionInput)),
461
+ __param(9, (0, typeorm_1.InjectRepository)(ai_action_entity_1.AIAction)),
462
+ __metadata("design:paramtypes", [sub_agents_service_1.SubAgentsService,
463
+ sub_agent_runs_service_1.SubAgentRunsService,
464
+ sessions_service_1.SessionsService,
465
+ application_state_service_1.ApplicationStateService,
466
+ execution_logs_service_1.ExecutionLogsService,
467
+ events_gateway_1.EventsGateway, Object, core_1.ModuleRef,
468
+ typeorm_2.Repository,
469
+ typeorm_2.Repository])
470
+ ], SubAgentRunner);
471
+ //# sourceMappingURL=sub-agent-runner.service.js.map