44 */
55
66import path from 'path' ;
7- import clack from '../utils/clack' ;
8- import { debug , logToFile , initLogFile , LOG_FILE_PATH } from '../utils/debug' ;
9- import type { WizardOptions } from '../utils/types' ;
10- import { analytics } from '../utils/analytics' ;
11- import { WIZARD_INTERACTION_EVENT_NAME } from './constants' ;
12- import { LINTING_TOOLS } from './safe-tools' ;
13- import { getLlmGatewayUrlFromHost } from '../utils/urls' ;
7+ import { fileURLToPath } from 'url' ;
8+ import clack from '../utils/clack.js' ;
9+ import { debug , logToFile , initLogFile , LOG_FILE_PATH } from '../utils/debug.js' ;
10+ import type { WizardOptions } from '../utils/types.js' ;
11+ import { analytics } from '../utils/analytics.js' ;
12+ import { WIZARD_INTERACTION_EVENT_NAME } from './constants.js' ;
13+ import { LINTING_TOOLS } from './safe-tools.js' ;
14+ import { getLlmGatewayUrlFromHost } from '../utils/urls.js' ;
15+ import { getSettings } from './settings.js' ;
1416
1517// Dynamic import cache for ESM module
1618let _sdkModule : any = null ;
@@ -21,16 +23,6 @@ async function getSDKModule(): Promise<any> {
2123 return _sdkModule ;
2224}
2325
24- /**
25- * Get the path to the bundled Claude Code CLI from the SDK package.
26- * This ensures we use the SDK's bundled version rather than the user's installed Claude Code.
27- */
28- function getClaudeCodeExecutablePath ( ) : string {
29- // require.resolve finds the package's main entry, then we get cli.js from same dir
30- const sdkPackagePath = require . resolve ( '@anthropic-ai/claude-agent-sdk' ) ;
31- return path . join ( path . dirname ( sdkPackagePath ) , 'cli.js' ) ;
32- }
33-
3426// Using `any` because typed imports from ESM modules require import attributes
3527// syntax which prettier cannot parse. See PR discussion for details.
3628type SDKMessage = any ;
@@ -254,9 +246,10 @@ export function initializeAgent(
254246 // Configure LLM gateway for Claude API calls
255247 // Local testing: use localhost LLM gateway
256248 // Production: use WorkOS production gateway
249+ const settings = getSettings ( ) ;
257250 const gatewayUrl = options . local
258- ? 'http://localhost:8000'
259- : getLlmGatewayUrlFromHost ( config . workOSApiHost ) ;
251+ ? settings . gateway . development
252+ : getLlmGatewayUrlFromHost ( ) ;
260253
261254 process . env . ANTHROPIC_BASE_URL = gatewayUrl ;
262255 process . env . ANTHROPIC_AUTH_TOKEN = config . workOSApiKey ;
@@ -279,7 +272,7 @@ export function initializeAgent(
279272 args : [ '-y' , '@workos/mcp-docs-server' ] ,
280273 } ,
281274 } ,
282- model : 'claude-opus-4-5-20251101' ,
275+ model : settings . model ,
283276 allowedTools : [
284277 'Skill' ,
285278 'Read' ,
@@ -348,9 +341,7 @@ export async function runAgent(
348341
349342 spinner . start ( spinnerMessage ) ;
350343
351- const cliPath = getClaudeCodeExecutablePath ( ) ;
352344 logToFile ( 'Starting agent run' ) ;
353- logToFile ( 'Claude Code executable:' , cliPath ) ;
354345 logToFile ( 'Prompt:' , prompt ) ;
355346
356347 const startTime = Date . now ( ) ;
@@ -379,6 +370,8 @@ export async function runAgent(
379370
380371 // Load plugin with bundled skills
381372 // Path from dist/src/lib/ back to package root
373+ const __filename = fileURLToPath ( import . meta. url ) ;
374+ const __dirname = path . dirname ( __filename ) ;
382375 const pluginPath = path . join ( __dirname , '../../..' ) ;
383376 logToFile ( 'Loading plugin from:' , pluginPath ) ;
384377
0 commit comments