mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## What
Assistant tool contracts now declare where they're available, and
`getTools` builds tools from the registry.
- `ToolContract` and `RemoteToolContract` gain `availability: {
environments, requires? }`, both read-only sets. `environments` is
`platform` and/or `self-hosted`; `requires` is any of `explorer`,
`supportMode`, `baseUrl`.
- New `tools/registry.server.ts` maps every contract to its factory in
`TOOL_FACTORIES`; its type makes a missing or mismatched factory a
compile error. `buildLocalTools` builds only the tools available for a
request.
- `getTools` no longer branches per tool module. Local contract tools
take precedence over remote MCP tools with the same name. The
self-hosted fallback tools are unchanged for now.
- Deleted the per-module getters (`studio-tools.ts`, `schema-tools.ts`,
`report-tools.ts`, `notebook-tools.ts`, `incident-tools.ts`,
`support-tools.ts`); their tests now call the factories directly.
## Behavior changes
- Self-hosted no longer offers `deploy_edge_function`. Its server half
calls `/v1/projects/{ref}/functions/deploy`, which self-hosted Studio
doesn't serve.
- Self-hosted no longer offers the support tools (`escalate_to_human`,
`resolve_support_conversation`) in support mode.
- Platform offers `list_databases` without the Explorer flag.
Everything else produces the same tool set as before.
## Tests
- `index.availability.test.ts` asserts the exact tool names for every
combination of environment, Explorer, support mode, and `baseUrl`.
- `registry.test.ts` checks registry invariants: keys match contract
names, every contract has a factory, and a name in both the local and
remote maps has disjoint environments and matching gates.
This is the first step in moving the self-hosted Assistant tools to
contracts.
## Checklist
Check all before review:
- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
import type { ToolContract } from './types'
|
|
|
|
const inputSchema = z.object({})
|
|
|
|
const outputSchema = z.object({
|
|
incidents: z.array(
|
|
z.object({
|
|
kind: z.enum(['incident', 'maintenance']),
|
|
name: z.string(),
|
|
status: z.string(),
|
|
impact: z.string().optional(),
|
|
affected_components: z.array(z.string()),
|
|
last_update_message: z.string().nullable(),
|
|
url: z.string(),
|
|
started_at: z.string().optional(),
|
|
})
|
|
),
|
|
message: z.string(),
|
|
})
|
|
|
|
export const contract = {
|
|
name: 'get_active_incidents',
|
|
description:
|
|
'Check for active incidents. Use this tool when the user reports issues with any Supabase service, including the database, authentication, realtime, storage, and functions. Possible problems include, but are not limited to, connection issues, timeouts, service unavailability, authentication failures, or unexpected errors.',
|
|
inputSchema,
|
|
outputSchema,
|
|
minOptInLevel: null,
|
|
availability: {
|
|
environments: new Set(['platform']),
|
|
requires: new Set(['baseUrl']),
|
|
},
|
|
needsApproval: false,
|
|
toModelOutput: (output: z.infer<typeof outputSchema>) => output,
|
|
} as const satisfies ToolContract
|