Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
484a7654
authored
May 27, 2026
by
Archer
Committed by
GitHub
May 27, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: require OpenSandbox credentials (#6994)
parent
db8edc43
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
packages/service/core/ai/sandbox/provider/config.ts
+5
-1
packages/service/env.ts
+4
-2
packages/service/test/core/ai/sandbox/provider/config.test.ts
+17
-3
No files found.
packages/service/core/ai/sandbox/provider/config.ts
View file @
484a7654
...
@@ -66,6 +66,10 @@ export function validateSandboxConfig(config: SandboxProviderConfig): void {
...
@@ -66,6 +66,10 @@ export function validateSandboxConfig(config: SandboxProviderConfig): void {
throw
new
Error
(
`Invalid runtime:
${
config
.
runtime
}
`
);
throw
new
Error
(
`Invalid runtime:
${
config
.
runtime
}
`
);
}
}
if
(
config
.
provider
===
'opensandbox'
&&
!
config
.
apiKey
)
{
throw
new
Error
(
'Sandbox provider apiKey is required for opensandbox'
);
}
if
(
config
.
provider
===
'sealosdevbox'
&&
!
config
.
token
)
{
if
(
config
.
provider
===
'sealosdevbox'
&&
!
config
.
token
)
{
throw
new
Error
(
'Sandbox provider token is required for sealosdevbox'
);
throw
new
Error
(
'Sandbox provider token is required for sealosdevbox'
);
}
}
...
@@ -100,7 +104,7 @@ export function getSandboxAdapterConfig({
...
@@ -100,7 +104,7 @@ export function getSandboxAdapterConfig({
case
'opensandbox'
:
{
case
'opensandbox'
:
{
const
providerConfig
:
OpenSandboxProviderConfig
=
{
const
providerConfig
:
OpenSandboxProviderConfig
=
{
provider
,
provider
,
baseUrl
:
serviceEnv
.
AGENT_SANDBOX_OPENSANDBOX_BASEURL
,
baseUrl
:
serviceEnv
.
AGENT_SANDBOX_OPENSANDBOX_BASEURL
??
''
,
apiKey
:
serviceEnv
.
AGENT_SANDBOX_OPENSANDBOX_API_KEY
??
''
,
apiKey
:
serviceEnv
.
AGENT_SANDBOX_OPENSANDBOX_API_KEY
??
''
,
runtime
:
serviceEnv
.
AGENT_SANDBOX_OPENSANDBOX_RUNTIME
,
runtime
:
serviceEnv
.
AGENT_SANDBOX_OPENSANDBOX_RUNTIME
,
useServerProxy
:
serviceEnv
.
AGENT_SANDBOX_OPENSANDBOX_USE_SERVER_PROXY
useServerProxy
:
serviceEnv
.
AGENT_SANDBOX_OPENSANDBOX_USE_SERVER_PROXY
...
...
packages/service/env.ts
View file @
484a7654
...
@@ -21,7 +21,9 @@ export const hasAgentSandboxConfig = () => {
...
@@ -21,7 +21,9 @@ export const hasAgentSandboxConfig = () => {
}
}
if
(
provider
===
'opensandbox'
)
{
if
(
provider
===
'opensandbox'
)
{
return
!!
process
.
env
.
AGENT_SANDBOX_OPENSANDBOX_BASEURL
;
return
!!
(
process
.
env
.
AGENT_SANDBOX_OPENSANDBOX_BASEURL
&&
process
.
env
.
AGENT_SANDBOX_OPENSANDBOX_API_KEY
);
}
}
return
false
;
return
false
;
...
@@ -81,7 +83,7 @@ export const serviceEnv = createEnv({
...
@@ -81,7 +83,7 @@ export const serviceEnv = createEnv({
AGENT_SANDBOX_SEALOS_TOKEN
:
z
.
string
().
optional
(),
AGENT_SANDBOX_SEALOS_TOKEN
:
z
.
string
().
optional
(),
AGENT_SANDBOX_SEALOS_WORK_DIRECTORY
:
z
.
string
().
default
(
'/home/devbox/workspace'
),
AGENT_SANDBOX_SEALOS_WORK_DIRECTORY
:
z
.
string
().
default
(
'/home/devbox/workspace'
),
// OpenSandbox配置
// OpenSandbox配置
AGENT_SANDBOX_OPENSANDBOX_BASEURL
:
UrlSchema
.
default
(
'http://127.0.0.1:8080'
),
AGENT_SANDBOX_OPENSANDBOX_BASEURL
:
UrlSchema
.
optional
(
),
AGENT_SANDBOX_OPENSANDBOX_API_KEY
:
z
.
string
().
optional
(),
AGENT_SANDBOX_OPENSANDBOX_API_KEY
:
z
.
string
().
optional
(),
AGENT_SANDBOX_OPENSANDBOX_RUNTIME
:
z
.
enum
([
'docker'
,
'kubernetes'
]).
default
(
'docker'
),
AGENT_SANDBOX_OPENSANDBOX_RUNTIME
:
z
.
enum
([
'docker'
,
'kubernetes'
]).
default
(
'docker'
),
AGENT_SANDBOX_OPENSANDBOX_IMAGE_REPO
:
z
.
string
().
default
(
'fastgpt-agent-sandbox'
),
AGENT_SANDBOX_OPENSANDBOX_IMAGE_REPO
:
z
.
string
().
default
(
'fastgpt-agent-sandbox'
),
...
...
packages/service/test/core/ai/sandbox/provider/config.test.ts
View file @
484a7654
...
@@ -154,6 +154,9 @@ describe('sandbox provider config', () => {
...
@@ -154,6 +154,9 @@ describe('sandbox provider config', () => {
expect
(()
=>
getSandboxAdapterConfig
({
provider
:
'sealosdevbox'
})).
toThrow
(
expect
(()
=>
getSandboxAdapterConfig
({
provider
:
'sealosdevbox'
})).
toThrow
(
'Sandbox provider base URL is required'
'Sandbox provider base URL is required'
);
);
expect
(()
=>
getSandboxAdapterConfig
({
provider
:
'opensandbox'
})).
toThrow
(
'Sandbox provider base URL is required'
);
expect
(()
=>
getSandboxAdapterConfig
({
provider
:
'e2b'
})).
toThrow
(
expect
(()
=>
getSandboxAdapterConfig
({
provider
:
'e2b'
})).
toThrow
(
'Sandbox provider apiKey is required for e2b'
'Sandbox provider apiKey is required for e2b'
);
);
...
@@ -268,13 +271,14 @@ describe('sandbox provider config', () => {
...
@@ -268,13 +271,14 @@ describe('sandbox provider config', () => {
).
toThrow
(
'Sandbox provider apiKey is required for e2b'
);
).
toThrow
(
'Sandbox provider apiKey is required for e2b'
);
});
});
it
(
'validates base url and opensandbox runtime requirements'
,
async
()
=>
{
it
(
'validates base url
, api key
and opensandbox runtime requirements'
,
async
()
=>
{
const
{
validateSandboxConfig
}
=
await
loadSandboxConfigModule
();
const
{
validateSandboxConfig
}
=
await
loadSandboxConfigModule
();
expect
(()
=>
expect
(()
=>
validateSandboxConfig
({
validateSandboxConfig
({
provider
:
'opensandbox'
,
provider
:
'opensandbox'
,
baseUrl
:
''
,
baseUrl
:
''
,
apiKey
:
'opensandbox-key'
,
runtime
:
'docker'
runtime
:
'docker'
})
})
).
toThrow
(
'Sandbox provider base URL is required'
);
).
toThrow
(
'Sandbox provider base URL is required'
);
...
@@ -283,12 +287,22 @@ describe('sandbox provider config', () => {
...
@@ -283,12 +287,22 @@ describe('sandbox provider config', () => {
validateSandboxConfig
({
validateSandboxConfig
({
provider
:
'opensandbox'
,
provider
:
'opensandbox'
,
baseUrl
:
'http://opensandbox.local'
,
baseUrl
:
'http://opensandbox.local'
,
apiKey
:
''
,
runtime
:
'docker'
})
).
toThrow
(
'Sandbox provider apiKey is required for opensandbox'
);
expect
(()
=>
validateSandboxConfig
({
provider
:
'opensandbox'
,
baseUrl
:
'http://opensandbox.local'
,
apiKey
:
'opensandbox-key'
,
runtime
:
'invalid'
as
'docker'
runtime
:
'invalid'
as
'docker'
})
})
).
toThrow
(
'Invalid runtime: invalid'
);
).
toThrow
(
'Invalid runtime: invalid'
);
});
});
it
(
'
does not require
opensandbox api key for docker runtime'
,
async
()
=>
{
it
(
'
requires
opensandbox api key for docker runtime'
,
async
()
=>
{
const
{
validateSandboxConfig
}
=
await
loadSandboxConfigModule
();
const
{
validateSandboxConfig
}
=
await
loadSandboxConfigModule
();
expect
(()
=>
expect
(()
=>
...
@@ -298,7 +312,7 @@ describe('sandbox provider config', () => {
...
@@ -298,7 +312,7 @@ describe('sandbox provider config', () => {
apiKey
:
''
,
apiKey
:
''
,
runtime
:
'docker'
runtime
:
'docker'
})
})
).
not
.
toThrow
(
);
).
toThrow
(
'Sandbox provider apiKey is required for opensandbox'
);
});
});
it
(
'throws for unsupported provider in config switch'
,
async
()
=>
{
it
(
'throws for unsupported provider in config switch'
,
async
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment