Skip to content

Commit ae73d13

Browse files
committed
fix: give the remote client the full environment
This change will give the remote client the full environment instead of just the extra env vars. Doing this allows the provider tools to detect credentials and other environment variables set by the user or system. Signed-off-by: Donnie Adams <[email protected]>
1 parent 622ce1e commit ae73d13

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

pkg/gptscript/gptscript.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@ func New(opts *Options) (*GPTScript, error) {
110110
closeServer()
111111
return nil, err
112112
}
113-
oaiClient.SetEnvs(extraEnv)
114113

115-
remoteClient := remote.New(runner, extraEnv, cacheClient, cliCfg, opts.CredentialContext)
114+
fullEnv := append(opts.Env, extraEnv...)
115+
oaiClient.SetEnvs(fullEnv)
116+
117+
remoteClient := remote.New(runner, fullEnv, cacheClient, cliCfg, opts.CredentialContext)
116118
if err := registry.AddClient(remoteClient); err != nil {
117119
closeServer()
118120
return nil, err

pkg/prompt/server.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,13 @@ import (
1414
)
1515

1616
func NewServer(ctx context.Context, envs []string) ([]string, error) {
17-
var extraEnvs []string
1817
for _, env := range envs {
19-
for _, prefix := range []string{types.PromptURLEnvVar, types.PromptTokenEnvVar} {
20-
v, ok := strings.CutPrefix(env, prefix+"=")
21-
if ok && v != "" {
22-
extraEnvs = append(extraEnvs, env)
23-
}
18+
v, ok := strings.CutPrefix(env, types.PromptTokenEnvVar+"=")
19+
if ok && v != "" {
20+
return nil, nil
2421
}
2522
}
2623

27-
if len(extraEnvs) == 2 {
28-
return extraEnvs, nil
29-
}
30-
3124
l, err := net.Listen("tcp", "127.0.0.1:0")
3225
if err != nil {
3326
return nil, err

0 commit comments

Comments
 (0)