2025-12-19 14:11:32 -08:00
/ * *
* @license
* Copyright 2025 Google LLC
* SPDX - License - Identifier : Apache - 2.0
* /
import type { AgentDefinition } from './types.js' ;
import { GEMINI_MODEL_ALIAS_FLASH } from '../config/models.js' ;
import { z } from 'zod' ;
2026-01-07 15:01:57 -08:00
import type { Config } from '../config/config.js' ;
import { GetInternalDocsTool } from '../tools/get-internal-docs.js' ;
2025-12-19 14:11:32 -08:00
2026-01-07 15:01:57 -08:00
const CliHelpReportSchema = z . object ( {
2025-12-19 14:11:32 -08:00
answer : z
. string ( )
. describe ( 'The detailed answer to the user question about Gemini CLI.' ) ,
sources : z
. array ( z . string ( ) )
. describe ( 'The documentation files used to answer the question.' ) ,
} ) ;
/ * *
* An agent specialized in answering questions about Gemini CLI itself ,
* using its own documentation and runtime state .
* /
2026-01-07 15:01:57 -08:00
export const CliHelpAgent = (
config : Config ,
) : AgentDefinition < typeof CliHelpReportSchema > = > ( {
name : 'cli_help' ,
2025-12-19 14:11:32 -08:00
kind : 'local' ,
2026-01-07 15:01:57 -08:00
displayName : 'CLI Help Agent' ,
2025-12-19 14:11:32 -08:00
description :
2026-01-07 15:01:57 -08:00
'Specialized in answering questions about how users use you, (Gemini CLI): features, documentation, and current runtime configuration.' ,
2025-12-19 14:11:32 -08:00
inputConfig : {
2026-01-21 16:56:01 -08:00
inputSchema : {
type : 'object' ,
properties : {
question : {
type : 'string' ,
description : 'The specific question about Gemini CLI.' ,
} ,
2025-12-19 14:11:32 -08:00
} ,
2026-01-21 16:56:01 -08:00
required : [ 'question' ] ,
2025-12-19 14:11:32 -08:00
} ,
} ,
outputConfig : {
outputName : 'report' ,
description : 'The final answer and sources as a JSON object.' ,
2026-01-07 15:01:57 -08:00
schema : CliHelpReportSchema ,
2025-12-19 14:11:32 -08:00
} ,
processOutput : ( output ) = > JSON . stringify ( output , null , 2 ) ,
modelConfig : {
model : GEMINI_MODEL_ALIAS_FLASH ,
2026-01-13 14:31:34 -08:00
generateContentConfig : {
temperature : 0.1 ,
topP : 0.95 ,
thinkingConfig : {
includeThoughts : true ,
thinkingBudget : - 1 ,
} ,
} ,
2025-12-19 14:11:32 -08:00
} ,
runConfig : {
2026-01-13 14:31:34 -08:00
maxTimeMinutes : 3 ,
maxTurns : 10 ,
2025-12-19 14:11:32 -08:00
} ,
toolConfig : {
2026-01-07 15:01:57 -08:00
tools : [ new GetInternalDocsTool ( config . getMessageBus ( ) ) ] ,
2025-12-19 14:11:32 -08:00
} ,
promptConfig : {
query :
'Your task is to answer the following question about Gemini CLI:\n' +
'<question>\n' +
'${question}\n' +
'</question>' ,
systemPrompt :
2026-01-07 15:01:57 -08:00
"You are **CLI Help Agent**, an expert on Gemini CLI. Your purpose is to provide accurate information about Gemini CLI's features, configuration, and current state.\n\n" +
2025-12-19 14:11:32 -08:00
'### Runtime Context\n' +
'- **CLI Version:** ${cliVersion}\n' +
'- **Active Model:** ${activeModel}\n' +
"- **Today's Date:** ${today}\n\n" +
'### Instructions\n' +
"1. **Explore Documentation**: Use the `get_internal_docs` tool to find answers. If you don't know where to start, call `get_internal_docs()` without arguments to see the full list of available documentation files.\n" +
'2. **Be Precise**: Use the provided runtime context and documentation to give exact answers.\n' +
'3. **Cite Sources**: Always include the specific documentation files you used in your final report.\n' +
'4. **Non-Interactive**: You operate in a loop and cannot ask the user for more info. If the question is ambiguous, answer as best as you can with the information available.\n\n' +
'You MUST call `complete_task` with a JSON report containing your `answer` and the `sources` you used.' ,
} ,
2026-01-07 15:01:57 -08:00
} ) ;