|
1 | 1 | import { findConfigRoot, setEnvVar } from '../../lib'; |
2 | 2 | import type { AgentCoreGateway, AgentCoreGatewayTarget, AgentCoreMcpSpec, GatewayAuthorizerType } from '../../schema'; |
3 | | -import { AgentCoreGatewaySchema } from '../../schema'; |
| 3 | +import { AgentCoreGatewaySchema, PolicyEngineModeSchema } from '../../schema'; |
4 | 4 | import type { AddGatewayOptions as CLIAddGatewayOptions } from '../commands/add/types'; |
5 | 5 | import { validateAddGatewayOptions } from '../commands/add/validate'; |
6 | 6 | import { getErrorMessage } from '../errors'; |
@@ -28,6 +28,8 @@ export interface AddGatewayOptions { |
28 | 28 | agents?: string; |
29 | 29 | enableSemanticSearch?: boolean; |
30 | 30 | exceptionLevel?: string; |
| 31 | + policyEngine?: string; |
| 32 | + policyEngineMode?: string; |
31 | 33 | } |
32 | 34 |
|
33 | 35 | /** |
@@ -160,6 +162,8 @@ export class GatewayPrimitive extends BasePrimitive<AddGatewayOptions, Removable |
160 | 162 | .option('--agents <agents>', 'Comma-separated agent names') |
161 | 163 | .option('--no-semantic-search', 'Disable semantic search for tool discovery') |
162 | 164 | .option('--exception-level <level>', 'Exception verbosity level', 'NONE') |
| 165 | + .option('--policy-engine <name>', 'Policy engine name for Cedar-based authorization') |
| 166 | + .option('--policy-engine-mode <mode>', 'Policy engine mode: LOG_ONLY or ENFORCE') |
163 | 167 | .option('--json', 'Output as JSON') |
164 | 168 | .action(async (rawOptions: Record<string, string | boolean | undefined>) => { |
165 | 169 | const cliOptions = rawOptions as unknown as CLIAddGatewayOptions; |
@@ -192,6 +196,8 @@ export class GatewayPrimitive extends BasePrimitive<AddGatewayOptions, Removable |
192 | 196 | agents: cliOptions.agents, |
193 | 197 | enableSemanticSearch: cliOptions.semanticSearch !== false, |
194 | 198 | exceptionLevel: cliOptions.exceptionLevel, |
| 199 | + policyEngine: cliOptions.policyEngine, |
| 200 | + policyEngineMode: cliOptions.policyEngineMode, |
195 | 201 | }); |
196 | 202 |
|
197 | 203 | if (cliOptions.json) { |
@@ -290,6 +296,10 @@ export class GatewayPrimitive extends BasePrimitive<AddGatewayOptions, Removable |
290 | 296 | jwtConfig: undefined, |
291 | 297 | enableSemanticSearch: options.enableSemanticSearch ?? true, |
292 | 298 | exceptionLevel: options.exceptionLevel === 'DEBUG' ? 'DEBUG' : 'NONE', |
| 299 | + policyEngineConfiguration: |
| 300 | + options.policyEngine && options.policyEngineMode |
| 301 | + ? { policyEngineName: options.policyEngine, mode: PolicyEngineModeSchema.parse(options.policyEngineMode) } |
| 302 | + : undefined, |
293 | 303 | }; |
294 | 304 |
|
295 | 305 | if (options.authorizerType === 'CUSTOM_JWT' && options.discoveryUrl) { |
@@ -358,6 +368,7 @@ export class GatewayPrimitive extends BasePrimitive<AddGatewayOptions, Removable |
358 | 368 | authorizerConfiguration: this.buildAuthorizerConfiguration(config), |
359 | 369 | enableSemanticSearch: config.enableSemanticSearch, |
360 | 370 | exceptionLevel: config.exceptionLevel, |
| 371 | + policyEngineConfiguration: config.policyEngineConfiguration, |
361 | 372 | }; |
362 | 373 |
|
363 | 374 | mcpSpec.agentCoreGateways.push(gateway); |
|
0 commit comments