mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-11 07:04:58 -05:00
* fix(helm): add custom egress rules to realtime network policy (#2481) The realtime service network policy was missing the custom egress rules section that allows configuration of additional egress rules via values.yaml. This caused the realtime pods to be unable to connect to external databases (e.g., PostgreSQL on port 5432) when using external database configurations. The app network policy already had this section, but the realtime network policy was missing it, creating an inconsistency and preventing the realtime service from accessing external databases configured via networkPolicy.egress values. This fix adds the same custom egress rules template section to the realtime network policy, matching the app network policy behavior and allowing users to configure database connectivity via values.yaml. * Add subagents * Edit, plan, debug subagents * Tweaks * Message queue * Many subagents * Fix bugs * Trigger request * Overlays * Diff in chat * Remove context usage code * Diff view in chat * Options * Lint * Fix rendering of edit subblocks * Add deploy mcp tools * Add evaluator subagent * Editor component * Options select * Fixes to options * Fix spacing between options * Subagent rendering * Fix previews * Plan * Streaming * Fix thinking scroll * Renaming * Fix thinking text * Persist and load chats properly * Diff view * Fix lint * Previous options should not be selectable * Enable images * improvement(copilot): ui/ux * improvement(copilot): diff controls * Fix ops bug * Fix ops * Stuff * Fix config --------- Co-authored-by: Vikhyath Mondreti <vikhyathvikku@gmail.com> Co-authored-by: Waleed <walif6@gmail.com> Co-authored-by: Martin Yankov <23098926+Lutherwaves@users.noreply.github.com> Co-authored-by: Emir Karabeg <78010029+emir-karabeg@users.noreply.github.com> Co-authored-by: waleedlatif1 <waleedlatif1@users.noreply.github.com> Co-authored-by: Adam Gough <77861281+aadamgough@users.noreply.github.com> Co-authored-by: aadamgough <adam@sim.ai> Co-authored-by: Emir Karabeg <emirkarabeg@berkeley.edu>
121 lines
3.6 KiB
TypeScript
121 lines
3.6 KiB
TypeScript
/**
|
|
* Base class for subagent tools.
|
|
*
|
|
* Subagent tools spawn a server-side subagent that does the actual work.
|
|
* The tool auto-executes and the subagent's output is streamed back
|
|
* as nested content under the tool call.
|
|
*
|
|
* Examples: edit, plan, debug, evaluate, research, etc.
|
|
*/
|
|
import type { LucideIcon } from 'lucide-react'
|
|
import { BaseClientTool, type BaseClientToolMetadata, ClientToolCallState } from './base-tool'
|
|
import type { SubagentConfig, ToolUIConfig } from './ui-config'
|
|
import { registerToolUIConfig } from './ui-config'
|
|
|
|
/**
|
|
* Configuration for creating a subagent tool
|
|
*/
|
|
export interface SubagentToolConfig {
|
|
/** Unique tool ID */
|
|
id: string
|
|
/** Display names per state */
|
|
displayNames: {
|
|
streaming: { text: string; icon: LucideIcon }
|
|
success: { text: string; icon: LucideIcon }
|
|
error: { text: string; icon: LucideIcon }
|
|
}
|
|
/** Subagent UI configuration */
|
|
subagent: SubagentConfig
|
|
/**
|
|
* Optional: Whether this is a "special" tool (gets gradient styling).
|
|
* Default: false
|
|
*/
|
|
isSpecial?: boolean
|
|
}
|
|
|
|
/**
|
|
* Create metadata for a subagent tool from config
|
|
*/
|
|
function createSubagentMetadata(config: SubagentToolConfig): BaseClientToolMetadata {
|
|
const { displayNames, subagent, isSpecial } = config
|
|
const { streaming, success, error } = displayNames
|
|
|
|
const uiConfig: ToolUIConfig = {
|
|
isSpecial: isSpecial ?? false,
|
|
subagent,
|
|
}
|
|
|
|
return {
|
|
displayNames: {
|
|
[ClientToolCallState.generating]: streaming,
|
|
[ClientToolCallState.pending]: streaming,
|
|
[ClientToolCallState.executing]: streaming,
|
|
[ClientToolCallState.success]: success,
|
|
[ClientToolCallState.error]: error,
|
|
[ClientToolCallState.rejected]: {
|
|
text: `${config.id.charAt(0).toUpperCase() + config.id.slice(1)} skipped`,
|
|
icon: error.icon,
|
|
},
|
|
[ClientToolCallState.aborted]: {
|
|
text: `${config.id.charAt(0).toUpperCase() + config.id.slice(1)} aborted`,
|
|
icon: error.icon,
|
|
},
|
|
},
|
|
uiConfig,
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Base class for subagent tools.
|
|
* Extends BaseClientTool with subagent-specific behavior.
|
|
*/
|
|
export abstract class BaseSubagentTool extends BaseClientTool {
|
|
/**
|
|
* Subagent configuration.
|
|
* Override in subclasses to customize behavior.
|
|
*/
|
|
static readonly subagentConfig: SubagentToolConfig
|
|
|
|
constructor(toolCallId: string, config: SubagentToolConfig) {
|
|
super(toolCallId, config.id, createSubagentMetadata(config))
|
|
// Register UI config for this tool
|
|
registerToolUIConfig(config.id, this.metadata.uiConfig!)
|
|
}
|
|
|
|
/**
|
|
* Execute the subagent tool.
|
|
* Immediately transitions to executing state - the actual work
|
|
* is done server-side by the subagent.
|
|
*/
|
|
async execute(_args?: Record<string, any>): Promise<void> {
|
|
this.setState(ClientToolCallState.executing)
|
|
// The tool result will come from the server via tool_result event
|
|
// when the subagent completes its work
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Factory function to create a subagent tool class.
|
|
* Use this for simple subagent tools that don't need custom behavior.
|
|
*/
|
|
export function createSubagentToolClass(config: SubagentToolConfig) {
|
|
// Register UI config at class creation time
|
|
const uiConfig: ToolUIConfig = {
|
|
isSpecial: config.isSpecial ?? false,
|
|
subagent: config.subagent,
|
|
}
|
|
registerToolUIConfig(config.id, uiConfig)
|
|
|
|
return class extends BaseClientTool {
|
|
static readonly id = config.id
|
|
|
|
constructor(toolCallId: string) {
|
|
super(toolCallId, config.id, createSubagentMetadata(config))
|
|
}
|
|
|
|
async execute(_args?: Record<string, any>): Promise<void> {
|
|
this.setState(ClientToolCallState.executing)
|
|
}
|
|
}
|
|
}
|