@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
@@ -0,0 +1,387 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * @fileoverview Execution environment preparation for subagents.
8
+ * Contains standalone functions for validation, configuration building,
9
+ * chat object creation, and prompt assembly.
10
+ *
11
+ * Extracted from subagent.ts as part of Issue #1581 (Phase 2).
12
+ */
13
+ import { reportError } from '@vybestack/llxprt-code-core/utils/errorReporting.js';
14
+ import { DebugLogger } from '@vybestack/llxprt-code-core/debug/DebugLogger.js';
15
+ import { ApprovalMode, } from '@vybestack/llxprt-code-core/config/config.js';
16
+ import { Type, } from '@google/genai';
17
+ import { ChatSession } from './chatSession.js';
18
+ import { getCoreSystemPromptAsync } from '@vybestack/llxprt-code-core/core/prompts.js';
19
+ import { EmojiFilter, } from '@vybestack/llxprt-code-core/filters/EmojiFilter.js';
20
+ import { debugLogger } from '@vybestack/llxprt-code-core/utils/debugLogger.js';
21
+ import { templateString, } from '@vybestack/llxprt-code-core/core/subagentTypes.js';
22
+ // ---------------------------------------------------------------------------
23
+ // Simple utilities
24
+ // ---------------------------------------------------------------------------
25
+ /** Canonicalizes a tool name for whitelist matching (trim + lowercase). */
26
+ export const canonicalizeToolName = (name) => name.trim().toLowerCase();
27
+ /**
28
+ * Converts a ToolMetadata object into a FunctionDeclaration for the Gemini API.
29
+ */
30
+ export function convertMetadataToFunctionDeclaration(fallbackName, metadata) {
31
+ const rawSchema = metadata.parameterSchema && typeof metadata.parameterSchema === 'object'
32
+ ? { ...metadata.parameterSchema }
33
+ : {};
34
+ const properties = rawSchema.properties ?? {};
35
+ const parameterType = rawSchema.type ?? Type.OBJECT;
36
+ const parameterProperties = { ...properties };
37
+ const parametersJsonSchema = {
38
+ ...rawSchema,
39
+ type: parameterType,
40
+ properties: parameterProperties,
41
+ };
42
+ return {
43
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
44
+ name: metadata.name ?? fallbackName,
45
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
46
+ description: metadata.description ?? '',
47
+ parametersJsonSchema,
48
+ };
49
+ }
50
+ // ---------------------------------------------------------------------------
51
+ // Validation
52
+ // ---------------------------------------------------------------------------
53
+ /**
54
+ * Filters the tools in toolConfig against the allowed set from the runtime view.
55
+ * Returns a new ToolConfig with only the tools that are permitted.
56
+ * Tools not in the allowed set are logged as warnings and removed.
57
+ *
58
+ * @param params - Object containing toolConfig and toolsView
59
+ * @returns A Promise that resolves to a filtered ToolConfig
60
+ */
61
+ export async function filterToolsAgainstRuntime(params) {
62
+ const { toolConfig, toolsView } = params;
63
+ const allowedNames = new Set((typeof toolsView.listToolNames === 'function'
64
+ ? toolsView.listToolNames()
65
+ : []).map(canonicalizeToolName));
66
+ const filteredTools = [];
67
+ // eslint-disable-next-line sonarjs/too-many-break-or-continue-in-loop -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
68
+ for (const toolEntry of toolConfig.tools) {
69
+ if (typeof toolEntry !== 'string') {
70
+ // Non-string entries (e.g., FunctionDeclaration objects) are preserved
71
+ filteredTools.push(toolEntry);
72
+ continue;
73
+ }
74
+ if (allowedNames.size > 0 &&
75
+ !allowedNames.has(canonicalizeToolName(toolEntry))) {
76
+ debugLogger.warn(`Tool "${toolEntry}" is not permitted by the runtime view and is skipped.`);
77
+ continue;
78
+ }
79
+ filteredTools.push(toolEntry);
80
+ }
81
+ return {
82
+ ...toolConfig,
83
+ tools: filteredTools,
84
+ };
85
+ }
86
+ // ---------------------------------------------------------------------------
87
+ // Ephemeral settings & tool execution config
88
+ // ---------------------------------------------------------------------------
89
+ export function buildEphemeralSettings(snapshot) {
90
+ const ephemerals = {};
91
+ if (!snapshot) {
92
+ ephemerals.emojifilter = 'auto';
93
+ return ephemerals;
94
+ }
95
+ if (snapshot.emojifilter !== undefined) {
96
+ ephemerals.emojifilter = snapshot.emojifilter;
97
+ }
98
+ else {
99
+ ephemerals.emojifilter = 'auto';
100
+ }
101
+ if (snapshot.tools?.allowed) {
102
+ ephemerals['tools.allowed'] = [...snapshot.tools.allowed];
103
+ }
104
+ if (snapshot.tools?.disabled) {
105
+ ephemerals['tools.disabled'] = [...snapshot.tools.disabled];
106
+ }
107
+ return ephemerals;
108
+ }
109
+ /**
110
+ * Creates the bottom-layer tool execution configuration for subagents.
111
+ *
112
+ * This is the single source of truth for tool-related configuration in the
113
+ * subagent, including scheduler creation. It interfaces directly with
114
+ * `foregroundConfig` and is responsible for injecting default dependencies
115
+ * (`messageBus` and `toolRegistry`) that callers may not provide.
116
+ *
117
+ * Delegation chain: createSchedulerConfig → toolExecutorContext → foregroundConfig
118
+ */
119
+ export function createToolExecutionConfig(runtimeBundle, toolRegistry, foregroundConfig, messageBus, settingsSnapshot, toolConfig) {
120
+ const ephemerals = buildEphemeralSettings(settingsSnapshot);
121
+ if (toolConfig && Array.isArray(toolConfig.tools)) {
122
+ applyToolWhitelistToEphemerals(ephemerals, toolConfig);
123
+ }
124
+ return {
125
+ getToolRegistry: () => toolRegistry,
126
+ getEphemeralSettings: () => ({ ...ephemerals }),
127
+ getEphemeralSetting: (key) => ephemerals[key],
128
+ getExcludeTools: () => [],
129
+ getSessionId: () => runtimeBundle.runtimeContext.state.sessionId,
130
+ getTelemetryLogPromptsEnabled: () => Boolean(settingsSnapshot?.telemetry?.enabled),
131
+ getOrCreateScheduler: (sessionId, callbacks, options, dependencies) => foregroundConfig.getOrCreateScheduler(sessionId, callbacks, options, {
132
+ messageBus: dependencies?.messageBus ?? messageBus,
133
+ toolRegistry: dependencies?.toolRegistry ?? toolRegistry,
134
+ }),
135
+ disposeScheduler: (sessionId) => foregroundConfig.disposeScheduler(sessionId),
136
+ };
137
+ }
138
+ /** @internal — applies tool whitelist from toolConfig onto ephemeral settings */
139
+ function applyToolWhitelistToEphemerals(ephemerals, toolConfig) {
140
+ const normalizedWhitelist = toolConfig.tools
141
+ .filter((entry) => typeof entry === 'string')
142
+ .map((entry) => entry.trim())
143
+ .filter((entry) => entry.length > 0)
144
+ .map((entry) => entry.toLowerCase());
145
+ if (normalizedWhitelist.length === 0)
146
+ return;
147
+ const existingAllowed = Array.isArray(ephemerals['tools.allowed'])
148
+ ? ephemerals['tools.allowed']
149
+ .map((entry) => (typeof entry === 'string' ? entry.trim() : ''))
150
+ .filter((entry) => entry.length > 0)
151
+ .map((entry) => entry.toLowerCase())
152
+ : [];
153
+ const allowedSet = existingAllowed.length > 0
154
+ ? normalizedWhitelist.filter((entry) => existingAllowed.includes(entry))
155
+ : normalizedWhitelist;
156
+ ephemerals['tools.allowed'] = Array.from(new Set(allowedSet));
157
+ }
158
+ // ---------------------------------------------------------------------------
159
+ // Emoji filter
160
+ // ---------------------------------------------------------------------------
161
+ export function createEmojiFilter(settingsSnapshot) {
162
+ const filterMode =
163
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
164
+ settingsSnapshot?.emojifilter ?? 'auto';
165
+ if (filterMode === 'allowed') {
166
+ const noFilter = void 0;
167
+ return noFilter;
168
+ }
169
+ return new EmojiFilter({ mode: filterMode });
170
+ }
171
+ // ---------------------------------------------------------------------------
172
+ // Function declarations
173
+ // ---------------------------------------------------------------------------
174
+ export function buildRuntimeFunctionDeclarations(toolsView, toolConfig) {
175
+ if (!toolConfig || toolConfig.tools.length === 0) {
176
+ const noFunctionDeclarations = [];
177
+ return noFunctionDeclarations;
178
+ }
179
+ const listedNames = typeof toolsView.listToolNames === 'function'
180
+ ? toolsView.listToolNames()
181
+ : [];
182
+ const allowedNames = new Set(listedNames.map(canonicalizeToolName));
183
+ const declarations = [];
184
+ // eslint-disable-next-line sonarjs/too-many-break-or-continue-in-loop -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
185
+ for (const entry of toolConfig.tools) {
186
+ if (typeof entry !== 'string') {
187
+ declarations.push(entry);
188
+ continue;
189
+ }
190
+ if (allowedNames.size > 0 &&
191
+ !allowedNames.has(canonicalizeToolName(entry))) {
192
+ debugLogger.warn(`Tool "${entry}" is not permitted by the runtime view and is skipped.`);
193
+ continue;
194
+ }
195
+ const metadata = toolsView.getToolMetadata(entry);
196
+ if (!metadata) {
197
+ debugLogger.warn(`Tool "${entry}" is not available in the runtime view and is skipped.`);
198
+ continue;
199
+ }
200
+ declarations.push(convertMetadataToFunctionDeclaration(entry, metadata));
201
+ }
202
+ return declarations;
203
+ }
204
+ export function getScopeLocalFuncDefs(outputConfig) {
205
+ if (!outputConfig?.outputs) {
206
+ return [];
207
+ }
208
+ const emitValueTool = {
209
+ name: 'self_emitvalue',
210
+ description: `* This tool emits A SINGLE return value from this execution, such that it can be collected and presented to the calling function.
211
+ * You can only emit ONE VALUE each time you call this tool. You are expected to call this tool MULTIPLE TIMES if you have MULTIPLE OUTPUTS.`,
212
+ parametersJsonSchema: {
213
+ type: Type.OBJECT,
214
+ properties: {
215
+ emit_variable_name: {
216
+ description: 'This is the name of the variable to be returned.',
217
+ type: Type.STRING,
218
+ },
219
+ emit_variable_value: {
220
+ description: 'This is the _value_ to be returned for this variable.',
221
+ type: Type.STRING,
222
+ },
223
+ },
224
+ required: ['emit_variable_name', 'emit_variable_value'],
225
+ },
226
+ };
227
+ return [emitValueTool];
228
+ }
229
+ // ---------------------------------------------------------------------------
230
+ // System prompt
231
+ // ---------------------------------------------------------------------------
232
+ export function buildChatSystemPrompt(promptConfig, outputConfig, context) {
233
+ let finalPrompt = templateString(promptConfig.systemPrompt, context);
234
+ if (outputConfig?.outputs) {
235
+ let outputInstructions = '\n\nAfter you have achieved all other goals, you MUST emit the required output variables. For each expected output, make one final call to the `self_emitvalue` tool.';
236
+ for (const [key, value] of Object.entries(outputConfig.outputs)) {
237
+ outputInstructions += `\n* Use 'self_emitvalue' to emit the '${key}' key, with a value described as: '${value}'`;
238
+ }
239
+ finalPrompt += outputInstructions;
240
+ }
241
+ finalPrompt += `
242
+
243
+ Important Rules:
244
+ * You are running in a non-interactive mode. You CANNOT ask the user for input or clarification. You must proceed with the information you have.
245
+ * Once you believe all goals have been met and all required outputs have been emitted, stop calling tools.`;
246
+ return finalPrompt;
247
+ }
248
+ // ---------------------------------------------------------------------------
249
+ // Scheduler config
250
+ // ---------------------------------------------------------------------------
251
+ /**
252
+ * Creates a higher-level Config facade for the CoreToolScheduler.
253
+ *
254
+ * This facade delegates scheduler operations (`getOrCreateScheduler`,
255
+ * `disposeScheduler`) through `toolExecutorContext` rather than bypassing
256
+ * it. The only policy this layer adds is the `interactiveMode` flag.
257
+ *
258
+ * Delegation chain: createSchedulerConfig → toolExecutorContext → foregroundConfig
259
+ */
260
+ export function createSchedulerConfig(toolExecutorContext, foregroundConfig, options) {
261
+ const isInteractive = options?.interactive ?? false;
262
+ const getEphemeralSettings = typeof toolExecutorContext.getEphemeralSettings === 'function'
263
+ ? () => ({
264
+ ...toolExecutorContext.getEphemeralSettings(),
265
+ })
266
+ : () => foregroundConfig.getEphemeralSettings();
267
+ const getEphemeralSetting = (key) => {
268
+ const settings = getEphemeralSettings();
269
+ return settings[key];
270
+ };
271
+ const getExcludeTools = typeof toolExecutorContext.getExcludeTools === 'function'
272
+ ? () => toolExecutorContext.getExcludeTools()
273
+ : // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
274
+ () => foregroundConfig.getExcludeTools?.() ?? [];
275
+ const getTelemetryLogPromptsEnabled = typeof toolExecutorContext.getTelemetryLogPromptsEnabled === 'function'
276
+ ? () => toolExecutorContext.getTelemetryLogPromptsEnabled()
277
+ : () => foregroundConfig.getTelemetryLogPromptsEnabled();
278
+ const getAllowedTools = () => {
279
+ const ephemerals = getEphemeralSettings();
280
+ const allowed = ephemerals['tools.allowed'];
281
+ if (Array.isArray(allowed)) {
282
+ return allowed.filter((entry) => typeof entry === 'string');
283
+ }
284
+ return typeof foregroundConfig.getAllowedTools === 'function'
285
+ ? foregroundConfig.getAllowedTools()
286
+ : undefined;
287
+ };
288
+ // Partial Config adapter for CoreToolScheduler — only the methods the
289
+ // scheduler and tool-execution paths actually call are implemented.
290
+ return {
291
+ getToolRegistry: () => toolExecutorContext.getToolRegistry(),
292
+ getSessionId: () => toolExecutorContext.getSessionId(),
293
+ getEphemeralSettings,
294
+ getEphemeralSetting,
295
+ getExcludeTools,
296
+ getTelemetryLogPromptsEnabled,
297
+ getAllowedTools,
298
+ getApprovalMode: () => typeof foregroundConfig.getApprovalMode === 'function'
299
+ ? foregroundConfig.getApprovalMode()
300
+ : ApprovalMode.DEFAULT,
301
+ getPolicyEngine: () => foregroundConfig.getPolicyEngine(),
302
+ getOrCreateScheduler: (sessionId, callbacks, schedulerOptions, dependencies) => toolExecutorContext.getOrCreateScheduler(sessionId, callbacks, { ...schedulerOptions, interactiveMode: isInteractive }, dependencies),
303
+ disposeScheduler: (sessionId) => {
304
+ toolExecutorContext.disposeScheduler(sessionId);
305
+ },
306
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
307
+ getEnableHooks: () => foregroundConfig.getEnableHooks?.() ?? false,
308
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
309
+ getHooks: () => foregroundConfig.getHooks?.(),
310
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
311
+ getHookSystem: () => foregroundConfig.getHookSystem?.(),
312
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
313
+ getWorkingDir: () => foregroundConfig.getWorkingDir?.() ?? process.cwd(),
314
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
315
+ getTargetDir: () => foregroundConfig.getTargetDir?.() ?? process.cwd(),
316
+ };
317
+ }
318
+ export async function createChatObject(params) {
319
+ const { promptConfig, modelConfig, outputConfig, toolConfig } = params;
320
+ const { runtimeContext, contentGenerator, environmentContextLoader } = params;
321
+ const { foregroundConfig: config, context } = params;
322
+ const logger = new DebugLogger('llxprt:subagent');
323
+ if (typeof promptConfig.systemPrompt !== 'string' ||
324
+ promptConfig.systemPrompt.trim().length === 0) {
325
+ throw new Error('PromptConfig.systemPrompt must be a non-empty string.');
326
+ }
327
+ const startHistory = [];
328
+ const personaPrompt = buildChatSystemPrompt(promptConfig, outputConfig, context);
329
+ const runtimeDecls = buildRuntimeFunctionDeclarations(runtimeContext.tools, toolConfig);
330
+ const scopeLocalDecls = getScopeLocalFuncDefs(outputConfig);
331
+ const combinedDeclarations = [...runtimeDecls, ...scopeLocalDecls];
332
+ const systemInstruction = await buildSystemInstruction(environmentContextLoader, runtimeContext, modelConfig, combinedDeclarations, config, personaPrompt, logger);
333
+ return instantiateChat(modelConfig, systemInstruction, combinedDeclarations, startHistory, runtimeContext, contentGenerator, logger);
334
+ }
335
+ async function buildSystemInstruction(environmentContextLoader, runtimeContext, modelConfig, combinedDeclarations, config, personaPrompt, logger) {
336
+ const envParts = await environmentContextLoader(runtimeContext);
337
+ const envContextText = envParts
338
+ .map((part) => ('text' in part ? part.text : ''))
339
+ .join('\n')
340
+ .trim();
341
+ const toolNames = Array.from(new Set(combinedDeclarations
342
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
343
+ .map((d) => d?.name?.trim())
344
+ .filter((name) => Boolean(name && name.length > 0))));
345
+ const mcpInstructions = config.getMcpClientManager()?.getMcpInstructions();
346
+ const coreSystemPrompt = await getCoreSystemPromptAsync({
347
+ mcpInstructions,
348
+ model: modelConfig.model,
349
+ tools: toolNames,
350
+ includeSubagentDelegation: false,
351
+ interactionMode: 'subagent',
352
+ });
353
+ const instructionSections = [
354
+ envContextText,
355
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
356
+ coreSystemPrompt?.trim() ?? '',
357
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
358
+ personaPrompt?.trim() ?? '',
359
+ ].filter((section) => section.length > 0);
360
+ const systemInstruction = instructionSections.length > 0 ? instructionSections.join('\n\n') : '';
361
+ logger.debug(() => {
362
+ const preview = systemInstruction && systemInstruction.length > 0
363
+ ? systemInstruction.slice(0, 1200)
364
+ : '<empty>';
365
+ return `System instruction preview: ${preview}`;
366
+ });
367
+ return systemInstruction;
368
+ }
369
+ function instantiateChat(modelConfig, systemInstruction, combinedDeclarations, startHistory, runtimeContext, contentGenerator, _logger) {
370
+ try {
371
+ const generationConfig = {
372
+ temperature: modelConfig.temp,
373
+ topP: modelConfig.top_p,
374
+ systemInstruction: systemInstruction || undefined,
375
+ tools: combinedDeclarations.length > 0
376
+ ? [{ functionDeclarations: combinedDeclarations }]
377
+ : undefined,
378
+ };
379
+ return new ChatSession(runtimeContext, contentGenerator, generationConfig, startHistory);
380
+ }
381
+ catch (error) {
382
+ void reportError(error, 'Error initializing Gemini chat session.', startHistory, 'startChat');
383
+ const missingChatObject = null;
384
+ return missingChatObject;
385
+ }
386
+ }
387
+ //# sourceMappingURL=subagentRuntimeSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagentRuntimeSetup.js","sourceRoot":"","sources":["../../../src/core/subagentRuntimeSetup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qDAAqD,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AAE/E,OAAO,EACL,YAAY,GAGb,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAIL,IAAI,GACL,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAA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ClC,CAAC,CAAC,SAAS,CAAC;QAChB,OAAO,+BAA+B,OAAO,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,eAAe,CACtB,WAAwB,EACxB,iBAAyB,EACzB,oBAA2C,EAC3C,YAAuB,EACvB,cAAmC,EACnC,gBAAkC,EAClC,OAA8C;IAE9C,IAAI,CAAC;QACH,MAAM,gBAAgB,GAElB;YACF,WAAW,EAAE,WAAW,CAAC,IAAI;YAC7B,IAAI,EAAE,WAAW,CAAC,KAAK;YACvB,iBAAiB,EAAE,iBAAiB,IAAI,SAAS;YACjD,KAAK,EACH,oBAAoB,CAAC,MAAM,GAAG,CAAC;gBAC7B,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,CAAC;gBAClD,CAAC,CAAC,SAAS;SAChB,CAAC;QAEF,OAAO,IAAI,WAAW,CACpB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,CACb,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,WAAW,CACd,KAAK,EACL,yCAAyC,EACzC,YAAY,EACZ,WAAW,CACZ,CAAC;QACF,MAAM,iBAAiB,GAAuB,IAAI,CAAC;QACnD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,17 @@
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 { ToolCallRequestInfo } from './turn.js';
8
+ import type { CompletedToolCall, OutputUpdateHandler, ToolCallsUpdateHandler } from './coreToolScheduler.js';
9
+ export type SubagentSchedulerFactory = (args: {
10
+ schedulerConfig: Config;
11
+ onAllToolCallsComplete: (calls: CompletedToolCall[]) => Promise<void>;
12
+ outputUpdateHandler: OutputUpdateHandler;
13
+ onToolCallsUpdate?: ToolCallsUpdateHandler;
14
+ }) => {
15
+ schedule(request: ToolCallRequestInfo | ToolCallRequestInfo[], signal: AbortSignal): Promise<void> | void;
16
+ dispose?: () => void;
17
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=subagentScheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagentScheduler.js","sourceRoot":"","sources":["../../../src/core/subagentScheduler.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * @fileoverview Tool call dispatch, emit handling, and response building
8
+ * for subagents.
9
+ *
10
+ * Extracted from subagent.ts as part of Issue #1581 (Phase 3).
11
+ */
12
+ import type { DebugLogger } from '@vybestack/llxprt-code-core/debug/DebugLogger.js';
13
+ import type { Config } from '@vybestack/llxprt-code-core/config/config.js';
14
+ import { type ToolCallRequestInfo } from './turn.js';
15
+ import { type ToolExecutionConfig } from './nonInteractiveToolExecutor.js';
16
+ import { type Part, type FunctionCall, type Content } from '@google/genai';
17
+ import type { AgentRuntimeContext, ToolRegistryView } from '@vybestack/llxprt-code-core/runtime/AgentRuntimeContext.js';
18
+ import { ToolErrorType } from '@vybestack/llxprt-code-tools';
19
+ import { type ToolResultDisplay } from '@vybestack/llxprt-code-tools';
20
+ import { type CompletedToolCall } from './coreToolScheduler.js';
21
+ import { type OutputObject } from '@vybestack/llxprt-code-core/core/subagentTypes.js';
22
+ import type { MessageBus } from '@vybestack/llxprt-code-core/confirmation-bus/message-bus.js';
23
+ export declare function toSnakeCase(value: string): string;
24
+ export declare function isFatalToolError(errorType: ToolErrorType | undefined): boolean;
25
+ export declare function extractToolDetail(resultDisplay?: ToolResultDisplay, error?: Error): string | undefined;
26
+ export declare function buildToolUnavailableMessage(toolName: string, resultDisplay?: ToolResultDisplay, error?: Error): string;
27
+ export declare function resolveToolName(rawName: string | undefined, toolsView: ToolRegistryView): string | null;
28
+ export declare function finalizeOutput(output: OutputObject): void;
29
+ export interface EmitValueContext {
30
+ output: OutputObject;
31
+ onMessage?: (message: string) => void;
32
+ subagentId: string;
33
+ logger: DebugLogger;
34
+ }
35
+ export declare function handleEmitValueCall(request: ToolCallRequestInfo, ctx: EmitValueContext): Part[];
36
+ export interface BuildPartsContext {
37
+ onMessage?: (message: string) => void;
38
+ subagentId: string;
39
+ logger: DebugLogger;
40
+ }
41
+ export declare function buildPartsFromCompletedCalls(completedCalls: CompletedToolCall[], ctx: BuildPartsContext): Part[];
42
+ export interface ProcessFunctionCallsContext {
43
+ output: OutputObject;
44
+ subagentId: string;
45
+ logger: DebugLogger;
46
+ toolExecutorContext: ToolExecutionConfig;
47
+ config: Config;
48
+ messageBus?: MessageBus;
49
+ }
50
+ export declare function processFunctionCalls(functionCalls: FunctionCall[], abortController: AbortController, promptId: string, ctx: ProcessFunctionCallsContext): Promise<Content[]>;
51
+ export declare function buildTodoCompletionPrompt(runtimeContext: AgentRuntimeContext, subagentId: string, logger: DebugLogger): Promise<string | null>;