Skip to content

Commit e4200af

Browse files
Sg312claude
andcommitted
feat(copilot): run_code compute-only handler; docs lint fix
Mirrors mothership dev db60da94: run_code is the compute-only variant of function_execute for the search agent — same sandbox and inputs, no outputs.files / outputTable, so it cannot create or overwrite workspace resources. Wrapper handler hard-rejects the write vectors and delegates to executeFunctionExecute; run_code is deliberately absent from OUTPUT_PATH_TOOLS and the table output post-processor, so the name gating blocks writes even for leaked args. Added to LONG_RUNNING_TOOL_IDS, display title/icon maps, and the regenerated catalog/schema mirrors. Also removes two ineffective biome suppression comments in the docs workflow-preview (the rule doesn't fire in the docs app config). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 3e43b48 commit e4200af

8 files changed

Lines changed: 324 additions & 99 deletions

File tree

apps/docs/components/workflow-preview/format-references.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ export function formatReferences(text: string): ReactNode[] {
1515
const isReference =
1616
(part.startsWith('<') && part.endsWith('>')) || (part.startsWith('{{') && part.endsWith('}}'))
1717
return isReference ? (
18-
// biome-ignore lint/suspicious/noArrayIndexKey: static, never reordered
1918
<span key={index} className='text-[var(--brand-secondary)]'>
2019
{part}
2120
</span>
2221
) : (
23-
// biome-ignore lint/suspicious/noArrayIndexKey: static, never reordered
2422
<span key={index}>{part}</span>
2523
)
2624
})

apps/sim/app/workspace/[workspaceId]/home/components/message-content/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const TOOL_ICONS: Record<string, IconComponent> = {
3838
manage_skill: Asterisk,
3939
user_memory: Database,
4040
function_execute: TerminalWindow,
41+
run_code: TerminalWindow,
4142
superagent: Blimp,
4243
user_table: TableIcon,
4344
workspace_file: File,

apps/sim/lib/copilot/generated/tool-catalog-v1.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export interface ToolCatalogEntry {
8181
| 'restore_resource'
8282
| 'run'
8383
| 'run_block'
84+
| 'run_code'
8485
| 'run_from_block'
8586
| 'run_workflow'
8687
| 'run_workflow_until_block'
@@ -181,6 +182,7 @@ export interface ToolCatalogEntry {
181182
| 'restore_resource'
182183
| 'run'
183184
| 'run_block'
185+
| 'run_code'
184186
| 'run_from_block'
185187
| 'run_workflow'
186188
| 'run_workflow_until_block'
@@ -3332,6 +3334,99 @@ export const RunBlock: ToolCatalogEntry = {
33323334
clientExecutable: true,
33333335
}
33343336

3337+
export const RunCode: ToolCatalogEntry = {
3338+
id: 'run_code',
3339+
name: 'run_code',
3340+
route: 'sim',
3341+
mode: 'async',
3342+
parameters: {
3343+
type: 'object',
3344+
properties: {
3345+
code: {
3346+
type: 'string',
3347+
description:
3348+
'Code to execute. For JS: raw statements auto-wrapped in async context. For Python: full script. For shell: bash script with access to pre-installed CLI tools and workspace env vars as $VAR_NAME.',
3349+
},
3350+
inputs: {
3351+
type: 'object',
3352+
description:
3353+
'Workspace resources to mount into the sandbox. Copy paths verbatim from glob/read/grep output — they are percent-encoded per segment (spaces are %20, an in-name slash is %2F; parentheses and dots stay literal). Both the encoded path and the plain name resolve, so copy the returned path exactly rather than retyping or decoding it.',
3354+
properties: {
3355+
directories: {
3356+
type: 'array',
3357+
description:
3358+
'Workspace folders to mount recursively into the sandbox, including nested files and empty folders.',
3359+
items: {
3360+
type: 'object',
3361+
properties: {
3362+
path: {
3363+
type: 'string',
3364+
description:
3365+
'Canonical VFS folder path, e.g. "files/Reports". By default this mounts at "/home/user/{path}".',
3366+
},
3367+
sandboxPath: {
3368+
type: 'string',
3369+
description:
3370+
'Optional full sandbox directory path override. Omit to mount at /home/user/{path}.',
3371+
},
3372+
},
3373+
required: ['path'],
3374+
},
3375+
},
3376+
files: {
3377+
type: 'array',
3378+
description: 'Workspace files to mount into the sandbox.',
3379+
items: {
3380+
type: 'object',
3381+
properties: {
3382+
path: {
3383+
type: 'string',
3384+
description:
3385+
'Canonical VFS file path, e.g. "files/Reports/sales.csv". By default this mounts at "/home/user/{path}".',
3386+
},
3387+
sandboxPath: {
3388+
type: 'string',
3389+
description:
3390+
'Full sandbox path to mount at, e.g. /home/user/inputs/data.csv. STRONGLY RECOMMENDED whenever the file name has spaces or special characters: the default mount path is the percent-ENCODED canonical path (e.g. /home/user/files/Q4%20Sales%20(Final).csv), which code using the human-readable name will not find. Set a simple sandboxPath and read exactly that.',
3391+
},
3392+
},
3393+
required: ['path'],
3394+
},
3395+
},
3396+
tables: {
3397+
type: 'array',
3398+
description: 'Workspace tables to mount as CSV files.',
3399+
items: {
3400+
type: 'object',
3401+
properties: {
3402+
path: { type: 'string', description: 'Canonical VFS table path when available.' },
3403+
sandboxPath: {
3404+
type: 'string',
3405+
description: 'Optional full sandbox path for the mounted CSV.',
3406+
},
3407+
tableId: { type: 'string', description: 'Workspace table ID.' },
3408+
},
3409+
},
3410+
},
3411+
},
3412+
},
3413+
language: {
3414+
type: 'string',
3415+
description: 'Execution language.',
3416+
enum: ['javascript', 'python', 'shell'],
3417+
},
3418+
title: {
3419+
type: 'string',
3420+
description:
3421+
'Short user-visible label for this execution, e.g. "Sum June invoices" or "Verify email formats".',
3422+
},
3423+
},
3424+
required: ['code'],
3425+
},
3426+
requiredPermission: 'write',
3427+
capabilities: ['file_input', 'directory_input', 'table_input'],
3428+
}
3429+
33353430
export const RunFromBlock: ToolCatalogEntry = {
33363431
id: 'run_from_block',
33373432
name: 'run_from_block',
@@ -4773,6 +4868,7 @@ export const TOOL_CATALOG: Record<string, ToolCatalogEntry> = {
47734868
[RestoreResource.id]: RestoreResource,
47744869
[Run.id]: Run,
47754870
[RunBlock.id]: RunBlock,
4871+
[RunCode.id]: RunCode,
47764872
[RunFromBlock.id]: RunFromBlock,
47774873
[RunWorkflow.id]: RunWorkflow,
47784874
[RunWorkflowUntilBlock.id]: RunWorkflowUntilBlock,

0 commit comments

Comments
 (0)