@ctxprotocol/sdk 0.12.0 → 0.13.1

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 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 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 -> iterative execute (with in-loop
612
+ * clarification if needed) -> 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,9 @@ 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 tool selection, clarification, and iterative execution behavior.
681
682
  */
682
683
  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
684
  /**
698
685
  * Optional idempotency key (UUID recommended).
699
686
  * Reuse the same key when retrying the same logical request.
@@ -719,7 +706,7 @@ interface QueryDeveloperTraceLoopInfo {
719
706
  [key: string]: unknown;
720
707
  }
721
708
  /**
722
- * Tool selection metadata attached to discovery/planning diagnostics.
709
+ * Tool selection metadata attached to discovery diagnostics.
723
710
  */
724
711
  interface QueryDeveloperTraceToolSelection {
725
712
  toolId: string;
@@ -730,7 +717,7 @@ interface QueryDeveloperTraceToolSelection {
730
717
  priceUsd?: string;
731
718
  }
732
719
  /**
733
- * Initial planner diagnostic details.
720
+ * Execution-contract details handed to the iterative runtime.
734
721
  */
735
722
  interface QueryPlanningTraceDiagnostic {
736
723
  plannerQuery: string;
@@ -738,25 +725,6 @@ interface QueryPlanningTraceDiagnostic {
738
725
  scoutEvidencePromptBlock: string | null;
739
726
  allowedModules: string[];
740
727
  }
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
728
  interface QueryCompletenessRepairEvent {
761
729
  attempt: number;
762
730
  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 +745,15 @@ interface QueryCompletenessRepairEvent {
777
745
  }>;
778
746
  }
779
747
  /**
780
- * Rich developer-trace diagnostics for discovery-first orchestration internals.
748
+ * Rich developer-trace diagnostics for managed query-runtime internals.
781
749
  */
782
750
  interface QueryDeveloperTraceDiagnostics {
783
751
  selection: {
784
- selectedDepth: string;
785
- deepMode: string | null;
752
+ selectedPolicy: string;
786
753
  debugScoutDeepMode: string | null;
787
754
  plannerReasoningStage: string;
788
755
  scoutEnabled: boolean;
789
- preserveFastOneShot: boolean;
756
+ oneShotBias: boolean;
790
757
  candidateMethodCount: number;
791
758
  scoutProbeStatus: string;
792
759
  scoutProbeAdequacy: string;
@@ -801,8 +768,7 @@ interface QueryDeveloperTraceDiagnostics {
801
768
  scoutPrePlanProbeBudgetReasonCode: string | null;
802
769
  scoutChangedInitialPlan: boolean;
803
770
  scoutChangedPlannerReasoningStage: boolean;
804
- scoutInitialSelectedDepth: string;
805
- scoutInitialDeepMode: string | null;
771
+ scoutInitialSelectedPolicy: string;
806
772
  scoutInitialPlannerReasoningStage: string;
807
773
  scoutInitialReasonCode: string;
808
774
  scoutFinalReasonCode: string;
@@ -812,9 +778,7 @@ interface QueryDeveloperTraceDiagnostics {
812
778
  scoutLlmSelectionLatencyMs: number | null;
813
779
  selectedTools: QueryDeveloperTraceToolSelection[];
814
780
  };
815
- planning: {
816
- initial: QueryPlanningTraceDiagnostic;
817
- };
781
+ executionContract?: QueryPlanningTraceDiagnostic;
818
782
  cost?: {
819
783
  planningCostUsd: number;
820
784
  initialExecutionCostUsd: number;
@@ -824,13 +788,20 @@ interface QueryDeveloperTraceDiagnostics {
824
788
  toolCostUsd: number;
825
789
  totalChargedUsd: number;
826
790
  };
827
- completeness: {
791
+ verification: {
828
792
  evaluations: unknown[];
829
793
  repairEvents: QueryCompletenessRepairEvent[];
830
794
  triggerNeedsDifferentTools: boolean;
831
795
  triggerMissingCapability: string | null;
832
796
  };
833
- rediscovery: QueryRediscoveryTraceDiagnostic | null;
797
+ execution?: {
798
+ reasoningEnabled: boolean;
799
+ receivedReasoning: boolean;
800
+ reasoningChars: number;
801
+ scoutEvidenceInjected: boolean;
802
+ stepBudget: number;
803
+ completedStepCount: number;
804
+ };
834
805
  clarification?: QueryClarificationDiagnostics;
835
806
  contributorSearches?: ContributorSearchTraceRecord[];
836
807
  [key: string]: unknown;
@@ -950,8 +921,8 @@ interface QueryForkReference extends QueryAttemptReference {
950
921
  }
951
922
  /**
952
923
  * Public continuation state returned by headless Query responses.
953
- * Internal selected-tool lineage, Scout reuse, and clarification snapshots
954
- * remain durable server state but are not exposed as chat-style payloads.
924
+ * Internal selected-tool lineage and clarification snapshots remain durable
925
+ * server state but are not exposed as chat-style payloads.
955
926
  */
956
927
  interface QuerySessionState {
957
928
  sessionId: string;
@@ -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 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 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 -> iterative execute (with in-loop
612
+ * clarification if needed) -> 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,9 @@ 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 tool selection, clarification, and iterative execution behavior.
681
682
  */
682
683
  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
684
  /**
698
685
  * Optional idempotency key (UUID recommended).
699
686
  * Reuse the same key when retrying the same logical request.
@@ -719,7 +706,7 @@ interface QueryDeveloperTraceLoopInfo {
719
706
  [key: string]: unknown;
720
707
  }
721
708
  /**
722
- * Tool selection metadata attached to discovery/planning diagnostics.
709
+ * Tool selection metadata attached to discovery diagnostics.
723
710
  */
724
711
  interface QueryDeveloperTraceToolSelection {
725
712
  toolId: string;
@@ -730,7 +717,7 @@ interface QueryDeveloperTraceToolSelection {
730
717
  priceUsd?: string;
731
718
  }
732
719
  /**
733
- * Initial planner diagnostic details.
720
+ * Execution-contract details handed to the iterative runtime.
734
721
  */
735
722
  interface QueryPlanningTraceDiagnostic {
736
723
  plannerQuery: string;
@@ -738,25 +725,6 @@ interface QueryPlanningTraceDiagnostic {
738
725
  scoutEvidencePromptBlock: string | null;
739
726
  allowedModules: string[];
740
727
  }
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
728
  interface QueryCompletenessRepairEvent {
761
729
  attempt: number;
762
730
  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 +745,15 @@ interface QueryCompletenessRepairEvent {
777
745
  }>;
778
746
  }
779
747
  /**
780
- * Rich developer-trace diagnostics for discovery-first orchestration internals.
748
+ * Rich developer-trace diagnostics for managed query-runtime internals.
781
749
  */
782
750
  interface QueryDeveloperTraceDiagnostics {
783
751
  selection: {
784
- selectedDepth: string;
785
- deepMode: string | null;
752
+ selectedPolicy: string;
786
753
  debugScoutDeepMode: string | null;
787
754
  plannerReasoningStage: string;
788
755
  scoutEnabled: boolean;
789
- preserveFastOneShot: boolean;
756
+ oneShotBias: boolean;
790
757
  candidateMethodCount: number;
791
758
  scoutProbeStatus: string;
792
759
  scoutProbeAdequacy: string;
@@ -801,8 +768,7 @@ interface QueryDeveloperTraceDiagnostics {
801
768
  scoutPrePlanProbeBudgetReasonCode: string | null;
802
769
  scoutChangedInitialPlan: boolean;
803
770
  scoutChangedPlannerReasoningStage: boolean;
804
- scoutInitialSelectedDepth: string;
805
- scoutInitialDeepMode: string | null;
771
+ scoutInitialSelectedPolicy: string;
806
772
  scoutInitialPlannerReasoningStage: string;
807
773
  scoutInitialReasonCode: string;
808
774
  scoutFinalReasonCode: string;
@@ -812,9 +778,7 @@ interface QueryDeveloperTraceDiagnostics {
812
778
  scoutLlmSelectionLatencyMs: number | null;
813
779
  selectedTools: QueryDeveloperTraceToolSelection[];
814
780
  };
815
- planning: {
816
- initial: QueryPlanningTraceDiagnostic;
817
- };
781
+ executionContract?: QueryPlanningTraceDiagnostic;
818
782
  cost?: {
819
783
  planningCostUsd: number;
820
784
  initialExecutionCostUsd: number;
@@ -824,13 +788,20 @@ interface QueryDeveloperTraceDiagnostics {
824
788
  toolCostUsd: number;
825
789
  totalChargedUsd: number;
826
790
  };
827
- completeness: {
791
+ verification: {
828
792
  evaluations: unknown[];
829
793
  repairEvents: QueryCompletenessRepairEvent[];
830
794
  triggerNeedsDifferentTools: boolean;
831
795
  triggerMissingCapability: string | null;
832
796
  };
833
- rediscovery: QueryRediscoveryTraceDiagnostic | null;
797
+ execution?: {
798
+ reasoningEnabled: boolean;
799
+ receivedReasoning: boolean;
800
+ reasoningChars: number;
801
+ scoutEvidenceInjected: boolean;
802
+ stepBudget: number;
803
+ completedStepCount: number;
804
+ };
834
805
  clarification?: QueryClarificationDiagnostics;
835
806
  contributorSearches?: ContributorSearchTraceRecord[];
836
807
  [key: string]: unknown;
@@ -950,8 +921,8 @@ interface QueryForkReference extends QueryAttemptReference {
950
921
  }
951
922
  /**
952
923
  * Public continuation state returned by headless Query responses.
953
- * Internal selected-tool lineage, Scout reuse, and clarification snapshots
954
- * remain durable server state but are not exposed as chat-style payloads.
924
+ * Internal selected-tool lineage and clarification snapshots remain durable
925
+ * server state but are not exposed as chat-style payloads.
955
926
  */
956
927
  interface QuerySessionState {
957
928
  sessionId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctxprotocol/sdk",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
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",