fix(core): align agent tests with universal default permissions (#34561)
This commit is contained in:
@@ -60,7 +60,6 @@ export const Plugin = define({
|
|||||||
const configuredDefault = Config.latest(documents, "default_agent")
|
const configuredDefault = Config.latest(documents, "default_agent")
|
||||||
if (configuredDefault !== undefined) draft.default(AgentV2.ID.make(configuredDefault))
|
if (configuredDefault !== undefined) draft.default(AgentV2.ID.make(configuredDefault))
|
||||||
for (const current of draft.list()) {
|
for (const current of draft.list()) {
|
||||||
yield* Effect.log({ msg: "applying permissions", id: current.id, permissions: global })
|
|
||||||
draft.update(current.id, (agent) => agent.permissions.push(...global))
|
draft.update(current.id, (agent) => agent.permissions.push(...global))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ describe("ConfigAgentPlugin.Plugin", () => {
|
|||||||
const buildAgent = yield* agents.get(build)
|
const buildAgent = yield* agents.get(build)
|
||||||
if (!buildAgent) throw new Error("expected configured build agent")
|
if (!buildAgent) throw new Error("expected configured build agent")
|
||||||
expect(buildAgent.permissions).toEqual([
|
expect(buildAgent.permissions).toEqual([
|
||||||
|
{ action: "*", resource: "*", effect: "allow" },
|
||||||
|
{ action: "external_directory", resource: "*", effect: "ask" },
|
||||||
{ action: "bash", resource: "*", effect: "allow" },
|
{ action: "bash", resource: "*", effect: "allow" },
|
||||||
{ action: "bash", resource: "*", effect: "ask" },
|
{ action: "bash", resource: "*", effect: "ask" },
|
||||||
{ action: "read", resource: "*", effect: "allow" },
|
{ action: "read", resource: "*", effect: "allow" },
|
||||||
@@ -94,6 +96,8 @@ describe("ConfigAgentPlugin.Plugin", () => {
|
|||||||
model: { providerID: "openrouter", id: "openai/gpt-5", variant: "high" },
|
model: { providerID: "openrouter", id: "openai/gpt-5", variant: "high" },
|
||||||
})
|
})
|
||||||
expect(reviewer.permissions).toEqual([
|
expect(reviewer.permissions).toEqual([
|
||||||
|
{ action: "*", resource: "*", effect: "allow" },
|
||||||
|
{ action: "external_directory", resource: "*", effect: "ask" },
|
||||||
{ action: "bash", resource: "*", effect: "ask" },
|
{ action: "bash", resource: "*", effect: "ask" },
|
||||||
{ action: "read", resource: "*", effect: "allow" },
|
{ action: "read", resource: "*", effect: "allow" },
|
||||||
{ action: "edit", resource: "*", effect: "deny" },
|
{ action: "edit", resource: "*", effect: "deny" },
|
||||||
@@ -101,6 +105,8 @@ describe("ConfigAgentPlugin.Plugin", () => {
|
|||||||
])
|
])
|
||||||
expect(PermissionV2.evaluate("read", "README.md", reviewer.permissions).effect).toBe("deny")
|
expect(PermissionV2.evaluate("read", "README.md", reviewer.permissions).effect).toBe("deny")
|
||||||
expect((yield* agents.get(AgentV2.ID.make("late")))?.permissions).toEqual([
|
expect((yield* agents.get(AgentV2.ID.make("late")))?.permissions).toEqual([
|
||||||
|
{ action: "*", resource: "*", effect: "allow" },
|
||||||
|
{ action: "external_directory", resource: "*", effect: "ask" },
|
||||||
{ action: "bash", resource: "*", effect: "ask" },
|
{ action: "bash", resource: "*", effect: "ask" },
|
||||||
{ action: "read", resource: "*", effect: "allow" },
|
{ action: "read", resource: "*", effect: "allow" },
|
||||||
{ action: "edit", resource: "*", effect: "allow" },
|
{ action: "edit", resource: "*", effect: "allow" },
|
||||||
@@ -258,13 +264,21 @@ Use native v2 fields.`,
|
|||||||
system: "Review carefully.",
|
system: "Review carefully.",
|
||||||
description: "Markdown description",
|
description: "Markdown description",
|
||||||
request: { body: { temperature: 0.5 } },
|
request: { body: { temperature: 0.5 } },
|
||||||
permissions: [{ action: "edit", resource: "*", effect: "deny" }],
|
permissions: [
|
||||||
|
{ action: "*", resource: "*", effect: "allow" },
|
||||||
|
{ action: "external_directory", resource: "*", effect: "ask" },
|
||||||
|
{ action: "edit", resource: "*", effect: "deny" },
|
||||||
|
],
|
||||||
})
|
})
|
||||||
expect(yield* agents.get(AgentV2.ID.make("team/helper"))).toMatchObject({ system: "Help the team." })
|
expect(yield* agents.get(AgentV2.ID.make("team/helper"))).toMatchObject({ system: "Help the team." })
|
||||||
expect(yield* agents.get(AgentV2.ID.make("native"))).toMatchObject({
|
expect(yield* agents.get(AgentV2.ID.make("native"))).toMatchObject({
|
||||||
system: "Use native v2 fields.",
|
system: "Use native v2 fields.",
|
||||||
request: { headers: { "x-agent": "native" }, body: { effort: "high" } },
|
request: { headers: { "x-agent": "native" }, body: { effort: "high" } },
|
||||||
permissions: [{ action: "edit", resource: "*", effect: "deny" }],
|
permissions: [
|
||||||
|
{ action: "*", resource: "*", effect: "allow" },
|
||||||
|
{ action: "external_directory", resource: "*", effect: "ask" },
|
||||||
|
{ action: "edit", resource: "*", effect: "deny" },
|
||||||
|
],
|
||||||
})
|
})
|
||||||
expect(yield* agents.get(AgentV2.ID.make("disabled"))).toBeUndefined()
|
expect(yield* agents.get(AgentV2.ID.make("disabled"))).toBeUndefined()
|
||||||
expect(yield* agents.get(AgentV2.ID.make("plan"))).toMatchObject({ system: "Make a plan.", mode: "primary" })
|
expect(yield* agents.get(AgentV2.ID.make("plan"))).toMatchObject({ system: "Make a plan.", mode: "primary" })
|
||||||
|
|||||||
Reference in New Issue
Block a user