@@ -48,6 +48,59 @@ export interface SessionDetail {
4848 entries : TranscriptEntry [ ] ;
4949}
5050
51+ // Policies — SRS-managed. The browser only sees the bits that matter for
52+ // the runtime (name, description, cedar/opa subsections). Everything else
53+ // is forwarded by the server-side proxy; we don't reshape it.
54+ export interface CedarPolicyEntry {
55+ id : string ;
56+ name ?: string ;
57+ description ?: string ;
58+ policy_text : string ;
59+ enabled ?: boolean ;
60+ }
61+ export interface CedarGuardrailConfig {
62+ enabled : boolean ;
63+ policies : CedarPolicyEntry [ ] ;
64+ fail_open ?: boolean ;
65+ }
66+ export interface OPAManagedBinding {
67+ policy_id : string ;
68+ hooks ?: string [ ] ;
69+ }
70+ export interface OPAGuardrailConfig {
71+ enabled : boolean ;
72+ source : "managed" | "external" ;
73+ managed_policies : OPAManagedBinding [ ] ;
74+ server_url ?: string | null ;
75+ policy_path ?: string | null ;
76+ mode ?: "audit" | "enforce" | "fail_open" | "fail_closed" ;
77+ timeout_seconds ?: number ;
78+ }
79+ export interface PolicyDoc {
80+ _id : string ;
81+ name : string ;
82+ description : string ;
83+ cedar_guardrail ?: CedarGuardrailConfig | null ;
84+ opa_guardrail ?: OPAGuardrailConfig | null ;
85+ created_at ?: string ;
86+ updated_at ?: string ;
87+ [ k : string ] : unknown ;
88+ }
89+ export interface AgentPolicyBinding {
90+ _id : string ; // agent name
91+ policyId : string ;
92+ updatedAt : string ;
93+ }
94+
95+ export interface OPAPolicyDoc {
96+ _id : string ;
97+ name : string ;
98+ description ?: string ;
99+ rego_content : string ;
100+ created_at ?: string ;
101+ updated_at ?: string ;
102+ }
103+
51104export interface Schedule {
52105 _id : string ;
53106 agentName : string ;
@@ -122,4 +175,26 @@ export const api = {
122175 reqJSON < { schedule : Schedule } > ( "PATCH" , `/schedules/${ encodeURIComponent ( id ) } ` , fields ) . then ( ( d ) => d . schedule ) ,
123176 deleteSchedule : ( id : string ) => reqJSON < { ok : boolean } > ( "DELETE" , `/schedules/${ encodeURIComponent ( id ) } ` ) ,
124177 runScheduleNow : ( id : string ) => postJSON < { ok : boolean } > ( `/schedules/${ encodeURIComponent ( id ) } /run-now` , { } ) ,
178+ // Policies — SRS-proxied. Server injects x-api-key.
179+ policies : ( ) => getJSON < { policies : PolicyDoc [ ] } > ( "/policies" ) . then ( ( d ) => d . policies ) ,
180+ policy : ( id : string ) => getJSON < PolicyDoc > ( `/policies/${ encodeURIComponent ( id ) } ` ) ,
181+ createPolicy : ( body : Partial < PolicyDoc > ) => postJSON < PolicyDoc > ( "/policies" , body ) ,
182+ updatePolicy : ( id : string , body : Partial < PolicyDoc > ) =>
183+ reqJSON < { success ?: boolean } | PolicyDoc > ( "PUT" , `/policies/${ encodeURIComponent ( id ) } ` , body ) ,
184+ deletePolicy : ( id : string ) =>
185+ reqJSON < { success ?: boolean } > ( "DELETE" , `/policies/${ encodeURIComponent ( id ) } ` ) ,
186+ // Per-agent policy binding (Mongo, ours).
187+ getAgentPolicy : ( agent : string ) =>
188+ getJSON < { binding : AgentPolicyBinding | null } > ( `/agents/${ encodeURIComponent ( agent ) } /policy` ) . then ( ( d ) => d . binding ) ,
189+ setAgentPolicy : ( agent : string , policyId : string | null ) =>
190+ reqJSON < { binding : AgentPolicyBinding | null } > ( "PUT" , `/agents/${ encodeURIComponent ( agent ) } /policy` , { policy_id : policyId } ) . then ( ( d ) => d . binding ) ,
191+ // OPA rego policies (managed by SRS, referenced from RAI policies' opa_guardrail).
192+ opaPolicies : ( ) => getJSON < { policies : OPAPolicyDoc [ ] } | OPAPolicyDoc [ ] > ( "/opa-policies" ) . then ( ( d ) => ( Array . isArray ( d ) ? d : d . policies ) ) ,
193+ opaPolicy : ( id : string ) => getJSON < OPAPolicyDoc > ( `/opa-policies/${ encodeURIComponent ( id ) } ` ) ,
194+ createOpaPolicy : ( body : { name : string ; description ?: string ; rego_content : string } ) =>
195+ postJSON < OPAPolicyDoc > ( "/opa-policies" , body ) ,
196+ updateOpaPolicy : ( id : string , body : Partial < OPAPolicyDoc > ) =>
197+ reqJSON < OPAPolicyDoc | { success ?: boolean } > ( "PUT" , `/opa-policies/${ encodeURIComponent ( id ) } ` , body ) ,
198+ deleteOpaPolicy : ( id : string ) =>
199+ reqJSON < { success ?: boolean } > ( "DELETE" , `/opa-policies/${ encodeURIComponent ( id ) } ` ) ,
125200} ;
0 commit comments