feat: add individual agent interaction permissions (#20411)

Add eleven sparse incoming and outgoing restrictions, human CLI/API administration, shared mutation enforcement, and pending-delivery checks. Preserve existing defaults, agent settings, and existing authorization boundaries.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-11-09 20:34:04 -06:00
1 parent 4158799d1b
commit 5bad074baa
97 files changed
+3590 -433

No files matched your search

@@ -1,4 +1,5 @@
import { and, asc, desc, eq, inArray, isNull, sql } from "drizzle-orm";
import { assertAgentInteraction } from "./agent-interaction-policy.js";
import type { Db } from "@paperclipai/db";
import {
documentAnnotationAnchorSnapshots,
@@ -423,6 +424,8 @@ export function documentAnnotationService(db: Db) {
`);
const doc = await getIssueDocument(issueId, key, tx);
if (!doc) throw notFound("Document not found");
await assertAgentInteraction(tx, { companyId: doc.companyId, actorAgentId: actor.agentId,
operation: "comment", issueId, texts: [input.body], lock: true });
if (
input.baseRevisionId !== doc.latestRevisionId
|| input.baseRevisionNumber !== doc.latestRevisionNumber
@@ -682,6 +685,8 @@ export function documentAnnotationService(db: Db) {
) => db.transaction(async (tx) => {
const thread = await getThreadForIssue(issueId, key, threadId, tx);
if (!thread) throw notFound("Annotation thread not found");
await assertAgentInteraction(tx, { companyId: thread.companyId, actorAgentId: actor.agentId,
operation: "comment", issueId, texts: [input.body], lock: true });
const now = new Date();
const linkedIssueComment = await assertLinkedIssueComment(issueId, input.issueCommentId, tx);
const [comment] = await tx
@@ -857,6 +862,8 @@ export function documentAnnotationService(db: Db) {
) => db.transaction(async (tx) => {
const thread = await getThreadForIssue(issueId, key, threadId, tx);
if (!thread) throw notFound("Annotation thread not found");
await assertAgentInteraction(tx, { companyId: thread.companyId, actorAgentId: actor.agentId,
operation: "edit", issueId, lock: true });
if (!input.status || input.status === thread.status) return thread;
const now = new Date();