Skip to content

Commit 3b3d682

Browse files
authored
Merge pull request #11 from PinataCloud/feat/local-vars
feat: support local var
2 parents 4b44bc3 + 221c9b9 commit 3b3d682

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

internal/agents/chat/stream.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"sync"
1010
"time"
1111

12+
"pinata/internal/config"
13+
1214
"github.com/google/uuid"
1315
"github.com/gorilla/websocket"
1416
)
@@ -125,8 +127,10 @@ type ChatEventPayload struct {
125127
}
126128

127129
// BuildGatewayURL constructs the WebSocket URL for an agent's gateway.
130+
// The host suffix is derived from PINATA_AGENTS_HOST so dev envs reach
131+
// <agentID>.agents.devpinata.cloud instead of prod.
128132
func BuildGatewayURL(agentID string) string {
129-
return fmt.Sprintf("wss://%s.agents.pinata.cloud", agentID)
133+
return fmt.Sprintf("wss://%s.%s", agentID, config.GetAgentsHost())
130134
}
131135

132136
// StreamChat connects to the agent's gateway via WebSocket and streams responses.
@@ -141,7 +145,7 @@ func StreamChat(ctx context.Context, agentID, token, model, session string, mess
141145

142146
// Connect to WebSocket with proper headers and timeout
143147
header := http.Header{}
144-
header.Set("Origin", "https://agents.pinata.cloud")
148+
header.Set("Origin", "https://"+config.GetAgentsHost())
145149
if token != "" {
146150
header.Set("Authorization", "Bearer "+token)
147151
}

internal/common/token.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ import (
66
"path/filepath"
77
)
88

9-
// FindToken extracts the JWT token from the .pinata-files-cli file
9+
// FindToken extracts the JWT token from the PINATA_JWT env var if set,
10+
// otherwise from the .pinata-files-cli file
1011
func FindToken() ([]byte, error) {
12+
if jwt := os.Getenv("PINATA_JWT"); jwt != "" {
13+
return []byte(jwt), nil
14+
}
1115
homeDir, err := os.UserHomeDir()
1216
if err != nil {
1317
return nil, err

0 commit comments

Comments
 (0)