Skip to content

Commit d1417fc

Browse files
committed
fix(tui): gate auth screen behind advanced config and fix lint errors
Auth type selection (CUSTOM_JWT vs AWS_IAM) now only appears when the user selects advanced config in the generate wizard and BYO agent paths. Skipping advanced goes directly to confirm with default AWS_IAM auth. Also fixes 4 lint errors: unused import, optional chain preferences, and unsafe argument type cast.
1 parent 82450a3 commit d1417fc

7 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/cli/aws/agentcore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async function invokeWithBearerTokenStreaming(options: InvokeAgentRuntimeOptions
167167
const result = await reader.read();
168168
if (result.done) break;
169169

170-
const decoded = decoder.decode(result.value, { stream: true });
170+
const decoded = decoder.decode(result.value as Uint8Array | undefined, { stream: true });
171171
buffer += decoded;
172172
fullResponse += decoded;
173173

src/cli/operations/agent/import/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { RuntimeAuthorizerType, SDKFramework } from '../../../../schema';
88
import { getBedrockAgentConfig } from '../../../aws/bedrock-import';
99
import { getErrorMessage } from '../../../errors';
1010
import type { JwtConfigOptions } from '../../../primitives/auth-utils';
11-
import { buildAuthorizerConfigFromJwtConfig, createManagedOAuthCredential } from '../../../primitives/auth-utils';
11+
import { createManagedOAuthCredential } from '../../../primitives/auth-utils';
1212
import type { AddResult } from '../../../primitives/types';
1313
import type { MemoryOption } from '../../../tui/screens/generate/types';
1414
import { setupPythonProject } from '../../python';

src/cli/operations/fetch-access/fetch-runtime-token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function canFetchRuntimeToken(
2121
const projectSpec = await configIO.readProjectSpec();
2222

2323
const agentSpec = projectSpec.agents.find(a => a.name === agentName);
24-
if (!agentSpec || agentSpec.authorizerType !== 'CUSTOM_JWT') return false;
24+
if (!agentSpec?.authorizerType || agentSpec.authorizerType !== 'CUSTOM_JWT') return false;
2525
if (!agentSpec.authorizerConfiguration?.customJwtAuthorizer) return false;
2626

2727
const credName = computeManagedOAuthCredentialName(agentName);

src/cli/tui/screens/agent/AddAgentScreen.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const ADVANCED_ITEMS: SelectableItem[] = ADVANCED_OPTIONS.map(o => ({
8787
title: o.title,
8888
description: o.description,
8989
}));
90-
const BYO_STEPS: ByoStep[] = ['codeLocation', 'buildType', 'modelProvider', 'apiKey', 'advanced', 'authorizerType', 'confirm'];
90+
const BYO_STEPS: ByoStep[] = ['codeLocation', 'buildType', 'modelProvider', 'apiKey', 'advanced', 'confirm'];
9191

9292
type ImportStep = 'region' | 'bedrockAgent' | 'bedrockAlias' | 'framework' | 'memory' | 'authorizerType' | 'jwtConfig' | 'confirm';
9393
const BASE_IMPORT_STEPS: ImportStep[] = ['region', 'bedrockAgent', 'bedrockAlias', 'framework', 'memory', 'authorizerType', 'confirm'];
@@ -266,6 +266,7 @@ export function AddAgentScreen({ existingAgentNames, onComplete, onExit }: AddAg
266266
...steps.slice(0, afterAdvanced),
267267
...networkSteps,
268268
'requestHeaderAllowlist',
269+
'authorizerType',
269270
...steps.slice(afterAdvanced),
270271
];
271272
}
@@ -384,7 +385,7 @@ export function AddAgentScreen({ existingAgentNames, onComplete, onExit }: AddAg
384385
} else {
385386
setByoAdvancedSelected(false);
386387
setByoConfig(c => ({ ...c, networkMode: 'PUBLIC' as NetworkMode, subnets: '', securityGroups: '' }));
387-
setByoStep('authorizerType');
388+
setByoStep('confirm');
388389
}
389390
},
390391
onExit: handleByoBack,

src/cli/tui/screens/generate/__tests__/useGenerateWizard.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ describe('useGenerateWizard — advanced config gate', () => {
4343
const frame = lastFrame()!;
4444
expect(frame).toContain('steps:');
4545
// Default modelProvider is Bedrock which filters out apiKey
46-
// authorizerType is always inserted before confirm
47-
expect(frame).toMatch(/modelProvider,advanced,authorizerType,confirm/);
46+
// authorizerType is only shown when advanced is selected
47+
expect(frame).toMatch(/modelProvider,advanced,confirm/);
4848
expect(frame).not.toContain('apiKey');
4949
});
5050

@@ -89,15 +89,15 @@ describe('useGenerateWizard — advanced config gate', () => {
8989
});
9090
}
9191

92-
it('setAdvanced(false) jumps to authorizerType with PUBLIC defaults', () => {
92+
it('setAdvanced(false) jumps to confirm with PUBLIC defaults', () => {
9393
const { ref, lastFrame } = setup();
9494
walkToAdvanced(ref);
9595
expect(lastFrame()).toContain('step:advanced');
9696

9797
act(() => ref.current!.wizard.setAdvanced(false));
9898

9999
const frame = lastFrame()!;
100-
expect(frame).toContain('step:authorizerType');
100+
expect(frame).toContain('step:confirm');
101101
expect(frame).toContain('networkMode:PUBLIC');
102102
expect(frame).toContain('advancedSelected:false');
103103
});
@@ -170,7 +170,7 @@ describe('useGenerateWizard — advanced config gate', () => {
170170
act(() => ref.current!.wizard.setAdvanced(false));
171171

172172
const w = ref.current!.wizard;
173-
expect(w.step).toBe('authorizerType');
173+
expect(w.step).toBe('confirm');
174174
expect(w.config.networkMode).toBe('PUBLIC');
175175
expect(w.advancedSelected).toBe(false);
176176
// Network steps should not be in the step list

src/cli/tui/screens/generate/useGenerateWizard.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ export function useGenerateWizard(options?: UseGenerateWizardOptions) {
6868
'authorizerType',
6969
...filtered.slice(afterAdvanced),
7070
];
71-
} else {
72-
// Even without advanced, add authorizerType before confirm
73-
const confirmIndex = filtered.indexOf('confirm');
74-
filtered = [...filtered.slice(0, confirmIndex), 'authorizerType', ...filtered.slice(confirmIndex)];
7571
}
7672
// Add jwtConfig step after authorizerType when CUSTOM_JWT is selected
7773
if (config.authorizerType === 'CUSTOM_JWT') {
@@ -190,7 +186,7 @@ export function useGenerateWizard(options?: UseGenerateWizardOptions) {
190186
securityGroups: undefined,
191187
requestHeaderAllowlist: undefined,
192188
}));
193-
setStep('authorizerType');
189+
setStep('confirm');
194190
}
195191
}, []);
196192

src/cli/tui/screens/invoke/useInvokeFlow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export function useInvokeFlow(options: InvokeFlowOptions = {}): InvokeFlowState
195195
const fetchBearerToken = useCallback(async () => {
196196
if (!config) return;
197197
const agent = config.agents[selectedAgent];
198-
if (!agent || agent.authorizerType !== 'CUSTOM_JWT') return;
198+
if (agent?.authorizerType !== 'CUSTOM_JWT') return;
199199

200200
// Check if credentials are set up before attempting fetch
201201
const canFetch = await canFetchRuntimeToken(agent.name);

0 commit comments

Comments
 (0)