@@ -12,6 +12,7 @@ import {
1212 PRODUCT_DESIGNER_SYSTEM_PROMPT
1313} from '@renderer/pages/ChatPage/constants/DEFAULT_AGENTS'
1414import { InferenceParameters , LLM , BEDROCK_SUPPORTED_REGIONS } from '@/types/llm'
15+ import type { AwsCredentialIdentity } from "@smithy/types" ;
1516
1617const DEFAULT_INFERENCE_PARAMS : InferenceParameters = {
1718 maxTokens : 4096 ,
@@ -141,6 +142,8 @@ export interface SettingsContextType {
141142 setAwsAccessKeyId : ( accessKeyId : string ) => void
142143 awsSecretAccessKey : string
143144 setAwsSecretAccessKey : ( secretAccessKey : string ) => void
145+ awsSessionToken : string
146+ setAwsSessionToken : ( sessionToken : string ) => void
144147
145148 // Custom Agents Settings
146149 customAgents : CustomAgent [ ]
@@ -215,6 +218,7 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
215218 const [ awsRegion , setStateAwsRegion ] = useState < string > ( '' )
216219 const [ awsAccessKeyId , setStateAwsAccessKeyId ] = useState < string > ( '' )
217220 const [ awsSecretAccessKey , setStateAwsSecretAccessKey ] = useState < string > ( '' )
221+ const [ awsSessionToken , setStateAwsSessionToken ] = useState < string > ( '' )
218222
219223 // Custom Agents Settings
220224 const [ customAgents , setCustomAgents ] = useState < CustomAgent [ ] > ( [ ] )
@@ -290,6 +294,7 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
290294 setStateAwsRegion ( awsConfig . region || '' )
291295 setStateAwsAccessKeyId ( awsConfig . accessKeyId || '' )
292296 setStateAwsSecretAccessKey ( awsConfig . secretAccessKey || '' )
297+ setStateAwsSessionToken ( awsConfig . sessionToken || '' )
293298 }
294299
295300 // Load Custom Agents
@@ -442,7 +447,12 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
442447
443448 const setAwsRegion = ( region : string ) => {
444449 setStateAwsRegion ( region )
445- saveAwsConfig ( region , awsAccessKeyId , awsSecretAccessKey )
450+ const credentials : AwsCredentialIdentity = {
451+ accessKeyId : awsAccessKeyId ,
452+ secretAccessKey : awsSecretAccessKey ,
453+ sessionToken : ! awsSessionToken ? undefined : awsSessionToken
454+ }
455+ saveAwsConfig ( credentials , region )
446456
447457 // availableFailoverRegions をリセット
448458 setBedrockSettings ( {
@@ -457,20 +467,36 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
457467
458468 const setAwsAccessKeyId = ( accessKeyId : string ) => {
459469 setStateAwsAccessKeyId ( accessKeyId )
460- saveAwsConfig ( awsRegion , accessKeyId , awsSecretAccessKey )
470+ const credentials : AwsCredentialIdentity = {
471+ accessKeyId,
472+ secretAccessKey : awsSecretAccessKey ,
473+ sessionToken : ! awsSessionToken ? undefined : awsSessionToken
474+ }
475+ saveAwsConfig ( credentials , awsRegion )
461476 }
462477
463478 const setAwsSecretAccessKey = ( secretAccessKey : string ) => {
464479 setStateAwsSecretAccessKey ( secretAccessKey )
465- saveAwsConfig ( awsRegion , awsAccessKeyId , secretAccessKey )
480+ const credentials : AwsCredentialIdentity = {
481+ accessKeyId : awsAccessKeyId ,
482+ secretAccessKey,
483+ sessionToken : ! awsSessionToken ? undefined : awsSessionToken
484+ }
485+ saveAwsConfig ( credentials , awsRegion )
466486 }
467487
468- const saveAwsConfig = ( region : string , accessKeyId : string , secretAccessKey : string ) => {
469- window . store . set ( 'aws' , {
470- region,
471- accessKeyId,
472- secretAccessKey
473- } )
488+ const setAwsSessionToken = ( sessionToken : string ) => {
489+ setStateAwsSessionToken ( sessionToken )
490+ const credentials : AwsCredentialIdentity = {
491+ accessKeyId : awsAccessKeyId ,
492+ secretAccessKey : awsSecretAccessKey ,
493+ sessionToken : ! sessionToken ? undefined : sessionToken
494+ }
495+ saveAwsConfig ( credentials , awsRegion )
496+ }
497+
498+ const saveAwsConfig = ( credentials : AwsCredentialIdentity , region : string ) => {
499+ window . store . set ( 'aws' , { credentials, region } )
474500 }
475501
476502 const saveCustomAgents = ( agents : CustomAgent [ ] ) => {
@@ -581,11 +607,11 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
581607 const currentAgent = allAgents . find ( ( a ) => a . id === selectedAgentId )
582608 const systemPrompt = currentAgent ?. system
583609 ? replacePlaceholders ( currentAgent ?. system , {
584- projectPath,
585- allowedCommands : allowedCommands ,
586- knowledgeBases : knowledgeBases ,
587- bedrockAgents : bedrockAgents
588- } )
610+ projectPath,
611+ allowedCommands : allowedCommands ,
612+ knowledgeBases : knowledgeBases ,
613+ bedrockAgents : bedrockAgents
614+ } )
589615 : ''
590616
591617 const setTools = ( newTools : ToolState [ ] ) => {
@@ -678,6 +704,8 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
678704 setAwsAccessKeyId,
679705 awsSecretAccessKey,
680706 setAwsSecretAccessKey,
707+ awsSessionToken,
708+ setAwsSessionToken,
681709
682710 // Custom Agents Settings
683711 customAgents,
0 commit comments