@didim365/agent-cli-core 0.2.3 → 0.2.6
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.
- package/dist/src/agents/llmAgentChatSession.d.ts +117 -0
- package/dist/src/agents/llmAgentChatSession.js +252 -0
- package/dist/src/agents/llmAgentChatSession.js.map +1 -0
- package/dist/src/agents/local-invocation.d.ts +7 -0
- package/dist/src/agents/local-invocation.js +71 -1
- package/dist/src/agents/local-invocation.js.map +1 -1
- package/dist/src/core/baseLlmClient.d.ts +16 -0
- package/dist/src/core/baseLlmClient.js +134 -2
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/client.d.ts +6 -0
- package/dist/src/core/client.js +75 -1
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +42 -5
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/llmMessageUtils.d.ts +36 -0
- package/dist/src/core/llmMessageUtils.js +66 -0
- package/dist/src/core/llmMessageUtils.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/ide/types.d.ts +4 -4
- package/dist/src/policy/policy-engine.js +20 -6
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/providers/gemini/requestBuilder.js +7 -1
- package/dist/src/providers/gemini/requestBuilder.js.map +1 -1
- package/dist/src/providers/gemini/typeConversion.d.ts +11 -2
- package/dist/src/providers/gemini/typeConversion.js +42 -0
- package/dist/src/providers/gemini/typeConversion.js.map +1 -1
- package/dist/src/scheduler/scheduler.js +36 -3
- package/dist/src/scheduler/scheduler.js.map +1 -1
- package/dist/src/services/sessionSummaryUtils.js +1 -8
- package/dist/src/services/sessionSummaryUtils.js.map +1 -1
- package/dist/src/tools/mcp-client.js +3 -12
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +9 -2
- package/dist/src/tools/mcp-tool.js +63 -11
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/tool-names.js +2 -1
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +16 -0
- package/dist/src/tools/tool-registry.js +111 -2
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/utils/tokenCalculation.js +37 -0
- package/dist/src/utils/tokenCalculation.js.map +1 -1
- package/dist/src/utils/tool-utils.d.ts +63 -0
- package/dist/src/utils/tool-utils.js +356 -0
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/utils/messageInspectors.d.ts +0 -16
- package/dist/src/utils/messageInspectors.js +0 -24
- package/dist/src/utils/messageInspectors.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @fileoverview LlmAgentChatSession — AgentChatSession implementation for non-Gemini providers.
|
|
8
|
+
*
|
|
9
|
+
* Bridges the provider-independent `llmGenerateContentStream()` API with the
|
|
10
|
+
* legacy `StreamEvent` protocol consumed by `local-executor.ts`.
|
|
11
|
+
*
|
|
12
|
+
* Key design decisions:
|
|
13
|
+
* - Dependency Injection: all external functions injected via constructor for testability
|
|
14
|
+
* - StreamEvent compatibility: constructs partial `GenerateContentResponse` objects
|
|
15
|
+
* with the exact fields accessed by `callModel()` in local-executor.ts:
|
|
16
|
+
* `chunk.candidates?.[0]?.content?.parts`, `chunk.functionCalls`,
|
|
17
|
+
* `parts?.find(p => p.thought)?.text`
|
|
18
|
+
* - Error → throw: LlmEventType.Error throws immediately (not yielded as StreamEvent)
|
|
19
|
+
* - History management: Gemini Content[] format for compatibility with local-executor
|
|
20
|
+
*/
|
|
21
|
+
import type { Content, PartListUnion, Tool } from '@google/genai';
|
|
22
|
+
import type { LlmEvent } from '../providers/events.js';
|
|
23
|
+
import type { StreamEvent } from '../providers/gemini/chat.js';
|
|
24
|
+
import type { LlmGenerateRequest, LlmMessage } from '../providers/types.js';
|
|
25
|
+
import type { ModelConfigKey } from '../services/modelConfigService.js';
|
|
26
|
+
import type { AgentChatSession } from './types.js';
|
|
27
|
+
/**
|
|
28
|
+
* Converts a provider-independent LlmEvent into a legacy StreamEvent
|
|
29
|
+
* compatible with local-executor's `callModel()`.
|
|
30
|
+
*
|
|
31
|
+
* Returns null for events that don't map to StreamEvent
|
|
32
|
+
* (Finished, MessageEnd, Error — handled separately by the session).
|
|
33
|
+
*/
|
|
34
|
+
export declare function convertLlmEventToStreamEvent(event: LlmEvent): StreamEvent | null;
|
|
35
|
+
/**
|
|
36
|
+
* Constructor options for LlmAgentChatSession.
|
|
37
|
+
* All external dependencies are injected for testability.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Generation parameters resolved from model config aliases/overrides.
|
|
41
|
+
* Maps to GenerateContentConfig fields from @google/genai SDK.
|
|
42
|
+
*/
|
|
43
|
+
export interface ResolvedGenerateConfig {
|
|
44
|
+
temperature?: number;
|
|
45
|
+
topP?: number;
|
|
46
|
+
topK?: number;
|
|
47
|
+
maxOutputTokens?: number;
|
|
48
|
+
stopSequences?: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface LlmAgentChatSessionOptions {
|
|
51
|
+
/** Content generator with llm* methods */
|
|
52
|
+
generator: {
|
|
53
|
+
llmGenerateContentStream: (request: LlmGenerateRequest, promptId: string, options?: {
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}) => AsyncGenerator<LlmEvent>;
|
|
56
|
+
};
|
|
57
|
+
/** Provider name (e.g., 'claude', 'openai') */
|
|
58
|
+
providerName: string;
|
|
59
|
+
/** System instruction for the model */
|
|
60
|
+
systemInstruction: string | undefined;
|
|
61
|
+
/** Available tools */
|
|
62
|
+
tools: Tool[];
|
|
63
|
+
/** Initial conversation history in Gemini Content[] format */
|
|
64
|
+
initialHistory: Content[];
|
|
65
|
+
resolveProviderModelFn: (model: string, providerName: string) => string;
|
|
66
|
+
buildLlmRequestFn: (options: {
|
|
67
|
+
history: LlmMessage[];
|
|
68
|
+
systemInstruction: string | undefined;
|
|
69
|
+
tools: Tool[];
|
|
70
|
+
}) => LlmGenerateRequest;
|
|
71
|
+
fixToolResultRolesFn: (messages: LlmMessage[]) => LlmMessage[];
|
|
72
|
+
convertContentsToLlmMessagesFn: (contents: Content[]) => LlmMessage[];
|
|
73
|
+
/**
|
|
74
|
+
* Resolves generation parameters (temperature, topP, maxOutputTokens, etc.)
|
|
75
|
+
* from a ModelConfigKey. Used to propagate agent alias/override config
|
|
76
|
+
* to non-Gemini provider requests. [리뷰 #1]
|
|
77
|
+
*/
|
|
78
|
+
resolveGenerateConfigFn?: (key: ModelConfigKey) => ResolvedGenerateConfig | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* AgentChatSession implementation that uses provider-independent
|
|
82
|
+
* `llmGenerateContentStream()` and converts events to legacy StreamEvent.
|
|
83
|
+
*
|
|
84
|
+
* Used when a non-Gemini provider is selected (Claude, OpenAI, etc.)
|
|
85
|
+
* and injected into `LocalAgentExecutor.create()` via `ChatSessionFactory`.
|
|
86
|
+
*/
|
|
87
|
+
export declare class LlmAgentChatSession implements AgentChatSession {
|
|
88
|
+
private readonly generator;
|
|
89
|
+
private readonly providerName;
|
|
90
|
+
private readonly systemInstruction;
|
|
91
|
+
private readonly tools;
|
|
92
|
+
private history;
|
|
93
|
+
private lastPromptTokenCount;
|
|
94
|
+
private readonly resolveProviderModelFn;
|
|
95
|
+
private readonly buildLlmRequestFn;
|
|
96
|
+
private readonly fixToolResultRolesFn;
|
|
97
|
+
private readonly convertContentsToLlmMessagesFn;
|
|
98
|
+
private readonly resolveGenerateConfigFn;
|
|
99
|
+
constructor(options: LlmAgentChatSessionOptions);
|
|
100
|
+
sendMessageStream(modelConfigKey: ModelConfigKey, message: PartListUnion, promptId: string, signal: AbortSignal): Promise<AsyncGenerator<StreamEvent>>;
|
|
101
|
+
setHistory(history: Content[]): void;
|
|
102
|
+
getHistory(_curated?: boolean): Content[];
|
|
103
|
+
getLastPromptTokenCount(): number;
|
|
104
|
+
/**
|
|
105
|
+
* Processes the LlmEvent stream: yields StreamEvents, tracks usage,
|
|
106
|
+
* and adds model response to history after successful completion.
|
|
107
|
+
*/
|
|
108
|
+
private processEventStream;
|
|
109
|
+
/**
|
|
110
|
+
* Updates last prompt token count from usage data.
|
|
111
|
+
*/
|
|
112
|
+
private updateUsage;
|
|
113
|
+
/**
|
|
114
|
+
* Adds the accumulated model response to history in Gemini Content format.
|
|
115
|
+
*/
|
|
116
|
+
private addModelResponseToHistory;
|
|
117
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { estimateTokenCountSync } from '../utils/tokenCalculation.js';
|
|
7
|
+
import { LlmEventType } from '../providers/events.js';
|
|
8
|
+
import { StreamEventType } from '../providers/gemini/chat.js';
|
|
9
|
+
// ─── convertLlmEventToStreamEvent ────────────────────────────────
|
|
10
|
+
/**
|
|
11
|
+
* Converts a provider-independent LlmEvent into a legacy StreamEvent
|
|
12
|
+
* compatible with local-executor's `callModel()`.
|
|
13
|
+
*
|
|
14
|
+
* Returns null for events that don't map to StreamEvent
|
|
15
|
+
* (Finished, MessageEnd, Error — handled separately by the session).
|
|
16
|
+
*/
|
|
17
|
+
export function convertLlmEventToStreamEvent(event) {
|
|
18
|
+
switch (event.type) {
|
|
19
|
+
case LlmEventType.TextDelta:
|
|
20
|
+
return {
|
|
21
|
+
type: StreamEventType.CHUNK,
|
|
22
|
+
value: {
|
|
23
|
+
candidates: [
|
|
24
|
+
{
|
|
25
|
+
content: {
|
|
26
|
+
parts: [{ text: event.text }],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
case LlmEventType.ThoughtDelta:
|
|
33
|
+
return {
|
|
34
|
+
type: StreamEventType.CHUNK,
|
|
35
|
+
value: {
|
|
36
|
+
candidates: [
|
|
37
|
+
{
|
|
38
|
+
content: {
|
|
39
|
+
parts: [{ text: event.thought, thought: true }],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
case LlmEventType.ToolCallRequest:
|
|
46
|
+
return {
|
|
47
|
+
type: StreamEventType.CHUNK,
|
|
48
|
+
value: {
|
|
49
|
+
candidates: [
|
|
50
|
+
{
|
|
51
|
+
content: {
|
|
52
|
+
parts: [
|
|
53
|
+
{
|
|
54
|
+
functionCall: {
|
|
55
|
+
id: event.callId,
|
|
56
|
+
name: event.name,
|
|
57
|
+
args: event.args,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
functionCalls: [
|
|
65
|
+
{
|
|
66
|
+
id: event.callId,
|
|
67
|
+
name: event.name,
|
|
68
|
+
args: event.args,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
case LlmEventType.Retry:
|
|
74
|
+
return { type: StreamEventType.RETRY };
|
|
75
|
+
case LlmEventType.AgentStopped:
|
|
76
|
+
return {
|
|
77
|
+
type: StreamEventType.AGENT_EXECUTION_STOPPED,
|
|
78
|
+
reason: event.reason ?? 'stopped',
|
|
79
|
+
};
|
|
80
|
+
case LlmEventType.AgentBlocked:
|
|
81
|
+
return {
|
|
82
|
+
type: StreamEventType.AGENT_EXECUTION_BLOCKED,
|
|
83
|
+
reason: event.reason ?? 'blocked',
|
|
84
|
+
};
|
|
85
|
+
default:
|
|
86
|
+
// Finished, MessageEnd, Error, and all other events → null
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* AgentChatSession implementation that uses provider-independent
|
|
92
|
+
* `llmGenerateContentStream()` and converts events to legacy StreamEvent.
|
|
93
|
+
*
|
|
94
|
+
* Used when a non-Gemini provider is selected (Claude, OpenAI, etc.)
|
|
95
|
+
* and injected into `LocalAgentExecutor.create()` via `ChatSessionFactory`.
|
|
96
|
+
*/
|
|
97
|
+
export class LlmAgentChatSession {
|
|
98
|
+
generator;
|
|
99
|
+
providerName;
|
|
100
|
+
systemInstruction;
|
|
101
|
+
tools;
|
|
102
|
+
history;
|
|
103
|
+
lastPromptTokenCount = 0;
|
|
104
|
+
// Injected dependencies
|
|
105
|
+
resolveProviderModelFn;
|
|
106
|
+
buildLlmRequestFn;
|
|
107
|
+
fixToolResultRolesFn;
|
|
108
|
+
convertContentsToLlmMessagesFn;
|
|
109
|
+
resolveGenerateConfigFn;
|
|
110
|
+
constructor(options) {
|
|
111
|
+
this.generator = options.generator;
|
|
112
|
+
this.providerName = options.providerName;
|
|
113
|
+
this.systemInstruction = options.systemInstruction;
|
|
114
|
+
this.tools = options.tools;
|
|
115
|
+
this.history = [...options.initialHistory];
|
|
116
|
+
this.resolveProviderModelFn = options.resolveProviderModelFn;
|
|
117
|
+
this.buildLlmRequestFn = options.buildLlmRequestFn;
|
|
118
|
+
this.fixToolResultRolesFn = options.fixToolResultRolesFn;
|
|
119
|
+
this.convertContentsToLlmMessagesFn =
|
|
120
|
+
options.convertContentsToLlmMessagesFn;
|
|
121
|
+
this.resolveGenerateConfigFn = options.resolveGenerateConfigFn;
|
|
122
|
+
}
|
|
123
|
+
// ─── AgentChatSession interface ──────────────────────────────────
|
|
124
|
+
async sendMessageStream(modelConfigKey, message, promptId, signal) {
|
|
125
|
+
// 1. Resolve provider model from config alias
|
|
126
|
+
const resolvedModel = this.resolveProviderModelFn(modelConfigKey.model, this.providerName);
|
|
127
|
+
// 2. Add user content to history BEFORE streaming (Gemini convention)
|
|
128
|
+
// PartListUnion = (Part | string)[] | Part | string → convert to Part[]
|
|
129
|
+
const rawParts = Array.isArray(message) ? message : [message];
|
|
130
|
+
const parts = rawParts.map((p) => typeof p === 'string' ? { text: p } : p);
|
|
131
|
+
const userContent = { role: 'user', parts };
|
|
132
|
+
this.history.push(userContent);
|
|
133
|
+
// 3. Build LLM request from current state
|
|
134
|
+
const llmMessages = this.convertContentsToLlmMessagesFn(this.history);
|
|
135
|
+
const request = this.buildLlmRequestFn({
|
|
136
|
+
history: llmMessages,
|
|
137
|
+
systemInstruction: this.systemInstruction,
|
|
138
|
+
tools: this.tools,
|
|
139
|
+
});
|
|
140
|
+
// 4. Apply fixToolResultRoles and override model
|
|
141
|
+
request.messages = this.fixToolResultRolesFn(request.messages);
|
|
142
|
+
request.model = resolvedModel;
|
|
143
|
+
// 4b. Apply generation config from model config aliases/overrides [리뷰 #1]
|
|
144
|
+
if (this.resolveGenerateConfigFn) {
|
|
145
|
+
const genConfig = this.resolveGenerateConfigFn(modelConfigKey);
|
|
146
|
+
if (genConfig) {
|
|
147
|
+
if (genConfig.temperature != null)
|
|
148
|
+
request.temperature = genConfig.temperature;
|
|
149
|
+
if (genConfig.topP != null)
|
|
150
|
+
request.topP = genConfig.topP;
|
|
151
|
+
if (genConfig.topK != null)
|
|
152
|
+
request.topK = genConfig.topK;
|
|
153
|
+
if (genConfig.maxOutputTokens != null)
|
|
154
|
+
request.maxTokens = genConfig.maxOutputTokens;
|
|
155
|
+
if (genConfig.stopSequences != null)
|
|
156
|
+
request.stopSequences = genConfig.stopSequences;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// 5. Call provider stream (returns AsyncGenerator directly, not Promise)
|
|
160
|
+
const eventStream = this.generator.llmGenerateContentStream(request, promptId, { signal });
|
|
161
|
+
// 6. Return async generator that converts LlmEvent → StreamEvent
|
|
162
|
+
return this.processEventStream(eventStream);
|
|
163
|
+
}
|
|
164
|
+
setHistory(history) {
|
|
165
|
+
this.history = history;
|
|
166
|
+
// Recalculate token count to keep compression threshold accurate [리뷰 #5]
|
|
167
|
+
this.lastPromptTokenCount = estimateTokenCountSync(this.history.flatMap((c) => c.parts || []));
|
|
168
|
+
}
|
|
169
|
+
getHistory(_curated) {
|
|
170
|
+
// Return a deep copy to prevent external mutation of internal state [리뷰 #2]
|
|
171
|
+
return structuredClone(this.history);
|
|
172
|
+
}
|
|
173
|
+
getLastPromptTokenCount() {
|
|
174
|
+
return this.lastPromptTokenCount;
|
|
175
|
+
}
|
|
176
|
+
// ─── Internal ────────────────────────────────────────────────────
|
|
177
|
+
/**
|
|
178
|
+
* Processes the LlmEvent stream: yields StreamEvents, tracks usage,
|
|
179
|
+
* and adds model response to history after successful completion.
|
|
180
|
+
*/
|
|
181
|
+
async *processEventStream(eventStream) {
|
|
182
|
+
let responseText = '';
|
|
183
|
+
const functionCalls = [];
|
|
184
|
+
let hasError = false;
|
|
185
|
+
for await (const event of eventStream) {
|
|
186
|
+
// Track usage from Finished and MessageEnd events
|
|
187
|
+
if (event.type === LlmEventType.Finished) {
|
|
188
|
+
this.updateUsage(event.usage);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (event.type === LlmEventType.MessageEnd) {
|
|
192
|
+
this.updateUsage(event.usage);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
// Error → throw (not yielded as StreamEvent)
|
|
196
|
+
if (event.type === LlmEventType.Error) {
|
|
197
|
+
hasError = true;
|
|
198
|
+
const err = event.error;
|
|
199
|
+
throw err instanceof Error ? err : new Error(String(err));
|
|
200
|
+
}
|
|
201
|
+
// Accumulate text and tool calls for history
|
|
202
|
+
if (event.type === LlmEventType.TextDelta) {
|
|
203
|
+
responseText += event.text;
|
|
204
|
+
}
|
|
205
|
+
if (event.type === LlmEventType.ToolCallRequest) {
|
|
206
|
+
functionCalls.push({
|
|
207
|
+
id: event.callId,
|
|
208
|
+
name: event.name,
|
|
209
|
+
args: event.args,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
// Convert to StreamEvent and yield if mappable
|
|
213
|
+
const streamEvent = convertLlmEventToStreamEvent(event);
|
|
214
|
+
if (streamEvent) {
|
|
215
|
+
yield streamEvent;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Add model response to history after successful stream completion
|
|
219
|
+
if (!hasError) {
|
|
220
|
+
this.addModelResponseToHistory(responseText, functionCalls);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Updates last prompt token count from usage data.
|
|
225
|
+
*/
|
|
226
|
+
updateUsage(usage) {
|
|
227
|
+
if (usage?.promptTokens != null) {
|
|
228
|
+
this.lastPromptTokenCount = usage.promptTokens;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Adds the accumulated model response to history in Gemini Content format.
|
|
233
|
+
*/
|
|
234
|
+
addModelResponseToHistory(text, functionCalls) {
|
|
235
|
+
const parts = [];
|
|
236
|
+
if (text) {
|
|
237
|
+
parts.push({ text });
|
|
238
|
+
}
|
|
239
|
+
for (const fc of functionCalls) {
|
|
240
|
+
parts.push({
|
|
241
|
+
functionCall: { id: fc.id, name: fc.name, args: fc.args },
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
if (parts.length > 0) {
|
|
245
|
+
this.history.push({
|
|
246
|
+
role: 'model',
|
|
247
|
+
parts,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=llmAgentChatSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmAgentChatSession.js","sourceRoot":"","sources":["../../../src/agents/llmAgentChatSession.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,6BA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KAAK,CAAC,IAAI;iBACjB,CAAC,CAAC;YACL,CAAC;YAED,+CAA+C;YAC/C,MAAM,WAAW,GAAG,4BAA4B,CAAC,KAAK,CAAC,CAAC;YACxD,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,WAAW,CAAC;YACpB,CAAC;QACH,CAAC;QAED,mEAAmE;QACnE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,yBAAyB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,KAAqB;QACvC,IAAI,KAAK,EAAE,YAAY,IAAI,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAAC;QACjD,CAAC;IACH,CAAC;IAED;;OAEG;IACK,yBAAyB,CAC/B,IAAY,EACZ,aAIE;QAEF,MAAM,KAAK,GAAmC,EAAE,CAAC;QAEjD,IAAI,IAAI,EAAE,CAAC;YACT,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACvB,CAAC;QAED,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC;gBACT,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;aAC1D,CAAC,CAAC;QACL,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBAChB,IAAI,EAAE,OAAO;gBACb,KAAK;aACK,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -42,4 +42,11 @@ export declare class LocalSubagentInvocation extends BaseToolInvocation<AgentInp
|
|
|
42
42
|
* @returns A `Promise` that resolves with the final `ToolResult`.
|
|
43
43
|
*/
|
|
44
44
|
execute(signal: AbortSignal, updateOutput?: (output: string | AnsiOutput) => void): Promise<ToolResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a ChatSessionFactory for non-Gemini providers with llm* methods,
|
|
47
|
+
* or undefined for Gemini (which uses the default GeminiChat factory).
|
|
48
|
+
*
|
|
49
|
+
* Throws eagerly for non-Gemini providers that lack llm* methods [리뷰 #3].
|
|
50
|
+
*/
|
|
51
|
+
private buildChatFactoryIfNonGemini;
|
|
45
52
|
}
|
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
import { LocalAgentExecutor } from './local-executor.js';
|
|
7
7
|
import { BaseToolInvocation } from '../tools/tools.js';
|
|
8
8
|
import { ToolErrorType } from '../tools/tool-error.js';
|
|
9
|
+
import { isProviderIndependentGenerator } from '../core/contentGenerator.js';
|
|
10
|
+
import { resolveProviderModel } from '../providers/providerSelector.js';
|
|
11
|
+
import { convertContentsToLlmMessages } from '../providers/gemini/typeConversion.js';
|
|
12
|
+
import { convertGeminiToolsToLlm } from '../providers/gemini/requestBuilder.js';
|
|
13
|
+
import { fixToolResultRoles } from '../core/llmMessageUtils.js';
|
|
14
|
+
import { LlmAgentChatSession } from './llmAgentChatSession.js';
|
|
9
15
|
const INPUT_PREVIEW_MAX_LENGTH = 50;
|
|
10
16
|
const DESCRIPTION_MAX_LENGTH = 200;
|
|
11
17
|
/**
|
|
@@ -66,7 +72,11 @@ export class LocalSubagentInvocation extends BaseToolInvocation {
|
|
|
66
72
|
updateOutput(`🤖💭 ${activity.data['text']}`);
|
|
67
73
|
}
|
|
68
74
|
};
|
|
69
|
-
|
|
75
|
+
// Detect non-Gemini provider and inject LlmAgentChatSession factory
|
|
76
|
+
const chatFactory = this.buildChatFactoryIfNonGemini();
|
|
77
|
+
const executor = chatFactory
|
|
78
|
+
? await LocalAgentExecutor.create(this.definition, this.config, onActivity, chatFactory)
|
|
79
|
+
: await LocalAgentExecutor.create(this.definition, this.config, onActivity);
|
|
70
80
|
const output = await executor.run(this.params, signal);
|
|
71
81
|
const resultContent = `Subagent '${this.definition.name}' finished.
|
|
72
82
|
Termination Reason: ${output.terminate_reason}
|
|
@@ -97,5 +107,65 @@ ${output.result}
|
|
|
97
107
|
};
|
|
98
108
|
}
|
|
99
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns a ChatSessionFactory for non-Gemini providers with llm* methods,
|
|
112
|
+
* or undefined for Gemini (which uses the default GeminiChat factory).
|
|
113
|
+
*
|
|
114
|
+
* Throws eagerly for non-Gemini providers that lack llm* methods [리뷰 #3].
|
|
115
|
+
*/
|
|
116
|
+
buildChatFactoryIfNonGemini() {
|
|
117
|
+
let generator;
|
|
118
|
+
try {
|
|
119
|
+
generator = this.config.getContentGenerator();
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
if (!generator)
|
|
125
|
+
return undefined;
|
|
126
|
+
const providerName = generator.providerName;
|
|
127
|
+
// Gemini (or unknown) → use default GeminiChat factory
|
|
128
|
+
if (providerName == null || providerName === 'gemini') {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
// Non-Gemini without llm* methods → fail fast [리뷰 #3]
|
|
132
|
+
if (!isProviderIndependentGenerator(generator)) {
|
|
133
|
+
throw new Error(`Provider "${providerName}" is non-Gemini but does not support ` +
|
|
134
|
+
`provider-independent API (llm* methods). Subagent execution cannot proceed.`);
|
|
135
|
+
}
|
|
136
|
+
return (config, systemInstruction, tools, history) => new LlmAgentChatSession({
|
|
137
|
+
generator,
|
|
138
|
+
providerName,
|
|
139
|
+
systemInstruction,
|
|
140
|
+
tools,
|
|
141
|
+
initialHistory: history,
|
|
142
|
+
resolveProviderModelFn: resolveProviderModel,
|
|
143
|
+
buildLlmRequestFn: ({ history: msgs, systemInstruction: si, tools: t, }) => {
|
|
144
|
+
const request = {
|
|
145
|
+
model: 'placeholder', // overridden by LlmAgentChatSession
|
|
146
|
+
messages: msgs,
|
|
147
|
+
};
|
|
148
|
+
if (si !== undefined) {
|
|
149
|
+
request.systemInstruction = si;
|
|
150
|
+
}
|
|
151
|
+
if (t.length > 0) {
|
|
152
|
+
request.tools = convertGeminiToolsToLlm(t);
|
|
153
|
+
}
|
|
154
|
+
return request;
|
|
155
|
+
},
|
|
156
|
+
fixToolResultRolesFn: fixToolResultRoles,
|
|
157
|
+
convertContentsToLlmMessagesFn: convertContentsToLlmMessages,
|
|
158
|
+
// Propagate generation config (temperature/topP/maxOutputTokens etc.) [리뷰 #1]
|
|
159
|
+
resolveGenerateConfigFn: (key) => {
|
|
160
|
+
try {
|
|
161
|
+
const resolved = config.modelConfigService.getResolvedConfig(key);
|
|
162
|
+
return resolved.generateContentConfig;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
100
170
|
}
|
|
101
171
|
//# sourceMappingURL=local-invocation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-invocation.js","sourceRoot":"","sources":["../../../src/agents/local-invocation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQvD,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC;;;;;;;;;GASG;AACH,MAAM,OAAO,uBAAwB,SAAQ,kBAG5C;IAQoB;IACA;IARnB;;;;;OAKG;IACH,YACmB,UAAgC,EAChC,MAAc,EAC/B,MAAmB,EACnB,UAAsB,EACtB,SAAkB,EAClB,gBAAyB;QAEzB,KAAK,CACH,MAAM,EACN,UAAU,EACV,SAAS,IAAI,UAAU,CAAC,IAAI,EAC5B,gBAAgB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generateContent(options: GenerateContentOptions | LlmGenerateContentOptions): Promise<GenerateContentResponse>;
|
|
130
130
|
private _generateWithRetry;
|
|
131
|
+
/**
|
|
132
|
+
* Non-Gemini variant of _generateWithRetry.
|
|
133
|
+
* Converts Content[] → LlmMessage[], calls llmGenerateContent(),
|
|
134
|
+
* and converts the response back to GenerateContentResponse.
|
|
135
|
+
*/
|
|
136
|
+
private _generateWithRetryLlm;
|
|
137
|
+
/**
|
|
138
|
+
* Builds an LlmGenerateRequest from Gemini Content[] and calls llmGenerateContent().
|
|
139
|
+
* Returns GenerateContentResponse for compatibility with existing callers.
|
|
140
|
+
*/
|
|
141
|
+
private _callLlmGenerateContent;
|
|
142
|
+
/**
|
|
143
|
+
* Normalizes various systemInstruction forms to a plain string.
|
|
144
|
+
* BaseLlmClient callers pass string | Part | Part[] | Content.
|
|
145
|
+
*/
|
|
146
|
+
private _normalizeSystemInstruction;
|
|
131
147
|
}
|