Let a bot and a workspace set their own envs
Envs had three scopes, general, workspace and computer. A bot had no
scope of its own, so the only way to give one worker a key was to set it
on a computer it happened to share.
The envs table gets a bot_id, and resolution now layers bot over
computer over workspace over general, so a bot's own key wins wherever it
runs. Every computer call site passes the run's bot_id, and grabRunEnvs
does the same for the {{env.KEY}} a custom tool or an MCP server's headers
read.
A bot's and a workspace's settings page can now edit their own envs, in
place, through the same save-env and delete-env routes: sending `scoped`
makes them answer with just that scope instead of the whole install's
overview. Super admins only, like the Environment page.
This commit is contained in:
@@ -12,12 +12,22 @@ export const SaveEnvRequestSchema = z.object({
|
||||
paradigm: z.enum(EnvParadigms.map((p) => p.value) as [EnvParadigm, ...EnvParadigm[]]),
|
||||
workspace_id: z.coerce.number().int().positive().nullable().optional(),
|
||||
computer_id: z.coerce.number().int().positive().nullable().optional(),
|
||||
bot_id: z.coerce.number().int().positive().nullable().optional(),
|
||||
secret: z.boolean(),
|
||||
expose_to_computers: z.boolean(),
|
||||
/**
|
||||
* Set when the form was a bot's or workspace's settings page, which
|
||||
* keeps only that scope's envs rather than the whole overview.
|
||||
*/
|
||||
scoped: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const EnvIdRequestSchema = z.object({
|
||||
env_id: z.coerce.number().int().positive(),
|
||||
/**
|
||||
* A bot's or workspace's settings page, as `SaveEnvRequestSchema`'s.
|
||||
*/
|
||||
scoped: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export type SaveEnvRequest = z.infer<typeof SaveEnvRequestSchema>;
|
||||
|
||||
Reference in New Issue
Block a user