@ctxprotocol/sdk 0.12.0 → 0.13.0

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.
@@ -221,7 +221,7 @@ interface McpToolRateLimitHints {
221
221
  supportsBulk?: boolean;
222
222
  /** Preferred batch-oriented methods to call instead of fan-out loops */
223
223
  recommendedBatchTools?: string[];
224
- /** Optional human-readable notes for planning */
224
+ /** Optional human-readable notes for execution behavior */
225
225
  notes?: string;
226
226
  }
227
227
  type DiscoveryMode = "query" | "execute";
@@ -237,7 +237,7 @@ interface McpToolMeta {
237
237
  surface?: McpToolSurface;
238
238
  /** Whether this method can be selected in query mode */
239
239
  queryEligible?: boolean;
240
- /** Declared latency class for planner/runtime gating */
240
+ /** Declared latency class for metadata-scout/runtime gating */
241
241
  latencyClass?: McpToolLatencyClass;
242
242
  /** Method-level pricing metadata */
243
243
  pricing?: McpToolPricingMeta;
@@ -248,7 +248,7 @@ interface McpToolMeta {
248
248
  /** Context injection requirements handled by the Context runtime */
249
249
  contextRequirements?: string[];
250
250
  /**
251
- * Optional planner/runtime pacing hints.
251
+ * Optional metadata-scout/runtime pacing hints.
252
252
  * Tool contributors can publish these to reduce rate-limit failures.
253
253
  */
254
254
  rateLimit?: McpToolRateLimitHints;
@@ -512,8 +512,6 @@ interface ExecutionResult<T = unknown> {
512
512
  /** Execution duration in milliseconds */
513
513
  durationMs: number;
514
514
  }
515
- /** Supported orchestration depth modes for query execution. */
516
- type QueryDepth = "fast" | "auto" | "deep";
517
515
  type QueryDeepMode = "deep" | "deep-light" | "deep-heavy";
518
516
  type QueryClarificationPolicy = "return" | "auto" | "error";
519
517
  type QueryOutcomeType = "answer" | "clarification_required" | "capability_miss";
@@ -609,19 +607,22 @@ interface QueryClarificationDiagnostics {
609
607
  * Options for the agentic query endpoint (pay-per-response).
610
608
  *
611
609
  * Unlike `execute()` which calls a single tool once, `query()` sends a
612
- * natural-language question and lets the server handle discovery-first
613
- * orchestration (`discover/probe -> plan-from-evidence -> execute ->
614
- * bounded fallback`) plus synthesis.
610
+ * natural-language question and lets the server handle the live librarian
611
+ * pipeline (`discover -> select -> metadata scout -> clarify if needed ->
612
+ * iterative execute -> synthesize -> settle`).
615
613
  * One flat fee covers up to 100 MCP skill calls per tool.
616
614
  */
617
615
  interface QueryOptions {
618
616
  /** The natural-language question to answer */
619
617
  query: string;
620
618
  /**
621
- * How the SDK should handle clarification-required pre-plan situations:
619
+ * How the SDK should handle clarification-required situations:
622
620
  * - `return`: surface a structured clarification result to the caller
623
621
  * - `auto`: enable clarification auto-select and continue with the server's deterministic recommended option
624
622
  * - `error`: turn structured clarification/capability outcomes into terminal errors
623
+ *
624
+ * Default behavior is surface-dependent: headless SDK and MCP callers default
625
+ * to `auto`, while first-party chat defaults to `return`.
625
626
  */
626
627
  clarificationPolicy?: QueryClarificationPolicy;
627
628
  /**
@@ -677,23 +678,10 @@ interface QueryOptions {
677
678
  /**
678
679
  * Include machine-readable developer trace output for this query response.
679
680
  * When enabled, the server may return summary counters plus diagnostics
680
- * for lane selection, scout probe adequacy, and bounded fallback behavior.
681
+ * for lane selection, metadata scout adequacy, clarification, and iterative
682
+ * execution behavior.
681
683
  */
682
684
  includeDeveloperTrace?: boolean;
683
- /**
684
- * Query orchestration depth mode:
685
- * - `fast`: lower-latency path
686
- * - `auto`: server decides between fast/deep
687
- * - `deep`: full completeness-oriented path
688
- */
689
- queryDepth?: QueryDepth;
690
- /**
691
- * Development/testing only: force the server's internal deep lane.
692
- * `deep` is the canonical value. Legacy `deep-light` / `deep-heavy`
693
- * aliases are still accepted temporarily for compatibility and normalize
694
- * to the same runtime lane. Invalid when `queryDepth` is `fast`.
695
- */
696
- debugScoutDeepMode?: QueryDeepMode;
697
685
  /**
698
686
  * Optional idempotency key (UUID recommended).
699
687
  * Reuse the same key when retrying the same logical request.
@@ -719,7 +707,7 @@ interface QueryDeveloperTraceLoopInfo {
719
707
  [key: string]: unknown;
720
708
  }
721
709
  /**
722
- * Tool selection metadata attached to discovery/planning diagnostics.
710
+ * Tool selection metadata attached to discovery and metadata-scout diagnostics.
723
711
  */
724
712
  interface QueryDeveloperTraceToolSelection {
725
713
  toolId: string;
@@ -730,7 +718,7 @@ interface QueryDeveloperTraceToolSelection {
730
718
  priceUsd?: string;
731
719
  }
732
720
  /**
733
- * Initial planner diagnostic details.
721
+ * Execution-contract details handed to the iterative runtime.
734
722
  */
735
723
  interface QueryPlanningTraceDiagnostic {
736
724
  plannerQuery: string;
@@ -738,25 +726,6 @@ interface QueryPlanningTraceDiagnostic {
738
726
  scoutEvidencePromptBlock: string | null;
739
727
  allowedModules: string[];
740
728
  }
741
- /**
742
- * Rediscovery/fallback diagnostic details.
743
- */
744
- interface QueryRediscoveryTraceDiagnostic {
745
- considered: boolean;
746
- executed: boolean;
747
- skipReason: string | null;
748
- missingCapability: string | null;
749
- rediscoveryQuery: string | null;
750
- capabilityLooksLikeSearchNeed: boolean;
751
- allowSearchFallbackOnElapsedCap: boolean;
752
- searchFallbackUsed: boolean;
753
- preRediscoveryBudgetReasonCode: string | null;
754
- candidateSearchResults: QueryDeveloperTraceToolSelection[];
755
- selectedAlternatives: QueryDeveloperTraceToolSelection[];
756
- mergedTools: QueryDeveloperTraceToolSelection[];
757
- usingPaidFallback: boolean;
758
- branchPlan: QueryPlanningTraceDiagnostic | null;
759
- }
760
729
  interface QueryCompletenessRepairEvent {
761
730
  attempt: number;
762
731
  outcome: "attempted" | "skipped_by_guardrail" | "skipped_no_retry_budget" | "skipped_needs_different_tools" | "skipped_no_retry_path" | "patch_failed" | "replan_failed" | "patched" | "replanned";
@@ -777,16 +746,15 @@ interface QueryCompletenessRepairEvent {
777
746
  }>;
778
747
  }
779
748
  /**
780
- * Rich developer-trace diagnostics for discovery-first orchestration internals.
749
+ * Rich developer-trace diagnostics for managed query-runtime internals.
781
750
  */
782
751
  interface QueryDeveloperTraceDiagnostics {
783
752
  selection: {
784
- selectedDepth: string;
785
- deepMode: string | null;
753
+ selectedPolicy: string;
786
754
  debugScoutDeepMode: string | null;
787
755
  plannerReasoningStage: string;
788
756
  scoutEnabled: boolean;
789
- preserveFastOneShot: boolean;
757
+ oneShotBias: boolean;
790
758
  candidateMethodCount: number;
791
759
  scoutProbeStatus: string;
792
760
  scoutProbeAdequacy: string;
@@ -801,8 +769,7 @@ interface QueryDeveloperTraceDiagnostics {
801
769
  scoutPrePlanProbeBudgetReasonCode: string | null;
802
770
  scoutChangedInitialPlan: boolean;
803
771
  scoutChangedPlannerReasoningStage: boolean;
804
- scoutInitialSelectedDepth: string;
805
- scoutInitialDeepMode: string | null;
772
+ scoutInitialSelectedPolicy: string;
806
773
  scoutInitialPlannerReasoningStage: string;
807
774
  scoutInitialReasonCode: string;
808
775
  scoutFinalReasonCode: string;
@@ -812,9 +779,7 @@ interface QueryDeveloperTraceDiagnostics {
812
779
  scoutLlmSelectionLatencyMs: number | null;
813
780
  selectedTools: QueryDeveloperTraceToolSelection[];
814
781
  };
815
- planning: {
816
- initial: QueryPlanningTraceDiagnostic;
817
- };
782
+ executionContract?: QueryPlanningTraceDiagnostic;
818
783
  cost?: {
819
784
  planningCostUsd: number;
820
785
  initialExecutionCostUsd: number;
@@ -824,13 +789,20 @@ interface QueryDeveloperTraceDiagnostics {
824
789
  toolCostUsd: number;
825
790
  totalChargedUsd: number;
826
791
  };
827
- completeness: {
792
+ verification: {
828
793
  evaluations: unknown[];
829
794
  repairEvents: QueryCompletenessRepairEvent[];
830
795
  triggerNeedsDifferentTools: boolean;
831
796
  triggerMissingCapability: string | null;
832
797
  };
833
- rediscovery: QueryRediscoveryTraceDiagnostic | null;
798
+ execution?: {
799
+ reasoningEnabled: boolean;
800
+ receivedReasoning: boolean;
801
+ reasoningChars: number;
802
+ scoutEvidenceInjected: boolean;
803
+ stepBudget: number;
804
+ completedStepCount: number;
805
+ };
834
806
  clarification?: QueryClarificationDiagnostics;
835
807
  contributorSearches?: ContributorSearchTraceRecord[];
836
808
  [key: string]: unknown;
@@ -221,7 +221,7 @@ interface McpToolRateLimitHints {
221
221
  supportsBulk?: boolean;
222
222
  /** Preferred batch-oriented methods to call instead of fan-out loops */
223
223
  recommendedBatchTools?: string[];
224
- /** Optional human-readable notes for planning */
224
+ /** Optional human-readable notes for execution behavior */
225
225
  notes?: string;
226
226
  }
227
227
  type DiscoveryMode = "query" | "execute";
@@ -237,7 +237,7 @@ interface McpToolMeta {
237
237
  surface?: McpToolSurface;
238
238
  /** Whether this method can be selected in query mode */
239
239
  queryEligible?: boolean;
240
- /** Declared latency class for planner/runtime gating */
240
+ /** Declared latency class for metadata-scout/runtime gating */
241
241
  latencyClass?: McpToolLatencyClass;
242
242
  /** Method-level pricing metadata */
243
243
  pricing?: McpToolPricingMeta;
@@ -248,7 +248,7 @@ interface McpToolMeta {
248
248
  /** Context injection requirements handled by the Context runtime */
249
249
  contextRequirements?: string[];
250
250
  /**
251
- * Optional planner/runtime pacing hints.
251
+ * Optional metadata-scout/runtime pacing hints.
252
252
  * Tool contributors can publish these to reduce rate-limit failures.
253
253
  */
254
254
  rateLimit?: McpToolRateLimitHints;
@@ -512,8 +512,6 @@ interface ExecutionResult<T = unknown> {
512
512
  /** Execution duration in milliseconds */
513
513
  durationMs: number;
514
514
  }
515
- /** Supported orchestration depth modes for query execution. */
516
- type QueryDepth = "fast" | "auto" | "deep";
517
515
  type QueryDeepMode = "deep" | "deep-light" | "deep-heavy";
518
516
  type QueryClarificationPolicy = "return" | "auto" | "error";
519
517
  type QueryOutcomeType = "answer" | "clarification_required" | "capability_miss";
@@ -609,19 +607,22 @@ interface QueryClarificationDiagnostics {
609
607
  * Options for the agentic query endpoint (pay-per-response).
610
608
  *
611
609
  * Unlike `execute()` which calls a single tool once, `query()` sends a
612
- * natural-language question and lets the server handle discovery-first
613
- * orchestration (`discover/probe -> plan-from-evidence -> execute ->
614
- * bounded fallback`) plus synthesis.
610
+ * natural-language question and lets the server handle the live librarian
611
+ * pipeline (`discover -> select -> metadata scout -> clarify if needed ->
612
+ * iterative execute -> synthesize -> settle`).
615
613
  * One flat fee covers up to 100 MCP skill calls per tool.
616
614
  */
617
615
  interface QueryOptions {
618
616
  /** The natural-language question to answer */
619
617
  query: string;
620
618
  /**
621
- * How the SDK should handle clarification-required pre-plan situations:
619
+ * How the SDK should handle clarification-required situations:
622
620
  * - `return`: surface a structured clarification result to the caller
623
621
  * - `auto`: enable clarification auto-select and continue with the server's deterministic recommended option
624
622
  * - `error`: turn structured clarification/capability outcomes into terminal errors
623
+ *
624
+ * Default behavior is surface-dependent: headless SDK and MCP callers default
625
+ * to `auto`, while first-party chat defaults to `return`.
625
626
  */
626
627
  clarificationPolicy?: QueryClarificationPolicy;
627
628
  /**
@@ -677,23 +678,10 @@ interface QueryOptions {
677
678
  /**
678
679
  * Include machine-readable developer trace output for this query response.
679
680
  * When enabled, the server may return summary counters plus diagnostics
680
- * for lane selection, scout probe adequacy, and bounded fallback behavior.
681
+ * for lane selection, metadata scout adequacy, clarification, and iterative
682
+ * execution behavior.
681
683
  */
682
684
  includeDeveloperTrace?: boolean;
683
- /**
684
- * Query orchestration depth mode:
685
- * - `fast`: lower-latency path
686
- * - `auto`: server decides between fast/deep
687
- * - `deep`: full completeness-oriented path
688
- */
689
- queryDepth?: QueryDepth;
690
- /**
691
- * Development/testing only: force the server's internal deep lane.
692
- * `deep` is the canonical value. Legacy `deep-light` / `deep-heavy`
693
- * aliases are still accepted temporarily for compatibility and normalize
694
- * to the same runtime lane. Invalid when `queryDepth` is `fast`.
695
- */
696
- debugScoutDeepMode?: QueryDeepMode;
697
685
  /**
698
686
  * Optional idempotency key (UUID recommended).
699
687
  * Reuse the same key when retrying the same logical request.
@@ -719,7 +707,7 @@ interface QueryDeveloperTraceLoopInfo {
719
707
  [key: string]: unknown;
720
708
  }
721
709
  /**
722
- * Tool selection metadata attached to discovery/planning diagnostics.
710
+ * Tool selection metadata attached to discovery and metadata-scout diagnostics.
723
711
  */
724
712
  interface QueryDeveloperTraceToolSelection {
725
713
  toolId: string;
@@ -730,7 +718,7 @@ interface QueryDeveloperTraceToolSelection {
730
718
  priceUsd?: string;
731
719
  }
732
720
  /**
733
- * Initial planner diagnostic details.
721
+ * Execution-contract details handed to the iterative runtime.
734
722
  */
735
723
  interface QueryPlanningTraceDiagnostic {
736
724
  plannerQuery: string;
@@ -738,25 +726,6 @@ interface QueryPlanningTraceDiagnostic {
738
726
  scoutEvidencePromptBlock: string | null;
739
727
  allowedModules: string[];
740
728
  }
741
- /**
742
- * Rediscovery/fallback diagnostic details.
743
- */
744
- interface QueryRediscoveryTraceDiagnostic {
745
- considered: boolean;
746
- executed: boolean;
747
- skipReason: string | null;
748
- missingCapability: string | null;
749
- rediscoveryQuery: string | null;
750
- capabilityLooksLikeSearchNeed: boolean;
751
- allowSearchFallbackOnElapsedCap: boolean;
752
- searchFallbackUsed: boolean;
753
- preRediscoveryBudgetReasonCode: string | null;
754
- candidateSearchResults: QueryDeveloperTraceToolSelection[];
755
- selectedAlternatives: QueryDeveloperTraceToolSelection[];
756
- mergedTools: QueryDeveloperTraceToolSelection[];
757
- usingPaidFallback: boolean;
758
- branchPlan: QueryPlanningTraceDiagnostic | null;
759
- }
760
729
  interface QueryCompletenessRepairEvent {
761
730
  attempt: number;
762
731
  outcome: "attempted" | "skipped_by_guardrail" | "skipped_no_retry_budget" | "skipped_needs_different_tools" | "skipped_no_retry_path" | "patch_failed" | "replan_failed" | "patched" | "replanned";
@@ -777,16 +746,15 @@ interface QueryCompletenessRepairEvent {
777
746
  }>;
778
747
  }
779
748
  /**
780
- * Rich developer-trace diagnostics for discovery-first orchestration internals.
749
+ * Rich developer-trace diagnostics for managed query-runtime internals.
781
750
  */
782
751
  interface QueryDeveloperTraceDiagnostics {
783
752
  selection: {
784
- selectedDepth: string;
785
- deepMode: string | null;
753
+ selectedPolicy: string;
786
754
  debugScoutDeepMode: string | null;
787
755
  plannerReasoningStage: string;
788
756
  scoutEnabled: boolean;
789
- preserveFastOneShot: boolean;
757
+ oneShotBias: boolean;
790
758
  candidateMethodCount: number;
791
759
  scoutProbeStatus: string;
792
760
  scoutProbeAdequacy: string;
@@ -801,8 +769,7 @@ interface QueryDeveloperTraceDiagnostics {
801
769
  scoutPrePlanProbeBudgetReasonCode: string | null;
802
770
  scoutChangedInitialPlan: boolean;
803
771
  scoutChangedPlannerReasoningStage: boolean;
804
- scoutInitialSelectedDepth: string;
805
- scoutInitialDeepMode: string | null;
772
+ scoutInitialSelectedPolicy: string;
806
773
  scoutInitialPlannerReasoningStage: string;
807
774
  scoutInitialReasonCode: string;
808
775
  scoutFinalReasonCode: string;
@@ -812,9 +779,7 @@ interface QueryDeveloperTraceDiagnostics {
812
779
  scoutLlmSelectionLatencyMs: number | null;
813
780
  selectedTools: QueryDeveloperTraceToolSelection[];
814
781
  };
815
- planning: {
816
- initial: QueryPlanningTraceDiagnostic;
817
- };
782
+ executionContract?: QueryPlanningTraceDiagnostic;
818
783
  cost?: {
819
784
  planningCostUsd: number;
820
785
  initialExecutionCostUsd: number;
@@ -824,13 +789,20 @@ interface QueryDeveloperTraceDiagnostics {
824
789
  toolCostUsd: number;
825
790
  totalChargedUsd: number;
826
791
  };
827
- completeness: {
792
+ verification: {
828
793
  evaluations: unknown[];
829
794
  repairEvents: QueryCompletenessRepairEvent[];
830
795
  triggerNeedsDifferentTools: boolean;
831
796
  triggerMissingCapability: string | null;
832
797
  };
833
- rediscovery: QueryRediscoveryTraceDiagnostic | null;
798
+ execution?: {
799
+ reasoningEnabled: boolean;
800
+ receivedReasoning: boolean;
801
+ reasoningChars: number;
802
+ scoutEvidenceInjected: boolean;
803
+ stepBudget: number;
804
+ completedStepCount: number;
805
+ };
834
806
  clarification?: QueryClarificationDiagnostics;
835
807
  contributorSearches?: ContributorSearchTraceRecord[];
836
808
  [key: string]: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctxprotocol/sdk",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Official TypeScript SDK for the Context Protocol - Discover and execute AI tools programmatically",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",