feat(providers): add native options and exact MCP grants (#3025)

* feat(providers): add native options and exact MCP grants

Keep provider policy in provider-owned schemas so unattended Hub runs can grant only requested tools from injected MCP servers. Preserve the native resolved sandbox policy when a workflow override is present, including configured writable roots.

* test(hub): verify real provider tool policy

* test(app): avoid pinning transient restart status
This commit is contained in:
Mohamed Boudra
2026-08-08 16:49:29 +02:00
committed by GitHub
parent b669dad221
commit f0eb7cea4b
48 changed files with 2497 additions and 280 deletions
@@ -108,6 +108,43 @@ describe("Hub session protocol", () => {
});
});
test("round-trips native provider options and structured MCP preapproval", () => {
const message = {
type: "hub.execution.agent.create.request",
requestId: "request-policy",
executionId: "execution-policy",
provider: "codex",
cwd: "/workspace",
prompt: "Classify and finish",
providerOptions: {
sandbox_mode: "workspace-write",
sandbox_workspace_write: { writable_roots: ["/var/cache/npm"] },
},
mcpServers: {
hub: { type: "http", url: "https://hub.example/executions/policy" },
},
toolPolicy: {
preapproved: [{ kind: "mcp", server: "hub", tool: "finish_execution" }],
},
};
expect(SessionInboundMessageSchema.parse(message)).toEqual(message);
});
test.each(["Bash", "Edit", "Write"])("cannot encode native %s tool preapproval", (tool) => {
const message = {
type: "hub.execution.agent.create.request",
requestId: "request-native-tool",
executionId: "execution-native-tool",
provider: "claude",
cwd: "/workspace",
prompt: "Do work",
toolPolicy: { preapproved: [{ kind: "native", server: "claude", tool }] },
};
expect(SessionInboundMessageSchema.safeParse(message).success).toBe(false);
});
test.each([
undefined,
{ mode: "branch-off", newBranch: "hub-work", base: "main" },