@kodax-ai/kodax 0.7.44 → 0.7.46

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 (52) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +6 -5
  3. package/README_CN.md +6 -5
  4. package/dist/builtin/skill-creator/scripts/utils.js +12 -27
  5. package/dist/chunks/chunk-2GEKCIIW.js +31 -0
  6. package/dist/chunks/chunk-ARUWXX25.js +2 -0
  7. package/dist/chunks/chunk-JRT447X5.js +565 -0
  8. package/dist/chunks/chunk-K4RBLNSY.js +2 -0
  9. package/dist/chunks/chunk-VBIVZOSD.js +425 -0
  10. package/dist/chunks/{chunk-4YPL2UVZ.js → chunk-XUEINS3X.js} +253 -252
  11. package/dist/chunks/{chunk-RUDYNAK7.js → chunk-Z4UT32NN.js} +1 -1
  12. package/dist/chunks/{compaction-config-NAPRF7XR.js → compaction-config-PFTBIGQT.js} +1 -1
  13. package/dist/chunks/{construction-bootstrap-PHTGBRNU.js → construction-bootstrap-2FKNOZZE.js} +1 -1
  14. package/dist/chunks/devtools-4CRULTR2.js +2 -0
  15. package/dist/chunks/devtools-YINBSZC7.js +2 -0
  16. package/dist/chunks/dist-JLMKDPEL.js +2 -0
  17. package/dist/chunks/dist-QTV5M2JW.js +2 -0
  18. package/dist/chunks/{utils-TV3UYCHQ.js → utils-LY3LB65Z.js} +1 -1
  19. package/dist/index.d.ts +11 -11
  20. package/dist/index.js +2 -2
  21. package/dist/kodax_cli.js +913 -863
  22. package/dist/provider-capabilities.json +46 -18
  23. package/dist/sdk-agent.d.ts +55 -10
  24. package/dist/sdk-agent.js +1 -1
  25. package/dist/sdk-coding.d.ts +31 -13
  26. package/dist/sdk-coding.js +1 -1
  27. package/dist/sdk-llm.d.ts +84 -7
  28. package/dist/sdk-llm.js +1 -1
  29. package/dist/sdk-mcp.js +1 -1
  30. package/dist/sdk-repl.d.ts +19 -9
  31. package/dist/sdk-repl.js +2 -2
  32. package/dist/sdk-session.d.ts +27 -6
  33. package/dist/sdk-session.js +1 -1
  34. package/dist/sdk-skills.js +1 -1
  35. package/dist/types-chunks/{base.d-FUJahC0i.d.ts → base.d-BdJKSPO2.d.ts} +18 -1
  36. package/dist/types-chunks/{bash-prefix-extractor.d-DdoSeghD.d.ts → bash-prefix-extractor.d-BICYx8pt.d.ts} +184 -141
  37. package/dist/types-chunks/{file-tracker.d-DOfaoCbJ.d.ts → file-tracker.d-BNTIvsdb.d.ts} +11 -4
  38. package/dist/types-chunks/{resolver.d-B7ZnVuuf.d.ts → resolver.d-DkgJlEzr.d.ts} +80 -4
  39. package/dist/types-chunks/storage.d-B1Jk6ryM.d.ts +202 -0
  40. package/dist/types-chunks/{types.d-HBbWT-iA.d.ts → types.d-B_MIIApc.d.ts} +1 -1
  41. package/dist/types-chunks/{types.d-B1uGoVTE.d.ts → types.d-Cf-GCzac.d.ts} +82 -1
  42. package/dist/types-chunks/{types.d-DM8zEJgF.d.ts → types.d-D2RNa5Y7.d.ts} +2 -2
  43. package/dist/types-chunks/{utils.d-C5fzCE9W.d.ts → utils.d-pzHPkrb8.d.ts} +31 -5
  44. package/package.json +1 -1
  45. package/dist/chunks/chunk-35BDEEC5.js +0 -2
  46. package/dist/chunks/chunk-DI2G3YWL.js +0 -31
  47. package/dist/chunks/chunk-HHQ7YTGM.js +0 -425
  48. package/dist/chunks/chunk-QHILHQBB.js +0 -519
  49. package/dist/chunks/devtools-EYGFOXEU.js +0 -2
  50. package/dist/chunks/dist-CCYBJJZY.js +0 -2
  51. package/dist/chunks/dist-RHIHZAYX.js +0 -2
  52. package/dist/types-chunks/storage.d-DFD9ln5c.d.ts +0 -115
@@ -0,0 +1,202 @@
1
+ import { n as KodaXSessionData, s as KodaXSessionLineage, v as KodaXSessionNavigationOptions, w as KodaXSessionRuntimeInfo, y as KodaXSessionStorage } from './types.d-B_MIIApc.js';
2
+
3
+ /**
4
+ * Session Storage - Session storage abstraction layer
5
+ *
6
+ * Provides a shared persistence interface across memory and filesystem storage.
7
+ */
8
+
9
+ /**
10
+ * Session data structure.
11
+ */
12
+ type SessionData = KodaXSessionData;
13
+ /**
14
+ * Session storage interface.
15
+ */
16
+ interface SessionStorage {
17
+ save(id: string, data: SessionData): Promise<void>;
18
+ load(id: string): Promise<SessionData | null>;
19
+ getLineage?(id: string): Promise<KodaXSessionLineage | null>;
20
+ setActiveEntry?(id: string, selector: string, options?: KodaXSessionNavigationOptions): Promise<SessionData | null>;
21
+ setLabel?(id: string, selector: string, label?: string): Promise<SessionData | null>;
22
+ rewind?(id: string, selector?: string): Promise<SessionData | null>;
23
+ fork?(id: string, selector?: string, options?: {
24
+ sessionId?: string;
25
+ title?: string;
26
+ }): Promise<{
27
+ sessionId: string;
28
+ data: SessionData;
29
+ } | null>;
30
+ list(gitRoot?: string): Promise<Array<{
31
+ id: string;
32
+ title: string;
33
+ msgCount: number;
34
+ runtimeInfo?: KodaXSessionRuntimeInfo;
35
+ }>>;
36
+ delete?(id: string): Promise<void>;
37
+ deleteAll?(gitRoot?: string): Promise<void>;
38
+ }
39
+ /**
40
+ * In-memory session storage implementation.
41
+ */
42
+ declare class MemorySessionStorage implements SessionStorage {
43
+ private sessions;
44
+ save(id: string, data: SessionData): Promise<void>;
45
+ load(id: string): Promise<SessionData | null>;
46
+ getLineage(id: string): Promise<KodaXSessionLineage | null>;
47
+ setActiveEntry(id: string, selector: string, options?: KodaXSessionNavigationOptions): Promise<SessionData | null>;
48
+ setLabel(id: string, selector: string, label?: string): Promise<SessionData | null>;
49
+ fork(id: string, selector?: string, options?: {
50
+ sessionId?: string;
51
+ title?: string;
52
+ }): Promise<{
53
+ sessionId: string;
54
+ data: SessionData;
55
+ } | null>;
56
+ rewind(id: string, selector?: string): Promise<SessionData | null>;
57
+ list(_gitRoot?: string): Promise<Array<{
58
+ id: string;
59
+ title: string;
60
+ msgCount: number;
61
+ }>>;
62
+ delete(id: string): Promise<void>;
63
+ deleteAll(_gitRoot?: string): Promise<void>;
64
+ }
65
+ declare function createMemorySessionStorage(): SessionStorage;
66
+
67
+ /**
68
+ * KodaX session storage - filesystem implementation.
69
+ */
70
+
71
+ declare class FileSessionStorage implements KodaXSessionStorage {
72
+ private readonly sessionsDir;
73
+ /**
74
+ * v0.7.46 — optional explicit project cwd for in-process embedders
75
+ * (KodaX Space) serving multiple projects from a single runtime.
76
+ * Threaded through `getGitRoot(this.hostCwd)` and `inspectWorkspaceRuntime({cwd: this.hostCwd})`
77
+ * so the workspace-mismatch check in `load()` compares against the
78
+ * project the embedder opened, NOT the embedder's startup directory.
79
+ * Unset → all paths behave identically to the pre-v0.7.46 form.
80
+ */
81
+ private readonly hostCwd?;
82
+ /**
83
+ * v0.7.46 F7 — explicit opt-in for the CLI-style "[Warning] Session
84
+ * project mismatch" stderr notice emitted from `load()`. Pre-v0.7.46
85
+ * the gate was `!this.hostCwd` which fired whenever the embedder
86
+ * hadn't supplied a cwd — but that ALSO matched SDK consumers who
87
+ * don't set cwd (e.g. KodaX Space), bleeding the yellow warning into
88
+ * their stdout/stderr UI channels on every cross-project load. The
89
+ * v0.7.46 default is `false` — silent. CLI surfaces that want the
90
+ * old behavior (warn when user resumes a session from outside its
91
+ * original project) can pass `emitMismatchWarnings: true`.
92
+ */
93
+ private readonly emitMismatchWarnings;
94
+ constructor(opts?: {
95
+ sessionsDir?: string;
96
+ cwd?: string;
97
+ emitMismatchWarnings?: boolean;
98
+ });
99
+ private writeQueues;
100
+ private serializedWrite;
101
+ private appendState;
102
+ private sessionDirCache;
103
+ private projectJsonWritten;
104
+ private migrationPromise?;
105
+ private ensureMigrated;
106
+ /** Update watermarks. Only overwrites fields the caller actually provided. */
107
+ private syncAppendState;
108
+ private legacyFlatPath;
109
+ private legacyFlatArchivePath;
110
+ private projectDir;
111
+ /** Resolve (and cache) the project directory a write for `id` should land in. */
112
+ private resolveWriteDir;
113
+ private writeFilePath;
114
+ /**
115
+ * id-only locator (ADR-038 §7). Resolution order:
116
+ * 1. cached project dir for this id
117
+ * 2. bounded scan of project dirs: <key>/<id>.jsonl
118
+ * 3. bounded scan of archived: <key>/archived/<id>.jsonl
119
+ * 4. legacy flat: <sessionsDir>/<id>.jsonl
120
+ * On multiple matches (only possible for pre-FEATURE_219 same-second
121
+ * duplicate ids) it prefers the current process's project dir, else
122
+ * returns null with a warning rather than guessing.
123
+ */
124
+ private resolveSessionLocation;
125
+ private readSession;
126
+ /** Write `<dir>/project.json` once per process per directory (best-effort). */
127
+ private ensureProjectJson;
128
+ private writeSessionInternal;
129
+ private mergeAndWriteInternal;
130
+ appendSessionDelta(id: string, data: SessionData): Promise<void>;
131
+ private shouldRunMaintenance;
132
+ private runMaintenance;
133
+ save(id: string, data: SessionData): Promise<void>;
134
+ load(id: string): Promise<SessionData | null>;
135
+ getLineage(id: string): Promise<KodaXSessionLineage | null>;
136
+ setActiveEntry(id: string, selector: string, options?: {
137
+ summarizeCurrentBranch?: boolean;
138
+ }): Promise<SessionData | null>;
139
+ rewind(id: string, selector?: string): Promise<SessionData | null>;
140
+ setLabel(id: string, selector: string, label?: string): Promise<SessionData | null>;
141
+ fork(id: string, selector?: string, options?: {
142
+ sessionId?: string;
143
+ title?: string;
144
+ }): Promise<{
145
+ sessionId: string;
146
+ data: SessionData;
147
+ } | null>;
148
+ /**
149
+ * v0.7.46 — `opts.limit` added so SDK consumers can request more than
150
+ * the legacy 10-entry cap. Default stays at 10 to preserve the
151
+ * interactive REPL picker's behavior. The `public-api.ts` fast path
152
+ * forwards the caller's `limit`; `deleteAll()` passes a large value
153
+ * so it can enumerate ALL sessions for the gitRoot.
154
+ *
155
+ * v0.7.46 — return now carries `createdAt` so the fast path in
156
+ * `public-api.ts` no longer silently strips it. Pre-v0.7.46 callers
157
+ * that only destructured `{id, title, msgCount, runtimeInfo}` are
158
+ * unaffected (extra fields are ignored).
159
+ */
160
+ list(gitRoot?: string, opts?: {
161
+ limit?: number;
162
+ includeArchived?: boolean;
163
+ }): Promise<Array<{
164
+ id: string;
165
+ title: string;
166
+ msgCount: number;
167
+ runtimeInfo?: KodaXSessionRuntimeInfo;
168
+ archived?: boolean;
169
+ createdAt?: string;
170
+ }>>;
171
+ /**
172
+ * FEATURE_219 Phase 4 — whole-session archive (ADR-038 §4). Moves the session
173
+ * file together with its island sidecar into `<projectKey>/archived/`. Paired
174
+ * (never orphans the sidecar). No-op + returns false for a missing session.
175
+ */
176
+ archive(id: string): Promise<boolean>;
177
+ /** Restore an archived session back into its project directory. */
178
+ unarchive(id: string): Promise<boolean>;
179
+ /**
180
+ * Move a session + its island sidecar between two directories. Propagates a
181
+ * non-ENOENT rename error (e.g. Windows file-in-use) so a partial move is
182
+ * surfaced as a failure instead of silently splitting main + sidecar.
183
+ */
184
+ private movePair;
185
+ delete(id: string): Promise<void>;
186
+ deleteAll(gitRoot?: string): Promise<void>;
187
+ /**
188
+ * Auto-retention: delete session files (`.jsonl` + `.archive.jsonl`) whose
189
+ * mtime is older than `retentionDays`. Modeled on claudecode's
190
+ * `cleanup.ts` (`unlinkIfOld`). Bounds the sessions directory so it never
191
+ * accumulates unboundedly — which is what keeps `list()`'s head-read pass
192
+ * fast (its cost scales with file COUNT, not size). A non-positive /
193
+ * non-finite `retentionDays` disables cleanup (no-op). Best-effort: per-file
194
+ * errors are swallowed so a single locked/racing file never aborts the
195
+ * sweep. Returns the number of files removed. mtime-based, so the session
196
+ * currently being written/resumed (fresh mtime) is never eligible.
197
+ */
198
+ cleanupOldSessions(retentionDays: number): Promise<number>;
199
+ }
200
+
201
+ export { FileSessionStorage as F, MemorySessionStorage as M, createMemorySessionStorage as c };
202
+ export type { SessionData as S, SessionStorage as a };
@@ -1,4 +1,4 @@
1
- import { m as KodaXMessage } from './types.d-B1uGoVTE.js';
1
+ import { n as KodaXMessage } from './types.d-Cf-GCzac.js';
2
2
 
3
3
  /**
4
4
  * @kodax-ai/agent Types
@@ -240,6 +240,69 @@ interface KodaXModelDescriptor {
240
240
  }
241
241
  type KodaXProtocolFamily = 'anthropic' | 'openai';
242
242
  type KodaXProviderUserAgentMode = 'compat' | 'sdk';
243
+ /**
244
+ * FEATURE_216 v0.7.45 — Strategy KodaX uses to verify a provider's API
245
+ * credentials. Per-provider data-driven (set in `provider-capabilities.json`)
246
+ * because the 14 providers KodaX ships do not share a single zero-token
247
+ * verify primitive — empirically 3 distinct strategies are needed:
248
+ *
249
+ * - `count-tokens`: Anthropic-protocol `messages.countTokens()` —
250
+ * true 0-token (input_tokens reported but no model invocation).
251
+ * Use for Anthropic-compat providers whose upstream implements
252
+ * `/v1/messages/count_tokens`.
253
+ * - `models-list`: `models.list()` — 0-token, authenticated GET.
254
+ * Use ONLY when the provider's `/v1/models` endpoint actually
255
+ * gates on auth (some compat layers expose it publicly → false
256
+ * positives; others 401 even for valid keys → false negatives).
257
+ * - `minimal-message`: `{messages,chat.completions}.create({max_tokens:1})`
258
+ * — ~6-7 tokens / call. Universal fallback for providers where
259
+ * the above two are unreliable. Cost is trivial for UI-button
260
+ * "test connection" use cases (≈ $0.00001 per verify).
261
+ * - `unsupported`: Provider has no verify primitive (CLI bridges
262
+ * own credentials in their own subprocess token store; the SDK
263
+ * does not enter that surface).
264
+ */
265
+ type KodaXVerifyStrategy = 'count-tokens' | 'models-list' | 'minimal-message' | 'unsupported';
266
+ /**
267
+ * FEATURE_216 v0.7.45 — Never-throws result envelope for
268
+ * `provider.verifyCredential()` / `verifyProviderCredential(name)`.
269
+ * Mirrors `side-query.ts` `SideQueryResult` pattern: every failure
270
+ * mode is captured in the returned object — no rejection, no throw.
271
+ */
272
+ interface KodaXVerifyCredentialResult {
273
+ readonly ok: boolean;
274
+ /** HTTP status when applicable (verify primitives that hit the wire). */
275
+ readonly status?: number;
276
+ /**
277
+ * Error category. Stable for UI consumers to map to user-facing
278
+ * states ("invalid key", "no network", "provider doesn't support
279
+ * verification", etc.). `unconfigured` is set by the top-level
280
+ * helper when env var is missing — avoids the provider ctor throw
281
+ * (per FEATURE_198 model-capabilities exposure pattern).
282
+ */
283
+ readonly error?: 'unauthorized' | 'network' | 'timeout' | 'unsupported' | 'unconfigured' | 'server_error' | 'rate_limited' | 'unknown';
284
+ /** Upstream error body or short diagnostic, capped to 240 chars. */
285
+ readonly message?: string;
286
+ readonly durationMs: number;
287
+ /** Estimated token cost: 0 (count-tokens / models-list) or ~6-7 (minimal-message). */
288
+ readonly approxTokensSpent: number;
289
+ /** Which strategy ran (or 'unsupported' if no primitive was attempted). */
290
+ readonly strategy: KodaXVerifyStrategy;
291
+ }
292
+ /**
293
+ * FEATURE_216 v0.7.45 — Best-effort upstream model listing. Distinct from
294
+ * credential verification: this is for "model picker" UIs. Mixes upstream
295
+ * `/v1/models` data with static `provider-capabilities.json` fallback when
296
+ * the upstream endpoint is unreliable. NOT a cred test — for that, call
297
+ * `verifyProviderCredential()`.
298
+ */
299
+ interface KodaXListModelsResult {
300
+ readonly ok: boolean;
301
+ readonly source: 'upstream' | 'static' | 'failed';
302
+ readonly models?: readonly string[];
303
+ readonly error?: string;
304
+ readonly durationMs: number;
305
+ }
243
306
  interface KodaXCustomProviderConfig {
244
307
  name: string;
245
308
  protocol: KodaXProtocolFamily;
@@ -287,6 +350,15 @@ interface KodaXCustomProviderConfig {
287
350
  * override.
288
351
  */
289
352
  streamMaxDurationMs?: number;
353
+ /**
354
+ * FEATURE_216 v0.7.45 — Which verify primitive this provider supports.
355
+ * Optional: when unset, the SDK derives a default from `protocol`
356
+ * (anthropic → count-tokens / openai → models-list). Set explicitly when
357
+ * the upstream `/v1/models` is public (false-positive risk) or the
358
+ * `messages.count_tokens` endpoint is unimplemented (404), in which
359
+ * case `minimal-message` is the only safe fallback.
360
+ */
361
+ verifyStrategy?: KodaXVerifyStrategy;
290
362
  }
291
363
  interface KodaXProviderConfig {
292
364
  apiKeyEnv: string;
@@ -349,6 +421,15 @@ interface KodaXProviderConfig {
349
421
  * the ~RTT margin between client send and server kill timestamp).
350
422
  */
351
423
  streamMaxDurationMs?: number;
424
+ /**
425
+ * FEATURE_216 v0.7.45 — Which verify primitive this provider's compat
426
+ * base class uses for `verifyCredential()`. Sourced from
427
+ * `provider-capabilities.json` for built-in providers; for custom
428
+ * providers, falls back to a protocol-derived default
429
+ * (anthropic → count-tokens / openai → models-list) when the custom
430
+ * config does not set it explicitly.
431
+ */
432
+ verifyStrategy?: KodaXVerifyStrategy;
352
433
  }
353
434
  interface KodaXProviderStreamOptions {
354
435
  onTextDelta?: (text: string) => void;
@@ -397,4 +478,4 @@ interface KodaXProviderStreamOptions {
397
478
  signal?: AbortSignal;
398
479
  }
399
480
 
400
- export type { KodaXToolResultTextItem as $, KodaXProviderToolCallingFidelity as A, KodaXProviderTransport as B, KodaXReasoningCapability as C, KodaXReasoningMode as D, KodaXReasoningOverride as E, KodaXReasoningRequest as F, KodaXRedactedThinkingBlock as G, KodaXReviewScale as H, KodaXRiskLevel as I, KodaXStreamResult as J, KodaXAmaControllerDecision as K, KodaXTaskActionability as L, KodaXTaskBudgetOverrides as M, KodaXTaskComplexity as N, KodaXTaskFamily as O, KodaXTaskRoutingDecision as P, KodaXTaskType as Q, KodaXTaskWorkIntent as R, KodaXTextBlock as S, KodaXThinkingBlock as T, KodaXThinkingBudgetMap as U, KodaXThinkingDepth as V, KodaXTokenUsage as W, KodaXToolDefinition as X, KodaXToolResultBlock as Y, KodaXToolResultContentItem as Z, KodaXToolResultImageItem as _, KodaXAmaFanoutClass as a, KodaXToolUseBlock as a0, KodaXAmaFanoutPolicy as b, KodaXAmaProfile as c, KodaXAmaTactic as d, KodaXAssuranceIntent as e, KodaXCacheBoundary as f, KodaXContentBlock as g, KodaXCustomProviderConfig as h, KodaXExecutionMode as i, KodaXExecutionPattern as j, KodaXHarnessProfile as k, KodaXImageBlock as l, KodaXMessage as m, KodaXModelDescriptor as n, KodaXMutationSurface as o, KodaXProtocolFamily as p, KodaXProviderCapabilityProfile as q, KodaXProviderConfig as r, KodaXProviderContextFidelity as s, KodaXProviderConversationSemantics as t, KodaXProviderEvidenceSupport as u, KodaXProviderLongRunningSupport as v, KodaXProviderMcpSupport as w, KodaXProviderMultimodalSupport as x, KodaXProviderSessionSupport as y, KodaXProviderStreamOptions as z };
481
+ export type { KodaXToolResultImageItem as $, KodaXProviderStreamOptions as A, KodaXProviderToolCallingFidelity as B, KodaXProviderTransport as C, KodaXReasoningCapability as D, KodaXReasoningMode as E, KodaXReasoningOverride as F, KodaXReasoningRequest as G, KodaXRedactedThinkingBlock as H, KodaXReviewScale as I, KodaXRiskLevel as J, KodaXAmaControllerDecision as K, KodaXStreamResult as L, KodaXTaskActionability as M, KodaXTaskBudgetOverrides as N, KodaXTaskComplexity as O, KodaXTaskFamily as P, KodaXTaskRoutingDecision as Q, KodaXTaskType as R, KodaXTaskWorkIntent as S, KodaXTextBlock as T, KodaXThinkingBlock as U, KodaXThinkingBudgetMap as V, KodaXThinkingDepth as W, KodaXTokenUsage as X, KodaXToolDefinition as Y, KodaXToolResultBlock as Z, KodaXToolResultContentItem as _, KodaXAmaFanoutClass as a, KodaXToolResultTextItem as a0, KodaXToolUseBlock as a1, KodaXVerifyCredentialResult as a2, KodaXVerifyStrategy as a3, KodaXAmaFanoutPolicy as b, KodaXAmaProfile as c, KodaXAmaTactic as d, KodaXAssuranceIntent as e, KodaXCacheBoundary as f, KodaXContentBlock as g, KodaXCustomProviderConfig as h, KodaXExecutionMode as i, KodaXExecutionPattern as j, KodaXHarnessProfile as k, KodaXImageBlock as l, KodaXListModelsResult as m, KodaXMessage as n, KodaXModelDescriptor as o, KodaXMutationSurface as p, KodaXProtocolFamily as q, KodaXProviderCapabilityProfile as r, KodaXProviderConfig as s, KodaXProviderContextFidelity as t, KodaXProviderConversationSemantics as u, KodaXProviderEvidenceSupport as v, KodaXProviderLongRunningSupport as w, KodaXProviderMcpSupport as x, KodaXProviderMultimodalSupport as y, KodaXProviderSessionSupport as z };
@@ -1,5 +1,5 @@
1
- import { X as KodaXToolDefinition, m as KodaXMessage, D as KodaXReasoningMode, Z as KodaXToolResultContentItem, T as KodaXThinkingBlock, G as KodaXRedactedThinkingBlock } from './types.d-B1uGoVTE.js';
2
- import { a as KodaXCompactMemorySeed, k as KodaXSessionArtifactLedgerEntry } from './types.d-HBbWT-iA.js';
1
+ import { Y as KodaXToolDefinition, n as KodaXMessage, E as KodaXReasoningMode, _ as KodaXToolResultContentItem, U as KodaXThinkingBlock, H as KodaXRedactedThinkingBlock } from './types.d-Cf-GCzac.js';
2
+ import { a as KodaXCompactMemorySeed, k as KodaXSessionArtifactLedgerEntry } from './types.d-B_MIIApc.js';
3
3
 
4
4
  /**
5
5
  * Layer A Primitive: Agent / Handoff / Guardrail / AgentReasoningProfile
@@ -1,7 +1,7 @@
1
- import { l as BashPrefixExtractor, a1 as KodaXOptions, L as KodaXContextTokenSnapshot, K as KodaXAgentMode, a6 as KodaXRepoIntelligenceMode, A as AgentsFile, i as AutoModeStats, ah as KodaXSkillInvocationContext, _ as KodaXMcpServersConfig } from './bash-prefix-extractor.d-DdoSeghD.js';
2
- import { a as SessionStorage$1 } from './storage.d-DFD9ln5c.js';
3
- import { y as KodaXSessionStorage, n as KodaXSessionData, A as KodaXSessionUiHistoryItem, s as KodaXSessionLineage, k as KodaXSessionArtifactLedgerEntry, w as KodaXSessionRuntimeInfo } from './types.d-HBbWT-iA.js';
4
- import { m as KodaXMessage, D as KodaXReasoningMode, q as KodaXProviderCapabilityProfile, E as KodaXReasoningOverride, h as KodaXCustomProviderConfig } from './types.d-B1uGoVTE.js';
1
+ import { l as BashPrefixExtractor, a1 as KodaXOptions, L as KodaXContextTokenSnapshot, K as KodaXAgentMode, a6 as KodaXRepoIntelligenceMode, A as AgentsFile, i as AutoModeStats, ah as KodaXSkillInvocationContext, _ as KodaXMcpServersConfig } from './bash-prefix-extractor.d-BICYx8pt.js';
2
+ import { a as SessionStorage$1 } from './storage.d-B1Jk6ryM.js';
3
+ import { y as KodaXSessionStorage, n as KodaXSessionData, A as KodaXSessionUiHistoryItem, s as KodaXSessionLineage, k as KodaXSessionArtifactLedgerEntry, w as KodaXSessionRuntimeInfo } from './types.d-B_MIIApc.js';
4
+ import { n as KodaXMessage, E as KodaXReasoningMode, r as KodaXProviderCapabilityProfile, F as KodaXReasoningOverride, h as KodaXCustomProviderConfig } from './types.d-Cf-GCzac.js';
5
5
  import * as readline from 'readline';
6
6
  import { SpawnSyncReturns } from 'child_process';
7
7
 
@@ -233,6 +233,8 @@ interface CurrentConfig {
233
233
  repointelEndpoint?: string;
234
234
  repointelBin?: string;
235
235
  repoIntelligenceTrace?: boolean;
236
+ /** FEATURE_102 Phase 3 — cross-provider child fallback chain. */
237
+ fallbackProviders?: string[];
236
238
  }
237
239
  type SessionLoadStatus = 'loaded' | 'missing' | 'blocked';
238
240
  type SessionBranchSwitchStatus = 'switched' | 'missing' | 'blocked';
@@ -479,6 +481,14 @@ declare function loadConfig(): {
479
481
  * Mirrored to env var `KODAX_STALL_LOG=1`.
480
482
  */
481
483
  stallLog?: boolean;
484
+ /**
485
+ * FEATURE_102 Phase 3 (v0.7.45) — ordered cross-provider fallback chain for
486
+ * child dispatch. When a child's primary provider is exhausted/down, the
487
+ * runtime re-runs it on the next provider here. Empty/absent = OFF. Mirrored
488
+ * to env var `KODAX_FALLBACK_PROVIDERS` (comma-separated) for the coding
489
+ * layer, which has no config access. Set via the `/fallback` command.
490
+ */
491
+ fallbackProviders?: string[];
482
492
  };
483
493
  declare function prepareRuntimeConfig(): ReturnType<typeof loadConfig>;
484
494
  declare function saveConfig(config: {
@@ -502,8 +512,24 @@ declare function saveConfig(config: {
502
512
  verifierLog?: boolean;
503
513
  /** FEATURE_187 Phase C — opt-in stall sidecar log line. */
504
514
  stallLog?: boolean;
515
+ /** FEATURE_102 Phase 3 — cross-provider child fallback chain. */
516
+ fallbackProviders?: string[];
505
517
  }): void;
506
- declare function getGitRoot(): Promise<string | null>;
518
+ /**
519
+ * Get git root directory.
520
+ *
521
+ * v0.7.46 fix — accepts optional `cwd` so in-process SDK embedders (KodaX
522
+ * Space) that serve multiple projects from a single runtime can resolve
523
+ * the git root of the project the user opened, NOT the embedder's
524
+ * startup directory. Without `cwd`, `git rev-parse --show-toplevel`
525
+ * inherits the host process's cwd, which mis-tags storage operations
526
+ * for multi-project embedders (the same root cause as the
527
+ * `saveSessionSnapshot` gitRoot bug in agent-runtime/middleware/ shipped in v0.7.45).
528
+ *
529
+ * No `cwd` arg → behaves identically to the pre-v0.7.46 form
530
+ * (process.cwd() of the host).
531
+ */
532
+ declare function getGitRoot(cwd?: string): Promise<string | null>;
507
533
  declare function rateLimitedCall<T>(fn: () => Promise<T>): Promise<T>;
508
534
 
509
535
  export { processSpecialSyntax as A, BUILTIN_COMMANDS as B, rateLimitedCall as D, registerConfiguredCustomProviders as E, runInkInteractiveMode as F, runInteractiveMode as G, saveConfig as H, touchContext as J, KODAX_CONFIG_FILE as K, PERMISSION_MODES as P, KODAX_DIR as f, KODAX_SESSIONS_DIR as g, KODAX_VERSION as h, PREVIEW_MAX_LENGTH as i, computeConfirmTools as l, createInteractiveContext as m, executeCommand as n, getGitRoot as o, getProviderList as p, getProviderModel as q, getVersion as r, hydrateProcessEnvFromShell as s, isPermissionMode as t, isProviderConfigured as u, loadConfig as v, normalizePermissionMode as w, parseCommand as x, permissionModeDisplayName as y, prepareRuntimeConfig as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodax-ai/kodax",
3
- "version": "0.7.44",
3
+ "version": "0.7.46",
4
4
  "description": "极致轻量化 Coding Agent - TypeScript 实现,支持 12 个 LLM 提供商,可发布为免 Node 单文件二进制",
5
5
  "type": "module",
6
6
  "private": false,
@@ -1,2 +0,0 @@
1
- // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
- import{ic as A,kc as T}from"./chunk-4YPL2UVZ.js";import{S as w,T as S,U as L,V as x,W as I,X as h,ca as O,da as m,ga as b,qa as R}from"./chunk-DI2G3YWL.js";import{va as k}from"./chunk-HHQ7YTGM.js";import{a as i}from"./chunk-V4WSBIXB.js";import a from"fs";import c from"path";import{exec as j,spawnSync as z}from"child_process";import{promisify as U}from"util";import{fileURLToPath as q}from"url";var E="en";function H(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}i(H,"detectSystemLocale");function M(e){if(!e||e==="auto"){E=H();return}E=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}i(M,"setLocale");var D={en:{"dialog.confirm":"[Confirm]","dialog.select":"[Select]","dialog.input":"[Input]","confirm.instruction.basic":"Press (y) yes, (n) no","confirm.instruction.always":"Press (y) yes, (a) always yes for this tool, (n) no","confirm.instruction.protected":"Press (y) to confirm, (n) to cancel (protected path)","confirm.result.approved":"Approved","confirm.result.approved_always":"Approved (always)","confirm.result.denied":"Denied","tool.bash.title":"Execute bash command?","tool.shell.title":"Execute shell command?","tool.write.title":"Write to file?","tool.edit.title":"Edit file?","tool.generic.title":"Execute {tool}?","field.reason":"Reason","field.intent":"Intent","field.target":"Target","field.scope":"Scope","field.risk":"Risk","field.summary":"Summary","intent.read":"Read project files","intent.delete":"Delete files","intent.deps":"Modify dependencies or environment","intent.modify":"Modify files","intent.execute":"Execute command","intent.write_file":"Write file","intent.edit_file":"Edit file","intent.use_tool":"Use {tool}","risk.destructive":"Destructive change","risk.deps":"May change dependencies or local tools","risk.modify":"May modify files","risk.unknown":"Command effects depend on its arguments","risk.network":"May access network","scope.outside":"Outside project","scope.protected":"Protected path","waiting.confirm":"Waiting: approval required","waiting.select":"Waiting: choose an option","waiting.input":"Waiting: answer the prompt","placeholder.confirm":"Respond to the approval prompt above...","placeholder.select":"Choose an option above...","placeholder.input":"Answer the prompt above...","placeholder.busy":"Agent is busy...","placeholder.queue":"Queue a follow-up for the next round...","placeholder.idle":"Type a message...","select.choice":"Choice:","select.type_number":"(type a number)","select.more":"{count} more choices...","select.more_above":"\u2191 {count} more above","select.more_below":"\u2193 {count} more below","select.confirm_hint":"Press Enter to confirm, Esc to cancel","select.navigate_hint":"Use \u2191\u2193 to navigate, Enter to confirm, Esc to cancel","select.multiselect_hint":"Use \u2191\u2193 to navigate, Space to toggle, Enter to confirm, Esc to cancel","select.multiselect_empty":"Select at least one option with Space before confirming.","select.back_prev":"\u2190 Back to previous question","input.default":"Default:","input.value":"Value:","input.type_response":"(type your response)","managed.completed":"Task completed","managed.completed.blocked":"Task blocked","managed.completed.continuation":"Task needs continuation",cancelled:"[Cancelled] Operation cancelled by user"},zh:{"dialog.confirm":"[\u786E\u8BA4]","dialog.select":"[\u9009\u62E9]","dialog.input":"[\u8F93\u5165]","confirm.instruction.basic":"\u6309 (y) \u786E\u8BA4, (n) \u62D2\u7EDD","confirm.instruction.always":"\u6309 (y) \u786E\u8BA4, (a) \u59CB\u7EC8\u5141\u8BB8\u6B64\u5DE5\u5177, (n) \u62D2\u7EDD","confirm.instruction.protected":"\u6309 (y) \u786E\u8BA4, (n) \u53D6\u6D88 (\u53D7\u4FDD\u62A4\u8DEF\u5F84)","confirm.result.approved":"\u5DF2\u6279\u51C6","confirm.result.approved_always":"\u5DF2\u6279\u51C6 (\u59CB\u7EC8\u5141\u8BB8)","confirm.result.denied":"\u5DF2\u62D2\u7EDD","tool.bash.title":"\u6267\u884C bash \u547D\u4EE4\uFF1F","tool.shell.title":"\u6267\u884C shell \u547D\u4EE4\uFF1F","tool.write.title":"\u5199\u5165\u6587\u4EF6\uFF1F","tool.edit.title":"\u7F16\u8F91\u6587\u4EF6\uFF1F","tool.generic.title":"\u6267\u884C {tool}\uFF1F","field.reason":"\u539F\u56E0","field.intent":"\u610F\u56FE","field.target":"\u76EE\u6807","field.scope":"\u8303\u56F4","field.risk":"\u98CE\u9669","field.summary":"\u6458\u8981","intent.read":"\u8BFB\u53D6\u9879\u76EE\u6587\u4EF6","intent.delete":"\u5220\u9664\u6587\u4EF6","intent.deps":"\u4FEE\u6539\u4F9D\u8D56\u6216\u73AF\u5883","intent.modify":"\u4FEE\u6539\u6587\u4EF6","intent.execute":"\u6267\u884C\u547D\u4EE4","intent.write_file":"\u5199\u5165\u6587\u4EF6","intent.edit_file":"\u7F16\u8F91\u6587\u4EF6","intent.use_tool":"\u4F7F\u7528 {tool}","risk.destructive":"\u7834\u574F\u6027\u53D8\u66F4","risk.deps":"\u53EF\u80FD\u4FEE\u6539\u4F9D\u8D56\u6216\u672C\u5730\u5DE5\u5177","risk.modify":"\u53EF\u80FD\u4FEE\u6539\u6587\u4EF6","risk.unknown":"\u547D\u4EE4\u6548\u679C\u53D6\u51B3\u4E8E\u53C2\u6570","risk.network":"\u53EF\u80FD\u8BBF\u95EE\u7F51\u7EDC","scope.outside":"\u9879\u76EE\u5916\u90E8","scope.protected":"\u53D7\u4FDD\u62A4\u8DEF\u5F84","waiting.confirm":"\u7B49\u5F85\u4E2D\uFF1A\u9700\u8981\u5BA1\u6279","waiting.select":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u9009\u62E9","waiting.input":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u56DE\u7B54","placeholder.confirm":"\u8BF7\u56DE\u5E94\u4E0A\u65B9\u7684\u5BA1\u6279\u63D0\u793A...","placeholder.select":"\u8BF7\u5728\u4E0A\u65B9\u9009\u62E9\u4E00\u4E2A\u9009\u9879...","placeholder.input":"\u8BF7\u56DE\u7B54\u4E0A\u65B9\u7684\u63D0\u793A...","placeholder.busy":"\u4EE3\u7406\u6B63\u5728\u5DE5\u4F5C\u4E2D...","placeholder.queue":"\u6392\u961F\u7B49\u5F85\u4E0B\u4E00\u8F6E\u8DDF\u8FDB...","placeholder.idle":"\u8F93\u5165\u6D88\u606F...","select.choice":"\u9009\u9879\uFF1A","select.type_number":"(\u8F93\u5165\u7F16\u53F7)","select.more":"\u8FD8\u6709 {count} \u4E2A\u9009\u9879...","select.more_above":"\u2191 \u4E0A\u65B9\u8FD8\u6709 {count} \u4E2A","select.more_below":"\u2193 \u4E0B\u65B9\u8FD8\u6709 {count} \u4E2A","select.confirm_hint":"\u6309 Enter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.navigate_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0C\u7A7A\u683C \u5207\u6362\u9009\u4E2D\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_empty":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u9009\u9879\u3002","select.back_prev":"\u2190 \u8FD4\u56DE\u4E0A\u4E00\u9898","input.default":"\u9ED8\u8BA4\u503C\uFF1A","input.value":"\u503C\uFF1A","input.type_response":"(\u8F93\u5165\u4F60\u7684\u56DE\u7B54)","managed.completed":"\u4EFB\u52A1\u5B8C\u6210","managed.completed.blocked":"\u4EFB\u52A1\u53D7\u963B","managed.completed.continuation":"\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88"}};function me(e,t){let o=D[E][e]??D.en[e]??e;if(t)for(let[r,l]of Object.entries(t))o=o.replace(`{${r}}`,String(l));return o}i(me,"t");var W=U(j),X=k(),Se=c.join(X,"sessions"),p=c.join(X,"config.json"),Le=60,s=null,_=!1,J="dumb";function Q(e){let t=c.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",o=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",o],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",o]:["-lc",o],sentinel:n}}i(Q,"buildShellEnvCommand");function Y(e,t){let n=`${t}\0`,o=e.lastIndexOf(n);if(o===-1)return{};let r=e.slice(o+n.length),l={};for(let u of r.split("\0")){if(!u)continue;let d=u.indexOf("=");d<=0||(l[u.slice(0,d)]=u.slice(d+1))}return l}i(Y,"parseNullDelimitedShellEnv");function Z(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let o=e.shell??t.SHELL;if(!o||!c.isAbsolute(o))return!1;let{args:r,sentinel:l}=Q(o),u=e.run??z,d={...t,TERM:J},f=u(o,r,{encoding:"utf8",env:d,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(f.status!==0||!f.stdout)return!1;let B=typeof f.stdout=="string"?f.stdout:f.stdout.toString("utf8"),V=Y(B,l),C=!1;for(let[v,F]of Object.entries(V))v!=="TERM"&&t[v]===void 0&&(t[v]=F,C=!0);return C}i(Z,"hydrateProcessEnvFromShell");function ee(){if(!_){_=!0;try{Z()}catch{}}}i(ee,"ensureShellEnvironmentHydrated");function xe(){_=!1}i(xe,"resetShellEnvironmentHydrationForTesting");function te(e){O(e.customProviders??[])}i(te,"registerConfiguredCustomProviders");function $(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:[]}i($,"normalizeConfiguredExtensions");function ne(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{a.mkdirSync(c.dirname(p),{recursive:!0}),a.writeFileSync(p,JSON.stringify(t,null,2))}catch{}return t}i(ne,"migrateLegacyPermissionModeInConfig");function oe(){if(s)return s;let e="0.7.44";if(e)return s=e,s;let t=c.join(c.dirname(q(import.meta.url)),"../../package.json");if(a.existsSync(t))try{return s=JSON.parse(a.readFileSync(t,"utf-8")).version??"0.0.0",s??"0.0.0"}catch{}return s="0.0.0",s}i(oe,"getVersion");var Ie=oe();function Oe(e){return S(e)}i(Oe,"getProviderModel");function P(e,t){let n=new Set(e.map(r=>r.toLowerCase())),o=[...e];for(let r of t)n.has(r.toLowerCase())||o.push(r);return o}i(P,"mergeModels");function ie(e,t){t||(t=y().providerModels);let n=t?.[e];if(n&&n.length>0){try{let o=h(e);if(o.length>0)return P(n,o)}catch{}try{let o=m(e);if(o)return P(n,o.getAvailableModels())}catch{}return n}try{let o=h(e);if(o.length>0)return o}catch{}try{let o=m(e);if(o)return o.getAvailableModels()}catch{}return[]}i(ie,"getProviderAvailableModels");function re(e,t){let n=L(e,t);if(n!=="unknown")return n;try{let o=m(e);if(o)return o.getReasoningCapability(t)}catch{}return"unknown"}i(re,"getProviderReasoningCapability");function se(e){let t=x(e);if(t)return t;try{return b().find(o=>o.name===e)?.capabilityProfile??null}catch{return null}}i(se,"getProviderCapabilityProfile");function G(e,t){let n=se(e),o=re(e,t);if(n)return{capabilityProfile:n,reasoningCapability:o};try{let r=R(e);return{capabilityProfile:r.getCapabilityProfile(),reasoningCapability:r.getReasoningCapability(t)}}catch{return null}}i(G,"getProviderCapabilityMetadata");function Re(e,t){let n=G(e,t);return n?A({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}i(Re,"getProviderCapabilitySnapshot");function ae(e,t,n,o){let r=G(e,t);return r?T({providerName:e,model:t,capabilityProfile:r.capabilityProfile,reasoningCapability:r.reasoningCapability==="unknown"?void 0:r.reasoningCapability,reasoningMode:n,hints:o}):null}i(ae,"getProviderPolicyDecision");function ke(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"forwards only the latest user message":"preserves full conversation history",o=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${o}`}i(ke,"describeProviderCapabilitySummary");function Ae(e){switch(e){case"native-budget":return"B";case"native-effort":return"E";case"native-toggle":return"T";default:return"-"}}i(Ae,"formatReasoningCapabilityShort");function ce(e){switch(e){case"native-budget":return"budget";case"native-effort":return"effort";case"native-toggle":return"toggle";default:return"none"}}i(ce,"describeReasoningCapabilityControl");function Te(e,t){if(e==="off")return"Reasoning disabled";switch(t){case"native-budget":return"Uses native thinking budget control";case"native-effort":return"Uses native reasoning effort control";case"native-toggle":return"Uses provider-native thinking toggle only";case"none":return"Runs without native reasoning parameters";case"prompt-only":return"Uses prompt overlays only; no native reasoning parameter";default:return"Runs without native reasoning parameters"}}i(Te,"describeReasoningExecution");function De(e){let t=[];e||(e=y().providerModels);for(let n of I())t.push({name:n.name,model:n.model,models:ie(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=b().map(o=>({...o,models:(()=>{let r=e?.[o.name];return r&&r.length>0?P(r,o.models):o.models})()}));t.push(...n)}catch{}return t}i(De,"getProviderList");function Me(e){if(w(e))return!0;try{return m(e)?.isConfigured()??!1}catch{return!1}}i(Me,"isProviderConfigured");function y(){try{if(a.existsSync(p)){let e=JSON.parse(a.readFileSync(p,"utf-8")),t=e.reasoningCeiling??e.reasoningMode;return ne({...e,reasoningMode:t,extensions:$(e.extensions)})}}catch{}return{}}i(y,"loadConfig");function le(e){e.streamIdleTimeoutMs&&!process.env.KODAX_STREAM_IDLE_TIMEOUT_MS&&(process.env.KODAX_STREAM_IDLE_TIMEOUT_MS=String(e.streamIdleTimeoutMs))}i(le,"applyResilienceRuntimeEnv");function ue(e){e.repoIntelligenceMode&&!process.env.KODAX_REPO_INTELLIGENCE_MODE&&(process.env.KODAX_REPO_INTELLIGENCE_MODE=e.repoIntelligenceMode),e.repointelEndpoint&&!process.env.KODAX_REPOINTEL_ENDPOINT&&(process.env.KODAX_REPOINTEL_ENDPOINT=e.repointelEndpoint),e.repointelBin&&!process.env.KODAX_REPOINTEL_BIN&&(process.env.KODAX_REPOINTEL_BIN=e.repointelBin),e.repoIntelligenceTrace===!0&&!process.env.KODAX_REPO_INTELLIGENCE_TRACE&&(process.env.KODAX_REPO_INTELLIGENCE_TRACE="1")}i(ue,"applyRepoIntelligenceRuntimeEnv");function pe(e){e.verifierLog===!0&&!process.env.KODAX_VERIFIER_LOG&&(process.env.KODAX_VERIFIER_LOG="1")}i(pe,"applyVerifierRuntimeEnv");function de(e){e.stallLog===!0&&!process.env.KODAX_STALL_LOG&&(process.env.KODAX_STALL_LOG="1")}i(de,"applyStallSidecarRuntimeEnv");function Ne(){ee();let e=y();return le(e),ue(e),pe(e),de(e),te(e),M(e.locale),e}i(Ne,"prepareRuntimeConfig");function Ke(e){let n={...y(),...e},o=$(n.extensions);o!==void 0&&(n.extensions=o);for(let r of Object.keys(e))e[r]===void 0&&delete n[r];a.mkdirSync(c.dirname(p),{recursive:!0}),a.writeFileSync(p,JSON.stringify(n,null,2))}i(Ke,"saveConfig");async function Xe(){try{let{stdout:e}=await W("git rev-parse --show-toplevel");return e.trim()}catch{return null}}i(Xe,"getGitRoot");function fe(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}i(fe,"formatProviderSourceKind");function $e(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"latest-user-message only":"full conversation history";return[`Source: ${fe(e.sourceKind)}`,`Transport: ${t}`,`Conversation semantics: ${n}`,`Context fidelity: ${e.contextFidelity}`,`Tool calling: ${e.toolCallingFidelity}`,`Session behavior: ${e.sessionSupport}`,`Long-running support: ${e.longRunningSupport}`,`Evidence-heavy flows: ${e.evidenceSupport}`,`Multimodal support: ${e.multimodalSupport}`,`MCP support: ${e.mcpSupport}`,`Reasoning control: ${ce(e.reasoningCapability)}`]}i($e,"formatProviderCapabilityDetailLines");function Ge(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(r=>({label:r.label,decision:ae(e,t,n,r.hints)})).filter(r=>r.decision!==null)}i(Ge,"getProviderCommonPolicyScenarios");var N=.5,K=0,g={locked:!1,queue:[]};async function Be(e){for(;g.locked;)await new Promise(t=>g.queue.push(t));g.locked=!0;try{let t=(Date.now()-K)/1e3;t<N&&await new Promise(o=>setTimeout(o,(N-t)*1e3));let n=await e();return K=Date.now(),n}finally{g.locked=!1;let t=g.queue.shift();t&&t()}}i(Be,"rateLimitedCall");export{me as a,X as b,Se as c,p as d,Le as e,Z as f,xe as g,te as h,oe as i,Ie as j,Oe as k,ie as l,re as m,se as n,Re as o,ae as p,ke as q,Ae as r,ce as s,Te as t,De as u,Me as v,y as w,Ne as x,Ke as y,Xe as z,fe as A,$e as B,Ge as C,Be as D};