Skip to content

Commit 5c0a7b4

Browse files
committed
feat(copilot): add rename operation to user_table tool
1 parent fa181f0 commit 5c0a7b4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

apps/sim/lib/copilot/tools/server/table/user-table.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
insertRow,
1919
queryRows,
2020
renameColumn,
21+
renameTable,
2122
updateColumnConstraints,
2223
updateColumnType,
2324
updateRow,
@@ -878,6 +879,35 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
878879
}
879880
}
880881

882+
case 'rename': {
883+
if (!args.tableId) {
884+
return { success: false, message: 'Table ID is required' }
885+
}
886+
if (!args.name) {
887+
return { success: false, message: 'Name is required for renaming a table' }
888+
}
889+
if (!workspaceId) {
890+
return { success: false, message: 'Workspace ID is required' }
891+
}
892+
893+
const table = await getTableById(args.tableId)
894+
if (!table) {
895+
return { success: false, message: `Table not found: ${args.tableId}` }
896+
}
897+
if (table.workspaceId !== workspaceId) {
898+
return { success: false, message: 'Table not found' }
899+
}
900+
901+
const requestId = crypto.randomUUID().slice(0, 8)
902+
const renamed = await renameTable(args.tableId, args.name, requestId)
903+
904+
return {
905+
success: true,
906+
message: `Renamed table to "${renamed.name}"`,
907+
data: { table: { id: renamed.id, name: renamed.name } },
908+
}
909+
}
910+
881911
default:
882912
return { success: false, message: `Unknown operation: ${operation}` }
883913
}

apps/sim/lib/copilot/tools/shared/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export const UserTableArgsSchema = z.object({
127127
'rename_column',
128128
'delete_column',
129129
'update_column',
130+
'rename',
130131
]),
131132
args: z
132133
.object({

0 commit comments

Comments
 (0)