3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { Options , Query , SDKAssistantMessage , SDKResultMessage , SDKUserMessage } from '@anthropic-ai/claude-code ' ;
6
+ import { Options , Query , SDKAssistantMessage , SDKResultMessage , SDKUserMessage } from '@anthropic-ai/claude-agent-sdk ' ;
7
7
import Anthropic from '@anthropic-ai/sdk' ;
8
8
import type * as vscode from 'vscode' ;
9
9
import { ConfigKey , IConfigurationService } from '../../../../platform/configuration/common/configurationService' ;
@@ -234,7 +234,6 @@ export class ClaudeCodeSession extends Disposable {
234
234
*/
235
235
private async _startSession ( ) : Promise < void > {
236
236
// Build options for the Claude Code SDK
237
- // process.env.DEBUG = '1'; // debug messages from sdk.mjs
238
237
const isDebugEnabled = this . configService . getConfig ( ConfigKey . Internal . ClaudeCodeDebugEnabled ) ;
239
238
this . logService . trace ( `appRoot: ${ this . envService . appRoot } ` ) ;
240
239
const pathSep = isWindows ? ';' : ':' ;
@@ -244,7 +243,6 @@ export class ClaudeCodeSession extends Disposable {
244
243
executable : process . execPath as 'node' , // get it to fork the EH node process
245
244
env : {
246
245
...process . env ,
247
- ...( isDebugEnabled ? { DEBUG : '1' } : { } ) ,
248
246
ANTHROPIC_BASE_URL : `http://localhost:${ this . serverConfig . port } ` ,
249
247
ANTHROPIC_API_KEY : this . serverConfig . nonce ,
250
248
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC : '1' ,
@@ -257,10 +255,20 @@ export class ClaudeCodeSession extends Disposable {
257
255
this . canUseTool ( name , input , this . _currentRequest . toolInvocationToken ) :
258
256
{ behavior : 'deny' , message : 'No active request' } ;
259
257
} ,
260
- 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.'
258
+ systemPrompt : {
259
+ type : 'preset' ,
260
+ preset : 'claude_code' ,
261
+ 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.'
262
+ } ,
263
+ settingSources : [ 'user' , 'project' , 'local' ] ,
264
+ ...( isDebugEnabled && {
265
+ stderr : data => {
266
+ this . logService . trace ( `claude-agent-sdk stderr: ${ data } ` ) ;
267
+ }
268
+ } )
261
269
} ;
262
270
263
- this . logService . trace ( `Claude CLI SDK : Starting query with options: ${ JSON . stringify ( options ) } ` ) ;
271
+ this . logService . trace ( `claude-agent-sdk : Starting query with options: ${ JSON . stringify ( options ) } ` ) ;
264
272
this . _queryGenerator = await this . claudeCodeService . query ( {
265
273
prompt : this . _createPromptIterable ( ) ,
266
274
options
@@ -323,7 +331,7 @@ export class ClaudeCodeSession extends Disposable {
323
331
throw new Error ( 'Request was cancelled' ) ;
324
332
}
325
333
326
- this . logService . trace ( `Claude CLI SDK Message: ${ JSON . stringify ( message , null , 2 ) } ` ) ;
334
+ this . logService . trace ( `claude-agent-sdk Message: ${ JSON . stringify ( message , null , 2 ) } ` ) ;
327
335
if ( message . session_id ) {
328
336
this . sessionId = message . session_id ;
329
337
}
0 commit comments