graphlit-client 1.0.20260601001 → 1.0.20260601002

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
@@ -7,7 +7,7 @@ import gql from "graphql-tag";
7
7
  import { attachPartialErrors } from "./partial-errors.js";
8
8
  import * as Types from "./generated/graphql-types.js";
9
9
  import * as Documents from "./generated/graphql-documents.js";
10
- import { getServiceType, getModelName, getModelEnum, isOpenAIResponsesEligibleModel, } from "./model-mapping.js";
10
+ import { getServiceType, getModelName, getModelEnum, isAnthropicAdaptiveThinkingOnlyModel, isOpenAIResponsesEligibleModel, } from "./model-mapping.js";
11
11
  import { StuckDetector } from "./helpers/stuck-detector.js";
12
12
  import { TurnEvaluator } from "./helpers/turn-evaluator.js";
13
13
  import { TokenBudgetTracker, truncateToolResult, windowToolRounds, estimateTokens, DEFAULT_CONTEXT_STRATEGY, } from "./helpers/context-management.js";
@@ -362,7 +362,7 @@ function isValidGuid(guid) {
362
362
  /**
363
363
  * Map Graphlit AnthropicEffortLevels to the string values accepted by the
364
364
  * Anthropic Messages API `output_config.effort` parameter (adaptive thinking).
365
- * Used for Claude 4.7 Opus, which replaces `thinking.budget_tokens` with
365
+ * Used for Claude Opus 4.7/4.8, which replace `thinking.budget_tokens` with
366
366
  * `thinking.type = "adaptive"` + `output_config.effort`.
367
367
  */
368
368
  function mapAnthropicEffort(effort) {
@@ -8335,8 +8335,8 @@ class Graphlit {
8335
8335
  if (specification.serviceType === Types.ModelServiceTypes.Anthropic) {
8336
8336
  const anthropic = specification.anthropic;
8337
8337
  if (anthropic?.enableThinking) {
8338
- // Claude 4.7 Opus only supports adaptive thinking with output_config.effort
8339
- if (anthropic.model === Types.AnthropicModels.Claude_4_7Opus) {
8338
+ // Claude Opus 4.7/4.8 only support adaptive thinking with output_config.effort
8339
+ if (isAnthropicAdaptiveThinkingOnlyModel(specification)) {
8340
8340
  return {
8341
8341
  type: "adaptive",
8342
8342
  effort: mapAnthropicEffort(anthropic.effort),
@@ -22,6 +22,11 @@ export declare function getServiceType(specification: any): string | undefined;
22
22
  * @returns The model enum value
23
23
  */
24
24
  export declare function getModelEnum(specification: any): string | undefined;
25
+ /**
26
+ * Check whether an Anthropic specification targets an Opus model that only
27
+ * supports adaptive thinking and rejects non-default sampling parameters.
28
+ */
29
+ export declare function isAnthropicAdaptiveThinkingOnlyModel(specification: any): boolean;
25
30
  /**
26
31
  * Check whether an OpenAI specification should use the Responses API path.
27
32
  * Eligible models are GPT-5.4 and newer.
@@ -120,8 +120,9 @@ const ANTHROPIC_MODEL_MAP = {
120
120
  [Types.AnthropicModels.Claude_4_6Sonnet_20260217]: "claude-sonnet-4-6-20260217",
121
121
  [Types.AnthropicModels.Claude_4_6Sonnet_1M]: "claude-sonnet-4-6",
122
122
  [Types.AnthropicModels.Claude_4_6Sonnet_1M_20260217]: "claude-sonnet-4-6-20260217",
123
- // Claude 4.7 models (1M context is native to the model, no beta header required)
123
+ // Claude 4.7+ models (1M context is native to the model, no beta header required)
124
124
  [Types.AnthropicModels.Claude_4_7Opus]: "claude-opus-4-7",
125
+ [Types.AnthropicModels.Claude_4_8Opus]: "claude-opus-4-8",
125
126
  };
126
127
  // Google model mappings
127
128
  const GOOGLE_MODEL_MAP = {
@@ -357,6 +358,22 @@ export function getModelEnum(specification) {
357
358
  return undefined;
358
359
  }
359
360
  }
361
+ /**
362
+ * Check whether an Anthropic specification targets an Opus model that only
363
+ * supports adaptive thinking and rejects non-default sampling parameters.
364
+ */
365
+ export function isAnthropicAdaptiveThinkingOnlyModel(specification) {
366
+ if (specification?.serviceType !== Types.ModelServiceTypes.Anthropic) {
367
+ return false;
368
+ }
369
+ const modelEnum = getModelEnum(specification);
370
+ if (modelEnum === Types.AnthropicModels.Claude_4_7Opus ||
371
+ modelEnum === Types.AnthropicModels.Claude_4_8Opus) {
372
+ return true;
373
+ }
374
+ const modelName = getModelName(specification);
375
+ return modelName === "claude-opus-4-7" || modelName === "claude-opus-4-8";
376
+ }
360
377
  /**
361
378
  * Check whether an OpenAI specification should use the Responses API path.
362
379
  * Eligible models are GPT-5.4 and newer.
@@ -1,5 +1,5 @@
1
1
  import * as Types from "../generated/graphql-types.js";
2
- import { getModelName } from "../model-mapping.js";
2
+ import { getModelName, isAnthropicAdaptiveThinkingOnlyModel, } from "../model-mapping.js";
3
3
  import { ProviderError, isRetryableServerError, isRateLimitError, isNetworkError, extractRequestId, } from "../types/internal.js";
4
4
  import { createHash } from "node:crypto";
5
5
  /**
@@ -509,17 +509,17 @@ onEvent, onComplete, abortSignal, thinkingConfig) {
509
509
  stream: true,
510
510
  max_tokens: specification.anthropic?.completionTokenLimit || defaultMaxTokens,
511
511
  };
512
- // Handle temperature based on thinking configuration and model
513
- // Claude 4.7 Opus (adaptive thinking) does not accept sampling parameters at all.
512
+ // Claude Opus 4.7/4.8 do not accept non-default sampling parameters at all.
514
513
  const isAdaptiveThinking = thinkingConfig?.type === "adaptive";
515
- if (thinkingConfig && !isAdaptiveThinking) {
514
+ const isAdaptiveThinkingOnlyModel = isAnthropicAdaptiveThinkingOnlyModel(specification);
515
+ if (thinkingConfig && !isAdaptiveThinking && !isAdaptiveThinkingOnlyModel) {
516
516
  // When legacy thinking budget is enabled, temperature must be 1
517
517
  streamConfig.temperature = 1;
518
518
  if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
519
519
  console.log(`🧠 [Anthropic] Setting temperature to 1 (required for extended thinking)`);
520
520
  }
521
521
  }
522
- else if (!isAdaptiveThinking) {
522
+ else if (!isAdaptiveThinkingOnlyModel && !isAdaptiveThinking) {
523
523
  // Only add temperature if it's defined and valid for non-thinking requests
524
524
  if (specification.anthropic?.temperature !== undefined &&
525
525
  specification.anthropic?.temperature !== null &&
@@ -550,7 +550,7 @@ onEvent, onComplete, abortSignal, thinkingConfig) {
550
550
  // Add thinking config if provided
551
551
  if (thinkingConfig) {
552
552
  if (thinkingConfig.type === "adaptive") {
553
- // Claude 4.7 Opus: adaptive thinking, effort controls depth via output_config
553
+ // Claude Opus 4.7/4.8: adaptive thinking, effort controls depth via output_config
554
554
  streamConfig.thinking = { type: "adaptive" };
555
555
  if (thinkingConfig.effort) {
556
556
  streamConfig.output_config = { effort: thinkingConfig.effort };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphlit-client",
3
- "version": "1.0.20260601001",
3
+ "version": "1.0.20260601002",
4
4
  "description": "Graphlit API Client for TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/client.js",