Files
PaperClipAI/server/src/services/plugin-interaction-context.ts
T
DottaandPaperclip 5bad074baa 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>
2026-11-09 20:34:04 -06:00

18 lines
574 B
TypeScript

import { AsyncLocalStorage } from "node:async_hooks";
export interface PluginInteractionOrigin {
companyId: string;
agentId: string;
runId?: string | null;
}
const origins = new AsyncLocalStorage<Readonly<PluginInteractionOrigin> | undefined>();
export function withPluginInteractionOrigin<T>(origin: PluginInteractionOrigin | undefined, fn: () => T): T {
return origins.run(origin ? Object.freeze({ ...origin }) : undefined, fn);
}
export function currentPluginInteractionOrigin(): Readonly<PluginInteractionOrigin> | undefined {
return origins.getStore();
}