Something went wrong. Try again.
A local-first event pipeline for independent agents, built on Jazz.
Something went wrong. Try again.
1.5 kB · 44 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445import type { ModelAdapterIdentity, ModelAdapterReleaseIdentity } from "../adapters/model-adapters.js";import type { ThoughtAgentDeclaration } from "../agents/types.js";import type { PrivacyClass } from "../events/types.js";import type { AgentRun } from "../store/types.js";
export type PrivacyInput = PrivacyClass | "public" | undefined;
const privacyRank: Record<Exclude<PrivacyInput, undefined>, number> = { public: 0, "public-source": 0, private: 1, sensitive: 2,};
export function joinPrivacy(...values: PrivacyInput[]): PrivacyClass { let result: PrivacyClass = "public-source"; for (const value of values) { if (!value) continue; const normalized: PrivacyClass = value === "public" ? "public-source" : value; if (privacyRank[normalized] > privacyRank[result]) result = normalized; } return result;}
export function modelAdapterPrivacy( adapter: ModelAdapterIdentity | ModelAdapterReleaseIdentity | undefined,): PrivacyClass { return adapter ? joinPrivacy(adapter.privacyClass) : "public-source";}
export function declarationPrivacy( declaration: ThoughtAgentDeclaration, ...values: PrivacyInput[]): PrivacyClass { return joinPrivacy( declaration.privacyFloor, ...values, modelAdapterPrivacy(declaration.modelAdapter ?? declaration.modelAdapterRelease), );}
export function runPrivacy(run: AgentRun, ...values: PrivacyInput[]): PrivacyClass { return joinPrivacy(...values, run.privacy, modelAdapterPrivacy(run.modelAdapter));}