Skip to content

Commit a267e30

Browse files
Merge remote-tracking branch 'origin/deploy' into deploy
2 parents c4b7508 + b56d882 commit a267e30

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

agentos/src/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export interface OPAGuardrailConfig {
183183
managed_policies: OPAManagedBinding[];
184184
server_url?: string | null;
185185
policy_path?: string | null;
186+
external_hooks?: string[];
186187
mode?: "audit" | "enforce" | "fail_open" | "fail_closed";
187188
timeout_seconds?: number;
188189
}

agentos/src/components/PoliciesPage.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ interface EditorState {
125125
opaManagedPolicyIds: string; // comma-separated for the textarea
126126
opaServerUrl: string;
127127
opaPolicyPath: string;
128+
opaHook: "llm_input" | "llm_output" | "tool_input"; // stage the OPA binding runs at
128129
opaMode: "audit" | "enforce" | "fail_open" | "fail_closed";
129130
opaTimeoutSeconds: number;
130131
}
@@ -161,6 +162,10 @@ function PolicyEditor({
161162
opaManagedPolicyIds: (initial?.opa_guardrail?.managed_policies ?? []).map((m) => m.policy_id).join(", "),
162163
opaServerUrl: initial?.opa_guardrail?.server_url ?? "",
163164
opaPolicyPath: initial?.opa_guardrail?.policy_path ?? "",
165+
opaHook:
166+
(initial?.opa_guardrail?.managed_policies?.[0]?.hooks?.[0] as EditorState["opaHook"]) ??
167+
(initial?.opa_guardrail?.external_hooks?.[0] as EditorState["opaHook"]) ??
168+
"tool_input",
164169
opaMode: initial?.opa_guardrail?.mode ?? "audit",
165170
opaTimeoutSeconds: initial?.opa_guardrail?.timeout_seconds ?? 5.0,
166171
}));
@@ -195,9 +200,10 @@ function PolicyEditor({
195200
source: s.opaSource,
196201
managed_policies: s.opaManagedPolicyIds
197202
.split(",").map((x) => x.trim()).filter(Boolean)
198-
.map((policy_id) => ({ policy_id })),
203+
.map((policy_id) => ({ policy_id, hooks: [s.opaHook] })),
199204
server_url: s.opaServerUrl || null,
200205
policy_path: s.opaPolicyPath || null,
206+
external_hooks: [s.opaHook],
201207
mode: s.opaMode,
202208
timeout_seconds: s.opaTimeoutSeconds,
203209
},
@@ -331,6 +337,17 @@ function PolicyEditor({
331337
</Field>
332338
</>
333339
)}
340+
<Field label="Hook (stage)">
341+
<select
342+
value={s.opaHook}
343+
onChange={(e) => upd("opaHook", e.target.value as EditorState["opaHook"])}
344+
className="bg-ink-700 border border-ink-600 rounded px-2 py-1 text-sm"
345+
>
346+
<option value="tool_input">tool_input (gate tool calls)</option>
347+
<option value="llm_input">llm_input (evaluate on prompt)</option>
348+
<option value="llm_output">llm_output (evaluate on model output)</option>
349+
</select>
350+
</Field>
334351
<Field label="Mode">
335352
<select
336353
value={s.opaMode}

0 commit comments

Comments
 (0)