SPB Git
2.7 KB · 24 lines typescript
1/** Controlled agent framework — shared types. Agents never write directly (except a single draft page); everything else is a proposal awaiting human approval. */2export type Scope = "read:pages" | "read:search" | "write:pages" | "write:tasks" | "write:links" | "write:properties";3export const ALL_SCOPES: Scope[] = ["read:pages", "read:search", "write:pages", "write:tasks", "write:links", "write:properties"];4export const READ_SCOPES: Scope[] = ["read:pages", "read:search"];5export const SCOPE_LABELS: Record<Scope, string> = {6  "read:pages": "Read pages", "read:search": "Search the workspace",7  "write:pages": "Create draft pages (under “AI drafts”)", "write:tasks": "Tasks (proposals)", "write:links": "Links (proposals)", "write:properties": "Page properties (proposals)",8};910export type AgentId = "research_assistant" | "document_organizer" | "graph_curator" | "writing_assistant" | "database_analyst" | "planning_assistant";11export interface AgentDef { id: AgentId; name: string; description: string; icon: string; system: string; tools: string[]; defaultScopes: Scope[]; allowedScopes: Scope[] }1213export type ProposalKind = "page_edit" | "task" | "link" | "property";14export interface ProposalBase { idx: number; tool: string; kind: ProposalKind; scope: Scope; scopeGranted: boolean; rationale: string; status: "proposed" | "approved" | "rejected" | "applied" | "failed"; at: string; decidedAt?: string; appliedAt?: string; error?: string; result?: unknown }15export interface PageEditProposal extends ProposalBase { kind: "page_edit"; payload: { pageId: string; pageTitle: string; mode: "append" | "replace"; markdown: string; currentMarkdown: string } }16export interface TaskProposal extends ProposalBase { kind: "task"; payload: { title: string; priority: "low" | "medium" | "high"; dueAt: string | null; pageId: string | null; pageTitle: string | null; project: string | null } }17export interface LinkProposal extends ProposalBase { kind: "link"; payload: { fromPageId: string; fromTitle: string; toPageId: string; toTitle: string; relation: string; confidence: number | null } }18export interface PropertyProposal extends ProposalBase { kind: "property"; payload: { pageId: string; pageTitle: string; key: string; value: unknown; previous: unknown } }19export type Proposal = PageEditProposal | TaskProposal | LinkProposal | PropertyProposal;2021export interface ToolStep { tool: string; input: unknown; output?: unknown; at: string; ms?: number; error?: string; proposalIdx?: number }22export interface RunLimits { maxToolCalls: number; maxTokens: number; maxCostUsd: number; maxTurns: number }23export const DEFAULT_LIMITS: RunLimits = { maxToolCalls: 12, maxTokens: 200_000, maxCostUsd: 1.5, maxTurns: 14 };24
Files · 2c37cb5a3e2af18e5ba361996d453cab97da82c2
Menu

Theme