mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 15:52:36 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Budgets stop agent spending. The budget hard stop is a control-plane invariant > - The budget routes (`PATCH /api/agents/:id/budgets`, `PATCH /api/companies/:id/budgets`) are board-only > - `PATCH /api/agents/:id` also accepts `budgetMonthlyCents`, and the configuration service writes the agent budget policy from it. That route had no board check for the field > - So an agent, such as a CEO, a manager or the agent itself, can change a monthly budget without a board user. This is a second route around a board-only control, like the pause bypass that #20164 fixed > - This pull request applies the budget route authority to every route that writes an agent budget, and gives agents the final board-only denial with a link to the budget page (#20151) > - The benefit is that only the board changes budgets, and an agent that asks gets a final answer that it can pass to the person ## Linked Issues or Issue Description Refs #17857 (earlier fix, now in conflict with master; this PR rebases it and adds the budget page link). Refs #20164 and #20151 (same pattern for PATCH status and board-only denials). **What happened** An agent can send `PATCH /api/agents/{id}` with `budgetMonthlyCents`. The route accepts it, and the configuration service writes the agent budget policy. This works for the agent's own budget and, with update permission, for other agents. The same field also reaches budget policy through a configuration rollback, direct agent creation, an immediate hire and a built-in agent provision. A chat eval (`budgets-costs.resolve-budget`) found the route. **Expected behavior** Only a board user can change an active budget, as on the dedicated budget routes. An agent gets `403` with code `board_access_required`. The denial says it is final and links the agent's budget tab (`/<prefix>/agents/<id>/budgets`) or the company budgets page (`/<prefix>/activity/budgets`). An agent can still propose a budget in a hire that waits for board approval. The approving board user activates it. **Steps to reproduce** 1. On master, authenticate as an agent of a company (for example the CEO). 2. Send `PATCH /api/agents/{agentId}` with body `{"budgetMonthlyCents": 5000}`, for its own id or for another agent. 3. See `200`. The agent budget policy changes with no board action. 4. The new route tests reproduce this: on master source they fail with `expected 200 to be 403`. ## What Changed - `PATCH /api/agents/:id`: a changed `budgetMonthlyCents` requires a board actor. An unchanged amount with other edits still works. - Configuration rollback: a rollback that changes the budget requires a board actor. - `POST /api/companies/:id/agents` and an immediate `agent-hires`: a positive budget requires a board actor. A hire that needs board approval keeps the proposed budget and does not activate it before approval. - Built-in agent provision: a budget override requires a board actor. - `prepareAgentConfiguration` rejects an agent-originated budget change again (defense in depth). An agent rollback with an unchanged amount does not rewrite the policy. - Board writes keep the actual operator identity. The initial hire budget is saved in the hire transaction. - `assertBoard` and `boardAccessRequired` take an optional board page. Budget denials link the agent's budget tab or the company budgets page, not the general agent profile. - Agent access map updated. - This includes the four commits of #17857 (f970f6b01f,8c06aba41c,e5682d22fa,b6cd49d4b6), rebased onto master with the conflicts resolved, then squashed. ## Verification - Red on master source, same tests: 12 budget tests fail. The PATCH tests fail with `expected 200 to be 403` for the agent's own budget and for a CEO on another agent. Built-in provision fails with `expected 200 to be 403`. Creation and immediate hire fail with `expected 201 to be 403`. - Green with the fix: `cd server && npx vitest run src/__tests__/agent-permissions-routes.test.ts src/__tests__/built-in-agent-routes.test.ts src/__tests__/built-in-agents.test.ts src/__tests__/agent-hire-idempotency-routes.test.ts src/__tests__/board-access-denial.test.ts src/__tests__/agent-budget-configuration.test.ts`: 222 passed. - `src/modules/agent-lifecycle/__tests__/lifecycle.test.ts` (embedded Postgres): 76 passed. - `agent-skills-routes`, `agent-adapter-validation-routes`, `openapi-routes`, `agent-cross-tenant-authz-routes`: 275 passed. - `node scripts/check-maps.mjs`: passed. `git diff --check`: passed. - Server `tsc --noEmit`: no errors in changed files. One error in `native-session-executor.ts` comes from a linked runner build in the local worktree, not from this change. CI runs the full typecheck. ## Risks - Agent clients that set an active budget directly now get `403`. They must propose the budget in an approval-gated hire, or ask a board user. - Agent creation with no budget or a zero budget is not changed. Pending hire budgets do not activate before approval. - Trusted internal plugin provisioning keeps its prior behavior and gets no board identity. - No schema or migration change. ## Model Used - Anthropic Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution, in Claude Code. The rebased commits from #17857 were first written with OpenAI `gpt-6.1-sol` through Codex. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
455 lines
16 KiB
TypeScript
455 lines
16 KiB
TypeScript
import express from "express";
|
|
import request from "supertest";
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const companyId = "22222222-2222-4222-8222-222222222222";
|
|
const agentId = "11111111-1111-4111-8111-111111111111";
|
|
|
|
const mockAccessService = vi.hoisted(() => ({
|
|
decide: vi.fn(),
|
|
canUser: vi.fn(),
|
|
}));
|
|
|
|
const mockInstanceSettingsService = vi.hoisted(() => ({
|
|
getExperimental: vi.fn(),
|
|
}));
|
|
|
|
const mockBuiltInAgentService = vi.hoisted(() => ({
|
|
list: vi.fn(),
|
|
get: vi.fn(),
|
|
ensure: vi.fn(),
|
|
provision: vi.fn(),
|
|
reset: vi.fn(),
|
|
enableRoutineSchedule: vi.fn(),
|
|
disableRoutineSchedule: vi.fn(),
|
|
runRoutine: vi.fn(),
|
|
}));
|
|
|
|
const mockLogActivity = vi.hoisted(() => vi.fn());
|
|
|
|
function allowDecision() {
|
|
return {
|
|
allowed: true,
|
|
action: "agents:create",
|
|
reason: "allow_explicit_grant",
|
|
explanation: "Allowed.",
|
|
};
|
|
}
|
|
|
|
function denyDecision() {
|
|
return {
|
|
allowed: false,
|
|
action: "agents:create",
|
|
reason: "deny_missing_grant",
|
|
explanation: "Missing permission: agents:create.",
|
|
};
|
|
}
|
|
|
|
function builtInState(overrides: Record<string, unknown> = {}) {
|
|
return {
|
|
definition: {
|
|
key: "briefs",
|
|
displayName: "Briefs Agent",
|
|
featureKeys: ["briefs"],
|
|
shortPurpose: "Prepares concise operational briefs.",
|
|
defaultInstructions: "Write briefs.",
|
|
defaultRole: "general",
|
|
allowedAdapterTypes: ["codex_local"],
|
|
},
|
|
status: "ready",
|
|
agentId,
|
|
agent: {
|
|
id: agentId,
|
|
companyId,
|
|
name: "Briefs Agent",
|
|
role: "general",
|
|
status: "idle",
|
|
adapterType: "codex_local",
|
|
adapterConfig: { model: "gpt-5.4" },
|
|
},
|
|
pauseReason: null,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
function registerModuleMocks() {
|
|
vi.doMock("../services/index.js", () => ({
|
|
accessService: () => mockAccessService,
|
|
instanceSettingsService: () => mockInstanceSettingsService,
|
|
logActivity: mockLogActivity,
|
|
}));
|
|
vi.doMock("../services/built-in-agents.js", () => ({
|
|
builtInAgentService: () => mockBuiltInAgentService,
|
|
}));
|
|
}
|
|
|
|
async function createApp(actor: Record<string, unknown>) {
|
|
const [{ builtInAgentRoutes }, { errorHandler }] = await Promise.all([
|
|
vi.importActual<typeof import("../routes/built-in-agents.js")>("../routes/built-in-agents.js"),
|
|
vi.importActual<typeof import("../middleware/index.js")>("../middleware/index.js"),
|
|
]);
|
|
const app = express();
|
|
app.use(express.json());
|
|
app.use((req, _res, next) => {
|
|
(req as any).actor = actor;
|
|
next();
|
|
});
|
|
app.use("/api", builtInAgentRoutes({} as any));
|
|
app.use(errorHandler);
|
|
return app;
|
|
}
|
|
|
|
describe("built-in agent routes", () => {
|
|
beforeEach(() => {
|
|
vi.resetModules();
|
|
registerModuleMocks();
|
|
vi.clearAllMocks();
|
|
mockAccessService.decide.mockResolvedValue(allowDecision());
|
|
mockAccessService.canUser.mockResolvedValue(true);
|
|
mockInstanceSettingsService.getExperimental.mockResolvedValue({ enableBuiltInAgents: true });
|
|
mockBuiltInAgentService.list.mockResolvedValue([builtInState()]);
|
|
mockBuiltInAgentService.get.mockResolvedValue(builtInState());
|
|
mockBuiltInAgentService.ensure.mockResolvedValue(builtInState());
|
|
mockBuiltInAgentService.provision.mockResolvedValue({ state: builtInState(), approval: null });
|
|
mockBuiltInAgentService.reset.mockResolvedValue(builtInState());
|
|
mockBuiltInAgentService.enableRoutineSchedule.mockResolvedValue(builtInState());
|
|
mockBuiltInAgentService.disableRoutineSchedule.mockResolvedValue(builtInState());
|
|
mockBuiltInAgentService.runRoutine.mockResolvedValue({ id: "routine-run-1", source: "manual", status: "queued" });
|
|
});
|
|
|
|
it("lists built-in agent state for actors with company access", async () => {
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app).get(`/api/companies/${companyId}/built-in-agents`);
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
expect(mockBuiltInAgentService.list).toHaveBeenCalledWith(companyId);
|
|
expect(res.body).toEqual([expect.objectContaining({ status: "ready", agentId })]);
|
|
expect(res.body[0].agent.adapterConfig).toEqual({});
|
|
});
|
|
|
|
it("denies list requests outside the actor company boundary", async () => {
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: ["33333333-3333-4333-8333-333333333333"],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app).get(`/api/companies/${companyId}/built-in-agents`);
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
|
expect(mockBuiltInAgentService.list).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("returns 404 and does not load built-in state when the experimental flag is disabled", async () => {
|
|
mockInstanceSettingsService.getExperimental.mockResolvedValue({ enableBuiltInAgents: false });
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app).get(`/api/companies/${companyId}/built-in-agents`);
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(404);
|
|
expect(res.body.error).toContain("Built-in agents are not enabled");
|
|
expect(mockBuiltInAgentService.list).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("provisions through the agents:create gate and passes optional adapter overrides", async () => {
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/briefs/provision`)
|
|
.send({ adapterType: "codex_local", adapterConfig: { model: "gpt-5.4" }, budgetMonthlyCents: 5000 });
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
expect(mockAccessService.decide).toHaveBeenCalledWith({
|
|
actor: expect.objectContaining({ type: "board" }),
|
|
action: "agents:create",
|
|
resource: { type: "company", companyId },
|
|
});
|
|
expect(mockBuiltInAgentService.provision).toHaveBeenCalledWith(
|
|
companyId,
|
|
"briefs",
|
|
{
|
|
adapterType: "codex_local",
|
|
adapterConfig: { model: "gpt-5.4" },
|
|
budgetMonthlyCents: 5000,
|
|
},
|
|
{ requestedByAgentId: null, requestedByUserId: "board-user" },
|
|
);
|
|
expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
|
|
companyId,
|
|
actorType: "user",
|
|
actorId: "board-user",
|
|
action: "built_in_agent.provision_requested",
|
|
entityId: agentId,
|
|
}));
|
|
});
|
|
|
|
it.each([0, 5000])("rejects an agent budget override through built-in provision (%s)", async budgetMonthlyCents => {
|
|
const app = await createApp({ type: "agent", agentId: "agent-1", companyId, source: "agent_key" });
|
|
const response = await request(app).post(`/api/companies/${companyId}/built-in-agents/briefs/provision`).send({ budgetMonthlyCents });
|
|
expect(response.status).toBe(403);
|
|
expect(response.body.code).toBe("board_access_required");
|
|
expect(response.body.remediation).toContain("[Open budgets](/<prefix>/activity/budgets)");
|
|
expect(mockBuiltInAgentService.provision).not.toHaveBeenCalled();
|
|
expect(mockLogActivity).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("denies provision when agents:create is not allowed", async () => {
|
|
mockAccessService.decide.mockResolvedValue(denyDecision());
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/briefs/provision`)
|
|
.send({ adapterType: "codex_local" });
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
|
expect(res.body.details).toMatchObject({ reason: "deny_missing_grant" });
|
|
expect(mockBuiltInAgentService.ensure).not.toHaveBeenCalled();
|
|
expect(mockBuiltInAgentService.provision).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("rejects provision bodies with unknown fields", async () => {
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/briefs/provision`)
|
|
.send({ adapterType: "codex_local", unexpected: true });
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(400);
|
|
expect(mockBuiltInAgentService.ensure).not.toHaveBeenCalled();
|
|
expect(mockBuiltInAgentService.provision).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("enables a built-in routine schedule through the board tasks:assign gate", async () => {
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/reflection-coach/routines/recent-agent-reflection/enable`)
|
|
.send({});
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
expect(mockAccessService.canUser).toHaveBeenCalledWith(companyId, "board-user", "tasks:assign");
|
|
expect(mockBuiltInAgentService.enableRoutineSchedule).toHaveBeenCalledWith(
|
|
companyId,
|
|
"reflection-coach",
|
|
"recent-agent-reflection",
|
|
{ agentId: null, userId: "board-user", runId: null },
|
|
);
|
|
expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
|
|
action: "built_in_agent.routine_schedule_enabled",
|
|
entityId: agentId,
|
|
details: expect.objectContaining({ routineKey: "recent-agent-reflection" }),
|
|
}));
|
|
});
|
|
|
|
it("disables a built-in routine schedule", async () => {
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/reflection-coach/routines/recent-agent-reflection/disable`)
|
|
.send({});
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
expect(mockBuiltInAgentService.disableRoutineSchedule).toHaveBeenCalledWith(
|
|
companyId,
|
|
"reflection-coach",
|
|
"recent-agent-reflection",
|
|
{ agentId: null, userId: "board-user", runId: null },
|
|
);
|
|
});
|
|
|
|
it("triggers a built-in routine manual run", async () => {
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/reflection-coach/routines/recent-agent-reflection/run`)
|
|
.send({});
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(202);
|
|
expect(res.body).toMatchObject({ id: "routine-run-1", source: "manual" });
|
|
expect(mockBuiltInAgentService.runRoutine).toHaveBeenCalledWith(
|
|
companyId,
|
|
"reflection-coach",
|
|
"recent-agent-reflection",
|
|
{ agentId: null, userId: "board-user", runId: null },
|
|
);
|
|
expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
|
|
action: "built_in_agent.routine_run_triggered",
|
|
details: expect.objectContaining({ routineRunId: "routine-run-1" }),
|
|
}));
|
|
});
|
|
|
|
it("denies built-in routine controls when tasks:assign is not allowed", async () => {
|
|
mockAccessService.canUser.mockResolvedValue(false);
|
|
const app = await createApp({
|
|
type: "board",
|
|
userId: "board-user",
|
|
companyIds: [companyId],
|
|
source: "session",
|
|
isInstanceAdmin: false,
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/reflection-coach/routines/recent-agent-reflection/run`)
|
|
.send({});
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
|
expect(mockBuiltInAgentService.runRoutine).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("denies agent actors from controlling built-in routines", async () => {
|
|
const app = await createApp({
|
|
type: "agent",
|
|
agentId: "manager-agent",
|
|
companyId,
|
|
source: "agent_key",
|
|
runId: "55555555-5555-4555-8555-555555555555",
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/reflection-coach/routines/recent-agent-reflection/run`)
|
|
.send({});
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
|
expect(res.body.error).toContain("Only board operators can control built-in routines.");
|
|
expect(mockAccessService.canUser).not.toHaveBeenCalled();
|
|
expect(mockBuiltInAgentService.runRoutine).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("returns pending hire approvals instead of provisioning immediately when company policy requires it", async () => {
|
|
const approval = {
|
|
id: "approval-1",
|
|
status: "pending",
|
|
type: "hire_agent",
|
|
};
|
|
mockBuiltInAgentService.provision.mockResolvedValue({
|
|
state: builtInState({
|
|
status: "pending_approval",
|
|
agent: { ...builtInState().agent, status: "pending_approval" },
|
|
}),
|
|
approval,
|
|
});
|
|
const app = await createApp({
|
|
type: "agent",
|
|
agentId: "manager-agent",
|
|
runId: "native-request-run",
|
|
companyId,
|
|
source: "agent_key",
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/briefs/provision`)
|
|
.send({ adapterType: "codex_local", adapterConfig: { model: "gpt-5.4" } });
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(202);
|
|
expect(res.body.status).toBe("pending_approval");
|
|
expect(res.body.approval).toMatchObject({ id: "approval-1", status: "pending", type: "hire_agent" });
|
|
expect(mockBuiltInAgentService.ensure).not.toHaveBeenCalled();
|
|
expect(mockBuiltInAgentService.provision).toHaveBeenCalledWith(
|
|
companyId,
|
|
"briefs",
|
|
{ adapterType: "codex_local", adapterConfig: { model: "gpt-5.4" } },
|
|
{ requestedByAgentId: "manager-agent", requestedByUserId: null },
|
|
);
|
|
expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
|
|
companyId,
|
|
actorType: "agent",
|
|
actorId: "manager-agent",
|
|
action: "approval.created",
|
|
runId: "native-request-run",
|
|
entityId: "approval-1",
|
|
}));
|
|
});
|
|
|
|
it("resets registry defaults through the same agents:create gate", async () => {
|
|
const app = await createApp({
|
|
type: "agent",
|
|
agentId: "manager-agent",
|
|
companyId,
|
|
source: "agent_key",
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/briefs/reset`)
|
|
.send({});
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
expect(mockBuiltInAgentService.reset).toHaveBeenCalledWith(companyId, "briefs", {}, expect.objectContaining({ type: "agent", agentId: "manager-agent" }));
|
|
expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
|
|
companyId,
|
|
actorType: "agent",
|
|
actorId: "manager-agent",
|
|
agentId: "manager-agent",
|
|
action: "built_in_agent.reset",
|
|
entityId: agentId,
|
|
}));
|
|
});
|
|
|
|
it("denies agent actors from provisioning across company boundaries", async () => {
|
|
const app = await createApp({
|
|
type: "agent",
|
|
agentId: "manager-agent",
|
|
companyId: "33333333-3333-4333-8333-333333333333",
|
|
source: "agent_key",
|
|
});
|
|
|
|
const res = await request(app)
|
|
.post(`/api/companies/${companyId}/built-in-agents/briefs/reset`)
|
|
.send({});
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
|
expect(mockAccessService.decide).not.toHaveBeenCalled();
|
|
expect(mockBuiltInAgentService.reset).not.toHaveBeenCalled();
|
|
});
|
|
});
|