Skip to content

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.

1.3 KB
Raw Blame
import { describe, expect, test } from "bun:test";
import { shareTargetOf } from "../src/plugins/share-target";

describe("which connector writes send content to other people", () => {
  test("a message, a post, a reply and an email are sends, addressed to their recipients", () => {
    const slack = shareTargetOf("slack", "slack_send_message", {
      channel: "C123",
      text: "The Q3 numbers are in",
    });
    expect(slack).toEqual({
      audience: expect.objectContaining({
        kind: "external",
        id: "C123",
        recipientUserIds: [],
      }),
      content: "The Q3 numbers are in",
    });
    expect(
      shareTargetOf("gmail", "GMAIL_SEND_EMAIL", { to: "[email protected]", body: "hi" })
        ?.audience.id,
    ).toBe("[email protected]");
    expect(
      shareTargetOf("teams", "postMessage", {
        chatId: "19:abc",
        content: "hi",
      }),
    ).not.toBeNull();
    expect(
      shareTargetOf("linear", "create_comment", { issueId: "L-1", body: "hi" }),
    ).not.toBeNull();
  });

  test("a write that stages or changes the owner's own data is not", () => {
    expect(
      shareTargetOf("gmail", "create_draft", { to: "[email protected]", body: "hi" }),
    ).toBeNull();
    expect(shareTargetOf("notion", "update_page", { text: "hi" })).toBeNull();
    expect(shareTargetOf("linear", "create_issue", { title: "hi" })).toBeNull();
  });
});