@kodax-ai/kodax 0.7.42 → 0.7.43

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +34 -6
  2. package/README.md +87 -56
  3. package/README_CN.md +46 -25
  4. package/dist/chunks/chunk-7G5PSL6C.js +830 -0
  5. package/dist/chunks/{chunk-IYJ5EPRV.js → chunk-IYSK7LUK.js} +1 -1
  6. package/dist/chunks/chunk-K75O2CAE.js +31 -0
  7. package/dist/chunks/chunk-UG4262JI.js +502 -0
  8. package/dist/chunks/chunk-VHKAJDQD.js +425 -0
  9. package/dist/chunks/chunk-YMRZBS4G.js +2 -0
  10. package/dist/chunks/compaction-config-3E57ABCT.js +2 -0
  11. package/dist/chunks/{construction-bootstrap-J2WOCYEK.js → construction-bootstrap-JR63KI5N.js} +4 -4
  12. package/dist/chunks/dist-KWHUKXEL.js +2 -0
  13. package/dist/chunks/dist-XANXEVTU.js +2 -0
  14. package/dist/chunks/utils-HQ2QCKJA.js +2 -0
  15. package/dist/index.d.ts +10 -10
  16. package/dist/index.js +2 -2
  17. package/dist/kodax_cli.js +1124 -1102
  18. package/dist/sdk-agent.d.ts +850 -48
  19. package/dist/sdk-agent.js +1 -1
  20. package/dist/sdk-coding.d.ts +701 -815
  21. package/dist/sdk-coding.js +1 -1
  22. package/dist/sdk-llm.d.ts +5 -3
  23. package/dist/sdk-llm.js +1 -1
  24. package/dist/sdk-mcp.d.ts +1 -1
  25. package/dist/sdk-mcp.js +1 -1
  26. package/dist/sdk-repl.d.ts +9 -8
  27. package/dist/sdk-repl.js +1 -1
  28. package/dist/sdk-session.d.ts +22 -10
  29. package/dist/sdk-session.js +1 -1
  30. package/dist/sdk-skills.js +1 -1
  31. package/dist/types-chunks/{cost-tracker.d-B6vMoLLF.d.ts → base.d-FUJahC0i.d.ts} +2 -110
  32. package/dist/types-chunks/{bash-prefix-extractor.d-CkhaqKkg.d.ts → bash-prefix-extractor.d-DMrGImMl.d.ts} +35 -136
  33. package/dist/types-chunks/cost-tracker.d-wRtyEW9d.d.ts +110 -0
  34. package/dist/types-chunks/{history-cleanup.d-DznrzEiU.d.ts → file-tracker.d-zaLZeNBK.d.ts} +314 -6
  35. package/dist/types-chunks/manager.d-87belpiS.d.ts +370 -0
  36. package/dist/types-chunks/{resolver.d-DX9au4NJ.d.ts → resolver.d-CA68_NeH.d.ts} +149 -5
  37. package/dist/types-chunks/{session-storage.d-Cci897iM.d.ts → storage.d-DPAEX7zS.d.ts} +49 -2
  38. package/dist/types-chunks/{instance-discovery.d-BsKnIwpg.d.ts → types.d-CKJtjo-6.d.ts} +139 -2
  39. package/dist/types-chunks/{storage.d-Bc5DoAwp.d.ts → utils.d-DkLZD_wa.d.ts} +24 -46
  40. package/package.json +7 -6
  41. package/dist/chunks/chunk-3RKBXWZS.js +0 -2
  42. package/dist/chunks/chunk-7JLYVWAF.js +0 -1033
  43. package/dist/chunks/chunk-CD3R5YBH.js +0 -16
  44. package/dist/chunks/chunk-DKXUY5F2.js +0 -209
  45. package/dist/chunks/chunk-HMYEQJGT.js +0 -31
  46. package/dist/chunks/chunk-KUX5LRPP.js +0 -2
  47. package/dist/chunks/chunk-OWSKU55I.js +0 -13
  48. package/dist/chunks/chunk-ZZ4KRK2B.js +0 -465
  49. package/dist/chunks/compaction-config-FIFFP4FT.js +0 -2
  50. package/dist/chunks/dist-2ZHWDXMQ.js +0 -2
  51. package/dist/chunks/dist-W4CJWLIH.js +0 -2
  52. package/dist/chunks/utils-A5MWDTWZ.js +0 -2
  53. package/dist/types-chunks/transport.d-DuyjG30t.d.ts +0 -180
@@ -0,0 +1,370 @@
1
+ import { a as McpServerConfig, b as McpServersConfig, M as McpConnectMode } from './config.d-BfJUXxC0.js';
2
+ import { a as CapabilityProvider, C as CapabilityKind, b as CapabilityResult } from './capability.d-3C62G8Eq.js';
3
+
4
+ type McpCapabilityKind = 'tool' | 'resource' | 'prompt';
5
+ type McpCapabilityRisk = 'read' | 'write' | 'network' | 'exec';
6
+ interface McpCatalogItem {
7
+ id: string;
8
+ serverId: string;
9
+ kind: McpCapabilityKind;
10
+ name: string;
11
+ title?: string;
12
+ summary: string;
13
+ tags?: string[];
14
+ risk?: McpCapabilityRisk;
15
+ annotations?: Record<string, unknown>;
16
+ cachedAt: string;
17
+ }
18
+ interface McpCapabilityDescriptor extends McpCatalogItem {
19
+ inputSchema?: unknown;
20
+ outputSchema?: unknown;
21
+ promptArgsSchema?: unknown;
22
+ uri?: string;
23
+ mimeType?: string;
24
+ }
25
+ interface McpServerCatalogSnapshot {
26
+ serverId: string;
27
+ items: McpCatalogItem[];
28
+ descriptors: McpCapabilityDescriptor[];
29
+ updatedAt: string;
30
+ }
31
+ interface McpCatalogSearchOptions {
32
+ kind?: McpCapabilityKind;
33
+ limit?: number;
34
+ }
35
+ declare function defaultMcpCacheDir(): string;
36
+ declare function createMcpCapabilityId(serverId: string, kind: McpCapabilityKind, name: string): string;
37
+ declare function parseMcpCapabilityId(id: string): {
38
+ serverId: string;
39
+ kind: McpCapabilityKind;
40
+ name: string;
41
+ };
42
+ declare function searchMcpCatalog(items: readonly McpCatalogItem[], query: string, options?: McpCatalogSearchOptions): McpCatalogItem[];
43
+ declare function getMcpCachePaths(cacheDir: string, serverId: string): {
44
+ catalogDir: string;
45
+ indexPath: string;
46
+ itemsPath: string;
47
+ };
48
+
49
+ interface McpServerRuntimeDiagnostics {
50
+ serverId: string;
51
+ connect: 'lazy' | 'prewarm' | 'disabled';
52
+ status: 'idle' | 'connecting' | 'ready' | 'error' | 'disabled';
53
+ dirty: boolean;
54
+ lastError?: string;
55
+ cachedAt?: string;
56
+ tools: number;
57
+ resources: number;
58
+ prompts: number;
59
+ }
60
+ declare class McpServerRuntime {
61
+ private readonly serverId;
62
+ private readonly config;
63
+ private readonly cacheDir;
64
+ private transport?;
65
+ private readonly pending;
66
+ private nextRequestId;
67
+ private initialized;
68
+ private connectPromise?;
69
+ private catalog?;
70
+ private diagnostics;
71
+ constructor(serverId: string, config: McpServerConfig, cacheDir: string);
72
+ getDiagnostics(): McpServerRuntimeDiagnostics;
73
+ prewarmIfNeeded(): Promise<void>;
74
+ /** Load catalog from memory or disk only — never triggers a lazy connection. */
75
+ getCachedCatalog(): Promise<McpServerCatalogSnapshot | undefined>;
76
+ getCatalog(forceRefresh?: boolean): Promise<McpServerCatalogSnapshot>;
77
+ describeCapability(capabilityId: string): Promise<McpCapabilityDescriptor | undefined>;
78
+ callTool(name: string, args: Record<string, unknown>): Promise<{
79
+ content?: string;
80
+ structuredContent?: unknown;
81
+ metadata?: Record<string, unknown>;
82
+ }>;
83
+ readResource(name: string, options: Record<string, unknown>): Promise<{
84
+ content?: string;
85
+ structuredContent?: unknown;
86
+ metadata?: Record<string, unknown>;
87
+ }>;
88
+ getPrompt(name: string, args: Record<string, unknown>): Promise<unknown>;
89
+ refreshCatalog(forceReconnect?: boolean): Promise<void>;
90
+ /** Public teardown — clears everything including the connect lock. */
91
+ dispose(): Promise<void>;
92
+ /** Internal transport teardown — does NOT clear connectPromise so the
93
+ * retry loop inside doConnect() can safely call it between attempts. */
94
+ private resetTransport;
95
+ private connect;
96
+ private doConnect;
97
+ private listDescriptors;
98
+ private request;
99
+ private notify;
100
+ private handleMessage;
101
+ private failPending;
102
+ private applyCatalogSnapshot;
103
+ }
104
+
105
+ /**
106
+ * `McpCapabilityProvider` — implements the Layer A `CapabilityProvider`
107
+ * contract for an MCP server fleet.
108
+ *
109
+ * FEATURE_082 (v0.7.24): moved from
110
+ * `@kodax-ai/coding/src/capabilities/providers/mcp/provider.ts` to this package.
111
+ * The coding-specific `registerConfiguredMcpCapabilityProvider` adapter (which
112
+ * pulls in `KodaXExtensionRuntime`) lives in
113
+ * `@kodax-ai/coding/src/capabilities/providers/mcp-adapter.ts`.
114
+ */
115
+
116
+ interface McpProviderOptions {
117
+ cacheDir?: string;
118
+ }
119
+ declare class McpCapabilityProvider implements CapabilityProvider {
120
+ readonly id = "mcp";
121
+ readonly kinds: CapabilityProvider['kinds'];
122
+ private readonly runtimes;
123
+ private readonly cacheDir;
124
+ /**
125
+ * Construct an MCP capability provider.
126
+ *
127
+ * **Cache-dir capture warning (v0.7.35.1 FEATURE_145)** — when
128
+ * `options.cacheDir` is omitted, this constructor resolves
129
+ * `defaultMcpCacheDir()` ONCE at instantiation time and threads the
130
+ * result into every `McpServerRuntime` it spawns. If a substrate
131
+ * consumer plans to redirect the agent config home via
132
+ * `setAgentConfigHome()` from `@kodax-ai/agent`, that call MUST happen
133
+ * BEFORE constructing this provider. Late calls have no effect on
134
+ * already-constructed runtimes.
135
+ *
136
+ * To bypass the agent-home resolver entirely, pass
137
+ * `options.cacheDir` explicitly — that path wins unconditionally.
138
+ */
139
+ constructor(servers: McpServersConfig | undefined, options?: McpProviderOptions);
140
+ hasActiveServers(): boolean;
141
+ /**
142
+ * v0.7.42 — read-only accessor for the enabled server id list.
143
+ * Used by {@link McpManager} to drive popout-shape `listServers /
144
+ * startServer / stopServer / logs / tools` operations without
145
+ * exposing the internal runtimes Map.
146
+ */
147
+ getServerIds(): readonly string[];
148
+ /**
149
+ * v0.7.42 — single-server runtime accessor. Returns `undefined`
150
+ * for unknown / disabled servers. Use {@link McpManager} for
151
+ * higher-level lifecycle control.
152
+ */
153
+ getRuntime(serverId: string): McpServerRuntime | undefined;
154
+ prewarm(): Promise<void>;
155
+ search(query: string, options?: {
156
+ kind?: CapabilityKind;
157
+ limit?: number;
158
+ server?: string;
159
+ }): Promise<unknown[]>;
160
+ describe(id: string): Promise<unknown>;
161
+ execute(id: string, input: Record<string, unknown>): Promise<CapabilityResult>;
162
+ read(id: string, options?: Record<string, unknown>): Promise<CapabilityResult>;
163
+ getPrompt(id: string, args?: Record<string, unknown>): Promise<unknown>;
164
+ getPromptContext(): Promise<string | undefined>;
165
+ getDiagnostics(): Record<string, unknown> | undefined;
166
+ refresh(): Promise<void>;
167
+ dispose(): Promise<void>;
168
+ private collectCatalogItems;
169
+ private listServerDiagnostics;
170
+ private requireRuntime;
171
+ }
172
+
173
+ interface McpTransportEvents {
174
+ /** Called with a complete JSON-RPC message (raw JSON string). */
175
+ onMessage(raw: string): void;
176
+ onError(error: Error): void;
177
+ onClose(reason: string): void;
178
+ }
179
+ interface McpTransport {
180
+ open(events: McpTransportEvents): Promise<void>;
181
+ /** Send a JSON string. The transport handles framing. */
182
+ send(json: string): Promise<void>;
183
+ close(): Promise<void>;
184
+ readonly connected: boolean;
185
+ }
186
+ type StdioFraming = 'content-length' | 'ndjson';
187
+ interface McpTransportOptions {
188
+ stdioFraming?: StdioFraming;
189
+ }
190
+ declare function createMcpTransport(config: McpServerConfig, options?: McpTransportOptions): McpTransport;
191
+
192
+ /**
193
+ * McpManager — v0.7.42 (extends FEATURE_186 MCP popout surface).
194
+ *
195
+ * `McpCapabilityProvider` (`./provider.ts`) is the capability-provider-
196
+ * shaped object KodaX uses internally to plug MCP into the agent runtime
197
+ * — its public methods are `search` / `describe` / `execute` / `read` /
198
+ * `getPrompt` / `getDiagnostics` / `refresh` / `dispose`, which is the
199
+ * shape the substrate consumes but NOT the shape a popout UI wants.
200
+ *
201
+ * KodaX Space reported that `@kodax-ai/kodax/mcp` only exposed "types +
202
+ * helpers, no manager-shape API" — concretely they wanted a thin
203
+ * `listServers / startServer / stopServer / getServerLogs / listTools`
204
+ * surface to drive a popout panel:
205
+ *
206
+ * - One row per configured MCP server with live status
207
+ * - "Start" / "Stop" buttons that map to refreshCatalog(true) / dispose
208
+ * - Server logs (last error + status) so users can debug failures
209
+ * - Per-server tool list (filtered descriptors) for the "what does
210
+ * this MCP server expose" pane
211
+ *
212
+ * `McpManager` is the thin wrapper. It owns one `McpCapabilityProvider`
213
+ * instance internally, so all the existing lifecycle invariants
214
+ * (cache-dir capture, refresh, dispose, server-config validation) are
215
+ * preserved verbatim. The capability-provider-shaped methods stay
216
+ * available via `manager.provider()` as an escape hatch.
217
+ *
218
+ * Trust boundary: same as the rest of FEATURE_186 — KodaX is a
219
+ * single-user CLI, last-write-wins on the server-config-vs-active-
220
+ * runtime path; a Space popout that swaps configs hot would still need
221
+ * to construct a fresh `McpManager` (or call `dispose()` then
222
+ * `createMcpManager` again) to pick up the new wire.
223
+ */
224
+
225
+ interface McpServerStatus {
226
+ readonly serverId: string;
227
+ readonly config: McpServerConfig;
228
+ readonly connect: McpConnectMode;
229
+ readonly status: McpServerRuntimeDiagnostics['status'];
230
+ readonly tools: number;
231
+ readonly resources: number;
232
+ readonly prompts: number;
233
+ readonly dirty: boolean;
234
+ readonly cachedAt?: string;
235
+ readonly lastError?: string;
236
+ }
237
+ interface McpServerLogs {
238
+ readonly serverId: string;
239
+ readonly status: McpServerRuntimeDiagnostics['status'];
240
+ readonly connect: McpConnectMode;
241
+ readonly lastError?: string;
242
+ readonly cachedAt?: string;
243
+ }
244
+ interface McpServerToolList {
245
+ readonly serverId: string;
246
+ readonly tools: readonly McpCapabilityDescriptor[];
247
+ readonly cachedAt?: string;
248
+ }
249
+ /**
250
+ * Full catalog snapshot for a server — tools + resources + prompts.
251
+ * Use {@link McpManager.getCatalog} when the popout needs to render
252
+ * all three capability kinds (not just tools).
253
+ *
254
+ * `cachedAt` matches the naming used by {@link McpServerStatus},
255
+ * {@link McpServerLogs}, and {@link McpServerToolList} for consistency
256
+ * across the manager surface (all are renames of the underlying
257
+ * `McpServerCatalogSnapshot.updatedAt` field).
258
+ */
259
+ interface McpServerCatalog {
260
+ readonly serverId: string;
261
+ readonly items: readonly McpCatalogItem[];
262
+ readonly descriptors: readonly McpCapabilityDescriptor[];
263
+ readonly cachedAt: string;
264
+ }
265
+ /**
266
+ * Manager-shape facade over {@link McpCapabilityProvider}. Construct
267
+ * via the {@link createMcpManager} factory or `new McpManager(...)`
268
+ * directly.
269
+ */
270
+ declare class McpManager {
271
+ private readonly capabilityProvider;
272
+ private readonly serversConfig;
273
+ constructor(servers: McpServersConfig | undefined, options?: McpProviderOptions);
274
+ /**
275
+ * Escape hatch — returns the underlying {@link McpCapabilityProvider}
276
+ * for callers that need the search / describe / execute / read /
277
+ * getPrompt API (e.g. embedding into a custom agent runtime).
278
+ */
279
+ provider(): McpCapabilityProvider;
280
+ /**
281
+ * One status row per configured server (lazy / prewarm / disabled
282
+ * all included). Returned objects are plain readonly snapshots —
283
+ * mutating them does NOT affect runtime state.
284
+ */
285
+ listServers(): McpServerStatus[];
286
+ /**
287
+ * Force a connection + catalog refresh for `serverId`. Returns the
288
+ * post-start status row. Throws if `serverId` is not configured.
289
+ *
290
+ * For lazy servers, this is the explicit "connect now" trigger —
291
+ * useful when a popout user clicks "Start" before any tool call has
292
+ * forced the lazy connection.
293
+ */
294
+ startServer(serverId: string): Promise<McpServerStatus>;
295
+ /**
296
+ * Disconnect `serverId` — closes the transport, drops the pending
297
+ * request queue, but keeps the server in the config so a subsequent
298
+ * `startServer` / `listTools` can reconnect. Returns the post-stop
299
+ * status (`status: 'idle'`).
300
+ */
301
+ stopServer(serverId: string): Promise<McpServerStatus>;
302
+ /**
303
+ * Return the most recent runtime diagnostic envelope for `serverId`
304
+ * — status, last error, last cached timestamp. Designed as the data
305
+ * source for a popout "Logs" pane.
306
+ *
307
+ * Logs API is intentionally conservative in v0.7.42: only the last
308
+ * error message + status are exposed. A future iteration may add a
309
+ * ring buffer of recent events; the field shape will extend (add
310
+ * fields), never break (rename / remove).
311
+ */
312
+ getServerLogs(serverId: string): McpServerLogs;
313
+ /**
314
+ * Return the tool descriptors for `serverId`. Triggers a lazy
315
+ * connect + catalog fetch if the catalog has not yet been built;
316
+ * pass `{ forceRefresh: true }` to force a fresh catalog regardless
317
+ * of cache state.
318
+ *
319
+ * Only `kind === 'tool'` descriptors are returned (filters out
320
+ * resources + prompts so popout consumers can render a clean
321
+ * "tools" table). Use the underlying `provider().describe(id)` for
322
+ * full descriptor introspection including resources + prompts.
323
+ */
324
+ listTools(serverId: string, options?: {
325
+ forceRefresh?: boolean;
326
+ }): Promise<McpServerToolList>;
327
+ /**
328
+ * Return the full catalog snapshot for `serverId` — every tool,
329
+ * resource, and prompt the server exposes — plus lightweight catalog
330
+ * items for menu rendering. `listTools` is the tools-only fast path;
331
+ * use this when the popout needs to render resources / prompts panes
332
+ * alongside tools.
333
+ *
334
+ * Triggers a lazy connect + catalog fetch if the catalog has not yet
335
+ * been built; pass `{ forceRefresh: true }` to force a fresh catalog
336
+ * regardless of cache state.
337
+ */
338
+ getCatalog(serverId: string, options?: {
339
+ forceRefresh?: boolean;
340
+ }): Promise<McpServerCatalog>;
341
+ /**
342
+ * Dispose all runtimes. After calling, the manager is no longer
343
+ * usable for `startServer` / `listTools` (they would reconnect, but
344
+ * the consumer should construct a fresh manager instead).
345
+ */
346
+ dispose(): Promise<void>;
347
+ /** v0.7.42 — escape hatch for advanced uses; usually consumers use the typed methods above. */
348
+ search(query: string, options?: {
349
+ kind?: CapabilityKind;
350
+ limit?: number;
351
+ server?: string;
352
+ }): Promise<readonly McpCatalogItem[]>;
353
+ /** v0.7.42 — escape hatch for advanced uses; usually consumers use {@link listTools}. */
354
+ describe(id: string): Promise<McpCapabilityDescriptor | undefined>;
355
+ /** v0.7.42 — invoke a tool by capability id (`mcp://<serverId>/<kind>/<name>`). */
356
+ execute(id: string, input: Record<string, unknown>): Promise<CapabilityResult>;
357
+ /** v0.7.42 — read a resource by capability id. */
358
+ read(id: string, options?: Record<string, unknown>): Promise<CapabilityResult>;
359
+ private requireRuntime;
360
+ private buildStatus;
361
+ }
362
+ /**
363
+ * Convenience factory matching the rest of the FEATURE_186 surface
364
+ * naming (`createSessionControl`, etc.). Equivalent to
365
+ * `new McpManager(servers, options)`.
366
+ */
367
+ declare function createMcpManager(servers: McpServersConfig | undefined, options?: McpProviderOptions): McpManager;
368
+
369
+ export { McpCapabilityProvider as b, McpManager as e, McpServerRuntime as j, createMcpCapabilityId as p, createMcpManager as q, createMcpTransport as r, defaultMcpCacheDir as s, getMcpCachePaths as t, parseMcpCapabilityId as u, searchMcpCatalog as v };
370
+ export type { McpCapabilityDescriptor as M, McpCapabilityKind as a, McpCapabilityRisk as c, McpCatalogItem as d, McpProviderOptions as f, McpServerCatalog as g, McpServerCatalogSnapshot as h, McpServerLogs as i, McpServerRuntimeDiagnostics as k, McpServerStatus as l, McpServerToolList as m, McpTransport as n, McpTransportEvents as o };
@@ -1,6 +1,6 @@
1
- import { D as KodaXReasoningMode, U as KodaXThinkingBudgetMap, V as KodaXThinkingDepth, r as KodaXProviderConfig, C as KodaXReasoningCapability, F as KodaXReasoningRequest, Q as KodaXTaskType, E as KodaXReasoningOverride, X as KodaXToolDefinition, m as KodaXMessage, z as KodaXProviderStreamOptions, J as KodaXStreamResult, q as KodaXProviderCapabilityProfile, h as KodaXCustomProviderConfig } from './types.d-B1uGoVTE.js';
1
+ import { D as KodaXReasoningMode, U as KodaXThinkingBudgetMap, V as KodaXThinkingDepth, r as KodaXProviderConfig, C as KodaXReasoningCapability, F as KodaXReasoningRequest, Q as KodaXTaskType, E as KodaXReasoningOverride, X as KodaXToolDefinition, m as KodaXMessage, z as KodaXProviderStreamOptions, J as KodaXStreamResult, n as KodaXModelDescriptor, q as KodaXProviderCapabilityProfile, h as KodaXCustomProviderConfig } from './types.d-B1uGoVTE.js';
2
2
  import Anthropic from '@anthropic-ai/sdk';
3
- import { K as KodaXBaseProvider } from './cost-tracker.d-B6vMoLLF.js';
3
+ import { K as KodaXBaseProvider } from './base.d-FUJahC0i.js';
4
4
  import OpenAI from 'openai';
5
5
 
6
6
  /**
@@ -155,13 +155,41 @@ declare abstract class KodaXOpenAICompatProvider extends KodaXBaseProvider {
155
155
  */
156
156
 
157
157
  type ProviderName = 'anthropic' | 'openai' | 'deepseek' | 'kimi' | 'kimi-code' | 'qwen' | 'zhipu' | 'zhipu-coding' | 'minimax-coding' | 'mimo-coding' | 'ark-coding' | 'gemini-cli' | 'codex-cli';
158
+ /**
159
+ * Per-provider static metadata. v0.7.43 — promoted from a partial
160
+ * descriptor (`models: string[]`) to the full capability surface so
161
+ * SDK consumers can read context windows / max output tokens /
162
+ * thinking-budget caps / per-model descriptors without instantiating
163
+ * a Provider class (which previously required a valid API key just
164
+ * to read static metadata — architectural mismatch).
165
+ *
166
+ * This map is now the single source of truth for capability data;
167
+ * Provider classes derive their runtime `config` from it via
168
+ * `buildProviderConfig`.
169
+ */
158
170
  type ProviderSnapshot = {
159
171
  model: string;
160
- models?: readonly string[];
172
+ /**
173
+ * Alternative model descriptors beyond the default `model`. Carries
174
+ * per-model capability overrides (`contextWindow` / `maxOutputTokens` /
175
+ * `thinkingBudgetCap` / `reasoningCapability` / `replayReasoningContent` /
176
+ * `strictThinkingSignature`). Provider-level defaults below fill any
177
+ * gaps a descriptor leaves unset. The default model has no descriptor
178
+ * entry — it inherits provider-level defaults directly.
179
+ */
180
+ models?: readonly KodaXModelDescriptor[];
161
181
  apiKeyEnv: string;
162
182
  reasoningCapability: KodaXReasoningCapability;
163
183
  modelReasoningCapabilities?: Partial<Record<string, KodaXReasoningCapability>>;
164
184
  capabilityProfile: KodaXProviderCapabilityProfile;
185
+ /** Maximum input context window (tokens). Provider-level default. */
186
+ contextWindow?: number;
187
+ /** Per-turn output token cap KodaX requests. Provider-level default. */
188
+ maxOutputTokens?: number;
189
+ /** Upper bound on `thinking_budget` for native-budget reasoning providers. */
190
+ thinkingBudgetCap?: number;
191
+ /** Whether the provider supports `thinking_budget` / native reasoning. */
192
+ supportsThinking?: boolean;
165
193
  };
166
194
  declare const KODAX_PROVIDER_SNAPSHOTS: Record<ProviderName, ProviderSnapshot>;
167
195
  declare const KODAX_PROVIDERS: Record<string, () => KodaXBaseProvider>;
@@ -181,6 +209,82 @@ declare function getProviderList(): Array<{
181
209
  }>;
182
210
  declare function getProviderModels(name: string): string[];
183
211
  declare function isProviderName(name: string): name is ProviderName;
212
+ /**
213
+ * Effective per-model capability surface. v0.7.43 SDK exposure.
214
+ *
215
+ * Values are resolved with the cascade:
216
+ * 1. Per-model descriptor override (`KodaXModelDescriptor` field)
217
+ * 2. Provider-level default (`KODAX_PROVIDER_SNAPSHOTS[name].*`)
218
+ * 3. `undefined` (the field is genuinely not advertised for this model)
219
+ *
220
+ * `displayName` falls back to `id` when not set; never undefined.
221
+ *
222
+ * **All fields below are KodaX-maintained values** — they reflect what
223
+ * KodaX itself uses at runtime (the per-turn `max_tokens` we request,
224
+ * the thinking budget we cap at, etc.), benchmarked against the upstream
225
+ * model so they are honest representations of the agent's behavior. They
226
+ * are deliberately NOT sourced from upstream `/models` API responses,
227
+ * which a 2026-05 cross-provider probe confirmed are sparse and often
228
+ * empty (see docs/SDK_EMBEDDER_GUIDE.md §9). Embedders showing these
229
+ * values in a popout UI can trust them.
230
+ */
231
+ interface KodaXModelCapabilities {
232
+ /** Provider name (`anthropic`, `kimi`, `ark-coding`, or any custom name). */
233
+ provider: string;
234
+ /** Model id (the value `runKodaX(... { model } ...)` accepts). */
235
+ model: string;
236
+ /** Human-readable label — falls back to `model` when no descriptor entry. */
237
+ displayName: string;
238
+ /** Whether the provider supports `thinking_budget` / native reasoning. */
239
+ supportsThinking: boolean;
240
+ /** Effective reasoning capability for THIS model (per-model override aware). */
241
+ reasoningCapability: KodaXReasoningCapability;
242
+ /** Maximum input context window (tokens). `undefined` for CLI-bridge providers. */
243
+ contextWindow?: number;
244
+ /**
245
+ * Per-turn `max_tokens` KodaX requests. KodaX-side decision —
246
+ * benchmarked against each provider (kill-windows, decode rate, cost
247
+ * predictability). NOT the upstream "theoretical maximum" — providers
248
+ * often advertise inflated ceilings; this value reflects what KodaX
249
+ * actually asks for. If you display "expected output size" in your UI,
250
+ * use this. Long generations escalate through the L5 continuation
251
+ * meta path, not by raising this number per-turn.
252
+ */
253
+ maxOutputTokens?: number;
254
+ /** Upper bound on `thinking_budget` (native-budget providers only). */
255
+ thinkingBudgetCap?: number;
256
+ /** True when the model is the provider's default (the `model` field on the snapshot). */
257
+ isDefault: boolean;
258
+ }
259
+ /**
260
+ * List all model descriptors for a built-in provider — default model first,
261
+ * then alternatives. No API key required (reads from KODAX_PROVIDER_SNAPSHOTS).
262
+ *
263
+ * Returns an empty array for unknown provider names so SDK consumers can
264
+ * iterate `[...KODAX_PROVIDER_LIST, ...customNames]` without a guard per name.
265
+ */
266
+ declare function getProviderModelDescriptors(name: string): KodaXModelDescriptor[];
267
+ /**
268
+ * Effective per-model capability surface for a built-in provider. Returns
269
+ * `undefined` for unknown provider name or unknown model under a known
270
+ * provider — caller should fall back to `DEFAULT_CONTEXT_WINDOW` from
271
+ * `@kodax-ai/kodax/agent` when nothing is advertised.
272
+ *
273
+ * No API key required.
274
+ */
275
+ declare function getModelCapabilities(providerName: string, modelId: string): KodaXModelCapabilities | undefined;
276
+ /**
277
+ * Full capability listing for every built-in provider/model pair. Default
278
+ * model comes first per provider, in the order providers appear in
279
+ * `KODAX_PROVIDERS`. Use this for popout UIs that enumerate all models
280
+ * without filtering by `configured` (the consumer can filter post-hoc by
281
+ * checking `process.env[snapshot.apiKeyEnv]` themselves, or just present
282
+ * everything for selection).
283
+ *
284
+ * Custom-provider models are exposed via the equivalent helper in
285
+ * `custom-registry.ts` (`getCustomProviderModelCapabilities`).
286
+ */
287
+ declare function listBuiltinModelCapabilities(): KodaXModelCapabilities[];
184
288
 
185
289
  /**
186
290
  * Custom Provider Factory
@@ -230,6 +334,25 @@ declare function getCustomProviderList(): Array<{
230
334
  * Returns undefined if not a custom provider.
231
335
  */
232
336
  declare function getCustomProviderModels(name: string): string[] | undefined;
337
+ /**
338
+ * List all model descriptors for a custom provider. Default model first,
339
+ * then alternatives. Returns undefined when the name doesn't match any
340
+ * registered custom provider — caller can fall through to the built-in
341
+ * `getProviderModelDescriptors`.
342
+ */
343
+ declare function getCustomProviderModelDescriptors(name: string): KodaXModelDescriptor[] | undefined;
344
+ /**
345
+ * Effective per-model capability surface for a custom provider. Returns
346
+ * undefined when the provider name is not a registered custom provider,
347
+ * OR when the model id doesn't appear under that provider. The same
348
+ * descriptor-then-provider cascade as the built-in counterpart.
349
+ */
350
+ declare function getCustomModelCapabilities(providerName: string, modelId: string): KodaXModelCapabilities | undefined;
351
+ /**
352
+ * Full capability listing for every registered custom provider / model.
353
+ * Mirrors `listBuiltinModelCapabilities`. Default model first per provider.
354
+ */
355
+ declare function listCustomProviderModelCapabilities(): KodaXModelCapabilities[];
233
356
 
234
357
  type ModelProviderFactory = () => KodaXBaseProvider;
235
358
  declare function registerModelProvider(name: string, factory: ModelProviderFactory): () => void;
@@ -258,6 +381,27 @@ declare function isKnownProvider(name: string): boolean;
258
381
  * Get all available provider names (built-in + custom).
259
382
  */
260
383
  declare function getAvailableProviderNames(): string[];
384
+ /**
385
+ * Model descriptors for any registered provider (built-in or custom).
386
+ * Default model first, then alternatives. Empty array if name unknown.
387
+ */
388
+ declare function resolveProviderModelDescriptors(name: string): KodaXModelDescriptor[];
389
+ /**
390
+ * Effective capabilities for a single provider/model pair. Built-in
391
+ * lookup first, then custom. Returns undefined when neither has it.
392
+ */
393
+ declare function resolveModelCapabilities(providerName: string, modelId: string): KodaXModelCapabilities | undefined;
394
+ /**
395
+ * Every model capability KodaX knows about — built-in + custom — in
396
+ * a single flat list. Built-in providers come first (in `KODAX_PROVIDERS`
397
+ * declaration order), then custom providers (in registration order).
398
+ * Within each provider, default model first.
399
+ *
400
+ * Use for popout UIs that need a single source for a model picker.
401
+ * No filtering by `configured` — consumers can subset themselves by
402
+ * checking `process.env[snapshot.apiKeyEnv]` if they care.
403
+ */
404
+ declare function listAllModelCapabilities(): KodaXModelCapabilities[];
261
405
 
262
- export { getProviderList as A, getProviderModel as B, getProviderModels as C, getReasoningCapability as D, getRuntimeModelProvider as E, getRuntimeModelProviderNames as F, isCustomProviderName as G, isKnownProvider as H, isProviderConfigured as I, isProviderName as J, KODAX_DEFAULT_PROVIDER as K, isReasoningEnabled as L, isRuntimeModelProviderName as M, loadReasoningOverride as N, mapDepthToOpenAIReasoningEffort as O, normalizeReasoningRequest as Q, reasoningCapabilityToOverride as R, reasoningOverrideToCapability as S, registerCustomProviders as T, registerModelProvider as U, resolveProvider as V, resolveThinkingBudget as W, saveReasoningOverride as X, validateCustomProviderConfig as Y, KODAX_DEFAULT_THINKING_BUDGETS as a, KODAX_PROVIDERS as b, KODAX_PROVIDER_SNAPSHOTS as c, KODAX_REASONING_MODE_SEQUENCE as d, KODAX_REASONING_SAFETY_RESERVE as e, KodaXAnthropicCompatProvider as f, KodaXError as g, KodaXNetworkError as h, KodaXOpenAICompatProvider as i, KodaXProviderError as j, KodaXRateLimitError as k, KodaXToolCallIdError as l, buildReasoningOverrideKey as m, clampThinkingBudget as n, clearReasoningOverride as o, clearRuntimeModelProviders as p, createCustomProvider as q, getAvailableProviderNames as r, getCustomProvider as s, getCustomProviderList as t, getCustomProviderModels as u, getCustomProviderNames as v, getDefaultThinkingDepthForMode as w, getProvider as x, getProviderConfiguredCapabilityProfile as y, getProviderConfiguredReasoningCapability as z };
263
- export type { ProviderName as P };
406
+ export { registerCustomProviders as $, getModelCapabilities as A, getProvider as B, getProviderConfiguredCapabilityProfile as C, getProviderConfiguredReasoningCapability as D, getProviderList as E, getProviderModel as F, getProviderModelDescriptors as G, getProviderModels as H, getReasoningCapability as I, getRuntimeModelProvider as J, KODAX_DEFAULT_PROVIDER as K, getRuntimeModelProviderNames as L, isCustomProviderName as M, isKnownProvider as N, isProviderConfigured as O, isProviderName as Q, isReasoningEnabled as R, isRuntimeModelProviderName as S, listAllModelCapabilities as T, listBuiltinModelCapabilities as U, listCustomProviderModelCapabilities as V, loadReasoningOverride as W, mapDepthToOpenAIReasoningEffort as X, normalizeReasoningRequest as Y, reasoningCapabilityToOverride as Z, reasoningOverrideToCapability as _, KODAX_DEFAULT_THINKING_BUDGETS as a, registerModelProvider as a0, resolveModelCapabilities as a1, resolveProvider as a2, resolveProviderModelDescriptors as a3, resolveThinkingBudget as a4, saveReasoningOverride as a5, validateCustomProviderConfig as a6, KODAX_PROVIDERS as b, KODAX_PROVIDER_SNAPSHOTS as c, KODAX_REASONING_MODE_SEQUENCE as d, KODAX_REASONING_SAFETY_RESERVE as e, KodaXAnthropicCompatProvider as f, KodaXError as g, KodaXNetworkError as i, KodaXOpenAICompatProvider as j, KodaXProviderError as k, KodaXRateLimitError as l, KodaXToolCallIdError as m, buildReasoningOverrideKey as n, clampThinkingBudget as o, clearReasoningOverride as p, clearRuntimeModelProviders as q, createCustomProvider as r, getAvailableProviderNames as s, getCustomModelCapabilities as t, getCustomProvider as u, getCustomProviderList as v, getCustomProviderModelDescriptors as w, getCustomProviderModels as x, getCustomProviderNames as y, getDefaultThinkingDepthForMode as z };
407
+ export type { ProviderName as P, KodaXModelCapabilities as h };
@@ -1,4 +1,4 @@
1
- import { k as KodaXSessionData, o as KodaXSessionLineage, r as KodaXSessionNavigationOptions, s as KodaXSessionRuntimeInfo } from './types.d-mM8vqvhT.js';
1
+ import { k as KodaXSessionData, o as KodaXSessionLineage, r as KodaXSessionNavigationOptions, s as KodaXSessionRuntimeInfo, u as KodaXSessionStorage } from './types.d-mM8vqvhT.js';
2
2
 
3
3
  /**
4
4
  * Session Storage - Session storage abstraction layer
@@ -64,5 +64,52 @@ declare class MemorySessionStorage implements SessionStorage {
64
64
  }
65
65
  declare function createMemorySessionStorage(): SessionStorage;
66
66
 
67
- export { MemorySessionStorage as M, createMemorySessionStorage as c };
67
+ /**
68
+ * KodaX session storage - filesystem implementation.
69
+ */
70
+
71
+ declare class FileSessionStorage implements KodaXSessionStorage {
72
+ private readonly sessionsDir;
73
+ constructor(opts?: {
74
+ sessionsDir?: string;
75
+ });
76
+ private writeQueues;
77
+ private serializedWrite;
78
+ private appendState;
79
+ /** Update watermarks. Only overwrites fields the caller actually provided. */
80
+ private syncAppendState;
81
+ private getSessionFilePath;
82
+ private getArchiveFilePath;
83
+ private readSession;
84
+ private writeSessionInternal;
85
+ private mergeAndWriteInternal;
86
+ appendSessionDelta(id: string, data: SessionData): Promise<void>;
87
+ private shouldRunMaintenance;
88
+ private runMaintenance;
89
+ save(id: string, data: SessionData): Promise<void>;
90
+ load(id: string): Promise<SessionData | null>;
91
+ getLineage(id: string): Promise<KodaXSessionLineage | null>;
92
+ setActiveEntry(id: string, selector: string, options?: {
93
+ summarizeCurrentBranch?: boolean;
94
+ }): Promise<SessionData | null>;
95
+ rewind(id: string, selector?: string): Promise<SessionData | null>;
96
+ setLabel(id: string, selector: string, label?: string): Promise<SessionData | null>;
97
+ fork(id: string, selector?: string, options?: {
98
+ sessionId?: string;
99
+ title?: string;
100
+ }): Promise<{
101
+ sessionId: string;
102
+ data: SessionData;
103
+ } | null>;
104
+ list(gitRoot?: string): Promise<Array<{
105
+ id: string;
106
+ title: string;
107
+ msgCount: number;
108
+ runtimeInfo?: KodaXSessionRuntimeInfo;
109
+ }>>;
110
+ delete(id: string): Promise<void>;
111
+ deleteAll(gitRoot?: string): Promise<void>;
112
+ }
113
+
114
+ export { FileSessionStorage as F, MemorySessionStorage as M, createMemorySessionStorage as c };
68
115
  export type { SessionData as S, SessionStorage as a };