@kodax-ai/kodax 0.7.96 → 0.7.97-alpha.2

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 (127) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +85 -62
  3. package/README_CN.md +57 -67
  4. package/config-templates/config.example.jsonc +0 -14
  5. package/dist/chunks/{agent-7N427EVB.js → agent-J7SHFM5N.js} +1 -1
  6. package/dist/chunks/argument-completer-ZJQOWTIS.js +2 -0
  7. package/dist/chunks/{chunk-ABZDFK2X.js → chunk-2GV6MQ4T.js} +14 -14
  8. package/dist/chunks/{chunk-6QI3GOYG.js → chunk-3PS3YEDS.js} +1 -1
  9. package/dist/chunks/chunk-4VJMQDTH.js +417 -0
  10. package/dist/chunks/{chunk-NI7PBPUR.js → chunk-5DSUVP46.js} +1 -1
  11. package/dist/chunks/chunk-5P7RTSZT.js +21 -0
  12. package/dist/chunks/{chunk-XXNR6S4Q.js → chunk-6ZAQKFIM.js} +1 -1
  13. package/dist/chunks/chunk-7V2QBZ73.js +137 -0
  14. package/dist/chunks/{chunk-C7U542KM.js → chunk-F7DHZH6T.js} +1 -1
  15. package/dist/chunks/{chunk-7IMWOR34.js → chunk-HSRYDDPF.js} +1 -1
  16. package/dist/chunks/chunk-K3DQGSQU.js +372 -0
  17. package/dist/chunks/chunk-NO23K2CB.js +2 -0
  18. package/dist/chunks/{chunk-NKT3B3DR.js → chunk-OT5WHAX4.js} +1 -1
  19. package/dist/chunks/{chunk-YEAUDI6U.js → chunk-QGWHJIO4.js} +1 -1
  20. package/dist/chunks/chunk-QOFFAY5C.js +261 -0
  21. package/dist/chunks/{chunk-4PFZ7BEE.js → chunk-QVDTORL3.js} +11 -11
  22. package/dist/chunks/chunk-QZ4B4AWG.js +473 -0
  23. package/dist/chunks/chunk-RXDS6CNA.js +355 -0
  24. package/dist/chunks/{chunk-WV3DJVW4.js → chunk-VDGPJQL7.js} +135 -135
  25. package/dist/chunks/chunk-VEZ4WHPN.js +641 -0
  26. package/dist/chunks/chunk-ZPPAT25E.js +5 -0
  27. package/dist/chunks/chunk-ZQYWDI4O.js +1 -0
  28. package/dist/chunks/chunk-ZS2GUADU.js +498 -0
  29. package/dist/chunks/{chunk-GN2IY5YE.js → chunk-ZTYZYXGV.js} +1 -1
  30. package/dist/chunks/{chunk-EM4XJBTK.js → chunk-ZZQ4GDVU.js} +1 -1
  31. package/dist/chunks/{client-6WZZTTSV.js → client-MXOJ5XUN.js} +1 -1
  32. package/dist/chunks/{compaction-config-ZMEJU4U7.js → compaction-config-5VZSGKBQ.js} +1 -1
  33. package/dist/chunks/{construction-bootstrap-RX4DMHI7.js → construction-bootstrap-U2ZU2WAT.js} +1 -1
  34. package/dist/chunks/dist-CSLNWLOE.js +2 -0
  35. package/dist/chunks/dist-XXMJMJDU.js +2 -0
  36. package/dist/chunks/host-RUXYZFYN.js +2 -0
  37. package/dist/chunks/readline-helpers-JCVULR4C.js +2 -0
  38. package/dist/chunks/run-manager-DRIM5VNE.js +2 -0
  39. package/dist/chunks/utils-MQEBGKIX.js +2 -0
  40. package/dist/index.d.ts +63 -30
  41. package/dist/index.js +10 -6
  42. package/dist/kodax_bootstrap.js +1 -1
  43. package/dist/kodax_cli.js +1745 -1734
  44. package/dist/kodax_resume.js +32 -35
  45. package/dist/native/win32-x64/kodax-windows-sandbox.exe +0 -0
  46. package/dist/native/win32-x64/kodax-windows-text-transaction.node +0 -0
  47. package/dist/native/win32-x64/manifest.json +2 -2
  48. package/dist/sandbox-network-broker.js +77 -77
  49. package/dist/sdk-a2a.d.ts +33 -18
  50. package/dist/sdk-a2a.js +8 -9
  51. package/dist/sdk-agent.d.ts +33 -26
  52. package/dist/sdk-agent.js +1 -1
  53. package/dist/sdk-client.d.ts +40 -0
  54. package/dist/sdk-client.js +2 -0
  55. package/dist/sdk-coding.d.ts +87 -499
  56. package/dist/sdk-coding.js +1 -1
  57. package/dist/sdk-experimental-memory.d.ts +3 -4
  58. package/dist/sdk-experimental-memory.js +1 -1
  59. package/dist/sdk-llm.d.ts +11 -9
  60. package/dist/sdk-llm.js +1 -1
  61. package/dist/sdk-mcp.d.ts +3 -3
  62. package/dist/sdk-mcp.js +1 -1
  63. package/dist/sdk-media.d.ts +3 -1
  64. package/dist/sdk-media.js +1 -1
  65. package/dist/sdk-repl.d.ts +317 -70
  66. package/dist/sdk-repl.js +2 -2
  67. package/dist/sdk-runtime.d.ts +580 -452
  68. package/dist/sdk-runtime.js +1 -1
  69. package/dist/sdk-sandbox.js +1 -1
  70. package/dist/sdk-session.d.ts +13 -9
  71. package/dist/sdk-session.js +1 -1
  72. package/dist/sdk-skills.js +1 -1
  73. package/dist/semantic-worker.js +57 -57
  74. package/dist/types-chunks/{base.d-Bt9lhwSV.d.ts → base.d-ZBOdjDUT.d.ts} +2 -1
  75. package/dist/types-chunks/{bash-prefix-extractor.d-DWFIMg0v.d.ts → bash-prefix-extractor.d-DvswAXKS.d.ts} +136 -66
  76. package/dist/types-chunks/{capability-learning.d-gRtO03f6.d.ts → capability-learning.d-B4pxKwP4.d.ts} +1 -1
  77. package/dist/types-chunks/{capability.d-Ch5Vos33.d.ts → capability.d-DOF3r0fJ.d.ts} +1 -1
  78. package/dist/types-chunks/{capsule.d-Dj1n6s0Y.d.ts → capsule.d-B4atvlxE.d.ts} +7 -19
  79. package/dist/types-chunks/client-contract-A1jdk6xz.d.ts +1993 -0
  80. package/dist/types-chunks/{controller.d-C0IM1Tud.d.ts → controller.d-BkUJ_3sl.d.ts} +1 -1
  81. package/dist/types-chunks/{controller.d-J2t1q8Ly.d.ts → controller.d-yyKajPTi.d.ts} +140 -1380
  82. package/dist/types-chunks/{cost-tracker.d-BWI4lFWn.d.ts → cost-tracker.d-BeaenODW.d.ts} +2 -47
  83. package/dist/types-chunks/{history-retrieval.d-CPN5PMBV.d.ts → history-retrieval.d-JdFfkeF3.d.ts} +2 -2
  84. package/dist/types-chunks/{manager.d-rtmywU9M.d.ts → manager.d-C_20XqCV.d.ts} +8 -1
  85. package/dist/types-chunks/manifest.d-Bw2i-zQi.d.ts +18 -0
  86. package/dist/types-chunks/provider-credential-context.d-BH2OaB1b.d.ts +47 -0
  87. package/dist/types-chunks/provider-request-observation.d-jL8T6wVO.d.ts +34 -0
  88. package/dist/types-chunks/{public-api.d-amBop8Nk.d.ts → public-api.d-Cq8ILMte.d.ts} +52 -13
  89. package/dist/types-chunks/{resolver.d-BrwLoWNr.d.ts → resolver.d-DLY01RHx.d.ts} +4 -2
  90. package/dist/types-chunks/{types.d-CSv0_cZC.d.ts → review-inbox.d-BeaLRNHx.d.ts} +251 -3
  91. package/dist/types-chunks/{shell-command-sets.d-oejwpP_7.d.ts → review-packet.d-D4bbTbq3.d.ts} +46 -3
  92. package/dist/types-chunks/{exec-policy.d-BPESl90L.d.ts → run-manager.d-C7Q71rin.d.ts} +385 -62
  93. package/dist/types-chunks/runtime-client-info-CxnlZlW5.d.ts +175 -0
  94. package/dist/types-chunks/{sdk-session-B6XjHNU1.d.ts → sdk-session-BDFjCpDn.d.ts} +12 -4
  95. package/dist/types-chunks/{side-query.d-DHWG1JZg.d.ts → side-query.d-DTrhVd_r.d.ts} +4 -3
  96. package/dist/types-chunks/trusted-repl-entry-vbUM8R6P.d.ts +445 -0
  97. package/dist/types-chunks/{types.d-CtO8mR1s.d.ts → types.d-BJTN-RZr.d.ts} +5 -5
  98. package/dist/types-chunks/{types.d-BrQMB-hy.d.ts → types.d-BjOq57-z.d.ts} +6 -0
  99. package/dist/types-chunks/types.d-o7t9dds4.d.ts +1484 -0
  100. package/dist/types-chunks/{utils.d-DcznBeQ3.d.ts → utils.d-CWiMhFfu.d.ts} +202 -36
  101. package/docs/CLIENT_CONTRACT.md +441 -0
  102. package/docs/SDK_MIGRATION.md +123 -0
  103. package/docs/SPACE_SDK_SEAMS.md +139 -0
  104. package/package.json +10 -5
  105. package/public_docs/README.md +12 -133
  106. package/public_docs/configuration/config-files.md +8 -14
  107. package/public_docs/sdk/embedder-guide.md +494 -420
  108. package/dist/chunks/argument-completer-FAIHW7HZ.js +0 -2
  109. package/dist/chunks/chunk-66XN5AFU.js +0 -417
  110. package/dist/chunks/chunk-7O2AIFNE.js +0 -373
  111. package/dist/chunks/chunk-DSXUXUZG.js +0 -5
  112. package/dist/chunks/chunk-GYO73UYQ.js +0 -275
  113. package/dist/chunks/chunk-HPCS3LZ5.js +0 -324
  114. package/dist/chunks/chunk-HZYRLIOC.js +0 -137
  115. package/dist/chunks/chunk-SC2ELSUS.js +0 -675
  116. package/dist/chunks/chunk-TEUD5VPJ.js +0 -471
  117. package/dist/chunks/chunk-TYZ2ZAYL.js +0 -487
  118. package/dist/chunks/dist-3UCCMCYR.js +0 -2
  119. package/dist/chunks/dist-F5IWZSAY.js +0 -2
  120. package/dist/chunks/host-W2JJ3V3Q.js +0 -2
  121. package/dist/chunks/run-manager-RBWU3EVE.js +0 -2
  122. package/dist/chunks/utils-DJ4ZFJGL.js +0 -2
  123. package/dist/runtime-worker.js +0 -5381
  124. package/dist/types-chunks/review-inbox.d-CTeUIKda.d.ts +0 -225
  125. package/dist/types-chunks/run-manager.d-hm1XgEou.d.ts +0 -94
  126. package/dist/types-chunks/trusted-repl-entry-D0w5M0UZ.d.ts +0 -323
  127. package/dist/types-chunks/types.d-B1l9pWyX.d.ts +0 -146
@@ -1,10 +1,65 @@
1
1
  import { b as McpServersConfig, M as McpConnectMode, a as McpServerConfig, c as McpTransportKind } from './config.d-CJy1WENT.js';
2
- import { K as KodaXBaseProvider } from './base.d-Bt9lhwSV.js';
3
- import { a as CostTracker } from './cost-tracker.d-BWI4lFWn.js';
4
- import { cb as RunnerToolCall, cH as ToolGuardrail, aM as GuardrailContext, aQ as GuardrailVerdict } from './controller.d-J2t1q8Ly.js';
5
- import { k as KodaXMessage } from './types.d-BrQMB-hy.js';
6
- import { S as SideQueryDiagnostics } from './side-query.d-DHWG1JZg.js';
7
- import { b$ as ToolSideEffect, aE as KodaXShellPermissionMode } from './bash-prefix-extractor.d-DWFIMg0v.js';
2
+ import { K as KodaXBaseProvider } from './base.d-ZBOdjDUT.js';
3
+ import { a as CostTracker } from './cost-tracker.d-BeaenODW.js';
4
+ import { aD as RunnerToolCall, b7 as ToolGuardrail, z as GuardrailContext, J as GuardrailVerdict, x as Guardrail } from './controller.d-yyKajPTi.js';
5
+ import { k as KodaXMessage } from './types.d-BjOq57-z.js';
6
+ import { S as SideQueryDiagnostics } from './side-query.d-DTrhVd_r.js';
7
+ import { c0 as ToolSideEffect, aF as KodaXShellPermissionMode, J as KodaXChildAgentResult, aa as KodaXOptions, S as KodaXContextOptions, v as KodaXActorHost, b9 as KodaXToolExecutionContext, L as KodaXChildContextBundle, M as KodaXChildExecutionResult, c1 as WorkflowHostPolicy, V as KodaXEvents } from './bash-prefix-extractor.d-DvswAXKS.js';
8
+ import { b5 as WorkflowEventCorrelation, bL as WorkflowTaskSummaryEventUpdate, a_ as WorkflowAgentBackend, bz as WorkflowProcessTrackerOptions, b4 as WorkflowEvent, b2 as WorkflowArtifactRef, bb as WorkflowMeta, bC as WorkflowRunState, bd as WorkflowModule, b0 as WorkflowApproval, bm as WorkflowProcessEvent, b1 as WorkflowApprovalSummary, b9 as WorkflowLimits, aV as ManagedWorkflowSnapshot$1, bt as WorkflowProcessSnapshot, bB as WorkflowRunManager$1 } from './types.d-o7t9dds4.js';
9
+ import { aG as KodaXSessionStorage, a as AgentActorClient, q as AgentCapabilities } from './review-inbox.d-BeaLRNHx.js';
10
+ import { b as WorkflowScriptManifest } from './manifest.d-Bw2i-zQi.js';
11
+
12
+ /**
13
+ * Circuit Breaker — FEATURE_092 Phase 2b.4 (v0.7.33).
14
+ *
15
+ * Sliding-window error counter for classifier failures (timeouts, 5xx, 429,
16
+ * unparseable outputs). When ≥ 5 errors land within a 10-minute window, the
17
+ * callers temporarily skip classifier calls and apply the Accept-edits
18
+ * failure boundary. The selected Auto engine remains `llm`; health state is
19
+ * diagnostic, not a mode change.
20
+ *
21
+ * Pure functional API: each operation returns a new breaker. No mutation.
22
+ * Memory bound: stale timestamps are pruned on each recordError call so
23
+ * the timestamps array never grows unbounded.
24
+ */
25
+ declare const ERROR_THRESHOLD = 5;
26
+ declare const WINDOW_MS: number;
27
+ interface CircuitBreaker {
28
+ readonly timestamps: readonly number[];
29
+ }
30
+ declare function createCircuitBreaker(): CircuitBreaker;
31
+ declare function recordError(b: CircuitBreaker, now: number): CircuitBreaker;
32
+ declare function shouldFallback$1(b: CircuitBreaker, now: number): boolean;
33
+
34
+ /**
35
+ * Denial Tracker — FEATURE_092 Phase 2b.4 (v0.7.33).
36
+ *
37
+ * Tracks classifier blocks per session. When either threshold is crossed,
38
+ * threshold state is exposed for diagnostics and does not mutate the selected
39
+ * Auto engine.
40
+ *
41
+ * - 3 consecutive blocks → likely an unproductive loop (agent not adapting)
42
+ * - 10 blocks in the last 50 completed reviews → broader review loop
43
+ *
44
+ * Both are session-scoped, shared with subagents (per design doc, to defend
45
+ * against threshold-bypass via spawning).
46
+ *
47
+ * Pure functional API: each operation returns a new tracker. No mutation.
48
+ */
49
+ declare const CONSECUTIVE_THRESHOLD = 3;
50
+ declare const RECENT_DENIAL_THRESHOLD = 10;
51
+ declare const RECENT_WINDOW_SIZE = 50;
52
+ interface DenialTracker {
53
+ readonly consecutive: number;
54
+ /** Lifetime diagnostic only; never trips the breaker by itself. */
55
+ readonly cumulative: number;
56
+ /** Bounded completed-review window. `true` means the reviewer denied. */
57
+ readonly recent?: readonly boolean[];
58
+ }
59
+ declare function createDenialTracker(): DenialTracker;
60
+ declare function recordBlock(t: DenialTracker): DenialTracker;
61
+ declare function recordAllow(t: DenialTracker): DenialTracker;
62
+ declare function shouldFallback(t: DenialTracker): boolean;
8
63
 
9
64
  /**
10
65
  * FEATURE_200 Phase F (v0.7.45) — MCP domain types extracted from types.ts.
@@ -487,58 +542,6 @@ type AbsoluteDenyCheck = (call: RunnerToolCall, projectRoot: string, executionCw
487
542
  */
488
543
  declare function checkAbsoluteDeny(call: RunnerToolCall, projectRoot: string, executionCwd?: string): AbsoluteDenyResult;
489
544
 
490
- /**
491
- * Circuit Breaker — FEATURE_092 Phase 2b.4 (v0.7.33).
492
- *
493
- * Sliding-window error counter for classifier failures (timeouts, 5xx, 429,
494
- * unparseable outputs). When ≥ 5 errors land within a 10-minute window, the
495
- * callers temporarily skip classifier calls and apply the Accept-edits
496
- * failure boundary. The selected Auto engine remains `llm`; health state is
497
- * diagnostic, not a mode change.
498
- *
499
- * Pure functional API: each operation returns a new breaker. No mutation.
500
- * Memory bound: stale timestamps are pruned on each recordError call so
501
- * the timestamps array never grows unbounded.
502
- */
503
- declare const ERROR_THRESHOLD = 5;
504
- declare const WINDOW_MS: number;
505
- interface CircuitBreaker {
506
- readonly timestamps: readonly number[];
507
- }
508
- declare function createCircuitBreaker(): CircuitBreaker;
509
- declare function recordError(b: CircuitBreaker, now: number): CircuitBreaker;
510
- declare function shouldFallback$1(b: CircuitBreaker, now: number): boolean;
511
-
512
- /**
513
- * Denial Tracker — FEATURE_092 Phase 2b.4 (v0.7.33).
514
- *
515
- * Tracks classifier blocks per session. When either threshold is crossed,
516
- * threshold state is exposed for diagnostics and does not mutate the selected
517
- * Auto engine.
518
- *
519
- * - 3 consecutive blocks → likely an unproductive loop (agent not adapting)
520
- * - 10 blocks in the last 50 completed reviews → broader review loop
521
- *
522
- * Both are session-scoped, shared with subagents (per design doc, to defend
523
- * against threshold-bypass via spawning).
524
- *
525
- * Pure functional API: each operation returns a new tracker. No mutation.
526
- */
527
- declare const CONSECUTIVE_THRESHOLD = 3;
528
- declare const RECENT_DENIAL_THRESHOLD = 10;
529
- declare const RECENT_WINDOW_SIZE = 50;
530
- interface DenialTracker {
531
- readonly consecutive: number;
532
- /** Lifetime diagnostic only; never trips the breaker by itself. */
533
- readonly cumulative: number;
534
- /** Bounded completed-review window. `true` means the reviewer denied. */
535
- readonly recent?: readonly boolean[];
536
- }
537
- declare function createDenialTracker(): DenialTracker;
538
- declare function recordBlock(t: DenialTracker): DenialTracker;
539
- declare function recordAllow(t: DenialTracker): DenialTracker;
540
- declare function shouldFallback(t: DenialTracker): boolean;
541
-
542
545
  /**
543
546
  * AutoModeToolGuardrail — FEATURE_092 Phase 2b.6 (v0.7.33).
544
547
  *
@@ -782,8 +785,6 @@ interface AutoModeGuardrailConfig {
782
785
  * Layer-owned high-impact pattern checks. They add classifier evidence.
783
786
  */
784
787
  readonly extraAbsoluteDenyChecks?: readonly AbsoluteDenyCheck[];
785
- /** @deprecated Retained as inert source-compatibility input. */
786
- readonly speculativeWindowMs?: number;
787
788
  }
788
789
  /**
789
790
  * Snapshot of the auto-mode guardrail's session-scoped state. Returned by
@@ -894,5 +895,327 @@ declare function tokenizeShellCommand(command: string): {
894
895
  readonly compound: boolean;
895
896
  };
896
897
 
897
- export { CLASSIFIER_MAX_OUTPUT_TOKENS as C, DEFAULT_CLASSIFIER_RETRY_TIMEOUT_MS as L, DEFAULT_CLASSIFIER_TIMEOUT_MS as M, ERROR_THRESHOLD as O, RECENT_DENIAL_THRESHOLD as a3, RECENT_WINDOW_SIZE as a4, WINDOW_MS as a8, buildClassifierPrompt as a9, checkAbsoluteDeny as aa, classify as ab, collectAllSignals as ac, createAutoModeToolGuardrail as ad, createCircuitBreaker as ae, createDenialTracker as af, createExecPolicyOperation as ag, evaluateExecPolicy as ah, evaluateShellExecPolicy as ai, formatAgentsForPrompt as aj, formatExecPolicyConfigurationError as ak, formatExecPolicyRejection as al, getKodaxGlobalDir as am, loadAgentsFiles as an, loadExecPolicy as ao, parseClassifierOutput as ap, parseExecPolicy as aq, recordAllow as ar, recordBlock as as, recordError as at, shouldFallback as au, shouldFallback$1 as av, tokenizeShellCommand as aw, CONSECUTIVE_THRESHOLD as t };
898
- export type { LoadAgentsOptions as $, AbsoluteDenyCheck as A, BuildClassifierPromptInput as B, ClassifierObservedProtocol as D, ClassifierOutputWarningCode as E, ClassifierParseFailureCode as F, ClassifierPrompt as G, ClassifierProtocol as H, ClassifierToolProjectionResolver as I, ClassifyDecision as J, ClassifyOptions as K, DenialTracker as N, ExecPolicyCriticalEffect as P, ExecPolicyDecision as Q, ExecPolicyEvaluation as R, ExecPolicyOperation as S, ExecPolicyRejection as T, ExecPolicyRule as U, ExecPolicyRuleInput as V, ExecPolicySource as W, KodaXMcpConnectMode as X, KodaXMcpServerConfig as Y, KodaXMcpServersConfig as Z, KodaXMcpTransport as _, AbsoluteDenyMatch as a, LoadExecPolicyOptions as a0, LoadExecPolicyResult as a1, ParseExecPolicyResult as a2, SignalCollector as a5, TierZeroPatternId as a6, ToolCallSignal as a7, AbsoluteDenyMiss as b, AbsoluteDenyResult as c, AgentsFile as d, AutoModeAskUser as e, AutoModeAskUserVerdict as f, AutoModeCallAnalyzer as g, AutoModeDecisionDiagnostics as h, AutoModeGuardrailConfig as i, AutoModePermissionBoundary as j, AutoModePermissionOperation as k, AutoModePermissionReview as l, AutoModePermissionTarget as m, AutoModeRulesContext as n, AutoModeRulesDecision as o, AutoModeRulesEvaluator as p, AutoModeSharedState as q, AutoModeStats as r, AutoModeToolGuardrail as s, CircuitBreaker as u, ClassifierAttemptDiagnostics as v, ClassifierAttemptOutcome as w, ClassifierDecision as x, ClassifierFailureKind as y, ClassifierHazard as z };
898
+ /**
899
+ * Predicate the parent REPL injects so the child executor can enforce plan-mode
900
+ * constraints without `packages/coding` reverse-depending on `packages/repl`.
901
+ *
902
+ * The predicate MUST read the parent's permission mode lazily (e.g., through a
903
+ * closure over a ref), so mid-run mode toggles propagate to in-flight child tool
904
+ * calls. Returns the block reason (string) for tools/inputs that are currently
905
+ * plan-mode-violating, or `null` when the call is allowed right now.
906
+ */
907
+ type PlanModeBlockCheck = (tool: string, input: Record<string, unknown>) => string | null;
908
+ interface WorkflowChildDigestUpdate {
909
+ readonly childId: string;
910
+ readonly digest?: string;
911
+ readonly digestFailed?: boolean;
912
+ readonly totalTokensUsed: number;
913
+ readonly digestTokensUsed?: number;
914
+ readonly usage?: {
915
+ readonly inputTokens?: number;
916
+ readonly outputTokens?: number;
917
+ readonly totalTokens?: number;
918
+ readonly cacheReadTokens?: number;
919
+ };
920
+ }
921
+ interface ChildExecutorOptions {
922
+ readonly onIteration?: (iteration: NonNullable<KodaXChildAgentResult['iteration']>) => void;
923
+ readonly maxParallel: number;
924
+ readonly maxIterationsPerChild: number;
925
+ readonly abortSignal?: AbortSignal;
926
+ /** Parent-provided persistence capability for an isolated child-owned lineage. */
927
+ readonly historyStorage?: KodaXSessionStorage;
928
+ readonly parentOptions: Readonly<Partial<Pick<KodaXOptions, 'provider' | 'model' | 'effort' | 'reasoningMode' | 'extensionRuntime' | 'events' | 'compaction' | 'disablePromptCache' | 'sandbox'> & Pick<KodaXContextOptions, 'repoIntelligenceMode' | 'repoIntelligenceTrace' | 'contextDiagnostics' | 'shellExecution' | 'permissionIntent'>>>;
929
+ readonly parentRole: string;
930
+ readonly parentHarness: string;
931
+ /**
932
+ * FEATURE_217 (v0.7.49): set by the workflow agent backend to enable the
933
+ * one-turn, no-tool self-distill digest for workflow-launched children.
934
+ * Distinct from `parentHarness` because workflow children must keep
935
+ * `parentHarness:'tool-dispatch'` so `validateWriteBundles` still admits
936
+ * write children — the two concerns cannot share one field.
937
+ */
938
+ readonly workflowChild?: boolean;
939
+ /**
940
+ * Workflow child digest mode. `blocking` preserves FEATURE_217 behavior.
941
+ * `async` returns the child result immediately and reports the digest through
942
+ * `onWorkflowChildDigest`; worktree-isolated children still use blocking mode
943
+ * so the digest runs before cleanup removes the worktree.
944
+ */
945
+ readonly workflowDigestMode?: 'blocking' | 'async';
946
+ readonly onWorkflowChildDigest?: (update: WorkflowChildDigestUpdate) => void;
947
+ readonly workflowCorrelation?: WorkflowEventCorrelation;
948
+ /** User-facing child label for live telemetry surfaces. Defaults to bundle id. */
949
+ readonly childActivityName?: string;
950
+ /** Progress callback for REPL status display. Called when children start, progress, and complete. */
951
+ readonly onProgress?: (status: string) => void;
952
+ /**
953
+ * FEATURE_074: Predicate provided by the parent REPL to evaluate plan-mode block
954
+ * reasons at each child tool call. The predicate closes over parent state so
955
+ * mid-run mode toggles propagate to in-flight children. When absent, children
956
+ * run without plan-mode enforcement.
957
+ */
958
+ readonly planModeBlockCheck?: PlanModeBlockCheck;
959
+ /**
960
+ * FEATURE_092 phase 2b.7b slice D: parent-Runner guardrails forwarded into
961
+ * each child's `Runner.run` via `KodaXOptions.guardrails`. The auto-mode
962
+ * guardrail's mutable review-denial and circuit-breaker state is shared by
963
+ * passing the SAME instance, so children cannot restart the parent's bounded
964
+ * denial budget.
965
+ */
966
+ readonly guardrails?: readonly Guardrail[];
967
+ /** Runtime-minted principal inherited by the child runtime for recursive collaboration. */
968
+ readonly actorControl?: AgentActorClient;
969
+ /** Exact non-root parent identity for nested live-context attribution. */
970
+ readonly actorParentAgentId?: string;
971
+ /** Exact admitted Actor Turn id used as the child run's live Turn identity. */
972
+ readonly actorTurnId?: string;
973
+ /** Trusted host bridge inherited beside the principal for nested Workflow owners. */
974
+ readonly actorHost?: KodaXActorHost;
975
+ /** Prior Actor turns and committed mailbox facts projected into this turn. */
976
+ readonly initialMessages?: readonly KodaXMessage[];
977
+ /** Runtime-minted ceiling applied after specialist/default tool resolution. */
978
+ readonly actorCapabilities?: AgentCapabilities;
979
+ /** Logical diagnostics identity when bundle ids are local to a Workflow backend. */
980
+ readonly contextAgentId?: string;
981
+ /** Logical diagnostics parent paired with contextAgentId. */
982
+ readonly contextParentAgentId?: string;
983
+ }
984
+
985
+ /** Coding Workflow adapter over the Runtime-owned Actor control plane. */
986
+
987
+ /** The subset of `ChildExecutorOptions` the caller fixes once per run. */
988
+ type WorkflowChildOptions = Omit<ChildExecutorOptions, 'maxParallel' | 'abortSignal' | 'workflowChild' | 'workflowDigestMode' | 'onWorkflowChildDigest' | 'workflowCorrelation'>;
989
+ interface CodingWorkflowBackendDeps {
990
+ /** Parent tool-execution context carrying the Workflow owner's Actor binding. */
991
+ readonly ctx: KodaXToolExecutionContext;
992
+ /** Fixed per-run child options (parentRole / parentHarness / parentOptions
993
+ * / maxIterationsPerChild / guardrails / …). */
994
+ readonly childOptions: WorkflowChildOptions;
995
+ /** Seam: child runner. Defaults to `executeChildAgents`. */
996
+ readonly runChild?: (bundles: readonly KodaXChildContextBundle[], ctx: KodaXToolExecutionContext, options: ChildExecutorOptions) => Promise<KodaXChildExecutionResult>;
997
+ /** Seam: unique child id generator. */
998
+ readonly generateId?: () => string;
999
+ /** Workflow run id for correlating child-agent SDK callbacks. */
1000
+ readonly runId?: string;
1001
+ /** Default child write policy from the workflow manifest. */
1002
+ readonly defaultChildReadOnly?: boolean;
1003
+ /** Seam: workspace changed path reader. Defaults to git status/diff. */
1004
+ readonly listChangedFiles?: (ctx: KodaXToolExecutionContext) => Promise<readonly string[]>;
1005
+ readonly onTaskSummary?: (taskId: string, update: WorkflowTaskSummaryEventUpdate) => void;
1006
+ /** True only for scripts generated by KodaX in this run; never inferred from schema content. */
1007
+ readonly kodaxAuthored?: boolean;
1008
+ }
1009
+ /**
1010
+ * Build a `WorkflowAgentBackend` over the coding child-dispatch substrate.
1011
+ */
1012
+ declare function createCodingWorkflowBackend(deps: CodingWorkflowBackendDeps): WorkflowAgentBackend;
1013
+
1014
+ /**
1015
+ * FEATURE_217 (v0.7.49) Phase D — Durable workflow run graph.
1016
+ *
1017
+ * Persists a workflow run as `run.json` + append-only `events.jsonl` +
1018
+ * `artifacts/` under a caller-supplied run directory (the REPL points
1019
+ * this at `~/.kodax/workflow-runs/<project-key>/<runId>/` via
1020
+ * `getAgentConfigPath`). Modelling the run as an event stream — not a
1021
+ * single summary blob — keeps the agent relationships (spawn / message /
1022
+ * complete / synthesize) inspectable after the fact.
1023
+ *
1024
+ * `appendFileSync` is used for events so the on-disk order matches the
1025
+ * recorder's `seq` order with no async interleave.
1026
+ */
1027
+
1028
+ type WorkflowRunProcessMetadata = Pick<WorkflowProcessTrackerOptions, 'displayName' | 'goal' | 'source' | 'savedWorkflowName' | 'sourceRunId' | 'sourceWorkflowName' | 'revisionOf' | 'resumedFromRunId' | 'hostMetadata'>;
1029
+ interface RunGraphWriterDeps {
1030
+ /** Clock for the per-event `ts` stamp. Defaults to `Date.now`. */
1031
+ readonly now?: () => number;
1032
+ }
1033
+ interface RunJsonInput {
1034
+ readonly meta: WorkflowMeta;
1035
+ readonly args: unknown;
1036
+ readonly state: WorkflowRunState;
1037
+ readonly startedAt: number;
1038
+ readonly endedAt: number;
1039
+ readonly scriptSnapshot?: WorkflowScriptSnapshotRef;
1040
+ readonly resultSummary?: string;
1041
+ readonly processMetadata?: WorkflowRunProcessMetadata;
1042
+ }
1043
+ interface WorkflowScriptSnapshotInput {
1044
+ readonly source: string;
1045
+ readonly manifest?: WorkflowScriptManifest;
1046
+ }
1047
+ interface WorkflowScriptSnapshotRef {
1048
+ readonly scriptPath: string;
1049
+ readonly manifestPath?: string;
1050
+ }
1051
+ interface RunGraphWriter {
1052
+ readonly runDir: string;
1053
+ /** Append one event to `events.jsonl`. */
1054
+ onEvent(event: WorkflowEvent): void;
1055
+ /** Persist an artifact under `artifacts/<safe-name>.json`. */
1056
+ writeArtifact(name: string, value: unknown): WorkflowArtifactRef;
1057
+ /** Persist generated workflow source + optional manifest beside run.json. */
1058
+ writeScriptSnapshot(input: WorkflowScriptSnapshotInput): WorkflowScriptSnapshotRef;
1059
+ /** Write the terminal `run.json` summary. */
1060
+ writeRunJson(input: RunJsonInput): void;
1061
+ }
1062
+ declare function safeWorkflowArtifactName(name: string): string;
1063
+ declare function createRunGraphWriter(runDir: string, deps?: RunGraphWriterDeps): RunGraphWriter;
1064
+
1065
+ interface WorktreeSweepDeps {
1066
+ /** Run a git subcommand from `cwd`, resolving stdout. Defaults to `execFile`. */
1067
+ readonly runGit?: (args: readonly string[], cwd: string) => Promise<string>;
1068
+ /** Worktree directory mtime in ms. Defaults to `statSync`. Layer 3 only. */
1069
+ readonly mtimeMs?: (path: string) => number;
1070
+ /** Clock for staleness comparison. Defaults to `Date.now`. Layer 3 only. */
1071
+ readonly now?: () => number;
1072
+ }
1073
+
1074
+ /**
1075
+ * FEATURE_217 (v0.7.49) Phase D — Headless workflow orchestrator.
1076
+ *
1077
+ * Ties together: the approval gate, the coding agent backend (Phase B),
1078
+ * the durable run-graph writer, and the agent-layer `runWorkflow`
1079
+ * envelope. This is the REPL-agnostic core the `/workflow` command
1080
+ * (Phase D.2) drives; it is fully testable with a fake backend + temp
1081
+ * run dir + a stub approval callback.
1082
+ */
1083
+
1084
+ declare const SYSTEM_WORKFLOW_LIMITS: {
1085
+ readonly maxAgents: 64;
1086
+ readonly tokenBudget: 200000;
1087
+ };
1088
+ interface RunWorkflowModuleOptions {
1089
+ readonly module: WorkflowModule;
1090
+ readonly args: unknown;
1091
+ readonly runId: string;
1092
+ /** Directory for the durable run graph (run.json / events.jsonl / artifacts). */
1093
+ readonly runDir: string;
1094
+ /** Parent context — required when the backend is built internally. */
1095
+ readonly ctx?: KodaXToolExecutionContext;
1096
+ /** Per-run child options — required when the backend is built internally. */
1097
+ readonly childOptions?: WorkflowChildOptions;
1098
+ /** Pre-built backend (test seam). When omitted, built from ctx + childOptions. */
1099
+ readonly backend?: WorkflowAgentBackend;
1100
+ /** Approval gate. When omitted, the run auto-proceeds (SDK / headless). */
1101
+ readonly approval?: WorkflowApproval;
1102
+ /** Optional host/SDK ceilings. These may only lower manifest/system limits. */
1103
+ readonly hostPolicy?: WorkflowHostPolicy;
1104
+ readonly signal?: AbortSignal;
1105
+ /** Extra event sink (e.g. live UI), in addition to the durable writer. */
1106
+ readonly onEvent?: (event: WorkflowEvent) => void;
1107
+ /** Host/SDK process snapshot stream. */
1108
+ readonly onWorkflowProcessEvent?: (event: WorkflowProcessEvent) => void;
1109
+ readonly now?: () => number;
1110
+ readonly scriptSnapshot?: WorkflowScriptSnapshotInput;
1111
+ /** FEATURE_246 Part D (ADR-048): a prior run dir to seed the result cache from
1112
+ * for same-session resume. Unchanged effects replay from it; only changed
1113
+ * effects re-run live. */
1114
+ readonly resumeFromRunDir?: string;
1115
+ readonly processMetadata?: WorkflowRunProcessMetadata;
1116
+ /** Optional lifecycle gate, used by WorkflowRunManager pause/resume. */
1117
+ readonly beforeSpawn?: () => Promise<void>;
1118
+ /** Test seam: inject git/mtime for the worktree sweep (FEATURE_217 Layer 2/3). */
1119
+ readonly worktreeSweepDeps?: WorktreeSweepDeps;
1120
+ }
1121
+ type RunWorkflowModuleOutcome = {
1122
+ readonly kind: 'denied';
1123
+ readonly summary: WorkflowApprovalSummary;
1124
+ } | {
1125
+ readonly kind: 'completed';
1126
+ readonly result: unknown;
1127
+ readonly state: WorkflowRunState;
1128
+ } | {
1129
+ readonly kind: 'failed';
1130
+ readonly error: Error;
1131
+ readonly state: WorkflowRunState;
1132
+ };
1133
+ /** Build the pre-run approval summary from a workflow module's metadata. */
1134
+ declare function buildApprovalSummary(module: WorkflowModule, hostPolicy?: WorkflowHostPolicy): WorkflowApprovalSummary;
1135
+ declare function clampWorkflowLimits(meta: WorkflowMeta, hostPolicy?: WorkflowHostPolicy): WorkflowLimits;
1136
+ /**
1137
+ * Run a workflow module end-to-end: approval → runtime + backend +
1138
+ * durable run graph → terminal `run.json`. A workflow execution failure
1139
+ * surfaces as `{ kind: 'failed' }` and a denied approval as
1140
+ * `{ kind: 'denied' }`. Only a misconfiguration (no backend AND no
1141
+ * ctx+childOptions) throws — that is a programmer precondition error.
1142
+ */
1143
+ declare function runWorkflowModule(opts: RunWorkflowModuleOptions): Promise<RunWorkflowModuleOutcome>;
1144
+ interface RunWorkflowFromOptionsInput {
1145
+ readonly module: WorkflowModule;
1146
+ readonly args: unknown;
1147
+ readonly options: KodaXOptions;
1148
+ readonly runId: string;
1149
+ readonly runDir: string;
1150
+ readonly approval?: WorkflowApproval;
1151
+ readonly signal?: AbortSignal;
1152
+ readonly onEvent?: (event: WorkflowEvent) => void;
1153
+ readonly onWorkflowProcessEvent?: (event: WorkflowProcessEvent) => void;
1154
+ readonly now?: () => number;
1155
+ readonly scriptSnapshot?: WorkflowScriptSnapshotInput;
1156
+ /** FEATURE_246 Part D (ADR-048): prior run dir to seed the resume cache. */
1157
+ readonly resumeFromRunDir?: string;
1158
+ readonly processMetadata?: WorkflowRunProcessMetadata;
1159
+ readonly beforeSpawn?: () => Promise<void>;
1160
+ }
1161
+ /**
1162
+ * ADR-049: forward a single workflow child-agent terminal/summary event to the
1163
+ * REPL's per-agent digest hook. Coarse gate here (the four summary event types);
1164
+ * the REPL's `formatWorkflowAgentDigest` does the fine filtering (status, pending
1165
+ * summaries) so inline and slash `/workflow` digests stay identical.
1166
+ */
1167
+ declare function emitWorkflowAgentDigest(events: KodaXEvents | undefined, runId: string, event: WorkflowEvent): void;
1168
+ /**
1169
+ * High-level entry: build a tool-execution context + child options from
1170
+ * `KodaXOptions` (provider / model / extensionRuntime) and run the
1171
+ * workflow module. ctx construction stays inside `@kodax-ai/coding` — the
1172
+ * REPL passes plain `KodaXOptions` (from `createKodaXOptions`) rather than
1173
+ * reaching into run-loop internals.
1174
+ */
1175
+ declare function runWorkflowFromOptions(input: RunWorkflowFromOptionsInput): Promise<RunWorkflowModuleOutcome>;
1176
+
1177
+ /**
1178
+ * FEATURE_246 Part A0b (ADR-046) — coding adapter over the neutral agent-layer
1179
+ * workflow run manager.
1180
+ *
1181
+ * The lifecycle core (registry / pause / resume / stop / process tracking /
1182
+ * settle) now lives in `@kodax-ai/agent` (`createWorkflowRunManager`). This
1183
+ * adapter preserves the coding-facing API (`start` / `startFromOptions` driven
1184
+ * by `RunWorkflowModuleOptions` / `KodaXOptions` + durable run dirs) by building
1185
+ * the agent manager's injected `runFn` from `runWorkflowModule` /
1186
+ * `runWorkflowFromOptions`, and augments the neutral snapshot with the
1187
+ * coding-specific `runDir`. Dependency arrows point coding → agent only.
1188
+ */
1189
+
1190
+ /** Coding snapshot = the neutral agent snapshot plus the durable run dir. */
1191
+ interface ManagedWorkflowSnapshot extends ManagedWorkflowSnapshot$1 {
1192
+ readonly runDir: string;
1193
+ }
1194
+ interface ManagedWorkflowRun {
1195
+ readonly runId: string;
1196
+ readonly done: Promise<RunWorkflowModuleOutcome>;
1197
+ readonly getSnapshot?: () => ManagedWorkflowSnapshot | undefined;
1198
+ readonly getProcessSnapshot?: () => WorkflowProcessSnapshot | undefined;
1199
+ }
1200
+ interface WorkflowRunManager {
1201
+ start(opts: RunWorkflowModuleOptions): ManagedWorkflowRun;
1202
+ startFromOptions(input: RunWorkflowFromOptionsInput): ManagedWorkflowRun;
1203
+ list(): readonly ManagedWorkflowSnapshot[];
1204
+ get(runId: string): ManagedWorkflowSnapshot | undefined;
1205
+ subscribeWorkflowProcess(listener: (event: WorkflowProcessEvent) => void): () => void;
1206
+ getWorkflowProcessSnapshot(runId: string): WorkflowProcessSnapshot | undefined;
1207
+ listWorkflowProcessSnapshots(options?: {
1208
+ readonly activeOnly?: boolean;
1209
+ readonly limit?: number;
1210
+ }): readonly WorkflowProcessSnapshot[];
1211
+ pause(runId: string): boolean;
1212
+ resume(runId: string): boolean;
1213
+ stop(runId: string, reason?: string): boolean;
1214
+ }
1215
+ declare function createWorkflowRunManager(deps?: {
1216
+ readonly now?: () => number;
1217
+ }, agent?: WorkflowRunManager$1): WorkflowRunManager;
1218
+ declare function getDefaultWorkflowRunManager(): WorkflowRunManager;
1219
+
1220
+ export { CLASSIFIER_MAX_OUTPUT_TOKENS as C, DEFAULT_CLASSIFIER_RETRY_TIMEOUT_MS as M, DEFAULT_CLASSIFIER_TIMEOUT_MS as N, ERROR_THRESHOLD as P, RECENT_DENIAL_THRESHOLD as a6, RECENT_WINDOW_SIZE as a7, createWorkflowRunManager as aA, emitWorkflowAgentDigest as aB, evaluateExecPolicy as aC, evaluateShellExecPolicy as aD, formatAgentsForPrompt as aE, formatExecPolicyConfigurationError as aF, formatExecPolicyRejection as aG, getDefaultWorkflowRunManager as aH, getKodaxGlobalDir as aI, loadAgentsFiles as aJ, loadExecPolicy as aK, parseClassifierOutput as aL, parseExecPolicy as aM, recordAllow as aN, recordBlock as aO, recordError as aP, runWorkflowFromOptions as aQ, runWorkflowModule as aR, safeWorkflowArtifactName as aS, shouldFallback as aT, shouldFallback$1 as aU, tokenizeShellCommand as aV, SYSTEM_WORKFLOW_LIMITS as ae, WINDOW_MS as ai, buildApprovalSummary as ao, buildClassifierPrompt as ap, checkAbsoluteDeny as aq, clampWorkflowLimits as ar, classify as as, collectAllSignals as at, createAutoModeToolGuardrail as au, createCircuitBreaker as av, createCodingWorkflowBackend as aw, createDenialTracker as ax, createExecPolicyOperation as ay, createRunGraphWriter as az, CONSECUTIVE_THRESHOLD as t };
1221
+ export type { KodaXMcpTransport as $, AbsoluteDenyCheck as A, BuildClassifierPromptInput as B, ClassifierObservedProtocol as D, ClassifierOutputWarningCode as E, ClassifierParseFailureCode as F, ClassifierPrompt as G, ClassifierProtocol as H, ClassifierToolProjectionResolver as I, ClassifyDecision as J, ClassifyOptions as K, CodingWorkflowBackendDeps as L, DenialTracker as O, ExecPolicyCriticalEffect as Q, ExecPolicyDecision as R, ExecPolicyEvaluation as S, ExecPolicyOperation as T, ExecPolicyRejection as U, ExecPolicyRule as V, ExecPolicyRuleInput as W, ExecPolicySource as X, KodaXMcpConnectMode as Y, KodaXMcpServerConfig as Z, KodaXMcpServersConfig as _, AbsoluteDenyMatch as a, LoadAgentsOptions as a0, LoadExecPolicyOptions as a1, LoadExecPolicyResult as a2, ManagedWorkflowRun as a3, ManagedWorkflowSnapshot as a4, ParseExecPolicyResult as a5, RunGraphWriter as a8, RunGraphWriterDeps as a9, RunJsonInput as aa, RunWorkflowFromOptionsInput as ab, RunWorkflowModuleOptions as ac, RunWorkflowModuleOutcome as ad, SignalCollector as af, TierZeroPatternId as ag, ToolCallSignal as ah, WorkflowChildOptions as aj, WorkflowRunManager as ak, WorkflowRunProcessMetadata as al, WorkflowScriptSnapshotInput as am, WorkflowScriptSnapshotRef as an, AbsoluteDenyMiss as b, AbsoluteDenyResult as c, AgentsFile as d, AutoModeAskUser as e, AutoModeAskUserVerdict as f, AutoModeCallAnalyzer as g, AutoModeDecisionDiagnostics as h, AutoModeGuardrailConfig as i, AutoModePermissionBoundary as j, AutoModePermissionOperation as k, AutoModePermissionReview as l, AutoModePermissionTarget as m, AutoModeRulesContext as n, AutoModeRulesDecision as o, AutoModeRulesEvaluator as p, AutoModeSharedState as q, AutoModeStats as r, AutoModeToolGuardrail as s, CircuitBreaker as u, ClassifierAttemptDiagnostics as v, ClassifierAttemptOutcome as w, ClassifierDecision as x, ClassifierFailureKind as y, ClassifierHazard as z };
@@ -0,0 +1,175 @@
1
+ import { ap as ClientSubmitInput, c as ClientCommandInput, a4 as ClientReviewInput, ar as ClientToolInvocationInput, ax as ClientWorkflowStartInput } from './client-contract-A1jdk6xz.js';
2
+ import { M as AgentSpawnInput } from './review-inbox.d-BeaLRNHx.js';
3
+
4
+ /** Trusted Main bridge contracts; keep this leaf free of Node and Runtime implementation types. */
5
+
6
+ interface RuntimeCredentialRequest {
7
+ readonly leaseId: string;
8
+ readonly provider: string;
9
+ readonly sessionId: string;
10
+ readonly runId: string;
11
+ }
12
+ type RuntimeCredentialBroker = (request: RuntimeCredentialRequest) => Promise<string | undefined>;
13
+ /** Public binding only carries authority; credential material never crosses this input. */
14
+ type RuntimeCredentialBinding = {
15
+ readonly leaseId: string;
16
+ /** v1 compatibility: one credential is acquired for the complete Run. */
17
+ readonly provider: string;
18
+ } | {
19
+ readonly leaseId: string;
20
+ readonly mode: "scoped";
21
+ /** Operation-local narrowing of the registered v2 lease allowlist. */
22
+ readonly providers: readonly string[];
23
+ };
24
+ type RuntimeScopedCredentialTarget = {
25
+ readonly kind: "run";
26
+ readonly runId: string;
27
+ } | {
28
+ readonly kind: "operation";
29
+ readonly operationId: string;
30
+ readonly operation: "session.compact";
31
+ } | {
32
+ readonly kind: "actor_turn";
33
+ readonly actorPath: string;
34
+ readonly turnId: string;
35
+ readonly parentRunId?: string;
36
+ } | {
37
+ readonly kind: "workflow";
38
+ readonly workflowRunId: string;
39
+ readonly parentRunId?: string;
40
+ };
41
+ type RuntimeScopedCredentialPurpose = "primary" | "fallback" | "classifier" | "sidecar" | "compaction" | "workflow" | "utility";
42
+ interface RuntimeScopedCredentialRequest {
43
+ readonly requestId: string;
44
+ readonly leaseId: string;
45
+ readonly provider: string;
46
+ readonly sessionId: string;
47
+ readonly target: RuntimeScopedCredentialTarget;
48
+ readonly purpose: RuntimeScopedCredentialPurpose;
49
+ }
50
+ type RuntimeScopedCredentialBroker = (request: RuntimeScopedCredentialRequest) => Promise<string | undefined>;
51
+ interface RuntimeCredentialLease {
52
+ readonly id: string;
53
+ readonly providers: readonly string[];
54
+ readonly expiresAt?: string;
55
+ /** Absent on legacy v1 daemons. */
56
+ readonly brokerVersion?: 1 | 2;
57
+ }
58
+ interface RuntimeCredentialService {
59
+ register(input: {
60
+ readonly providers: readonly string[];
61
+ readonly expiresAt?: string;
62
+ }, broker: RuntimeCredentialBroker): Promise<RuntimeCredentialLease>;
63
+ resume(leaseId: string, broker: RuntimeCredentialBroker): Promise<RuntimeCredentialLease>;
64
+ registerScoped(input: {
65
+ readonly providers: readonly string[];
66
+ readonly expiresAt?: string;
67
+ }, broker: RuntimeScopedCredentialBroker): Promise<RuntimeCredentialLease>;
68
+ resumeScoped(leaseId: string, broker: RuntimeScopedCredentialBroker): Promise<RuntimeCredentialLease>;
69
+ revoke(leaseId: string): Promise<boolean>;
70
+ }
71
+ interface RuntimeHostToolDescriptor {
72
+ readonly name: string;
73
+ readonly description: string;
74
+ readonly inputSchema: Readonly<Record<string, unknown>>;
75
+ readonly sideEffect: "none" | "idempotent" | "non_idempotent";
76
+ }
77
+ interface RuntimeHostToolInvocation {
78
+ readonly invocationId: string;
79
+ readonly leaseId: string;
80
+ readonly toolName: string;
81
+ readonly sessionId: string;
82
+ readonly runId: string;
83
+ readonly input: Readonly<Record<string, unknown>>;
84
+ }
85
+ interface RuntimeHostToolResult {
86
+ readonly content: string;
87
+ readonly structuredContent?: unknown;
88
+ }
89
+ type RuntimeHostToolHandler = (invocation: RuntimeHostToolInvocation) => Promise<RuntimeHostToolResult>;
90
+ interface RuntimeHostToolLease {
91
+ readonly id: string;
92
+ readonly tools: readonly RuntimeHostToolDescriptor[];
93
+ }
94
+ interface RuntimeHostToolInvocationStatus {
95
+ readonly invocationId: string;
96
+ readonly leaseId: string;
97
+ readonly toolName: string;
98
+ readonly sessionId: string;
99
+ readonly runId: string;
100
+ readonly state: "prepared" | "dispatched" | "completed" | "unknown" | "not_dispatched";
101
+ readonly updatedAt: string;
102
+ }
103
+ interface RuntimeHostToolService {
104
+ register(tools: readonly RuntimeHostToolDescriptor[], handlers: Readonly<Record<string, RuntimeHostToolHandler>>): Promise<RuntimeHostToolLease>;
105
+ resume(leaseId: string, handlers: Readonly<Record<string, RuntimeHostToolHandler>>): Promise<RuntimeHostToolLease>;
106
+ getInvocation(invocationId: string): Promise<RuntimeHostToolInvocationStatus | undefined>;
107
+ revoke(leaseId: string): Promise<boolean>;
108
+ }
109
+ /** Non-secret capabilities selected by trusted Main code, never by a Product input. */
110
+ interface RuntimeExecutionAuthorization {
111
+ readonly credential?: Extract<RuntimeCredentialBinding, {
112
+ readonly mode: 'scoped';
113
+ }>;
114
+ readonly hostTools?: {
115
+ readonly leaseId: string;
116
+ };
117
+ /** Additional ceiling for independently admitted Actor turns. */
118
+ readonly tools?: readonly string[];
119
+ }
120
+ type KodaXClientExecutionRequest = {
121
+ readonly kind: 'input';
122
+ readonly input: ClientSubmitInput;
123
+ } | {
124
+ readonly kind: 'command';
125
+ readonly input: ClientCommandInput;
126
+ } | {
127
+ readonly kind: 'review' | 'agents_lean';
128
+ readonly input: ClientReviewInput;
129
+ } | {
130
+ readonly kind: 'tool';
131
+ readonly input: ClientToolInvocationInput;
132
+ } | {
133
+ readonly kind: 'workflow';
134
+ readonly input: ClientWorkflowStartInput;
135
+ } | {
136
+ readonly kind: 'agent_spawn';
137
+ readonly input: {
138
+ readonly sessionId: string;
139
+ readonly agent: AgentSpawnInput;
140
+ };
141
+ } | {
142
+ readonly kind: 'agent_followup';
143
+ readonly input: {
144
+ readonly sessionId: string;
145
+ readonly actorPath: string;
146
+ readonly objective: string;
147
+ readonly expectedRevision?: number;
148
+ };
149
+ } | {
150
+ readonly kind: 'compaction';
151
+ readonly input: {
152
+ readonly sessionId: string;
153
+ readonly customInstructions?: string;
154
+ };
155
+ };
156
+ type KodaXClientHostAuthorization = (request: KodaXClientExecutionRequest, services: {
157
+ readonly credentials: RuntimeCredentialService;
158
+ readonly hostTools: RuntimeHostToolService;
159
+ }) => Promise<RuntimeExecutionAuthorization | undefined>;
160
+
161
+ /** Display classification only; never authority for process control. */
162
+ type RuntimeDaemonClientType = 'app' | 'cli' | 'diagnostic' | 'automation' | 'unknown';
163
+ interface RuntimeClientInfo {
164
+ readonly name: string;
165
+ /** Stable host-generated identity used only after daemon authentication. */
166
+ readonly instanceId?: string;
167
+ /** Stable host-generated secret; persist in OS keychain to resume client-owned leases. */
168
+ readonly instanceSecret?: string;
169
+ readonly title?: string;
170
+ readonly version?: string;
171
+ /** Display-only classification; never use it for authorization or process control. */
172
+ readonly clientType?: RuntimeDaemonClientType;
173
+ }
174
+
175
+ export type { KodaXClientExecutionRequest as K, RuntimeClientInfo as R, KodaXClientHostAuthorization as a, RuntimeCredentialBinding as b, RuntimeCredentialBroker as c, RuntimeCredentialLease as d, RuntimeCredentialRequest as e, RuntimeCredentialService as f, RuntimeDaemonClientType as g, RuntimeExecutionAuthorization as h, RuntimeHostToolDescriptor as i, RuntimeHostToolHandler as j, RuntimeHostToolInvocation as k, RuntimeHostToolInvocationStatus as l, RuntimeHostToolLease as m, RuntimeHostToolResult as n, RuntimeHostToolService as o, RuntimeScopedCredentialBroker as p, RuntimeScopedCredentialPurpose as q, RuntimeScopedCredentialRequest as r, RuntimeScopedCredentialTarget as s };