Skip to content

Commit ca9069e

Browse files
Add AWS Bedrock sessionToken (#478)
* add aws bedrock sessionToken * update changelog for bedrock sessionToken --------- Co-authored-by: Brendan Kellam <bshizzle1234@gmail.com>
1 parent d9fa221 commit ca9069e

File tree

11 files changed

+292
-0
lines changed

11 files changed

+292
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111
- Updated NextJS to version 15. [#477](https://github.com/sourcebot-dev/sourcebot/pull/477)
12+
- Add `sessionToken` as optional Bedrock configuration parameter. [#478](https://github.com/sourcebot-dev/sourcebot/pull/478)
1213

1314
## [4.6.4] - 2025-08-11
1415

docs/docs/configuration/language-model-providers.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ For a detailed description of all the providers, please refer to the [schema](ht
6767
"accessKeySecret": {
6868
"env": "AWS_SECRET_ACCESS_KEY"
6969
},
70+
"sessionToken": {
71+
"env": "AWS_SESSION_TOKEN"
72+
},
7073
"region": "YOUR_REGION_HERE", // defaults to the AWS_REGION env var if not set
7174
"baseUrl": "OPTIONAL_BASE_URL"
7275
}

docs/snippets/schemas/v3/index.schema.mdx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,37 @@
12841284
}
12851285
]
12861286
},
1287+
"sessionToken": {
1288+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
1289+
"anyOf": [
1290+
{
1291+
"type": "object",
1292+
"properties": {
1293+
"secret": {
1294+
"type": "string",
1295+
"description": "The name of the secret that contains the token."
1296+
}
1297+
},
1298+
"required": [
1299+
"secret"
1300+
],
1301+
"additionalProperties": false
1302+
},
1303+
{
1304+
"type": "object",
1305+
"properties": {
1306+
"env": {
1307+
"type": "string",
1308+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
1309+
}
1310+
},
1311+
"required": [
1312+
"env"
1313+
],
1314+
"additionalProperties": false
1315+
}
1316+
]
1317+
},
12871318
"region": {
12881319
"type": "string",
12891320
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",
@@ -2628,6 +2659,37 @@
26282659
}
26292660
]
26302661
},
2662+
"sessionToken": {
2663+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
2664+
"anyOf": [
2665+
{
2666+
"type": "object",
2667+
"properties": {
2668+
"secret": {
2669+
"type": "string",
2670+
"description": "The name of the secret that contains the token."
2671+
}
2672+
},
2673+
"required": [
2674+
"secret"
2675+
],
2676+
"additionalProperties": false
2677+
},
2678+
{
2679+
"type": "object",
2680+
"properties": {
2681+
"env": {
2682+
"type": "string",
2683+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
2684+
}
2685+
},
2686+
"required": [
2687+
"env"
2688+
],
2689+
"additionalProperties": false
2690+
}
2691+
]
2692+
},
26312693
"region": {
26322694
"type": "string",
26332695
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",

docs/snippets/schemas/v3/languageModel.schema.mdx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,37 @@
8181
}
8282
]
8383
},
84+
"sessionToken": {
85+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
86+
"anyOf": [
87+
{
88+
"type": "object",
89+
"properties": {
90+
"secret": {
91+
"type": "string",
92+
"description": "The name of the secret that contains the token."
93+
}
94+
},
95+
"required": [
96+
"secret"
97+
],
98+
"additionalProperties": false
99+
},
100+
{
101+
"type": "object",
102+
"properties": {
103+
"env": {
104+
"type": "string",
105+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
106+
}
107+
},
108+
"required": [
109+
"env"
110+
],
111+
"additionalProperties": false
112+
}
113+
]
114+
},
84115
"region": {
85116
"type": "string",
86117
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",
@@ -1425,6 +1456,37 @@
14251456
}
14261457
]
14271458
},
1459+
"sessionToken": {
1460+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
1461+
"anyOf": [
1462+
{
1463+
"type": "object",
1464+
"properties": {
1465+
"secret": {
1466+
"type": "string",
1467+
"description": "The name of the secret that contains the token."
1468+
}
1469+
},
1470+
"required": [
1471+
"secret"
1472+
],
1473+
"additionalProperties": false
1474+
},
1475+
{
1476+
"type": "object",
1477+
"properties": {
1478+
"env": {
1479+
"type": "string",
1480+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
1481+
}
1482+
},
1483+
"required": [
1484+
"env"
1485+
],
1486+
"additionalProperties": false
1487+
}
1488+
]
1489+
},
14281490
"region": {
14291491
"type": "string",
14301492
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",

packages/schemas/src/v3/index.schema.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,37 @@ const schema = {
12831283
}
12841284
]
12851285
},
1286+
"sessionToken": {
1287+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
1288+
"anyOf": [
1289+
{
1290+
"type": "object",
1291+
"properties": {
1292+
"secret": {
1293+
"type": "string",
1294+
"description": "The name of the secret that contains the token."
1295+
}
1296+
},
1297+
"required": [
1298+
"secret"
1299+
],
1300+
"additionalProperties": false
1301+
},
1302+
{
1303+
"type": "object",
1304+
"properties": {
1305+
"env": {
1306+
"type": "string",
1307+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
1308+
}
1309+
},
1310+
"required": [
1311+
"env"
1312+
],
1313+
"additionalProperties": false
1314+
}
1315+
]
1316+
},
12861317
"region": {
12871318
"type": "string",
12881319
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",
@@ -2627,6 +2658,37 @@ const schema = {
26272658
}
26282659
]
26292660
},
2661+
"sessionToken": {
2662+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
2663+
"anyOf": [
2664+
{
2665+
"type": "object",
2666+
"properties": {
2667+
"secret": {
2668+
"type": "string",
2669+
"description": "The name of the secret that contains the token."
2670+
}
2671+
},
2672+
"required": [
2673+
"secret"
2674+
],
2675+
"additionalProperties": false
2676+
},
2677+
{
2678+
"type": "object",
2679+
"properties": {
2680+
"env": {
2681+
"type": "string",
2682+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
2683+
}
2684+
},
2685+
"required": [
2686+
"env"
2687+
],
2688+
"additionalProperties": false
2689+
}
2690+
]
2691+
},
26302692
"region": {
26312693
"type": "string",
26322694
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",

packages/schemas/src/v3/index.type.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,22 @@ export interface AmazonBedrockLanguageModel {
488488
*/
489489
env: string;
490490
};
491+
/**
492+
* Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.
493+
*/
494+
sessionToken?:
495+
| {
496+
/**
497+
* The name of the secret that contains the token.
498+
*/
499+
secret: string;
500+
}
501+
| {
502+
/**
503+
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
504+
*/
505+
env: string;
506+
};
491507
/**
492508
* The AWS region. Defaults to the `AWS_REGION` environment variable.
493509
*/

packages/schemas/src/v3/languageModel.schema.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,37 @@ const schema = {
8080
}
8181
]
8282
},
83+
"sessionToken": {
84+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
85+
"anyOf": [
86+
{
87+
"type": "object",
88+
"properties": {
89+
"secret": {
90+
"type": "string",
91+
"description": "The name of the secret that contains the token."
92+
}
93+
},
94+
"required": [
95+
"secret"
96+
],
97+
"additionalProperties": false
98+
},
99+
{
100+
"type": "object",
101+
"properties": {
102+
"env": {
103+
"type": "string",
104+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
105+
}
106+
},
107+
"required": [
108+
"env"
109+
],
110+
"additionalProperties": false
111+
}
112+
]
113+
},
83114
"region": {
84115
"type": "string",
85116
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",
@@ -1424,6 +1455,37 @@ const schema = {
14241455
}
14251456
]
14261457
},
1458+
"sessionToken": {
1459+
"description": "Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.",
1460+
"anyOf": [
1461+
{
1462+
"type": "object",
1463+
"properties": {
1464+
"secret": {
1465+
"type": "string",
1466+
"description": "The name of the secret that contains the token."
1467+
}
1468+
},
1469+
"required": [
1470+
"secret"
1471+
],
1472+
"additionalProperties": false
1473+
},
1474+
{
1475+
"type": "object",
1476+
"properties": {
1477+
"env": {
1478+
"type": "string",
1479+
"description": "The name of the environment variable that contains the token. Only supported in declarative connection configs."
1480+
}
1481+
},
1482+
"required": [
1483+
"env"
1484+
],
1485+
"additionalProperties": false
1486+
}
1487+
]
1488+
},
14271489
"region": {
14281490
"type": "string",
14291491
"description": "The AWS region. Defaults to the `AWS_REGION` environment variable.",

packages/schemas/src/v3/languageModel.type.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ export interface AmazonBedrockLanguageModel {
5959
*/
6060
env: string;
6161
};
62+
/**
63+
* Optional session token to use with the model. Defaults to the `AWS_SESSION_TOKEN` environment variable.
64+
*/
65+
sessionToken?:
66+
| {
67+
/**
68+
* The name of the secret that contains the token.
69+
*/
70+
secret: string;
71+
}
72+
| {
73+
/**
74+
* The name of the environment variable that contains the token. Only supported in declarative connection configs.
75+
*/
76+
env: string;
77+
};
6278
/**
6379
* The AWS region. Defaults to the `AWS_REGION` environment variable.
6480
*/

packages/web/src/env.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export const env = createEnv({
121121

122122
AWS_ACCESS_KEY_ID: z.string().optional(),
123123
AWS_SECRET_ACCESS_KEY: z.string().optional(),
124+
AWS_SESSION_TOKEN: z.string().optional(),
124125
AWS_REGION: z.string().optional(),
125126

126127
SOURCEBOT_CHAT_MODEL_TEMPERATURE: numberSchema.default(0.3),

packages/web/src/features/chat/actions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ export const _getAISDKLanguageModelAndOptions = async (config: LanguageModel, or
389389
secretAccessKey: config.accessKeySecret
390390
? await getTokenFromConfig(config.accessKeySecret, orgId, prisma)
391391
: env.AWS_SECRET_ACCESS_KEY,
392+
sessionToken: config.sessionToken
393+
? await getTokenFromConfig(config.sessionToken, orgId, prisma)
394+
: env.AWS_SESSION_TOKEN,
392395
headers: config.headers
393396
? await extractLanguageModelHeaders(config.headers, orgId, prisma)
394397
: undefined,

0 commit comments

Comments
 (0)