/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { FunctionCall } from '@google/genai'; import { Context } from '../agents/context.js'; import { REQUEST_CONFIRMATION_FUNCTION_CALL_NAME } from '../agents/functions.js'; import { Event } from '../events/event.js'; import { BasePlugin } from '../plugins/base_plugin.js'; import { BaseTool } from '../tools/base_tool.js'; export { REQUEST_CONFIRMATION_FUNCTION_CALL_NAME }; /** * The outcome of a policy check. */ export declare enum PolicyOutcome { DENY = "DENY", CONFIRM = "CONFIRM", ALLOW = "ALLOW" } /** The result returned by a policy engine after evaluating a tool call. */ export interface PolicyCheckResult { /** The policy decision: `ALLOW`, `DENY`, or `CONFIRM`. */ outcome: string; /** Optional human-readable explanation of the decision. */ reason?: string; } /** Context passed to a policy engine when evaluating a tool call. */ export interface ToolCallPolicyContext { /** The tool being invoked. */ tool: BaseTool; /** The arguments supplied to the tool call. */ toolArgs: Record; } /** Interface for policy engines that gate tool call execution. */ export interface BasePolicyEngine { /** * Evaluates whether a tool call should be allowed, denied, or confirmed. * * @param context - The tool and its arguments to evaluate. * @returns A promise resolving to the policy decision. */ evaluate(context: ToolCallPolicyContext): Promise; } /** In-memory policy engine that permits all tool calls. Intended for prototyping. */ export declare class InMemoryPolicyEngine implements BasePolicyEngine { /** * Always returns {@link PolicyOutcome.ALLOW} for every tool call. * * @param _context - The tool and its arguments; ignored. * @returns A promise resolving to an ALLOW result. */ evaluate(_context: ToolCallPolicyContext): Promise; } /** * Security Plugin for running Orcas agents. */ export declare class SecurityPlugin extends BasePlugin { private readonly policyEngine; /** * @param params - Optional configuration. Defaults to {@link InMemoryPolicyEngine} * when no policy engine is provided. */ constructor(params?: { policyEngine?: BasePolicyEngine; }); /** * Intercepts tool calls, evaluating them against the policy engine before * execution and handling confirmation flows for calls that require it. * * @returns A partial or error response object if the call is blocked or * awaiting confirmation, or `undefined` to allow execution to proceed. */ beforeToolCallback({ tool, toolArgs, toolContext, }: { tool: BaseTool; toolArgs: { [key: string]: unknown; }; toolContext: Context; }): Promise<{ [key: string]: unknown; } | undefined>; private getToolCallCheckState; private setToolCallCheckState; private checkToolCallPolicy; } /** * Gets the ask user confirmation function calls from the event. * @param event The event to get the function calls from. * @returns The ask user confirmation function calls. */ export declare function getAskUserConfirmationFunctionCalls(event: Event): FunctionCall[];