graphlit-client 1.0.20260415003 → 1.0.20260416002
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/dist/client.js
CHANGED
|
@@ -222,6 +222,29 @@ function isValidGuid(guid) {
|
|
|
222
222
|
const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
223
223
|
return guidRegex.test(guid);
|
|
224
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Map Graphlit AnthropicEffortLevels to the string values accepted by the
|
|
227
|
+
* Anthropic Messages API `output_config.effort` parameter (adaptive thinking).
|
|
228
|
+
* Used for Claude 4.7 Opus, which replaces `thinking.budget_tokens` with
|
|
229
|
+
* `thinking.type = "adaptive"` + `output_config.effort`.
|
|
230
|
+
*/
|
|
231
|
+
function mapAnthropicEffort(effort) {
|
|
232
|
+
if (!effort)
|
|
233
|
+
return undefined;
|
|
234
|
+
switch (effort) {
|
|
235
|
+
case Types.AnthropicEffortLevels.Low:
|
|
236
|
+
return "low";
|
|
237
|
+
case Types.AnthropicEffortLevels.Medium:
|
|
238
|
+
return "medium";
|
|
239
|
+
case Types.AnthropicEffortLevels.High:
|
|
240
|
+
return "high";
|
|
241
|
+
case Types.AnthropicEffortLevels.XHigh:
|
|
242
|
+
case Types.AnthropicEffortLevels.Max:
|
|
243
|
+
return "xhigh";
|
|
244
|
+
default:
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
225
248
|
// Define the Graphlit class
|
|
226
249
|
class Graphlit {
|
|
227
250
|
client;
|
|
@@ -7683,7 +7706,12 @@ class Graphlit {
|
|
|
7683
7706
|
// Get thinking configuration from specification
|
|
7684
7707
|
const thinkingConfig = this.getThinkingConfig(specification);
|
|
7685
7708
|
if (thinkingConfig && process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
7686
|
-
|
|
7709
|
+
if (thinkingConfig.type === "adaptive") {
|
|
7710
|
+
console.log(`🧠 [Graphlit SDK] Anthropic adaptive thinking enabled | Effort: ${thinkingConfig.effort ?? "default"}`);
|
|
7711
|
+
}
|
|
7712
|
+
else {
|
|
7713
|
+
console.log(`🧠 [Graphlit SDK] Anthropic thinking enabled | Budget: ${thinkingConfig.budget_tokens} tokens`);
|
|
7714
|
+
}
|
|
7687
7715
|
}
|
|
7688
7716
|
await streamWithAnthropic(specification, messages, systemPrompt, tools, anthropicClient, (event) => uiAdapter.handleEvent(event), onComplete, abortSignal, thinkingConfig);
|
|
7689
7717
|
}
|
|
@@ -7695,6 +7723,13 @@ class Graphlit {
|
|
|
7695
7723
|
if (specification.serviceType === Types.ModelServiceTypes.Anthropic) {
|
|
7696
7724
|
const anthropic = specification.anthropic;
|
|
7697
7725
|
if (anthropic?.enableThinking) {
|
|
7726
|
+
// Claude 4.7 Opus only supports adaptive thinking with output_config.effort
|
|
7727
|
+
if (anthropic.model === Types.AnthropicModels.Claude_4_7Opus) {
|
|
7728
|
+
return {
|
|
7729
|
+
type: "adaptive",
|
|
7730
|
+
effort: mapAnthropicEffort(anthropic.effort),
|
|
7731
|
+
};
|
|
7732
|
+
}
|
|
7698
7733
|
return {
|
|
7699
7734
|
type: "enabled",
|
|
7700
7735
|
budget_tokens: anthropic.thinkingTokenLimit || 10000,
|
|
@@ -7732,7 +7767,9 @@ class Graphlit {
|
|
|
7732
7767
|
console.log(`🚀 [Graphlit SDK] Routing to Google streaming provider | Spec: ${specification.name} (${specification.id}) | Messages: ${messages.length} | Tools: ${tools?.length || 0} | SystemPrompt: ${systemPrompt ? "Yes" : "No"}`);
|
|
7733
7768
|
}
|
|
7734
7769
|
// Get thinking configuration from specification
|
|
7735
|
-
|
|
7770
|
+
// Google only supports legacy budget-based thinking — adaptive is Anthropic-only.
|
|
7771
|
+
const rawThinkingConfig = this.getThinkingConfig(specification);
|
|
7772
|
+
const thinkingConfig = rawThinkingConfig?.type === "enabled" ? rawThinkingConfig : undefined;
|
|
7736
7773
|
if (thinkingConfig && process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
7737
7774
|
console.log(`🧠 [Graphlit SDK] Google thinking enabled | Budget: ${thinkingConfig.budget_tokens} tokens`);
|
|
7738
7775
|
}
|
|
@@ -722,7 +722,9 @@ export declare enum AnthropicEffortLevels {
|
|
|
722
722
|
/** Maximum effort */
|
|
723
723
|
Max = "MAX",
|
|
724
724
|
/** Medium effort */
|
|
725
|
-
Medium = "MEDIUM"
|
|
725
|
+
Medium = "MEDIUM",
|
|
726
|
+
/** Extra high effort */
|
|
727
|
+
XHigh = "X_HIGH"
|
|
726
728
|
}
|
|
727
729
|
/** Represents Anthropic model properties. */
|
|
728
730
|
export type AnthropicModelProperties = {
|
|
@@ -866,6 +868,8 @@ export declare enum AnthropicModels {
|
|
|
866
868
|
Claude_4_6Sonnet_1M_20260217 = "CLAUDE_4_6_SONNET_1_M_20260217",
|
|
867
869
|
/** Claude 4.6 Sonnet (02-17-2026 version) */
|
|
868
870
|
Claude_4_6Sonnet_20260217 = "CLAUDE_4_6_SONNET_20260217",
|
|
871
|
+
/** Claude 4.7 Opus (Latest) */
|
|
872
|
+
Claude_4_7Opus = "CLAUDE_4_7_OPUS",
|
|
869
873
|
/** Claude 4 Opus (Latest) */
|
|
870
874
|
Claude_4Opus = "CLAUDE_4_OPUS",
|
|
871
875
|
/** Claude 4 Opus (05-14-2025 version) */
|
|
@@ -77,6 +77,8 @@ export var AnthropicEffortLevels;
|
|
|
77
77
|
AnthropicEffortLevels["Max"] = "MAX";
|
|
78
78
|
/** Medium effort */
|
|
79
79
|
AnthropicEffortLevels["Medium"] = "MEDIUM";
|
|
80
|
+
/** Extra high effort */
|
|
81
|
+
AnthropicEffortLevels["XHigh"] = "X_HIGH";
|
|
80
82
|
})(AnthropicEffortLevels || (AnthropicEffortLevels = {}));
|
|
81
83
|
/** Anthropic model type */
|
|
82
84
|
export var AnthropicModels;
|
|
@@ -145,6 +147,8 @@ export var AnthropicModels;
|
|
|
145
147
|
AnthropicModels["Claude_4_6Sonnet_1M_20260217"] = "CLAUDE_4_6_SONNET_1_M_20260217";
|
|
146
148
|
/** Claude 4.6 Sonnet (02-17-2026 version) */
|
|
147
149
|
AnthropicModels["Claude_4_6Sonnet_20260217"] = "CLAUDE_4_6_SONNET_20260217";
|
|
150
|
+
/** Claude 4.7 Opus (Latest) */
|
|
151
|
+
AnthropicModels["Claude_4_7Opus"] = "CLAUDE_4_7_OPUS";
|
|
148
152
|
/** Claude 4 Opus (Latest) */
|
|
149
153
|
AnthropicModels["Claude_4Opus"] = "CLAUDE_4_OPUS";
|
|
150
154
|
/** Claude 4 Opus (05-14-2025 version) */
|
package/dist/model-mapping.js
CHANGED
|
@@ -116,6 +116,8 @@ const ANTHROPIC_MODEL_MAP = {
|
|
|
116
116
|
[Types.AnthropicModels.Claude_4_6Sonnet_20260217]: "claude-sonnet-4-6-20260217",
|
|
117
117
|
[Types.AnthropicModels.Claude_4_6Sonnet_1M]: "claude-sonnet-4-6",
|
|
118
118
|
[Types.AnthropicModels.Claude_4_6Sonnet_1M_20260217]: "claude-sonnet-4-6-20260217",
|
|
119
|
+
// Claude 4.7 models (1M context is native to the model, no beta header required)
|
|
120
|
+
[Types.AnthropicModels.Claude_4_7Opus]: "claude-opus-4-7",
|
|
119
121
|
};
|
|
120
122
|
// Google model mappings
|
|
121
123
|
const GOOGLE_MODEL_MAP = {
|
|
@@ -15,6 +15,9 @@ export declare function streamWithAnthropic(specification: Specification, messag
|
|
|
15
15
|
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[], usage?: any, reasoning?: ReasoningMetadata) => void, abortSignal?: AbortSignal, thinkingConfig?: {
|
|
16
16
|
type: "enabled";
|
|
17
17
|
budget_tokens: number;
|
|
18
|
+
} | {
|
|
19
|
+
type: "adaptive";
|
|
20
|
+
effort?: "low" | "medium" | "high" | "xhigh";
|
|
18
21
|
}): Promise<void>;
|
|
19
22
|
/**
|
|
20
23
|
* Stream with Google SDK
|
|
@@ -462,15 +462,17 @@ onEvent, onComplete, abortSignal, thinkingConfig) {
|
|
|
462
462
|
stream: true,
|
|
463
463
|
max_tokens: specification.anthropic?.completionTokenLimit || defaultMaxTokens,
|
|
464
464
|
};
|
|
465
|
-
// Handle temperature based on thinking configuration
|
|
466
|
-
|
|
467
|
-
|
|
465
|
+
// Handle temperature based on thinking configuration and model
|
|
466
|
+
// Claude 4.7 Opus (adaptive thinking) does not accept sampling parameters at all.
|
|
467
|
+
const isAdaptiveThinking = thinkingConfig?.type === "adaptive";
|
|
468
|
+
if (thinkingConfig && !isAdaptiveThinking) {
|
|
469
|
+
// When legacy thinking budget is enabled, temperature must be 1
|
|
468
470
|
streamConfig.temperature = 1;
|
|
469
471
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
470
472
|
console.log(`🧠 [Anthropic] Setting temperature to 1 (required for extended thinking)`);
|
|
471
473
|
}
|
|
472
474
|
}
|
|
473
|
-
else {
|
|
475
|
+
else if (!isAdaptiveThinking) {
|
|
474
476
|
// Only add temperature if it's defined and valid for non-thinking requests
|
|
475
477
|
if (specification.anthropic?.temperature !== undefined &&
|
|
476
478
|
specification.anthropic?.temperature !== null &&
|
|
@@ -496,17 +498,29 @@ onEvent, onComplete, abortSignal, thinkingConfig) {
|
|
|
496
498
|
Types.AnthropicModels.Claude_4_6Opus_1M_20260205;
|
|
497
499
|
// Add thinking config if provided
|
|
498
500
|
if (thinkingConfig) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
501
|
+
if (thinkingConfig.type === "adaptive") {
|
|
502
|
+
// Claude 4.7 Opus: adaptive thinking, effort controls depth via output_config
|
|
503
|
+
streamConfig.thinking = { type: "adaptive" };
|
|
504
|
+
if (thinkingConfig.effort) {
|
|
505
|
+
streamConfig.output_config = { effort: thinkingConfig.effort };
|
|
506
|
+
}
|
|
507
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
508
|
+
console.log(`🧠 [Anthropic] Adaptive thinking enabled | Effort: ${thinkingConfig.effort ?? "default"}`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
streamConfig.thinking = thinkingConfig;
|
|
513
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
514
|
+
console.log(`🧠 [Anthropic] Extended thinking enabled | Budget: ${thinkingConfig.budget_tokens} tokens`);
|
|
515
|
+
}
|
|
516
|
+
// Adjust max_tokens to account for thinking budget
|
|
517
|
+
// 1M context models have a 1,000,000 token window; standard models have 200,000
|
|
518
|
+
const contextWindowLimit = is1MContext ? 1000000 : 200000;
|
|
519
|
+
const totalTokens = streamConfig.max_tokens + thinkingConfig.budget_tokens;
|
|
520
|
+
if (totalTokens > contextWindowLimit) {
|
|
521
|
+
console.warn(`⚠️ [Anthropic] Total tokens (${totalTokens}) exceeds ${is1MContext ? "1M" : "200K"} context window, adjusting completion tokens...`);
|
|
522
|
+
streamConfig.max_tokens = Math.max(1000, contextWindowLimit - thinkingConfig.budget_tokens);
|
|
523
|
+
}
|
|
510
524
|
}
|
|
511
525
|
}
|
|
512
526
|
// Build request options with optional abort signal and 1M context beta header
|