@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,5 +1,318 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { o as KodaXMessage, $ as KodaXToolDefinition, G as KodaXReasoningMode, a1 as KodaXToolResultContentItem, X as KodaXThinkingBlock, J as KodaXRedactedThinkingBlock } from './base.d-GZ6jvICS.js';
|
|
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 KodaXGoalStatus = 'active' | 'paused' | 'budget_limited' | 'blocked' | 'complete';
|
|
86
|
+
/**
|
|
87
|
+
* Persistent user-set goal state. v0.7.44 FEATURE_192 — backs the
|
|
88
|
+
* `/goal` slash command and the get_goal / create_goal / update_goal
|
|
89
|
+
* tools.
|
|
90
|
+
*
|
|
91
|
+
* Persistence model: each lifecycle event (create / update / pause /
|
|
92
|
+
* resume / clear / budget_limited / blocked / complete) appends a
|
|
93
|
+
* `KodaXSessionGoalEntry` carrying a frozen `KodaXGoalState` snapshot
|
|
94
|
+
* to the session lineage. `readLatestGoalFromBranch` walks the active
|
|
95
|
+
* branch's message-entry IDs and returns the latest goal entry whose
|
|
96
|
+
* parentId belongs to that branch — so forks and rewinds naturally
|
|
97
|
+
* drop goals attached to abandoned message paths.
|
|
98
|
+
*/
|
|
99
|
+
interface KodaXGoalState {
|
|
100
|
+
readonly version: 1;
|
|
101
|
+
/** `${createdAt}-${rand}` — stable across updates of the same goal. */
|
|
102
|
+
readonly id: string;
|
|
103
|
+
readonly objective: string;
|
|
104
|
+
readonly status: KodaXGoalStatus;
|
|
105
|
+
/** Optional explicit token budget; null when the user did not set one. */
|
|
106
|
+
readonly tokenBudget: number | null;
|
|
107
|
+
readonly tokensUsed: number;
|
|
108
|
+
readonly timeUsedSeconds: number;
|
|
109
|
+
/** Consecutive turns the model has reported the same blocker. */
|
|
110
|
+
readonly blockerTurnCount: number;
|
|
111
|
+
/** The blocker_kind string the model last reported, or null. */
|
|
112
|
+
readonly lastBlockerKind: string | null;
|
|
113
|
+
readonly createdAt: number;
|
|
114
|
+
readonly updatedAt: number;
|
|
115
|
+
}
|
|
116
|
+
type KodaXGoalEventType = 'created' | 'updated' | 'paused' | 'resumed' | 'cleared' | 'budget_limited' | 'blocked' | 'complete';
|
|
117
|
+
interface KodaXSessionGoalEntry extends KodaXSessionEntryBase {
|
|
118
|
+
type: 'goal';
|
|
119
|
+
/** Snapshot at time of event; `null` only when `event === 'cleared'`. */
|
|
120
|
+
goal: KodaXGoalState | null;
|
|
121
|
+
event: KodaXGoalEventType;
|
|
122
|
+
}
|
|
123
|
+
type KodaXSessionEntry = KodaXSessionMessageEntry | KodaXSessionCompactionEntry | KodaXSessionBranchSummaryEntry | KodaXSessionLabelEntry | KodaXSessionArchiveMarkerEntry | KodaXSessionGoalEntry;
|
|
124
|
+
interface KodaXSessionArtifactLedgerEntry {
|
|
125
|
+
id: string;
|
|
126
|
+
kind: 'file_read' | 'file_modified' | 'file_created' | 'file_deleted' | 'path_scope' | 'search_scope' | 'command_scope' | 'check_result' | 'decision' | 'image_input' | 'tombstone';
|
|
127
|
+
sourceTool?: string;
|
|
128
|
+
action?: string;
|
|
129
|
+
target: string;
|
|
130
|
+
displayTarget?: string;
|
|
131
|
+
summary?: string;
|
|
132
|
+
sessionEntryId?: string;
|
|
133
|
+
timestamp: string;
|
|
134
|
+
metadata?: Record<string, KodaXJsonValue>;
|
|
135
|
+
}
|
|
136
|
+
interface KodaXCompactMemoryProgress {
|
|
137
|
+
completed: string[];
|
|
138
|
+
inProgress: string[];
|
|
139
|
+
blockers: string[];
|
|
140
|
+
}
|
|
141
|
+
interface KodaXCompactMemorySeed {
|
|
142
|
+
objective?: string;
|
|
143
|
+
constraints: string[];
|
|
144
|
+
progress: KodaXCompactMemoryProgress;
|
|
145
|
+
keyDecisions: string[];
|
|
146
|
+
nextSteps: string[];
|
|
147
|
+
keyContext: string[];
|
|
148
|
+
importantTargets: string[];
|
|
149
|
+
tombstones: string[];
|
|
150
|
+
}
|
|
151
|
+
interface KodaXSessionLineage {
|
|
152
|
+
version: 2;
|
|
153
|
+
activeEntryId: string | null;
|
|
154
|
+
entries: KodaXSessionEntry[];
|
|
155
|
+
}
|
|
156
|
+
interface KodaXSessionNavigationOptions {
|
|
157
|
+
summarizeCurrentBranch?: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface KodaXSessionTreeNode {
|
|
160
|
+
entry: Exclude<KodaXSessionEntry, KodaXSessionLabelEntry | KodaXSessionGoalEntry>;
|
|
161
|
+
children: KodaXSessionTreeNode[];
|
|
162
|
+
label?: string;
|
|
163
|
+
active: boolean;
|
|
164
|
+
}
|
|
165
|
+
type KodaXSessionScope = 'user' | 'managed-task-worker';
|
|
166
|
+
type KodaXSessionUiTextHistoryItemType = 'user' | 'assistant' | 'system' | 'thinking' | 'error' | 'event' | 'info' | 'hint';
|
|
167
|
+
type KodaXSessionUiHistoryItemType = KodaXSessionUiTextHistoryItemType | 'tool_group';
|
|
168
|
+
interface KodaXSessionUiTextHistoryItem {
|
|
169
|
+
type: KodaXSessionUiTextHistoryItemType;
|
|
170
|
+
text: string;
|
|
171
|
+
icon?: string;
|
|
172
|
+
compactText?: string;
|
|
173
|
+
}
|
|
174
|
+
type KodaXSessionUiToolCallStatus = 'success' | 'error' | 'cancelled' | 'awaiting_approval';
|
|
175
|
+
interface KodaXSessionUiToolCall {
|
|
176
|
+
id: string;
|
|
177
|
+
name: string;
|
|
178
|
+
status: KodaXSessionUiToolCallStatus;
|
|
179
|
+
input?: {
|
|
180
|
+
[key: string]: KodaXJsonValue;
|
|
181
|
+
};
|
|
182
|
+
preview?: string;
|
|
183
|
+
output?: string;
|
|
184
|
+
error?: string;
|
|
185
|
+
startTime?: number;
|
|
186
|
+
endTime?: number;
|
|
187
|
+
}
|
|
188
|
+
interface KodaXSessionUiToolGroupHistoryItem {
|
|
189
|
+
type: 'tool_group';
|
|
190
|
+
tools: KodaXSessionUiToolCall[];
|
|
191
|
+
}
|
|
192
|
+
type KodaXSessionUiHistoryItem = KodaXSessionUiTextHistoryItem | KodaXSessionUiToolGroupHistoryItem;
|
|
193
|
+
type KodaXSessionWorkspaceKind = 'detected' | 'managed';
|
|
194
|
+
interface KodaXSessionRuntimeInfo {
|
|
195
|
+
canonicalRepoRoot?: string;
|
|
196
|
+
workspaceRoot?: string;
|
|
197
|
+
executionCwd?: string;
|
|
198
|
+
branch?: string;
|
|
199
|
+
workspaceKind?: KodaXSessionWorkspaceKind;
|
|
200
|
+
}
|
|
201
|
+
interface KodaXSessionData {
|
|
202
|
+
messages: KodaXMessage[];
|
|
203
|
+
title: string;
|
|
204
|
+
gitRoot: string;
|
|
205
|
+
/** Consumer-owned private string persisted with the session. */
|
|
206
|
+
tag?: string;
|
|
207
|
+
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
208
|
+
scope?: KodaXSessionScope;
|
|
209
|
+
uiHistory?: KodaXSessionUiHistoryItem[];
|
|
210
|
+
errorMetadata?: SessionErrorMetadata;
|
|
211
|
+
extensionState?: KodaXExtensionSessionState;
|
|
212
|
+
extensionRecords?: KodaXExtensionSessionRecord[];
|
|
213
|
+
lineage?: KodaXSessionLineage;
|
|
214
|
+
artifactLedger?: KodaXSessionArtifactLedgerEntry[];
|
|
215
|
+
}
|
|
216
|
+
interface KodaXSessionMeta {
|
|
217
|
+
_type: 'meta';
|
|
218
|
+
title: string;
|
|
219
|
+
id: string;
|
|
220
|
+
gitRoot: string;
|
|
221
|
+
/** Consumer-owned private string persisted with the session. */
|
|
222
|
+
tag?: string;
|
|
223
|
+
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
224
|
+
createdAt: string;
|
|
225
|
+
scope?: KodaXSessionScope;
|
|
226
|
+
uiHistory?: KodaXSessionUiHistoryItem[];
|
|
227
|
+
extensionState?: KodaXExtensionSessionState;
|
|
228
|
+
extensionRecordCount?: number;
|
|
229
|
+
artifactLedgerCount?: number;
|
|
230
|
+
lineageVersion?: 2;
|
|
231
|
+
activeEntryId?: string | null;
|
|
232
|
+
lineageEntryCount?: number;
|
|
233
|
+
activeMessageCount?: number;
|
|
234
|
+
/** Error metadata for recovery - 错误元数据用于恢复 */
|
|
235
|
+
errorMetadata?: SessionErrorMetadata;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Extension-scoped persistence entry.
|
|
239
|
+
*
|
|
240
|
+
* Each entry belongs to a namespace (extensionId) and carries
|
|
241
|
+
* a string key, a JSON-safe value, and an opaque version tag
|
|
242
|
+
* used for optimistic concurrency control.
|
|
243
|
+
*/
|
|
244
|
+
interface KodaXExtensionStoreEntry {
|
|
245
|
+
key: string;
|
|
246
|
+
value: KodaXJsonValue;
|
|
247
|
+
version: string;
|
|
248
|
+
updatedAt: number;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Extension persistence store interface (FEATURE_034 manual persistence).
|
|
252
|
+
*
|
|
253
|
+
* Implementations provide a durable key-value store scoped to a single
|
|
254
|
+
* extension identity. The store is independent of session lifecycle —
|
|
255
|
+
* data survives across sessions and restarts.
|
|
256
|
+
*/
|
|
257
|
+
interface KodaXExtensionStore {
|
|
258
|
+
/**
|
|
259
|
+
* Read a single key.
|
|
260
|
+
* Returns `undefined` when the key does not exist.
|
|
261
|
+
*/
|
|
262
|
+
get(key: string): Promise<KodaXExtensionStoreEntry | undefined>;
|
|
263
|
+
/**
|
|
264
|
+
* Write a key-value pair.
|
|
265
|
+
*
|
|
266
|
+
* When `expectedVersion` is provided the write only succeeds when the
|
|
267
|
+
* stored entry's version still matches (optimistic concurrency).
|
|
268
|
+
* Returns the new entry on success, or `false` on version mismatch.
|
|
269
|
+
*/
|
|
270
|
+
put(key: string, value: KodaXJsonValue, options?: {
|
|
271
|
+
expectedVersion?: string;
|
|
272
|
+
}): Promise<KodaXExtensionStoreEntry | false>;
|
|
273
|
+
/**
|
|
274
|
+
* Remove a key.
|
|
275
|
+
* Returns `true` when the key existed and was removed.
|
|
276
|
+
*/
|
|
277
|
+
delete(key: string): Promise<boolean>;
|
|
278
|
+
/**
|
|
279
|
+
* List all keys (optionally filtered by prefix).
|
|
280
|
+
*/
|
|
281
|
+
list(options?: {
|
|
282
|
+
prefix?: string;
|
|
283
|
+
}): Promise<string[]>;
|
|
284
|
+
/**
|
|
285
|
+
* Clear all keys (optionally filtered by prefix).
|
|
286
|
+
* Returns the number of entries removed.
|
|
287
|
+
*/
|
|
288
|
+
clear(options?: {
|
|
289
|
+
prefix?: string;
|
|
290
|
+
}): Promise<number>;
|
|
291
|
+
}
|
|
292
|
+
interface KodaXSessionStorage {
|
|
293
|
+
save(id: string, data: KodaXSessionData): Promise<void>;
|
|
294
|
+
load(id: string): Promise<KodaXSessionData | null>;
|
|
295
|
+
getLineage?(id: string): Promise<KodaXSessionLineage | null>;
|
|
296
|
+
setActiveEntry?(id: string, selector: string, options?: KodaXSessionNavigationOptions): Promise<KodaXSessionData | null>;
|
|
297
|
+
setLabel?(id: string, selector: string, label?: string): Promise<KodaXSessionData | null>;
|
|
298
|
+
rewind?(id: string, selector?: string): Promise<KodaXSessionData | null>;
|
|
299
|
+
fork?(id: string, selector?: string, options?: {
|
|
300
|
+
sessionId?: string;
|
|
301
|
+
title?: string;
|
|
302
|
+
}): Promise<{
|
|
303
|
+
sessionId: string;
|
|
304
|
+
data: KodaXSessionData;
|
|
305
|
+
} | null>;
|
|
306
|
+
list?(gitRoot?: string): Promise<Array<{
|
|
307
|
+
id: string;
|
|
308
|
+
title: string;
|
|
309
|
+
msgCount: number;
|
|
310
|
+
tag?: string;
|
|
311
|
+
runtimeInfo?: KodaXSessionRuntimeInfo;
|
|
312
|
+
}>>;
|
|
313
|
+
delete?(id: string): Promise<void>;
|
|
314
|
+
deleteAll?(gitRoot?: string): Promise<void>;
|
|
315
|
+
}
|
|
3
316
|
|
|
4
317
|
/**
|
|
5
318
|
* Layer A Primitive: Agent / Handoff / Guardrail / AgentReasoningProfile
|
|
@@ -1667,157 +1980,6 @@ declare class Runner {
|
|
|
1667
1980
|
/** @internal Exposed so preset dispatchers can extract the assistant text from a KodaXResult. */
|
|
1668
1981
|
declare function extractAssistantTextFromMessage(message: AgentMessage): string;
|
|
1669
1982
|
|
|
1670
|
-
/**
|
|
1671
|
-
* Guardrail Runtime — FEATURE_085 (v0.7.26).
|
|
1672
|
-
*
|
|
1673
|
-
* Three-tier runtime for Agent guardrails:
|
|
1674
|
-
*
|
|
1675
|
-
* - `InputGuardrail`: runs once before the first LLM turn, inspects the
|
|
1676
|
-
* full input transcript, may allow / rewrite / block / escalate.
|
|
1677
|
-
* - `OutputGuardrail`: runs once before returning, inspects the final
|
|
1678
|
-
* assistant message, may allow / rewrite / block / escalate.
|
|
1679
|
-
* - `ToolGuardrail`: runs before and/or after each tool invocation,
|
|
1680
|
-
* inspects the call / result, may allow / rewrite / block / escalate.
|
|
1681
|
-
*
|
|
1682
|
-
* The four verdict actions:
|
|
1683
|
-
*
|
|
1684
|
-
* - `allow`: continue with the current value.
|
|
1685
|
-
* - `rewrite`: replace the current value with `payload`.
|
|
1686
|
-
* - `block`: throw `GuardrailBlockedError` (for input/output) or surface
|
|
1687
|
-
* an error tool_result (for tool-before); the LLM / caller sees a
|
|
1688
|
-
* rejection and must adapt.
|
|
1689
|
-
* - `escalate`: throw `GuardrailEscalateError`; the SDK consumer catches
|
|
1690
|
-
* and decides whether to prompt the user, retry under different
|
|
1691
|
-
* constraints, etc.
|
|
1692
|
-
*
|
|
1693
|
-
* Every guardrail invocation emits a `GuardrailSpan` under the agent's
|
|
1694
|
-
* span when tracing is active.
|
|
1695
|
-
*
|
|
1696
|
-
* @experimental API shape may adjust during v0.7.x rollout.
|
|
1697
|
-
*/
|
|
1698
|
-
|
|
1699
|
-
/**
|
|
1700
|
-
* Shared execution context passed to every guardrail.
|
|
1701
|
-
*
|
|
1702
|
-
* `messages` is the live conversation transcript at the moment this
|
|
1703
|
-
* guardrail fires. For tool-side guardrails this is the transcript at
|
|
1704
|
-
* call-site time — it does NOT yet include the assistant turn that
|
|
1705
|
-
* emitted the current tool_use, since that turn is appended only after
|
|
1706
|
-
* the full tool batch settles. Optional so existing guardrails that
|
|
1707
|
-
* don't read context still type-check; populated by the Runner for all
|
|
1708
|
-
* production hook points.
|
|
1709
|
-
*
|
|
1710
|
-
* Added in FEATURE_092 (v0.7.33) so the auto-mode classifier guardrail
|
|
1711
|
-
* can extract intent context (user prompt + prior tool_use / tool_result
|
|
1712
|
-
* blocks) without reaching into Runner internals.
|
|
1713
|
-
*/
|
|
1714
|
-
interface GuardrailContext {
|
|
1715
|
-
readonly agent: Agent;
|
|
1716
|
-
readonly abortSignal?: AbortSignal;
|
|
1717
|
-
readonly messages?: readonly AgentMessage[];
|
|
1718
|
-
}
|
|
1719
|
-
/**
|
|
1720
|
-
* Outcome of a single guardrail check. `payload` shape depends on the hook
|
|
1721
|
-
* point — see the specific guardrail interface for the expected type.
|
|
1722
|
-
*/
|
|
1723
|
-
type GuardrailVerdict = {
|
|
1724
|
-
readonly action: 'allow';
|
|
1725
|
-
} | {
|
|
1726
|
-
readonly action: 'rewrite';
|
|
1727
|
-
readonly payload: unknown;
|
|
1728
|
-
readonly reason?: string;
|
|
1729
|
-
} | {
|
|
1730
|
-
readonly action: 'block';
|
|
1731
|
-
readonly reason: string;
|
|
1732
|
-
} | {
|
|
1733
|
-
readonly action: 'escalate';
|
|
1734
|
-
readonly reason: string;
|
|
1735
|
-
};
|
|
1736
|
-
/**
|
|
1737
|
-
* Input-side guardrail. Expected `rewrite` payload shape:
|
|
1738
|
-
* `readonly AgentMessage[]` — the replacement transcript.
|
|
1739
|
-
*/
|
|
1740
|
-
interface InputGuardrail extends Guardrail {
|
|
1741
|
-
readonly kind: 'input';
|
|
1742
|
-
check(input: readonly AgentMessage[], ctx: GuardrailContext): Promise<GuardrailVerdict>;
|
|
1743
|
-
}
|
|
1744
|
-
/**
|
|
1745
|
-
* Output-side guardrail. Expected `rewrite` payload shape:
|
|
1746
|
-
* `AgentMessage` — the replacement final assistant message.
|
|
1747
|
-
*/
|
|
1748
|
-
interface OutputGuardrail extends Guardrail {
|
|
1749
|
-
readonly kind: 'output';
|
|
1750
|
-
check(output: AgentMessage, ctx: GuardrailContext): Promise<GuardrailVerdict>;
|
|
1751
|
-
}
|
|
1752
|
-
/**
|
|
1753
|
-
* Tool-side guardrail. `beforeTool` rewrite payload shape: `RunnerToolCall`
|
|
1754
|
-
* (replacement call). `afterTool` rewrite payload shape: `RunnerToolResult`
|
|
1755
|
-
* (replacement result). Either hook is optional.
|
|
1756
|
-
*/
|
|
1757
|
-
interface ToolGuardrail extends Guardrail {
|
|
1758
|
-
readonly kind: 'tool';
|
|
1759
|
-
beforeTool?(call: RunnerToolCall, ctx: GuardrailContext): Promise<GuardrailVerdict>;
|
|
1760
|
-
afterTool?(call: RunnerToolCall, result: RunnerToolResult, ctx: GuardrailContext): Promise<GuardrailVerdict>;
|
|
1761
|
-
}
|
|
1762
|
-
/**
|
|
1763
|
-
* Thrown when any guardrail returns `{ action: 'block' }`. The Runner
|
|
1764
|
-
* propagates this up to the caller — the run is aborted at that point.
|
|
1765
|
-
*/
|
|
1766
|
-
declare class GuardrailBlockedError extends Error {
|
|
1767
|
-
readonly guardrailName: string;
|
|
1768
|
-
readonly hookPoint: 'input' | 'output' | 'tool';
|
|
1769
|
-
constructor(guardrailName: string, hookPoint: 'input' | 'output' | 'tool', reason: string);
|
|
1770
|
-
}
|
|
1771
|
-
/**
|
|
1772
|
-
* Thrown when any guardrail returns `{ action: 'escalate' }`. Callers can
|
|
1773
|
-
* catch and prompt the user or apply a stricter policy before retrying.
|
|
1774
|
-
*/
|
|
1775
|
-
declare class GuardrailEscalateError extends Error {
|
|
1776
|
-
readonly guardrailName: string;
|
|
1777
|
-
readonly hookPoint: 'input' | 'output' | 'tool';
|
|
1778
|
-
constructor(guardrailName: string, hookPoint: 'input' | 'output' | 'tool', reason: string);
|
|
1779
|
-
}
|
|
1780
|
-
/** Filter a guardrail list by hook-point. */
|
|
1781
|
-
declare function collectGuardrails(guardrails: readonly Guardrail[] | undefined): {
|
|
1782
|
-
input: readonly InputGuardrail[];
|
|
1783
|
-
output: readonly OutputGuardrail[];
|
|
1784
|
-
tool: readonly ToolGuardrail[];
|
|
1785
|
-
};
|
|
1786
|
-
/**
|
|
1787
|
-
* Run all input guardrails in declaration order. Returns the (possibly
|
|
1788
|
-
* rewritten) transcript. Throws on block / escalate.
|
|
1789
|
-
*/
|
|
1790
|
-
declare function runInputGuardrails(transcript: readonly AgentMessage[], guardrails: readonly InputGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<readonly AgentMessage[]>;
|
|
1791
|
-
/**
|
|
1792
|
-
* Run all output guardrails in declaration order. Returns the (possibly
|
|
1793
|
-
* rewritten) final assistant message. Throws on block / escalate.
|
|
1794
|
-
*/
|
|
1795
|
-
declare function runOutputGuardrails(output: AgentMessage, guardrails: readonly OutputGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<AgentMessage>;
|
|
1796
|
-
/**
|
|
1797
|
-
* Outcome of the before-tool guardrail stage.
|
|
1798
|
-
* - `{ kind: 'allow', call }`: continue to executeRunnerToolCall with `call`
|
|
1799
|
-
* - `{ kind: 'block', result }`: skip execution; return `result` as the
|
|
1800
|
-
* tool_result to the LLM (so it sees the rejection and can adapt)
|
|
1801
|
-
*/
|
|
1802
|
-
type ToolBeforeOutcome = {
|
|
1803
|
-
readonly kind: 'allow';
|
|
1804
|
-
readonly call: RunnerToolCall;
|
|
1805
|
-
} | {
|
|
1806
|
-
readonly kind: 'block';
|
|
1807
|
-
readonly result: RunnerToolResult;
|
|
1808
|
-
};
|
|
1809
|
-
/**
|
|
1810
|
-
* Run before-tool guardrails in declaration order. Rewrite replaces the
|
|
1811
|
-
* tool call. Block surfaces an error tool_result to the LLM instead of
|
|
1812
|
-
* throwing — the LLM sees the rejection and adapts. Escalate still throws.
|
|
1813
|
-
*/
|
|
1814
|
-
declare function runToolBeforeGuardrails(call: RunnerToolCall, guardrails: readonly ToolGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<ToolBeforeOutcome>;
|
|
1815
|
-
/**
|
|
1816
|
-
* Run after-tool guardrails in declaration order. Rewrite replaces the
|
|
1817
|
-
* result content. Block replaces with an error result. Escalate throws.
|
|
1818
|
-
*/
|
|
1819
|
-
declare function runToolAfterGuardrails(call: RunnerToolCall, result: RunnerToolResult, guardrails: readonly ToolGuardrail[], ctx: GuardrailContext, agentSpan: Span | null): Promise<RunnerToolResult>;
|
|
1820
|
-
|
|
1821
1983
|
/**
|
|
1822
1984
|
* FEATURE_222 — user-interaction primitive (agent layer).
|
|
1823
1985
|
*
|
|
@@ -1884,124 +2046,6 @@ declare function setActiveUserInteraction(interaction: UserInteraction | undefin
|
|
|
1884
2046
|
/** The live user-interaction surface, or undefined when none is active. */
|
|
1885
2047
|
declare function getActiveUserInteraction(): UserInteraction | undefined;
|
|
1886
2048
|
|
|
1887
|
-
/**
|
|
1888
|
-
* @kodax-ai/agent/messaging — Message queue types
|
|
1889
|
-
*
|
|
1890
|
-
* FEATURE_115 (v0.7.36): agentId-scoped 2-tier priority queue infrastructure.
|
|
1891
|
-
*
|
|
1892
|
-
* Per ADR-021: messaging is a generic agent-platform primitive (not coding-
|
|
1893
|
-
* specific). Downstream consumers:
|
|
1894
|
-
* - @kodax-ai/coding runner-driven mid-turn drain
|
|
1895
|
-
* - @kodax-ai/repl InkREPL ESC soft-pause + text injection (FEATURE_111 absorbed)
|
|
1896
|
-
* - subagent task-notification routing (FEATURE_155 idle-yield wakeup)
|
|
1897
|
-
*
|
|
1898
|
-
* Phase 0.6 study (`c:/tmp/claude-code-actual-usage.md`): Claude Code's
|
|
1899
|
-
* `'now'` priority has zero production usage; KodaX simplifies to 2 tiers.
|
|
1900
|
-
*/
|
|
1901
|
-
type MessagePriority = 'user' | 'background';
|
|
1902
|
-
type MessageMode = 'prompt' | 'task-notification' | 'system-reminder';
|
|
1903
|
-
interface QueuedMessage {
|
|
1904
|
-
/** Stable id for tracing / dedup. Format: `msg-<sequence>`. */
|
|
1905
|
-
readonly id: string;
|
|
1906
|
-
readonly priority: MessagePriority;
|
|
1907
|
-
/**
|
|
1908
|
-
* Routing key:
|
|
1909
|
-
* undefined = main thread / coordinator agent
|
|
1910
|
-
* 'agent-id-XYZ' = subagent / specific consumer
|
|
1911
|
-
*
|
|
1912
|
-
* Drain consumers MUST filter by agentId match — undefined matches only
|
|
1913
|
-
* undefined-agentId messages, not "any agent".
|
|
1914
|
-
*/
|
|
1915
|
-
readonly agentId?: string;
|
|
1916
|
-
readonly mode: MessageMode;
|
|
1917
|
-
readonly content: string;
|
|
1918
|
-
/** Wall-clock timestamp (`Date.now()`) for tracing only — not used for ordering. */
|
|
1919
|
-
readonly enqueuedAt: number;
|
|
1920
|
-
}
|
|
1921
|
-
interface DequeueFilter {
|
|
1922
|
-
/**
|
|
1923
|
-
* Only return messages with this agentId.
|
|
1924
|
-
* undefined matches messages with no agentId (main-thread messages only).
|
|
1925
|
-
*/
|
|
1926
|
-
readonly agentId?: string;
|
|
1927
|
-
/**
|
|
1928
|
-
* Highest priority level included in the drain.
|
|
1929
|
-
* 'user' → only user priority drained, background stays queued
|
|
1930
|
-
* 'background' → both user + background drained (Sleep-gated case)
|
|
1931
|
-
*/
|
|
1932
|
-
readonly maxPriority: MessagePriority;
|
|
1933
|
-
/**
|
|
1934
|
-
* Optional cap on number of messages drained in this call.
|
|
1935
|
-
* Defaults to unlimited (drains all matching).
|
|
1936
|
-
*/
|
|
1937
|
-
readonly limit?: number;
|
|
1938
|
-
/**
|
|
1939
|
-
* FEATURE_159 (v0.7.40) — optional mode filter. Lets REPL split the
|
|
1940
|
-
* single queue into mode-typed views (e.g. `mode:'prompt'` for user
|
|
1941
|
-
* input vs `mode:'task-notification'` for child completion banners)
|
|
1942
|
-
* without separate queues. When omitted, all modes match.
|
|
1943
|
-
*/
|
|
1944
|
-
readonly mode?: MessageMode;
|
|
1945
|
-
/**
|
|
1946
|
-
* FEATURE_159 (v0.7.40) — optional precise-id filter. Single-message
|
|
1947
|
-
* targeted removal — drives Esc-pop-this-uuid in REPL. When set, all
|
|
1948
|
-
* other filters still apply (agentId / priority / mode mismatches still
|
|
1949
|
-
* skip the message), so callers can't accidentally remove a message
|
|
1950
|
-
* outside their scope.
|
|
1951
|
-
*/
|
|
1952
|
-
readonly id?: string;
|
|
1953
|
-
/**
|
|
1954
|
-
* FEATURE_159 (v0.7.40) — optional escape-hatch predicate, AND-ed with
|
|
1955
|
-
* the structured filters. Lets SDK consumers express conditions the
|
|
1956
|
-
* typed fields don't cover (e.g. timestamp ranges, content-match) without
|
|
1957
|
-
* forcing every new use case to extend `DequeueFilter`. KodaX-internal
|
|
1958
|
-
* code should prefer the typed fields for readability; this is the
|
|
1959
|
-
* "data-driven main path + predicate escape" pattern.
|
|
1960
|
-
*
|
|
1961
|
-
* Evaluated AFTER the typed filters succeed — so a `predicate` that
|
|
1962
|
-
* inspects `message.content` never runs on messages outside the
|
|
1963
|
-
* caller's `agentId` / `mode` / `id` scope.
|
|
1964
|
-
*/
|
|
1965
|
-
readonly predicate?: (message: QueuedMessage) => boolean;
|
|
1966
|
-
}
|
|
1967
|
-
/**
|
|
1968
|
-
* FEATURE_159 (v0.7.40) — structured queue event emitted to subscribers.
|
|
1969
|
-
*
|
|
1970
|
-
* Replaces the prior `() => void` bare-notify signal. Carries the kind +
|
|
1971
|
-
* affected messages so SDK observability consumers (logging, tracing,
|
|
1972
|
-
* metrics) can react per-event without re-diffing snapshots.
|
|
1973
|
-
*
|
|
1974
|
-
* Event granularity rules:
|
|
1975
|
-
* - `enqueued` fires ONCE per `enqueue()` call (always 1 message).
|
|
1976
|
-
* - `dequeued` fires ONCE per `dequeue()` call that removed ≥1 message,
|
|
1977
|
-
* carrying ALL drained messages in priority+FIFO order. No-op drains
|
|
1978
|
-
* (filter matched nothing) fire no event — quiet by design so the
|
|
1979
|
-
* `waitForWakeEvent` 100ms poll doesn't spam idle subscribers.
|
|
1980
|
-
* - `cleared` fires ONCE per `clear()` call that removed ≥1 message,
|
|
1981
|
-
* carrying the pre-clear messages. Empty-queue clear fires nothing.
|
|
1982
|
-
*
|
|
1983
|
-
* The `useSyncExternalStore` React hook ignores the event payload (it
|
|
1984
|
-
* only needs the change signal); SDK / tracer consumers read the event.
|
|
1985
|
-
*/
|
|
1986
|
-
type QueueEvent = {
|
|
1987
|
-
readonly kind: 'enqueued';
|
|
1988
|
-
readonly message: QueuedMessage;
|
|
1989
|
-
} | {
|
|
1990
|
-
readonly kind: 'dequeued';
|
|
1991
|
-
readonly messages: readonly QueuedMessage[];
|
|
1992
|
-
} | {
|
|
1993
|
-
readonly kind: 'cleared';
|
|
1994
|
-
readonly messages: readonly QueuedMessage[];
|
|
1995
|
-
};
|
|
1996
|
-
/** FEATURE_159 — `MessageQueue.subscribe` listener signature. */
|
|
1997
|
-
type QueueEventListener = (event: QueueEvent) => void;
|
|
1998
|
-
interface EnqueueInput {
|
|
1999
|
-
readonly priority: MessagePriority;
|
|
2000
|
-
readonly mode: MessageMode;
|
|
2001
|
-
readonly content: string;
|
|
2002
|
-
readonly agentId?: string;
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
2049
|
/**
|
|
2006
2050
|
* Child task registry primitive — generic fan-out tracking.
|
|
2007
2051
|
*
|
|
@@ -2468,7 +2512,7 @@ interface FileOperations {
|
|
|
2468
2512
|
* injected clock). The run graph models agent relationships as a
|
|
2469
2513
|
* thread/edge/event stream, not just a final summary blob.
|
|
2470
2514
|
*/
|
|
2471
|
-
type WorkflowEventType = 'workflow_started' | 'phase_started' | 'phase_finished' | 'agent_spawned' | 'agent_message_sent' | 'agent_completed' | 'agent_stopped' | 'artifact_written' | 'synthesis_completed' | 'workflow_completed' | 'workflow_stopped' | 'workflow_failed';
|
|
2515
|
+
type WorkflowEventType = 'workflow_started' | 'phase_started' | 'phase_finished' | 'agent_spawned' | 'agent_message_sent' | 'agent_completed' | 'agent_unverified' | 'agent_failed' | 'agent_summary_updated' | 'agent_stopped' | 'workflow_log' | 'artifact_written' | 'synthesis_completed' | 'workflow_completed' | 'workflow_stopped' | 'workflow_failed';
|
|
2472
2516
|
interface WorkflowEvent {
|
|
2473
2517
|
/** Monotonic sequence number — stable append ordering. */
|
|
2474
2518
|
readonly seq: number;
|
|
@@ -2504,12 +2548,32 @@ declare class WorkflowEventRecorder {
|
|
|
2504
2548
|
* dependency (ADR-021 layer independence).
|
|
2505
2549
|
*/
|
|
2506
2550
|
/** Lifecycle status of a single workflow-spawned agent. */
|
|
2507
|
-
type WorkflowTaskStatus = 'running' | 'completed' | 'failed' | 'stopped';
|
|
2551
|
+
type WorkflowTaskStatus = 'running' | 'completed' | 'completed_unverified' | 'failed' | 'stopped';
|
|
2508
2552
|
/** Routing hint for which provider/model tier the child should use. */
|
|
2509
2553
|
type WorkflowModelHint = 'fast' | 'balanced' | 'deep';
|
|
2510
2554
|
/** Isolation policy for a spawned agent. `shared-cwd` is the default
|
|
2511
2555
|
* (FEATURE_188); `worktree` is opt-in for high-risk parallel writes. */
|
|
2512
2556
|
type WorkflowIsolation = 'shared-cwd' | 'worktree';
|
|
2557
|
+
/**
|
|
2558
|
+
* Machine-checkable postconditions for a workflow child task. The agent
|
|
2559
|
+
* package only defines the contract; concrete backends decide which evidence
|
|
2560
|
+
* they can verify.
|
|
2561
|
+
*/
|
|
2562
|
+
interface WorkflowTaskVerification {
|
|
2563
|
+
readonly enforcement?: 'hard' | 'warn';
|
|
2564
|
+
readonly requiresMutation?: boolean;
|
|
2565
|
+
readonly requiredChangedPaths?: readonly string[];
|
|
2566
|
+
readonly minFinalTextChars?: number;
|
|
2567
|
+
readonly rejectPreparatoryFinalText?: boolean;
|
|
2568
|
+
}
|
|
2569
|
+
interface WorkflowTaskVerificationResult {
|
|
2570
|
+
readonly ok: boolean;
|
|
2571
|
+
readonly enforcement?: 'hard' | 'warn';
|
|
2572
|
+
readonly reasons: readonly string[];
|
|
2573
|
+
readonly changedPaths?: readonly string[];
|
|
2574
|
+
readonly mutationToolCalls?: readonly string[];
|
|
2575
|
+
readonly mutationEvidence?: boolean;
|
|
2576
|
+
}
|
|
2513
2577
|
interface WorkflowSpawnAgentInput {
|
|
2514
2578
|
/** Human-readable label for the agent — surfaces in events / UI. */
|
|
2515
2579
|
readonly name: string;
|
|
@@ -2525,6 +2589,8 @@ interface WorkflowSpawnAgentInput {
|
|
|
2525
2589
|
readonly isolation?: WorkflowIsolation;
|
|
2526
2590
|
/** Evidence refs (`task_id:<id>` etc.) seeded into the child context. */
|
|
2527
2591
|
readonly evidenceRefs?: readonly string[];
|
|
2592
|
+
/** Optional machine-checkable postconditions for this child task. */
|
|
2593
|
+
readonly verification?: WorkflowTaskVerification;
|
|
2528
2594
|
}
|
|
2529
2595
|
/** Returned by `spawnAgent` — the child is in-flight, not yet complete. */
|
|
2530
2596
|
interface WorkflowTaskHandle {
|
|
@@ -2536,6 +2602,12 @@ interface WorkflowTaskUsage {
|
|
|
2536
2602
|
readonly outputTokens?: number;
|
|
2537
2603
|
readonly totalTokens?: number;
|
|
2538
2604
|
}
|
|
2605
|
+
type WorkflowTaskSummaryKind = 'digest' | 'excerpt' | 'digest-failed' | 'pending';
|
|
2606
|
+
interface WorkflowTaskSummaryEventUpdate {
|
|
2607
|
+
readonly summary?: string;
|
|
2608
|
+
readonly summaryKind: WorkflowTaskSummaryKind;
|
|
2609
|
+
readonly usage?: WorkflowTaskUsage;
|
|
2610
|
+
}
|
|
2539
2611
|
/** Terminal result of a spawned agent (from `wait` / `runAgent`). */
|
|
2540
2612
|
interface WorkflowTaskResult {
|
|
2541
2613
|
readonly taskId: string;
|
|
@@ -2546,6 +2618,15 @@ interface WorkflowTaskResult {
|
|
|
2546
2618
|
readonly digest?: string;
|
|
2547
2619
|
/** True when a digest was attempted but failed (error/timeout/empty); the UI then labels the excerpt fallback. */
|
|
2548
2620
|
readonly digestFailed?: boolean;
|
|
2621
|
+
/** True when a digest was scheduled asynchronously and may arrive via `agent_summary_updated`. */
|
|
2622
|
+
readonly digestPending?: boolean;
|
|
2623
|
+
/** Task postcondition check, when a backend evaluated one. */
|
|
2624
|
+
readonly verification?: WorkflowTaskVerificationResult;
|
|
2625
|
+
/** True when the child exhausted its iteration budget before completing. */
|
|
2626
|
+
readonly limitReached?: boolean;
|
|
2627
|
+
/** Best-known provider/model used by the child, for host correlation only. */
|
|
2628
|
+
readonly provider?: string;
|
|
2629
|
+
readonly model?: string;
|
|
2549
2630
|
readonly usage?: WorkflowTaskUsage;
|
|
2550
2631
|
}
|
|
2551
2632
|
/** Point-in-time snapshot of a (possibly still-running) agent. */
|
|
@@ -2615,6 +2696,9 @@ interface WorkflowApi {
|
|
|
2615
2696
|
/** Await a spawned agent's terminal result. */
|
|
2616
2697
|
wait(taskId: string, opts?: WorkflowWaitOptions): Promise<WorkflowTaskResult>;
|
|
2617
2698
|
/** Snapshot a (possibly running) agent. */
|
|
2699
|
+
snapshot(taskId: string): Promise<WorkflowTaskSnapshot>;
|
|
2700
|
+
/** Snapshot a (possibly running) agent.
|
|
2701
|
+
* @deprecated Prefer `snapshot(taskId)`; `output` is kept as a compatibility alias. */
|
|
2618
2702
|
output(taskId: string): Promise<WorkflowTaskSnapshot>;
|
|
2619
2703
|
/** Send a message to a running agent (via MessageQueue routing). */
|
|
2620
2704
|
send(taskId: string, content: string): Promise<void>;
|
|
@@ -2683,6 +2767,8 @@ interface WorkflowAgentBackend {
|
|
|
2683
2767
|
output(taskId: string): Promise<WorkflowTaskSnapshot>;
|
|
2684
2768
|
send(taskId: string, content: string): Promise<void>;
|
|
2685
2769
|
stop(taskId: string, reason: string): Promise<void>;
|
|
2770
|
+
/** Optional late summary stream for presentation-only async digests. */
|
|
2771
|
+
subscribeTaskSummaryUpdates?(listener: (taskId: string, update: WorkflowTaskSummaryEventUpdate) => void): () => void;
|
|
2686
2772
|
/** Optional durable artifact writer (Phase D wires the run graph).
|
|
2687
2773
|
* `wf.synthesize` is NOT a backend method — it runs as a gated agent
|
|
2688
2774
|
* through `spawn`/`wait` so it counts toward the runtime's caps. */
|
|
@@ -2698,5 +2784,131 @@ interface WorkflowRunState {
|
|
|
2698
2784
|
readonly artifacts: readonly WorkflowArtifactRef[];
|
|
2699
2785
|
}
|
|
2700
2786
|
|
|
2701
|
-
|
|
2702
|
-
|
|
2787
|
+
type WorkflowProcessStatus = 'running' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
|
2788
|
+
type WorkflowProcessItemStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'skipped';
|
|
2789
|
+
type WorkflowProcessItemKind = 'phase' | 'agent' | 'step' | 'artifact';
|
|
2790
|
+
type WorkflowProcessSummaryStatus = 'pending' | 'result' | 'notice' | 'unavailable';
|
|
2791
|
+
type WorkflowProcessSource = 'command' | 'amaw' | 'review' | 'sdk' | 'capsule' | 'extension' | 'automation';
|
|
2792
|
+
interface WorkflowProcessItem {
|
|
2793
|
+
readonly id: string;
|
|
2794
|
+
readonly title: string;
|
|
2795
|
+
readonly kind: WorkflowProcessItemKind;
|
|
2796
|
+
readonly status: WorkflowProcessItemStatus;
|
|
2797
|
+
readonly phaseId?: string;
|
|
2798
|
+
readonly parentId?: string;
|
|
2799
|
+
readonly agentId?: string;
|
|
2800
|
+
readonly childAgentId?: string;
|
|
2801
|
+
readonly provider?: string;
|
|
2802
|
+
readonly model?: string;
|
|
2803
|
+
readonly startedAt?: string;
|
|
2804
|
+
readonly endedAt?: string;
|
|
2805
|
+
readonly summary?: string;
|
|
2806
|
+
readonly summaryStatus?: WorkflowProcessSummaryStatus;
|
|
2807
|
+
readonly error?: string;
|
|
2808
|
+
}
|
|
2809
|
+
interface WorkflowEventCorrelation {
|
|
2810
|
+
readonly workflowRunId: string;
|
|
2811
|
+
readonly childAgentId?: string;
|
|
2812
|
+
readonly phaseId?: string;
|
|
2813
|
+
readonly itemId?: string;
|
|
2814
|
+
}
|
|
2815
|
+
interface WorkflowProcessCounts {
|
|
2816
|
+
readonly pending: number;
|
|
2817
|
+
readonly running: number;
|
|
2818
|
+
readonly completed: number;
|
|
2819
|
+
readonly failed: number;
|
|
2820
|
+
readonly cancelled: number;
|
|
2821
|
+
readonly skipped: number;
|
|
2822
|
+
}
|
|
2823
|
+
interface WorkflowProcessProgress {
|
|
2824
|
+
readonly spawnedAgents: number;
|
|
2825
|
+
readonly finishedAgents: number;
|
|
2826
|
+
readonly activeAgents: number;
|
|
2827
|
+
readonly failedAgents: number;
|
|
2828
|
+
readonly stoppedAgents: number;
|
|
2829
|
+
readonly agentCap?: number;
|
|
2830
|
+
readonly plannedItems?: number;
|
|
2831
|
+
}
|
|
2832
|
+
interface WorkflowProcessTokenUsage {
|
|
2833
|
+
readonly spent: number;
|
|
2834
|
+
readonly total?: number;
|
|
2835
|
+
}
|
|
2836
|
+
interface WorkflowProcessArtifact {
|
|
2837
|
+
readonly name: string;
|
|
2838
|
+
readonly path?: string;
|
|
2839
|
+
readonly description?: string;
|
|
2840
|
+
}
|
|
2841
|
+
interface WorkflowProcessSnapshot {
|
|
2842
|
+
readonly runId: string;
|
|
2843
|
+
readonly workflowName: string;
|
|
2844
|
+
readonly displayName?: string;
|
|
2845
|
+
readonly status: WorkflowProcessStatus;
|
|
2846
|
+
readonly startedAt: string;
|
|
2847
|
+
readonly updatedAt: string;
|
|
2848
|
+
readonly elapsedMs?: number;
|
|
2849
|
+
readonly goal?: string;
|
|
2850
|
+
readonly source?: WorkflowProcessSource;
|
|
2851
|
+
readonly savedWorkflowName?: string;
|
|
2852
|
+
readonly sourceRunId?: string;
|
|
2853
|
+
readonly sourceWorkflowName?: string;
|
|
2854
|
+
readonly revisionOf?: string;
|
|
2855
|
+
readonly hostMetadata?: Record<string, string>;
|
|
2856
|
+
readonly activePhaseId?: string;
|
|
2857
|
+
readonly activePhaseIndex?: number;
|
|
2858
|
+
readonly phaseCount?: number;
|
|
2859
|
+
readonly items: readonly WorkflowProcessItem[];
|
|
2860
|
+
readonly counts: WorkflowProcessCounts;
|
|
2861
|
+
readonly progress: WorkflowProcessProgress;
|
|
2862
|
+
readonly tokens?: WorkflowProcessTokenUsage;
|
|
2863
|
+
readonly latestMessage?: string;
|
|
2864
|
+
readonly resultSummary?: string;
|
|
2865
|
+
readonly error?: string;
|
|
2866
|
+
readonly artifacts?: readonly WorkflowProcessArtifact[];
|
|
2867
|
+
}
|
|
2868
|
+
type WorkflowProcessEvent = {
|
|
2869
|
+
readonly type: 'workflow_started';
|
|
2870
|
+
readonly snapshot: WorkflowProcessSnapshot;
|
|
2871
|
+
} | {
|
|
2872
|
+
readonly type: 'workflow_updated';
|
|
2873
|
+
readonly snapshot: WorkflowProcessSnapshot;
|
|
2874
|
+
readonly message?: string;
|
|
2875
|
+
} | {
|
|
2876
|
+
readonly type: 'workflow_finished';
|
|
2877
|
+
readonly snapshot: WorkflowProcessSnapshot;
|
|
2878
|
+
};
|
|
2879
|
+
interface WorkflowProcessTrackerOptions {
|
|
2880
|
+
readonly runId: string;
|
|
2881
|
+
readonly workflowName: string;
|
|
2882
|
+
readonly displayName?: string;
|
|
2883
|
+
readonly goal?: string;
|
|
2884
|
+
readonly source?: WorkflowProcessSource;
|
|
2885
|
+
readonly savedWorkflowName?: string;
|
|
2886
|
+
readonly sourceRunId?: string;
|
|
2887
|
+
readonly sourceWorkflowName?: string;
|
|
2888
|
+
readonly revisionOf?: string;
|
|
2889
|
+
readonly hostMetadata?: Record<string, string>;
|
|
2890
|
+
readonly phases?: readonly string[];
|
|
2891
|
+
readonly maxAgents?: number;
|
|
2892
|
+
readonly plannedAgents?: number;
|
|
2893
|
+
readonly tokenBudget?: number;
|
|
2894
|
+
readonly resultSummary?: string;
|
|
2895
|
+
readonly artifacts?: readonly WorkflowArtifactRef[];
|
|
2896
|
+
readonly now?: () => string;
|
|
2897
|
+
}
|
|
2898
|
+
interface WorkflowTaskSummaryUpdate {
|
|
2899
|
+
readonly summary?: string;
|
|
2900
|
+
readonly summaryStatus: WorkflowProcessSummaryStatus;
|
|
2901
|
+
}
|
|
2902
|
+
interface WorkflowProcessTracker {
|
|
2903
|
+
applyEvent(event: WorkflowEvent): WorkflowProcessEvent;
|
|
2904
|
+
updateTaskSummary(taskId: string, update: WorkflowTaskSummaryUpdate): WorkflowProcessEvent | undefined;
|
|
2905
|
+
setStatus(status: WorkflowProcessStatus, message?: string): WorkflowProcessEvent;
|
|
2906
|
+
setResultSummary(resultSummary: string | undefined): WorkflowProcessEvent;
|
|
2907
|
+
getSnapshot(): WorkflowProcessSnapshot;
|
|
2908
|
+
}
|
|
2909
|
+
declare function isFinalWorkflowProcessStatus(status: WorkflowProcessStatus): boolean;
|
|
2910
|
+
declare function normalizeHostMetadata(value: unknown): Record<string, string> | undefined;
|
|
2911
|
+
declare function createWorkflowProcessTracker(options: WorkflowProcessTrackerOptions): WorkflowProcessTracker;
|
|
2912
|
+
|
|
2913
|
+
export { DEFAULT_SYSTEM_CAP as D, InvariantSession as M, Runner as aC, SpanImpl as aV, MAX_TOOL_LOOP_ITERATIONS as ak, _resetPresetDispatchers as b$, _resetAdmittedAgentBindings as b_, Tracer as bb, WorkflowEventRecorder as bm, buildAssistantMessageFromLlmResult as c0, buildSystemPrompt as c1, buildToolResultMessage as c2, createAgent as c3, createHandoff as c4, createInMemorySession as c5, createInvariantSessionForAgent as c6, createStateWriter as c7, createTrace as c8, createWorkflowProcessTracker as c9, defaultTracer as ca, detectInstructionsInjection as cb, discoverInstances as cc, executeRunnerToolCall as cd, extractAssistantTextFromMessage as ce, getActiveUserInteraction as cf, getAdmittedAgentBindings as cg, isFinalWorkflowProcessStatus as ch, isRunnableTool as ci, isRunnerLlmResult as cj, normalizeHostMetadata as ck, registerChildTask as cl, registerPresetDispatcher as cm, requestTaskStop as cn, runAdmissionAudit as co, setActiveUserInteraction as cp, setAdmittedAgentBindings as cq };
|
|
2914
|
+
export type { KodaXSessionData as $, AdmissionAuditOptions as A, HandoffSpanData as B, ChildTaskRegistry as C, EvidenceSpanData as E, FanoutSpanData as F, GenerationSpanData as G, Handoff as H, InMemorySessionOptions as I, InstanceDiscoveryFs as J, InvariantId as K, InvariantResult as L, KodaXCompactMemoryProgress as N, KodaXCompactMemorySeed as O, KodaXExtensionSessionRecord as P, KodaXExtensionSessionState as Q, KodaXExtensionStore as R, KodaXExtensionStoreEntry as S, KodaXGoalEventType as T, KodaXGoalState as U, KodaXGoalStatus as V, KodaXJsonValue as W, KodaXSessionArchiveMarkerEntry as X, KodaXSessionArtifactLedgerEntry as Y, KodaXSessionBranchSummaryEntry as Z, KodaXSessionCompactionEntry as _, AdmissionCtx as a, StopHookContext as a$, KodaXSessionEntry as a0, KodaXSessionEntryBase as a1, KodaXSessionGoalEntry as a2, KodaXSessionLabelEntry as a3, KodaXSessionLineage as a4, KodaXSessionMessageEntry as a5, KodaXSessionMeta as a6, KodaXSessionNavigationOptions as a7, KodaXSessionRuntimeInfo as a8, KodaXSessionScope as a9, RunResult as aA, RunnableTool as aB, RunnerEvent as aD, RunnerLlmResult as aE, RunnerLlmReturn as aF, RunnerToolCall as aG, RunnerToolContext as aH, RunnerToolObserver as aI, RunnerToolResult as aJ, Session as aK, SessionDispatchResult as aL, SessionEntry as aM, SessionErrorMetadata as aN, SessionExtension as aO, SessionForkOptions as aP, SessionMeta as aQ, SessionStateSnapshot as aR, Span as aS, SpanData as aT, SpanError as aU, SpanImplOptions as aW, StartTraceOptions as aX, StateWriter as aY, StateWriterFs as aZ, StateWriterOptions as a_, KodaXSessionStorage as aa, KodaXSessionTreeNode as ab, KodaXSessionUiHistoryItem as ac, KodaXSessionUiHistoryItemType as ad, KodaXSessionUiTextHistoryItem as ae, KodaXSessionUiTextHistoryItemType as af, KodaXSessionUiToolCall as ag, KodaXSessionUiToolCallStatus as ah, KodaXSessionUiToolGroupHistoryItem as ai, KodaXSessionWorkspaceKind as aj, ManifestPatch as al, MessageEntry as am, ObserveCtx as an, PersistedSessionState as ao, PresetDispatcher as ap, PresetTracingContext as aq, QualityInvariant as ar, ReadonlyMutationTracker as as, ReadonlyRecorder as at, ReasoningDepth as au, RecentlyModifiedFile as av, RequestTaskStopOptions as aw, RequestTaskStopResult as ax, RunEvent as ay, RunOptions as az, AdmissionVerdict as b, StopHookFn as b0, StopHookResult as b1, StopHookSpanData as b2, SystemCap as b3, TaskAbortRegistry as b4, TerminalCtx as b5, ToolCallSpanData as b6, ToolCapability as b7, ToolPermission as b8, Trace as b9, WorkflowProcessItemStatus as bA, WorkflowProcessProgress as bB, WorkflowProcessSnapshot as bC, WorkflowProcessSource as bD, WorkflowProcessStatus as bE, WorkflowProcessSummaryStatus as bF, WorkflowProcessTokenUsage as bG, WorkflowProcessTracker as bH, WorkflowProcessTrackerOptions as bI, WorkflowRun as bJ, WorkflowRunState as bK, WorkflowRunStatus as bL, WorkflowSpawnAgentInput as bM, WorkflowSynthesis as bN, WorkflowSynthesizeInput as bO, WorkflowTaskHandle as bP, WorkflowTaskResult as bQ, WorkflowTaskSnapshot as bR, WorkflowTaskStatus as bS, WorkflowTaskSummaryEventUpdate as bT, WorkflowTaskSummaryKind as bU, WorkflowTaskSummaryUpdate as bV, WorkflowTaskUsage as bW, WorkflowTaskVerification as bX, WorkflowTaskVerificationResult as bY, WorkflowWaitOptions as bZ, TraceOptions as ba, TracerOptions as bc, UserInteraction as bd, WorkflowAgentBackend as be, WorkflowApi as bf, WorkflowApproval as bg, WorkflowApprovalSummary as bh, WorkflowArtifactRef as bi, WorkflowBudget as bj, WorkflowEvent as bk, WorkflowEventCorrelation as bl, WorkflowEventType as bn, WorkflowIsolation as bo, WorkflowLimits as bp, WorkflowLogEvent as bq, WorkflowMeta as br, WorkflowModelHint as bs, WorkflowModule as bt, WorkflowParallelOptions as bu, WorkflowProcessArtifact as bv, WorkflowProcessCounts as bw, WorkflowProcessEvent as bx, WorkflowProcessItem as by, WorkflowProcessItemKind as bz, AdmittedHandle as c, Agent as d, AgentManifest as e, AgentMessage as f, AgentMiddlewareDeclaration as g, AgentReasoningProfile as h, AgentSpanData as i, AgentTool as j, AskUserMultiOptions as k, AskUserQuestionItem as l, AskUserQuestionOptions as m, CompactionAnchor as n, CompactionConfig as o, CompactionDetails as p, CompactionResult as q, CompactionSpanData as r, CompactionUpdate as s, CurrentTodoSummary as t, Deliverable as u, DiscoveredInstance as v, DiscoveryOptions as w, FileOperations as x, Guardrail as y, GuardrailSpanData as z };
|