Compare commits

...

3 Commits

Author SHA1 Message Date
Siddharth Ganesan
896d6b5529 Remove console logs 2026-01-23 13:02:37 -08:00
Siddharth Ganesan
fefcb61f8b Fix actions mapping 2026-01-23 12:28:23 -08:00
Siddharth Ganesan
24173bb008 Improvements 2026-01-23 12:10:29 -08:00
3 changed files with 52 additions and 9 deletions

View File

@@ -1425,10 +1425,7 @@ function RunSkipButtons({
setIsProcessing(true) setIsProcessing(true)
setButtonsHidden(true) setButtonsHidden(true)
try { try {
// Add to auto-allowed list - this also executes all pending integration tools of this type
await addAutoAllowedTool(toolCall.name) await addAutoAllowedTool(toolCall.name)
// For client tools with interrupts (not integration tools), we still need to call handleRun
// since executeIntegrationTool only works for server-side tools
if (!isIntegrationTool(toolCall.name)) { if (!isIntegrationTool(toolCall.name)) {
await handleRun(toolCall, setToolCallState, onStateChange, editedParams) await handleRun(toolCall, setToolCallState, onStateChange, editedParams)
} }
@@ -1526,7 +1523,11 @@ export function ToolCall({
toolCall.name === 'user_memory' || toolCall.name === 'user_memory' ||
toolCall.name === 'edit_respond' || toolCall.name === 'edit_respond' ||
toolCall.name === 'debug_respond' || toolCall.name === 'debug_respond' ||
toolCall.name === 'plan_respond' toolCall.name === 'plan_respond' ||
toolCall.name === 'research_respond' ||
toolCall.name === 'info_respond' ||
toolCall.name === 'deploy_respond' ||
toolCall.name === 'superagent_respond'
) )
return null return null

View File

@@ -209,9 +209,20 @@ export interface SlashCommand {
export const TOP_LEVEL_COMMANDS: readonly SlashCommand[] = [ export const TOP_LEVEL_COMMANDS: readonly SlashCommand[] = [
{ id: 'fast', label: 'Fast' }, { id: 'fast', label: 'Fast' },
{ id: 'research', label: 'Research' }, { id: 'research', label: 'Research' },
{ id: 'superagent', label: 'Actions' }, { id: 'actions', label: 'Actions' },
] as const ] as const
/**
* Maps UI command IDs to API command IDs.
* Some commands have different IDs for display vs API (e.g., "actions" -> "superagent")
*/
export function getApiCommandId(uiCommandId: string): string {
const commandMapping: Record<string, string> = {
actions: 'superagent',
}
return commandMapping[uiCommandId] || uiCommandId
}
export const WEB_COMMANDS: readonly SlashCommand[] = [ export const WEB_COMMANDS: readonly SlashCommand[] = [
{ id: 'search', label: 'Search' }, { id: 'search', label: 'Search' },
{ id: 'read', label: 'Read' }, { id: 'read', label: 'Read' },

View File

@@ -2116,6 +2116,24 @@ const subAgentSSEHandlers: Record<string, SSEHandler> = {
}) })
}) })
} }
} else {
// Check if this is an integration tool (server-side) that should be auto-executed
const isIntegrationTool = !CLASS_TOOL_METADATA[name]
if (isIntegrationTool && isSubAgentAutoAllowed) {
logger.info('[SubAgent] Auto-executing integration tool (auto-allowed)', {
id,
name,
})
// Execute integration tool via the store method
const { executeIntegrationTool } = get()
executeIntegrationTool(id).catch((err) => {
logger.error('[SubAgent] Integration tool auto-execution failed', {
id,
name,
error: err?.message || err,
})
})
}
} }
} }
} catch (e: any) { } catch (e: any) {
@@ -2797,9 +2815,14 @@ export const useCopilotStore = create<CopilotStore>()(
mode === 'ask' ? 'ask' : mode === 'plan' ? 'plan' : 'agent' mode === 'ask' ? 'ask' : mode === 'plan' ? 'plan' : 'agent'
// Extract slash commands from contexts (lowercase) and filter them out from contexts // Extract slash commands from contexts (lowercase) and filter them out from contexts
// Map UI command IDs to API command IDs (e.g., "actions" -> "superagent")
const uiToApiCommandMap: Record<string, string> = { actions: 'superagent' }
const commands = contexts const commands = contexts
?.filter((c) => c.kind === 'slash_command' && 'command' in c) ?.filter((c) => c.kind === 'slash_command' && 'command' in c)
.map((c) => (c as any).command.toLowerCase()) as string[] | undefined .map((c) => {
const uiCommand = (c as any).command.toLowerCase()
return uiToApiCommandMap[uiCommand] || uiCommand
}) as string[] | undefined
const filteredContexts = contexts?.filter((c) => c.kind !== 'slash_command') const filteredContexts = contexts?.filter((c) => c.kind !== 'slash_command')
const result = await sendStreamingMessage({ const result = await sendStreamingMessage({
@@ -3923,11 +3946,16 @@ export const useCopilotStore = create<CopilotStore>()(
loadAutoAllowedTools: async () => { loadAutoAllowedTools: async () => {
try { try {
logger.info('[AutoAllowedTools] Loading from API...')
const res = await fetch('/api/copilot/auto-allowed-tools') const res = await fetch('/api/copilot/auto-allowed-tools')
logger.info('[AutoAllowedTools] Load response', { status: res.status, ok: res.ok })
if (res.ok) { if (res.ok) {
const data = await res.json() const data = await res.json()
set({ autoAllowedTools: data.autoAllowedTools || [] }) const tools = data.autoAllowedTools || []
logger.info('[AutoAllowedTools] Loaded', { tools: data.autoAllowedTools }) set({ autoAllowedTools: tools })
logger.info('[AutoAllowedTools] Loaded successfully', { count: tools.length, tools })
} else {
logger.warn('[AutoAllowedTools] Load failed with status', { status: res.status })
} }
} catch (err) { } catch (err) {
logger.error('[AutoAllowedTools] Failed to load', { error: err }) logger.error('[AutoAllowedTools] Failed to load', { error: err })
@@ -3936,15 +3964,18 @@ export const useCopilotStore = create<CopilotStore>()(
addAutoAllowedTool: async (toolId: string) => { addAutoAllowedTool: async (toolId: string) => {
try { try {
logger.info('[AutoAllowedTools] Adding tool...', { toolId })
const res = await fetch('/api/copilot/auto-allowed-tools', { const res = await fetch('/api/copilot/auto-allowed-tools', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ toolId }), body: JSON.stringify({ toolId }),
}) })
logger.info('[AutoAllowedTools] API response', { toolId, status: res.status, ok: res.ok })
if (res.ok) { if (res.ok) {
const data = await res.json() const data = await res.json()
logger.info('[AutoAllowedTools] API returned', { toolId, tools: data.autoAllowedTools })
set({ autoAllowedTools: data.autoAllowedTools || [] }) set({ autoAllowedTools: data.autoAllowedTools || [] })
logger.info('[AutoAllowedTools] Added tool', { toolId }) logger.info('[AutoAllowedTools] Added tool to store', { toolId })
// Auto-execute all pending tools of the same type // Auto-execute all pending tools of the same type
const { toolCallsById, executeIntegrationTool } = get() const { toolCallsById, executeIntegrationTool } = get()