@kodax-ai/kodax 0.7.41 → 0.7.43
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 +119 -3
- package/README.md +214 -286
- package/README_CN.md +173 -277
- package/dist/chunks/chunk-7G5PSL6C.js +830 -0
- package/dist/chunks/{chunk-6OB4AJOM.js → chunk-IYSK7LUK.js} +1 -1
- package/dist/chunks/chunk-K75O2CAE.js +31 -0
- package/dist/chunks/chunk-UG4262JI.js +502 -0
- package/dist/chunks/chunk-VHKAJDQD.js +425 -0
- package/dist/chunks/chunk-YMRZBS4G.js +2 -0
- package/dist/chunks/{compaction-config-LT5PEXPT.js → compaction-config-3E57ABCT.js} +1 -1
- package/dist/chunks/{construction-bootstrap-HBCWJFHC.js → construction-bootstrap-JR63KI5N.js} +4 -4
- package/dist/chunks/dist-KWHUKXEL.js +2 -0
- package/dist/chunks/dist-XANXEVTU.js +2 -0
- package/dist/chunks/utils-HQ2QCKJA.js +2 -0
- package/dist/index.d.ts +15 -10
- package/dist/index.js +5 -5
- package/dist/kodax_cli.js +1084 -1054
- package/dist/sdk-agent.d.ts +853 -135
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +932 -981
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.d.ts +8 -5
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.d.ts +17 -0
- package/dist/sdk-mcp.js +2 -0
- package/dist/sdk-repl.d.ts +343 -10
- package/dist/sdk-repl.js +2 -1
- package/dist/sdk-session.d.ts +176 -0
- package/dist/sdk-session.js +2 -0
- package/dist/sdk-skills.d.ts +72 -4
- package/dist/sdk-skills.js +1 -1
- package/dist/types-chunks/{cost-tracker.d-C4dMlQuV.d.ts → base.d-FUJahC0i.d.ts} +22 -112
- package/dist/types-chunks/{bash-prefix-extractor.d-B2iliwdi.d.ts → bash-prefix-extractor.d-DMrGImMl.d.ts} +266 -228
- package/dist/types-chunks/capability.d-3C62G8Eq.d.ts +39 -0
- package/dist/types-chunks/config.d-BfJUXxC0.d.ts +41 -0
- package/dist/types-chunks/cost-tracker.d-wRtyEW9d.d.ts +110 -0
- package/dist/types-chunks/{history-cleanup.d-q1vAvCss.d.ts → file-tracker.d-zaLZeNBK.d.ts} +532 -15
- package/dist/types-chunks/manager.d-87belpiS.d.ts +370 -0
- package/dist/types-chunks/{resolver.d-BwD6TKz7.d.ts → resolver.d-CA68_NeH.d.ts} +150 -5
- package/dist/types-chunks/storage.d-DPAEX7zS.d.ts +115 -0
- package/dist/types-chunks/{capability.d-BxNgd1-c.d.ts → types.d-B1uGoVTE.d.ts} +72 -40
- package/dist/types-chunks/{instance-discovery.d-DZhp77vb.d.ts → types.d-CKJtjo-6.d.ts} +168 -258
- package/dist/types-chunks/types.d-mM8vqvhT.d.ts +254 -0
- package/dist/types-chunks/{storage.d-Bv9T99Qu.d.ts → utils.d-DkLZD_wa.d.ts} +38 -112
- package/package.json +15 -6
- package/dist/chunks/chunk-5TFLMGER.js +0 -2
- package/dist/chunks/chunk-6QO6HWGU.js +0 -30
- package/dist/chunks/chunk-EQ5DGS2W.js +0 -14
- package/dist/chunks/chunk-HYWVRTFA.js +0 -1233
- package/dist/chunks/chunk-SX2IS5JP.js +0 -16
- package/dist/chunks/chunk-ZPJPNLBK.js +0 -462
- package/dist/chunks/dist-M57GIWR4.js +0 -2
- package/dist/chunks/dist-V3BS2NKB.js +0 -2
- package/dist/chunks/utils-FAFUQJ2A.js +0 -2
|
@@ -1,255 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @kodax-ai/agent Types
|
|
5
|
-
*
|
|
6
|
-
* 通用 Agent 类型定义
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
type KodaXJsonPrimitive = string | number | boolean | null;
|
|
10
|
-
type KodaXJsonValue = KodaXJsonPrimitive | KodaXJsonValue[] | {
|
|
11
|
-
[key: string]: KodaXJsonValue;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Session error metadata - 会话错误元数据
|
|
15
|
-
* Used for error recovery and session cleanup - 用于错误恢复和会话清理
|
|
16
|
-
*/
|
|
17
|
-
interface SessionErrorMetadata {
|
|
18
|
-
/** Last error message - 最后的错误消息 */
|
|
19
|
-
lastError?: string;
|
|
20
|
-
/** Last error timestamp - 最后错误时间戳 */
|
|
21
|
-
lastErrorTime?: number;
|
|
22
|
-
/** Consecutive error count - 连续错误计数 */
|
|
23
|
-
consecutiveErrors: number;
|
|
24
|
-
}
|
|
25
|
-
interface KodaXExtensionSessionRecord {
|
|
26
|
-
id: string;
|
|
27
|
-
extensionId: string;
|
|
28
|
-
type: string;
|
|
29
|
-
ts: number;
|
|
30
|
-
data?: KodaXJsonValue;
|
|
31
|
-
dedupeKey?: string;
|
|
32
|
-
}
|
|
33
|
-
type KodaXExtensionSessionState = Record<string, Record<string, KodaXJsonValue>>;
|
|
34
|
-
interface KodaXSessionEntryBase {
|
|
35
|
-
id: string;
|
|
36
|
-
parentId: string | null;
|
|
37
|
-
timestamp: string;
|
|
38
|
-
}
|
|
39
|
-
interface KodaXSessionMessageEntry extends KodaXSessionEntryBase {
|
|
40
|
-
type: 'message';
|
|
41
|
-
message: KodaXMessage;
|
|
42
|
-
}
|
|
43
|
-
interface KodaXSessionCompactionEntry extends KodaXSessionEntryBase {
|
|
44
|
-
type: 'compaction';
|
|
45
|
-
summary: string;
|
|
46
|
-
firstKeptEntryId?: string;
|
|
47
|
-
tokensBefore?: number;
|
|
48
|
-
tokensAfter?: number;
|
|
49
|
-
artifactLedgerId?: string;
|
|
50
|
-
reason?: string;
|
|
51
|
-
details?: KodaXJsonValue;
|
|
52
|
-
memorySeed?: KodaXCompactMemorySeed;
|
|
53
|
-
/**
|
|
54
|
-
* FEATURE_072: post-compact ledger summary + file-content messages that
|
|
55
|
-
* are inlined after the compaction summary at slicer time
|
|
56
|
-
* (`getSessionMessagesFromLineage`). Stored here so they leave the active
|
|
57
|
-
* path automatically when a new compaction entry is appended.
|
|
58
|
-
*
|
|
59
|
-
* NOTE: attachments are emitted by the slicer, NOT by `getContextMessagesForEntry`
|
|
60
|
-
* — preserving the latter's 1-to-1 contract that `entryMatchesContextMessage`
|
|
61
|
-
* and FEATURE_073's future slicing both depend on.
|
|
62
|
-
*/
|
|
63
|
-
postCompactAttachments?: readonly KodaXMessage[];
|
|
64
|
-
}
|
|
65
|
-
interface KodaXSessionBranchSummaryEntry extends KodaXSessionEntryBase {
|
|
66
|
-
type: 'branch_summary';
|
|
67
|
-
summary: string;
|
|
68
|
-
fromId?: string;
|
|
69
|
-
details?: KodaXJsonValue;
|
|
70
|
-
}
|
|
71
|
-
interface KodaXSessionLabelEntry extends KodaXSessionEntryBase {
|
|
72
|
-
type: 'label';
|
|
73
|
-
targetId: string;
|
|
74
|
-
label?: string;
|
|
75
|
-
}
|
|
76
|
-
interface KodaXSessionArchiveMarkerEntry extends KodaXSessionEntryBase {
|
|
77
|
-
type: 'archive_marker';
|
|
78
|
-
/** Links to the corresponding batch in the .archive.jsonl sidecar file */
|
|
79
|
-
archiveBatchId: string;
|
|
80
|
-
/** Number of entries that were archived in this batch */
|
|
81
|
-
archivedEntryCount: number;
|
|
82
|
-
/** Brief summary of the archived content */
|
|
83
|
-
summary: string;
|
|
84
|
-
}
|
|
85
|
-
type KodaXSessionEntry = KodaXSessionMessageEntry | KodaXSessionCompactionEntry | KodaXSessionBranchSummaryEntry | KodaXSessionLabelEntry | KodaXSessionArchiveMarkerEntry;
|
|
86
|
-
interface KodaXSessionArtifactLedgerEntry {
|
|
87
|
-
id: string;
|
|
88
|
-
kind: 'file_read' | 'file_modified' | 'file_created' | 'file_deleted' | 'path_scope' | 'search_scope' | 'command_scope' | 'check_result' | 'decision' | 'image_input' | 'tombstone';
|
|
89
|
-
sourceTool?: string;
|
|
90
|
-
action?: string;
|
|
91
|
-
target: string;
|
|
92
|
-
displayTarget?: string;
|
|
93
|
-
summary?: string;
|
|
94
|
-
sessionEntryId?: string;
|
|
95
|
-
timestamp: string;
|
|
96
|
-
metadata?: Record<string, KodaXJsonValue>;
|
|
97
|
-
}
|
|
98
|
-
interface KodaXCompactMemoryProgress {
|
|
99
|
-
completed: string[];
|
|
100
|
-
inProgress: string[];
|
|
101
|
-
blockers: string[];
|
|
102
|
-
}
|
|
103
|
-
interface KodaXCompactMemorySeed {
|
|
104
|
-
objective?: string;
|
|
105
|
-
constraints: string[];
|
|
106
|
-
progress: KodaXCompactMemoryProgress;
|
|
107
|
-
keyDecisions: string[];
|
|
108
|
-
nextSteps: string[];
|
|
109
|
-
keyContext: string[];
|
|
110
|
-
importantTargets: string[];
|
|
111
|
-
tombstones: string[];
|
|
112
|
-
}
|
|
113
|
-
interface KodaXSessionLineage {
|
|
114
|
-
version: 2;
|
|
115
|
-
activeEntryId: string | null;
|
|
116
|
-
entries: KodaXSessionEntry[];
|
|
117
|
-
}
|
|
118
|
-
interface KodaXSessionNavigationOptions {
|
|
119
|
-
summarizeCurrentBranch?: boolean;
|
|
120
|
-
}
|
|
121
|
-
interface KodaXSessionTreeNode {
|
|
122
|
-
entry: Exclude<KodaXSessionEntry, KodaXSessionLabelEntry>;
|
|
123
|
-
children: KodaXSessionTreeNode[];
|
|
124
|
-
label?: string;
|
|
125
|
-
active: boolean;
|
|
126
|
-
}
|
|
127
|
-
type KodaXSessionScope = 'user' | 'managed-task-worker';
|
|
128
|
-
type KodaXSessionUiHistoryItemType = 'user' | 'assistant' | 'system' | 'thinking' | 'error' | 'event' | 'info' | 'hint';
|
|
129
|
-
interface KodaXSessionUiHistoryItem {
|
|
130
|
-
type: KodaXSessionUiHistoryItemType;
|
|
131
|
-
text: string;
|
|
132
|
-
icon?: string;
|
|
133
|
-
compactText?: string;
|
|
134
|
-
}
|
|
135
|
-
type KodaXSessionWorkspaceKind = 'detected' | 'managed';
|
|
136
|
-
interface KodaXSessionRuntimeInfo {
|
|
137
|
-
canonicalRepoRoot?: string;
|
|
138
|
-
workspaceRoot?: string;
|
|
139
|
-
executionCwd?: string;
|
|
140
|
-
branch?: string;
|
|
141
|
-
workspaceKind?: KodaXSessionWorkspaceKind;
|
|
142
|
-
}
|
|
143
|
-
interface KodaXSessionData {
|
|
144
|
-
messages: KodaXMessage[];
|
|
145
|
-
title: string;
|
|
146
|
-
gitRoot: string;
|
|
147
|
-
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
148
|
-
scope?: KodaXSessionScope;
|
|
149
|
-
uiHistory?: KodaXSessionUiHistoryItem[];
|
|
150
|
-
errorMetadata?: SessionErrorMetadata;
|
|
151
|
-
extensionState?: KodaXExtensionSessionState;
|
|
152
|
-
extensionRecords?: KodaXExtensionSessionRecord[];
|
|
153
|
-
lineage?: KodaXSessionLineage;
|
|
154
|
-
artifactLedger?: KodaXSessionArtifactLedgerEntry[];
|
|
155
|
-
}
|
|
156
|
-
interface KodaXSessionMeta {
|
|
157
|
-
_type: 'meta';
|
|
158
|
-
title: string;
|
|
159
|
-
id: string;
|
|
160
|
-
gitRoot: string;
|
|
161
|
-
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
162
|
-
createdAt: string;
|
|
163
|
-
scope?: KodaXSessionScope;
|
|
164
|
-
uiHistory?: KodaXSessionUiHistoryItem[];
|
|
165
|
-
extensionState?: KodaXExtensionSessionState;
|
|
166
|
-
extensionRecordCount?: number;
|
|
167
|
-
artifactLedgerCount?: number;
|
|
168
|
-
lineageVersion?: 2;
|
|
169
|
-
activeEntryId?: string | null;
|
|
170
|
-
lineageEntryCount?: number;
|
|
171
|
-
activeMessageCount?: number;
|
|
172
|
-
/** Error metadata for recovery - 错误元数据用于恢复 */
|
|
173
|
-
errorMetadata?: SessionErrorMetadata;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Extension-scoped persistence entry.
|
|
177
|
-
*
|
|
178
|
-
* Each entry belongs to a namespace (extensionId) and carries
|
|
179
|
-
* a string key, a JSON-safe value, and an opaque version tag
|
|
180
|
-
* used for optimistic concurrency control.
|
|
181
|
-
*/
|
|
182
|
-
interface KodaXExtensionStoreEntry {
|
|
183
|
-
key: string;
|
|
184
|
-
value: KodaXJsonValue;
|
|
185
|
-
version: string;
|
|
186
|
-
updatedAt: number;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Extension persistence store interface (FEATURE_034 manual persistence).
|
|
190
|
-
*
|
|
191
|
-
* Implementations provide a durable key-value store scoped to a single
|
|
192
|
-
* extension identity. The store is independent of session lifecycle —
|
|
193
|
-
* data survives across sessions and restarts.
|
|
194
|
-
*/
|
|
195
|
-
interface KodaXExtensionStore {
|
|
196
|
-
/**
|
|
197
|
-
* Read a single key.
|
|
198
|
-
* Returns `undefined` when the key does not exist.
|
|
199
|
-
*/
|
|
200
|
-
get(key: string): Promise<KodaXExtensionStoreEntry | undefined>;
|
|
201
|
-
/**
|
|
202
|
-
* Write a key-value pair.
|
|
203
|
-
*
|
|
204
|
-
* When `expectedVersion` is provided the write only succeeds when the
|
|
205
|
-
* stored entry's version still matches (optimistic concurrency).
|
|
206
|
-
* Returns the new entry on success, or `false` on version mismatch.
|
|
207
|
-
*/
|
|
208
|
-
put(key: string, value: KodaXJsonValue, options?: {
|
|
209
|
-
expectedVersion?: string;
|
|
210
|
-
}): Promise<KodaXExtensionStoreEntry | false>;
|
|
211
|
-
/**
|
|
212
|
-
* Remove a key.
|
|
213
|
-
* Returns `true` when the key existed and was removed.
|
|
214
|
-
*/
|
|
215
|
-
delete(key: string): Promise<boolean>;
|
|
216
|
-
/**
|
|
217
|
-
* List all keys (optionally filtered by prefix).
|
|
218
|
-
*/
|
|
219
|
-
list(options?: {
|
|
220
|
-
prefix?: string;
|
|
221
|
-
}): Promise<string[]>;
|
|
222
|
-
/**
|
|
223
|
-
* Clear all keys (optionally filtered by prefix).
|
|
224
|
-
* Returns the number of entries removed.
|
|
225
|
-
*/
|
|
226
|
-
clear(options?: {
|
|
227
|
-
prefix?: string;
|
|
228
|
-
}): Promise<number>;
|
|
229
|
-
}
|
|
230
|
-
interface KodaXSessionStorage {
|
|
231
|
-
save(id: string, data: KodaXSessionData): Promise<void>;
|
|
232
|
-
load(id: string): Promise<KodaXSessionData | null>;
|
|
233
|
-
getLineage?(id: string): Promise<KodaXSessionLineage | null>;
|
|
234
|
-
setActiveEntry?(id: string, selector: string, options?: KodaXSessionNavigationOptions): Promise<KodaXSessionData | null>;
|
|
235
|
-
setLabel?(id: string, selector: string, label?: string): Promise<KodaXSessionData | null>;
|
|
236
|
-
rewind?(id: string, selector?: string): Promise<KodaXSessionData | null>;
|
|
237
|
-
fork?(id: string, selector?: string, options?: {
|
|
238
|
-
sessionId?: string;
|
|
239
|
-
title?: string;
|
|
240
|
-
}): Promise<{
|
|
241
|
-
sessionId: string;
|
|
242
|
-
data: KodaXSessionData;
|
|
243
|
-
} | null>;
|
|
244
|
-
list?(gitRoot?: string): Promise<Array<{
|
|
245
|
-
id: string;
|
|
246
|
-
title: string;
|
|
247
|
-
msgCount: number;
|
|
248
|
-
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
249
|
-
}>>;
|
|
250
|
-
delete?(id: string): Promise<void>;
|
|
251
|
-
deleteAll?(gitRoot?: string): Promise<void>;
|
|
252
|
-
}
|
|
1
|
+
import { X as KodaXToolDefinition, m as KodaXMessage, D as KodaXReasoningMode, Z as KodaXToolResultContentItem, T as KodaXThinkingBlock, G as KodaXRedactedThinkingBlock } from './types.d-B1uGoVTE.js';
|
|
2
|
+
import { a as KodaXCompactMemorySeed, h as KodaXSessionArtifactLedgerEntry } from './types.d-mM8vqvhT.js';
|
|
253
3
|
|
|
254
4
|
/**
|
|
255
5
|
* Layer A Primitive: Agent / Handoff / Guardrail / AgentReasoningProfile
|
|
@@ -369,6 +119,17 @@ interface Agent<TContext = unknown> {
|
|
|
369
119
|
readonly handoffs?: readonly Handoff[];
|
|
370
120
|
readonly reasoning?: AgentReasoningProfile;
|
|
371
121
|
readonly guardrails?: readonly Guardrail[];
|
|
122
|
+
/**
|
|
123
|
+
* FEATURE_191 — one-sentence human-readable summary surfaced to
|
|
124
|
+
* other agents that may dispatch this one (e.g., via the
|
|
125
|
+
* `dispatch_child_task(subagent_type=<name>)` Worker SP block). The
|
|
126
|
+
* field propagates from `AgentContent.description` when the agent is
|
|
127
|
+
* built via the construction substrate; built-in / SDK-created
|
|
128
|
+
* agents may set it directly. Optional for backward compatibility
|
|
129
|
+
* with the FEATURE_089 minimal-agent shape and pre-FEATURE_191
|
|
130
|
+
* built-ins.
|
|
131
|
+
*/
|
|
132
|
+
readonly description?: string;
|
|
372
133
|
/** Reserved for structured-output agents; not consumed in v0.7.23. */
|
|
373
134
|
readonly outputSchema?: unknown;
|
|
374
135
|
readonly model?: string;
|
|
@@ -508,12 +269,29 @@ interface FanoutSpanData {
|
|
|
508
269
|
readonly winnerChildId?: string;
|
|
509
270
|
readonly cancelledChildIds?: readonly string[];
|
|
510
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* FEATURE_184 (v0.7.45) — Stop hook observability.
|
|
274
|
+
*
|
|
275
|
+
* Emitted when the Runner's `RunOptions.stopHook` is invoked or fails.
|
|
276
|
+
* `outcome` records what the hook returned (or `'error'` for thrown
|
|
277
|
+
* exceptions — fail-open path), `reanimateCount` is the running count
|
|
278
|
+
* after this invocation. `reason` carries the abort/reanimate text
|
|
279
|
+
* when relevant, truncated by consumers as needed.
|
|
280
|
+
*/
|
|
281
|
+
interface StopHookSpanData {
|
|
282
|
+
readonly kind: 'stop-hook';
|
|
283
|
+
readonly outcome: 'accept' | 'reanimate' | 'abort' | 'budget-exhausted' | 'error';
|
|
284
|
+
readonly reanimateCount: number;
|
|
285
|
+
readonly reanimateBudget: number;
|
|
286
|
+
readonly reason?: string;
|
|
287
|
+
readonly error?: string;
|
|
288
|
+
}
|
|
511
289
|
/**
|
|
512
290
|
* Discriminated union of all span payload shapes. Additional variants may
|
|
513
291
|
* be added in future features — consumers should check `kind` before
|
|
514
292
|
* reading specific fields.
|
|
515
293
|
*/
|
|
516
|
-
type SpanData = AgentSpanData | GenerationSpanData | ToolCallSpanData | HandoffSpanData | CompactionSpanData | GuardrailSpanData | EvidenceSpanData | FanoutSpanData;
|
|
294
|
+
type SpanData = AgentSpanData | GenerationSpanData | ToolCallSpanData | HandoffSpanData | CompactionSpanData | GuardrailSpanData | EvidenceSpanData | FanoutSpanData | StopHookSpanData;
|
|
517
295
|
|
|
518
296
|
/**
|
|
519
297
|
* Span — a single timed unit of work inside a Trace.
|
|
@@ -552,6 +330,41 @@ interface Span {
|
|
|
552
330
|
setError(err: SpanError | Error): void;
|
|
553
331
|
end(): void;
|
|
554
332
|
}
|
|
333
|
+
interface SpanImplOptions {
|
|
334
|
+
readonly id: string;
|
|
335
|
+
readonly traceId: string;
|
|
336
|
+
readonly parentId?: string;
|
|
337
|
+
readonly name: string;
|
|
338
|
+
readonly data: SpanData;
|
|
339
|
+
readonly startedAt?: number;
|
|
340
|
+
readonly now?: () => number;
|
|
341
|
+
readonly nextSpanId?: () => string;
|
|
342
|
+
readonly onChildCreated?: (span: Span) => void;
|
|
343
|
+
readonly onSpanEnd?: (span: Span) => void;
|
|
344
|
+
}
|
|
345
|
+
declare class SpanImpl implements Span {
|
|
346
|
+
readonly id: string;
|
|
347
|
+
readonly traceId: string;
|
|
348
|
+
readonly parentId?: string;
|
|
349
|
+
readonly name: string;
|
|
350
|
+
readonly data: SpanData;
|
|
351
|
+
readonly startedAt: number;
|
|
352
|
+
private _endedAt?;
|
|
353
|
+
private _error?;
|
|
354
|
+
private readonly _children;
|
|
355
|
+
private readonly now;
|
|
356
|
+
private readonly nextSpanId;
|
|
357
|
+
private readonly onChildCreated?;
|
|
358
|
+
private readonly onSpanEnd?;
|
|
359
|
+
private _ended;
|
|
360
|
+
constructor(opts: SpanImplOptions);
|
|
361
|
+
get endedAt(): number | undefined;
|
|
362
|
+
get error(): SpanError | undefined;
|
|
363
|
+
get children(): readonly Span[];
|
|
364
|
+
addChild(name: string, data: SpanData): Span;
|
|
365
|
+
setError(err: SpanError | Error): void;
|
|
366
|
+
end(): void;
|
|
367
|
+
}
|
|
555
368
|
|
|
556
369
|
/**
|
|
557
370
|
* Runner Tool Loop — FEATURE_084 Shard 1 (v0.7.26).
|
|
@@ -644,11 +457,18 @@ interface RunnerToolContext {
|
|
|
644
457
|
readonly toolCallId?: string;
|
|
645
458
|
}
|
|
646
459
|
/**
|
|
647
|
-
* Value returned by `RunnableTool.execute`. The `content`
|
|
648
|
-
*
|
|
460
|
+
* Value returned by `RunnableTool.execute`. The `content` is what the LLM
|
|
461
|
+
* sees in the next turn as `tool_result`:
|
|
462
|
+
*
|
|
463
|
+
* - `string` — plain text (the default for most tools).
|
|
464
|
+
* - `readonly KodaXToolResultContentItem[]` — an array of typed items
|
|
465
|
+
* (text + image), used by multimodal tools like `read` on an image
|
|
466
|
+
* path. Provider serializers lower each item to the wire format
|
|
467
|
+
* (Anthropic accepts inline; OpenAI-compat downgrades image to text
|
|
468
|
+
* placeholder).
|
|
649
469
|
*/
|
|
650
470
|
interface RunnerToolResult {
|
|
651
|
-
readonly content: string;
|
|
471
|
+
readonly content: string | readonly KodaXToolResultContentItem[];
|
|
652
472
|
readonly isError?: boolean;
|
|
653
473
|
readonly metadata?: Record<string, unknown>;
|
|
654
474
|
}
|
|
@@ -1050,6 +870,15 @@ interface SessionStateSnapshot {
|
|
|
1050
870
|
* working on: <X>" without owning the todo store.
|
|
1051
871
|
*/
|
|
1052
872
|
readonly currentTodoSummary?: CurrentTodoSummary;
|
|
873
|
+
/**
|
|
874
|
+
* v0.7.43 (FEATURE_173 Part B follow-up) — REPL session id
|
|
875
|
+
* (e.g. `YYYYMMDD_HHMMSS`). Lets `listRunningSessions()` correlate
|
|
876
|
+
* a sibling instance with its `.jsonl` file. Mutable: starts
|
|
877
|
+
* undefined during bootstrap, set after `createInteractiveContext`,
|
|
878
|
+
* re-published on `/new`. Older writers omit this; readers MUST
|
|
879
|
+
* treat as optional.
|
|
880
|
+
*/
|
|
881
|
+
readonly sessionId?: string;
|
|
1053
882
|
}
|
|
1054
883
|
interface RecentlyModifiedFile {
|
|
1055
884
|
readonly path: string;
|
|
@@ -1213,5 +1042,86 @@ interface DiscoveryOptions {
|
|
|
1213
1042
|
*/
|
|
1214
1043
|
declare function discoverInstances(options?: DiscoveryOptions): DiscoveredInstance[];
|
|
1215
1044
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1045
|
+
/**
|
|
1046
|
+
* ../../index.js Compaction Types
|
|
1047
|
+
*/
|
|
1048
|
+
|
|
1049
|
+
interface CompactionConfig {
|
|
1050
|
+
/** Whether automatic compaction is enabled. */
|
|
1051
|
+
enabled: boolean;
|
|
1052
|
+
/** Trigger compaction when context usage exceeds this percentage of the window. */
|
|
1053
|
+
triggerPercent: number;
|
|
1054
|
+
/**
|
|
1055
|
+
* @deprecated V2 compaction no longer uses this option.
|
|
1056
|
+
*
|
|
1057
|
+
* The system now combines protected recent context, lightweight pruning, and
|
|
1058
|
+
* rolling summaries automatically.
|
|
1059
|
+
*/
|
|
1060
|
+
keepRecentPercent?: number;
|
|
1061
|
+
/** Percentage of the most recent context that is never compacted or pruned. Defaults to 20. */
|
|
1062
|
+
protectionPercent?: number;
|
|
1063
|
+
/**
|
|
1064
|
+
* Percentage of the context window used as the chunk size for each rolling
|
|
1065
|
+
* summary pass. Defaults to 10.
|
|
1066
|
+
*/
|
|
1067
|
+
rollingSummaryPercent?: number;
|
|
1068
|
+
/** Prune oversized tool results when they exceed roughly this many tokens. Defaults to 500. */
|
|
1069
|
+
pruningThresholdTokens?: number;
|
|
1070
|
+
/**
|
|
1071
|
+
* Gap ratio for prune fast-return. After pruning, if remaining tokens still exceed
|
|
1072
|
+
* triggerTokens * pruningGapRatio, the system continues to the summarization path
|
|
1073
|
+
* instead of returning early. Defaults to 0.8.
|
|
1074
|
+
*/
|
|
1075
|
+
pruningGapRatio?: number;
|
|
1076
|
+
/** Optional override for the provider context window. */
|
|
1077
|
+
contextWindow?: number;
|
|
1078
|
+
}
|
|
1079
|
+
interface CompactionDetails {
|
|
1080
|
+
readFiles: string[];
|
|
1081
|
+
modifiedFiles: string[];
|
|
1082
|
+
}
|
|
1083
|
+
interface CompactionAnchor {
|
|
1084
|
+
summary: string;
|
|
1085
|
+
tokensBefore: number;
|
|
1086
|
+
tokensAfter: number;
|
|
1087
|
+
entriesRemoved: number;
|
|
1088
|
+
reason: string;
|
|
1089
|
+
artifactLedgerId?: string;
|
|
1090
|
+
details?: CompactionDetails;
|
|
1091
|
+
memorySeed?: KodaXCompactMemorySeed;
|
|
1092
|
+
}
|
|
1093
|
+
interface CompactionUpdate {
|
|
1094
|
+
anchor?: CompactionAnchor;
|
|
1095
|
+
artifactLedger?: KodaXSessionArtifactLedgerEntry[];
|
|
1096
|
+
memorySeed?: KodaXCompactMemorySeed;
|
|
1097
|
+
/**
|
|
1098
|
+
* FEATURE_072: ledger-summary + file-content messages produced by
|
|
1099
|
+
* `buildPostCompactAttachments` + `buildFileContentMessages`. Agent.ts
|
|
1100
|
+
* passes these separately from the kept-tail messages so REPL-side
|
|
1101
|
+
* `applySessionCompaction` can store them natively on the CompactionEntry
|
|
1102
|
+
* rather than inlining them as loose `[Post-compact: ...]` system messages
|
|
1103
|
+
* in lineage. Agent.ts keeps inlining them into its local flat `messages`
|
|
1104
|
+
* via `injectPostCompactAttachments` (P4 belt-and-suspenders); the lineage
|
|
1105
|
+
* is the persistence source of truth.
|
|
1106
|
+
*/
|
|
1107
|
+
postCompactAttachments?: readonly KodaXMessage[];
|
|
1108
|
+
}
|
|
1109
|
+
interface CompactionResult {
|
|
1110
|
+
compacted: boolean;
|
|
1111
|
+
messages: KodaXMessage[];
|
|
1112
|
+
summary?: string;
|
|
1113
|
+
tokensBefore: number;
|
|
1114
|
+
tokensAfter: number;
|
|
1115
|
+
entriesRemoved: number;
|
|
1116
|
+
details?: CompactionDetails;
|
|
1117
|
+
artifactLedger?: KodaXSessionArtifactLedgerEntry[];
|
|
1118
|
+
anchor?: CompactionAnchor;
|
|
1119
|
+
memorySeed?: KodaXCompactMemorySeed;
|
|
1120
|
+
}
|
|
1121
|
+
interface FileOperations {
|
|
1122
|
+
readFiles: string[];
|
|
1123
|
+
modifiedFiles: string[];
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
export { MAX_TOOL_LOOP_ITERATIONS as M, SpanImpl as X, buildAssistantMessageFromLlmResult as a5, buildToolResultMessage as a6, collectGuardrails as a7, createAgent as a8, createHandoff as a9, createStateWriter as aa, discoverInstances as ab, executeRunnerToolCall as ac, isRunnableTool as ad, isRunnerLlmResult as ae, registerChildTask as af, requestTaskStop as ag, runInputGuardrails as ah, runOutputGuardrails as ai, runToolAfterGuardrails as aj, runToolBeforeGuardrails as ak, GuardrailBlockedError as p, GuardrailEscalateError as r };
|
|
1127
|
+
export type { StateWriterOptions as $, Agent as A, RunnerLlmResult as B, ChildTaskRegistry as C, DiscoveredInstance as D, EvidenceSpanData as E, FanoutSpanData as F, GenerationSpanData as G, Handoff as H, InputGuardrail as I, RunnerLlmReturn as J, RunnerToolCall as K, RunnerToolContext as L, RunnerToolObserver as N, OutputGuardrail as O, PersistedSessionState as P, RunnerToolResult as Q, ReasoningDepth as R, SessionMeta as S, SessionStateSnapshot as T, Span as U, SpanData as V, SpanError as W, SpanImplOptions as Y, StateWriter as Z, StateWriterFs as _, AgentMessage as a, StopHookSpanData as a0, TaskAbortRegistry as a1, ToolBeforeOutcome as a2, ToolCallSpanData as a3, ToolGuardrail as a4, AgentMiddlewareDeclaration as b, AgentReasoningProfile as c, AgentSpanData as d, AgentTool as e, CompactionAnchor as f, CompactionConfig as g, CompactionDetails as h, CompactionResult as i, CompactionSpanData as j, CompactionUpdate as k, CurrentTodoSummary as l, DiscoveryOptions as m, FileOperations as n, Guardrail as o, GuardrailContext as q, GuardrailSpanData as s, GuardrailVerdict as t, HandoffSpanData as u, InstanceDiscoveryFs as v, RecentlyModifiedFile as w, RequestTaskStopOptions as x, RequestTaskStopResult as y, RunnableTool as z };
|