@kodax-ai/kodax 0.7.62 → 0.7.66

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 (81) hide show
  1. package/CHANGELOG.md +2300 -2145
  2. package/README.md +81 -9
  3. package/README_CN.md +54 -5
  4. package/dist/chunks/{agent-4ZMCIEGD.js → agent-KER4WDNO.js} +1 -1
  5. package/dist/chunks/argument-completer-HK3MHA3K.js +2 -0
  6. package/dist/chunks/{chunk-ARUWXX25.js → chunk-35P7QL2Q.js} +1 -1
  7. package/dist/chunks/chunk-3HKBBY74.js +339 -0
  8. package/dist/chunks/chunk-AKBH2EEE.js +8 -0
  9. package/dist/chunks/{chunk-OGRJQGKO.js → chunk-ALS32RNZ.js} +1 -1
  10. package/dist/chunks/chunk-MHRN2LQV.js +328 -0
  11. package/dist/chunks/{chunk-JILSZHCQ.js → chunk-NBQW7PNZ.js} +2 -2
  12. package/dist/chunks/{chunk-S4GVQO3W.js → chunk-O7N22GJ3.js} +1 -1
  13. package/dist/chunks/chunk-ONUPGMER.js +2 -0
  14. package/dist/chunks/{chunk-ZL5CEANW.js → chunk-PZTG2C33.js} +1 -1
  15. package/dist/chunks/{chunk-AY3BLB4Q.js → chunk-QAQ2HNXD.js} +112 -112
  16. package/dist/chunks/{chunk-6OZ5KWG3.js → chunk-QJJKMNZF.js} +1 -1
  17. package/dist/chunks/chunk-QJVZZSEO.js +56 -0
  18. package/dist/chunks/chunk-TLJGOKBT.js +729 -0
  19. package/dist/chunks/{chunk-6HTR3GHZ.js → chunk-VS4CDDEF.js} +245 -245
  20. package/dist/chunks/chunk-WBBEJIAY.js +306 -0
  21. package/dist/chunks/{chunk-HO6P6CPU.js → chunk-WMIZCY2J.js} +1 -1
  22. package/dist/chunks/{chunk-UA744TZM.js → chunk-YRBNXFHY.js} +1 -1
  23. package/dist/chunks/compaction-config-7GMUFNPB.js +2 -0
  24. package/dist/chunks/{construction-bootstrap-4ZNFZFX2.js → construction-bootstrap-3XDS2D5K.js} +1 -1
  25. package/dist/chunks/{devtools-4CRULTR2.js → devtools-CD6KSIHE.js} +1 -1
  26. package/dist/chunks/{devtools-YINBSZC7.js → devtools-XR5F2C6T.js} +1 -1
  27. package/dist/chunks/{dist-73L4OYPD.js → dist-4PXB7U22.js} +1 -1
  28. package/dist/chunks/dist-4YAYT2TO.js +2 -0
  29. package/dist/chunks/host-KG3456QP.js +2 -0
  30. package/dist/chunks/{paste-FDYM7SZX.js → paste-C33GZQV5.js} +1 -1
  31. package/dist/chunks/run-manager-6CAH3KTA.js +2 -0
  32. package/dist/chunks/utils-OT5ENFUL.js +2 -0
  33. package/dist/constructed-handler-worker.js +2 -0
  34. package/dist/index.d.ts +22 -11
  35. package/dist/index.js +6 -6
  36. package/dist/kodax_cli.js +1117 -1090
  37. package/dist/runtime-worker.js +2843 -0
  38. package/dist/sdk-agent.d.ts +29 -10
  39. package/dist/sdk-agent.js +1 -1
  40. package/dist/sdk-coding.d.ts +108 -1091
  41. package/dist/sdk-coding.js +1 -1
  42. package/dist/sdk-llm.js +1 -1
  43. package/dist/sdk-mcp.d.ts +2 -1
  44. package/dist/sdk-mcp.js +1 -1
  45. package/dist/sdk-media.js +1 -1
  46. package/dist/sdk-repl.d.ts +198 -184
  47. package/dist/sdk-repl.js +2 -2
  48. package/dist/sdk-runtime.d.ts +982 -0
  49. package/dist/sdk-runtime.js +2 -0
  50. package/dist/sdk-session.d.ts +4 -4
  51. package/dist/sdk-session.js +1 -1
  52. package/dist/sdk-skills.js +1 -1
  53. package/dist/semantic-worker.js +191 -10
  54. package/dist/types-chunks/{bash-prefix-extractor.d-Do_TCAmA.d.ts → bash-prefix-extractor.d-BjkITAva.d.ts} +266 -4
  55. package/dist/types-chunks/{run-manager.d-CYY3pZeJ.d.ts → capsule.d-hVhPNkHd.d.ts} +9 -107
  56. package/dist/types-chunks/commands.d-C3B1TdGM.d.ts +213 -0
  57. package/dist/types-chunks/{types.d-DFf4Sfys.d.ts → guardrail.d-C_Siraua.d.ts} +3 -128
  58. package/dist/types-chunks/{guardrail.d-DRp0Lqvx.d.ts → guardrail.d-wk-s0psS.d.ts} +3 -3
  59. package/dist/types-chunks/{manager.d-DBD7SOTT.d.ts → manager.d-Zum9cGHU.d.ts} +3 -173
  60. package/dist/types-chunks/oauth-login.d-Bgb4rdLN.d.ts +174 -0
  61. package/dist/types-chunks/{process.d-DXkRD7hj.d.ts → process.d-CY2g03Mb.d.ts} +11 -4
  62. package/dist/types-chunks/public-api.d-jtREVfEq.d.ts +596 -0
  63. package/dist/types-chunks/run-manager.d-CFknOfo1.d.ts +91 -0
  64. package/dist/types-chunks/{sdk-session-BGGOC0cT.d.ts → sdk-session-CLqyfAmf.d.ts} +8 -304
  65. package/dist/types-chunks/types.d-BMLxKV69.d.ts +128 -0
  66. package/dist/types-chunks/types.d-CUN_bZU7.d.ts +975 -0
  67. package/dist/types-chunks/{utils.d-ChOEH3NF.d.ts → utils.d-C1rpoeDh.d.ts} +84 -72
  68. package/package.json +7 -1
  69. package/dist/chunks/argument-completer-5PWSKFKI.js +0 -2
  70. package/dist/chunks/chunk-2F4R7WM7.js +0 -52
  71. package/dist/chunks/chunk-3KD26NCI.js +0 -310
  72. package/dist/chunks/chunk-E2Q4RIOD.js +0 -731
  73. package/dist/chunks/chunk-S4ISEA6F.js +0 -341
  74. package/dist/chunks/chunk-V4WSBIXB.js +0 -2
  75. package/dist/chunks/chunk-WFE6FBQ2.js +0 -326
  76. package/dist/chunks/compaction-config-SP3REMFR.js +0 -2
  77. package/dist/chunks/dist-IKWRJW6J.js +0 -2
  78. package/dist/chunks/host-XL5CH7QP.js +0 -2
  79. package/dist/chunks/run-manager-UXIPDVVF.js +0 -2
  80. package/dist/chunks/utils-XKWEVPE3.js +0 -2
  81. package/dist/types-chunks/storage.d-C3umBC4g.d.ts +0 -280
@@ -0,0 +1,213 @@
1
+ import { h as SessionStorage$1, f as PermissionMode } from './public-api.d-jtREVfEq.js';
2
+ import { X as KodaXOptions, a5 as KodaXResult } from './bash-prefix-extractor.d-BjkITAva.js';
3
+ import { m as RuntimeSurfaceStatus, b as CommandDefinition, e as CommandSource, c as CommandInfo, C as Command$1, I as InteractiveContext, a as CommandCallbacks, g as CurrentConfig, d as CommandInvocationRequest, f as CommandWorkflowInvocationRequest } from './utils.d-C1rpoeDh.js';
4
+ import { am as KodaXSessionStorage, aa as KodaXSessionData } from './process.d-CY2g03Mb.js';
5
+
6
+ /**
7
+ * InkREPL - Ink-based REPL Adapter
8
+ *
9
+ * Bridges Ink UI components with existing KodaX command processing logic.
10
+ * Replaces the Node.js readline-based input with Ink's React components.
11
+ *
12
+ * Architecture based on Gemini CLI:
13
+ * - Uses UIStateContext for global state
14
+ * - Uses KeypressContext for priority-based keyboard handling
15
+ * - Uses StreamingContext for streaming response management
16
+ */
17
+
18
+ interface InkRuntimeRunnerInput {
19
+ readonly options: KodaXOptions;
20
+ readonly prompt: string;
21
+ readonly sessionId: string;
22
+ readonly permissionMode: PermissionMode;
23
+ }
24
+ type InkRuntimeRunner = (input: InkRuntimeRunnerInput) => Promise<KodaXResult>;
25
+ type InkRuntimeStatusProvider = () => Promise<RuntimeSurfaceStatus | undefined>;
26
+ interface InkREPLOptions extends KodaXOptions {
27
+ storage?: SessionStorage$1;
28
+ hardExitOnClose?: boolean;
29
+ runtimeRunner?: InkRuntimeRunner;
30
+ getRuntimeStatus?: InkRuntimeStatusProvider;
31
+ }
32
+ /**
33
+ * Run Ink-based interactive mode
34
+ */
35
+ declare function runInkInteractiveMode(options: InkREPLOptions): Promise<void>;
36
+
37
+ interface SessionStorage extends KodaXSessionStorage {
38
+ list(gitRoot?: string): Promise<Array<{
39
+ id: string;
40
+ title: string;
41
+ msgCount: number;
42
+ tag?: string;
43
+ runtimeInfo?: KodaXSessionData['runtimeInfo'];
44
+ }>>;
45
+ }
46
+ interface ReplRuntimeRunnerInput {
47
+ readonly options: KodaXOptions;
48
+ readonly prompt: string;
49
+ readonly sessionId: string;
50
+ readonly permissionMode: PermissionMode;
51
+ }
52
+ type ReplRuntimeRunner = (input: ReplRuntimeRunnerInput) => Promise<KodaXResult>;
53
+ type ReplRuntimeStatusProvider = () => Promise<RuntimeSurfaceStatus | undefined>;
54
+ interface RepLOptions extends KodaXOptions {
55
+ storage?: SessionStorage;
56
+ runtimeRunner?: ReplRuntimeRunner;
57
+ getRuntimeStatus?: ReplRuntimeStatusProvider;
58
+ }
59
+ declare function runInteractiveMode(options: RepLOptions): Promise<void>;
60
+ declare function processSpecialSyntax(input: string): Promise<string>;
61
+
62
+ /**
63
+ * Command Registry - Dynamic command registration system
64
+ * 命令注册表 - 动态命令注册系统
65
+ *
66
+ * Provides centralized command management with source tracking,
67
+ * supporting dynamic registration, lookup, and listing of commands.
68
+ */
69
+
70
+ /**
71
+ * CommandRegistry - Centralized command management
72
+ * 命令注册表 - 集中式命令管理
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const registry = new CommandRegistry();
77
+ *
78
+ * // Register a command
79
+ * registry.register({
80
+ * name: 'copy',
81
+ * description: 'Copy last message to clipboard',
82
+ * source: 'builtin',
83
+ * handler: async (args, context, callbacks, config) => {
84
+ * // Implementation
85
+ * }
86
+ * });
87
+ *
88
+ * // Get a command
89
+ * const cmd = registry.get('copy');
90
+ *
91
+ * // List all commands
92
+ * const allCommands = registry.getAll();
93
+ *
94
+ * // List builtin commands only
95
+ * const builtinCommands = registry.getBySource('builtin');
96
+ * ```
97
+ */
98
+ declare class CommandRegistry {
99
+ /**
100
+ * Internal command storage
101
+ * 内部命令存储
102
+ */
103
+ private commands;
104
+ /**
105
+ * Alias to command name mapping
106
+ * 别名到命令名称的映射
107
+ */
108
+ private aliases;
109
+ /**
110
+ * Register a command
111
+ * 注册命令
112
+ *
113
+ * @param def - Command definition
114
+ * @throws Error if command with same name already exists
115
+ */
116
+ register(def: CommandDefinition): void;
117
+ /**
118
+ * Unregister a command
119
+ * 注销命令
120
+ *
121
+ * @param name - Command name or alias
122
+ * @returns true if command was unregistered, false if not found
123
+ */
124
+ unregister(name: string): boolean;
125
+ /**
126
+ * Get a command by name or alias
127
+ * 通过名称或别名获取命令
128
+ *
129
+ * @param name - Command name or alias
130
+ * @returns Command definition or undefined if not found
131
+ */
132
+ get(name: string): CommandDefinition | undefined;
133
+ /**
134
+ * Check if a command exists
135
+ * 检查命令是否存在
136
+ *
137
+ * @param name - Command name or alias
138
+ * @returns true if command exists, false otherwise
139
+ */
140
+ has(name: string): boolean;
141
+ /**
142
+ * Get all commands with optional source filter
143
+ * 获取所有命令,可选按来源过滤
144
+ *
145
+ * @param source - Optional source filter
146
+ * @returns Array of command information
147
+ */
148
+ getAll(source?: CommandSource): CommandInfo[];
149
+ /**
150
+ * Get commands by source
151
+ * 按来源获取命令
152
+ *
153
+ * @param source - Command source
154
+ * @returns Array of command information
155
+ */
156
+ getBySource(source: CommandSource): CommandInfo[];
157
+ /**
158
+ * Get all command names
159
+ * 获取所有命令名称
160
+ *
161
+ * @returns Array of command names
162
+ */
163
+ getNames(): string[];
164
+ /**
165
+ * Clear all commands
166
+ * 清空所有命令
167
+ */
168
+ clear(): void;
169
+ /**
170
+ * Get command count
171
+ * 获取命令数量
172
+ *
173
+ * @returns Number of registered commands
174
+ */
175
+ get size(): number;
176
+ /**
177
+ * Get alias count
178
+ * 获取别名数量
179
+ *
180
+ * @returns Number of registered aliases
181
+ */
182
+ get aliasCount(): number;
183
+ }
184
+
185
+ /**
186
+ * KodaX Interactive Command System
187
+ */
188
+
189
+ type Command = Command$1;
190
+ declare const BUILTIN_COMMANDS: Command[];
191
+ declare function getCommandRegistry(projectRoot?: string): CommandRegistry;
192
+ declare function parseCommand(input: string): {
193
+ command: string;
194
+ args: string[];
195
+ skillInvocation?: {
196
+ name: string;
197
+ };
198
+ } | null;
199
+ type CommandResult = boolean | {
200
+ skillContent?: string;
201
+ invocation?: CommandInvocationRequest;
202
+ workflow?: CommandWorkflowInvocationRequest;
203
+ };
204
+ declare function executeCommand(parsed: {
205
+ command: string;
206
+ args: string[];
207
+ skillInvocation?: {
208
+ name: string;
209
+ };
210
+ }, context: InteractiveContext, callbacks: CommandCallbacks, currentConfig: CurrentConfig): Promise<CommandResult>;
211
+
212
+ export { BUILTIN_COMMANDS as B, executeCommand as g, getCommandRegistry as h, processSpecialSyntax as i, runInteractiveMode as j, parseCommand as p, runInkInteractiveMode as r };
213
+ export type { Command as C, InkREPLOptions as I, RepLOptions as R, InkRuntimeRunner as a, InkRuntimeRunnerInput as b, InkRuntimeStatusProvider as c, ReplRuntimeRunner as d, ReplRuntimeRunnerInput as e, ReplRuntimeStatusProvider as f };
@@ -1,5 +1,4 @@
1
- import { J as Guardrail, bp as RunnerToolCall, f as Agent, h as AgentMessage, bs as RunnerToolResult, bB as Span, a2 as KodaXInputArtifact } from './process.d-DXkRD7hj.js';
2
- import { R as KodaXTaskResultMetadata } from './types.d-Bp4Lm1jv.js';
1
+ import { J as Guardrail, bq as RunnerToolCall, f as Agent, h as AgentMessage, bt as RunnerToolResult, bC as Span } from './process.d-CY2g03Mb.js';
3
2
 
4
3
  /**
5
4
  * Guardrail Runtime — FEATURE_085 (v0.7.26).
@@ -152,129 +151,5 @@ declare function runToolBeforeGuardrails(call: RunnerToolCall, guardrails: reado
152
151
  */
153
152
  declare function runToolAfterGuardrails(call: RunnerToolCall, result: RunnerToolResult, guardrails: readonly ToolGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<RunnerToolResult>;
154
153
 
155
- /**
156
- * @kodax-ai/agent/messaging Message queue types
157
- *
158
- * FEATURE_115 (v0.7.36): agentId-scoped 2-tier priority queue infrastructure.
159
- *
160
- * Per ADR-021: messaging is a generic agent-platform primitive (not coding-
161
- * specific). Downstream consumers:
162
- * - @kodax-ai/coding runner-driven mid-turn drain
163
- * - @kodax-ai/repl InkREPL ESC soft-pause + text injection (FEATURE_111 absorbed)
164
- * - subagent task-notification routing (FEATURE_155 idle-yield wakeup)
165
- *
166
- * Phase 0.6 study (`c:/tmp/claude-code-actual-usage.md`): Claude Code's
167
- * `'now'` priority has zero production usage; KodaX simplifies to 2 tiers.
168
- */
169
-
170
- type MessagePriority = 'user' | 'background';
171
- type MessageMode = 'prompt' | 'task-notification' | 'system-reminder';
172
- type QueuedInputArtifact = KodaXInputArtifact;
173
- interface QueuedMessage {
174
- /** Stable id for tracing / dedup. Format: `msg-<sequence>`. */
175
- readonly id: string;
176
- readonly priority: MessagePriority;
177
- /**
178
- * Routing key:
179
- * undefined = main thread / coordinator agent
180
- * 'agent-id-XYZ' = subagent / specific consumer
181
- *
182
- * Drain consumers MUST filter by agentId match — undefined matches only
183
- * undefined-agentId messages, not "any agent".
184
- */
185
- readonly agentId?: string;
186
- readonly mode: MessageMode;
187
- readonly content: string;
188
- readonly inputArtifacts?: readonly QueuedInputArtifact[];
189
- readonly taskResult?: KodaXTaskResultMetadata;
190
- /** Wall-clock timestamp (`Date.now()`) for tracing only — not used for ordering. */
191
- readonly enqueuedAt: number;
192
- }
193
- interface DequeueFilter {
194
- /**
195
- * Only return messages with this agentId.
196
- * undefined matches messages with no agentId (main-thread messages only).
197
- */
198
- readonly agentId?: string;
199
- /**
200
- * Highest priority level included in the drain.
201
- * 'user' → only user priority drained, background stays queued
202
- * 'background' → both user + background drained (Sleep-gated case)
203
- */
204
- readonly maxPriority: MessagePriority;
205
- /**
206
- * Optional cap on number of messages drained in this call.
207
- * Defaults to unlimited (drains all matching).
208
- */
209
- readonly limit?: number;
210
- /**
211
- * FEATURE_159 (v0.7.40) — optional mode filter. Lets REPL split the
212
- * single queue into mode-typed views (e.g. `mode:'prompt'` for user
213
- * input vs `mode:'task-notification'` for child completion banners)
214
- * without separate queues. When omitted, all modes match.
215
- */
216
- readonly mode?: MessageMode;
217
- /**
218
- * FEATURE_159 (v0.7.40) — optional precise-id filter. Single-message
219
- * targeted removal — drives Esc-pop-this-uuid in REPL. When set, all
220
- * other filters still apply (agentId / priority / mode mismatches still
221
- * skip the message), so callers can't accidentally remove a message
222
- * outside their scope.
223
- */
224
- readonly id?: string;
225
- /**
226
- * FEATURE_159 (v0.7.40) — optional escape-hatch predicate, AND-ed with
227
- * the structured filters. Lets SDK consumers express conditions the
228
- * typed fields don't cover (e.g. timestamp ranges, content-match) without
229
- * forcing every new use case to extend `DequeueFilter`. KodaX-internal
230
- * code should prefer the typed fields for readability; this is the
231
- * "data-driven main path + predicate escape" pattern.
232
- *
233
- * Evaluated AFTER the typed filters succeed — so a `predicate` that
234
- * inspects `message.content` never runs on messages outside the
235
- * caller's `agentId` / `mode` / `id` scope.
236
- */
237
- readonly predicate?: (message: QueuedMessage) => boolean;
238
- }
239
- /**
240
- * FEATURE_159 (v0.7.40) — structured queue event emitted to subscribers.
241
- *
242
- * Replaces the prior `() => void` bare-notify signal. Carries the kind +
243
- * affected messages so SDK observability consumers (logging, tracing,
244
- * metrics) can react per-event without re-diffing snapshots.
245
- *
246
- * Event granularity rules:
247
- * - `enqueued` fires ONCE per `enqueue()` call (always 1 message).
248
- * - `dequeued` fires ONCE per `dequeue()` call that removed ≥1 message,
249
- * carrying ALL drained messages in priority+FIFO order. No-op drains
250
- * (filter matched nothing) fire no event — quiet by design so the
251
- * `waitForWakeEvent` 100ms poll doesn't spam idle subscribers.
252
- * - `cleared` fires ONCE per `clear()` call that removed ≥1 message,
253
- * carrying the pre-clear messages. Empty-queue clear fires nothing.
254
- *
255
- * The `useSyncExternalStore` React hook ignores the event payload (it
256
- * only needs the change signal); SDK / tracer consumers read the event.
257
- */
258
- type QueueEvent = {
259
- readonly kind: 'enqueued';
260
- readonly message: QueuedMessage;
261
- } | {
262
- readonly kind: 'dequeued';
263
- readonly messages: readonly QueuedMessage[];
264
- } | {
265
- readonly kind: 'cleared';
266
- readonly messages: readonly QueuedMessage[];
267
- };
268
- /** FEATURE_159 — `MessageQueue.subscribe` listener signature. */
269
- type QueueEventListener = (event: QueueEvent) => void;
270
- interface EnqueueInput {
271
- readonly priority: MessagePriority;
272
- readonly mode: MessageMode;
273
- readonly content: string;
274
- readonly agentId?: string;
275
- readonly inputArtifacts?: readonly QueuedInputArtifact[];
276
- readonly taskResult?: KodaXTaskResultMetadata;
277
- }
278
-
279
- export { GuardrailBlockedError as G, GuardrailEscalateError as b, collectGuardrails as h, runOutputGuardrails as i, runToolAfterGuardrails as j, runToolBeforeGuardrails as k, runInputGuardrails as r };
280
- export type { DequeueFilter as D, EnqueueInput as E, InputGuardrail as I, MessageMode as M, OutputGuardrail as O, QueueEventListener as Q, ToolBeforeOutcome as T, GuardrailContext as a, GuardrailVerdict as c, MessagePriority as d, QueuedInputArtifact as e, QueuedMessage as f, ToolGuardrail as g };
154
+ export { GuardrailBlockedError as G, GuardrailEscalateError as b, collectGuardrails as e, runOutputGuardrails as f, runToolAfterGuardrails as g, runToolBeforeGuardrails as h, runInputGuardrails as r };
155
+ export type { InputGuardrail as I, OutputGuardrail as O, ToolBeforeOutcome as T, GuardrailContext as a, GuardrailVerdict as c, ToolGuardrail as d };
@@ -1,8 +1,8 @@
1
- import { M as McpConnectMode, a as McpServerConfig, b as McpServersConfig, c as McpTransportKind } from './config.d-CJy1WENT.js';
1
+ import { b as McpServersConfig, M as McpConnectMode, a as McpServerConfig, c as McpTransportKind } from './config.d-CJy1WENT.js';
2
2
  import { K as KodaXBaseProvider } from './base.d-DalIRhbb.js';
3
3
  import { a as CostTracker } from './cost-tracker.d-CBLk1fiD.js';
4
- import { bp as RunnerToolCall } from './process.d-DXkRD7hj.js';
5
- import { g as ToolGuardrail } from './types.d-DFf4Sfys.js';
4
+ import { bq as RunnerToolCall } from './process.d-CY2g03Mb.js';
5
+ import { d as ToolGuardrail } from './guardrail.d-C_Siraua.js';
6
6
 
7
7
  /**
8
8
  * FEATURE_200 Phase F (v0.7.45) — MCP domain types extracted from types.ts.
@@ -1,5 +1,5 @@
1
- import { a as McpServerConfig, b as McpServersConfig, M as McpConnectMode } from './config.d-CJy1WENT.js';
2
1
  import { a as CapabilityProvider, C as CapabilityKind, b as CapabilityResult } from './capability.d-3C62G8Eq.js';
2
+ import { a as McpServerConfig, b as McpServersConfig, M as McpConnectMode } from './config.d-CJy1WENT.js';
3
3
 
4
4
  type McpCapabilityKind = 'tool' | 'resource' | 'prompt';
5
5
  type McpCapabilityRisk = 'read' | 'write' | 'network' | 'exec';
@@ -348,176 +348,6 @@ declare class McpCapabilityProvider implements CapabilityProvider {
348
348
  private requireRuntime;
349
349
  }
350
350
 
351
- interface McpTransportEvents {
352
- /** Called with a complete JSON-RPC message (raw JSON string). */
353
- onMessage(raw: string): void;
354
- onError(error: Error): void;
355
- onClose(reason: string): void;
356
- }
357
- interface McpTransport {
358
- open(events: McpTransportEvents): Promise<void>;
359
- /** Send a JSON string. The transport handles framing. */
360
- send(json: string): Promise<void>;
361
- setProtocolVersion?(version: string | undefined): void;
362
- close(): Promise<void>;
363
- readonly connected: boolean;
364
- /** Effective transport after auto-detection (diagnostics only). */
365
- readonly resolvedTransport?: string;
366
- }
367
- declare class McpExpiredSessionError extends Error {
368
- constructor();
369
- }
370
- /**
371
- * FEATURE_222 — the server demanded OAuth (401) or a stronger scope (403). It
372
- * carries the `WWW-Authenticate` header so the connect flow can discover the
373
- * authorization server (RFC 9728 pointer) or read the step-up scope.
374
- */
375
- declare class McpAuthRequiredError extends Error {
376
- readonly status: number;
377
- readonly wwwAuthenticate?: string | undefined;
378
- constructor(status: number, wwwAuthenticate?: string | undefined);
379
- }
380
- type StdioFraming = 'content-length' | 'ndjson';
381
- interface McpTransportOptions {
382
- stdioFraming?: StdioFraming;
383
- httpResolvedTransport?: 'streamable-http' | 'sse';
384
- }
385
- declare function createMcpTransport(config: McpServerConfig, options?: McpTransportOptions): McpTransport;
386
-
387
- /**
388
- * FEATURE_222 — MCP OAuth discovery (server→authorization-server resolution).
389
- *
390
- * The modern MCP auth flow does NOT require the user to hand-configure
391
- * authorization/token endpoints. Instead the client discovers them at runtime:
392
- *
393
- * 401 WWW-Authenticate (resource_metadata=...) [RFC 9728 pointer]
394
- * → GET /.well-known/oauth-protected-resource [RFC 9728 PRM]
395
- * → authorization_servers[0]
396
- * → GET /.well-known/oauth-authorization-server [RFC 8414]
397
- * (fallback /.well-known/openid-configuration) [OIDC]
398
- * → authorization_endpoint / token_endpoint / registration_endpoint
399
- *
400
- * This module is the pure-HTTP discovery layer (no PKCE, no browser, no token
401
- * storage — those compose on top). The path-aware fallback ordering mirrors
402
- * Claude Code's MCP client so KodaX resolves the same servers it does.
403
- */
404
- interface WwwAuthenticateChallenge {
405
- readonly scheme: string;
406
- readonly params: Record<string, string>;
407
- }
408
- /** The RFC 9728 `resource_metadata` URL a 401 challenge points at, if any. */
409
- declare function extractResourceMetadataUrl(header: string | undefined): string | undefined;
410
- /**
411
- * For a 403 `error="insufficient_scope"` challenge, the `scope` the server now
412
- * requires (space-separated). Undefined when the challenge is not a step-up.
413
- */
414
- declare function extractInsufficientScope(header: string | undefined): string | undefined;
415
- interface ProtectedResourceMetadata {
416
- readonly authorizationServers: string[];
417
- readonly resource?: string;
418
- readonly scopesSupported?: string[];
419
- }
420
- /**
421
- * Discover the protected-resource metadata for an MCP server URL. Prefers the
422
- * `resource_metadata` URL from the 401 challenge; otherwise probes the
423
- * path-specific then root `/.well-known/oauth-protected-resource`.
424
- */
425
- declare function discoverProtectedResourceMetadata(options: {
426
- serverUrl: string;
427
- resourceMetadataUrl?: string;
428
- fetchFn?: typeof fetch;
429
- }): Promise<ProtectedResourceMetadata | undefined>;
430
- interface AuthorizationServerMetadata {
431
- readonly issuer?: string;
432
- readonly authorizationEndpoint: string;
433
- readonly tokenEndpoint: string;
434
- readonly registrationEndpoint?: string;
435
- readonly scopesSupported?: string[];
436
- readonly codeChallengeMethodsSupported?: string[];
437
- }
438
- /** Discover an authorization server's endpoints. The first candidate returning
439
- * both an authorization + token endpoint wins. */
440
- declare function discoverAuthorizationServerMetadata(options: {
441
- authorizationServerUrl: string;
442
- fetchFn?: typeof fetch;
443
- }): Promise<AuthorizationServerMetadata | undefined>;
444
- /**
445
- * End-to-end endpoint discovery: PRM → first authorization server → AS metadata.
446
- * Returns the resolved endpoints plus the resource indicator (RFC 8707) and the
447
- * scopes the resource advertises. Undefined when discovery fails at any step.
448
- */
449
- interface DiscoveredOAuthEndpoints extends AuthorizationServerMetadata {
450
- /** RFC 8707 resource indicator (the MCP server's canonical URL). */
451
- readonly resource?: string;
452
- /** Scopes from the protected-resource document, when the AS omits them. */
453
- readonly resourceScopesSupported?: string[];
454
- }
455
- declare function discoverOAuthEndpoints(options: {
456
- serverUrl: string;
457
- resourceMetadataUrl?: string;
458
- fetchFn?: typeof fetch;
459
- }): Promise<DiscoveredOAuthEndpoints | undefined>;
460
-
461
- interface OAuthToken {
462
- readonly accessToken: string;
463
- readonly refreshToken?: string;
464
- readonly expiresAt?: number;
465
- readonly tokenType?: string;
466
- readonly scope?: string;
467
- }
468
-
469
- /** A dynamically-registered (or pre-configured) OAuth client. */
470
- interface OAuthClientInfo {
471
- readonly clientId: string;
472
- readonly clientSecret?: string;
473
- }
474
- /**
475
- * RFC 7591 Dynamic Client Registration. Registers a public client (PKCE, no
476
- * secret) for the loopback redirect and returns the issued client_id.
477
- */
478
- declare function registerOAuthClient(options: {
479
- registrationEndpoint: string;
480
- redirectUri: string;
481
- clientName: string;
482
- scope?: string;
483
- fetchFn?: typeof fetch;
484
- }): Promise<OAuthClientInfo>;
485
- /**
486
- * The host's consent gate for a login. Receives the authorization URL and must
487
- * return true to proceed (the user will open it in their browser). Returning
488
- * false aborts the login. KodaX never auto-opens the URL.
489
- */
490
- type OAuthLoginConsent = (authorizationUrl: string) => Promise<boolean>;
491
- interface PerformOAuthLoginOptions {
492
- serverId: string;
493
- /** The MCP server URL (resource) we are authenticating to. */
494
- serverUrl: string;
495
- /** resource_metadata URL from a 401 challenge, if one was seen. */
496
- resourceMetadataUrl?: string;
497
- /** A pre-configured client_id (skips dynamic registration). */
498
- configuredClientId?: string;
499
- /** Pre-configured scopes (override discovery). */
500
- configuredScopes?: readonly string[];
501
- /** For an insufficient_scope step-up: the elevated scope to request. */
502
- stepUpScope?: string;
503
- /** Host consent gate (anti-phishing) — receives the authorization URL. */
504
- consent: OAuthLoginConsent;
505
- /** Loopback callback port (defaults to {@link DEFAULT_OAUTH_REDIRECT_PORT}). */
506
- redirectPort?: number;
507
- fetchFn?: typeof fetch;
508
- }
509
- /**
510
- * Run the full interactive login and persist the resulting token. Returns the
511
- * token, or undefined when discovery fails, no client can be obtained, or the
512
- * user declines consent. Throws only on a hard protocol error (bad exchange).
513
- */
514
- declare function performOAuthLogin(options: PerformOAuthLoginOptions): Promise<OAuthToken | undefined>;
515
- /**
516
- * Return a still-valid cached token for a server, or undefined. (Discovery-based
517
- * refresh on expiry is driven by the connect flow, which knows the endpoints.)
518
- */
519
- declare function loadValidToken(serverId: string): Promise<OAuthToken | undefined>;
520
-
521
351
  /**
522
352
  * McpManager — v0.7.42 (extends FEATURE_186 MCP popout surface).
523
353
  *
@@ -697,5 +527,5 @@ declare class McpManager {
697
527
  */
698
528
  declare function createMcpManager(servers: McpServersConfig | undefined, options?: McpProviderOptions): McpManager;
699
529
 
700
- export { buildInitializeCapabilities as C, createMcpCapabilityId as E, createMcpManager as F, createMcpTransport as G, defaultMcpCacheDir as H, discoverAuthorizationServerMetadata as I, discoverOAuthEndpoints as J, discoverProtectedResourceMetadata as K, extractInsufficientScope as L, McpAuthRequiredError as M, extractResourceMetadataUrl as N, getMcpCachePaths as Q, loadValidToken as R, normalizeMcpCapabilityId as S, parseMcpCapabilityId as T, performOAuthLogin as U, registerOAuthClient as V, searchMcpCatalog as X, McpCapabilityProvider as c, McpExpiredSessionError as h, McpManager as j, McpServerRuntime as s };
701
- export type { AuthorizationServerMetadata as A, ProtectedResourceMetadata as B, DiscoveredOAuthEndpoints as D, OAuthClientInfo as O, PerformOAuthLoginOptions as P, WwwAuthenticateChallenge as W, McpCapabilityDescriptor as a, McpCapabilityKind as b, McpCapabilityRisk as d, McpCatalogItem as e, McpElicitRequest as f, McpElicitResult as g, McpIcon as i, McpProviderOptions as k, McpReverseCapabilities as l, McpRoot as m, McpSamplingRequest as n, McpSamplingResult as o, McpServerCatalog as p, McpServerCatalogSnapshot as q, McpServerLogs as r, McpServerRuntimeDiagnostics as t, McpServerStatus as u, McpServerToolList as v, McpToolTaskSupport as w, McpTransport as x, McpTransportEvents as y, OAuthLoginConsent as z };
530
+ export { normalizeMcpCapabilityId as A, parseMcpCapabilityId as B, searchMcpCatalog as C, McpCapabilityProvider as b, McpManager as h, McpServerRuntime as q, buildInitializeCapabilities as v, createMcpCapabilityId as w, createMcpManager as x, defaultMcpCacheDir as y, getMcpCachePaths as z };
531
+ export type { McpCapabilityDescriptor as M, McpCapabilityKind as a, McpCapabilityRisk as c, McpCatalogItem as d, McpElicitRequest as e, McpElicitResult as f, McpIcon as g, McpProviderOptions as i, McpReverseCapabilities as j, McpRoot as k, McpSamplingRequest as l, McpSamplingResult as m, McpServerCatalog as n, McpServerCatalogSnapshot as o, McpServerLogs as p, McpServerRuntimeDiagnostics as r, McpServerStatus as s, McpServerToolList as t, McpToolTaskSupport as u };