From 0213c996d010b38821d1725b9f7f9e0cb2624eea Mon Sep 17 00:00:00 2001 From: Hweinstock Date: Wed, 17 Jun 2026 22:23:23 +0000 Subject: [PATCH] Revert "chore: ungate web-search commands (#1558)" This reverts commit 6bb2ca458b9268b157229d96e5e5f3df674bef05. --- src/cli/primitives/GatewayTargetPrimitive.ts | 31 ++++++++++++++----- src/cli/tui/screens/add/AddScreen.tsx | 2 +- .../screens/add/__tests__/AddScreen.test.tsx | 11 +++++++ .../screens/mcp/AddGatewayTargetScreen.tsx | 2 +- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/cli/primitives/GatewayTargetPrimitive.ts b/src/cli/primitives/GatewayTargetPrimitive.ts index f96d5d0f4..71d363f77 100644 --- a/src/cli/primitives/GatewayTargetPrimitive.ts +++ b/src/cli/primitives/GatewayTargetPrimitive.ts @@ -283,9 +283,12 @@ export class GatewayTargetPrimitive extends BasePrimitive(option: T): T => (isGatedFeaturesEnabled() ? option : option.hideHelp()); + const typeDescription = isGatedFeaturesEnabled() ? 'Target type (required): mcp-server, api-gateway, open-api-schema, smithy-model, lambda-function-arn, http-runtime, connector, passthrough, web-search [non-interactive]' - : 'Target type (required): mcp-server, api-gateway, open-api-schema, smithy-model, lambda-function-arn, http-runtime, connector, web-search [non-interactive]'; + : 'Target type (required): mcp-server, api-gateway, open-api-schema, smithy-model, lambda-function-arn, http-runtime, connector [non-interactive]'; // Reject repeated use of --exclude-domains. Domains must be passed as a // single comma-separated value. @@ -315,10 +318,13 @@ export class GatewayTargetPrimitive extends BasePrimitive [...acc, val], [] as string[] ) - .option( - '--exclude-domains ', - 'Comma-separated domains to exclude from results (for --type web-search only) [non-interactive]', - excludeDomainsCoercer + .addOption( + gate( + new Option( + '--exclude-domains ', + 'Comma-separated domains to exclude from results (for --type web-search only) [non-interactive]' + ).argParser(excludeDomainsCoercer) + ) ) .option('--endpoint ', 'Server endpoint URL (for mcp-server type) [non-interactive]') .option('--language ', 'Language of target code: Python, TypeScript, Other [non-interactive]') @@ -613,6 +619,9 @@ ${ // Handle Amazon Web Search targets (managed-service backed via gateway IAM role) if (cliOptions.type === 'webSearch') { + if (!isGatedFeaturesEnabled()) { + throw new ValidationError('Web search target type is not yet available.'); + } const excludeDomains = typeof cliOptions.excludeDomains === 'string' ? cliOptions.excludeDomains @@ -902,13 +911,17 @@ ${ // Top-level shortcuts: agentcore add web-search / remove web-search // ────────────────────────────────────────────────────────────────── addCmd - .command('web-search') + .command('web-search', { hidden: !isGatedFeaturesEnabled() }) .description('Wire the Amazon Web Search managed connector to a gateway as a target.') .option('--name ', 'Target name (default: web-search) [non-interactive]') .option('--gateway ', 'Gateway to attach this target to [non-interactive]') .option('--exclude-domains ', 'Comma-separated domains to exclude from results [non-interactive]') .option('--json', 'Output as JSON [non-interactive]') .action(async (cliOptions: { name?: string; gateway?: string; excludeDomains?: string; json?: boolean }) => { + if (!isGatedFeaturesEnabled()) { + console.error('Error: Web search target type is not yet available.'); + process.exit(1); + } if (!findConfigRoot()) { console.error('No agentcore project found. Run `agentcore create` first.'); process.exit(1); @@ -996,13 +1009,17 @@ ${ }); removeCmd - .command('web-search') + .command('web-search', { hidden: !isGatedFeaturesEnabled() }) .description('Remove an Amazon Web Search gateway target from the project') .option('--name ', 'Name of the web-search target to remove [non-interactive]') .option('-y, --yes', 'Skip confirmation prompt [non-interactive]') .option('--json', 'Output as JSON [non-interactive]') .action(async (cliOptions: { name?: string; yes?: boolean; json?: boolean }) => { try { + if (!isGatedFeaturesEnabled()) { + console.error('Web search target type is not yet available.'); + process.exit(1); + } if (!findConfigRoot()) { console.error('No agentcore project found. Run `agentcore create` first.'); process.exit(1); diff --git a/src/cli/tui/screens/add/AddScreen.tsx b/src/cli/tui/screens/add/AddScreen.tsx index 45da63ff6..aca3e59a8 100644 --- a/src/cli/tui/screens/add/AddScreen.tsx +++ b/src/cli/tui/screens/add/AddScreen.tsx @@ -52,7 +52,7 @@ const ADD_RESOURCES: { id: AddResourceType; title: string; description: string } ]; const ADD_RESOURCE_ITEMS: SelectableItem[] = ADD_RESOURCES.map(r => { - const gated = r.id === 'knowledge-base' && !isGatedFeaturesEnabled(); + const gated = (r.id === 'knowledge-base' || r.id === 'web-search') && !isGatedFeaturesEnabled(); return { ...r, disabled: gated, diff --git a/src/cli/tui/screens/add/__tests__/AddScreen.test.tsx b/src/cli/tui/screens/add/__tests__/AddScreen.test.tsx index 82ae13de0..7ca2a3cb7 100644 --- a/src/cli/tui/screens/add/__tests__/AddScreen.test.tsx +++ b/src/cli/tui/screens/add/__tests__/AddScreen.test.tsx @@ -32,4 +32,15 @@ describe('AddScreen', () => { expect(lastFrame()).toContain('Payment Manager'); expect(lastFrame()).toContain('Payment Connector'); }); + + it('Web Search option shows Coming soon when ENABLE_GATED_FEATURES is unset', () => { + delete process.env.ENABLE_GATED_FEATURES; + const onSelect = vi.fn(); + const onExit = vi.fn(); + + const { lastFrame } = render(); + + expect(lastFrame()).toContain('Web Search'); + expect(lastFrame()).toContain('Coming soon'); + }); }); diff --git a/src/cli/tui/screens/mcp/AddGatewayTargetScreen.tsx b/src/cli/tui/screens/mcp/AddGatewayTargetScreen.tsx index b3e2aa835..18802a581 100644 --- a/src/cli/tui/screens/mcp/AddGatewayTargetScreen.tsx +++ b/src/cli/tui/screens/mcp/AddGatewayTargetScreen.tsx @@ -155,7 +155,7 @@ export function AddGatewayTargetScreen({ const targetTypeItems: SelectableItem[] = useMemo( () => TARGET_TYPE_OPTIONS.map(o => { - const gated = o.id === 'passthrough' && !isGatedFeaturesEnabled(); + const gated = (o.id === 'passthrough' || o.id === 'webSearch') && !isGatedFeaturesEnabled(); return { id: o.id, title: o.title,