@botiverse/kimi-code-sdk 0.20.1 → 0.21.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.
package/dist/index.d.mts CHANGED
@@ -22,6 +22,7 @@ import type { OAuthClientMetadata } from '@modelcontextprotocol/sdk/shared/auth.
22
22
  import type { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
23
23
  import type { OAuthDiscoveryState } from '@modelcontextprotocol/sdk/client/auth.js';
24
24
  import type { OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
25
+ import { PluginCommandActivatedEvent } from '@moonshot-ai/protocol';
25
26
  import type { Readable } from 'node:stream';
26
27
  import { SessionMetaUpdatedEvent } from '@moonshot-ai/protocol';
27
28
  import type { SessionWarning } from '@moonshot-ai/protocol';
@@ -52,6 +53,18 @@ import { WarningEvent } from '@moonshot-ai/protocol';
52
53
  import type { Writable } from 'node:stream';
53
54
  import { z } from 'zod';
54
55
 
56
+ declare interface ActivatePluginCommandPayload {
57
+ readonly pluginId: string;
58
+ readonly commandName: string;
59
+ readonly args?: string | undefined;
60
+ }
61
+
62
+ declare interface ActivatePluginCommandRpcInput extends SessionIdRpcInput {
63
+ readonly pluginId: string;
64
+ readonly commandName: string;
65
+ readonly args?: string | undefined;
66
+ }
67
+
55
68
  declare interface ActivateSkillPayload {
56
69
  readonly name: string;
57
70
  readonly args?: string | undefined;
@@ -100,6 +113,7 @@ declare class Agent {
100
113
  readonly rpc?: Partial<SDKAgentRPC>;
101
114
  readonly toolServices?: ToolServices;
102
115
  readonly pluginSessionStarts: readonly EnabledPluginSessionStart[];
116
+ readonly pluginCommands: readonly PluginCommandDef[];
103
117
  readonly rawGenerate: typeof generate;
104
118
  readonly modelProvider?: ModelProvider;
105
119
  readonly subagentHost?: SessionSubagentHost;
@@ -128,13 +142,25 @@ declare class Agent {
128
142
  readonly goal: GoalMode;
129
143
  readonly replayBuilder: ReplayBuilder;
130
144
  private additionalDirs;
145
+ private activeProfile?;
146
+ private brandHome?;
147
+ private readonly systemPromptContextProvider?;
131
148
  constructor(options: AgentOptions);
132
149
  setKaos(kaos: Kaos): void;
133
150
  getAdditionalDirs(): readonly string[];
134
151
  setAdditionalDirs(additionalDirs: readonly string[]): void;
135
152
  get generate(): typeof generate;
136
153
  get llm(): KosongLLM;
137
- useProfile(profile: ResolvedAgentProfile, context?: PreparedSystemPromptContext): void;
154
+ useProfile(profile: ResolvedAgentProfile, context?: PreparedSystemPromptContext, brandHome?: string): void;
155
+ setActiveProfile(profile: ResolvedAgentProfile, brandHome?: string): void;
156
+ /**
157
+ * Re-render the system prompt with freshly gathered runtime context (cwd
158
+ * listing, AGENTS.md, additional-dirs info, skill list). Called after
159
+ * compaction so the post-compaction turns do not keep a snapshot captured
160
+ * at session bootstrap. Invalidates the prompt-cache prefix by design.
161
+ */
162
+ refreshSystemPrompt(): Promise<void>;
163
+ private updateSystemPromptFromProfile;
138
164
  resume(options?: AgentRecordsReplayOptions): Promise<{
139
165
  warning?: string;
140
166
  }>;
@@ -170,6 +196,7 @@ declare interface AgentAPI {
170
196
  detachBackground: (payload: DetachBackgroundPayload) => BackgroundTaskInfo | undefined;
171
197
  clearContext: (payload: EmptyPayload) => void;
172
198
  activateSkill: (payload: ActivateSkillPayload) => void;
199
+ activatePluginCommand: (payload: ActivatePluginCommandPayload) => void;
173
200
  startBtw: (payload: EmptyPayload) => string;
174
201
  createGoal: (payload: CreateGoalPayload) => GoalSnapshot;
175
202
  getGoal: (payload: EmptyPayload) => GoalToolResult;
@@ -202,7 +229,7 @@ declare interface AgentConfigData {
202
229
  modelAlias?: string;
203
230
  modelCapabilities: ModelCapability;
204
231
  profileName?: string;
205
- thinkingLevel: string;
232
+ thinkingEffort: string;
206
233
  systemPrompt: string;
207
234
  }
208
235
 
@@ -210,7 +237,7 @@ declare type AgentConfigUpdateData = Partial<{
210
237
  cwd: string;
211
238
  modelAlias: string;
212
239
  profileName: string;
213
- thinkingLevel: string;
240
+ thinkingEffort: string;
214
241
  systemPrompt: string;
215
242
  }>;
216
243
 
@@ -248,9 +275,11 @@ declare interface AgentOptions {
248
275
  readonly log?: Logger;
249
276
  readonly telemetry?: TelemetryClient | undefined;
250
277
  readonly pluginSessionStarts?: readonly EnabledPluginSessionStart[];
278
+ readonly pluginCommands?: readonly PluginCommandDef[];
251
279
  readonly experimentalFlags?: ExperimentalFlagResolver;
252
280
  readonly replay?: ReplayBuilderOptions;
253
281
  readonly additionalDirs?: readonly string[];
282
+ readonly systemPromptContextProvider?: (() => Promise<PreparedSystemPromptContext>) | undefined;
254
283
  }
255
284
 
256
285
  declare type AgentRecord = {
@@ -431,6 +460,15 @@ declare interface AnthropicOptions {
431
460
  * encode a parseable Claude version. Leave undefined to infer from the name.
432
461
  */
433
462
  adaptiveThinking?: boolean | undefined;
463
+ /**
464
+ * Use the Anthropic **beta** Messages API (`client.beta.messages.create`,
465
+ * `POST /v1/messages?beta=true`) instead of the standard Messages API.
466
+ *
467
+ * Beta features (`betaFeatures`) are then sent via the request `betas`
468
+ * field rather than the `anthropic-beta` header. Defaults to false, which
469
+ * keeps the standard endpoint + header behavior.
470
+ */
471
+ betaApi?: boolean | undefined;
434
472
  clientFactory?: (auth: ProviderRequestAuth) => Anthropic;
435
473
  }
436
474
 
@@ -942,7 +980,7 @@ declare interface ChatProvider {
942
980
  readonly name: string;
943
981
  /** Model name passed to the upstream API (e.g. `"moonshot-v1-auto"`). */
944
982
  readonly modelName: string;
945
- /** Current thinking-effort level, or `null` if thinking is not configured. */
983
+ /** Current thinking effort, or `null` if thinking is not configured. */
946
984
  readonly thinkingEffort: ThinkingEffort | null;
947
985
  /**
948
986
  * Send a conversation to the LLM and return a streamed response.
@@ -1010,11 +1048,46 @@ export { CompactionCancelledEvent }
1010
1048
 
1011
1049
  export { CompactionCompletedEvent }
1012
1050
 
1051
+ /**
1052
+ * Inputs `ContextMemory.applyCompaction` needs to derive a `CompactionResult`.
1053
+ * `tokensAfter` / `keptUserMessageCount` / `droppedCount` are optional: the live
1054
+ * path fills in what it knows, while restore passes the persisted record so its
1055
+ * historical values are preserved verbatim.
1056
+ */
1057
+ declare type CompactionInput = Pick<CompactionResult, 'summary' | 'compactedCount' | 'tokensBefore'> & Partial<Pick<CompactionResult, 'contextSummary' | 'tokensAfter' | 'keptUserMessageCount' | 'droppedCount'>>;
1058
+
1013
1059
  export declare interface CompactionResult {
1060
+ /** Human-facing summary text produced by the compaction model. */
1014
1061
  summary: string;
1062
+ /**
1063
+ * Exact summary message stored in the live model context. It includes the
1064
+ * compaction prefix that tells the next model this is handoff context rather
1065
+ * than a real user prompt. Optional for backward compatibility with older
1066
+ * wire records, where `summary` was also the model-context text.
1067
+ */
1068
+ contextSummary?: string;
1015
1069
  compactedCount: number;
1016
1070
  tokensBefore: number;
1017
1071
  tokensAfter: number;
1072
+ /**
1073
+ * Number of real user messages kept verbatim ahead of the summary in the
1074
+ * post-compaction live context. Written by `ContextMemory.applyCompaction`
1075
+ * (the single derivation point for the post-compaction shape) so the
1076
+ * wire-transcript reducer can reproduce the live folded length without
1077
+ * re-deriving it from the full transcript. Optional for backward
1078
+ * compatibility with older wire records.
1079
+ */
1080
+ keptUserMessageCount?: number;
1081
+ /**
1082
+ * Number of oldest messages trimmed from the summarizer input when the
1083
+ * compaction request itself overflowed the model window. These messages are
1084
+ * not covered by the produced summary — a real-user message among them may
1085
+ * still be retained verbatim in the live context via `keptUserMessageCount`,
1086
+ * but assistant/tool messages are lost. Surfacing the count lets records and
1087
+ * telemetry report the summary's blind spot honestly. Optional for backward
1088
+ * compatibility with older wire records.
1089
+ */
1090
+ droppedCount?: number;
1018
1091
  }
1019
1092
 
1020
1093
  declare type CompactionSource = 'manual' | 'auto';
@@ -1024,10 +1097,9 @@ export { CompactionStartedEvent }
1024
1097
  declare interface CompactionStrategy {
1025
1098
  shouldCompact(usedSize: number): boolean;
1026
1099
  shouldBlock(usedSize: number): boolean;
1027
- computeCompactCount(messages: readonly Message[], source: CompactionSource): number;
1028
- reduceCompactOnOverflow(messages: readonly Message[]): number;
1029
1100
  readonly checkAfterStep: boolean;
1030
1101
  readonly maxCompactionPerTurn: number;
1102
+ readonly maxOverflowCompactionAttempts: number;
1031
1103
  }
1032
1104
 
1033
1105
  declare interface CompactionSummaryOrigin {
@@ -1056,7 +1128,7 @@ declare class ConfigState {
1056
1128
  private _cwd;
1057
1129
  private _modelAlias;
1058
1130
  private _profileName;
1059
- private _thinkingLevel;
1131
+ private _thinkingEffort;
1060
1132
  private _systemPrompt;
1061
1133
  constructor(agent: Agent);
1062
1134
  update(changed: AgentConfigUpdateData): void;
@@ -1068,8 +1140,8 @@ declare class ConfigState {
1068
1140
  get provider(): ChatProvider;
1069
1141
  get model(): string;
1070
1142
  get modelAlias(): string | undefined;
1071
- get thinkingLevel(): ThinkingEffort;
1072
- private get alwaysThinkingModel();
1143
+ get thinkingEffort(): ThinkingEffort;
1144
+ private get currentModel();
1073
1145
  get profileName(): string | undefined;
1074
1146
  get systemPrompt(): string;
1075
1147
  get modelCapabilities(): ModelCapability;
@@ -1096,6 +1168,7 @@ declare class ContextMemory {
1096
1168
  private pendingToolResultIds;
1097
1169
  private deferredMessages;
1098
1170
  private _lastAssistantAt;
1171
+ private lastProjectionRepairSignature;
1099
1172
  constructor(agent: Agent);
1100
1173
  get lastAssistantAt(): number | null;
1101
1174
  appendUserMessage(content: readonly ContentPart[], origin?: PromptOrigin): void;
@@ -1115,13 +1188,15 @@ declare class ContextMemory {
1115
1188
  popMatchedMessage(matcher: (origin: PromptOrigin | undefined) => boolean): boolean;
1116
1189
  clear(): void;
1117
1190
  undo(count: number): void;
1118
- applyCompaction(result: CompactionResult): void;
1191
+ applyCompaction(input: CompactionInput): CompactionResult;
1119
1192
  data(): AgentContextData;
1120
1193
  get tokenCount(): number;
1121
1194
  get tokenCountWithPending(): number;
1122
1195
  get history(): readonly ContextMessage[];
1123
- project(messages: readonly ContextMessage[]): Message[];
1196
+ project(messages: readonly ContextMessage[], options?: ProjectOptions): Message[];
1197
+ private reportProjectionRepairs;
1124
1198
  get messages(): Message[];
1199
+ get strictMessages(): Message[];
1125
1200
  useProjectedHistoryFrom(source: ContextMemory): void;
1126
1201
  finishResume(): void;
1127
1202
  private closePendingToolResults;
@@ -1903,7 +1978,7 @@ declare const FLAG_DEFINITIONS: readonly [{
1903
1978
  readonly title: "Micro compaction";
1904
1979
  readonly description: "Trim older large tool results from context while keeping recent conversation intact.";
1905
1980
  readonly env: "KIMI_CODE_EXPERIMENTAL_MICRO_COMPACTION";
1906
- readonly default: true;
1981
+ readonly default: false;
1907
1982
  readonly surface: "core";
1908
1983
  }];
1909
1984
 
@@ -1962,13 +2037,21 @@ declare class FullCompaction {
1962
2037
  promise: Promise<void>;
1963
2038
  blockedByTurn: boolean;
1964
2039
  } | null;
2040
+ private readonly observedMaxContextTokensByModel;
2041
+ private lastCompactedTokenCount;
2042
+ private consecutiveOverflowCompactions;
1965
2043
  protected readonly strategy: CompactionStrategy;
1966
2044
  constructor(agent: Agent, strategy?: CompactionStrategy);
1967
2045
  get isCompacting(): boolean;
2046
+ getEffectiveMaxContextTokens(): number;
2047
+ estimateCurrentRequestTokens(): number;
2048
+ shouldRecoverFromContextOverflow(error: unknown, estimatedRequestTokens?: number): boolean;
2049
+ observeContextOverflow(estimatedRequestTokens: number): void;
1968
2050
  begin(data: Readonly<CompactionBeginData>): void;
1969
2051
  cancel(): void;
1970
2052
  markCompleted(): void;
1971
2053
  private get tokenCountWithPending();
2054
+ private estimateRequestTokens;
1972
2055
  resetForTurn(): void;
1973
2056
  handleOverflowError(signal: AbortSignal, error: unknown): Promise<void>;
1974
2057
  beforeStep(signal: AbortSignal): Promise<void>;
@@ -1977,10 +2060,11 @@ declare class FullCompaction {
1977
2060
  private beginAutoCompaction;
1978
2061
  private block;
1979
2062
  private compactionWorker;
2063
+ private buildInstruction;
2064
+ private postProcessSummary;
1980
2065
  private compactionRound;
1981
2066
  private triggerPreCompactHook;
1982
2067
  private triggerPostCompactHook;
1983
- private postProcessSummary;
1984
2068
  }
1985
2069
 
1986
2070
  /**
@@ -2044,11 +2128,23 @@ declare interface GenerateOptions {
2044
2128
  * provider adapter's generate call.
2045
2129
  */
2046
2130
  onRequestStart?: () => void;
2131
+ /**
2132
+ * Host-side instrumentation hook fired by the provider adapter immediately
2133
+ * before it dispatches the network request to the upstream API. The window
2134
+ * between {@link onRequestStart} and this hook is in-process request-building
2135
+ * time (message serialization, param assembly) spent by the client; the
2136
+ * window between this hook and the first streamed part is network + server
2137
+ * time. Splitting time-to-first-token across this boundary lets hosts
2138
+ * attribute latency to the client vs. the API server.
2139
+ */
2140
+ onRequestSent?: () => void;
2047
2141
  /**
2048
2142
  * Host-side instrumentation hook fired after the provider stream is fully
2049
- * drained, before post-processing the assembled response.
2143
+ * drained, before post-processing the assembled response. Receives the
2144
+ * {@link StreamDecodeStats} accounting accumulated across the stream when at
2145
+ * least one part was streamed, or `undefined` for an empty stream.
2050
2146
  */
2051
- onStreamEnd?: () => void;
2147
+ onStreamEnd?: (stats?: StreamDecodeStats) => void;
2052
2148
  }
2053
2149
 
2054
2150
  /**
@@ -2094,7 +2190,6 @@ declare interface GenerationKwargs {
2094
2190
  presence_penalty?: number | undefined;
2095
2191
  frequency_penalty?: number | undefined;
2096
2192
  stop?: string | string[] | undefined;
2097
- reasoning_effort?: string | undefined;
2098
2193
  prompt_cache_key?: string | undefined;
2099
2194
  extra_body?: ExtraBody;
2100
2195
  }
@@ -2385,6 +2480,7 @@ declare interface GoogleGenAIOptions {
2385
2480
  project?: string | undefined;
2386
2481
  location?: string | undefined;
2387
2482
  stream?: boolean | undefined;
2483
+ defaultHeaders?: Record<string, string>;
2388
2484
  clientFactory?: (auth: ProviderRequestAuth) => GoogleGenAI;
2389
2485
  }
2390
2486
 
@@ -2512,8 +2608,19 @@ declare class InjectionManager {
2512
2608
  * mode is off, the agent is not the main agent, or there is nothing to inject.
2513
2609
  */
2514
2610
  injectGoal(): Promise<void>;
2611
+ injectAfterCompaction(): Promise<void>;
2612
+ /**
2613
+ * Post-compaction only: re-surface still-running background tasks. Folding the
2614
+ * live context to [recent user prompts, summary] drops the messages that
2615
+ * started them and their status updates, so without this the model can forget
2616
+ * a task is running and spawn a duplicate. Appended as an `injection`-origin
2617
+ * reminder, so the next compaction drops and rebuilds it — kept fresh, never
2618
+ * stacked. Runs only on the live path: restore replays the persisted reminder
2619
+ * and `FullCompaction.begin` short-circuits before compaction there.
2620
+ */
2621
+ private injectActiveBackgroundTasks;
2515
2622
  onContextClear(): void;
2516
- onContextCompacted(compactedCount: number): void;
2623
+ onContextCompacted(): void;
2517
2624
  onContextMessageRemoved(index: number): void;
2518
2625
  /** Per-step injectors plus the boundary goal injector, for lifecycle events. */
2519
2626
  private lifecycleInjectors;
@@ -3149,19 +3256,18 @@ declare const KimiConfigPatchSchema: z.ZodObject<{
3149
3256
  capabilities: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
3150
3257
  displayName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
3151
3258
  reasoningKey: z.ZodOptional<z.ZodOptional<z.ZodString>>;
3259
+ protocol: z.ZodOptional<z.ZodOptional<z.ZodLiteral<"anthropic">>>;
3152
3260
  adaptiveThinking: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
3261
+ supportEfforts: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
3262
+ defaultEffort: z.ZodOptional<z.ZodOptional<z.ZodString>>;
3263
+ betaApi: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
3153
3264
  }, z.core.$strip>>>;
3154
3265
  thinking: z.ZodOptional<z.ZodObject<{
3155
- mode: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
3156
- off: "off";
3157
- auto: "auto";
3158
- on: "on";
3159
- }>>>;
3266
+ enabled: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
3160
3267
  effort: z.ZodOptional<z.ZodOptional<z.ZodString>>;
3161
3268
  }, z.core.$strip>>;
3162
3269
  planMode: z.ZodOptional<z.ZodBoolean>;
3163
3270
  yolo: z.ZodOptional<z.ZodBoolean>;
3164
- defaultThinking: z.ZodOptional<z.ZodBoolean>;
3165
3271
  defaultPermissionMode: z.ZodOptional<z.ZodEnum<{
3166
3272
  auto: "auto";
3167
3273
  manual: "manual";
@@ -3251,6 +3357,10 @@ declare const KimiConfigPatchSchema: z.ZodObject<{
3251
3357
  killGracePeriodMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
3252
3358
  printWaitCeilingS: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
3253
3359
  }, z.core.$strip>>;
3360
+ modelCatalog: z.ZodOptional<z.ZodObject<{
3361
+ refreshIntervalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
3362
+ refreshOnStart: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
3363
+ }, z.core.$strip>>;
3254
3364
  experimental: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
3255
3365
  telemetry: z.ZodOptional<z.ZodBoolean>;
3256
3366
  }, z.core.$strict>;
@@ -3302,19 +3412,18 @@ declare const KimiConfigSchema: z.ZodObject<{
3302
3412
  capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
3303
3413
  displayName: z.ZodOptional<z.ZodString>;
3304
3414
  reasoningKey: z.ZodOptional<z.ZodString>;
3415
+ protocol: z.ZodOptional<z.ZodLiteral<"anthropic">>;
3305
3416
  adaptiveThinking: z.ZodOptional<z.ZodBoolean>;
3417
+ supportEfforts: z.ZodOptional<z.ZodArray<z.ZodString>>;
3418
+ defaultEffort: z.ZodOptional<z.ZodString>;
3419
+ betaApi: z.ZodOptional<z.ZodBoolean>;
3306
3420
  }, z.core.$strip>>>;
3307
3421
  thinking: z.ZodOptional<z.ZodObject<{
3308
- mode: z.ZodOptional<z.ZodEnum<{
3309
- off: "off";
3310
- auto: "auto";
3311
- on: "on";
3312
- }>>;
3422
+ enabled: z.ZodOptional<z.ZodBoolean>;
3313
3423
  effort: z.ZodOptional<z.ZodString>;
3314
3424
  }, z.core.$strip>>;
3315
3425
  planMode: z.ZodOptional<z.ZodBoolean>;
3316
3426
  yolo: z.ZodOptional<z.ZodBoolean>;
3317
- defaultThinking: z.ZodOptional<z.ZodBoolean>;
3318
3427
  defaultPermissionMode: z.ZodOptional<z.ZodEnum<{
3319
3428
  auto: "auto";
3320
3429
  manual: "manual";
@@ -3404,6 +3513,10 @@ declare const KimiConfigSchema: z.ZodObject<{
3404
3513
  killGracePeriodMs: z.ZodOptional<z.ZodNumber>;
3405
3514
  printWaitCeilingS: z.ZodOptional<z.ZodNumber>;
3406
3515
  }, z.core.$strip>>;
3516
+ modelCatalog: z.ZodOptional<z.ZodObject<{
3517
+ refreshIntervalMs: z.ZodOptional<z.ZodNumber>;
3518
+ refreshOnStart: z.ZodOptional<z.ZodBoolean>;
3519
+ }, z.core.$strip>>;
3407
3520
  experimental: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
3408
3521
  telemetry: z.ZodOptional<z.ZodBoolean>;
3409
3522
  raw: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -3488,6 +3601,7 @@ declare class KimiCore implements PromisableMethods<CoreAPI> {
3488
3601
  detachBackground({ sessionId, ...payload }: SessionAgentPayload<DetachBackgroundPayload>): Promise<BackgroundTaskInfo | undefined>;
3489
3602
  clearContext({ sessionId, ...payload }: SessionAgentPayload<EmptyPayload>): Promise<void>;
3490
3603
  activateSkill({ sessionId, ...payload }: SessionAgentPayload<ActivateSkillPayload>): Promise<void>;
3604
+ activatePluginCommand({ sessionId, ...payload }: SessionAgentPayload<ActivatePluginCommandPayload>): Promise<void>;
3491
3605
  getBackgroundOutput({ sessionId, ...payload }: SessionAgentPayload<GetBackgroundOutputPayload>): Promise<string>;
3492
3606
  getContext({ sessionId, ...payload }: SessionAgentPayload<EmptyPayload>): Promise<AgentContextData>;
3493
3607
  getConfig({ sessionId, ...payload }: SessionAgentPayload<EmptyPayload>): Promise<AgentConfigData>;
@@ -3499,6 +3613,7 @@ declare class KimiCore implements PromisableMethods<CoreAPI> {
3499
3613
  updateSessionMetadata({ sessionId, ...payload }: UpdateSessionMetadataRequest): Promise<void>;
3500
3614
  getSessionMetadata({ sessionId, ...payload }: SessionScopedPayload<EmptyPayload>): SessionMeta;
3501
3615
  listSkills({ sessionId, ...payload }: SessionScopedPayload<EmptyPayload>): Promise<readonly SkillSummary[]>;
3616
+ listPluginCommands({ sessionId, ...payload }: SessionScopedPayload<EmptyPayload>): readonly PluginCommandDef[];
3502
3617
  listMcpServers({ sessionId, ...payload }: SessionScopedPayload<EmptyPayload>): readonly McpServerInfo[];
3503
3618
  getMcpStartupMetrics({ sessionId, ...payload }: SessionScopedPayload<EmptyPayload>): Promise<McpStartupMetrics>;
3504
3619
  reconnectMcpServer({ sessionId, ...payload }: SessionScopedPayload<ReconnectMcpServerPayload>): Promise<void>;
@@ -3712,6 +3827,10 @@ declare interface KimiOptions {
3712
3827
  stream?: boolean | undefined;
3713
3828
  defaultHeaders?: Record<string, string> | undefined;
3714
3829
  generationKwargs?: GenerationKwargs | undefined;
3830
+ /** Efforts the model advertises (e.g. ["low", "high", "max"]). When
3831
+ * present and non-empty, withThinking sends the chosen effort on the wire;
3832
+ * when absent/empty, only thinking.type is sent. */
3833
+ supportEfforts?: readonly string[] | undefined;
3715
3834
  clientFactory?: (auth: ProviderRequestAuth) => OpenAI;
3716
3835
  }
3717
3836
 
@@ -3824,6 +3943,27 @@ declare class LlmRequestLogger {
3824
3943
  declare interface LLMStreamTiming {
3825
3944
  readonly firstTokenLatencyMs: number;
3826
3945
  readonly streamDurationMs: number;
3946
+ /**
3947
+ * Portion of `firstTokenLatencyMs` spent in-process building the request
3948
+ * (message serialization, param assembly) before the provider dispatched the
3949
+ * network call. `undefined` when the provider does not report the
3950
+ * client/server boundary (no `onRequestSent`).
3951
+ */
3952
+ readonly requestBuildMs?: number;
3953
+ /**
3954
+ * Portion of `firstTokenLatencyMs` spent waiting on the network + API server
3955
+ * from request dispatch to the first streamed token. `undefined` when the
3956
+ * provider does not report the client/server boundary.
3957
+ */
3958
+ readonly serverFirstTokenMs?: number;
3959
+ /**
3960
+ * Split of `streamDurationMs` (the decode window): time spent awaiting parts
3961
+ * from the provider (`serverDecodeMs`, server + network) vs. time spent
3962
+ * processing parts in-process (`clientConsumeMs`, host callbacks / merge).
3963
+ * `undefined` when the provider stream did not report decode accounting.
3964
+ */
3965
+ readonly serverDecodeMs?: number;
3966
+ readonly clientConsumeMs?: number;
3827
3967
  }
3828
3968
 
3829
3969
  /**
@@ -3940,6 +4080,20 @@ declare interface LoopStepEndEvent {
3940
4080
  readonly finishReason?: LoopStepStopReason | undefined;
3941
4081
  readonly llmFirstTokenLatencyMs?: number | undefined;
3942
4082
  readonly llmStreamDurationMs?: number | undefined;
4083
+ /**
4084
+ * Split of `llmFirstTokenLatencyMs`: in-process request-building time on the
4085
+ * client vs. network + API-server time to the first token. Both `undefined`
4086
+ * when the provider does not report the client/server boundary.
4087
+ */
4088
+ readonly llmRequestBuildMs?: number | undefined;
4089
+ readonly llmServerFirstTokenMs?: number | undefined;
4090
+ /**
4091
+ * Split of `llmStreamDurationMs` (the decode window): time awaiting parts
4092
+ * from the provider vs. time processing parts in-process. Both `undefined`
4093
+ * when the provider stream did not report decode accounting.
4094
+ */
4095
+ readonly llmServerDecodeMs?: number | undefined;
4096
+ readonly llmClientConsumeMs?: number | undefined;
3943
4097
  /**
3944
4098
  * Provider diagnostics are optional and must not drive loop control.
3945
4099
  * Use `finishReason` for normalized behavior.
@@ -4412,7 +4566,11 @@ declare const ModelAliasSchema: z.ZodObject<{
4412
4566
  capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
4413
4567
  displayName: z.ZodOptional<z.ZodString>;
4414
4568
  reasoningKey: z.ZodOptional<z.ZodString>;
4569
+ protocol: z.ZodOptional<z.ZodLiteral<"anthropic">>;
4415
4570
  adaptiveThinking: z.ZodOptional<z.ZodBoolean>;
4571
+ supportEfforts: z.ZodOptional<z.ZodArray<z.ZodString>>;
4572
+ defaultEffort: z.ZodOptional<z.ZodString>;
4573
+ betaApi: z.ZodOptional<z.ZodBoolean>;
4416
4574
  }, z.core.$strip>;
4417
4575
 
4418
4576
  /**
@@ -4689,6 +4847,38 @@ declare interface PluginCapabilityState {
4689
4847
  readonly mcpServers?: Readonly<Record<string, PluginMcpServerState>>;
4690
4848
  }
4691
4849
 
4850
+ export { PluginCommandActivatedEvent }
4851
+
4852
+ export declare interface PluginCommandDef {
4853
+ readonly pluginId: string;
4854
+ readonly name: string;
4855
+ readonly description: string;
4856
+ readonly body: string;
4857
+ readonly path: string;
4858
+ }
4859
+
4860
+ /**
4861
+ * A resolved command file plus its namespace-preserving name.
4862
+ *
4863
+ * `name` is the path of the file relative to the declared `commands` entry
4864
+ * (without the `.md` extension, using `/` separators), so a file at
4865
+ * `commands/frontend/component.md` yields the name `frontend/component`.
4866
+ * Frontmatter `name` in the file itself takes precedence over this at load time.
4867
+ */
4868
+ declare interface PluginCommandEntry {
4869
+ readonly path: string;
4870
+ readonly name: string;
4871
+ }
4872
+
4873
+ declare interface PluginCommandOrigin {
4874
+ readonly kind: 'plugin_command';
4875
+ readonly activationId: string;
4876
+ readonly pluginId: string;
4877
+ readonly commandName: string;
4878
+ readonly commandArgs?: string | undefined;
4879
+ readonly trigger: 'user-slash';
4880
+ }
4881
+
4692
4882
  declare interface PluginDiagnostic {
4693
4883
  readonly severity: PluginDiagnosticSeverity;
4694
4884
  readonly message: string;
@@ -4744,6 +4934,7 @@ declare class PluginManager {
4744
4934
  enabledSessionStarts(): readonly EnabledPluginSessionStart[];
4745
4935
  enabledMcpServers(): Record<string, McpServerConfig>;
4746
4936
  enabledHooks(): readonly HookDef[];
4937
+ enabledCommands(): Promise<readonly PluginCommandDef[]>;
4747
4938
  summaries(): readonly PluginSummary[];
4748
4939
  info(id: string): PluginInfo | undefined;
4749
4940
  private persist;
@@ -4766,6 +4957,7 @@ declare interface PluginManifest {
4766
4957
  readonly sessionStart?: PluginSessionStart;
4767
4958
  readonly mcpServers?: Readonly<Record<string, McpServerConfig>>;
4768
4959
  readonly hooks?: readonly HookDefConfig[];
4960
+ readonly commands?: readonly PluginCommandEntry[];
4769
4961
  readonly interface?: PluginInterface;
4770
4962
  readonly skillInstructions?: string;
4771
4963
  }
@@ -4827,6 +5019,7 @@ export declare interface PluginSummary {
4827
5019
  readonly mcpServerCount: number;
4828
5020
  readonly enabledMcpServerCount: number;
4829
5021
  readonly hookCount: number;
5022
+ readonly commandCount: number;
4830
5023
  readonly hasErrors: boolean;
4831
5024
  readonly source: PluginSource;
4832
5025
  readonly originalSource?: string;
@@ -4853,6 +5046,99 @@ export declare interface ProcessBackgroundTaskInfo extends BackgroundTaskInfoBas
4853
5046
  readonly exitCode: number | null;
4854
5047
  }
4855
5048
 
5049
+ /**
5050
+ * A repair the projector applied to make the history wire-valid. Each one means
5051
+ * the stored history was not directly sendable to a strict provider.
5052
+ */
5053
+ declare type ProjectionAnomaly =
5054
+ /** A recorded result was not adjacent to its call and had to be moved up. */
5055
+ {
5056
+ readonly kind: 'tool_result_reordered';
5057
+ readonly toolCallId: string;
5058
+ }
5059
+ /**
5060
+ * No result existed for a call, so a placeholder was synthesized. `trailing`
5061
+ * is true when it closed a still-open tail call (expected under
5062
+ * `synthesizeMissing`), false when it closed a mid-history orphan whose result
5063
+ * was lost (a genuine defect worth investigating).
5064
+ */
5065
+ | {
5066
+ readonly kind: 'tool_result_synthesized';
5067
+ readonly toolCallId: string;
5068
+ readonly trailing: boolean;
5069
+ }
5070
+ /** A result with no matching call anywhere was dropped (strict resend only). */
5071
+ | {
5072
+ readonly kind: 'orphan_tool_result_dropped';
5073
+ readonly toolCallId: string;
5074
+ }
5075
+ /** A leading non-user message was dropped so the first turn is user (strict). */
5076
+ | {
5077
+ readonly kind: 'leading_non_user_dropped';
5078
+ readonly role: string;
5079
+ }
5080
+ /** Two adjacent assistant turns were merged into one (strict). */
5081
+ | {
5082
+ readonly kind: 'consecutive_assistants_merged';
5083
+ }
5084
+ /** A non-empty but all-whitespace text block was dropped (always). */
5085
+ | {
5086
+ readonly kind: 'whitespace_text_dropped';
5087
+ readonly role: string;
5088
+ };
5089
+
5090
+ declare interface ProjectOptions {
5091
+ /**
5092
+ * When `true`, emit a synthetic `tool_result` for *every* assistant `tool_use`
5093
+ * whose result is not present in the provided messages — including a trailing,
5094
+ * still-in-flight call. Used by full compaction, where the compacted prefix is
5095
+ * a slice that may exclude a delayed result preserved in the retained tail; the
5096
+ * synthetic result keeps the exchange closed so the summary request is not
5097
+ * rejected. Leave `false` for normal turns: a *trailing* missing result there
5098
+ * means the call is still in-flight and must not be closed prematurely. (A
5099
+ * *non-trailing* missing result is always closed regardless of this flag — see
5100
+ * `repairToolExchangeAdjacency` — because a later turn proves it is not
5101
+ * in-flight.)
5102
+ */
5103
+ readonly synthesizeMissing?: boolean;
5104
+ /**
5105
+ * When `true`, drop any `tool_result` whose `toolCallId` matches no assistant
5106
+ * `tool_use` anywhere in the provided messages. Strict providers reject such a
5107
+ * stray result as an "unexpected `tool_result`". Off by default so the normal
5108
+ * path never silently discards recorded output; the post-400 strict-resend
5109
+ * fallback enables it (together with `synthesizeMissing`) as a last resort to
5110
+ * force a wire-compliant request out of an otherwise-bricked session.
5111
+ */
5112
+ readonly dropOrphanResults?: boolean;
5113
+ /**
5114
+ * When `true`, drop leading messages until the first one is a user turn. Strict
5115
+ * providers require the first message to be `user`; a history that (after
5116
+ * dropping/compaction) starts with an assistant or tool message is rejected.
5117
+ * Strict-resend only — the normal path keeps the original opening.
5118
+ */
5119
+ readonly dropLeadingNonUser?: boolean;
5120
+ /**
5121
+ * When `true`, merge back-to-back assistant messages into one. Strict providers
5122
+ * reject consecutive same-role turns ("roles must alternate"); consecutive user
5123
+ * turns are already merged at the provider boundary, but consecutive assistant
5124
+ * turns are not. Strict-resend only. Content is concatenated verbatim — callers
5125
+ * must not rely on this when extended-thinking ordering matters, but two
5126
+ * consecutive assistant turns do not arise in well-formed transcripts.
5127
+ */
5128
+ readonly mergeConsecutiveAssistants?: boolean;
5129
+ /**
5130
+ * Optional sink invoked for every repair the projector applies to keep the
5131
+ * outgoing wire valid: a displaced result moved back next to its call, a
5132
+ * synthetic result invented for a missing one, a stray result dropped, a
5133
+ * leading non-user message dropped, or consecutive assistants merged. The
5134
+ * projection itself stays a pure transform; the caller decides whether/how to
5135
+ * surface these (the context logs them so a silently-mangled history is never
5136
+ * papered over without a trace). Not called when the history is already
5137
+ * well-formed.
5138
+ */
5139
+ readonly onAnomaly?: (anomaly: ProjectionAnomaly) => void;
5140
+ }
5141
+
4856
5142
  declare type Promisable<T> = [T] extends [Promise<any>] ? T | Awaited<T> : T | Promise<T>;
4857
5143
 
4858
5144
  declare type PromisableMethods<T> = {
@@ -4863,7 +5149,7 @@ declare type Promisify<T> = [T] extends [Promise<any>] ? T : Promise<T>;
4863
5149
 
4864
5150
  export declare type PromptInput = readonly PromptPart[];
4865
5151
 
4866
- export declare type PromptOrigin = UserPromptOrigin | SkillActivationOrigin | InjectionOrigin | ShellCommandOrigin | CompactionSummaryOrigin | SystemTriggerOrigin | BackgroundTaskOrigin | CronJobOrigin | CronMissedOrigin | HookResultOrigin | RetryOrigin;
5152
+ export declare type PromptOrigin = UserPromptOrigin | SkillActivationOrigin | PluginCommandOrigin | InjectionOrigin | ShellCommandOrigin | CompactionSummaryOrigin | SystemTriggerOrigin | BackgroundTaskOrigin | CronJobOrigin | CronMissedOrigin | HookResultOrigin | RetryOrigin;
4867
5153
 
4868
5154
  export declare type PromptPart = Extract<ContentPart, {
4869
5155
  type: 'text' | 'image_url' | 'video_url';
@@ -4929,6 +5215,7 @@ declare interface ProviderManagerOptions {
4929
5215
  readonly kimiRequestHeaders?: Record<string, string>;
4930
5216
  readonly resolveOAuthTokenProvider?: OAuthTokenProviderResolver;
4931
5217
  readonly promptCacheKey?: string;
5218
+ readonly adaptiveThinkingOverride?: () => boolean | undefined;
4932
5219
  }
4933
5220
 
4934
5221
  /**
@@ -5134,6 +5421,10 @@ declare interface ResolvedRuntimeProvider {
5134
5421
  /** Declared 'always_thinking' capability — the model cannot disable thinking. */
5135
5422
  readonly alwaysThinking?: boolean;
5136
5423
  readonly maxOutputSize?: number;
5424
+ /** Configured provider wire type (`provider.type`), before any model-level protocol override. */
5425
+ readonly type: ProviderType;
5426
+ /** Model-level protocol override (`alias.protocol`); when set, takes precedence over `type` for transport selection. */
5427
+ readonly protocol: ModelAlias['protocol'];
5137
5428
  }
5138
5429
 
5139
5430
  declare interface ResolvedToolExecutionHookContext extends ToolExecutionHookContext {
@@ -5369,6 +5660,7 @@ export declare abstract class SDKRpcClientBase {
5369
5660
  getUsage(input: SessionIdRpcInput): Promise<SessionUsage>;
5370
5661
  getStatus(input: SessionIdRpcInput): Promise<SessionStatus>;
5371
5662
  listSkills(input: SessionIdRpcInput): Promise<readonly SkillSummary[]>;
5663
+ listPluginCommands(input: SessionIdRpcInput): Promise<readonly PluginCommandDef[]>;
5372
5664
  listBackgroundTasks(input: SessionIdRpcInput & {
5373
5665
  activeOnly?: boolean;
5374
5666
  limit?: number;
@@ -5400,6 +5692,7 @@ export declare abstract class SDKRpcClientBase {
5400
5692
  reloadPlugins(): Promise<ReloadSummary>;
5401
5693
  getPluginInfo(id: string): Promise<PluginInfo>;
5402
5694
  activateSkill(input: ActivateSkillRpcInput): Promise<void>;
5695
+ activatePluginCommand(input: ActivatePluginCommandRpcInput): Promise<void>;
5403
5696
  onEvent(listener: (event: Event_2) => void): Unsubscribe;
5404
5697
  receiveEvent(event: Event_2): void;
5405
5698
  setApprovalHandler(sessionId: string, handler: ApprovalHandler | undefined): void;
@@ -5501,7 +5794,7 @@ export declare class Session {
5501
5794
  startBtw(): Promise<string>;
5502
5795
  cancel(): Promise<void>;
5503
5796
  setModel(model: string): Promise<void>;
5504
- setThinking(level: string): Promise<void>;
5797
+ setThinking(effort: ThinkingEffort): Promise<void>;
5505
5798
  setPermission(mode: PermissionMode): Promise<void>;
5506
5799
  setPlanMode(enabled: boolean): Promise<void>;
5507
5800
  setSwarmMode(enabled: boolean, trigger: SwarmModeTrigger): Promise<void>;
@@ -5514,6 +5807,7 @@ export declare class Session {
5514
5807
  getUsage(): Promise<SessionUsage>;
5515
5808
  getStatus(): Promise<SessionStatus>;
5516
5809
  listSkills(): Promise<readonly SkillSummary[]>;
5810
+ listPluginCommands(): Promise<readonly PluginCommandDef[]>;
5517
5811
  /**
5518
5812
  * List background tasks for this session's interactive agent.
5519
5813
  *
@@ -5564,6 +5858,7 @@ export declare class Session {
5564
5858
  reloadPlugins(): Promise<ReloadSummary>;
5565
5859
  getPluginInfo(id: string): Promise<PluginInfo>;
5566
5860
  activateSkill(name: string, args?: string | undefined): Promise<void>;
5861
+ activatePluginCommand(pluginId: string, commandName: string, args?: string | undefined): Promise<void>;
5567
5862
  close(): Promise<void>;
5568
5863
  /** @internal */
5569
5864
  emitMetaUpdated(patch: {
@@ -5588,6 +5883,7 @@ declare class Session_2 {
5588
5883
  private toolKaos;
5589
5884
  private persistenceKaos;
5590
5885
  private additionalDirs;
5886
+ private readonly pluginCommands;
5591
5887
  private agentIdCounter;
5592
5888
  private readonly skillsReady;
5593
5889
  metadata: SessionMeta;
@@ -5654,6 +5950,7 @@ declare class Session_2 {
5654
5950
  readMetadata(): Promise<SessionMeta>;
5655
5951
  flushMetadata(): Promise<void>;
5656
5952
  listSkills(): Promise<readonly SkillSummary_2[]>;
5953
+ listPluginCommands(): readonly PluginCommandDef[];
5657
5954
  private loadSkills;
5658
5955
  private loadMcpServers;
5659
5956
  private emitInitialMcpLoadError;
@@ -5666,6 +5963,8 @@ declare class Session_2 {
5666
5963
  private resolveAgentEntry;
5667
5964
  private resumeAgent;
5668
5965
  private resumePersistedAgent;
5966
+ private restoreAgentProfileHandle;
5967
+ private resolvePersistedProfile;
5669
5968
  private nextGeneratedAgentId;
5670
5969
  private requireMainAgent;
5671
5970
  private triggerSessionStart;
@@ -5679,6 +5978,7 @@ declare interface SessionAPI extends AgentAPIWithId {
5679
5978
  updateSessionMetadata: (payload: UpdateSessionMetadataPayload) => void;
5680
5979
  getSessionMetadata: (payload: EmptyPayload) => SessionMeta;
5681
5980
  listSkills: (payload: EmptyPayload) => readonly SkillSummary[];
5981
+ listPluginCommands: (payload: EmptyPayload) => readonly PluginCommandDef[];
5682
5982
  listMcpServers: (payload: EmptyPayload) => readonly McpServerInfo[];
5683
5983
  getMcpStartupMetrics: (payload: EmptyPayload) => McpStartupMetrics;
5684
5984
  reconnectMcpServer: (payload: ReconnectMcpServerPayload) => void;
@@ -5803,6 +6103,7 @@ declare interface SessionOptions_2 {
5803
6103
  readonly mcpConfig?: SessionMcpConfig;
5804
6104
  readonly telemetry?: TelemetryClient | undefined;
5805
6105
  readonly pluginSessionStarts?: readonly EnabledPluginSessionStart[];
6106
+ readonly pluginCommands?: readonly PluginCommandDef[];
5806
6107
  readonly appVersion?: string;
5807
6108
  readonly experimentalFlags?: ExperimentalFlagResolver;
5808
6109
  readonly additionalDirs?: readonly string[];
@@ -5858,7 +6159,7 @@ declare class SessionSkillRegistry implements SkillRegistry {
5858
6159
 
5859
6160
  export declare interface SessionStatus {
5860
6161
  readonly model?: string;
5861
- readonly thinkingLevel: string;
6162
+ readonly thinkingEffort: string;
5862
6163
  readonly permission: PermissionMode;
5863
6164
  readonly planMode: boolean;
5864
6165
  readonly swarmMode?: boolean | undefined;
@@ -5984,11 +6285,11 @@ declare type SetSessionSwarmModeRpcInput = (SessionIdRpcInput & {
5984
6285
  });
5985
6286
 
5986
6287
  declare interface SetSessionThinkingRpcInput extends SessionIdRpcInput {
5987
- readonly level: string;
6288
+ readonly effort: string;
5988
6289
  }
5989
6290
 
5990
6291
  declare interface SetThinkingPayload {
5991
- readonly level: string;
6292
+ readonly effort: string;
5992
6293
  }
5993
6294
 
5994
6295
  declare interface ShellCommandOrigin {
@@ -6157,6 +6458,24 @@ declare interface StopBackgroundPayload {
6157
6458
  readonly reason?: string;
6158
6459
  }
6159
6460
 
6461
+ /**
6462
+ * Decode-phase accounting for a single streamed generation. Splits the window
6463
+ * from the first streamed part to stream end into the time spent waiting on the
6464
+ * provider for the next part (server + network) versus the time spent
6465
+ * processing each part in-process (deep copy, host callbacks, part merging).
6466
+ *
6467
+ * Because both buckets are wall-clock measured on the single JS thread, a
6468
+ * stop-the-world GC pause that lands while awaiting the next part is counted in
6469
+ * {@link serverDecodeMs}; a non-trivial {@link clientConsumeMs} share is the
6470
+ * unambiguous signal that the host's per-part processing is throttling decode.
6471
+ */
6472
+ declare interface StreamDecodeStats {
6473
+ /** Cumulative time spent awaiting the next streamed part (server + network). */
6474
+ readonly serverDecodeMs: number;
6475
+ /** Cumulative time spent processing streamed parts in-process (client). */
6476
+ readonly clientConsumeMs: number;
6477
+ }
6478
+
6160
6479
  /**
6161
6480
  * An async-iterable stream of message parts produced by a single LLM response.
6162
6481
  *
@@ -6311,31 +6630,33 @@ export declare type ThinkingConfig = z.infer<typeof ThinkingConfigSchema>;
6311
6630
 
6312
6631
  declare interface ThinkingConfig_2 {
6313
6632
  type?: 'enabled' | 'disabled';
6633
+ effort?: string;
6314
6634
  keep?: unknown;
6315
6635
  [key: string]: unknown;
6316
6636
  }
6317
6637
 
6318
6638
  declare const ThinkingConfigSchema: z.ZodObject<{
6319
- mode: z.ZodOptional<z.ZodEnum<{
6320
- off: "off";
6321
- auto: "auto";
6322
- on: "on";
6323
- }>>;
6639
+ enabled: z.ZodOptional<z.ZodBoolean>;
6324
6640
  effort: z.ZodOptional<z.ZodString>;
6325
6641
  }, z.core.$strip>;
6326
6642
 
6327
6643
  export { ThinkingDeltaEvent }
6328
6644
 
6329
6645
  /**
6330
- * Normalized thinking effort level used across providers.
6646
+ * Thinking effort passed to {@link ChatProvider.withThinking}.
6647
+ *
6648
+ * `'off'` and `'on'` are the only reserved values: `'off'` disables thinking,
6649
+ * and `'on'` is the on-signal for boolean models (models that do not declare
6650
+ * `support_efforts`). Everything else is a model-declared effort (e.g.
6651
+ * `"low"`, `"high"`, `"max"`) carried as an open string. The type collapses to
6652
+ * `string` at runtime; it exists purely as a semantic marker that a value is
6653
+ * expected to be `'off'`, `'on'`, or a model-declared effort.
6331
6654
  *
6332
- * Values above `high` are provider/model-specific and may be clamped by the
6333
- * adapter when the native API has no matching level. OpenAI maps `max` to its
6334
- * `xhigh` ceiling; Kimi and Gemini cap `xhigh`/`max` at `high`; Anthropic
6335
- * supports `xhigh`/`max` only on selected models and otherwise clamps to
6336
- * `high`.
6655
+ * The model's `support_efforts` is the single source of truth for which
6656
+ * efforts are valid providers normalize any unrecognized effort by omitting
6657
+ * the effort on the wire rather than rejecting it.
6337
6658
  */
6338
- declare type ThinkingEffort = 'off' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
6659
+ export declare type ThinkingEffort = 'off' | 'on' | (string & {});
6339
6660
 
6340
6661
  declare interface ThinkPart {
6341
6662
  type: 'think';
@@ -6548,6 +6869,7 @@ declare class ToolManager {
6548
6869
  initializeBuiltinTools(): void;
6549
6870
  refreshBuiltinTools(): void;
6550
6871
  private createVideoUploader;
6872
+ private videoUploadTelemetryProps;
6551
6873
  get loopTools(): readonly ExecutableTool[];
6552
6874
  }
6553
6875
 
@@ -6661,6 +6983,16 @@ declare class TurnFlow {
6661
6983
  waitForTurnFirstRequest(): Promise<void>;
6662
6984
  private abortTurn;
6663
6985
  private flushSteerBuffer;
6986
+ /**
6987
+ * Replay inputs (prompts or steers) that were deferred while a manual compaction
6988
+ * held the context. Called by `FullCompaction` once the compaction lifecycle
6989
+ * (summary + reinjection) is done — and on cancel/failure — so deferred input is
6990
+ * never lost or stuck. If a turn is somehow already active (e.g. one that raced
6991
+ * and cancelled the compaction), let it consume the buffer like any other steer;
6992
+ * otherwise launch a fresh turn from the first buffered item, with the rest
6993
+ * draining into it via `flushSteerBuffer`.
6994
+ */
6995
+ onCompactionFinished(): void;
6664
6996
  finishResume(): void;
6665
6997
  /**
6666
6998
  * The body of the single in-flight `activeTurn`. Routes to the goal driver
@@ -6699,6 +7031,13 @@ declare class TurnFlow {
6699
7031
  private hasPriorStepToolCallKey;
6700
7032
  private trackTurnInterrupted;
6701
7033
  private telemetryMode;
7034
+ /**
7035
+ * Resolve the current model's provider wire type and any model-level protocol
7036
+ * override for request telemetry. Never throws — telemetry must not break a
7037
+ * turn over an unresolvable provider config (the step loop will surface that
7038
+ * error on its own).
7039
+ */
7040
+ private requestProtocolProps;
6702
7041
  private shouldTrackApiError;
6703
7042
  }
6704
7043