Skip to content

Commit c69d710

Browse files
committed
ff
1 parent cec7b0e commit c69d710

8 files changed

Lines changed: 190 additions & 135 deletions

File tree

apps/sim/lib/copilot/tools/handlers/function-execute.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createLogger } from '@sim/logger'
22
import { decodeVfsPathSegments, encodeVfsPathSegments } from '@/lib/copilot/vfs/path-utils'
33
import { resolveWorkflowAliasForWorkspace } from '@/lib/copilot/vfs/workflow-alias-resolver'
44
import { isPlanAliasPath, workflowAliasSandboxPath } from '@/lib/copilot/vfs/workflow-aliases'
5+
import { isMothershipBetaFeaturesEnabled } from '@/lib/core/config/feature-flags'
56
import { getTableById, listTables, queryRows } from '@/lib/table/service'
67
import { listWorkspaceFileFolders } from '@/lib/uploads/contexts/workspace/workspace-file-folder-manager'
78
import {
@@ -71,7 +72,9 @@ async function resolveInputFiles(
7172
let totalSize = 0
7273

7374
if (inputFiles?.length && workspaceId) {
74-
const allFiles = await listWorkspaceFiles(workspaceId, { includeReservedSystemFiles: true })
75+
const allFiles = await listWorkspaceFiles(workspaceId, {
76+
includeReservedSystemFiles: isMothershipBetaFeaturesEnabled,
77+
})
7578
for (const fileRef of inputFiles) {
7679
const filePath =
7780
typeof fileRef === 'string'
@@ -124,11 +127,11 @@ async function resolveInputFiles(
124127

125128
if (inputDirectories?.length && workspaceId) {
126129
const folders = await listWorkspaceFileFolders(workspaceId, {
127-
includeReservedSystemFolders: true,
130+
includeReservedSystemFolders: isMothershipBetaFeaturesEnabled,
128131
})
129132
const allFiles = await listWorkspaceFiles(workspaceId, {
130133
folders,
131-
includeReservedSystemFiles: true,
134+
includeReservedSystemFiles: isMothershipBetaFeaturesEnabled,
132135
})
133136
for (const dirRef of inputDirectories) {
134137
const dirPath =

apps/sim/lib/copilot/tools/server/files/touch-plan.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ vi.mock('@/lib/copilot/vfs/resource-writer', () => ({
1818
writeWorkspaceFileByPath: mocks.writeWorkspaceFileByPath,
1919
}))
2020

21+
vi.mock('@/lib/core/config/feature-flags', () => ({
22+
isMothershipBetaFeaturesEnabled: true,
23+
}))
24+
2125
import { touchPlanServerTool } from './touch-plan'
2226

2327
describe('touch_plan server tool', () => {

apps/sim/lib/copilot/tools/server/files/touch-plan.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '@/lib/copilot/vfs/path-utils'
1313
import { writeWorkspaceFileByPath } from '@/lib/copilot/vfs/resource-writer'
1414
import { resolveWorkflowAliasForWorkspace } from '@/lib/copilot/vfs/workflow-alias-resolver'
15+
import { isMothershipBetaFeaturesEnabled } from '@/lib/core/config/feature-flags'
1516

1617
const logger = createLogger('TouchPlanServerTool')
1718
const TOUCH_PLAN_TOOL_ID = 'touch_plan'
@@ -64,6 +65,9 @@ function normalizePlanRelativePath(name: string): string {
6465
export const touchPlanServerTool: BaseServerTool<TouchPlanArgs, TouchPlanResult> = {
6566
name: TOUCH_PLAN_TOOL_ID,
6667
async execute(params: TouchPlanArgs, context?: ServerToolContext): Promise<TouchPlanResult> {
68+
if (!isMothershipBetaFeaturesEnabled) {
69+
return { success: false, message: 'touch_plan is not available' }
70+
}
6771
if (!context?.userId) {
6872
throw new Error('Authentication required')
6973
}

apps/sim/lib/copilot/tools/server/router.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
type BaseServerTool,
2626
type ServerToolContext,
2727
} from '@/lib/copilot/tools/server/base-tool'
28+
import { isMothershipBetaFeaturesEnabled } from '@/lib/core/config/feature-flags'
2829
import { getBlocksMetadataServerTool } from '@/lib/copilot/tools/server/blocks/get-blocks-metadata-tool'
2930
import { getTriggerBlocksServerTool } from '@/lib/copilot/tools/server/blocks/get-trigger-blocks'
3031
import { searchDocumentationServerTool } from '@/lib/copilot/tools/server/docs/search-documentation'
@@ -130,7 +131,7 @@ function isWriteAction(toolName: string, action: string | undefined): boolean {
130131
}
131132

132133
/** Registry of all server tools. Tools self-declare their validation schemas. */
133-
const serverToolRegistry: Record<string, BaseServerTool> = {
134+
const baseServerToolRegistry: Record<string, BaseServerTool> = {
134135
[getBlocksMetadataServerTool.name]: getBlocksMetadataServerTool,
135136
[getTriggerBlocksServerTool.name]: getTriggerBlocksServerTool,
136137
[editWorkflowServerTool.name]: editWorkflowServerTool,
@@ -159,16 +160,25 @@ const serverToolRegistry: Record<string, BaseServerTool> = {
159160
[generateImageServerTool.name]: generateImageServerTool,
160161
}
161162

163+
function getServerToolRegistry(): Record<string, BaseServerTool> {
164+
if (isMothershipBetaFeaturesEnabled) {
165+
return baseServerToolRegistry
166+
}
167+
const registry = { ...baseServerToolRegistry }
168+
delete registry[touchPlanServerTool.name]
169+
return registry
170+
}
171+
162172
export function getRegisteredServerToolNames(): string[] {
163-
return Object.keys(serverToolRegistry)
173+
return Object.keys(getServerToolRegistry())
164174
}
165175

166176
export async function routeExecution(
167177
toolName: string,
168178
payload: unknown,
169179
context?: ServerToolContext
170180
): Promise<unknown> {
171-
const tool = serverToolRegistry[toolName]
181+
const tool = getServerToolRegistry()[toolName]
172182
if (!tool) {
173183
throw new Error(`Unknown server tool: ${toolName}`)
174184
}

apps/sim/lib/copilot/vfs/workflow-alias-resolver.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import {
88
resolveWorkflowAliasPath,
99
type WorkflowAliasTarget,
1010
} from '@/lib/copilot/vfs/workflow-aliases'
11+
import { isMothershipBetaFeaturesEnabled } from '@/lib/core/config/feature-flags'
1112
import { canonicalizeVfsPath } from './path-utils'
1213

1314
export async function resolveWorkflowAliasForWorkspace(args: {
1415
workspaceId: string
1516
path: string
1617
}): Promise<WorkflowAliasTarget | null> {
18+
if (!isMothershipBetaFeaturesEnabled) return null
1719
if (!isPlanAliasPath(args.path)) return null
1820

1921
let canonicalPath: string

0 commit comments

Comments
 (0)