ai-sdk-provider-claude-code 3.4.1 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -21
- package/dist/index.cjs +92 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -3
- package/dist/index.d.ts +34 -3
- package/dist/index.js +92 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LanguageModelV3, ProviderV3, APICallError, LoadAPIKeyError } from '@ai-sdk/provider';
|
|
2
|
-
import { PermissionMode, SdkBeta, SdkPluginConfig, SandboxSettings, Options, McpServerConfig, CanUseTool, AgentMcpServerSpec, SpawnOptions, SpawnedProcess, Query, SdkMcpToolDefinition, McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk';
|
|
3
|
-
export { AgentMcpServerSpec, CanUseTool, HookCallback, HookCallbackMatcher, HookEvent, HookInput, HookJSONOutput, McpSdkServerConfigWithInstance, McpServerConfig, OutputFormat, PermissionBehavior, PermissionResult, PermissionRuleValue, PermissionUpdate, PostToolUseHookInput, PreToolUseHookInput, Query, SessionEndHookInput, SessionStartHookInput, SpawnOptions, SpawnedProcess, TaskCompletedHookInput, TeammateIdleHookInput, UserPromptSubmitHookInput, createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import { ThinkingConfig, PermissionMode, SdkBeta, SdkPluginConfig, SandboxSettings, Options, McpServerConfig, CanUseTool, AgentMcpServerSpec, SpawnOptions, SpawnedProcess, Query, SdkMcpToolDefinition, McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk';
|
|
3
|
+
export { AgentMcpServerSpec, CanUseTool, HookCallback, HookCallbackMatcher, HookEvent, HookInput, HookJSONOutput, McpSdkServerConfigWithInstance, McpServerConfig, OutputFormat, PermissionBehavior, PermissionResult, PermissionRuleValue, PermissionUpdate, PostToolUseHookInput, PreToolUseHookInput, Query, SessionEndHookInput, SessionStartHookInput, SpawnOptions, SpawnedProcess, TaskCompletedHookInput, TeammateIdleHookInput, ThinkingAdaptive, ThinkingConfig, ThinkingDisabled, ThinkingEnabled, UserPromptSubmitHookInput, createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
4
4
|
import { ZodObject, ZodRawShape } from 'zod';
|
|
5
5
|
|
|
6
6
|
type StreamingInputMode = 'auto' | 'always' | 'off';
|
|
@@ -85,8 +85,37 @@ interface ClaudeCodeSettings {
|
|
|
85
85
|
maxTurns?: number;
|
|
86
86
|
/**
|
|
87
87
|
* Maximum thinking tokens for the model
|
|
88
|
+
*
|
|
89
|
+
* @deprecated Use `thinking` instead.
|
|
88
90
|
*/
|
|
89
91
|
maxThinkingTokens?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Controls Claude's thinking/reasoning behavior.
|
|
94
|
+
* Takes precedence over the deprecated `maxThinkingTokens`.
|
|
95
|
+
*
|
|
96
|
+
* - `{ type: 'adaptive' }` — Claude decides when and how much to think (Opus 4.6+, default)
|
|
97
|
+
* - `{ type: 'enabled', budgetTokens?: number }` — Fixed thinking token budget
|
|
98
|
+
* - `{ type: 'disabled' }` — No extended thinking
|
|
99
|
+
*
|
|
100
|
+
* @see https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking
|
|
101
|
+
*/
|
|
102
|
+
thinking?: ThinkingConfig;
|
|
103
|
+
/**
|
|
104
|
+
* Controls how much effort Claude puts into its response.
|
|
105
|
+
*
|
|
106
|
+
* - `'low'` — Minimal thinking, fastest responses
|
|
107
|
+
* - `'medium'` — Moderate thinking
|
|
108
|
+
* - `'high'` — Deep reasoning (default)
|
|
109
|
+
* - `'max'` — Maximum effort (Opus 4.6 only)
|
|
110
|
+
*
|
|
111
|
+
* @see https://docs.anthropic.com/en/docs/build-with-claude/effort
|
|
112
|
+
*/
|
|
113
|
+
effort?: 'low' | 'medium' | 'high' | 'max';
|
|
114
|
+
/**
|
|
115
|
+
* Enable prompt suggestions. When true, the agent emits a predicted
|
|
116
|
+
* next user prompt after each turn (arrives after the result message).
|
|
117
|
+
*/
|
|
118
|
+
promptSuggestions?: boolean;
|
|
90
119
|
/**
|
|
91
120
|
* Working directory for CLI operations
|
|
92
121
|
*/
|
|
@@ -476,6 +505,7 @@ declare class ClaudeCodeLanguageModel implements LanguageModelV3 {
|
|
|
476
505
|
private getModel;
|
|
477
506
|
private getSanitizedSdkOptions;
|
|
478
507
|
private getEffectiveResume;
|
|
508
|
+
private extractTextAndThinking;
|
|
479
509
|
private extractToolUses;
|
|
480
510
|
private extractToolResults;
|
|
481
511
|
private extractToolErrors;
|
|
@@ -486,6 +516,7 @@ declare class ClaudeCodeLanguageModel implements LanguageModelV3 {
|
|
|
486
516
|
private createQueryOptions;
|
|
487
517
|
private handleClaudeCodeError;
|
|
488
518
|
private setSessionId;
|
|
519
|
+
private logMcpConnectionIssues;
|
|
489
520
|
doGenerate(options: Parameters<LanguageModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV3['doGenerate']>>>;
|
|
490
521
|
doStream(options: Parameters<LanguageModelV3['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV3['doStream']>>>;
|
|
491
522
|
private serializeWarningsForMetadata;
|
|
@@ -758,7 +789,7 @@ declare function createAPICallError({ message, code, exitCode, stderr, promptExc
|
|
|
758
789
|
* @example
|
|
759
790
|
* ```typescript
|
|
760
791
|
* throw createAuthenticationError({
|
|
761
|
-
* message: 'Please run "claude login" to authenticate'
|
|
792
|
+
* message: 'Please run "claude auth login" to authenticate'
|
|
762
793
|
* });
|
|
763
794
|
* ```
|
|
764
795
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LanguageModelV3, ProviderV3, APICallError, LoadAPIKeyError } from '@ai-sdk/provider';
|
|
2
|
-
import { PermissionMode, SdkBeta, SdkPluginConfig, SandboxSettings, Options, McpServerConfig, CanUseTool, AgentMcpServerSpec, SpawnOptions, SpawnedProcess, Query, SdkMcpToolDefinition, McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk';
|
|
3
|
-
export { AgentMcpServerSpec, CanUseTool, HookCallback, HookCallbackMatcher, HookEvent, HookInput, HookJSONOutput, McpSdkServerConfigWithInstance, McpServerConfig, OutputFormat, PermissionBehavior, PermissionResult, PermissionRuleValue, PermissionUpdate, PostToolUseHookInput, PreToolUseHookInput, Query, SessionEndHookInput, SessionStartHookInput, SpawnOptions, SpawnedProcess, TaskCompletedHookInput, TeammateIdleHookInput, UserPromptSubmitHookInput, createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import { ThinkingConfig, PermissionMode, SdkBeta, SdkPluginConfig, SandboxSettings, Options, McpServerConfig, CanUseTool, AgentMcpServerSpec, SpawnOptions, SpawnedProcess, Query, SdkMcpToolDefinition, McpSdkServerConfigWithInstance } from '@anthropic-ai/claude-agent-sdk';
|
|
3
|
+
export { AgentMcpServerSpec, CanUseTool, HookCallback, HookCallbackMatcher, HookEvent, HookInput, HookJSONOutput, McpSdkServerConfigWithInstance, McpServerConfig, OutputFormat, PermissionBehavior, PermissionResult, PermissionRuleValue, PermissionUpdate, PostToolUseHookInput, PreToolUseHookInput, Query, SessionEndHookInput, SessionStartHookInput, SpawnOptions, SpawnedProcess, TaskCompletedHookInput, TeammateIdleHookInput, ThinkingAdaptive, ThinkingConfig, ThinkingDisabled, ThinkingEnabled, UserPromptSubmitHookInput, createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
4
4
|
import { ZodObject, ZodRawShape } from 'zod';
|
|
5
5
|
|
|
6
6
|
type StreamingInputMode = 'auto' | 'always' | 'off';
|
|
@@ -85,8 +85,37 @@ interface ClaudeCodeSettings {
|
|
|
85
85
|
maxTurns?: number;
|
|
86
86
|
/**
|
|
87
87
|
* Maximum thinking tokens for the model
|
|
88
|
+
*
|
|
89
|
+
* @deprecated Use `thinking` instead.
|
|
88
90
|
*/
|
|
89
91
|
maxThinkingTokens?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Controls Claude's thinking/reasoning behavior.
|
|
94
|
+
* Takes precedence over the deprecated `maxThinkingTokens`.
|
|
95
|
+
*
|
|
96
|
+
* - `{ type: 'adaptive' }` — Claude decides when and how much to think (Opus 4.6+, default)
|
|
97
|
+
* - `{ type: 'enabled', budgetTokens?: number }` — Fixed thinking token budget
|
|
98
|
+
* - `{ type: 'disabled' }` — No extended thinking
|
|
99
|
+
*
|
|
100
|
+
* @see https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking
|
|
101
|
+
*/
|
|
102
|
+
thinking?: ThinkingConfig;
|
|
103
|
+
/**
|
|
104
|
+
* Controls how much effort Claude puts into its response.
|
|
105
|
+
*
|
|
106
|
+
* - `'low'` — Minimal thinking, fastest responses
|
|
107
|
+
* - `'medium'` — Moderate thinking
|
|
108
|
+
* - `'high'` — Deep reasoning (default)
|
|
109
|
+
* - `'max'` — Maximum effort (Opus 4.6 only)
|
|
110
|
+
*
|
|
111
|
+
* @see https://docs.anthropic.com/en/docs/build-with-claude/effort
|
|
112
|
+
*/
|
|
113
|
+
effort?: 'low' | 'medium' | 'high' | 'max';
|
|
114
|
+
/**
|
|
115
|
+
* Enable prompt suggestions. When true, the agent emits a predicted
|
|
116
|
+
* next user prompt after each turn (arrives after the result message).
|
|
117
|
+
*/
|
|
118
|
+
promptSuggestions?: boolean;
|
|
90
119
|
/**
|
|
91
120
|
* Working directory for CLI operations
|
|
92
121
|
*/
|
|
@@ -476,6 +505,7 @@ declare class ClaudeCodeLanguageModel implements LanguageModelV3 {
|
|
|
476
505
|
private getModel;
|
|
477
506
|
private getSanitizedSdkOptions;
|
|
478
507
|
private getEffectiveResume;
|
|
508
|
+
private extractTextAndThinking;
|
|
479
509
|
private extractToolUses;
|
|
480
510
|
private extractToolResults;
|
|
481
511
|
private extractToolErrors;
|
|
@@ -486,6 +516,7 @@ declare class ClaudeCodeLanguageModel implements LanguageModelV3 {
|
|
|
486
516
|
private createQueryOptions;
|
|
487
517
|
private handleClaudeCodeError;
|
|
488
518
|
private setSessionId;
|
|
519
|
+
private logMcpConnectionIssues;
|
|
489
520
|
doGenerate(options: Parameters<LanguageModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV3['doGenerate']>>>;
|
|
490
521
|
doStream(options: Parameters<LanguageModelV3['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV3['doStream']>>>;
|
|
491
522
|
private serializeWarningsForMetadata;
|
|
@@ -758,7 +789,7 @@ declare function createAPICallError({ message, code, exitCode, stderr, promptExc
|
|
|
758
789
|
* @example
|
|
759
790
|
* ```typescript
|
|
760
791
|
* throw createAuthenticationError({
|
|
761
|
-
* message: 'Please run "claude login" to authenticate'
|
|
792
|
+
* message: 'Please run "claude auth login" to authenticate'
|
|
762
793
|
* });
|
|
763
794
|
* ```
|
|
764
795
|
*/
|
package/dist/index.js
CHANGED
|
@@ -428,6 +428,16 @@ var claudeCodeSettingsSchema = z.object({
|
|
|
428
428
|
]).optional(),
|
|
429
429
|
maxTurns: z.number().int().min(1).max(100).optional(),
|
|
430
430
|
maxThinkingTokens: z.number().int().positive().max(1e5).optional(),
|
|
431
|
+
thinking: z.union([
|
|
432
|
+
z.object({ type: z.literal("adaptive") }).strict(),
|
|
433
|
+
z.object({
|
|
434
|
+
type: z.literal("enabled"),
|
|
435
|
+
budgetTokens: z.number().int().positive().optional()
|
|
436
|
+
}).strict(),
|
|
437
|
+
z.object({ type: z.literal("disabled") }).strict()
|
|
438
|
+
]).optional(),
|
|
439
|
+
effort: z.enum(["low", "medium", "high", "max"]).optional(),
|
|
440
|
+
promptSuggestions: z.boolean().optional(),
|
|
431
441
|
cwd: z.string().refine(
|
|
432
442
|
(val) => {
|
|
433
443
|
if (typeof process === "undefined" || !process.versions?.node) {
|
|
@@ -754,6 +764,22 @@ function getBaseProcessEnv() {
|
|
|
754
764
|
}
|
|
755
765
|
var STREAMING_FEATURE_WARNING = "Claude Agent SDK features (hooks/MCP/images) require streaming input. Set `streamingInput: 'always'` or provide `canUseTool` (auto streams only when canUseTool is set).";
|
|
756
766
|
var SDK_OPTIONS_BLOCKLIST = /* @__PURE__ */ new Set(["model", "abortController", "prompt", "outputFormat"]);
|
|
767
|
+
function isContentBlock(item) {
|
|
768
|
+
return typeof item === "object" && item !== null && "type" in item;
|
|
769
|
+
}
|
|
770
|
+
function filterContentBlocks(content, type) {
|
|
771
|
+
if (!Array.isArray(content)) return [];
|
|
772
|
+
const blocks = content.filter(
|
|
773
|
+
(item) => isContentBlock(item) && item.type === type
|
|
774
|
+
);
|
|
775
|
+
const mismatch = blocks.find((b) => b.type !== type);
|
|
776
|
+
if (mismatch) {
|
|
777
|
+
throw new Error(
|
|
778
|
+
`filterContentBlocks: block type '${mismatch.type}' passed filter for '${type}'`
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
return blocks;
|
|
782
|
+
}
|
|
757
783
|
function createEmptyUsage() {
|
|
758
784
|
return {
|
|
759
785
|
inputTokens: {
|
|
@@ -1009,14 +1035,29 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1009
1035
|
getEffectiveResume(sdkOptions) {
|
|
1010
1036
|
return sdkOptions?.resume ?? this.settings.resume ?? this.sessionId;
|
|
1011
1037
|
}
|
|
1012
|
-
|
|
1013
|
-
if (!Array.isArray(content)) {
|
|
1014
|
-
|
|
1038
|
+
extractTextAndThinking(content) {
|
|
1039
|
+
if (!Array.isArray(content)) return { text: "", thinking: [] };
|
|
1040
|
+
let text = "";
|
|
1041
|
+
const thinking = [];
|
|
1042
|
+
for (const part of content) {
|
|
1043
|
+
if (!isContentBlock(part)) continue;
|
|
1044
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
1045
|
+
text += part.text;
|
|
1046
|
+
} else if (part.type === "thinking" && typeof part.thinking === "string") {
|
|
1047
|
+
thinking.push(part.thinking);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
if (text.length > 0 && typeof text !== "string") {
|
|
1051
|
+
throw new Error("extractTextAndThinking: accumulated text must be a string");
|
|
1052
|
+
}
|
|
1053
|
+
if (thinking.some((t) => typeof t !== "string")) {
|
|
1054
|
+
throw new Error("extractTextAndThinking: all thinking entries must be strings");
|
|
1015
1055
|
}
|
|
1016
|
-
return
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1056
|
+
return { text, thinking };
|
|
1057
|
+
}
|
|
1058
|
+
extractToolUses(content) {
|
|
1059
|
+
return filterContentBlocks(content, "tool_use").map((block) => {
|
|
1060
|
+
const { id, name, input, parent_tool_use_id } = block;
|
|
1020
1061
|
return {
|
|
1021
1062
|
id: typeof id === "string" && id.length > 0 ? id : generateId(),
|
|
1022
1063
|
name: typeof name === "string" && name.length > 0 ? name : _ClaudeCodeLanguageModel.UNKNOWN_TOOL_NAME,
|
|
@@ -1026,13 +1067,8 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1026
1067
|
});
|
|
1027
1068
|
}
|
|
1028
1069
|
extractToolResults(content) {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1032
|
-
return content.filter(
|
|
1033
|
-
(item) => typeof item === "object" && item !== null && "type" in item && item.type === "tool_result"
|
|
1034
|
-
).map((item) => {
|
|
1035
|
-
const { tool_use_id, content: content2, is_error, name } = item;
|
|
1070
|
+
return filterContentBlocks(content, "tool_result").map((block) => {
|
|
1071
|
+
const { tool_use_id, content: content2, is_error, name } = block;
|
|
1036
1072
|
return {
|
|
1037
1073
|
id: typeof tool_use_id === "string" && tool_use_id.length > 0 ? tool_use_id : generateId(),
|
|
1038
1074
|
name: typeof name === "string" && name.length > 0 ? name : void 0,
|
|
@@ -1042,13 +1078,8 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1042
1078
|
});
|
|
1043
1079
|
}
|
|
1044
1080
|
extractToolErrors(content) {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
}
|
|
1048
|
-
return content.filter(
|
|
1049
|
-
(item) => typeof item === "object" && item !== null && "type" in item && item.type === "tool_error"
|
|
1050
|
-
).map((item) => {
|
|
1051
|
-
const { tool_use_id, error, name } = item;
|
|
1081
|
+
return filterContentBlocks(content, "tool_error").map((block) => {
|
|
1082
|
+
const { tool_use_id, error, name } = block;
|
|
1052
1083
|
return {
|
|
1053
1084
|
id: typeof tool_use_id === "string" && tool_use_id.length > 0 ? tool_use_id : generateId(),
|
|
1054
1085
|
name: typeof name === "string" && name.length > 0 ? name : void 0,
|
|
@@ -1172,6 +1203,9 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1172
1203
|
pathToClaudeCodeExecutable: this.settings.pathToClaudeCodeExecutable,
|
|
1173
1204
|
maxTurns: this.settings.maxTurns,
|
|
1174
1205
|
maxThinkingTokens: this.settings.maxThinkingTokens,
|
|
1206
|
+
thinking: this.settings.thinking,
|
|
1207
|
+
effort: this.settings.effort,
|
|
1208
|
+
promptSuggestions: this.settings.promptSuggestions,
|
|
1175
1209
|
cwd: this.settings.cwd,
|
|
1176
1210
|
executable: this.settings.executable,
|
|
1177
1211
|
executableArgs: this.settings.executableArgs,
|
|
@@ -1295,6 +1329,7 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1295
1329
|
"auth failed",
|
|
1296
1330
|
"please login",
|
|
1297
1331
|
"claude login",
|
|
1332
|
+
"claude auth login",
|
|
1298
1333
|
"/login",
|
|
1299
1334
|
// CLI returns "Please run /login"
|
|
1300
1335
|
"invalid api key"
|
|
@@ -1335,6 +1370,25 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1335
1370
|
this.logger.warn(`Claude Code Session: ${warning}`);
|
|
1336
1371
|
}
|
|
1337
1372
|
}
|
|
1373
|
+
logMcpConnectionIssues(mcpServers) {
|
|
1374
|
+
if (!Array.isArray(mcpServers) || mcpServers.length === 0) {
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
const serversNeedingAttention = mcpServers.filter((server) => {
|
|
1378
|
+
const status = typeof server.status === "string" ? server.status.toLowerCase() : "";
|
|
1379
|
+
return status === "failed" || status === "needs-auth";
|
|
1380
|
+
});
|
|
1381
|
+
if (serversNeedingAttention.length === 0) {
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
const details = serversNeedingAttention.map((server) => {
|
|
1385
|
+
const name = typeof server.name === "string" && server.name.trim().length > 0 ? server.name : "<unknown>";
|
|
1386
|
+
const status = typeof server.status === "string" && server.status.trim().length > 0 ? server.status : "unknown";
|
|
1387
|
+
const error = typeof server.error === "string" && server.error.trim().length > 0 ? ` (${server.error})` : "";
|
|
1388
|
+
return `${name}:${status}${error}`;
|
|
1389
|
+
}).join(", ");
|
|
1390
|
+
this.logger.warn(`[claude-code] MCP servers not connected: ${details}`);
|
|
1391
|
+
}
|
|
1338
1392
|
async doGenerate(options) {
|
|
1339
1393
|
this.logger.debug(`[claude-code] Starting doGenerate request with model: ${this.modelId}`);
|
|
1340
1394
|
this.logger.debug(`[claude-code] Response format: ${options.responseFormat?.type ?? "none"}`);
|
|
@@ -1369,6 +1423,7 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1369
1423
|
effectiveResume
|
|
1370
1424
|
);
|
|
1371
1425
|
let text = "";
|
|
1426
|
+
const thinkingTraces = [];
|
|
1372
1427
|
let structuredOutput;
|
|
1373
1428
|
let usage = createEmptyUsage();
|
|
1374
1429
|
let finishReason = { unified: "stop", raw: void 0 };
|
|
@@ -1424,7 +1479,11 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1424
1479
|
for await (const message of response) {
|
|
1425
1480
|
this.logger.debug(`[claude-code] Received message type: ${message.type}`);
|
|
1426
1481
|
if (message.type === "assistant") {
|
|
1427
|
-
|
|
1482
|
+
const { text: messageText, thinking: messageThinking } = this.extractTextAndThinking(
|
|
1483
|
+
message.message.content
|
|
1484
|
+
);
|
|
1485
|
+
text += messageText;
|
|
1486
|
+
thinkingTraces.push(...messageThinking);
|
|
1428
1487
|
} else if (message.type === "result") {
|
|
1429
1488
|
done();
|
|
1430
1489
|
this.setSessionId(message.session_id);
|
|
@@ -1457,6 +1516,7 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1457
1516
|
finishReason = mapClaudeCodeFinishReason(message.subtype, stopReason);
|
|
1458
1517
|
this.logger.debug(`[claude-code] Finish reason: ${finishReason.unified}`);
|
|
1459
1518
|
} else if (message.type === "system" && message.subtype === "init") {
|
|
1519
|
+
this.logMcpConnectionIssues(message.mcp_servers);
|
|
1460
1520
|
this.setSessionId(message.session_id);
|
|
1461
1521
|
this.logger.info(`[claude-code] Session initialized: ${message.session_id}`);
|
|
1462
1522
|
}
|
|
@@ -1490,7 +1550,13 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1490
1550
|
}
|
|
1491
1551
|
const finalText = structuredOutput !== void 0 ? JSON.stringify(structuredOutput) : text;
|
|
1492
1552
|
return {
|
|
1493
|
-
content: [
|
|
1553
|
+
content: [
|
|
1554
|
+
...thinkingTraces.map((trace) => ({
|
|
1555
|
+
type: "reasoning",
|
|
1556
|
+
text: trace
|
|
1557
|
+
})),
|
|
1558
|
+
{ type: "text", text: finalText }
|
|
1559
|
+
],
|
|
1494
1560
|
usage,
|
|
1495
1561
|
finishReason,
|
|
1496
1562
|
warnings,
|
|
@@ -1508,7 +1574,8 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
1508
1574
|
...costUsd !== void 0 && { costUsd },
|
|
1509
1575
|
...durationMs !== void 0 && { durationMs },
|
|
1510
1576
|
...modelUsage !== void 0 && { modelUsage },
|
|
1511
|
-
...wasTruncated && { truncated: true }
|
|
1577
|
+
...wasTruncated && { truncated: true },
|
|
1578
|
+
...thinkingTraces.length > 0 && { thinkingTraces }
|
|
1512
1579
|
}
|
|
1513
1580
|
}
|
|
1514
1581
|
};
|
|
@@ -2278,6 +2345,7 @@ var ClaudeCodeLanguageModel = class _ClaudeCodeLanguageModel {
|
|
|
2278
2345
|
controller.close();
|
|
2279
2346
|
return;
|
|
2280
2347
|
} else if (message.type === "system" && message.subtype === "init") {
|
|
2348
|
+
this.logMcpConnectionIssues(message.mcp_servers);
|
|
2281
2349
|
this.setSessionId(message.session_id);
|
|
2282
2350
|
this.logger.info(`[claude-code] Stream session initialized: ${message.session_id}`);
|
|
2283
2351
|
controller.enqueue({
|