mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 23:56:43 +01:00
feat(plugin-sdk): human-attributed issue comments for chat gateway plugins (#10050)
Adds the `issue.comments.create_human_attributed` capability and `ctx.issues.createComment` `actorUserId` option, with host-side active-human-member verification. LOOA-627. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
1b8738da5c
commit
e55d702916
12 files changed
+459
-11
No files matched your search
@@ -160,4 +160,96 @@ describe("plugin SDK test harness", () => {
|
||||
expect(JSON.stringify(comments)).not.toContain("secret plugin-visible body");
|
||||
expect(JSON.stringify(comments)).not.toContain("secret plugin metadata");
|
||||
});
|
||||
|
||||
it("rejects a human-attributed comment when the actorUserId is not an active member", async () => {
|
||||
const manifest: PaperclipPluginManifestV1 = {
|
||||
id: "paperclip.test-human-attributed-comment-unverified",
|
||||
apiVersion: 1,
|
||||
version: "0.1.0",
|
||||
displayName: "Human-Attributed Comment (unverified)",
|
||||
description: "Test plugin",
|
||||
author: "Paperclip",
|
||||
categories: ["automation"],
|
||||
capabilities: ["issue.comments.create", "issue.comments.create_human_attributed"],
|
||||
entrypoints: { worker: "./dist/worker.js" },
|
||||
};
|
||||
const harness = createTestHarness({ manifest });
|
||||
harness.seed({
|
||||
issues: [{
|
||||
id: "issue-1",
|
||||
companyId: "company-1",
|
||||
title: "Human attribution",
|
||||
status: "todo",
|
||||
priority: "medium",
|
||||
}],
|
||||
// A suspended member must not satisfy the active-human-member check —
|
||||
// the harness mirrors the host's `requireActiveHumanMember` guard so a
|
||||
// plugin test cannot pass an attribution production would reject.
|
||||
accessMembers: [{
|
||||
id: "member-suspended",
|
||||
companyId: "company-1",
|
||||
principalType: "user",
|
||||
principalId: "user-1",
|
||||
status: "suspended",
|
||||
membershipRole: "member",
|
||||
grants: [],
|
||||
createdAt: new Date("2026-06-03T11:00:00.000Z"),
|
||||
updatedAt: new Date("2026-06-03T11:00:00.000Z"),
|
||||
}],
|
||||
});
|
||||
|
||||
await expect(
|
||||
harness.ctx.issues.createComment("issue-1", "relayed reply", "company-1", { actorUserId: "user-1" }),
|
||||
).rejects.toThrow('actorUserId "user-1" is not an active human member of this company');
|
||||
});
|
||||
|
||||
it("attributes a comment to an active human member for a verified actorUserId", async () => {
|
||||
const manifest: PaperclipPluginManifestV1 = {
|
||||
id: "paperclip.test-human-attributed-comment-verified",
|
||||
apiVersion: 1,
|
||||
version: "0.1.0",
|
||||
displayName: "Human-Attributed Comment (verified)",
|
||||
description: "Test plugin",
|
||||
author: "Paperclip",
|
||||
categories: ["automation"],
|
||||
capabilities: ["issue.comments.create", "issue.comments.create_human_attributed"],
|
||||
entrypoints: { worker: "./dist/worker.js" },
|
||||
};
|
||||
const harness = createTestHarness({ manifest });
|
||||
harness.seed({
|
||||
issues: [{
|
||||
id: "issue-1",
|
||||
companyId: "company-1",
|
||||
title: "Human attribution",
|
||||
status: "todo",
|
||||
priority: "medium",
|
||||
}],
|
||||
accessMembers: [{
|
||||
id: "member-active",
|
||||
companyId: "company-1",
|
||||
principalType: "user",
|
||||
principalId: "user-1",
|
||||
status: "active",
|
||||
membershipRole: "member",
|
||||
grants: [],
|
||||
createdAt: new Date("2026-06-03T11:00:00.000Z"),
|
||||
updatedAt: new Date("2026-06-03T11:00:00.000Z"),
|
||||
}],
|
||||
});
|
||||
|
||||
const comment = await harness.ctx.issues.createComment(
|
||||
"issue-1",
|
||||
"relayed reply",
|
||||
"company-1",
|
||||
{ actorUserId: "user-1" },
|
||||
);
|
||||
|
||||
expect(comment).toMatchObject({
|
||||
issueId: "issue-1",
|
||||
authorType: "user",
|
||||
authorUserId: "user-1",
|
||||
authorAgentId: null,
|
||||
body: "relayed reply",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user