@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
@@ -1,9 +1,10 @@
1
- import { a as KodaXCompactMemorySeed, h as KodaXSessionArtifactLedgerEntry, t as KodaXSessionScope, u as KodaXSessionStorage, f as KodaXJsonValue, S as SessionErrorMetadata } from './types.d-mM8vqvhT.js';
1
+ import { t as KodaXSessionScope, u as KodaXSessionStorage, f as KodaXJsonValue, h as KodaXSessionArtifactLedgerEntry, S as SessionErrorMetadata } from './types.d-mM8vqvhT.js';
2
2
  import { m as KodaXMessage, W as KodaXTokenUsage, D as KodaXReasoningMode, k as KodaXHarnessProfile, R as KodaXTaskWorkIntent, H as KodaXReviewScale, N as KodaXTaskComplexity, a as KodaXAmaFanoutClass, P as KodaXTaskRoutingDecision, Q as KodaXTaskType, I as KodaXRiskLevel, i as KodaXExecutionMode, c as KodaXAmaProfile, d as KodaXAmaTactic, b as KodaXAmaFanoutPolicy } from './types.d-B1uGoVTE.js';
3
- import { G as Guardrail, D as DiscoveredInstance, C as ChildTaskRegistry, T as TaskAbortRegistry, r as RunnerToolCall, J as ToolGuardrail } from './instance-discovery.d-BsKnIwpg.js';
4
- import { C as CapabilityKind, b as CapabilityResult } from './capability.d-3C62G8Eq.js';
3
+ import { k as CompactionUpdate, o as Guardrail, D as DiscoveredInstance, C as ChildTaskRegistry, a1 as TaskAbortRegistry, K as RunnerToolCall, a4 as ToolGuardrail } from './types.d-CKJtjo-6.js';
5
4
  import { M as McpConnectMode, a as McpServerConfig, b as McpServersConfig, c as McpTransportKind } from './config.d-BfJUXxC0.js';
6
- import { K as KodaXBaseProvider, a as CostTracker } from './cost-tracker.d-B6vMoLLF.js';
5
+ import { C as CapabilityKind, b as CapabilityResult } from './capability.d-3C62G8Eq.js';
6
+ import { K as KodaXBaseProvider } from './base.d-FUJahC0i.js';
7
+ import { a as CostTracker } from './cost-tracker.d-wRtyEW9d.js';
7
8
 
8
9
  /** One tool-call breadcrumb. Captures only the name + a 60-char input
9
10
  * hint so the snapshot stays compact under fan-out. Mirrors the
@@ -61,6 +62,13 @@ interface ChildProgressSnapshot {
61
62
  /** Read-only flag forwarded from the dispatch bundle. Same rationale
62
63
  * as `parentRole` — currently captured for future surfacing. */
63
64
  readonly readOnly?: boolean;
65
+ /**
66
+ * FEATURE_191 — registered specialist agent name when the dispatch
67
+ * routed through a `subagent_type` argument. `undefined` for generic
68
+ * anonymous children. Surfaced by `task_output` so post-mortem peeks
69
+ * can identify which specialist owned the child.
70
+ */
71
+ readonly specialistName?: string;
64
72
  }
65
73
 
66
74
  /** Result of a cache lookup. */
@@ -315,53 +323,6 @@ interface TodoStore {
315
323
  reset(): void;
316
324
  }
317
325
 
318
- /**
319
- * @kodax-ai/agent Compaction Types
320
- */
321
-
322
- interface CompactionDetails {
323
- readFiles: string[];
324
- modifiedFiles: string[];
325
- }
326
- interface CompactionAnchor {
327
- summary: string;
328
- tokensBefore: number;
329
- tokensAfter: number;
330
- entriesRemoved: number;
331
- reason: string;
332
- artifactLedgerId?: string;
333
- details?: CompactionDetails;
334
- memorySeed?: KodaXCompactMemorySeed;
335
- }
336
- interface CompactionUpdate {
337
- anchor?: CompactionAnchor;
338
- artifactLedger?: KodaXSessionArtifactLedgerEntry[];
339
- memorySeed?: KodaXCompactMemorySeed;
340
- /**
341
- * FEATURE_072: ledger-summary + file-content messages produced by
342
- * `buildPostCompactAttachments` + `buildFileContentMessages`. Agent.ts
343
- * passes these separately from the kept-tail messages so REPL-side
344
- * `applySessionCompaction` can store them natively on the CompactionEntry
345
- * rather than inlining them as loose `[Post-compact: ...]` system messages
346
- * in lineage. Agent.ts keeps inlining them into its local flat `messages`
347
- * via `injectPostCompactAttachments` (P4 belt-and-suspenders); the lineage
348
- * is the persistence source of truth.
349
- */
350
- postCompactAttachments?: readonly KodaXMessage[];
351
- }
352
- interface CompactionResult {
353
- compacted: boolean;
354
- messages: KodaXMessage[];
355
- summary?: string;
356
- tokensBefore: number;
357
- tokensAfter: number;
358
- entriesRemoved: number;
359
- details?: CompactionDetails;
360
- artifactLedger?: KodaXSessionArtifactLedgerEntry[];
361
- anchor?: CompactionAnchor;
362
- memorySeed?: KodaXCompactMemorySeed;
363
- }
364
-
365
326
  /**
366
327
  * FEATURE_093 (v0.7.24): minimal contract interface for the coding extension
367
328
  * runtime. Extracted so `@kodax-ai/coding/src/types.ts` can reference the
@@ -798,7 +759,7 @@ interface KodaXRepoIntelligenceTrace {
798
759
  * (interactive REPL), and `acp_server`.
799
760
  *
800
761
  * Note: FEATURE_083 (v0.7.24) initially marked this as superseded by
801
- * `EvidenceSpan` in `@kodax-ai/tracing`. **FEATURE_086 (v0.7.27) re-evaluated
762
+ * `EvidenceSpan` in `@kodax-ai/agent`. **FEATURE_086 (v0.7.27) re-evaluated
802
763
  * and retained it**: `EvidenceSpanData` is a generic
803
764
  * `{ source, queryPreview?, resultCount?, cacheHit?, error? }` abstraction
804
765
  * that does not carry the repo-intelligence-specific `stage` enum,
@@ -1011,6 +972,17 @@ interface KodaXChildContextBundle {
1011
972
  * lands separately.
1012
973
  */
1013
974
  modelHint?: KodaXChildModelHint;
975
+ /**
976
+ * FEATURE_191 — optional registered specialist agent name. When set,
977
+ * the child is dispatched with that agent's `instructions` /
978
+ * `tools` / `reasoning` / `guardrails` instead of the stock Worker
979
+ * bundle. Resolved via `resolveConstructedAgent(name)` at dispatch
980
+ * time; unknown names are rejected by `toolDispatchChildTask` with
981
+ * a tool-result error (not throw) before the bundle reaches
982
+ * `executeReadChild` / `executeWriteChild`. Optional — omitting
983
+ * preserves byte-identical v0.7.42 baseline dispatch behavior.
984
+ */
985
+ specialistName?: string;
1014
986
  }
1015
987
  /**
1016
988
  * FEATURE_120 v0.7.39 Phase 4 — model tier hint. Tier semantics:
@@ -1469,7 +1441,6 @@ interface KodaXOrchestrationVerdict {
1469
1441
  signalReason?: string;
1470
1442
  signalDebugReason?: string;
1471
1443
  disposition?: 'complete' | 'blocked' | 'needs_continuation';
1472
- continuationSuggested?: boolean;
1473
1444
  }
1474
1445
  interface KodaXManagedTaskRuntimeState {
1475
1446
  amaProfile?: KodaXAmaProfile;
@@ -1491,24 +1462,6 @@ interface KodaXManagedTaskRuntimeState {
1491
1462
  currentHarness?: KodaXHarnessProfile;
1492
1463
  upgradeCeiling?: KodaXHarnessProfile;
1493
1464
  harnessTransitions?: KodaXManagedTaskHarnessTransition[];
1494
- scoutDecision?: {
1495
- summary: string;
1496
- recommendedHarness: KodaXHarnessProfile;
1497
- readyForUpgrade: boolean;
1498
- scope?: string[];
1499
- requiredEvidence?: string[];
1500
- reviewFilesOrAreas?: string[];
1501
- evidenceAcquisitionMode?: 'overview' | 'diff-bundle' | 'diff-slice' | 'file-read';
1502
- harnessRationale?: string;
1503
- blockingEvidence?: string[];
1504
- directCompletionReady?: 'yes' | 'no';
1505
- skillSummary?: string;
1506
- executionObligations?: string[];
1507
- verificationObligations?: string[];
1508
- ambiguities?: string[];
1509
- projectionConfidence?: KodaXSkillProjectionConfidence;
1510
- };
1511
- skillMap?: KodaXSkillMap;
1512
1465
  completionContractStatus?: Record<string, 'ready' | 'incomplete' | 'blocked' | 'missing'>;
1513
1466
  rawRoutingDecision?: KodaXTaskRoutingDecision;
1514
1467
  finalRoutingDecision?: KodaXTaskRoutingDecision;
@@ -1563,7 +1516,6 @@ interface KodaXManagedVerdictPayload {
1563
1516
  nextHarness?: KodaXTaskRoutingDecision['harnessProfile'];
1564
1517
  protocolParseFailed?: boolean;
1565
1518
  verificationDegraded?: boolean;
1566
- continuationSuggested?: boolean;
1567
1519
  preferredFallbackWorkerId?: string;
1568
1520
  /**
1569
1521
  * v0.7.26 Risk-3 fix — Evaluator explicit budget-extension request.
@@ -1576,72 +1528,19 @@ interface KodaXManagedVerdictPayload {
1576
1528
  budgetRequest?: string;
1577
1529
  }
1578
1530
  /**
1579
- * Signals surfaced by the harness (not the LLM) when Scout's completion looks
1580
- * suspicious. See runManagedScoutStage for the detection logic.
1531
+ * Signals surfaced by the harness (not the LLM) when V1 Scout's completion
1532
+ * looked suspicious.
1533
+ *
1534
+ * FEATURE_193 (v0.7.43) deep V1 cleanup: V1 Scout role is retired and the
1535
+ * Runner-driven path no longer fires `onScoutSuspiciousCompletion`. The
1536
+ * type is kept on the SDK surface so the `KodaXEvents.onScoutSuspiciousCompletion`
1537
+ * callback signature continues to compile for pre-1.0 SDK consumers (e.g.
1538
+ * the REPL renderers that still register a handler). New code MUST NOT
1539
+ * emit this signal.
1581
1540
  */
1582
1541
  type KodaXScoutSuspiciousSignal = 'mutation-expected-but-none' | 'budget-exhausted' | 'no-formal-completion';
1583
- interface KodaXManagedScoutPayload {
1584
- summary?: string;
1585
- scope: string[];
1586
- requiredEvidence: string[];
1587
- reviewFilesOrAreas?: string[];
1588
- evidenceAcquisitionMode?: 'overview' | 'diff-bundle' | 'diff-slice' | 'file-read';
1589
- confirmedHarness?: KodaXTaskRoutingDecision['harnessProfile'];
1590
- harnessRationale?: string;
1591
- blockingEvidence?: string[];
1592
- directCompletionReady?: 'yes' | 'no';
1593
- /**
1594
- * FEATURE_078 (v0.7.29): Scout's optional non-binding suggestion for
1595
- * the reasoning depth downstream workers (Planner / Generator /
1596
- * Evaluator) should use. Resolved by `resolveRoleReasoning(role,
1597
- * userCeiling, profile, scoutHint)` as the L3 input — clamped by L1
1598
- * (user ceiling) and L2 (agent profile max). Scout SHOULD set this
1599
- * sparingly: only when the scoped task signals atypically low
1600
- * complexity (`'quick'`) or atypically high stakes (`'deep'`); leave
1601
- * undefined for the default path so workers stick to their own
1602
- * `Agent.reasoning.default`.
1603
- */
1604
- downstreamReasoningHint?: KodaXReasoningMode;
1605
- userFacingText?: string;
1606
- skillMap?: {
1607
- skillSummary?: string;
1608
- executionObligations: string[];
1609
- verificationObligations: string[];
1610
- ambiguities: string[];
1611
- projectionConfidence?: KodaXSkillProjectionConfidence;
1612
- };
1613
- /**
1614
- * Harness-observed confidence in Scout's completion. 'confident' is the default
1615
- * (omitted). 'uncertain' means the harness detected signals that Scout may not
1616
- * have actually finished (e.g. mutation task with zero mutations, budget
1617
- * exhausted without explicit completion, tool calls followed by text-only exit
1618
- * without a completion statement).
1619
- *
1620
- * This field is set by the harness, not by the LLM — emit_managed_protocol
1621
- * payloads from models are ignored here and overwritten.
1622
- */
1623
- completionConfidence?: 'confident' | 'uncertain';
1624
- /** Which signals contributed to an 'uncertain' confidence verdict. */
1625
- suspiciousSignals?: KodaXScoutSuspiciousSignal[];
1626
- }
1627
- interface KodaXManagedContractPayload {
1628
- summary?: string;
1629
- successCriteria: string[];
1630
- requiredEvidence: string[];
1631
- constraints: string[];
1632
- }
1633
- interface KodaXManagedHandoffPayload {
1634
- status: 'ready' | 'incomplete' | 'blocked';
1635
- summary?: string;
1636
- evidence: string[];
1637
- followup: string[];
1638
- userFacingText: string;
1639
- }
1640
1542
  interface KodaXManagedProtocolPayload {
1641
1543
  verdict?: KodaXManagedVerdictPayload;
1642
- scout?: KodaXManagedScoutPayload;
1643
- contract?: KodaXManagedContractPayload;
1644
- handoff?: KodaXManagedHandoffPayload;
1645
1544
  }
1646
1545
  interface KodaXResult {
1647
1546
  success: boolean;
@@ -2567,5 +2466,5 @@ interface CreateBashPrefixExtractorOptions {
2567
2466
  */
2568
2467
  declare function createBashPrefixExtractor(opts: CreateBashPrefixExtractorOptions): BashPrefixExtractor;
2569
2468
 
2570
- export { BASH_POLICY_SPEC as B, CONSECUTIVE_THRESHOLD as C, ERROR_THRESHOLD as E, getKodaxGlobalDir as a$, WINDOW_MS as aS, collectAllSignals as aT, computeRulesFingerprint as aU, createAutoModeToolGuardrail as aV, createBashPrefixExtractor as aW, createCircuitBreaker as aX, createDenialTracker as aY, extractCommandPrefix as aZ, formatAgentsForPrompt as a_, loadAgentsFiles as b0, loadAutoRules as b1, parseAutoRules as b2, readTrustState as b3, recordAllow as b4, recordBlock as b5, recordError as b6, shouldFallback$1 as b7, shouldFallback as b8, trustProjectRules as b9, CUMULATIVE_THRESHOLD as n };
2571
- export type { KodaXOrchestrationVerdict as $, AgentsFile as A, DenialTracker as D, FailureStage as F, KodaXContextOptions as G, KodaXContextTokenSnapshot as H, KodaXEvents as I, KodaXFanoutBranchLifecycle as J, KodaXAgentMode as K, KodaXFanoutBranchRecord as L, KodaXFanoutBranchTransition as M, KodaXFanoutSchedulerInput as N, KodaXFanoutSchedulerPlan as O, KodaXInputArtifact as P, KodaXManagedBudgetSnapshot as Q, KodaXManagedProtocolPayload as R, KodaXManagedTask as S, KodaXManagedTaskRuntimeState as T, KodaXManagedTaskStatusEvent as U, KodaXMcpConnectMode as V, KodaXMcpServerConfig as W, KodaXMcpServersConfig as X, KodaXMcpTransport as Y, KodaXMemoryStrategy as Z, KodaXOptions as _, AskUserMultiOptions as a, KodaXParentReductionContract as a0, KodaXProviderPolicyHints as a1, KodaXRepoIntelligenceCapability as a2, KodaXRepoIntelligenceMode as a3, KodaXRepoIntelligenceResolvedMode as a4, KodaXRepoIntelligenceTrace as a5, KodaXRepoIntelligenceTraceEvent as a6, KodaXRepoRoutingSignals as a7, KodaXResult as a8, KodaXRoleRoundSummary as a9, ProviderRecoveryEvent as aA, ProviderResilienceConfig as aB, ProviderResiliencePolicy as aC, RecoveryAction as aD, RecoveryDecision as aE, RecoveryLadderStep as aF, RecoveryResult as aG, ResilienceClassification as aH, ResilienceErrorClass as aI, RulesLoadError as aJ, RulesLoadResult as aK, SignalCollector as aL, SkippedRulesSource as aM, TodoItem as aN, TodoList as aO, TodoStatus as aP, ToolCallSignal as aQ, TrustState as aR, KodaXRuntimeVerificationContract as aa, KodaXSessionControl as ab, KodaXSessionMutators as ac, KodaXSessionOptions as ad, KodaXSkillInvocationContext as ae, KodaXSkillMap as af, KodaXSkillProjectionConfidence as ag, KodaXTaskCapabilityHint as ah, KodaXTaskContract as ai, KodaXTaskEvidenceArtifact as aj, KodaXTaskEvidenceBundle as ak, KodaXTaskEvidenceEntry as al, KodaXTaskRole as am, KodaXTaskRoleAssignment as an, KodaXTaskStatus as ao, KodaXTaskSurface as ap, KodaXTaskToolPolicy as aq, KodaXTaskVerificationContract as ar, KodaXTaskVerificationCriterion as as, KodaXTaskWorkItem as at, KodaXToolExecutionContext as au, KodaXVerificationScorecard as av, KodaXVerificationScorecardCriterion as aw, LoadAgentsOptions as ax, LoadedRulesSource as ay, ProviderExecutionState as az, AskUserQuestionItem as b, AskUserQuestionOptions as c, AutoModeAskUser as d, AutoModeAskUserVerdict as e, AutoModeEngine as f, AutoModeGuardrailConfig as g, AutoModeSharedState as h, AutoModeStats as i, AutoModeToolGuardrail as j, AutoRules as k, BashPrefixExtractor as l, BashPrefixResult as m, CircuitBreaker as o, CompactionAnchor as p, CompactionDetails as q, CompactionResult as r, CompactionUpdate as s, CreateBashPrefixExtractorOptions as t, ExtensionRuntimeContract as u, ExtractCommandPrefixOptions as v, KodaXBudgetDisclosureZone as w, KodaXBudgetExtensionRequest as x, KodaXChildAgentResult as y, KodaXChildContextBundle as z };
2469
+ export { BASH_POLICY_SPEC as B, CONSECUTIVE_THRESHOLD as C, ERROR_THRESHOLD as E, readTrustState as a$, WINDOW_MS as aO, collectAllSignals as aP, computeRulesFingerprint as aQ, createAutoModeToolGuardrail as aR, createBashPrefixExtractor as aS, createCircuitBreaker as aT, createDenialTracker as aU, extractCommandPrefix as aV, formatAgentsForPrompt as aW, getKodaxGlobalDir as aX, loadAgentsFiles as aY, loadAutoRules as aZ, parseAutoRules as a_, recordAllow as b0, recordBlock as b1, recordError as b2, shouldFallback$1 as b3, shouldFallback as b4, trustProjectRules as b5, CUMULATIVE_THRESHOLD as n };
2470
+ export type { KodaXRepoIntelligenceMode as $, AgentsFile as A, DenialTracker as D, FailureStage as F, KodaXFanoutBranchRecord as G, KodaXFanoutBranchTransition as H, KodaXFanoutSchedulerInput as I, KodaXFanoutSchedulerPlan as J, KodaXAgentMode as K, KodaXInputArtifact as L, KodaXManagedBudgetSnapshot as M, KodaXManagedProtocolPayload as N, KodaXManagedTask as O, KodaXManagedTaskRuntimeState as P, KodaXManagedTaskStatusEvent as Q, KodaXMcpConnectMode as R, KodaXMcpServerConfig as S, KodaXMcpServersConfig as T, KodaXMcpTransport as U, KodaXMemoryStrategy as V, KodaXOptions as W, KodaXOrchestrationVerdict as X, KodaXParentReductionContract as Y, KodaXProviderPolicyHints as Z, KodaXRepoIntelligenceCapability as _, AskUserMultiOptions as a, KodaXRepoIntelligenceResolvedMode as a0, KodaXRepoIntelligenceTrace as a1, KodaXRepoIntelligenceTraceEvent as a2, KodaXRepoRoutingSignals as a3, KodaXResult as a4, KodaXRoleRoundSummary as a5, KodaXRuntimeVerificationContract as a6, KodaXSessionControl as a7, KodaXSessionMutators as a8, KodaXSessionOptions as a9, RecoveryDecision as aA, RecoveryLadderStep as aB, RecoveryResult as aC, ResilienceClassification as aD, ResilienceErrorClass as aE, RulesLoadError as aF, RulesLoadResult as aG, SignalCollector as aH, SkippedRulesSource as aI, TodoItem as aJ, TodoList as aK, TodoStatus as aL, ToolCallSignal as aM, TrustState as aN, KodaXSkillInvocationContext as aa, KodaXSkillMap as ab, KodaXSkillProjectionConfidence as ac, KodaXTaskCapabilityHint as ad, KodaXTaskContract as ae, KodaXTaskEvidenceArtifact as af, KodaXTaskEvidenceBundle as ag, KodaXTaskEvidenceEntry as ah, KodaXTaskRole as ai, KodaXTaskRoleAssignment as aj, KodaXTaskStatus as ak, KodaXTaskSurface as al, KodaXTaskToolPolicy as am, KodaXTaskVerificationContract as an, KodaXTaskVerificationCriterion as ao, KodaXTaskWorkItem as ap, KodaXToolExecutionContext as aq, KodaXVerificationScorecard as ar, KodaXVerificationScorecardCriterion as as, LoadAgentsOptions as at, LoadedRulesSource as au, ProviderExecutionState as av, ProviderRecoveryEvent as aw, ProviderResilienceConfig as ax, ProviderResiliencePolicy as ay, RecoveryAction as az, AskUserQuestionItem as b, AskUserQuestionOptions as c, AutoModeAskUser as d, AutoModeAskUserVerdict as e, AutoModeEngine as f, AutoModeGuardrailConfig as g, AutoModeSharedState as h, AutoModeStats as i, AutoModeToolGuardrail as j, AutoRules as k, BashPrefixExtractor as l, BashPrefixResult as m, CircuitBreaker as o, CreateBashPrefixExtractorOptions as p, ExtensionRuntimeContract as q, ExtractCommandPrefixOptions as r, KodaXBudgetDisclosureZone as s, KodaXBudgetExtensionRequest as t, KodaXChildAgentResult as u, KodaXChildContextBundle as v, KodaXContextOptions as w, KodaXContextTokenSnapshot as x, KodaXEvents as y, KodaXFanoutBranchLifecycle as z };
@@ -0,0 +1,110 @@
1
+ /**
2
+ * KodaX Cost Rates - Multi-Provider pricing table
3
+ *
4
+ * 成本费率表 - 所有 Provider 的计费标准
5
+ * 支持 11 个内置 Provider 的成本追踪,用户可以覆盖默认费率
6
+ */
7
+ interface CostRate {
8
+ readonly inputPer1M: number;
9
+ readonly outputPer1M: number;
10
+ readonly cachePer1M?: number;
11
+ }
12
+ declare const DEFAULT_COST_RATES: Readonly<Record<string, Readonly<Record<string, CostRate>>>>;
13
+ declare function getCostRate(provider: string, model: string, userOverrides?: Readonly<Record<string, Readonly<Record<string, CostRate>>>>): CostRate | undefined;
14
+ declare function calculateCost(rate: CostRate, inputTokens: number, outputTokens: number, cacheTokens?: number): number;
15
+
16
+ /**
17
+ * KodaX Cost Tracker - Immutable session cost tracking
18
+ *
19
+ * 成本追踪器 - 不可变的会话成本追踪
20
+ * 使用 Immutable 模式,每次操作都返回新对象而不修改原有对象
21
+ */
22
+
23
+ interface TokenUsageRecord {
24
+ readonly timestamp: number;
25
+ readonly provider: string;
26
+ readonly model: string;
27
+ readonly inputTokens: number;
28
+ readonly outputTokens: number;
29
+ readonly cacheReadTokens: number;
30
+ readonly cacheWriteTokens: number;
31
+ readonly cost: number;
32
+ readonly role?: string;
33
+ }
34
+ interface ProviderCostSummary {
35
+ readonly cost: number;
36
+ readonly calls: number;
37
+ readonly inputTokens: number;
38
+ readonly outputTokens: number;
39
+ }
40
+ /**
41
+ * FEATURE_130 (v0.7.36) — per-retry record. Captures the wait the
42
+ * provider asked us to take so `/cost` can report "X retries, Ys total
43
+ * wait" alongside the token cost. Lives in the same tracker as token
44
+ * records to keep one source of truth for the session.
45
+ */
46
+ interface RetryRecord {
47
+ readonly timestamp: number;
48
+ readonly provider: string;
49
+ readonly waitMs: number;
50
+ readonly reason: 'rate-limit' | 'overloaded';
51
+ readonly source: 'retry-after-seconds' | 'retry-after-date' | 'retry-after-ms' | 'exponential-backoff';
52
+ }
53
+ interface SessionCostSummary {
54
+ readonly totalCost: number;
55
+ readonly totalInputTokens: number;
56
+ readonly totalOutputTokens: number;
57
+ readonly totalCacheTokens: number;
58
+ /** FEATURE_116 (v0.7.37): cumulative cache-read input tokens across the
59
+ * session. Splits `totalCacheTokens` into the read half so the hit rate
60
+ * (`cacheHitRate = totalCacheReadTokens / totalCacheTokens`) is
61
+ * derivable for `/cost` reporting. */
62
+ readonly totalCacheReadTokens: number;
63
+ /** FEATURE_116 (v0.7.37): cumulative cache-write (creation) input tokens. */
64
+ readonly totalCacheWriteTokens: number;
65
+ /** FEATURE_116 (v0.7.37): cache-read share of all cache tokens this
66
+ * session, in [0, 1]. Computed as `totalCacheReadTokens /
67
+ * (totalCacheReadTokens + totalCacheWriteTokens)`. Returns 0 when no
68
+ * cache activity has been recorded — a session with zero cache
69
+ * activity is not "0% hit rate", just untracked. */
70
+ readonly cacheHitRate: number;
71
+ readonly callCount: number;
72
+ /** FEATURE_130: total retries triggered across the session. */
73
+ readonly retryCount: number;
74
+ /** FEATURE_130: cumulative milliseconds spent in retry-after sleeps. */
75
+ readonly retryWaitMs: number;
76
+ readonly byProvider: Readonly<Record<string, ProviderCostSummary>>;
77
+ readonly byRole: Readonly<Record<string, ProviderCostSummary>>;
78
+ }
79
+ interface CostTracker {
80
+ readonly records: readonly TokenUsageRecord[];
81
+ /** FEATURE_130 (v0.7.36): retry-wait records, append-only and immutable. */
82
+ readonly retries: readonly RetryRecord[];
83
+ }
84
+ declare function createCostTracker(): CostTracker;
85
+ /**
86
+ * FEATURE_130 (v0.7.36): record a retry-after wait. The InkREPL spinner
87
+ * (or any other consumer of `KodaXEvents.onRetryAfter`) calls this so
88
+ * `/cost` can surface accurate session-wide retry telemetry.
89
+ */
90
+ declare function recordRetry(tracker: CostTracker, entry: {
91
+ readonly provider: string;
92
+ readonly waitMs: number;
93
+ readonly reason: 'rate-limit' | 'overloaded';
94
+ readonly source: 'retry-after-seconds' | 'retry-after-date' | 'retry-after-ms' | 'exponential-backoff';
95
+ }): CostTracker;
96
+ declare function recordUsage(tracker: CostTracker, entry: {
97
+ readonly provider: string;
98
+ readonly model: string;
99
+ readonly inputTokens: number;
100
+ readonly outputTokens: number;
101
+ readonly cacheReadTokens?: number;
102
+ readonly cacheWriteTokens?: number;
103
+ readonly role?: string;
104
+ }, userCostOverrides?: Readonly<Record<string, Readonly<Record<string, CostRate>>>>): CostTracker;
105
+ declare function getSummary(tracker: CostTracker): SessionCostSummary;
106
+ declare function formatCost(usd: number): string;
107
+ declare function formatCostReport(summary: SessionCostSummary): string;
108
+
109
+ export { DEFAULT_COST_RATES as D, createCostTracker as b, calculateCost as c, formatCostReport as d, getSummary as e, formatCost as f, getCostRate as g, recordUsage as h, recordRetry as r };
110
+ export type { CostRate as C, ProviderCostSummary as P, RetryRecord as R, SessionCostSummary as S, TokenUsageRecord as T, CostTracker as a };