Compare commits
21 Commits
main
...
afw/idle-w
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
061ed12c4f | ||
|
|
ecbdbea6d5 | ||
|
|
515dd420ea | ||
|
|
a8dcff4229 | ||
|
|
76c96cc4be | ||
|
|
6880859fdb | ||
|
|
bb80f5fd67 | ||
|
|
ccfd2a48ad | ||
|
|
aabc27c12d | ||
|
|
6362e3cc15 | ||
|
|
8751910572 | ||
|
|
708d0e7016 | ||
|
|
d68cc3a88f | ||
|
|
6510587725 | ||
|
|
1d86b6504b | ||
|
|
1dc55b278b | ||
|
|
2727a871c3 | ||
|
|
8fcb18996a | ||
|
|
f46a1c7e8b | ||
|
|
8b7321ea8d | ||
|
|
931b80206b |
@ -80,6 +80,7 @@ import {
|
||||
ChangeAuthRequestedError,
|
||||
ProjectIdRequiredError,
|
||||
buildUserSteeringHintPrompt,
|
||||
formatBackgroundCompletionForModel,
|
||||
logBillingEvent,
|
||||
ApiKeyUpdatedEvent,
|
||||
type InjectionSource,
|
||||
@ -1099,30 +1100,49 @@ Logging in with Google... Restarting Gemini CLI to continue.
|
||||
}
|
||||
}, [pendingRestorePrompt, inputHistory, historyManager.history]);
|
||||
|
||||
const pendingHintsRef = useRef<string[]>([]);
|
||||
const [pendingHintCount, setPendingHintCount] = useState(0);
|
||||
const pendingInjectionsRef = useRef<
|
||||
Array<{ text: string; source: InjectionSource }>
|
||||
>([]);
|
||||
const [pendingInjectionCount, setPendingInjectionCount] = useState(0);
|
||||
|
||||
const consumePendingHints = useCallback(() => {
|
||||
if (pendingHintsRef.current.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const hint = pendingHintsRef.current.join('\n');
|
||||
pendingHintsRef.current = [];
|
||||
setPendingHintCount(0);
|
||||
return hint;
|
||||
}, []);
|
||||
const consumePendingInjections = useCallback(
|
||||
(source?: InjectionSource) => {
|
||||
if (pendingInjectionsRef.current.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!source) {
|
||||
const injections = [...pendingInjectionsRef.current];
|
||||
pendingInjectionsRef.current = [];
|
||||
setPendingInjectionCount(0);
|
||||
return injections;
|
||||
}
|
||||
|
||||
const matching = pendingInjectionsRef.current.filter(
|
||||
(inj) => inj.source === source,
|
||||
);
|
||||
pendingInjectionsRef.current = pendingInjectionsRef.current.filter(
|
||||
(inj) => inj.source !== source,
|
||||
);
|
||||
setPendingInjectionCount(pendingInjectionsRef.current.length);
|
||||
return matching;
|
||||
},
|
||||
[pendingInjectionsRef],
|
||||
);
|
||||
|
||||
const consumeUserHints = useCallback(() => {
|
||||
const hints = consumePendingInjections('user_steering');
|
||||
return hints.length > 0 ? hints.map((h) => h.text).join('\n') : null;
|
||||
}, [consumePendingInjections]);
|
||||
|
||||
useEffect(() => {
|
||||
const hintListener = (text: string, source: InjectionSource) => {
|
||||
if (source !== 'user_steering' && source !== 'background_completion') {
|
||||
return;
|
||||
}
|
||||
pendingHintsRef.current.push(text);
|
||||
setPendingHintCount((prev) => prev + 1);
|
||||
const injectionListener = (text: string, source: InjectionSource) => {
|
||||
pendingInjectionsRef.current.push({ text, source });
|
||||
setPendingInjectionCount((prev) => prev + 1);
|
||||
};
|
||||
config.injectionService.onInjection(hintListener);
|
||||
config.injectionService.onInjection(injectionListener);
|
||||
return () => {
|
||||
config.injectionService.offInjection(hintListener);
|
||||
config.injectionService.offInjection(injectionListener);
|
||||
};
|
||||
}, [config]);
|
||||
|
||||
@ -1164,7 +1184,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
|
||||
terminalWidth,
|
||||
terminalHeight,
|
||||
embeddedShellFocused,
|
||||
consumePendingHints,
|
||||
consumeUserHints,
|
||||
);
|
||||
|
||||
const pendingHistoryItems = useMemo(
|
||||
@ -2184,30 +2204,35 @@ Logging in with Google... Restarting Gemini CLI to continue.
|
||||
useEffect(() => {
|
||||
if (
|
||||
!isConfigInitialized ||
|
||||
!config.isModelSteeringEnabled() ||
|
||||
streamingState !== StreamingState.Idle ||
|
||||
!isMcpReady ||
|
||||
pendingInjectionCount === 0 ||
|
||||
isToolAwaitingConfirmation(pendingHistoryItems)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pendingHint = consumePendingHints();
|
||||
if (!pendingHint) {
|
||||
const pendingInjections = consumePendingInjections();
|
||||
if (pendingInjections.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
void submitQuery([{ text: buildUserSteeringHintPrompt(pendingHint) }]);
|
||||
const prompts = pendingInjections.map((inj) => {
|
||||
if (inj.source === 'user_steering') {
|
||||
return { text: buildUserSteeringHintPrompt(inj.text) };
|
||||
}
|
||||
return { text: formatBackgroundCompletionForModel(inj.text) };
|
||||
});
|
||||
|
||||
void submitQuery(prompts);
|
||||
}, [
|
||||
config,
|
||||
historyManager,
|
||||
isConfigInitialized,
|
||||
isMcpReady,
|
||||
streamingState,
|
||||
submitQuery,
|
||||
consumePendingHints,
|
||||
pendingInjectionCount,
|
||||
pendingHistoryItems,
|
||||
pendingHintCount,
|
||||
consumePendingInjections,
|
||||
]);
|
||||
|
||||
const allToolCalls = useMemo(
|
||||
|
||||
@ -188,6 +188,7 @@ describe('SubAgentInvocation', () => {
|
||||
expect(mockInnerInvocation.execute).toHaveBeenCalledWith(
|
||||
abortSignal,
|
||||
updateOutput,
|
||||
undefined,
|
||||
);
|
||||
|
||||
expect(runInDevTraceSpan).toHaveBeenCalledWith(
|
||||
|
||||
@ -13,6 +13,7 @@ import {
|
||||
type ToolCallConfirmationDetails,
|
||||
isTool,
|
||||
type ToolLiveOutput,
|
||||
type ExecuteOptions,
|
||||
} from '../tools/tools.js';
|
||||
import type { Config } from '../config/config.js';
|
||||
import { type AgentLoopContext } from '../config/agent-loop-context.js';
|
||||
@ -161,6 +162,7 @@ class SubAgentInvocation extends BaseToolInvocation<AgentInputs, ToolResult> {
|
||||
async execute(
|
||||
signal: AbortSignal,
|
||||
updateOutput?: (output: ToolLiveOutput) => void,
|
||||
options?: ExecuteOptions,
|
||||
): Promise<ToolResult> {
|
||||
const validationError = SchemaValidator.validate(
|
||||
this.definition.inputConfig.inputSchema,
|
||||
@ -189,7 +191,7 @@ class SubAgentInvocation extends BaseToolInvocation<AgentInputs, ToolResult> {
|
||||
},
|
||||
async ({ metadata }) => {
|
||||
metadata.input = this.params;
|
||||
const result = await invocation.execute(signal, updateOutput);
|
||||
const result = await invocation.execute(signal, updateOutput, options);
|
||||
metadata.output = result;
|
||||
return result;
|
||||
},
|
||||
|
||||
@ -553,12 +553,12 @@ export class ShellExecutionService {
|
||||
formatInjection: (output, error) =>
|
||||
ShellExecutionService.formatShellBackgroundCompletion(
|
||||
child.pid!,
|
||||
shellExecutionConfig.backgroundCompletionBehavior || 'silent',
|
||||
shellExecutionConfig.backgroundCompletionBehavior ?? 'inject',
|
||||
output,
|
||||
error ?? undefined,
|
||||
),
|
||||
completionBehavior:
|
||||
shellExecutionConfig.backgroundCompletionBehavior || 'silent',
|
||||
shellExecutionConfig.backgroundCompletionBehavior ?? 'inject',
|
||||
})
|
||||
: undefined;
|
||||
|
||||
@ -892,12 +892,12 @@ export class ShellExecutionService {
|
||||
formatInjection: (output, error) =>
|
||||
ShellExecutionService.formatShellBackgroundCompletion(
|
||||
ptyPid,
|
||||
shellExecutionConfig.backgroundCompletionBehavior || 'silent',
|
||||
shellExecutionConfig.backgroundCompletionBehavior ?? 'inject',
|
||||
output,
|
||||
error ?? undefined,
|
||||
),
|
||||
completionBehavior:
|
||||
shellExecutionConfig.backgroundCompletionBehavior || 'silent',
|
||||
shellExecutionConfig.backgroundCompletionBehavior ?? 'inject',
|
||||
}).result;
|
||||
|
||||
let processingChain = Promise.resolve();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user