@kodax-ai/kodax 0.7.49 → 0.7.51
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 +1800 -1741
- package/README.md +1215 -1210
- package/README_CN.md +636 -632
- package/dist/chunks/agent-EFA7BSE7.js +2 -0
- package/dist/chunks/argument-completer-MAJVHSE7.js +2 -0
- package/dist/chunks/{chunk-TYZAH3YP.js → chunk-CCZMQE3Q.js} +1 -1
- package/dist/chunks/chunk-E3HENKTX.js +420 -0
- package/dist/chunks/chunk-FAIGYAEX.js +301 -0
- package/dist/chunks/chunk-HMATTIU6.js +574 -0
- package/dist/chunks/{chunk-YW4RQV7U.js → chunk-JJTUBNQX.js} +1 -1
- package/dist/chunks/chunk-ODVA5VTE.js +492 -0
- package/dist/chunks/chunk-PEWH3AAL.js +31 -0
- package/dist/chunks/chunk-WQTVG2T5.js +648 -0
- package/dist/chunks/{compaction-config-BQBYOWX2.js → compaction-config-UBPCNGC2.js} +1 -1
- package/dist/chunks/{construction-bootstrap-5TFGMSWQ.js → construction-bootstrap-WY5MDXRX.js} +1 -1
- package/dist/chunks/{dist-BL7IBQHD.js → dist-B73FQEAA.js} +1 -1
- package/dist/chunks/dist-BTWS2ENP.js +2 -0
- package/dist/chunks/utils-HVOJRR5C.js +2 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.js +4 -4
- package/dist/kodax_cli.js +1091 -984
- package/dist/provider-capabilities.json +2 -0
- package/dist/sdk-agent.d.ts +25 -11
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +160 -34
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.d.ts +3 -5
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-repl.d.ts +38 -727
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-session.d.ts +8 -200
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/types-chunks/{types.d-rPRl2LSB.d.ts → base.d-GZ6jvICS.d.ts} +270 -3
- package/dist/types-chunks/{bash-prefix-extractor.d-CI_xcPhn.d.ts → bash-prefix-extractor.d-DTOiDMlG.d.ts} +84 -537
- package/dist/types-chunks/{capsule.d-DaPuhyyK.d.ts → capsule.d-CXGdLGAn.d.ts} +6 -3
- package/dist/types-chunks/guardrail.d-D47yu9AO.d.ts +518 -0
- package/dist/types-chunks/{types.d-BR9oNWup.d.ts → process.d-B8kEBnQD.d.ts} +487 -275
- package/dist/types-chunks/{resolver.d-B_wm409c.d.ts → resolver.d-D75XFRH2.d.ts} +23 -6
- package/dist/types-chunks/sdk-session-BKQJN9oH.d.ts +977 -0
- package/dist/types-chunks/{storage.d-J2GqOgaX.d.ts → storage.d-BN1xIn8R.d.ts} +78 -3
- package/dist/types-chunks/types.d-DQ_hdN70.d.ts +273 -0
- package/dist/types-chunks/{utils.d-BJ_-y8gC.d.ts → utils.d-ZfRDo-kX.d.ts} +8 -80
- package/package.json +2 -2
- package/dist/chunks/argument-completer-GDG5OHN7.js +0 -2
- package/dist/chunks/chunk-67SWUEEN.js +0 -1035
- package/dist/chunks/chunk-C5PKZX5Z.js +0 -291
- package/dist/chunks/chunk-ISGHUKRY.js +0 -428
- package/dist/chunks/chunk-JTHMWRXM.js +0 -566
- package/dist/chunks/chunk-YACQ4OST.js +0 -31
- package/dist/chunks/dist-D7HOETCE.js +0 -2
- package/dist/chunks/utils-XWDT3W5X.js +0 -2
- package/dist/types-chunks/base.d-C4jYVjJh.d.ts +0 -270
- package/dist/types-chunks/types.d-BnjX2Gn4.d.ts +0 -297
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { X as KodaXTokenUsage, n as KodaXMessage, E as KodaXReasoningMode, k as KodaXHarnessProfile, S as KodaXTaskWorkIntent, I as KodaXReviewScale, O as KodaXTaskComplexity, a as KodaXAmaFanoutClass, Q as KodaXTaskRoutingDecision, R as KodaXTaskType, J as KodaXRiskLevel, i as KodaXExecutionMode, c as KodaXAmaProfile, d as KodaXAmaTactic, b as KodaXAmaFanoutPolicy } from './types.d-rPRl2LSB.js';
|
|
4
|
-
import { f as AgentMessage, aE as StopHookFn, C as ChildTaskRegistry, s as CompactionUpdate, m as AskUserQuestionOptions, k as AskUserMultiOptions, B as Guardrail, b1 as WorkflowIsolation, w as DiscoveredInstance, aI as TaskAbortRegistry, aj as RunnerToolCall, aN as ToolGuardrail } from './types.d-BR9oNWup.js';
|
|
1
|
+
import { U as KodaXGoalState, f as AgentMessage, b0 as StopHookFn, a4 as KodaXSessionLineage, a9 as KodaXSessionScope, aa as KodaXSessionStorage, W as KodaXJsonValue, C as ChildTaskRegistry, bl as WorkflowEventCorrelation, s as CompactionUpdate, bx as WorkflowProcessEvent, m as AskUserQuestionOptions, k as AskUserMultiOptions, y as Guardrail, bo as WorkflowIsolation, Y as KodaXSessionArtifactLedgerEntry, aN as SessionErrorMetadata, v as DiscoveredInstance, b4 as TaskAbortRegistry } from './process.d-B8kEBnQD.js';
|
|
2
|
+
import { _ as KodaXTokenUsage, o as KodaXMessage, G as KodaXReasoningMode, l as KodaXHarnessProfile, V as KodaXTaskWorkIntent, M as KodaXReviewScale, R as KodaXTaskComplexity, a as KodaXAmaFanoutClass, T as KodaXTaskRoutingDecision, U as KodaXTaskType, N as KodaXRiskLevel, j as KodaXExecutionMode, c as KodaXAmaProfile, d as KodaXAmaTactic, b as KodaXAmaFanoutPolicy, f as KodaXBaseProvider } from './base.d-GZ6jvICS.js';
|
|
5
3
|
import { Diagnostic, Position, Location, Hover, DocumentSymbol, SymbolInformation } from 'vscode-languageserver-protocol';
|
|
6
4
|
import { C as CapabilityKind, b as CapabilityResult } from './capability.d-3C62G8Eq.js';
|
|
7
|
-
import { K as KodaXBaseProvider } from './base.d-C4jYVjJh.js';
|
|
8
5
|
import { a as CostTracker } from './cost-tracker.d-wRtyEW9d.js';
|
|
9
6
|
|
|
10
7
|
/**
|
|
@@ -409,6 +406,32 @@ interface TodoStore {
|
|
|
409
406
|
reset(): void;
|
|
410
407
|
}
|
|
411
408
|
|
|
409
|
+
type WorkflowInvocationSource = 'natural-language' | 'command';
|
|
410
|
+
type WorkflowInvocationAction = 'none' | 'suggest' | 'auto-start';
|
|
411
|
+
type WorkflowInvocationTrigger = 'explicit' | 'complexity' | 'negated' | 'none';
|
|
412
|
+
type WorkflowStartOutcome = 'started' | 'declined' | 'cancelled' | 'failed';
|
|
413
|
+
interface WorkflowHostPolicy {
|
|
414
|
+
readonly autoStart?: 'off' | 'confirm' | 'on';
|
|
415
|
+
readonly maxAgents?: number;
|
|
416
|
+
readonly maxConcurrency?: number;
|
|
417
|
+
readonly tokenBudget?: number;
|
|
418
|
+
}
|
|
419
|
+
interface WorkflowInvocationPolicyInput {
|
|
420
|
+
readonly agentMode: KodaXAgentMode;
|
|
421
|
+
readonly source: WorkflowInvocationSource;
|
|
422
|
+
readonly input: string;
|
|
423
|
+
readonly hostPolicy?: WorkflowHostPolicy;
|
|
424
|
+
}
|
|
425
|
+
interface WorkflowInvocationPolicyDecision {
|
|
426
|
+
readonly action: WorkflowInvocationAction;
|
|
427
|
+
readonly trigger: WorkflowInvocationTrigger;
|
|
428
|
+
readonly reason: string;
|
|
429
|
+
}
|
|
430
|
+
declare function decideWorkflowInvocation(input: WorkflowInvocationPolicyInput): WorkflowInvocationPolicyDecision;
|
|
431
|
+
declare function workflowStartOutcomeConsumesTurn(input: {
|
|
432
|
+
readonly outcome: WorkflowStartOutcome;
|
|
433
|
+
}): boolean;
|
|
434
|
+
|
|
412
435
|
/**
|
|
413
436
|
* FEATURE_132 — language-server registry + discovery (cascade step ①).
|
|
414
437
|
*
|
|
@@ -1054,18 +1077,6 @@ interface ProviderResiliencePolicy extends ProviderResilienceConfig {
|
|
|
1054
1077
|
provider: string;
|
|
1055
1078
|
}
|
|
1056
1079
|
|
|
1057
|
-
/**
|
|
1058
|
-
* FEATURE_200 Phase F (v0.7.45) — MCP domain types extracted from types.ts.
|
|
1059
|
-
* Thin KodaX-facing aliases over the @kodax-ai/agent MCP types. Re-exported
|
|
1060
|
-
* from ../types.ts so all `../types` importers are unaffected.
|
|
1061
|
-
*/
|
|
1062
|
-
|
|
1063
|
-
type KodaXMcpTransport = McpTransportKind;
|
|
1064
|
-
type KodaXMcpConnectMode = McpConnectMode;
|
|
1065
|
-
type KodaXMcpServerConfig = McpServerConfig;
|
|
1066
|
-
/** Flat map of MCP server configs, keyed under `mcpServers` in config.json. */
|
|
1067
|
-
type KodaXMcpServersConfig = McpServersConfig;
|
|
1068
|
-
|
|
1069
1080
|
/**
|
|
1070
1081
|
* FEATURE_200 Phase F (v0.7.45) — Todo domain types extracted from types.ts.
|
|
1071
1082
|
* Self-contained (no other coding-type deps); re-exported from ../types.ts
|
|
@@ -1210,29 +1221,43 @@ interface KodaXRepoIntelligenceTraceEvent {
|
|
|
1210
1221
|
trace?: KodaXRepoIntelligenceTrace;
|
|
1211
1222
|
}
|
|
1212
1223
|
|
|
1224
|
+
interface KodaXWorkflowEventMeta {
|
|
1225
|
+
readonly workflowCorrelation?: WorkflowEventCorrelation;
|
|
1226
|
+
}
|
|
1227
|
+
interface KodaXActivityEventMeta extends KodaXWorkflowEventMeta {
|
|
1228
|
+
readonly childAgentId?: string;
|
|
1229
|
+
readonly childAgentName?: string;
|
|
1230
|
+
readonly parentToolId?: string;
|
|
1231
|
+
readonly liveOnly?: boolean;
|
|
1232
|
+
}
|
|
1233
|
+
interface KodaXToolEventMeta extends KodaXActivityEventMeta {
|
|
1234
|
+
readonly toolId?: string;
|
|
1235
|
+
}
|
|
1213
1236
|
interface KodaXEvents {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1237
|
+
/** FEATURE_229: correlates child-agent SDK callbacks back to a workflow run/item. */
|
|
1238
|
+
workflowCorrelation?: WorkflowEventCorrelation;
|
|
1239
|
+
onTextDelta?: (text: string, meta?: KodaXActivityEventMeta) => void;
|
|
1240
|
+
onThinkingDelta?: (text: string, meta?: KodaXActivityEventMeta) => void;
|
|
1241
|
+
onThinkingEnd?: (thinking: string, meta?: KodaXActivityEventMeta) => void;
|
|
1217
1242
|
onToolUseStart?: (tool: {
|
|
1218
1243
|
name: string;
|
|
1219
1244
|
id: string;
|
|
1220
1245
|
input?: Record<string, unknown>;
|
|
1221
|
-
}) => void;
|
|
1246
|
+
}, meta?: KodaXToolEventMeta) => void;
|
|
1222
1247
|
onToolResult?: (result: {
|
|
1223
1248
|
id: string;
|
|
1224
1249
|
name: string;
|
|
1225
1250
|
content: string;
|
|
1226
|
-
}) => void;
|
|
1251
|
+
}, meta?: KodaXToolEventMeta) => void;
|
|
1227
1252
|
/** FEATURE_067 v2: Real-time tool execution progress update. Updates the tool's display in the REPL transcript. */
|
|
1228
1253
|
onToolProgress?: (update: {
|
|
1229
1254
|
id: string;
|
|
1230
1255
|
message: string;
|
|
1231
|
-
}) => void;
|
|
1232
|
-
onToolInputDelta?: (toolName: string, partialJson: string, meta?:
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1256
|
+
}, meta?: KodaXToolEventMeta) => void;
|
|
1257
|
+
onToolInputDelta?: (toolName: string, partialJson: string, meta?: KodaXToolEventMeta) => void;
|
|
1258
|
+
onStreamEnd?: (meta?: KodaXActivityEventMeta) => void;
|
|
1259
|
+
/** Fired once when a child-agent run fully leaves the child executor. */
|
|
1260
|
+
onChildActivityEnd?: (meta?: KodaXActivityEventMeta) => void;
|
|
1236
1261
|
onSessionStart?: (info: {
|
|
1237
1262
|
provider: string;
|
|
1238
1263
|
sessionId: string;
|
|
@@ -1294,8 +1319,8 @@ interface KodaXEvents {
|
|
|
1294
1319
|
* prompt contents in queue order. Empty arrays are not surfaced.
|
|
1295
1320
|
*/
|
|
1296
1321
|
onMidTurnUserMessages?: (contents: readonly string[]) => void;
|
|
1297
|
-
onRetry?: (reason: string, attempt: number, maxAttempts: number) => void;
|
|
1298
|
-
onProviderRateLimit?: (attempt: number, maxRetries: number, delayMs: number) => void;
|
|
1322
|
+
onRetry?: (reason: string, attempt: number, maxAttempts: number, meta?: KodaXActivityEventMeta) => void;
|
|
1323
|
+
onProviderRateLimit?: (attempt: number, maxRetries: number, delayMs: number, meta?: KodaXActivityEventMeta) => void;
|
|
1299
1324
|
/**
|
|
1300
1325
|
* FEATURE_130 (v0.7.36) — structured retry-after notification.
|
|
1301
1326
|
*
|
|
@@ -1320,7 +1345,7 @@ interface KodaXEvents {
|
|
|
1320
1345
|
source: 'retry-after-seconds' | 'retry-after-date' | 'retry-after-ms' | 'exponential-backoff';
|
|
1321
1346
|
attempt: number;
|
|
1322
1347
|
maxAttempts: number;
|
|
1323
|
-
}) => void;
|
|
1348
|
+
}, meta?: KodaXActivityEventMeta) => void;
|
|
1324
1349
|
onRepoIntelligenceTrace?: (event: KodaXRepoIntelligenceTraceEvent) => void;
|
|
1325
1350
|
/**
|
|
1326
1351
|
* FEATURE_097 (v0.7.34): emitted whenever the Scout-seeded todo list
|
|
@@ -1333,10 +1358,12 @@ interface KodaXEvents {
|
|
|
1333
1358
|
*/
|
|
1334
1359
|
onTodoUpdate?: (items: TodoList) => void;
|
|
1335
1360
|
/** Structured provider recovery event (Feature 045) */
|
|
1336
|
-
onProviderRecovery?: (event: ProviderRecoveryEvent) => void;
|
|
1361
|
+
onProviderRecovery?: (event: ProviderRecoveryEvent, meta?: KodaXActivityEventMeta) => void;
|
|
1337
1362
|
onComplete?: () => void;
|
|
1338
1363
|
onError?: (error: Error) => void;
|
|
1339
1364
|
onManagedTaskStatus?: (status: KodaXManagedTaskStatusEvent) => void;
|
|
1365
|
+
/** FEATURE_229: workflow process snapshot stream for SDK/host panels. */
|
|
1366
|
+
onWorkflowProcessEvent?: (event: WorkflowProcessEvent) => void;
|
|
1340
1367
|
/**
|
|
1341
1368
|
* Fired when Scout's managed-task completion is inferred but the harness
|
|
1342
1369
|
* detected suspicious signals (mutation expected but none happened, budget
|
|
@@ -1373,18 +1400,16 @@ interface KodaXEvents {
|
|
|
1373
1400
|
current: (() => string) | null;
|
|
1374
1401
|
};
|
|
1375
1402
|
/** Tool execution hook - called before tool execution, return false to block - 工具执行前回调 */
|
|
1376
|
-
beforeToolExecute?: (tool: string, input: Record<string, unknown>, meta?:
|
|
1377
|
-
toolId?: string;
|
|
1378
|
-
}) => Promise<boolean | string>;
|
|
1403
|
+
beforeToolExecute?: (tool: string, input: Record<string, unknown>, meta?: KodaXToolEventMeta) => Promise<boolean | string>;
|
|
1379
1404
|
/** Ask user a question interactively - Issue 069 - 交互式向用户提问 */
|
|
1380
|
-
askUser?: (options: AskUserQuestionOptions) => Promise<string>;
|
|
1405
|
+
askUser?: (options: AskUserQuestionOptions, meta?: KodaXToolEventMeta) => Promise<string>;
|
|
1381
1406
|
/** Ask user multiple independent questions sequentially - 多问题顺序提问 */
|
|
1382
|
-
askUserMulti?: (options: AskUserMultiOptions) => Promise<Record<string, string> | undefined>;
|
|
1407
|
+
askUserMulti?: (options: AskUserMultiOptions, meta?: KodaXToolEventMeta) => Promise<Record<string, string> | undefined>;
|
|
1383
1408
|
/** Ask user for free-text input - 自由文本输入 (Issue 112) */
|
|
1384
1409
|
askUserInput?: (options: {
|
|
1385
1410
|
question: string;
|
|
1386
1411
|
default?: string;
|
|
1387
|
-
}) => Promise<string | undefined>;
|
|
1412
|
+
}, meta?: KodaXToolEventMeta) => Promise<string | undefined>;
|
|
1388
1413
|
/**
|
|
1389
1414
|
* FEATURE_074: Exit plan mode with user approval. Called by the `exit_plan_mode` tool.
|
|
1390
1415
|
* Returns:
|
|
@@ -1630,10 +1655,17 @@ interface KodaXChildAgentResult {
|
|
|
1630
1655
|
digest?: string;
|
|
1631
1656
|
/** True when a workflow child digest was attempted but failed (error/timeout/empty distillation). */
|
|
1632
1657
|
digestFailed?: boolean;
|
|
1658
|
+
/** True when a workflow child digest is running asynchronously and may arrive later. */
|
|
1659
|
+
digestPending?: boolean;
|
|
1660
|
+
/** Actual provider/model selected for this child run, when known. */
|
|
1661
|
+
provider?: string;
|
|
1662
|
+
model?: string;
|
|
1633
1663
|
/** Actual iterations consumed by this child agent. */
|
|
1634
1664
|
actualIterations?: number;
|
|
1635
1665
|
/** Best-known token usage for this child run. Used by workflow budget accounting. */
|
|
1636
1666
|
totalTokensUsed?: number;
|
|
1667
|
+
/** True when the child exhausted its iteration budget before completing. */
|
|
1668
|
+
limitReached?: boolean;
|
|
1637
1669
|
/**
|
|
1638
1670
|
* True when the child's `runKodaX` exited via CAP-083 AbortError silent
|
|
1639
1671
|
* terminal (`KodaXResult.interrupted === true`). Surfaces the
|
|
@@ -2022,6 +2054,8 @@ interface KodaXOptions {
|
|
|
2022
2054
|
context?: KodaXContextOptions;
|
|
2023
2055
|
events?: KodaXEvents;
|
|
2024
2056
|
extensionRuntime?: ExtensionRuntimeContract;
|
|
2057
|
+
/** FEATURE_229: host-owned policy for workflow auto-start and ceilings. */
|
|
2058
|
+
workflowHostPolicy?: WorkflowHostPolicy;
|
|
2025
2059
|
/** FEATURE_221: SDK-consumer self-manual injection (product name + topics). */
|
|
2026
2060
|
selfManual?: KodaXSelfManualConfig;
|
|
2027
2061
|
/**
|
|
@@ -2302,6 +2336,11 @@ interface KodaXToolExecutionContext {
|
|
|
2302
2336
|
selfManual?: KodaXSelfManualConfig;
|
|
2303
2337
|
/** Working directory used to resolve relative paths and execute shell commands. */
|
|
2304
2338
|
executionCwd?: string;
|
|
2339
|
+
/**
|
|
2340
|
+
* Active skill invocation for the current managed run. Child dispatch uses
|
|
2341
|
+
* this to preserve the skill's support-file roots in sub-agent briefings.
|
|
2342
|
+
*/
|
|
2343
|
+
skillInvocation?: KodaXSkillInvocationContext;
|
|
2305
2344
|
/**
|
|
2306
2345
|
* FEATURE_217 (v0.7.49): parent dir for `isolation:'worktree'` workflow child
|
|
2307
2346
|
* worktrees. Workflow runs point this at `<runDir>/worktrees` so worktrees are
|
|
@@ -2356,6 +2395,12 @@ interface KodaXToolExecutionContext {
|
|
|
2356
2395
|
readonly model?: string;
|
|
2357
2396
|
readonly reasoningMode?: KodaXReasoningMode;
|
|
2358
2397
|
};
|
|
2398
|
+
/**
|
|
2399
|
+
* Parent SDK/REPL callback surface available to child-dispatch tools.
|
|
2400
|
+
* `dispatch_child_task` uses this to preserve live child telemetry without
|
|
2401
|
+
* copying every callback onto KodaXToolExecutionContext as a separate field.
|
|
2402
|
+
*/
|
|
2403
|
+
parentEvents?: KodaXEvents;
|
|
2359
2404
|
/**
|
|
2360
2405
|
* FEATURE_123 v0.7.44 — agentId of the agent whose tool call this
|
|
2361
2406
|
* context backs. `undefined` for the top-level Worker (main runtime
|
|
@@ -2587,504 +2632,6 @@ interface KodaXToolExecutionContext {
|
|
|
2587
2632
|
goalContext?: GoalToolsContext;
|
|
2588
2633
|
}
|
|
2589
2634
|
|
|
2590
|
-
/**
|
|
2591
|
-
* AGENTS.md - Project-level AI Context Rules Loader
|
|
2592
|
-
*
|
|
2593
|
-
* This module implements loading of project-level context rules from AGENTS.md files,
|
|
2594
|
-
* inspired by pi-mono's implementation.
|
|
2595
|
-
*
|
|
2596
|
-
* Priority: global < root < ... < current directory < .kodax/
|
|
2597
|
-
*/
|
|
2598
|
-
interface AgentsFile {
|
|
2599
|
-
path: string;
|
|
2600
|
-
content: string;
|
|
2601
|
-
scope: 'global' | 'project' | 'directory';
|
|
2602
|
-
}
|
|
2603
|
-
interface LoadAgentsOptions {
|
|
2604
|
-
/** Pass cwd explicitly for deterministic prompt building; process.cwd() is only a legacy fallback. */
|
|
2605
|
-
cwd?: string;
|
|
2606
|
-
kodaxDir?: string;
|
|
2607
|
-
projectRoot?: string;
|
|
2608
|
-
}
|
|
2609
|
-
/**
|
|
2610
|
-
* Get KodaX global directory.
|
|
2611
|
-
*
|
|
2612
|
-
* Routes through {@link getAgentConfigHome} (v0.7.35.1 FEATURE_145 3-tier
|
|
2613
|
-
* resolution: programmatic override > KODAX_HOME env > ~/.kodax default).
|
|
2614
|
-
*/
|
|
2615
|
-
declare function getKodaxGlobalDir(): string;
|
|
2616
|
-
/**
|
|
2617
|
-
* Load all AGENTS files
|
|
2618
|
-
* Priority: global < root < ... < current directory < .kodax/
|
|
2619
|
-
*/
|
|
2620
|
-
declare function loadAgentsFiles(options?: LoadAgentsOptions): AgentsFile[];
|
|
2621
|
-
/**
|
|
2622
|
-
* Format AGENTS files for system prompt
|
|
2623
|
-
*/
|
|
2624
|
-
declare function formatAgentsForPrompt(files: AgentsFile[]): string;
|
|
2625
|
-
|
|
2626
|
-
/**
|
|
2627
|
-
* Auto-Mode Rules Loader — FEATURE_092 Phase 2b.2 (v0.7.33).
|
|
2628
|
-
*
|
|
2629
|
-
* Three-layer trust model for `auto-rules.jsonc` files consumed by the
|
|
2630
|
-
* auto-mode classifier:
|
|
2631
|
-
*
|
|
2632
|
-
* 1. ~/.kodax/auto-rules.jsonc — user-level, always trusted
|
|
2633
|
-
* 2. <project>/.kodax/auto-rules.jsonc — shared, opt-in (sha256 fingerprint)
|
|
2634
|
-
* 3. <project>/.kodax/auto-rules.local.jsonc — workspace-local, gitignored, trusted
|
|
2635
|
-
*
|
|
2636
|
-
* Why opt-in for the shared file: a malicious PR could land an
|
|
2637
|
-
* `auto-rules.jsonc` claiming "allow any curl" and the user wouldn't
|
|
2638
|
-
* notice. First-checkout opt-in via fingerprint forces the user to
|
|
2639
|
-
* acknowledge the file by content. If the fingerprint changes later,
|
|
2640
|
-
* the file is silently skipped until re-trusted — failures favor safety.
|
|
2641
|
-
*
|
|
2642
|
-
* Schema (each field optional, defaults to []):
|
|
2643
|
-
* {
|
|
2644
|
-
* "allow": string[], // patterns the classifier defaults to allowing
|
|
2645
|
-
* "soft_deny": string[], // patterns the classifier defaults to blocking
|
|
2646
|
-
* "environment": string[] // background context the classifier sees verbatim
|
|
2647
|
-
* }
|
|
2648
|
-
*
|
|
2649
|
-
* Merge: layers concatenated in order (user → project → local). Identical
|
|
2650
|
-
* strings deduplicated by stable insertion (later layers win position only
|
|
2651
|
-
* when the string is unique per layer).
|
|
2652
|
-
*/
|
|
2653
|
-
interface AutoRules {
|
|
2654
|
-
readonly allow: readonly string[];
|
|
2655
|
-
readonly soft_deny: readonly string[];
|
|
2656
|
-
readonly environment: readonly string[];
|
|
2657
|
-
}
|
|
2658
|
-
type RulesOrigin = 'user' | 'project' | 'local';
|
|
2659
|
-
interface LoadedRulesSource {
|
|
2660
|
-
readonly origin: RulesOrigin;
|
|
2661
|
-
readonly path: string;
|
|
2662
|
-
readonly fingerprint: string;
|
|
2663
|
-
}
|
|
2664
|
-
interface SkippedRulesSource {
|
|
2665
|
-
readonly origin: 'project';
|
|
2666
|
-
readonly path: string;
|
|
2667
|
-
readonly fingerprint: string;
|
|
2668
|
-
readonly reason: 'untrusted' | 'fingerprint-changed';
|
|
2669
|
-
}
|
|
2670
|
-
interface RulesLoadError {
|
|
2671
|
-
readonly path: string;
|
|
2672
|
-
readonly message: string;
|
|
2673
|
-
}
|
|
2674
|
-
interface RulesLoadResult {
|
|
2675
|
-
readonly merged: AutoRules;
|
|
2676
|
-
readonly sources: readonly LoadedRulesSource[];
|
|
2677
|
-
readonly skipped: readonly SkippedRulesSource[];
|
|
2678
|
-
readonly errors: readonly RulesLoadError[];
|
|
2679
|
-
}
|
|
2680
|
-
interface LoadAutoRulesOptions {
|
|
2681
|
-
readonly userKodaxDir: string;
|
|
2682
|
-
readonly projectRoot: string;
|
|
2683
|
-
}
|
|
2684
|
-
interface TrustState {
|
|
2685
|
-
readonly trusted: Readonly<Record<string, string>>;
|
|
2686
|
-
}
|
|
2687
|
-
declare function computeRulesFingerprint(content: string): string;
|
|
2688
|
-
declare function readTrustState(userKodaxDir: string): Promise<TrustState>;
|
|
2689
|
-
interface TrustOptions {
|
|
2690
|
-
readonly userKodaxDir: string;
|
|
2691
|
-
}
|
|
2692
|
-
declare function trustProjectRules(rulesPath: string, fingerprint: string, opts: TrustOptions): Promise<void>;
|
|
2693
|
-
type ParseAutoRulesResult = {
|
|
2694
|
-
readonly ok: true;
|
|
2695
|
-
readonly rules: AutoRules;
|
|
2696
|
-
} | {
|
|
2697
|
-
readonly ok: false;
|
|
2698
|
-
readonly error: string;
|
|
2699
|
-
};
|
|
2700
|
-
declare function parseAutoRules(src: string): ParseAutoRulesResult;
|
|
2701
|
-
declare function loadAutoRules(opts: LoadAutoRulesOptions): Promise<RulesLoadResult>;
|
|
2702
|
-
|
|
2703
|
-
/**
|
|
2704
|
-
* Tool-Call Signals — FEATURE_158 Step 2 (v0.7.39).
|
|
2705
|
-
*
|
|
2706
|
-
* Mechanical pattern matches over a tool call. Signals are NOT verdicts;
|
|
2707
|
-
* the classifier consumes them as informational input alongside transcript
|
|
2708
|
-
* + user rules and produces the final decision (allow / block / escalate).
|
|
2709
|
-
*
|
|
2710
|
-
* Two invariants the producers must hold:
|
|
2711
|
-
*
|
|
2712
|
-
* 1. **Pure**: same `call` + `projectRoot` ⇒ same signals. No I/O, no
|
|
2713
|
-
* timestamps, no env reads inside collectors. Collectors run on every
|
|
2714
|
-
* non-Tier-1 tool call, so they must be cheap and deterministic.
|
|
2715
|
-
*
|
|
2716
|
-
* 2. **Fact-only**: a `protected_path` signal says "this command names
|
|
2717
|
-
* path X which is under ~/.kodax/", not "this should be blocked".
|
|
2718
|
-
* Severity stays on the producer side (e.g. `dangerous_pattern.severity`)
|
|
2719
|
-
* so the classifier can weight signals, but the verdict is not encoded
|
|
2720
|
-
* here.
|
|
2721
|
-
*
|
|
2722
|
-
* Tier 0 (absolute deny) is a separate module — signals are pre-verdict
|
|
2723
|
-
* material consumed by Tier 2 (LLM classifier). The two paths are not
|
|
2724
|
-
* coupled: Tier 0 catches a fixed catastrophic-pattern set; signals
|
|
2725
|
-
* describe a wider surface for the classifier to reason about.
|
|
2726
|
-
*
|
|
2727
|
-
* Design ref: ADR-025, FEATURE_158 (docs/features/v0.7.39.md).
|
|
2728
|
-
*/
|
|
2729
|
-
|
|
2730
|
-
/**
|
|
2731
|
-
* One mechanical signal about a tool call. Discriminated union — consumers
|
|
2732
|
-
* narrow on `kind` to access the kind-specific fields.
|
|
2733
|
-
*/
|
|
2734
|
-
type ToolCallSignal = {
|
|
2735
|
-
readonly kind: 'dangerous_pattern';
|
|
2736
|
-
/** Pattern source (e.g. regex .source) that matched. */
|
|
2737
|
-
readonly pattern: string;
|
|
2738
|
-
/**
|
|
2739
|
-
* Severity hint for the classifier.
|
|
2740
|
-
* `high` — destructive intent typical (e.g. `git push --force`,
|
|
2741
|
-
* `chmod 777`, `curl | bash`). Classifier should lean
|
|
2742
|
-
* toward escalate/block.
|
|
2743
|
-
* `medium` — risk-shaped but contextual (e.g. broad `rm`, `sudo`).
|
|
2744
|
-
* Classifier weighs against transcript context.
|
|
2745
|
-
*/
|
|
2746
|
-
readonly severity: 'high' | 'medium';
|
|
2747
|
-
} | {
|
|
2748
|
-
readonly kind: 'protected_path';
|
|
2749
|
-
/** Path token that triggered the match (as it appeared in the call). */
|
|
2750
|
-
readonly path: string;
|
|
2751
|
-
/**
|
|
2752
|
-
* `project-kodax` — under `<projectRoot>/.kodax/`
|
|
2753
|
-
* `user-kodax` — under `~/.kodax/` (credentials zone)
|
|
2754
|
-
*/
|
|
2755
|
-
readonly zone: 'project-kodax' | 'user-kodax';
|
|
2756
|
-
} | {
|
|
2757
|
-
readonly kind: 'outside_project';
|
|
2758
|
-
readonly path: string;
|
|
2759
|
-
} | {
|
|
2760
|
-
readonly kind: 'shell_redirect_outside';
|
|
2761
|
-
/** Redirection target path (`>`, `>>`, `tee` etc.). */
|
|
2762
|
-
readonly target: string;
|
|
2763
|
-
} | {
|
|
2764
|
-
readonly kind: 'package_install';
|
|
2765
|
-
readonly manager: 'npm' | 'pnpm' | 'yarn' | 'pip' | 'cargo' | 'apt' | 'brew';
|
|
2766
|
-
} | {
|
|
2767
|
-
readonly kind: 'git_write';
|
|
2768
|
-
readonly verb: 'commit' | 'push' | 'reset' | 'clean' | 'rebase' | 'cherry-pick' | 'revert';
|
|
2769
|
-
} | {
|
|
2770
|
-
readonly kind: 'network';
|
|
2771
|
-
readonly tool: 'curl' | 'wget' | 'fetch';
|
|
2772
|
-
} | {
|
|
2773
|
-
readonly kind: 'file_modification';
|
|
2774
|
-
readonly targets: readonly string[];
|
|
2775
|
-
};
|
|
2776
|
-
/**
|
|
2777
|
-
* Pulls signals from one tool call. A collector declares which tool names
|
|
2778
|
-
* it applies to via `toolNames`; the dispatcher in `collectAllSignals`
|
|
2779
|
-
* skips non-matching collectors so each one only sees calls it was
|
|
2780
|
-
* designed for.
|
|
2781
|
-
*
|
|
2782
|
-
* `collect` returns the signals; an empty array is fine and the common
|
|
2783
|
-
* case for benign calls.
|
|
2784
|
-
*/
|
|
2785
|
-
interface SignalCollector {
|
|
2786
|
-
/**
|
|
2787
|
-
* Tool names this collector reacts to (lowercase). Other tool names
|
|
2788
|
-
* never reach `collect`. Empty set = matches nothing (effectively
|
|
2789
|
-
* disabled — useful only for tests).
|
|
2790
|
-
*/
|
|
2791
|
-
readonly toolNames: ReadonlySet<string>;
|
|
2792
|
-
/**
|
|
2793
|
-
* Inspect the call and produce zero or more signals.
|
|
2794
|
-
*
|
|
2795
|
-
* Must be pure: no I/O, no timing, no global state reads. The
|
|
2796
|
-
* `projectRoot` argument is the only environmental context — pass
|
|
2797
|
-
* the same value through every call site to keep results stable.
|
|
2798
|
-
*/
|
|
2799
|
-
collect(call: RunnerToolCall, projectRoot: string): readonly ToolCallSignal[];
|
|
2800
|
-
}
|
|
2801
|
-
/**
|
|
2802
|
-
* Run every applicable collector on `call` and return the merged signal
|
|
2803
|
-
* list. Order preserved: collectors run in array order; per-collector
|
|
2804
|
-
* signal order preserved within their slice.
|
|
2805
|
-
*
|
|
2806
|
-
* Duplicates intentionally not deduped here — different collectors may
|
|
2807
|
-
* legitimately surface the same kind for different reasons (e.g. a
|
|
2808
|
-
* `protected_path` from a bash redirect target AND a `protected_path`
|
|
2809
|
-
* from an argv token in the same command). The classifier prompt
|
|
2810
|
-
* tolerates duplicates; dedup would risk dropping load-bearing context.
|
|
2811
|
-
*/
|
|
2812
|
-
declare function collectAllSignals(call: RunnerToolCall, projectRoot: string, collectors: readonly SignalCollector[]): readonly ToolCallSignal[];
|
|
2813
|
-
|
|
2814
|
-
/**
|
|
2815
|
-
* Denial Tracker — FEATURE_092 Phase 2b.4 (v0.7.33).
|
|
2816
|
-
*
|
|
2817
|
-
* Tracks classifier blocks per session. When either threshold is crossed,
|
|
2818
|
-
* the auto-mode engine downgrades from `llm` to `rules` (mode stays `auto`).
|
|
2819
|
-
*
|
|
2820
|
-
* - 3 consecutive blocks → likely an unproductive loop (agent not adapting)
|
|
2821
|
-
* - 20 cumulative blocks → broader classifier-noise pattern in this session
|
|
2822
|
-
*
|
|
2823
|
-
* Both are session-scoped, shared with subagents (per design doc, to defend
|
|
2824
|
-
* against threshold-bypass via spawning).
|
|
2825
|
-
*
|
|
2826
|
-
* Pure functional API: each operation returns a new tracker. No mutation.
|
|
2827
|
-
*/
|
|
2828
|
-
declare const CONSECUTIVE_THRESHOLD = 3;
|
|
2829
|
-
declare const CUMULATIVE_THRESHOLD = 20;
|
|
2830
|
-
interface DenialTracker {
|
|
2831
|
-
readonly consecutive: number;
|
|
2832
|
-
readonly cumulative: number;
|
|
2833
|
-
}
|
|
2834
|
-
declare function createDenialTracker(): DenialTracker;
|
|
2835
|
-
declare function recordBlock(t: DenialTracker): DenialTracker;
|
|
2836
|
-
declare function recordAllow(t: DenialTracker): DenialTracker;
|
|
2837
|
-
declare function shouldFallback$1(t: DenialTracker): boolean;
|
|
2838
|
-
|
|
2839
|
-
/**
|
|
2840
|
-
* Circuit Breaker — FEATURE_092 Phase 2b.4 (v0.7.33).
|
|
2841
|
-
*
|
|
2842
|
-
* Sliding-window error counter for classifier failures (timeouts, 5xx, 429,
|
|
2843
|
-
* unparseable outputs). When ≥ 5 errors land within a 10-minute window, the
|
|
2844
|
-
* auto-mode engine downgrades from `llm` to `rules` (mode stays `auto`) so
|
|
2845
|
-
* the user is not blocked by a degraded classifier path.
|
|
2846
|
-
*
|
|
2847
|
-
* Pure functional API: each operation returns a new breaker. No mutation.
|
|
2848
|
-
* Memory bound: stale timestamps are pruned on each recordError call so
|
|
2849
|
-
* the timestamps array never grows unbounded.
|
|
2850
|
-
*/
|
|
2851
|
-
declare const ERROR_THRESHOLD = 5;
|
|
2852
|
-
declare const WINDOW_MS: number;
|
|
2853
|
-
interface CircuitBreaker {
|
|
2854
|
-
readonly timestamps: readonly number[];
|
|
2855
|
-
}
|
|
2856
|
-
declare function createCircuitBreaker(): CircuitBreaker;
|
|
2857
|
-
declare function recordError(b: CircuitBreaker, now: number): CircuitBreaker;
|
|
2858
|
-
declare function shouldFallback(b: CircuitBreaker, now: number): boolean;
|
|
2859
|
-
|
|
2860
|
-
/**
|
|
2861
|
-
* AutoModeToolGuardrail — FEATURE_092 Phase 2b.6 (v0.7.33).
|
|
2862
|
-
*
|
|
2863
|
-
* Assembles the auto-mode classifier modules (rules + projection +
|
|
2864
|
-
* classify + denial-tracker + circuit-breaker + model-resolver) into a
|
|
2865
|
-
* `ToolGuardrail` that the Runner calls via `beforeTool` on every
|
|
2866
|
-
* tool invocation.
|
|
2867
|
-
*
|
|
2868
|
-
* Decision flow (per design doc "三层权限金字塔"):
|
|
2869
|
-
*
|
|
2870
|
-
* 1. Tool projection is '' (Tier 1) → allow (zero token cost)
|
|
2871
|
-
* 2. Engine has been downgraded to rules → escalate (user confirms)
|
|
2872
|
-
* 3. denialTracker.shouldFallback (3/20) → engine downgrade, then escalate
|
|
2873
|
-
* 4. circuitBreaker.shouldFallback (5/10m) → engine downgrade, then escalate
|
|
2874
|
-
* 5. classify(...) sideQuery
|
|
2875
|
-
* allow → allow (record allow → reset consecutive)
|
|
2876
|
-
* block → block + reason (record block)
|
|
2877
|
-
* escalate → escalate + reason (record error)
|
|
2878
|
-
* AbortError thrown → re-throw (propagate user cancel)
|
|
2879
|
-
*
|
|
2880
|
-
* State (mutable, session-scoped):
|
|
2881
|
-
* - engine: 'llm' | 'rules' (starts at 'llm', downgrades on threshold)
|
|
2882
|
-
* - denialTracker (immutable type, swapped on each event)
|
|
2883
|
-
* - circuitBreaker (immutable type, swapped on each event)
|
|
2884
|
-
*
|
|
2885
|
-
* Subagent sharing:
|
|
2886
|
-
* The factory accepts an optional `sharedState` ref; passing the same ref
|
|
2887
|
-
* to a subagent's guardrail means denial / circuit / engine state is
|
|
2888
|
-
* shared (per design doc "防绕阈值"). Without it each guardrail is
|
|
2889
|
-
* independent.
|
|
2890
|
-
*
|
|
2891
|
-
* Capability check, Tier 2 path-shortcuts, and the explicit
|
|
2892
|
-
* `supportsAutoModeClassifier` provider flag are deferred to follow-up
|
|
2893
|
-
* phases — v1 of the guardrail relies on Tier 1 (projection==='') as the
|
|
2894
|
-
* structural opt-out and forwards everything else to the classifier.
|
|
2895
|
-
*/
|
|
2896
|
-
|
|
2897
|
-
type AutoModeEngine = 'llm' | 'rules';
|
|
2898
|
-
interface AutoModeSharedState {
|
|
2899
|
-
engine: AutoModeEngine;
|
|
2900
|
-
denials: DenialTracker;
|
|
2901
|
-
breaker: CircuitBreaker;
|
|
2902
|
-
}
|
|
2903
|
-
/**
|
|
2904
|
-
* User answer for an escalated tool-call. The guardrail translates this into
|
|
2905
|
-
* the actual `GuardrailVerdict` returned to the Runner. `'block'` preserves
|
|
2906
|
-
* the original escalation reason as the verdict reason so downstream consumers
|
|
2907
|
-
* see why the tool was blocked.
|
|
2908
|
-
*/
|
|
2909
|
-
type AutoModeAskUserVerdict = 'allow' | 'block';
|
|
2910
|
-
/**
|
|
2911
|
-
* Optional REPL-supplied prompt callback for the 6 escalate paths in
|
|
2912
|
-
* `beforeTool` (engine-downgraded, denial-threshold-just-crossed,
|
|
2913
|
-
* breaker-just-tripped, classifier-error, classifier-decision-escalate,
|
|
2914
|
-
* provider-not-configured). When supplied, the guardrail calls this and
|
|
2915
|
-
* translates the user's answer into `'allow'` or `'block'`. When NOT
|
|
2916
|
-
* supplied, the guardrail returns `'escalate'` as before — the Runner will
|
|
2917
|
-
* then throw `GuardrailEscalateError` (preserves backward compat with
|
|
2918
|
-
* SDK-side guardrail consumers that have no askUser surface).
|
|
2919
|
-
*
|
|
2920
|
-
* Rejection propagates: if the user cancels (Ctrl-C in the prompt), throw
|
|
2921
|
-
* an AbortError-shaped exception and the Runner aborts the run cleanly.
|
|
2922
|
-
*/
|
|
2923
|
-
type AutoModeAskUser = (call: RunnerToolCall, reason: string,
|
|
2924
|
-
/**
|
|
2925
|
-
* FEATURE_158 (v0.7.39): static-analysis signals collected for this tool
|
|
2926
|
-
* call. Optional + readonly so existing callers without signal-aware UI
|
|
2927
|
-
* keep working. REPL uses these to render Scope/Risk labels on the
|
|
2928
|
-
* confirm dialog (replacing the input-marker path from FEATURE_066).
|
|
2929
|
-
*/
|
|
2930
|
-
signals?: readonly ToolCallSignal[]) => Promise<AutoModeAskUserVerdict>;
|
|
2931
|
-
interface AutoModeGuardrailConfig {
|
|
2932
|
-
readonly rules: AutoRules;
|
|
2933
|
-
readonly claudeMd?: string;
|
|
2934
|
-
/**
|
|
2935
|
-
* FEATURE_092 phase 2b.7b: optional user-prompt callback for escalate
|
|
2936
|
-
* paths. See `AutoModeAskUser` for semantics.
|
|
2937
|
-
*/
|
|
2938
|
-
readonly askUser?: AutoModeAskUser;
|
|
2939
|
-
/**
|
|
2940
|
-
* Look up a tool's `toClassifierInput` projection by tool name.
|
|
2941
|
-
* Returns `undefined` when the tool isn't in the registry — guardrail
|
|
2942
|
-
* treats that as "no projection ⇒ Tier 1 skip" (conservative for
|
|
2943
|
-
* unknown tools is debatable; v1 favors not blocking on noise).
|
|
2944
|
-
*/
|
|
2945
|
-
readonly getToolProjection: (toolName: string) => ((input: unknown) => string) | undefined;
|
|
2946
|
-
/**
|
|
2947
|
-
* Resolve a provider name to an instance. Returns `undefined` when
|
|
2948
|
-
* unconfigured / unknown — the guardrail then escalates.
|
|
2949
|
-
*/
|
|
2950
|
-
readonly resolveProvider: (providerName: string) => KodaXBaseProvider | undefined;
|
|
2951
|
-
readonly defaultProvider: string;
|
|
2952
|
-
readonly defaultModel: string;
|
|
2953
|
-
/**
|
|
2954
|
-
* FEATURE_092 v0.7.34 hotfix-3 — defaultProvider/defaultModel staleness fix.
|
|
2955
|
-
*
|
|
2956
|
-
* When supplied, these are called on EVERY classify() invocation, so the
|
|
2957
|
-
* classifier follows the user's current main session provider/model even
|
|
2958
|
-
* after `/model` or `/provider` mid-session swaps. Falls back to
|
|
2959
|
-
* `defaultProvider` / `defaultModel` (static strings) when unset, preserving
|
|
2960
|
-
* backward compatibility for SDK consumers that pass string literals.
|
|
2961
|
-
*/
|
|
2962
|
-
readonly getDefaultProvider?: () => string;
|
|
2963
|
-
readonly getDefaultModel?: () => string;
|
|
2964
|
-
readonly cliFlag?: string;
|
|
2965
|
-
readonly envVar?: string;
|
|
2966
|
-
readonly sessionOverride?: string;
|
|
2967
|
-
readonly userSettings?: string;
|
|
2968
|
-
/**
|
|
2969
|
-
* Optional cost-tracker accessors. The classifier writes its tokens to
|
|
2970
|
-
* the tracker under `querySource: 'auto_mode'` (handled inside sideQuery).
|
|
2971
|
-
*/
|
|
2972
|
-
readonly getCostTracker?: () => CostTracker | undefined;
|
|
2973
|
-
readonly setCostTracker?: (t: CostTracker) => void;
|
|
2974
|
-
/** Optional logger for engine-downgrade and config warnings. */
|
|
2975
|
-
readonly log?: (level: 'info' | 'warn', msg: string) => void;
|
|
2976
|
-
/**
|
|
2977
|
-
* Fired whenever the active engine changes — both on automatic downgrades
|
|
2978
|
-
* (denial threshold / circuit breaker) AND on manual `setEngine(...)`
|
|
2979
|
-
* calls. UI surfaces (status bar engine indicator, slash-command
|
|
2980
|
-
* confirmations) subscribe here so the displayed engine stays in sync
|
|
2981
|
-
* with the guardrail's internal state without the user having to trigger
|
|
2982
|
-
* another mode toggle just to refresh the bar.
|
|
2983
|
-
*/
|
|
2984
|
-
readonly onEngineChange?: (engine: AutoModeEngine) => void;
|
|
2985
|
-
/**
|
|
2986
|
-
* Optional shared state for subagent threshold-bypass defense
|
|
2987
|
-
* (design doc "防绕阈值"). When supplied, the parent and child
|
|
2988
|
-
* guardrails reference the SAME object — engine downgrades and
|
|
2989
|
-
* tracker advances are visible across the session boundary.
|
|
2990
|
-
*/
|
|
2991
|
-
readonly sharedState?: AutoModeSharedState;
|
|
2992
|
-
/**
|
|
2993
|
-
* FEATURE_092 phase 2b.7b slice C: starting engine. Defaults to `'llm'`.
|
|
2994
|
-
* Set to `'rules'` to skip the classifier entirely from session start
|
|
2995
|
-
* (the rules-mode escalate path runs immediately on the first non-Tier-1
|
|
2996
|
-
* tool call). Resolved by the REPL from `~/.kodax/config.json`
|
|
2997
|
-
* `autoMode.engine` and the `KODAX_AUTO_MODE_ENGINE` env var.
|
|
2998
|
-
*/
|
|
2999
|
-
readonly initialEngine?: AutoModeEngine;
|
|
3000
|
-
/**
|
|
3001
|
-
* FEATURE_092 phase 2b.7b slice C: classifier sideQuery timeout in ms.
|
|
3002
|
-
* Defaults to 8000. Resolved by the REPL from `~/.kodax/config.json`
|
|
3003
|
-
* `autoMode.timeoutMs`.
|
|
3004
|
-
*/
|
|
3005
|
-
readonly timeoutMs?: number;
|
|
3006
|
-
/**
|
|
3007
|
-
* Project root for signal collectors. File-tool collector uses this to
|
|
3008
|
-
* detect `outside_project` vs project-relative paths. Bash collector
|
|
3009
|
-
* doesn't use it (command-string-level) but threads it for uniform
|
|
3010
|
-
* collector contract.
|
|
3011
|
-
*
|
|
3012
|
-
* Required by FEATURE_158: if omitted, the default coding-side
|
|
3013
|
-
* collectors produce no `outside_project` signal (degrades gracefully),
|
|
3014
|
-
* but **REPL-injected `extraCollectors` will likely require it**.
|
|
3015
|
-
* SDK consumers without a project root should set `projectRoot: ''`
|
|
3016
|
-
* and supply no `extraCollectors`.
|
|
3017
|
-
*/
|
|
3018
|
-
readonly projectRoot?: string;
|
|
3019
|
-
/**
|
|
3020
|
-
* Override the default signal-collector set. When unset, defaults to
|
|
3021
|
-
* `[bashSignalCollector, fileSignalCollector]` — coding-side
|
|
3022
|
-
* command-string + file-tool collectors that don't depend on REPL
|
|
3023
|
-
* path utilities.
|
|
3024
|
-
*
|
|
3025
|
-
* Use `extraCollectors` instead if you want to **add** collectors
|
|
3026
|
-
* without replacing the defaults.
|
|
3027
|
-
*/
|
|
3028
|
-
readonly signalCollectors?: readonly SignalCollector[];
|
|
3029
|
-
/**
|
|
3030
|
-
* Additional signal collectors to merge with `signalCollectors`.
|
|
3031
|
-
* Primary use: REPL injects a path-aware bash collector built on its
|
|
3032
|
-
* own `extractPathsFromCommand` / `isAlwaysConfirmPath` utilities
|
|
3033
|
-
* (those live in `@kodax/repl` for historical reasons; lifting them
|
|
3034
|
-
* is out-of-scope for FEATURE_158 — see design doc layer-boundary
|
|
3035
|
-
* decision).
|
|
3036
|
-
*
|
|
3037
|
-
* Order: defaults run first, then extras (preserves per-collector
|
|
3038
|
-
* signal order).
|
|
3039
|
-
*/
|
|
3040
|
-
readonly extraCollectors?: readonly SignalCollector[];
|
|
3041
|
-
/**
|
|
3042
|
-
* Speculative-classify quiet window (ms). When a classifier promise
|
|
3043
|
-
* settles within this window, the guardrail uses the verdict directly
|
|
3044
|
-
* (no confirm dialog). When the window expires, the call escalates to
|
|
3045
|
-
* the user; the background classifier is left running for cost-tracker
|
|
3046
|
-
* settlement but its eventual result is discarded in v1 (UI doesn't
|
|
3047
|
-
* adopt late verdicts yet).
|
|
3048
|
-
*
|
|
3049
|
-
* Precedence: explicit arg > `KODAX_AUTO_SPECULATIVE_WINDOW_MS` env >
|
|
3050
|
-
* `DEFAULT_WINDOW_MS = 500`. Set to 0 to disable speculative race
|
|
3051
|
-
* (degrades to synchronous classify).
|
|
3052
|
-
*/
|
|
3053
|
-
readonly speculativeWindowMs?: number;
|
|
3054
|
-
}
|
|
3055
|
-
/**
|
|
3056
|
-
* Snapshot of the auto-mode guardrail's session-scoped state. Returned by
|
|
3057
|
-
* `getStats()` for diagnostic surfaces (`/auto-denials`) and the status bar
|
|
3058
|
-
* engine indicator. The DenialTracker / CircuitBreaker types are immutable
|
|
3059
|
-
* value objects, so this is a copy of the references — caller cannot mutate
|
|
3060
|
-
* guardrail state through it.
|
|
3061
|
-
*/
|
|
3062
|
-
interface AutoModeStats {
|
|
3063
|
-
readonly engine: AutoModeEngine;
|
|
3064
|
-
readonly denials: DenialTracker;
|
|
3065
|
-
readonly breaker: CircuitBreaker;
|
|
3066
|
-
}
|
|
3067
|
-
interface AutoModeToolGuardrail extends ToolGuardrail {
|
|
3068
|
-
/** Current engine for this session. */
|
|
3069
|
-
getEngine(): AutoModeEngine;
|
|
3070
|
-
/** Snapshot of engine + denial tracker + circuit breaker. */
|
|
3071
|
-
getStats(): AutoModeStats;
|
|
3072
|
-
/**
|
|
3073
|
-
* Manually set the engine. Used by `/auto-engine` slash command to flip
|
|
3074
|
-
* back to 'llm' after an automatic downgrade or to flip to 'rules' for
|
|
3075
|
-
* manual testing. The downgrade thresholds still operate normally — a
|
|
3076
|
-
* subsequent threshold cross will downgrade again.
|
|
3077
|
-
*/
|
|
3078
|
-
setEngine(engine: AutoModeEngine): void;
|
|
3079
|
-
/** Test-only alias for getEngine(). Backward-compat for test files. */
|
|
3080
|
-
getEngineForTest(): AutoModeEngine;
|
|
3081
|
-
/** Test-only alias for getStats(). Backward-compat for test files. */
|
|
3082
|
-
getStatsForTest(): AutoModeStats;
|
|
3083
|
-
/** Test-only override: swap the provider mid-test (for downgrade scenarios). */
|
|
3084
|
-
setProviderForTest(provider: KodaXBaseProvider): void;
|
|
3085
|
-
}
|
|
3086
|
-
declare function createAutoModeToolGuardrail(config: AutoModeGuardrailConfig): AutoModeToolGuardrail;
|
|
3087
|
-
|
|
3088
2635
|
/**
|
|
3089
2636
|
* Bash Command Prefix Extractor — FEATURE_153 (v0.7.38).
|
|
3090
2637
|
*
|
|
@@ -3234,5 +2781,5 @@ interface CreateBashPrefixExtractorOptions {
|
|
|
3234
2781
|
*/
|
|
3235
2782
|
declare function createBashPrefixExtractor(opts: CreateBashPrefixExtractorOptions): BashPrefixExtractor;
|
|
3236
2783
|
|
|
3237
|
-
export { BASH_POLICY_SPEC as B,
|
|
3238
|
-
export type {
|
|
2784
|
+
export { BASH_POLICY_SPEC as B, buildGoalRuntimeBinding as aQ, createBashPrefixExtractor as aR, decideWorkflowInvocation as aS, extractCommandPrefix as aT, getDefaultLspService as aU, makeDisabledGoalToolsContext as aV, shutdownDefaultLspService as aW, withGoalBeforeNextTurn as aX, withGoalStopHook as aY, workflowStartOutcomeConsumesTurn as aZ, LSP_SERVERS as ap, LspService as ar };
|
|
2785
|
+
export type { KodaXRuntimeVerificationContract as $, KodaXManagedBudgetSnapshot as A, ChildSnapshotEvent as C, DiagnosticsRequest as D, ExtensionRuntimeContract as E, FailureStage as F, GoalBlockedResult as G, KodaXManagedProtocolPayload as H, KodaXManagedTask as I, KodaXManagedTaskRuntimeState as J, KodaXActivityEventMeta as K, KodaXManagedTaskStatusEvent as L, KodaXManualTopicId as M, KodaXManualTopicInput as N, KodaXMemoryStrategy as O, KodaXOptions as P, KodaXOrchestrationVerdict as Q, KodaXParentReductionContract as R, KodaXProviderPolicyHints as S, KodaXRepoIntelligenceCapability as T, KodaXRepoIntelligenceMode as U, KodaXRepoIntelligenceResolvedMode as V, KodaXRepoIntelligenceTrace as W, KodaXRepoIntelligenceTraceEvent as X, KodaXRepoRoutingSignals as Y, KodaXResult as Z, KodaXRoleRoundSummary as _, BashPrefixExtractor as a, KodaXSelfManualConfig as a0, KodaXSessionControl as a1, KodaXSessionMutators as a2, KodaXSessionOptions as a3, KodaXSkillInvocationContext as a4, KodaXSkillMap as a5, KodaXSkillProjectionConfidence as a6, KodaXTaskCapabilityHint as a7, KodaXTaskContract as a8, KodaXTaskEvidenceArtifact as a9, RecoveryResult as aA, ResilienceClassification as aB, ResilienceErrorClass as aC, ResolveKodaXManualInput as aD, ResolveKodaXManualOptions as aE, ResolveKodaXManualResult as aF, TodoItem as aG, TodoList as aH, TodoStatus as aI, WorkflowHostPolicy as aJ, WorkflowInvocationAction as aK, WorkflowInvocationPolicyDecision as aL, WorkflowInvocationPolicyInput as aM, WorkflowInvocationSource as aN, WorkflowInvocationTrigger as aO, WorkflowStartOutcome as aP, KodaXTaskEvidenceBundle as aa, KodaXTaskEvidenceEntry as ab, KodaXTaskRole as ac, KodaXTaskRoleAssignment as ad, KodaXTaskStatus as ae, KodaXTaskSurface as af, KodaXTaskToolPolicy as ag, KodaXTaskVerificationContract as ah, KodaXTaskVerificationCriterion as ai, KodaXTaskWorkItem as aj, KodaXToolEventMeta as ak, KodaXToolExecutionContext as al, KodaXVerificationScorecard as am, KodaXVerificationScorecardCriterion as an, KodaXWorkflowEventMeta as ao, LspServerInfo as aq, LspServiceConfig as as, ProviderExecutionState as at, ProviderRecoveryEvent as au, ProviderResilienceConfig as av, ProviderResiliencePolicy as aw, RecoveryAction as ax, RecoveryDecision as ay, RecoveryLadderStep as az, BashPrefixResult as b, CreateBashPrefixExtractorOptions as c, ExtractCommandPrefixOptions as d, GoalCompleteResult as e, GoalCreateInput as f, GoalLifecycleContext as g, GoalRuntimeBinding as h, GoalRuntimeBindingDeps as i, GoalToolsContext as j, KodaXAgentMode as k, KodaXBudgetDisclosureZone as l, KodaXBudgetExtensionRequest as m, KodaXChildAgentResult as n, KodaXChildContextBundle as o, KodaXChildExecutionResult as p, KodaXCompactionOverride as q, KodaXContextOptions as r, KodaXContextTokenSnapshot as s, KodaXEvents as t, KodaXFanoutBranchLifecycle as u, KodaXFanoutBranchRecord as v, KodaXFanoutBranchTransition as w, KodaXFanoutSchedulerInput as x, KodaXFanoutSchedulerPlan as y, KodaXInputArtifact as z };
|