Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
fix(approvals): treat refunds as money-moving in the safety policy (#904)
Saim Shafiquec0fa0f78ba7b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2f9d3f16..54c57cad 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -78,6 +78,12 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.`COMPUTER_MEMORY_HIGH_PERCENT=0` and `COMPUTER_TAB_IDLE_MS=0` (Helm: `computers.memoryHighPercent`and `computers.tabIdleMs`) keep the old behaviour.+### Refunds now go to the person++The built-in safety rules hand paying, purchasing or moving money to you, but a refund action+(such as `SHOPIFY_CREATE_REFUND`) passed straight through: "refund" was not one of the words the+rule looked for. It is now, so issuing a refund is handed to you like any other movement of money.+### A computer closes browsers nobody is using when its memory runs highA computer runs one browser for each Bot that is browsing, and the only limits were a count and halfdiff --git a/server/src/approvals/policy.ts b/server/src/approvals/policy.tsindex f3cdf0cb..3de1eb48 100644--- a/server/src/approvals/policy.ts+++ b/server/src/approvals/policy.ts@@ -105,7 +105,7 @@ const SAFETY_REQUIREMENTS: readonly {pattern:// A wire of money, not a news wire: "Business Wire" is where press releases go out, so a Bot// filling in where its research came from would otherwise hand that typing to the person.- /payment|\bpay(ing)?\b|pay[-_ ]?now|checkout|purchase|place[-_ ]?order|buy[-_ ]?now|(?<!\b(business|news|press)[-_ ]?)\bwire\b|bank[-_ ]?transfer|transfer[-_ ]?(money|funds)|send[-_ ]?money|credit[-_ ]?card|card[-_ ]?number|\bcvv\b|\biban\b|routing[-_ ]?number|billing/i,+ /payment|refund|\bpay(ing)?\b|pay[-_ ]?now|checkout|purchase|place[-_ ]?order|buy[-_ ]?now|(?<!\b(business|news|press)[-_ ]?)\bwire\b|bank[-_ ]?transfer|transfer[-_ ]?(money|funds)|send[-_ ]?money|credit[-_ ]?card|card[-_ ]?number|\bcvv\b|\biban\b|routing[-_ ]?number|billing/i,},];diff --git a/server/tests/approvals-policy.test.ts b/server/tests/approvals-policy.test.tsindex 2c9c7c41..c3ccb59f 100644--- a/server/tests/approvals-policy.test.ts+++ b/server/tests/approvals-policy.test.ts@@ -288,6 +288,34 @@ describe("built-in safety requirements", () => {expect(clicking("Send a wire")).toBe("payments");expect(clicking("Start a wire transfer")).toBe("payments");});++ test("refunds move money; writing an order note does not", () => {+ const shopify = (toolName: string, args: Record<string, unknown>) =>+ safetyRequirement(+ candidate({+ toolRef: `composio-shopify/${toolName}`,+ scope: "composio-shopify",+ args,+ target: {+ serverId: "composio-shopify",+ toolName,+ url: "https://mcp.composio.dev/shopify",+ effect: "write",+ },+ }),+ )?.id;+ // A refund moves money, whatever surrounds it in the action name.+ expect(+ shopify("SHOPIFY_CREATE_REFUND", {+ id: 123,+ refund_line_items: [{ line_item_id: 1 }],+ }),+ ).toBe("payments");+ // Writing only a note on an order moves no money.+ expect(+ shopify("SHOPIFY_UPDATE_ORDER", { id: 123, note: "gift wrap" }),+ ).toBeUndefined();+ });});describe("the reviewer's safety classification", () => {