@vybestack/llxprt-code-agents 0.10.0-nightly.260613.1adad3b34

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 (176) hide show
  1. package/dist/.last_build +0 -0
  2. package/dist/index.d.ts +10 -0
  3. package/dist/index.js +11 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/agents/executor-prompt-builder.d.ts +19 -0
  6. package/dist/src/agents/executor-prompt-builder.js +44 -0
  7. package/dist/src/agents/executor-prompt-builder.js.map +1 -0
  8. package/dist/src/agents/executor-termination.d.ts +22 -0
  9. package/dist/src/agents/executor-termination.js +44 -0
  10. package/dist/src/agents/executor-termination.js.map +1 -0
  11. package/dist/src/agents/executor-validation.d.ts +17 -0
  12. package/dist/src/agents/executor-validation.js +35 -0
  13. package/dist/src/agents/executor-validation.js.map +1 -0
  14. package/dist/src/agents/executor.d.ts +136 -0
  15. package/dist/src/agents/executor.js +874 -0
  16. package/dist/src/agents/executor.js.map +1 -0
  17. package/dist/src/agents/invocation.d.ts +45 -0
  18. package/dist/src/agents/invocation.js +118 -0
  19. package/dist/src/agents/invocation.js.map +1 -0
  20. package/dist/src/agents/recovery.d.ts +75 -0
  21. package/dist/src/agents/recovery.js +107 -0
  22. package/dist/src/agents/recovery.js.map +1 -0
  23. package/dist/src/agents/types.d.ts +149 -0
  24. package/dist/src/agents/types.js +18 -0
  25. package/dist/src/agents/types.js.map +1 -0
  26. package/dist/src/agents/utils.d.ts +15 -0
  27. package/dist/src/agents/utils.js +28 -0
  28. package/dist/src/agents/utils.js.map +1 -0
  29. package/dist/src/compression/CompressionHandler.d.ts +178 -0
  30. package/dist/src/compression/CompressionHandler.js +630 -0
  31. package/dist/src/compression/CompressionHandler.js.map +1 -0
  32. package/dist/src/compression/HighDensityStrategy.d.ts +113 -0
  33. package/dist/src/compression/HighDensityStrategy.js +769 -0
  34. package/dist/src/compression/HighDensityStrategy.js.map +1 -0
  35. package/dist/src/compression/MiddleOutStrategy.d.ts +27 -0
  36. package/dist/src/compression/MiddleOutStrategy.js +347 -0
  37. package/dist/src/compression/MiddleOutStrategy.js.map +1 -0
  38. package/dist/src/compression/OneShotStrategy.d.ts +22 -0
  39. package/dist/src/compression/OneShotStrategy.js +235 -0
  40. package/dist/src/compression/OneShotStrategy.js.map +1 -0
  41. package/dist/src/compression/TopDownTruncationStrategy.d.ts +13 -0
  42. package/dist/src/compression/TopDownTruncationStrategy.js +74 -0
  43. package/dist/src/compression/TopDownTruncationStrategy.js.map +1 -0
  44. package/dist/src/compression/compressionBudgeting.d.ts +34 -0
  45. package/dist/src/compression/compressionBudgeting.js +139 -0
  46. package/dist/src/compression/compressionBudgeting.js.map +1 -0
  47. package/dist/src/compression/compressionStrategyFactory.d.ts +23 -0
  48. package/dist/src/compression/compressionStrategyFactory.js +40 -0
  49. package/dist/src/compression/compressionStrategyFactory.js.map +1 -0
  50. package/dist/src/compression/index.d.ts +16 -0
  51. package/dist/src/compression/index.js +17 -0
  52. package/dist/src/compression/index.js.map +1 -0
  53. package/dist/src/compression/reasoningUtils.d.ts +18 -0
  54. package/dist/src/compression/reasoningUtils.js +22 -0
  55. package/dist/src/compression/reasoningUtils.js.map +1 -0
  56. package/dist/src/compression/utils.d.ts +114 -0
  57. package/dist/src/compression/utils.js +316 -0
  58. package/dist/src/compression/utils.js.map +1 -0
  59. package/dist/src/core/AgentHookManager.d.ts +41 -0
  60. package/dist/src/core/AgentHookManager.js +65 -0
  61. package/dist/src/core/AgentHookManager.js.map +1 -0
  62. package/dist/src/core/ChatSessionFactory.d.ts +50 -0
  63. package/dist/src/core/ChatSessionFactory.js +216 -0
  64. package/dist/src/core/ChatSessionFactory.js.map +1 -0
  65. package/dist/src/core/ConversationManager.d.ts +113 -0
  66. package/dist/src/core/ConversationManager.js +311 -0
  67. package/dist/src/core/ConversationManager.js.map +1 -0
  68. package/dist/src/core/DirectMessageProcessor.d.ts +79 -0
  69. package/dist/src/core/DirectMessageProcessor.js +478 -0
  70. package/dist/src/core/DirectMessageProcessor.js.map +1 -0
  71. package/dist/src/core/IdeContextTracker.d.ts +56 -0
  72. package/dist/src/core/IdeContextTracker.js +207 -0
  73. package/dist/src/core/IdeContextTracker.js.map +1 -0
  74. package/dist/src/core/MessageConverter.d.ts +78 -0
  75. package/dist/src/core/MessageConverter.js +492 -0
  76. package/dist/src/core/MessageConverter.js.map +1 -0
  77. package/dist/src/core/MessageStreamOrchestrator.d.ts +85 -0
  78. package/dist/src/core/MessageStreamOrchestrator.js +448 -0
  79. package/dist/src/core/MessageStreamOrchestrator.js.map +1 -0
  80. package/dist/src/core/MessageStreamTerminalHandler.d.ts +16 -0
  81. package/dist/src/core/MessageStreamTerminalHandler.js +170 -0
  82. package/dist/src/core/MessageStreamTerminalHandler.js.map +1 -0
  83. package/dist/src/core/StreamProcessor.d.ts +105 -0
  84. package/dist/src/core/StreamProcessor.js +660 -0
  85. package/dist/src/core/StreamProcessor.js.map +1 -0
  86. package/dist/src/core/TodoContinuationService.d.ts +74 -0
  87. package/dist/src/core/TodoContinuationService.js +312 -0
  88. package/dist/src/core/TodoContinuationService.js.map +1 -0
  89. package/dist/src/core/TurnProcessor.d.ts +91 -0
  90. package/dist/src/core/TurnProcessor.js +540 -0
  91. package/dist/src/core/TurnProcessor.js.map +1 -0
  92. package/dist/src/core/baseLlmClient.d.ts +115 -0
  93. package/dist/src/core/baseLlmClient.js +231 -0
  94. package/dist/src/core/baseLlmClient.js.map +1 -0
  95. package/dist/src/core/bucketFailoverIntegration.d.ts +62 -0
  96. package/dist/src/core/bucketFailoverIntegration.js +186 -0
  97. package/dist/src/core/bucketFailoverIntegration.js.map +1 -0
  98. package/dist/src/core/chatSession.d.ts +121 -0
  99. package/dist/src/core/chatSession.js +720 -0
  100. package/dist/src/core/chatSession.js.map +1 -0
  101. package/dist/src/core/client.d.ts +132 -0
  102. package/dist/src/core/client.js +524 -0
  103. package/dist/src/core/client.js.map +1 -0
  104. package/dist/src/core/clientHelpers.d.ts +15 -0
  105. package/dist/src/core/clientHelpers.js +122 -0
  106. package/dist/src/core/clientHelpers.js.map +1 -0
  107. package/dist/src/core/clientLlmUtilities.d.ts +30 -0
  108. package/dist/src/core/clientLlmUtilities.js +125 -0
  109. package/dist/src/core/clientLlmUtilities.js.map +1 -0
  110. package/dist/src/core/clientToolGovernance.d.ts +37 -0
  111. package/dist/src/core/clientToolGovernance.js +104 -0
  112. package/dist/src/core/clientToolGovernance.js.map +1 -0
  113. package/dist/src/core/compression-config.d.ts +12 -0
  114. package/dist/src/core/compression-config.js +21 -0
  115. package/dist/src/core/compression-config.js.map +1 -0
  116. package/dist/src/core/coreToolScheduler.d.ts +105 -0
  117. package/dist/src/core/coreToolScheduler.js +453 -0
  118. package/dist/src/core/coreToolScheduler.js.map +1 -0
  119. package/dist/src/core/hookToolRestrictions.d.ts +18 -0
  120. package/dist/src/core/hookToolRestrictions.js +187 -0
  121. package/dist/src/core/hookToolRestrictions.js.map +1 -0
  122. package/dist/src/core/nonInteractiveToolExecutor.d.ts +17 -0
  123. package/dist/src/core/nonInteractiveToolExecutor.js +102 -0
  124. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
  125. package/dist/src/core/subagent.d.ts +105 -0
  126. package/dist/src/core/subagent.js +650 -0
  127. package/dist/src/core/subagent.js.map +1 -0
  128. package/dist/src/core/subagentExecution.d.ts +104 -0
  129. package/dist/src/core/subagentExecution.js +275 -0
  130. package/dist/src/core/subagentExecution.js.map +1 -0
  131. package/dist/src/core/subagentOrchestrator.d.ts +84 -0
  132. package/dist/src/core/subagentOrchestrator.js +503 -0
  133. package/dist/src/core/subagentOrchestrator.js.map +1 -0
  134. package/dist/src/core/subagentRuntimeSetup.d.ts +75 -0
  135. package/dist/src/core/subagentRuntimeSetup.js +387 -0
  136. package/dist/src/core/subagentRuntimeSetup.js.map +1 -0
  137. package/dist/src/core/subagentScheduler.d.ts +17 -0
  138. package/dist/src/core/subagentScheduler.js +7 -0
  139. package/dist/src/core/subagentScheduler.js.map +1 -0
  140. package/dist/src/core/subagentToolProcessing.d.ts +51 -0
  141. package/dist/src/core/subagentToolProcessing.js +359 -0
  142. package/dist/src/core/subagentToolProcessing.js.map +1 -0
  143. package/dist/src/core/toolGovernance.d.ts +18 -0
  144. package/dist/src/core/toolGovernance.js +50 -0
  145. package/dist/src/core/toolGovernance.js.map +1 -0
  146. package/dist/src/core/turn.d.ts +47 -0
  147. package/dist/src/core/turn.js +455 -0
  148. package/dist/src/core/turn.js.map +1 -0
  149. package/dist/src/core/turnLogging.d.ts +35 -0
  150. package/dist/src/core/turnLogging.js +80 -0
  151. package/dist/src/core/turnLogging.js.map +1 -0
  152. package/dist/src/index.d.ts +32 -0
  153. package/dist/src/index.js +44 -0
  154. package/dist/src/index.js.map +1 -0
  155. package/dist/src/scheduler/confirmation-coordinator.d.ts +139 -0
  156. package/dist/src/scheduler/confirmation-coordinator.js +443 -0
  157. package/dist/src/scheduler/confirmation-coordinator.js.map +1 -0
  158. package/dist/src/scheduler/result-aggregator.d.ts +127 -0
  159. package/dist/src/scheduler/result-aggregator.js +302 -0
  160. package/dist/src/scheduler/result-aggregator.js.map +1 -0
  161. package/dist/src/scheduler/status-transitions.d.ts +39 -0
  162. package/dist/src/scheduler/status-transitions.js +184 -0
  163. package/dist/src/scheduler/status-transitions.js.map +1 -0
  164. package/dist/src/scheduler/tool-dispatcher.d.ts +40 -0
  165. package/dist/src/scheduler/tool-dispatcher.js +120 -0
  166. package/dist/src/scheduler/tool-dispatcher.js.map +1 -0
  167. package/dist/src/scheduler/tool-executor.d.ts +44 -0
  168. package/dist/src/scheduler/tool-executor.js +117 -0
  169. package/dist/src/scheduler/tool-executor.js.map +1 -0
  170. package/dist/src/scheduler/utils.d.ts +11 -0
  171. package/dist/src/scheduler/utils.js +19 -0
  172. package/dist/src/scheduler/utils.js.map +1 -0
  173. package/dist/src/tools/task.d.ts +128 -0
  174. package/dist/src/tools/task.js +932 -0
  175. package/dist/src/tools/task.js.map +1 -0
  176. package/package.json +54 -0
File without changes
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @plan:PLAN-20260610-ISSUE1592.P02
3
+ * @requirement:REQ-PKG-001
4
+ */
5
+ /**
6
+ * @license
7
+ * Copyright 2025 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
10
+ export * from './src/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @plan:PLAN-20260610-ISSUE1592.P02
3
+ * @requirement:REQ-PKG-001
4
+ */
5
+ /**
6
+ * @license
7
+ * Copyright 2025 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
10
+ export * from './src/index.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { Config } from '@vybestack/llxprt-code-core/config/config.js';
7
+ import type { AgentInputs } from './types.js';
8
+ /**
9
+ * Build the system prompt for an agent execution.
10
+ */
11
+ export declare function buildAgentSystemPrompt(inputs: AgentInputs, runtimeContext: Config, systemPromptTemplate: string): Promise<string>;
12
+ /**
13
+ * Apply template strings to initial messages.
14
+ */
15
+ export declare function applyTemplateToInitialMessages<T extends {
16
+ parts?: Array<{
17
+ text?: string;
18
+ } | object>;
19
+ }>(initialMessages: T[], inputs: AgentInputs): T[];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { getDirectoryContextString } from '@vybestack/llxprt-code-core/utils/environmentContext.js';
7
+ import { templateString } from './utils.js';
8
+ const TASK_COMPLETE_TOOL_NAME = 'complete_task';
9
+ /**
10
+ * Build the system prompt for an agent execution.
11
+ */
12
+ export async function buildAgentSystemPrompt(inputs, runtimeContext, systemPromptTemplate) {
13
+ // Inject user inputs into the prompt template.
14
+ let finalPrompt = templateString(systemPromptTemplate, inputs);
15
+ // Append environment context (CWD and folder structure).
16
+ const dirContext = await getDirectoryContextString(runtimeContext);
17
+ finalPrompt += `\n\n# Environment Context\n${dirContext}`;
18
+ // Append standard rules for non-interactive execution.
19
+ finalPrompt += `
20
+ Important Rules:
21
+ * You are running in a non-interactive mode. You CANNOT ask the user for input or clarification.
22
+ * Work systematically using available tools to complete your task.
23
+ * Always use absolute paths for file operations. Construct them using the provided "Environment Context".`;
24
+ finalPrompt += `
25
+ * When you have completed your task, you MUST call the \`${TASK_COMPLETE_TOOL_NAME}\` tool.
26
+ * Do not call any other tools in the same turn as \`${TASK_COMPLETE_TOOL_NAME}\`.
27
+ * This is the ONLY way to complete your mission. If you stop calling tools without calling this, you have failed.`;
28
+ return finalPrompt;
29
+ }
30
+ /**
31
+ * Apply template strings to initial messages.
32
+ */
33
+ export function applyTemplateToInitialMessages(initialMessages, inputs) {
34
+ return initialMessages.map((content) => {
35
+ const newParts = (content.parts ?? []).map((part) => {
36
+ if ('text' in part && part.text !== undefined) {
37
+ return { text: templateString(part.text, inputs) };
38
+ }
39
+ return part;
40
+ });
41
+ return { ...content, parts: newParts };
42
+ });
43
+ }
44
+ //# sourceMappingURL=executor-prompt-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor-prompt-builder.js","sourceRoot":"","sources":["../../../src/agents/executor-prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,yDAAyD,CAAC;AAEpG,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,uBAAuB,GAAG,eAAe,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAmB,EACnB,cAAsB,EACtB,oBAA4B;IAE5B,+CAA+C;IAC/C,IAAI,WAAW,GAAG,cAAc,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAE/D,yDAAyD;IACzD,MAAM,UAAU,GAAG,MAAM,yBAAyB,CAAC,cAAc,CAAC,CAAC;IACnE,WAAW,IAAI,8BAA8B,UAAU,EAAE,CAAC;IAE1D,uDAAuD;IACvD,WAAW,IAAI;;;;0GAIyF,CAAC;IAEzG,WAAW,IAAI;2DAC0C,uBAAuB;sDAC5B,uBAAuB;kHACqC,CAAC;IAEjH,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAE5C,eAAoB,EAAE,MAAmB;IACzC,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAClD,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC9C,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAO,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { AgentTerminateMode } from './types.js';
7
+ /**
8
+ * Checks if the agent should terminate due to exceeding configured limits.
9
+ *
10
+ * @param runConfig The run configuration with max_turns and max_time_minutes.
11
+ * @param startTime The timestamp (ms) when execution started.
12
+ * @param turnCounter The current turn number.
13
+ * @param recoveryDeadlineMs If in a recovery turn, the absolute deadline (ms)
14
+ * that overrides the normal max_time_minutes timeout. When provided, the
15
+ * max_turns limit is also bypassed since recovery turns are exempt from turn
16
+ * counting. Pass `undefined` when not in recovery mode.
17
+ * @returns The reason for termination, or `null` if execution can continue.
18
+ */
19
+ export declare function checkAgentTermination(runConfig: {
20
+ max_turns?: number;
21
+ max_time_minutes: number;
22
+ }, startTime: number, turnCounter: number, recoveryDeadlineMs?: number): AgentTerminateMode | null;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { AgentTerminateMode } from './types.js';
7
+ /** Whether the given max_turns value represents a real, positive limit. */
8
+ function hasMaxTurnsLimit(maxTurns) {
9
+ return (typeof maxTurns === 'number' && maxTurns > 0 && !Number.isNaN(maxTurns));
10
+ }
11
+ /**
12
+ * Checks if the agent should terminate due to exceeding configured limits.
13
+ *
14
+ * @param runConfig The run configuration with max_turns and max_time_minutes.
15
+ * @param startTime The timestamp (ms) when execution started.
16
+ * @param turnCounter The current turn number.
17
+ * @param recoveryDeadlineMs If in a recovery turn, the absolute deadline (ms)
18
+ * that overrides the normal max_time_minutes timeout. When provided, the
19
+ * max_turns limit is also bypassed since recovery turns are exempt from turn
20
+ * counting. Pass `undefined` when not in recovery mode.
21
+ * @returns The reason for termination, or `null` if execution can continue.
22
+ */
23
+ export function checkAgentTermination(runConfig, startTime, turnCounter, recoveryDeadlineMs) {
24
+ const inRecovery = recoveryDeadlineMs !== undefined;
25
+ if (!inRecovery &&
26
+ hasMaxTurnsLimit(runConfig.max_turns) &&
27
+ turnCounter >= runConfig.max_turns) {
28
+ return AgentTerminateMode.MAX_TURNS;
29
+ }
30
+ const now = Date.now();
31
+ if (inRecovery) {
32
+ if (now >= recoveryDeadlineMs) {
33
+ return AgentTerminateMode.TIMEOUT;
34
+ }
35
+ }
36
+ else {
37
+ const elapsedMinutes = (now - startTime) / (1000 * 60);
38
+ if (elapsedMinutes >= runConfig.max_time_minutes) {
39
+ return AgentTerminateMode.TIMEOUT;
40
+ }
41
+ }
42
+ return null;
43
+ }
44
+ //# sourceMappingURL=executor-termination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor-termination.js","sourceRoot":"","sources":["../../../src/agents/executor-termination.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,2EAA2E;AAC3E,SAAS,gBAAgB,CAAC,QAA4B;IACpD,OAAO,CACL,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CACxE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAA2D,EAC3D,SAAiB,EACjB,WAAmB,EACnB,kBAA2B;IAE3B,MAAM,UAAU,GAAG,kBAAkB,KAAK,SAAS,CAAC;IAEpD,IACE,CAAC,UAAU;QACX,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC;QACrC,WAAW,IAAI,SAAS,CAAC,SAAS,EAClC,CAAC;QACD,OAAO,kBAAkB,CAAC,SAAS,CAAC;IACtC,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEvB,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,GAAG,IAAI,kBAAkB,EAAE,CAAC;YAC9B,OAAO,kBAAkB,CAAC,OAAO,CAAC;QACpC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,cAAc,GAAG,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;QACvD,IAAI,cAAc,IAAI,SAAS,CAAC,gBAAgB,EAAE,CAAC;YACjD,OAAO,kBAAkB,CAAC,OAAO,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ToolRegistry } from '@vybestack/llxprt-code-tools';
7
+ /**
8
+ * Tools that are currently approved for non-interactive execution while
9
+ * subagent confirmation handling remains restricted to this allowlist.
10
+ */
11
+ export declare const NON_INTERACTIVE_TOOL_ALLOWLIST: Set<string>;
12
+ /**
13
+ * Validates that all tools in a registry are safe for non-interactive use.
14
+ *
15
+ * @throws An error if a tool is not on the allow-list for non-interactive execution.
16
+ */
17
+ export declare function validateToolsForNonInteractiveUse(toolRegistry: ToolRegistry, agentName: string): Promise<void>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { GlobTool, GrepTool, LSTool, ReadFileTool, ReadManyFilesTool, RipGrepTool, MemoryTool, GoogleWebSearchTool, } from '@vybestack/llxprt-code-tools';
7
+ /**
8
+ * Tools that are currently approved for non-interactive execution while
9
+ * subagent confirmation handling remains restricted to this allowlist.
10
+ */
11
+ export const NON_INTERACTIVE_TOOL_ALLOWLIST = new Set([
12
+ LSTool.Name,
13
+ ReadFileTool.Name,
14
+ GrepTool.Name,
15
+ RipGrepTool.Name,
16
+ GlobTool.Name,
17
+ ReadManyFilesTool.Name,
18
+ MemoryTool.Name,
19
+ GoogleWebSearchTool.Name,
20
+ ]);
21
+ /**
22
+ * Validates that all tools in a registry are safe for non-interactive use.
23
+ *
24
+ * @throws An error if a tool is not on the allow-list for non-interactive execution.
25
+ */
26
+ export async function validateToolsForNonInteractiveUse(toolRegistry, agentName) {
27
+ for (const tool of toolRegistry.getAllTools()) {
28
+ if (!NON_INTERACTIVE_TOOL_ALLOWLIST.has(tool.name)) {
29
+ throw new Error(`Tool "${tool.name}" is not on the allow-list for non-interactive ` +
30
+ `execution in agent "${agentName}". Only tools that do not require user ` +
31
+ `confirmation can be used in subagents.`);
32
+ }
33
+ }
34
+ }
35
+ //# sourceMappingURL=executor-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor-validation.js","sourceRoot":"","sources":["../../../src/agents/executor-validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,GAAG,CAAC;IACpD,MAAM,CAAC,IAAI;IACX,YAAY,CAAC,IAAI;IACjB,QAAQ,CAAC,IAAI;IACb,WAAW,CAAC,IAAI;IAChB,QAAQ,CAAC,IAAI;IACb,iBAAiB,CAAC,IAAI;IACtB,UAAU,CAAC,IAAI;IACf,mBAAmB,CAAC,IAAI;CACzB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,YAA0B,EAC1B,SAAiB;IAEjB,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;QAC9C,IAAI,CAAC,8BAA8B,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CACb,SAAS,IAAI,CAAC,IAAI,iDAAiD;gBACjE,uBAAuB,SAAS,yCAAyC;gBACzE,wCAAwC,CAC3C,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { Config } from '@vybestack/llxprt-code-core/config/config.js';
7
+ import type { MessageBus } from '@vybestack/llxprt-code-core/confirmation-bus/message-bus.js';
8
+ import type { AgentDefinition, AgentInputs, OutputObject, SubagentActivityEvent } from './types.js';
9
+ import { type z } from 'zod';
10
+ /** A callback function to report on agent activity. */
11
+ export type ActivityCallback = (activity: SubagentActivityEvent) => void;
12
+ /**
13
+ * Executes an agent loop based on an {@link AgentDefinition}.
14
+ *
15
+ * This executor runs the agent in a loop, calling tools until it calls the
16
+ * mandatory `complete_task` tool to signal completion.
17
+ */
18
+ export declare class AgentExecutor<TOutput extends z.ZodTypeAny> {
19
+ readonly definition: AgentDefinition<TOutput>;
20
+ private readonly agentId;
21
+ private readonly toolRegistry;
22
+ private readonly runtimeContext;
23
+ private readonly messageBus;
24
+ private readonly onActivity?;
25
+ /**
26
+ * Creates and validates a new `AgentExecutor` instance.
27
+ *
28
+ * This method ensures that all tools specified in the agent's definition are
29
+ * safe for non-interactive use before creating the executor.
30
+ *
31
+ * @param definition The definition object for the agent.
32
+ * @param runtimeContext The global runtime configuration.
33
+ * @param onActivity An optional callback to receive activity events.
34
+ * @returns A promise that resolves to a new `AgentExecutor` instance.
35
+ */
36
+ /**
37
+ * @plan PLAN-20260309-MESSAGEBUS-DI-REMEDIATION.P05
38
+ * @requirement REQ-D01-001.2
39
+ * @pseudocode lines 56-72
40
+ */
41
+ static create<TOutput extends z.ZodTypeAny>(definition: AgentDefinition<TOutput>, runtimeContext: Config, messageBus: MessageBus, onActivity?: ActivityCallback): Promise<AgentExecutor<TOutput>>;
42
+ /**
43
+ * Constructs a new AgentExecutor instance.
44
+ *
45
+ * @private This constructor is private. Use the static `create` method to
46
+ * instantiate the class.
47
+ */
48
+ private constructor();
49
+ /**
50
+ * Runs the agent.
51
+ *
52
+ * @param inputs The validated input parameters for this invocation.
53
+ * @param signal An `AbortSignal` for cancellation.
54
+ * @returns A promise that resolves to the agent's final output.
55
+ */
56
+ run(inputs: AgentInputs, signal: AbortSignal): Promise<OutputObject>;
57
+ /** Runs the agent loop until termination, returning the reason and result. */
58
+ private runAgentLoop;
59
+ /** Single iteration of the agent loop. */
60
+ private runAgentLoopIteration;
61
+ /** Body of the agent loop iteration (after termination checks). */
62
+ private runAgentLoopIterationBody;
63
+ /** Check tool calls during recovery: non-complete_task = recovery failure. */
64
+ private checkRecoveryToolCalls;
65
+ /** Handle termination-reason checks: enter recovery or return immediately. */
66
+ private handleTerminationReason;
67
+ /** Handle the protocol-violation path (model stopped calling tools). */
68
+ private handleProtocolViolation;
69
+ private isAborted;
70
+ /** Create an AbortController that fires when the recovery deadline passes. */
71
+ private createRecoveryAbortController;
72
+ /** Emit a RECOVERY_OUTCOME telemetry event. */
73
+ private emitRecoveryOutcome;
74
+ /**
75
+ * Calls the generative model with the current context and tools.
76
+ *
77
+ * @returns The model's response, including any tool calls or text.
78
+ */
79
+ private callModel;
80
+ /** Consumes a response stream, accumulating function calls and text. */
81
+ private consumeStream;
82
+ /** Processes a single stream chunk, extracting thoughts, function calls, and text. */
83
+ private processStreamChunk;
84
+ /** Initializes a `ChatSession` instance for the agent run. */
85
+ private createChatObject;
86
+ /** Builds the generation config from model config and optional system instruction. */
87
+ private buildGenerationConfig;
88
+ /** Builds the runtime bundle for the ChatSession instance. */
89
+ private buildRuntimeBundle;
90
+ /** Resolves the settings snapshot from ephemeral config. */
91
+ private resolveSettingsSnapshot;
92
+ /** Attempts to get the content generator from the runtime context. */
93
+ private tryGetContentGenerator;
94
+ /**
95
+ * Executes function calls requested by the model and returns the results.
96
+ *
97
+ * @returns A new `Content` object for history, any submitted output, and completion status.
98
+ */
99
+ private processFunctionCalls;
100
+ /** Handles a `complete_task` function call, returning updated state and response parts. */
101
+ private handleCompleteTaskCall;
102
+ /** Processes the output argument of a `complete_task` call when outputConfig is present. */
103
+ private processCompleteTaskOutput;
104
+ /** Handles an unauthorized tool call by pushing an error response. */
105
+ private handleUnauthorizedToolCall;
106
+ /** Creates an async promise that executes a standard tool call. */
107
+ private createToolExecutionPromise;
108
+ /** Assembles all tool response parts and returns the final result. */
109
+ private assembleToolResponses;
110
+ /**
111
+ * Prepares the list of tool function declarations to be sent to the model.
112
+ */
113
+ private prepareToolsList;
114
+ /** Builds the system prompt from the agent definition and inputs. */
115
+ private buildSystemPrompt;
116
+ /**
117
+ * Applies template strings to initial messages.
118
+ *
119
+ * @param initialMessages The initial messages from the prompt config.
120
+ * @param inputs The validated input parameters for this invocation.
121
+ * @returns A new array of `Content` with templated strings.
122
+ */
123
+ private applyTemplateToInitialMessages;
124
+ /**
125
+ * Checks if the agent should terminate due to exceeding configured limits.
126
+ *
127
+ * @param startTime The timestamp (ms) when execution started.
128
+ * @param turnCounter The current turn number.
129
+ * @param recoveryDeadlineMs If in a recovery turn, the absolute deadline (ms)
130
+ * that overrides normal max_time_minutes. Pass `undefined` when not recovering.
131
+ * @returns The reason for termination, or `null` if execution can continue.
132
+ */
133
+ private checkTermination;
134
+ /** Emits an activity event to the configured callback. */
135
+ private emitActivity;
136
+ }