mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
Checkpoint interface consolidation
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
export const SUBAGENT_TOOL_NAMES = [
|
||||
'debug',
|
||||
'edit',
|
||||
'build',
|
||||
'plan',
|
||||
'test',
|
||||
'deploy',
|
||||
'auth',
|
||||
'research',
|
||||
'knowledge',
|
||||
'custom_tool',
|
||||
'tour',
|
||||
'info',
|
||||
'workflow',
|
||||
'evaluate',
|
||||
'superagent',
|
||||
'discovery',
|
||||
] as const
|
||||
|
||||
export const SUBAGENT_TOOL_SET = new Set<string>(SUBAGENT_TOOL_NAMES)
|
||||
|
||||
/**
|
||||
* Respond tools are internal to the copilot's subagent system.
|
||||
* They're used by subagents to signal completion and should NOT be executed by the sim side.
|
||||
* The copilot backend handles these internally.
|
||||
*/
|
||||
export const RESPOND_TOOL_NAMES = [
|
||||
'plan_respond',
|
||||
'edit_respond',
|
||||
'build_respond',
|
||||
'debug_respond',
|
||||
'info_respond',
|
||||
'research_respond',
|
||||
'deploy_respond',
|
||||
'superagent_respond',
|
||||
'discovery_respond',
|
||||
'tour_respond',
|
||||
'auth_respond',
|
||||
'workflow_respond',
|
||||
'knowledge_respond',
|
||||
'custom_tool_respond',
|
||||
'test_respond',
|
||||
] as const
|
||||
|
||||
export const RESPOND_TOOL_SET = new Set<string>(RESPOND_TOOL_NAMES)
|
||||
@@ -1,6 +1,5 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { STREAM_TIMEOUT_MS } from '@/lib/copilot/constants'
|
||||
import { RESPOND_TOOL_SET, SUBAGENT_TOOL_SET } from '@/lib/copilot/orchestrator/config'
|
||||
import {
|
||||
asRecord,
|
||||
getEventData,
|
||||
@@ -31,11 +30,18 @@ const logger = createLogger('CopilotSseHandlers')
|
||||
* Extract the `ui` object from a Go SSE event. The Go backend enriches
|
||||
* tool_call events with `ui: { requiresConfirmation, clientExecutable, ... }`.
|
||||
*/
|
||||
function getEventUI(event: SSEEvent): { requiresConfirmation: boolean; clientExecutable: boolean } {
|
||||
function getEventUI(event: SSEEvent): {
|
||||
requiresConfirmation: boolean
|
||||
clientExecutable: boolean
|
||||
internal: boolean
|
||||
hidden: boolean
|
||||
} {
|
||||
const raw = asRecord((event as unknown as Record<string, unknown>).ui)
|
||||
return {
|
||||
requiresConfirmation: raw.requiresConfirmation === true,
|
||||
clientExecutable: raw.clientExecutable === true,
|
||||
internal: raw.internal === true,
|
||||
hidden: raw.hidden === true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,25 +230,12 @@ export const sseHandlers: Record<string, SSEHandler> = {
|
||||
const toolCall = context.toolCalls.get(toolCallId)
|
||||
if (!toolCall) return
|
||||
|
||||
if (SUBAGENT_TOOL_SET.has(toolName)) {
|
||||
const { requiresConfirmation, clientExecutable, internal } = getEventUI(event)
|
||||
|
||||
if (internal) {
|
||||
return
|
||||
}
|
||||
|
||||
if (RESPOND_TOOL_SET.has(toolName)) {
|
||||
toolCall.status = 'success'
|
||||
toolCall.endTime = Date.now()
|
||||
toolCall.result = {
|
||||
success: true,
|
||||
output: 'Internal respond tool - handled by copilot backend',
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Go backend decides whether a tool needs confirmation via `ui.requiresConfirmation`.
|
||||
// If the flag is set, wait for client approval before executing.
|
||||
// If `ui.clientExecutable` is set, the client runs the tool and reports back.
|
||||
const { requiresConfirmation, clientExecutable } = getEventUI(event)
|
||||
|
||||
if (requiresConfirmation) {
|
||||
const decision = await waitForToolDecision(
|
||||
toolCallId,
|
||||
@@ -450,14 +443,9 @@ export const subAgentHandlers: Record<string, SSEHandler> = {
|
||||
|
||||
if (isPartial) return
|
||||
|
||||
// Respond tools are internal to copilot's subagent system - skip execution.
|
||||
if (RESPOND_TOOL_SET.has(toolName)) {
|
||||
toolCall.status = 'success'
|
||||
toolCall.endTime = Date.now()
|
||||
toolCall.result = {
|
||||
success: true,
|
||||
output: 'Internal respond tool - handled by copilot backend',
|
||||
}
|
||||
const { requiresConfirmation, clientExecutable, internal } = getEventUI(event)
|
||||
|
||||
if (internal) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -465,8 +453,6 @@ export const subAgentHandlers: Record<string, SSEHandler> = {
|
||||
return
|
||||
}
|
||||
|
||||
const { requiresConfirmation, clientExecutable } = getEventUI(event)
|
||||
|
||||
if (requiresConfirmation) {
|
||||
const decision = await waitForToolDecision(
|
||||
toolCallId,
|
||||
|
||||
Reference in New Issue
Block a user