File tree Expand file tree Collapse file tree 5 files changed +13
-17
lines changed Expand file tree Collapse file tree 5 files changed +13
-17
lines changed Original file line number Diff line number Diff line change 7
7
UnsupportedModelError ,
8
8
UnsupportedModelProviderError ,
9
9
} from "@/types/stagehandErrors" ;
10
+ import { ClientOptions } from "@/types/model" ;
10
11
11
12
// Map model names to their provider types
12
13
const modelToAgentProviderMap : Record < string , AgentType > = {
@@ -32,7 +33,7 @@ export class AgentProvider {
32
33
33
34
getClient (
34
35
modelName : string ,
35
- clientOptions ?: Record < string , unknown > ,
36
+ clientOptions ?: ClientOptions & Record < string , unknown > ,
36
37
userProvidedInstructions ?: string ,
37
38
) : AgentClient {
38
39
const type = AgentProvider . getAgentProvider ( modelName ) ;
Original file line number Diff line number Diff line change 1
- import Anthropic from "@anthropic-ai/sdk" ;
1
+ import Anthropic , {
2
+ type ClientOptions as AnthropicClientOptions ,
3
+ } from "@anthropic-ai/sdk" ;
2
4
import { LogLine } from "@/types/log" ;
3
5
import {
4
6
AgentAction ,
@@ -35,7 +37,7 @@ export class AnthropicCUAClient extends AgentClient {
35
37
type : AgentType ,
36
38
modelName : string ,
37
39
userProvidedInstructions ?: string ,
38
- clientOptions ?: Record < string , unknown > ,
40
+ clientOptions ?: AnthropicClientOptions & Record < string , unknown > ,
39
41
) {
40
42
super ( type , modelName , userProvidedInstructions ) ;
41
43
@@ -53,13 +55,7 @@ export class AnthropicCUAClient extends AgentClient {
53
55
}
54
56
55
57
// Store client options for reference
56
- this . clientOptions = {
57
- apiKey : this . apiKey ,
58
- } ;
59
-
60
- if ( this . baseURL ) {
61
- this . clientOptions . baseUrl = this . baseURL ;
62
- }
58
+ this . clientOptions = clientOptions ;
63
59
64
60
// Initialize the Anthropic client
65
61
this . client = new Anthropic ( this . clientOptions ) ;
Original file line number Diff line number Diff line change 1
- import OpenAI from "openai" ;
1
+ import OpenAI , { type ClientOptions as OpenAIClientOptions } from "openai" ;
2
2
import { LogLine } from "../../types/log" ;
3
3
import {
4
4
AgentAction ,
@@ -34,7 +34,7 @@ export class OpenAICUAClient extends AgentClient {
34
34
type : AgentType ,
35
35
modelName : string ,
36
36
userProvidedInstructions ?: string ,
37
- clientOptions ?: Record < string , unknown > ,
37
+ clientOptions ?: OpenAIClientOptions & Record < string , unknown > ,
38
38
) {
39
39
super ( type , modelName , userProvidedInstructions ) ;
40
40
@@ -54,9 +54,7 @@ export class OpenAICUAClient extends AgentClient {
54
54
}
55
55
56
56
// Store client options for reference
57
- this . clientOptions = {
58
- apiKey : this . apiKey ,
59
- } ;
57
+ this . clientOptions = clientOptions ;
60
58
61
59
if ( this . baseURL ) {
62
60
this . clientOptions . baseURL = this . baseURL ;
Original file line number Diff line number Diff line change 1
1
import { LogLine } from "./log" ;
2
+ import { ClientOptions } from "@/types/model" ;
2
3
3
4
export interface AgentAction {
4
5
type : string ;
@@ -44,7 +45,7 @@ export interface AgentExecutionOptions {
44
45
45
46
export interface AgentHandlerOptions {
46
47
modelName : string ;
47
- clientOptions ?: Record < string , unknown > ;
48
+ clientOptions ?: ClientOptions & Record < string , unknown > ;
48
49
userProvidedInstructions ?: string ;
49
50
agentType : AgentType ;
50
51
}
Original file line number Diff line number Diff line change @@ -255,7 +255,7 @@ export interface AgentConfig {
255
255
/**
256
256
* Additional options to pass to the agent client
257
257
*/
258
- options ?: Record < string , unknown > ;
258
+ options ?: ClientOptions & Record < string , unknown > ;
259
259
}
260
260
261
261
export enum StagehandFunctionName {
You can’t perform that action at this time.
0 commit comments