{"version":3,"file":"authority.d.ts","sourceRoot":"","sources":["../../../src/policy/authority.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,iHAOpB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC9D,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAWxF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC/C,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAC/B,GAAG,iBAAiB,CAEpB;AAED,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,OAAO,EACd,KAAK,SAA2B,GAC9B,qBAAqB,GAAG,SAAS,CAgBnC","sourcesContent":["export const AUTHORITY_ACTIONS = [\n\t\"discardWorktree\",\n\t\"destructiveCleanup\",\n\t\"spawnBudgetGrant\",\n\t\"scheduleCreate\",\n\t\"stopRun\",\n\t\"steerRun\",\n] as const;\n\nexport type AuthorityAction = (typeof AUTHORITY_ACTIONS)[number];\nexport type AuthorityDecision = \"auto\" | \"confirm\" | \"forbid\";\nexport type AuthorityPolicyConfig = Partial<Record<AuthorityAction, AuthorityDecision>>;\n\nconst DEFAULT_AUTHORITY_POLICY: Record<AuthorityAction, AuthorityDecision> = {\n\tdiscardWorktree: \"confirm\",\n\tdestructiveCleanup: \"confirm\",\n\tspawnBudgetGrant: \"confirm\",\n\tscheduleCreate: \"auto\",\n\tstopRun: \"auto\",\n\tsteerRun: \"auto\",\n};\n\nexport function resolveAuthorityDecision(input: {\n\taction: AuthorityAction;\n\tpolicy?: AuthorityPolicyConfig;\n}): AuthorityDecision {\n\treturn input.policy?.[input.action] ?? DEFAULT_AUTHORITY_POLICY[input.action];\n}\n\nexport function validateAuthorityPolicy(\n\tvalue: unknown,\n\tlabel = \"config.authorityPolicy\",\n): AuthorityPolicyConfig | undefined {\n\tif (value === undefined) return undefined;\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(`${label} must be a JSON object`);\n\t}\n\tconst policy = value as Record<string, unknown>;\n\tconst allowedActions = new Set<string>(AUTHORITY_ACTIONS);\n\tfor (const [action, decision] of Object.entries(policy)) {\n\t\tif (!allowedActions.has(action)) {\n\t\t\tthrow new Error(`${label}.${action} is unknown; expected one of ${AUTHORITY_ACTIONS.join(\", \")}`);\n\t\t}\n\t\tif (decision !== \"auto\" && decision !== \"confirm\" && decision !== \"forbid\") {\n\t\t\tthrow new Error(`${label}.${action} must be \"auto\", \"confirm\", or \"forbid\"`);\n\t\t}\n\t}\n\treturn policy as AuthorityPolicyConfig;\n}\n"]}