mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +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)
20 lines
1.0 KiB
TypeScript
20 lines
1.0 KiB
TypeScript
import { IS_PLATFORM } from 'common'
|
|
|
|
import { getServerFlags, type TrustedUserEmail } from '@/lib/server/configcat'
|
|
|
|
// Notebooks haven't shipped yet — they're gated behind the Explorer feature flag on the
|
|
// client (`useFlag('explorer')`). The AI tools that read notebook content (list_notebooks,
|
|
// get_notebook, which declare the `explorer` requirement) must not be advertised to the
|
|
// assistant until this resolves true for the requesting user, otherwise the assistant will
|
|
// believe notebooks exist for users who can't yet see them in the UI.
|
|
//
|
|
// Takes TrustedUserEmail, not a plain string: callers must go through
|
|
// lib/server/configcat's trustedUserEmail() to prove this came from a verified source
|
|
// (a decoded, signature-checked JWT claim), not a raw request param.
|
|
export async function isExplorerEnabled(userEmail?: TrustedUserEmail): Promise<boolean> {
|
|
if (!IS_PLATFORM) return false
|
|
|
|
const flags = await getServerFlags(userEmail)
|
|
return flags.some((flag) => flag.settingKey === 'explorer' && flag.settingValue === true)
|
|
}
|