33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { HookInput , HookJSONOutput , Options , PreToolUseHookInput , Query , SDKAssistantMessage , SDKResultMessage , SDKUserMessage } from '@anthropic-ai/claude-code ' ;
6+ import { HookInput , HookJSONOutput , Options , PreToolUseHookInput , Query , SDKAssistantMessage , SDKResultMessage , SDKUserMessage } from '@anthropic-ai/claude-agent-sdk ' ;
77import Anthropic from '@anthropic-ai/sdk' ;
88import type * as vscode from 'vscode' ;
99import { ConfigKey , IConfigurationService } from '../../../../platform/configuration/common/configurationService' ;
@@ -237,7 +237,6 @@ export class ClaudeCodeSession extends Disposable {
237237 */
238238 private async _startSession ( token : vscode . CancellationToken ) : Promise < void > {
239239 // Build options for the Claude Code SDK
240- // process.env.DEBUG = '1'; // debug messages from sdk.mjs
241240 const isDebugEnabled = this . configService . getConfig ( ConfigKey . Advanced . ClaudeCodeDebugEnabled ) ;
242241 this . logService . trace ( `appRoot: ${ this . envService . appRoot } ` ) ;
243242 const pathSep = isWindows ? ';' : ':' ;
@@ -247,7 +246,6 @@ export class ClaudeCodeSession extends Disposable {
247246 executable : process . execPath as 'node' , // get it to fork the EH node process
248247 env : {
249248 ...process . env ,
250- ...( isDebugEnabled ? { DEBUG : '1' } : { } ) ,
251249 ANTHROPIC_BASE_URL : `http://localhost:${ this . serverConfig . port } ` ,
252250 ANTHROPIC_API_KEY : this . serverConfig . nonce ,
253251 CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC : '1' ,
@@ -274,10 +272,20 @@ export class ClaudeCodeSession extends Disposable {
274272 this . canUseTool ( name , input , this . _currentRequest . toolInvocationToken ) :
275273 { behavior : 'deny' , message : 'No active request' } ;
276274 } ,
277- appendSystemPrompt : 'Your responses will be rendered as markdown, so please reply with properly formatted markdown when appropriate. When replying with code or the name of a symbol, wrap it in backticks.'
275+ systemPrompt : {
276+ type : 'preset' ,
277+ preset : 'claude_code' ,
278+ append : 'Your responses will be rendered as markdown, so please reply with properly formatted markdown when appropriate. When replying with code or the name of a symbol, wrap it in backticks.'
279+ } ,
280+ settingSources : [ 'user' , 'project' , 'local' ] ,
281+ ...( isDebugEnabled && {
282+ stderr : data => {
283+ this . logService . trace ( `claude-agent-sdk stderr: ${ data } ` ) ;
284+ }
285+ } )
278286 } ;
279287
280- this . logService . trace ( `Claude CLI SDK : Starting query with options: ${ JSON . stringify ( options ) } ` ) ;
288+ this . logService . trace ( `claude-agent-sdk : Starting query with options: ${ JSON . stringify ( options ) } ` ) ;
281289 this . _queryGenerator = await this . claudeCodeService . query ( {
282290 prompt : this . _createPromptIterable ( ) ,
283291 options
@@ -365,7 +373,7 @@ export class ClaudeCodeSession extends Disposable {
365373 throw new Error ( 'Request was cancelled' ) ;
366374 }
367375
368- this . logService . trace ( `Claude CLI SDK Message: ${ JSON . stringify ( message , null , 2 ) } ` ) ;
376+ this . logService . trace ( `claude-agent-sdk Message: ${ JSON . stringify ( message , null , 2 ) } ` ) ;
369377 if ( message . session_id ) {
370378 this . sessionId = message . session_id ;
371379 }
0 commit comments