mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 23:59:08 +03:00
## Summary
Migrates four more assistant tools to the contract + `.server.ts`
pattern used by the notebook tools. Each tool now declares its schemas,
opt-in level, approval and model-visible output once.
## Changes
* Add contracts and server factories for `execute_sql`,
`deploy_edge_function`, `rename_chat`, `load_knowledge`;
`getStudioTools` now composes them.
* Add `execute-sql-output.ts` (output schema, `toModelRows`,
`NO_DATA_PERMISSIONS`) and `knowledge-topics.ts` (topic names + UI
labels, replacing the copy in `Message.Parts.utils.ts`).
* Delete `executeSqlSanitizer` and `ALL_TOOL_SANITIZERS`; history replay
goes through `sanitizeContractPart` only.
* Drop the four tools from `TOOL_CATEGORY_MAP`; the UI and evals import
schemas from the contracts; `rename_chat` input casts now use the
contract type.
## Deviations worth reviewing
* `execute_sql` replay: a bare-array legacy output is stamped `schema`
via a union transform (still hidden from the model, still shown in the
UI). A malformed non-array output is now dropped, where before it passed
through at the data level.
* The "no data permission" message now reaches the model as a JSON
string value instead of a text part. The text the model sees is
unchanged.
* `deploy_edge_function` output is now strictly `{ success: boolean }`
in the UI parse (was optional/passthrough).
21 lines
693 B
TypeScript
21 lines
693 B
TypeScript
import { contract } from './deploy-edge-function'
|
|
import { toolFromContract } from './tool-from-contract'
|
|
import type { ToolFactory } from './types'
|
|
import { deployEdgeFunction } from '@/data/edge-functions/edge-functions-deploy-mutation'
|
|
|
|
export const createTool: ToolFactory<typeof contract> = (ctx) =>
|
|
toolFromContract(contract, ctx, async ({ name, code }) => {
|
|
await deployEdgeFunction({
|
|
projectRef: ctx.projectRef ?? '',
|
|
slug: name,
|
|
metadata: {
|
|
entrypoint_path: 'index.ts',
|
|
name,
|
|
verify_jwt: true,
|
|
},
|
|
files: [{ name: 'index.ts', content: code }],
|
|
authorization: ctx.authorization,
|
|
})
|
|
return { success: true }
|
|
})
|