(feat): Initial Version of Custom Commands (#4572)

This commit is contained in:
Abhi
2025-07-22 00:34:55 -04:00
committed by GitHub
parent 5f813ef510
commit 9daead63dd
17 changed files with 1008 additions and 96 deletions

View File

@@ -240,19 +240,37 @@ export const useGeminiStream = (
const slashCommandResult = await handleSlashCommand(trimmedQuery);
if (slashCommandResult) {
if (slashCommandResult.type === 'schedule_tool') {
const { toolName, toolArgs } = slashCommandResult;
const toolCallRequest: ToolCallRequestInfo = {
callId: `${toolName}-${Date.now()}-${Math.random().toString(16).slice(2)}`,
name: toolName,
args: toolArgs,
isClientInitiated: true,
prompt_id,
};
scheduleToolCalls([toolCallRequest], abortSignal);
}
switch (slashCommandResult.type) {
case 'schedule_tool': {
const { toolName, toolArgs } = slashCommandResult;
const toolCallRequest: ToolCallRequestInfo = {
callId: `${toolName}-${Date.now()}-${Math.random().toString(16).slice(2)}`,
name: toolName,
args: toolArgs,
isClientInitiated: true,
prompt_id,
};
scheduleToolCalls([toolCallRequest], abortSignal);
return { queryToSend: null, shouldProceed: false };
}
case 'submit_prompt': {
localQueryToSendToGemini = slashCommandResult.content;
return { queryToSend: null, shouldProceed: false };
return {
queryToSend: localQueryToSendToGemini,
shouldProceed: true,
};
}
case 'handled': {
return { queryToSend: null, shouldProceed: false };
}
default: {
const unreachable: never = slashCommandResult;
throw new Error(
`Unhandled slash command result type: ${unreachable}`,
);
}
}
}
if (shellModeActive && handleShellCommand(trimmedQuery, abortSignal)) {