@kodax-ai/kodax 0.7.96 → 0.7.97-alpha.2
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 +86 -0
- package/README.md +85 -62
- package/README_CN.md +57 -67
- package/config-templates/config.example.jsonc +0 -14
- package/dist/chunks/{agent-7N427EVB.js → agent-J7SHFM5N.js} +1 -1
- package/dist/chunks/argument-completer-ZJQOWTIS.js +2 -0
- package/dist/chunks/{chunk-ABZDFK2X.js → chunk-2GV6MQ4T.js} +14 -14
- package/dist/chunks/{chunk-6QI3GOYG.js → chunk-3PS3YEDS.js} +1 -1
- package/dist/chunks/chunk-4VJMQDTH.js +417 -0
- package/dist/chunks/{chunk-NI7PBPUR.js → chunk-5DSUVP46.js} +1 -1
- package/dist/chunks/chunk-5P7RTSZT.js +21 -0
- package/dist/chunks/{chunk-XXNR6S4Q.js → chunk-6ZAQKFIM.js} +1 -1
- package/dist/chunks/chunk-7V2QBZ73.js +137 -0
- package/dist/chunks/{chunk-C7U542KM.js → chunk-F7DHZH6T.js} +1 -1
- package/dist/chunks/{chunk-7IMWOR34.js → chunk-HSRYDDPF.js} +1 -1
- package/dist/chunks/chunk-K3DQGSQU.js +372 -0
- package/dist/chunks/chunk-NO23K2CB.js +2 -0
- package/dist/chunks/{chunk-NKT3B3DR.js → chunk-OT5WHAX4.js} +1 -1
- package/dist/chunks/{chunk-YEAUDI6U.js → chunk-QGWHJIO4.js} +1 -1
- package/dist/chunks/chunk-QOFFAY5C.js +261 -0
- package/dist/chunks/{chunk-4PFZ7BEE.js → chunk-QVDTORL3.js} +11 -11
- package/dist/chunks/chunk-QZ4B4AWG.js +473 -0
- package/dist/chunks/chunk-RXDS6CNA.js +355 -0
- package/dist/chunks/{chunk-WV3DJVW4.js → chunk-VDGPJQL7.js} +135 -135
- package/dist/chunks/chunk-VEZ4WHPN.js +641 -0
- package/dist/chunks/chunk-ZPPAT25E.js +5 -0
- package/dist/chunks/chunk-ZQYWDI4O.js +1 -0
- package/dist/chunks/chunk-ZS2GUADU.js +498 -0
- package/dist/chunks/{chunk-GN2IY5YE.js → chunk-ZTYZYXGV.js} +1 -1
- package/dist/chunks/{chunk-EM4XJBTK.js → chunk-ZZQ4GDVU.js} +1 -1
- package/dist/chunks/{client-6WZZTTSV.js → client-MXOJ5XUN.js} +1 -1
- package/dist/chunks/{compaction-config-ZMEJU4U7.js → compaction-config-5VZSGKBQ.js} +1 -1
- package/dist/chunks/{construction-bootstrap-RX4DMHI7.js → construction-bootstrap-U2ZU2WAT.js} +1 -1
- package/dist/chunks/dist-CSLNWLOE.js +2 -0
- package/dist/chunks/dist-XXMJMJDU.js +2 -0
- package/dist/chunks/host-RUXYZFYN.js +2 -0
- package/dist/chunks/readline-helpers-JCVULR4C.js +2 -0
- package/dist/chunks/run-manager-DRIM5VNE.js +2 -0
- package/dist/chunks/utils-MQEBGKIX.js +2 -0
- package/dist/index.d.ts +63 -30
- package/dist/index.js +10 -6
- package/dist/kodax_bootstrap.js +1 -1
- package/dist/kodax_cli.js +1745 -1734
- package/dist/kodax_resume.js +32 -35
- package/dist/native/win32-x64/kodax-windows-sandbox.exe +0 -0
- package/dist/native/win32-x64/kodax-windows-text-transaction.node +0 -0
- package/dist/native/win32-x64/manifest.json +2 -2
- package/dist/sandbox-network-broker.js +77 -77
- package/dist/sdk-a2a.d.ts +33 -18
- package/dist/sdk-a2a.js +8 -9
- package/dist/sdk-agent.d.ts +33 -26
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-client.d.ts +40 -0
- package/dist/sdk-client.js +2 -0
- package/dist/sdk-coding.d.ts +87 -499
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-experimental-memory.d.ts +3 -4
- package/dist/sdk-experimental-memory.js +1 -1
- package/dist/sdk-llm.d.ts +11 -9
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.d.ts +3 -3
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-media.d.ts +3 -1
- package/dist/sdk-media.js +1 -1
- package/dist/sdk-repl.d.ts +317 -70
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-runtime.d.ts +580 -452
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.d.ts +13 -9
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/semantic-worker.js +57 -57
- package/dist/types-chunks/{base.d-Bt9lhwSV.d.ts → base.d-ZBOdjDUT.d.ts} +2 -1
- package/dist/types-chunks/{bash-prefix-extractor.d-DWFIMg0v.d.ts → bash-prefix-extractor.d-DvswAXKS.d.ts} +136 -66
- package/dist/types-chunks/{capability-learning.d-gRtO03f6.d.ts → capability-learning.d-B4pxKwP4.d.ts} +1 -1
- package/dist/types-chunks/{capability.d-Ch5Vos33.d.ts → capability.d-DOF3r0fJ.d.ts} +1 -1
- package/dist/types-chunks/{capsule.d-Dj1n6s0Y.d.ts → capsule.d-B4atvlxE.d.ts} +7 -19
- package/dist/types-chunks/client-contract-A1jdk6xz.d.ts +1993 -0
- package/dist/types-chunks/{controller.d-C0IM1Tud.d.ts → controller.d-BkUJ_3sl.d.ts} +1 -1
- package/dist/types-chunks/{controller.d-J2t1q8Ly.d.ts → controller.d-yyKajPTi.d.ts} +140 -1380
- package/dist/types-chunks/{cost-tracker.d-BWI4lFWn.d.ts → cost-tracker.d-BeaenODW.d.ts} +2 -47
- package/dist/types-chunks/{history-retrieval.d-CPN5PMBV.d.ts → history-retrieval.d-JdFfkeF3.d.ts} +2 -2
- package/dist/types-chunks/{manager.d-rtmywU9M.d.ts → manager.d-C_20XqCV.d.ts} +8 -1
- package/dist/types-chunks/manifest.d-Bw2i-zQi.d.ts +18 -0
- package/dist/types-chunks/provider-credential-context.d-BH2OaB1b.d.ts +47 -0
- package/dist/types-chunks/provider-request-observation.d-jL8T6wVO.d.ts +34 -0
- package/dist/types-chunks/{public-api.d-amBop8Nk.d.ts → public-api.d-Cq8ILMte.d.ts} +52 -13
- package/dist/types-chunks/{resolver.d-BrwLoWNr.d.ts → resolver.d-DLY01RHx.d.ts} +4 -2
- package/dist/types-chunks/{types.d-CSv0_cZC.d.ts → review-inbox.d-BeaLRNHx.d.ts} +251 -3
- package/dist/types-chunks/{shell-command-sets.d-oejwpP_7.d.ts → review-packet.d-D4bbTbq3.d.ts} +46 -3
- package/dist/types-chunks/{exec-policy.d-BPESl90L.d.ts → run-manager.d-C7Q71rin.d.ts} +385 -62
- package/dist/types-chunks/runtime-client-info-CxnlZlW5.d.ts +175 -0
- package/dist/types-chunks/{sdk-session-B6XjHNU1.d.ts → sdk-session-BDFjCpDn.d.ts} +12 -4
- package/dist/types-chunks/{side-query.d-DHWG1JZg.d.ts → side-query.d-DTrhVd_r.d.ts} +4 -3
- package/dist/types-chunks/trusted-repl-entry-vbUM8R6P.d.ts +445 -0
- package/dist/types-chunks/{types.d-CtO8mR1s.d.ts → types.d-BJTN-RZr.d.ts} +5 -5
- package/dist/types-chunks/{types.d-BrQMB-hy.d.ts → types.d-BjOq57-z.d.ts} +6 -0
- package/dist/types-chunks/types.d-o7t9dds4.d.ts +1484 -0
- package/dist/types-chunks/{utils.d-DcznBeQ3.d.ts → utils.d-CWiMhFfu.d.ts} +202 -36
- package/docs/CLIENT_CONTRACT.md +441 -0
- package/docs/SDK_MIGRATION.md +123 -0
- package/docs/SPACE_SDK_SEAMS.md +139 -0
- package/package.json +10 -5
- package/public_docs/README.md +12 -133
- package/public_docs/configuration/config-files.md +8 -14
- package/public_docs/sdk/embedder-guide.md +494 -420
- package/dist/chunks/argument-completer-FAIHW7HZ.js +0 -2
- package/dist/chunks/chunk-66XN5AFU.js +0 -417
- package/dist/chunks/chunk-7O2AIFNE.js +0 -373
- package/dist/chunks/chunk-DSXUXUZG.js +0 -5
- package/dist/chunks/chunk-GYO73UYQ.js +0 -275
- package/dist/chunks/chunk-HPCS3LZ5.js +0 -324
- package/dist/chunks/chunk-HZYRLIOC.js +0 -137
- package/dist/chunks/chunk-SC2ELSUS.js +0 -675
- package/dist/chunks/chunk-TEUD5VPJ.js +0 -471
- package/dist/chunks/chunk-TYZ2ZAYL.js +0 -487
- package/dist/chunks/dist-3UCCMCYR.js +0 -2
- package/dist/chunks/dist-F5IWZSAY.js +0 -2
- package/dist/chunks/host-W2JJ3V3Q.js +0 -2
- package/dist/chunks/run-manager-RBWU3EVE.js +0 -2
- package/dist/chunks/utils-DJ4ZFJGL.js +0 -2
- package/dist/runtime-worker.js +0 -5381
- package/dist/types-chunks/review-inbox.d-CTeUIKda.d.ts +0 -225
- package/dist/types-chunks/run-manager.d-hm1XgEou.d.ts +0 -94
- package/dist/types-chunks/trusted-repl-entry-D0w5M0UZ.d.ts +0 -323
- package/dist/types-chunks/types.d-B1l9pWyX.d.ts +0 -146
|
@@ -0,0 +1,1484 @@
|
|
|
1
|
+
import { k as KodaXMessage, I as KodaXReasoningRequest, a2 as KodaXTokenUsage } from './types.d-BjOq57-z.js';
|
|
2
|
+
import { a9 as KodaXCompactMemorySeed, ao as KodaXSessionArtifactLedgerEntry } from './review-inbox.d-BeaLRNHx.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FEATURE_222 — user-interaction primitive (agent layer).
|
|
6
|
+
*
|
|
7
|
+
* "Ask the user a question" is needed at BOTH layers: the coding `ask_user_*`
|
|
8
|
+
* tools (LLM-initiated) AND the MCP elicitation reverse capability
|
|
9
|
+
* (server-initiated). The capability historically lived only in
|
|
10
|
+
* `@kodax-ai/coding`, but the MCP runtime lives one layer below in
|
|
11
|
+
* `@kodax-ai/agent` and cannot reach up to it. So the primitive is owned here,
|
|
12
|
+
* at the agent layer, and the host injects ONE implementation that both layers
|
|
13
|
+
* share — coding re-exports these types for backward compatibility.
|
|
14
|
+
*
|
|
15
|
+
* The agent layer is UI-less by design: these are the contract the host
|
|
16
|
+
* (REPL / ACP / SDK) fulfils with its real interaction surface. A headless host
|
|
17
|
+
* leaves them undefined and consumers degrade gracefully (cancel / decline).
|
|
18
|
+
*/
|
|
19
|
+
/** A single question item used in multi-question mode. */
|
|
20
|
+
interface AskUserQuestionItem {
|
|
21
|
+
question: string;
|
|
22
|
+
header?: string;
|
|
23
|
+
options: Array<{
|
|
24
|
+
label: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}>;
|
|
28
|
+
multiSelect?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* FEATURE_222 — only meaningful when `multiSelect` is true. The host should
|
|
31
|
+
* reject (re-prompt / show an error, do NOT resolve) a selection with fewer
|
|
32
|
+
* than `minSelections` items. Absent ⇒ no lower bound.
|
|
33
|
+
*/
|
|
34
|
+
minSelections?: number;
|
|
35
|
+
/**
|
|
36
|
+
* FEATURE_222 — only meaningful when `multiSelect` is true. The host should
|
|
37
|
+
* reject a selection with more than `maxSelections` items. Absent ⇒ no upper
|
|
38
|
+
* bound. Lets a host render + validate "pick at most N" structurally instead
|
|
39
|
+
* of parsing it out of natural-language question text.
|
|
40
|
+
*/
|
|
41
|
+
maxSelections?: number;
|
|
42
|
+
/** Runtime-validated option value selected if the interaction expires. */
|
|
43
|
+
default?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Choice surfaces are open-ended by default: hosts SHOULD offer a synthetic
|
|
46
|
+
* custom-input option unless this is explicitly false.
|
|
47
|
+
*/
|
|
48
|
+
allowCustomInput?: boolean;
|
|
49
|
+
customInputLabel?: string;
|
|
50
|
+
customInputPrompt?: string;
|
|
51
|
+
customInputDefault?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Options for multi-question mode — multiple independent questions in one call. */
|
|
54
|
+
interface AskUserMultiOptions {
|
|
55
|
+
questions: AskUserQuestionItem[];
|
|
56
|
+
}
|
|
57
|
+
/** Options for a single question (select or free-text input). */
|
|
58
|
+
interface AskUserQuestionOptions {
|
|
59
|
+
question: string;
|
|
60
|
+
kind?: 'select' | 'input';
|
|
61
|
+
/** Required for kind="select", ignored for kind="input". */
|
|
62
|
+
options?: Array<{
|
|
63
|
+
label: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
value: string;
|
|
66
|
+
}>;
|
|
67
|
+
multiSelect?: boolean;
|
|
68
|
+
/** FEATURE_222 — see {@link AskUserQuestionItem.minSelections}. */
|
|
69
|
+
minSelections?: number;
|
|
70
|
+
/** FEATURE_222 — see {@link AskUserQuestionItem.maxSelections}. */
|
|
71
|
+
maxSelections?: number;
|
|
72
|
+
/** Input text or a Runtime-validated option value selected on expiry. */
|
|
73
|
+
default?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Choice surfaces are open-ended by default: hosts SHOULD offer a synthetic
|
|
76
|
+
* custom-input option unless this is explicitly false.
|
|
77
|
+
*/
|
|
78
|
+
allowCustomInput?: boolean;
|
|
79
|
+
customInputLabel?: string;
|
|
80
|
+
customInputPrompt?: string;
|
|
81
|
+
customInputDefault?: string;
|
|
82
|
+
}
|
|
83
|
+
/** Host return value for a user-entered answer chosen through a select dialog's
|
|
84
|
+
* synthetic "Other..." option. */
|
|
85
|
+
interface AskUserCustomInputAnswer {
|
|
86
|
+
kind: 'customInput';
|
|
87
|
+
value: string;
|
|
88
|
+
}
|
|
89
|
+
type AskUserSelectionAnswer = string | AskUserCustomInputAnswer;
|
|
90
|
+
type AskUserAnswer = AskUserSelectionAnswer | AskUserSelectionAnswer[];
|
|
91
|
+
/**
|
|
92
|
+
* FEATURE_222 — reserved option value a host may append as a synthetic option
|
|
93
|
+
* (e.g. a "← Back" entry) in `askUserMulti`'s per-question flow to mean "return
|
|
94
|
+
* to the previous question" instead of answering the current one. Only
|
|
95
|
+
* meaningful for `questions[]` index > 0 (there is no previous before the
|
|
96
|
+
* first). The coding `ask_user_question` tool rejects this as a normal
|
|
97
|
+
* `option.value` supplied by the model, so a host may safely reuse it for its
|
|
98
|
+
* own back-navigation UI. A host that ignores this constant simply never offers
|
|
99
|
+
* back-navigation — the default multi-question flow is unaffected either way.
|
|
100
|
+
*/
|
|
101
|
+
declare const ASK_USER_BACK_SIGNAL = "__back__";
|
|
102
|
+
/** Reserved synthetic option value for a host-provided custom input entry. */
|
|
103
|
+
declare const ASK_USER_CUSTOM_INPUT_SIGNAL = "__custom_input__";
|
|
104
|
+
declare function isAskUserCustomInputAnswer(value: unknown): value is AskUserCustomInputAnswer;
|
|
105
|
+
/**
|
|
106
|
+
* FEATURE_222 — narrow an `askUser` result to a single string for the many
|
|
107
|
+
* callers that only ever ask single-select questions (they never set
|
|
108
|
+
* `multiSelect: true`, so the array branch is unreachable at runtime). Collapses
|
|
109
|
+
* an unexpected array to its first element so a mis-configured host degrades
|
|
110
|
+
* predictably instead of leaking `[object Array]` into a string comparison.
|
|
111
|
+
*/
|
|
112
|
+
declare function asSingleSelection(answer: AskUserAnswer): string;
|
|
113
|
+
/** Lifecycle signal supplied by a bounded interaction owner. */
|
|
114
|
+
interface UserInteractionPromptContext {
|
|
115
|
+
/** Aborted when the interaction expires or its owner settles it elsewhere. */
|
|
116
|
+
readonly signal: AbortSignal;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The host-provided user-interaction surface. Each method is optional — a
|
|
120
|
+
* headless host omits them and callers degrade gracefully. This is the single
|
|
121
|
+
* primitive shared by the coding `ask_user_*` tools and the agent's MCP
|
|
122
|
+
* elicitation reverse capability.
|
|
123
|
+
*/
|
|
124
|
+
interface UserInteraction {
|
|
125
|
+
/**
|
|
126
|
+
* Ask one question (select mode by default). Single-select resolves the
|
|
127
|
+
* chosen option value as a string. Multi-select resolves the selected values
|
|
128
|
+
* as an array. If the user chooses the host-provided custom-input option,
|
|
129
|
+
* return `{ kind: 'customInput', value }` in the single or array position.
|
|
130
|
+
* Plain string/string[] hosts remain valid for backward compatibility.
|
|
131
|
+
*/
|
|
132
|
+
askUser?: (options: AskUserQuestionOptions, context?: UserInteractionPromptContext) => Promise<AskUserAnswer>;
|
|
133
|
+
/** Ask several independent questions sequentially. Resolves a per-question
|
|
134
|
+
* value map using the same `AskUserAnswer` shape as `askUser`, or undefined
|
|
135
|
+
* when the user cancels. */
|
|
136
|
+
askUserMulti?: (options: AskUserMultiOptions, context?: UserInteractionPromptContext) => Promise<Record<string, AskUserAnswer> | undefined>;
|
|
137
|
+
/** Ask for free-text input. Resolves the text, or undefined when cancelled. */
|
|
138
|
+
askUserInput?: (options: {
|
|
139
|
+
question: string;
|
|
140
|
+
default?: string;
|
|
141
|
+
}, context?: UserInteractionPromptContext) => Promise<string | undefined>;
|
|
142
|
+
}
|
|
143
|
+
/** Register the live user-interaction surface (host calls this when interactive). */
|
|
144
|
+
declare function setActiveUserInteraction(interaction: UserInteraction | undefined): void;
|
|
145
|
+
/** The live user-interaction surface, or undefined when none is active. */
|
|
146
|
+
declare function getActiveUserInteraction(): UserInteraction | undefined;
|
|
147
|
+
|
|
148
|
+
type KodaXImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';
|
|
149
|
+
type KodaXVideoMediaType = 'video/mp4' | 'video/mpeg' | 'video/quicktime' | 'video/x-msvideo' | 'video/x-flv' | 'video/webm' | 'video/x-ms-wmv' | 'video/3gpp';
|
|
150
|
+
type KodaXInputArtifactSource = 'user-inline' | 'clipboard' | 'drag-drop' | 'file-picker';
|
|
151
|
+
interface KodaXImageInputArtifact {
|
|
152
|
+
readonly kind: 'image';
|
|
153
|
+
readonly path: string;
|
|
154
|
+
readonly mediaType?: KodaXImageMediaType;
|
|
155
|
+
readonly source?: KodaXInputArtifactSource;
|
|
156
|
+
readonly description?: string;
|
|
157
|
+
}
|
|
158
|
+
interface KodaXFileInputArtifact {
|
|
159
|
+
readonly kind: 'file';
|
|
160
|
+
readonly path: string;
|
|
161
|
+
readonly mediaType?: string;
|
|
162
|
+
readonly mimeType?: string;
|
|
163
|
+
readonly name?: string;
|
|
164
|
+
readonly source?: KodaXInputArtifactSource;
|
|
165
|
+
readonly description?: string;
|
|
166
|
+
}
|
|
167
|
+
interface KodaXVideoInputArtifact {
|
|
168
|
+
readonly kind: 'video';
|
|
169
|
+
readonly path: string;
|
|
170
|
+
readonly mediaType: KodaXVideoMediaType;
|
|
171
|
+
readonly name?: string;
|
|
172
|
+
readonly source?: KodaXInputArtifactSource;
|
|
173
|
+
readonly description?: string;
|
|
174
|
+
}
|
|
175
|
+
type KodaXInputArtifact = KodaXImageInputArtifact | KodaXFileInputArtifact | KodaXVideoInputArtifact;
|
|
176
|
+
|
|
177
|
+
type LearnedCapabilityCarrier = 'skill' | 'extension' | 'workflow_handoff';
|
|
178
|
+
type LearnedCapabilityLifecycle = 'opportunity' | 'drafting' | 'ready' | 'testing' | 'active_learned' | 'promoted_user' | 'quarantined' | 'archived' | 'rejected';
|
|
179
|
+
type LearningEventKind = 'opportunity' | 'drafting' | 'ready' | 'testing' | 'activated' | 'promoted' | 'attention' | 'archived' | 'rejected';
|
|
180
|
+
type LearningAction = 'review' | 'trust' | 'reject' | 'disable' | 'rollback' | 'archive' | 'restore' | 'promote';
|
|
181
|
+
interface LearnedCapabilitySource {
|
|
182
|
+
readonly kind: 'learning_controller' | 'f224_proposal' | 'skill_learning_loop' | 'legacy_manual';
|
|
183
|
+
readonly proposalId?: string;
|
|
184
|
+
}
|
|
185
|
+
interface LearnedCapabilityRecordBase {
|
|
186
|
+
readonly capabilityId: string;
|
|
187
|
+
readonly displayName: string;
|
|
188
|
+
readonly slug: string;
|
|
189
|
+
readonly carrier: LearnedCapabilityCarrier;
|
|
190
|
+
readonly lifecycle: LearnedCapabilityLifecycle;
|
|
191
|
+
readonly revision: number;
|
|
192
|
+
readonly createdAt: string;
|
|
193
|
+
readonly updatedAt: string;
|
|
194
|
+
readonly source: LearnedCapabilitySource;
|
|
195
|
+
/** The control action that produced this revision, when it is not implied by lifecycle. */
|
|
196
|
+
readonly lastAction?: LearningAction;
|
|
197
|
+
readonly artifactPath?: string;
|
|
198
|
+
readonly previousGoodRevision?: number;
|
|
199
|
+
readonly previousLifecycle?: LearnedCapabilityLifecycle;
|
|
200
|
+
readonly diagnostics?: readonly string[];
|
|
201
|
+
}
|
|
202
|
+
interface LearnedCapabilityRecordV1 extends LearnedCapabilityRecordBase {
|
|
203
|
+
readonly schemaVersion: 1;
|
|
204
|
+
}
|
|
205
|
+
interface LearnedCapabilityScope {
|
|
206
|
+
readonly configHomeHash: string;
|
|
207
|
+
readonly tenantHash: string;
|
|
208
|
+
readonly projectHash: string;
|
|
209
|
+
}
|
|
210
|
+
interface LearnedCapabilityArtifact {
|
|
211
|
+
readonly kind: 'skill_markdown';
|
|
212
|
+
readonly relativePath: string;
|
|
213
|
+
readonly fingerprint: string;
|
|
214
|
+
readonly contentRevision: number;
|
|
215
|
+
}
|
|
216
|
+
interface LearnedCapabilityProvenance {
|
|
217
|
+
readonly jobId: string;
|
|
218
|
+
readonly inputHash: string;
|
|
219
|
+
readonly decisionId: string;
|
|
220
|
+
readonly actionId: string;
|
|
221
|
+
}
|
|
222
|
+
interface LearnedCapabilityCanaryBinding {
|
|
223
|
+
readonly bindingId: string;
|
|
224
|
+
readonly ownerSessionRef: string;
|
|
225
|
+
readonly expiresAt: string;
|
|
226
|
+
}
|
|
227
|
+
interface LearnedCapabilityCanaryInvocation {
|
|
228
|
+
readonly invocationId: string;
|
|
229
|
+
readonly bindingId: string;
|
|
230
|
+
/** Durable usage-ledger identity for recovery after the binding expires. */
|
|
231
|
+
readonly usageSessionHash?: string;
|
|
232
|
+
readonly artifactRevision?: number;
|
|
233
|
+
readonly artifactFingerprint?: string;
|
|
234
|
+
readonly status: 'pending' | 'verified_success' | 'credible_negative' | 'inconclusive';
|
|
235
|
+
readonly evidenceRefs: readonly string[];
|
|
236
|
+
readonly invokedAt: string;
|
|
237
|
+
readonly completedAt?: string;
|
|
238
|
+
}
|
|
239
|
+
interface LearnedCapabilityCanary {
|
|
240
|
+
readonly maxInvocations: 3;
|
|
241
|
+
readonly invocationCount: number;
|
|
242
|
+
readonly verifiedSuccesses: number;
|
|
243
|
+
readonly credibleNegatives: number;
|
|
244
|
+
readonly binding?: LearnedCapabilityCanaryBinding;
|
|
245
|
+
readonly invocations: readonly LearnedCapabilityCanaryInvocation[];
|
|
246
|
+
}
|
|
247
|
+
interface LearnedCapabilityRecordV2 extends LearnedCapabilityRecordBase {
|
|
248
|
+
readonly schemaVersion: 2;
|
|
249
|
+
readonly carrier: 'skill';
|
|
250
|
+
readonly scope: LearnedCapabilityScope;
|
|
251
|
+
readonly artifact: LearnedCapabilityArtifact;
|
|
252
|
+
readonly previousGoodArtifact?: LearnedCapabilityArtifact;
|
|
253
|
+
readonly provenance: LearnedCapabilityProvenance;
|
|
254
|
+
readonly canary: LearnedCapabilityCanary;
|
|
255
|
+
}
|
|
256
|
+
type LearnedCapabilityRecord = LearnedCapabilityRecordV1 | LearnedCapabilityRecordV2;
|
|
257
|
+
interface LearningEvent {
|
|
258
|
+
readonly schemaVersion: 1;
|
|
259
|
+
readonly sequence: number;
|
|
260
|
+
readonly eventId: string;
|
|
261
|
+
readonly capabilityId: string;
|
|
262
|
+
readonly capabilityRevision: number;
|
|
263
|
+
readonly kind: LearningEventKind;
|
|
264
|
+
readonly lifecycle: LearnedCapabilityLifecycle;
|
|
265
|
+
readonly displayName: string;
|
|
266
|
+
readonly slug: string;
|
|
267
|
+
readonly carrier: LearnedCapabilityCarrier;
|
|
268
|
+
readonly createdAt: string;
|
|
269
|
+
}
|
|
270
|
+
type LearningNotificationState = 'unread' | 'seen' | 'acknowledged' | 'snoozed';
|
|
271
|
+
interface LearningClientEventState {
|
|
272
|
+
readonly state: LearningNotificationState;
|
|
273
|
+
readonly capabilityRevision: number;
|
|
274
|
+
readonly updatedAt: string;
|
|
275
|
+
readonly snoozedUntil?: string;
|
|
276
|
+
}
|
|
277
|
+
interface LearningClientRecord {
|
|
278
|
+
readonly schemaVersion: 1;
|
|
279
|
+
readonly clientIdentity: string;
|
|
280
|
+
readonly events: Readonly<Record<string, LearningClientEventState>>;
|
|
281
|
+
}
|
|
282
|
+
interface LearningSurfaceSnapshot {
|
|
283
|
+
readonly ready: number;
|
|
284
|
+
readonly newlyActive: number;
|
|
285
|
+
readonly attention: number;
|
|
286
|
+
readonly active: number;
|
|
287
|
+
readonly revision: number;
|
|
288
|
+
}
|
|
289
|
+
interface LearningQuery {
|
|
290
|
+
readonly search?: string;
|
|
291
|
+
readonly carrier?: LearnedCapabilityCarrier;
|
|
292
|
+
readonly lifecycle?: LearnedCapabilityLifecycle;
|
|
293
|
+
readonly limit?: number;
|
|
294
|
+
readonly cursor?: string;
|
|
295
|
+
}
|
|
296
|
+
interface LearningPage {
|
|
297
|
+
readonly items: readonly LearnedCapabilityRecord[];
|
|
298
|
+
readonly nextCursor?: string;
|
|
299
|
+
readonly revision: number;
|
|
300
|
+
}
|
|
301
|
+
interface LearningSubscribeOptions {
|
|
302
|
+
readonly afterRevision?: number;
|
|
303
|
+
}
|
|
304
|
+
interface LearningExplicitUserAuthority {
|
|
305
|
+
readonly authority: 'explicit_user';
|
|
306
|
+
readonly expectedRevision: number;
|
|
307
|
+
readonly expectedFingerprint?: string;
|
|
308
|
+
}
|
|
309
|
+
interface LearningActionDriver {
|
|
310
|
+
readonly carrier: LearnedCapabilityCarrier;
|
|
311
|
+
readonly actions: readonly LearningAction[];
|
|
312
|
+
execute(action: LearningAction, capability: LearnedCapabilityRecord): Promise<LearnedCapabilityRecord>;
|
|
313
|
+
}
|
|
314
|
+
type LearningCapabilityErrorCode = 'ambiguous_name' | 'action_failed' | 'capability_not_found' | 'invalid_record' | 'invalid_transition' | 'store_integrity_error' | 'unsupported_action';
|
|
315
|
+
declare class LearningCapabilityError extends Error {
|
|
316
|
+
readonly code: LearningCapabilityErrorCode;
|
|
317
|
+
constructor(code: LearningCapabilityErrorCode, message: string);
|
|
318
|
+
}
|
|
319
|
+
declare function canTransitionLearnedCapability(from: LearnedCapabilityLifecycle, to: LearnedCapabilityLifecycle): boolean;
|
|
320
|
+
declare function assertLearnedCapabilityTransition(from: LearnedCapabilityLifecycle, to: LearnedCapabilityLifecycle): void;
|
|
321
|
+
declare function slugifyLearnedCapabilityName(displayName: string): string;
|
|
322
|
+
declare function learningEventKindForLifecycle(lifecycle: LearnedCapabilityLifecycle): LearningEventKind;
|
|
323
|
+
declare function learningEventIdFor(record: LearnedCapabilityRecord): string;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* ../../index.js Compaction Types
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
interface CompactionConfig {
|
|
330
|
+
/** Independent of the main turn; defaults off, or to a low supported effort on always-on models. */
|
|
331
|
+
reasoning?: boolean | KodaXReasoningRequest;
|
|
332
|
+
/** @deprecated Automatic large compaction is always enabled. */
|
|
333
|
+
enabled: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Automatic large-compaction threshold percentage. Defaults to 75 and is
|
|
336
|
+
* normalized to the inclusive 15-90 range.
|
|
337
|
+
*/
|
|
338
|
+
triggerPercent: number;
|
|
339
|
+
/**
|
|
340
|
+
* Optional absolute token threshold. Missing or zero is inactive; otherwise
|
|
341
|
+
* the smaller percentage/absolute/physical threshold wins.
|
|
342
|
+
*/
|
|
343
|
+
triggerTokens?: number;
|
|
344
|
+
/**
|
|
345
|
+
* @deprecated V2 compaction no longer uses this option.
|
|
346
|
+
* FEATURE_272 derives protection from the effective trigger and covers the
|
|
347
|
+
* complete eligible prefix in one logical wave.
|
|
348
|
+
*/
|
|
349
|
+
keepRecentPercent?: number;
|
|
350
|
+
/**
|
|
351
|
+
* @deprecated Large compaction protects 20% of its effective trigger.
|
|
352
|
+
* Retained only for source compatibility with v0.7.x callers.
|
|
353
|
+
*/
|
|
354
|
+
protectionPercent?: number;
|
|
355
|
+
/**
|
|
356
|
+
* @deprecated FEATURE_272 replaces rolling summary passes with one complete
|
|
357
|
+
* eligible-prefix wave. Retained for source compatibility.
|
|
358
|
+
*/
|
|
359
|
+
rollingSummaryPercent?: number;
|
|
360
|
+
/**
|
|
361
|
+
* Explicit legacy opt-in for destructive emergency pruning after semantic
|
|
362
|
+
* compaction cannot restore a physically valid request. Undefined keeps the
|
|
363
|
+
* fallback disabled.
|
|
364
|
+
*/
|
|
365
|
+
pruningThresholdTokens?: number;
|
|
366
|
+
/**
|
|
367
|
+
* Legacy deterministic-pruning gap ratio. Only relevant when
|
|
368
|
+
* `pruningThresholdTokens` is explicitly configured.
|
|
369
|
+
*/
|
|
370
|
+
pruningGapRatio?: number;
|
|
371
|
+
/** Optional override for the provider context window. */
|
|
372
|
+
contextWindow?: number;
|
|
373
|
+
}
|
|
374
|
+
interface CompactionDetails {
|
|
375
|
+
readFiles: string[];
|
|
376
|
+
modifiedFiles: string[];
|
|
377
|
+
}
|
|
378
|
+
interface CompactionAnchor {
|
|
379
|
+
summary: string;
|
|
380
|
+
tokensBefore: number;
|
|
381
|
+
tokensAfter: number;
|
|
382
|
+
entriesRemoved: number;
|
|
383
|
+
reason: string;
|
|
384
|
+
artifactLedgerId?: string;
|
|
385
|
+
details?: CompactionDetails;
|
|
386
|
+
memorySeed?: KodaXCompactMemorySeed;
|
|
387
|
+
}
|
|
388
|
+
interface CompactionUpdate {
|
|
389
|
+
/**
|
|
390
|
+
* Exact host-only snapshot used to reconcile lineage before durable commit.
|
|
391
|
+
* It is intentionally not part of the persisted CompactionEntry or provider
|
|
392
|
+
* context. Hosts may evict old message bodies only after saving this state.
|
|
393
|
+
*/
|
|
394
|
+
preCompactionMessages?: readonly KodaXMessage[];
|
|
395
|
+
anchor?: CompactionAnchor;
|
|
396
|
+
artifactLedger?: KodaXSessionArtifactLedgerEntry[];
|
|
397
|
+
memorySeed?: KodaXCompactMemorySeed;
|
|
398
|
+
/**
|
|
399
|
+
* FEATURE_072: ledger-summary + file-content messages produced by
|
|
400
|
+
* `buildPostCompactAttachments` + `buildFileContentMessages`. Agent.ts
|
|
401
|
+
* passes these separately from the kept-tail messages so REPL-side
|
|
402
|
+
* `applySessionCompaction` can store them natively on the CompactionEntry
|
|
403
|
+
* rather than inlining them as loose `[Post-compact: ...]` system messages
|
|
404
|
+
* in lineage. Agent.ts keeps inlining them into its local flat `messages`
|
|
405
|
+
* via `injectPostCompactAttachments` (P4 belt-and-suspenders); the lineage
|
|
406
|
+
* is the persistence source of truth.
|
|
407
|
+
*/
|
|
408
|
+
postCompactAttachments?: readonly KodaXMessage[];
|
|
409
|
+
/** Canonical metrics for one committed large-compaction transaction. */
|
|
410
|
+
report?: CompactionReport;
|
|
411
|
+
}
|
|
412
|
+
interface CompactionReport {
|
|
413
|
+
/** Physical summary calls, including map/reduce; never contains prompt or output text. */
|
|
414
|
+
readonly summaryRequests?: readonly CompactionRequestMetrics[];
|
|
415
|
+
/** Durable history commit only; excludes summary generation. */
|
|
416
|
+
readonly commitMs?: number;
|
|
417
|
+
readonly strategy: 'full_prefix' | 'map_reduce';
|
|
418
|
+
readonly triggerSource: 'percentage' | 'absolute' | 'physical_capacity';
|
|
419
|
+
readonly effectiveTriggerTokens: number;
|
|
420
|
+
readonly protectedBudgetTokens: number;
|
|
421
|
+
readonly fixedInputTokens: number;
|
|
422
|
+
readonly eligibleTokens: number;
|
|
423
|
+
readonly rawTailTokens: number;
|
|
424
|
+
readonly summaryTokens: number;
|
|
425
|
+
readonly queryLedgerTokens: number;
|
|
426
|
+
}
|
|
427
|
+
interface CompactionRequestMetrics {
|
|
428
|
+
readonly provider: string;
|
|
429
|
+
readonly model: string;
|
|
430
|
+
/** Requested summary policy; the provider may adapt it to its capabilities. */
|
|
431
|
+
readonly reasoning: boolean | KodaXReasoningRequest;
|
|
432
|
+
readonly prepareMs: number;
|
|
433
|
+
readonly credentialMs: number;
|
|
434
|
+
/** Includes retries and their waits. firstDeltaMs is an offset within this duration. */
|
|
435
|
+
readonly providerMs: number;
|
|
436
|
+
readonly firstDeltaMs?: number;
|
|
437
|
+
/** Retries reported by the provider adapter; excludes opaque upstream retries. */
|
|
438
|
+
readonly retryCount: number;
|
|
439
|
+
readonly retryWaitMs: number;
|
|
440
|
+
readonly usage?: KodaXTokenUsage;
|
|
441
|
+
readonly stopReason?: string;
|
|
442
|
+
readonly outcome: 'succeeded' | 'failed';
|
|
443
|
+
}
|
|
444
|
+
interface CompactionResult {
|
|
445
|
+
compacted: boolean;
|
|
446
|
+
messages: KodaXMessage[];
|
|
447
|
+
summary?: string;
|
|
448
|
+
tokensBefore: number;
|
|
449
|
+
tokensAfter: number;
|
|
450
|
+
entriesRemoved: number;
|
|
451
|
+
details?: CompactionDetails;
|
|
452
|
+
artifactLedger?: KodaXSessionArtifactLedgerEntry[];
|
|
453
|
+
anchor?: CompactionAnchor;
|
|
454
|
+
memorySeed?: KodaXCompactMemorySeed;
|
|
455
|
+
report?: CompactionReport;
|
|
456
|
+
}
|
|
457
|
+
interface FileOperations {
|
|
458
|
+
readFiles: string[];
|
|
459
|
+
modifiedFiles: string[];
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* FEATURE_217 (v0.7.49) — Workflow run-graph events.
|
|
464
|
+
*
|
|
465
|
+
* Append-only event stream for a workflow run. Each event carries a
|
|
466
|
+
* monotonic `seq` so ordering is stable and verifiable regardless of
|
|
467
|
+
* wall-clock (the durable writer in Phase D adds timestamps via an
|
|
468
|
+
* injected clock). The run graph models agent relationships as a
|
|
469
|
+
* thread/edge/event stream, not just a final summary blob.
|
|
470
|
+
*/
|
|
471
|
+
type WorkflowEventType = 'workflow_started' | 'phase_started' | 'phase_finished' | 'agent_spawned' | 'agent_message_sent' | 'agent_completed' | 'agent_unverified' | 'agent_failed' | 'agent_summary_updated' | 'agent_stopped' | 'agent_replayed' | 'workflow_log' | 'artifact_written' | 'synthesis_completed' | 'workflow_completed' | 'workflow_stopped' | 'workflow_failed';
|
|
472
|
+
interface WorkflowEvent {
|
|
473
|
+
/** Monotonic sequence number — stable append ordering. */
|
|
474
|
+
readonly seq: number;
|
|
475
|
+
readonly type: WorkflowEventType;
|
|
476
|
+
/** Structured payload (agent name/id, phase name, error message, …). */
|
|
477
|
+
readonly data?: Record<string, unknown>;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Append-only event recorder. Assigns sequential `seq` and fans each
|
|
481
|
+
* event out to an optional sink (the durable JSONL writer / UI consumer
|
|
482
|
+
* subscribes here in Phase D).
|
|
483
|
+
*/
|
|
484
|
+
declare class WorkflowEventRecorder {
|
|
485
|
+
private readonly sink?;
|
|
486
|
+
private seq;
|
|
487
|
+
private readonly events;
|
|
488
|
+
constructor(sink?: ((event: WorkflowEvent) => void) | undefined);
|
|
489
|
+
/** Append an event, returning the materialized record. */
|
|
490
|
+
emit(type: WorkflowEventType, data?: Record<string, unknown>): WorkflowEvent;
|
|
491
|
+
/** Immutable snapshot of all events emitted so far. */
|
|
492
|
+
snapshot(): readonly WorkflowEvent[];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* FEATURE_217 (v0.7.49) — Dynamic Workflow Harness Runtime: public types.
|
|
497
|
+
*
|
|
498
|
+
* Domain-neutral workflow orchestration surface. A workflow *script*
|
|
499
|
+
* coordinates (decompose / fan-out / loop / wait / stop / verify /
|
|
500
|
+
* synthesize); it never touches files or shell directly. The actual
|
|
501
|
+
* agent execution is delegated to an injected `WorkflowAgentBackend`
|
|
502
|
+
* (the coding layer provides the real one in Phase B; tests inject a
|
|
503
|
+
* fake). This keeps `@kodax-ai/agent` free of any `@kodax-ai/coding`
|
|
504
|
+
* dependency (ADR-021 layer independence).
|
|
505
|
+
*/
|
|
506
|
+
/** Lifecycle status of a single workflow-spawned agent. */
|
|
507
|
+
type WorkflowTaskStatus = 'running' | 'completed' | 'completed_unverified' | 'failed' | 'stopped';
|
|
508
|
+
/** Routing hint for which provider/model tier the child should use. */
|
|
509
|
+
type WorkflowModelHint = 'fast' | 'balanced' | 'deep';
|
|
510
|
+
/** Isolation policy for a spawned agent. `shared-cwd` is the default
|
|
511
|
+
* (FEATURE_188); `worktree` is opt-in for high-risk parallel writes. */
|
|
512
|
+
type WorkflowIsolation = 'shared-cwd' | 'worktree';
|
|
513
|
+
/**
|
|
514
|
+
* Machine-checkable postconditions for a workflow child task. The agent
|
|
515
|
+
* package only defines the contract; concrete backends decide which evidence
|
|
516
|
+
* they can verify.
|
|
517
|
+
*/
|
|
518
|
+
interface WorkflowTaskVerification {
|
|
519
|
+
readonly enforcement?: 'hard' | 'warn';
|
|
520
|
+
readonly requiresMutation?: boolean;
|
|
521
|
+
readonly requiredChangedPaths?: readonly string[];
|
|
522
|
+
/** Read-tool paths that must be observed before accepting a review verdict. */
|
|
523
|
+
readonly requiredReadPaths?: readonly string[];
|
|
524
|
+
readonly minFinalTextChars?: number;
|
|
525
|
+
readonly rejectPreparatoryFinalText?: boolean;
|
|
526
|
+
}
|
|
527
|
+
interface WorkflowTaskVerificationResult {
|
|
528
|
+
readonly ok: boolean;
|
|
529
|
+
readonly enforcement?: 'hard' | 'warn';
|
|
530
|
+
readonly reasons: readonly string[];
|
|
531
|
+
readonly changedPaths?: readonly string[];
|
|
532
|
+
readonly mutationToolCalls?: readonly string[];
|
|
533
|
+
readonly mutationEvidence?: boolean;
|
|
534
|
+
readonly readPaths?: readonly string[];
|
|
535
|
+
}
|
|
536
|
+
interface WorkflowAgentTarget {
|
|
537
|
+
readonly agentId: string;
|
|
538
|
+
readonly expectedConfigurationRevision?: string;
|
|
539
|
+
}
|
|
540
|
+
interface WorkflowSpawnAgentInput {
|
|
541
|
+
/** Human-readable label for the agent — surfaces in events / UI. */
|
|
542
|
+
readonly name: string;
|
|
543
|
+
/**
|
|
544
|
+
* Optional progress-group tag (FEATURE_246 Part E). When set, this agent is
|
|
545
|
+
* grouped under a phase of that name in the progress display — the per-agent
|
|
546
|
+
* equivalent of wrapping a block in `wf.phase(name, fn)`, matching the harness
|
|
547
|
+
* `agent(..., { phase })`. The phase group is created on first use. Agents
|
|
548
|
+
* with no `phase` fall under the currently-active `wf.phase(...)` block (if any).
|
|
549
|
+
*/
|
|
550
|
+
readonly phase?: string;
|
|
551
|
+
/** The task prompt handed to the child agent. */
|
|
552
|
+
readonly prompt: string;
|
|
553
|
+
/** Compact scope summary copied into the child briefing without retyping the diff. */
|
|
554
|
+
readonly scopeSummary?: string;
|
|
555
|
+
/** Binding constraints/interfaces the child cannot discover locally. */
|
|
556
|
+
readonly constraints?: readonly string[];
|
|
557
|
+
/** When true, the child runs with a read-only tool whitelist. */
|
|
558
|
+
readonly readOnly?: boolean;
|
|
559
|
+
/** Route to a registered specialist agent (FEATURE_191). */
|
|
560
|
+
readonly subagentType?: string;
|
|
561
|
+
/** Route through the shared dispatchable-agent catalog (FEATURE_258). */
|
|
562
|
+
readonly target?: WorkflowAgentTarget;
|
|
563
|
+
/**
|
|
564
|
+
* Per-agent model TIER (FEATURE_120 model_hint). The script expresses semantic
|
|
565
|
+
* intent — 'fast' (cheap), 'deep' (strong), 'balanced' (default) — NOT a
|
|
566
|
+
* concrete model name: the authoring model has no cognition of which
|
|
567
|
+
* providers/models a given operator has configured. The operator maps the
|
|
568
|
+
* tiers to concrete models via env (KODAX_FAST/DEEP_PROVIDER/MODEL); when a
|
|
569
|
+
* tier is unconfigured the child inherits the parent provider/model. 'fast'
|
|
570
|
+
* applies to read-only children
|
|
571
|
+
* only (write/codegen stays on the parent tier — a quality guard).
|
|
572
|
+
*/
|
|
573
|
+
readonly modelHint?: WorkflowModelHint;
|
|
574
|
+
/** Isolation policy; defaults to `shared-cwd`. */
|
|
575
|
+
readonly isolation?: WorkflowIsolation;
|
|
576
|
+
/** Per-child reasoning effort hint (e.g. 'low' | 'medium' | 'high' | 'max').
|
|
577
|
+
* The backend maps it onto the child's reasoning resolver; omit to inherit
|
|
578
|
+
* the parent/default effort. Opaque string so the agent layer needs no
|
|
579
|
+
* coding effort-enum dependency. */
|
|
580
|
+
readonly effort?: string;
|
|
581
|
+
/** Evidence refs (`task_id:<id>` etc.) seeded into the child context. */
|
|
582
|
+
readonly evidenceRefs?: readonly string[];
|
|
583
|
+
/** Optional machine-checkable postconditions for this child task. */
|
|
584
|
+
readonly verification?: WorkflowTaskVerification;
|
|
585
|
+
/**
|
|
586
|
+
* Optional JSON Schema (FEATURE_246 Part B). When set, the child is asked to
|
|
587
|
+
* end with a fenced JSON block matching the schema; the backend parses and
|
|
588
|
+
* validates it (with one bounded repair turn on a hard miss) and returns the
|
|
589
|
+
* parsed object on `WorkflowTaskResult.structured`. Orthogonal to
|
|
590
|
+
* `verification` (which checks side-effects, not return shape). Carried as an
|
|
591
|
+
* opaque value so the agent layer needs no JSON-Schema dependency.
|
|
592
|
+
*/
|
|
593
|
+
readonly outputSchema?: unknown;
|
|
594
|
+
/** Register concise finalText for digest reuse; trusted host provenance is checked separately. */
|
|
595
|
+
readonly terseResult?: boolean;
|
|
596
|
+
}
|
|
597
|
+
/** Returned by `spawnAgent` — the child is in-flight, not yet complete. */
|
|
598
|
+
interface WorkflowTaskHandle {
|
|
599
|
+
readonly taskId: string;
|
|
600
|
+
readonly name: string;
|
|
601
|
+
}
|
|
602
|
+
interface WorkflowTaskUsage {
|
|
603
|
+
readonly inputTokens?: number;
|
|
604
|
+
readonly outputTokens?: number;
|
|
605
|
+
readonly totalTokens?: number;
|
|
606
|
+
readonly cacheReadTokens?: number;
|
|
607
|
+
}
|
|
608
|
+
type WorkflowTaskSummaryKind = 'digest' | 'excerpt' | 'digest-failed' | 'pending';
|
|
609
|
+
interface WorkflowTaskSummaryEventUpdate {
|
|
610
|
+
readonly summary?: string;
|
|
611
|
+
readonly summaryKind: WorkflowTaskSummaryKind;
|
|
612
|
+
readonly usage?: WorkflowTaskUsage;
|
|
613
|
+
}
|
|
614
|
+
/** Terminal result of a spawned agent (from `wait` / `runAgent`). */
|
|
615
|
+
interface WorkflowTaskResult {
|
|
616
|
+
readonly taskId: string;
|
|
617
|
+
readonly name: string;
|
|
618
|
+
readonly status: WorkflowTaskStatus;
|
|
619
|
+
readonly finalText: string;
|
|
620
|
+
/** Schema-validated structured result (FEATURE_246 Part B), present when the
|
|
621
|
+
* spawn carried `outputSchema` and a JSON value was parsed from the child's
|
|
622
|
+
* output. The workflow script consumes it directly (e.g. `result.structured`). */
|
|
623
|
+
readonly structured?: unknown;
|
|
624
|
+
/** Durable artifacts produced by this Agent turn. */
|
|
625
|
+
readonly artifacts?: readonly string[];
|
|
626
|
+
/** Short user-facing digest, separate from the full finalText used for synthesis/audit. */
|
|
627
|
+
readonly digest?: string;
|
|
628
|
+
/** True when a digest was attempted but failed (error/timeout/empty); the UI then labels the excerpt fallback. */
|
|
629
|
+
readonly digestFailed?: boolean;
|
|
630
|
+
/** True when a digest was scheduled asynchronously and may arrive via `agent_summary_updated`. */
|
|
631
|
+
readonly digestPending?: boolean;
|
|
632
|
+
/** Task postcondition check, when a backend evaluated one. */
|
|
633
|
+
readonly verification?: WorkflowTaskVerificationResult;
|
|
634
|
+
/** True when the child exhausted its iteration budget before completing. */
|
|
635
|
+
readonly limitReached?: boolean;
|
|
636
|
+
/** Best-known provider/model used by the child, for host correlation only. */
|
|
637
|
+
readonly provider?: string;
|
|
638
|
+
readonly model?: string;
|
|
639
|
+
/** Requested semantic tier and how the local runtime resolved it. */
|
|
640
|
+
readonly requestedTier?: WorkflowModelHint | 'inherited';
|
|
641
|
+
readonly tierOutcome?: 'applied' | 'balanced-parent' | 'fast-write-ineligible' | 'unconfigured' | 'shadowed-by-selector' | 'inherited';
|
|
642
|
+
readonly providerSource?: 'explicit' | 'specialist' | 'tier' | 'parent' | 'default';
|
|
643
|
+
readonly modelSource?: 'explicit' | 'specialist' | 'tier' | 'parent';
|
|
644
|
+
readonly initialProvider?: string;
|
|
645
|
+
readonly initialModel?: string;
|
|
646
|
+
readonly finalProvider?: string;
|
|
647
|
+
readonly finalModel?: string;
|
|
648
|
+
readonly fallbackReason?: string;
|
|
649
|
+
readonly resolvedEffort?: string;
|
|
650
|
+
readonly iterations?: number;
|
|
651
|
+
readonly durationMs?: number;
|
|
652
|
+
readonly digestUsage?: WorkflowTaskUsage;
|
|
653
|
+
readonly usage?: WorkflowTaskUsage;
|
|
654
|
+
}
|
|
655
|
+
/** Point-in-time snapshot of a (possibly still-running) agent. */
|
|
656
|
+
interface WorkflowTaskSnapshot {
|
|
657
|
+
readonly taskId: string;
|
|
658
|
+
readonly name: string;
|
|
659
|
+
readonly status: WorkflowTaskStatus;
|
|
660
|
+
readonly lastText?: string;
|
|
661
|
+
}
|
|
662
|
+
interface WorkflowWaitOptions {
|
|
663
|
+
readonly timeoutMs?: number;
|
|
664
|
+
}
|
|
665
|
+
interface WorkflowParallelOptions {
|
|
666
|
+
/** In-flight cap for this parallel block; clamped by workflow
|
|
667
|
+
* maxConcurrency. */
|
|
668
|
+
readonly concurrency?: number;
|
|
669
|
+
}
|
|
670
|
+
interface WorkflowSynthesizeInput {
|
|
671
|
+
readonly inputs: readonly unknown[] | string | Record<string, unknown>;
|
|
672
|
+
readonly rubric: string;
|
|
673
|
+
}
|
|
674
|
+
interface WorkflowSynthesis {
|
|
675
|
+
readonly text: string;
|
|
676
|
+
}
|
|
677
|
+
interface WorkflowArtifactRef {
|
|
678
|
+
readonly name: string;
|
|
679
|
+
readonly path?: string;
|
|
680
|
+
}
|
|
681
|
+
interface WorkflowLogEvent {
|
|
682
|
+
readonly message: string;
|
|
683
|
+
readonly data?: unknown;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Token budget accounting. The runtime hard-stops before launching a new
|
|
687
|
+
* agent once completed children have exhausted the configured budget.
|
|
688
|
+
*/
|
|
689
|
+
interface WorkflowBudget {
|
|
690
|
+
/** Configured token budget, or null when unbounded. */
|
|
691
|
+
readonly total: number | null;
|
|
692
|
+
/** Tokens accounted across completed agents so far. */
|
|
693
|
+
spent(): number;
|
|
694
|
+
/** `max(0, total - spent())`, or Infinity when unbounded. */
|
|
695
|
+
remaining(): number;
|
|
696
|
+
}
|
|
697
|
+
interface WorkflowLimits {
|
|
698
|
+
/** Total agents spawnable across the whole run lifetime. */
|
|
699
|
+
readonly maxAgents?: number;
|
|
700
|
+
/** Maximum simultaneously in-flight agents (via runAgent / parallel). */
|
|
701
|
+
readonly maxConcurrency?: number;
|
|
702
|
+
/** Token budget. New spawns stop once completed usage exhausts it. */
|
|
703
|
+
readonly tokenBudget?: number;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* The surface a workflow script consumes. The script never gets raw
|
|
707
|
+
* fs/shell — all effects route through agent tools behind the backend.
|
|
708
|
+
*/
|
|
709
|
+
interface WorkflowApi {
|
|
710
|
+
readonly runId: string;
|
|
711
|
+
readonly args: unknown;
|
|
712
|
+
readonly budget: WorkflowBudget;
|
|
713
|
+
/** Group operations under a named phase (emits phase_started/finished). */
|
|
714
|
+
phase<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
715
|
+
/** Start a child agent; returns immediately with a handle. */
|
|
716
|
+
spawnAgent(input: WorkflowSpawnAgentInput): Promise<WorkflowTaskHandle>;
|
|
717
|
+
/** spawnAgent + wait convenience; returns the terminal result, or `null` if
|
|
718
|
+
* the child ended failed/stopped (FEATURE_246 Part E lenient failure — the
|
|
719
|
+
* harness `agent()` semantics, so scripts can `.filter(Boolean)` instead of
|
|
720
|
+
* wrapping every call in try/catch). Abort and budget/agent-cap limits still
|
|
721
|
+
* throw. */
|
|
722
|
+
runAgent(input: WorkflowSpawnAgentInput): Promise<WorkflowTaskResult | null>;
|
|
723
|
+
/** Await a spawned agent's terminal result. */
|
|
724
|
+
wait(taskId: string, opts?: WorkflowWaitOptions): Promise<WorkflowTaskResult>;
|
|
725
|
+
/** Snapshot a (possibly running) agent. */
|
|
726
|
+
snapshot(taskId: string): Promise<WorkflowTaskSnapshot>;
|
|
727
|
+
/** Snapshot a (possibly running) agent.
|
|
728
|
+
* @deprecated Prefer `snapshot(taskId)`; `output` is kept as a compatibility alias. */
|
|
729
|
+
output(taskId: string): Promise<WorkflowTaskSnapshot>;
|
|
730
|
+
/** Send a message to a running Agent through its Actor mailbox. */
|
|
731
|
+
send(taskId: string, content: string): Promise<void>;
|
|
732
|
+
/** Stop a running agent (graceful abort). */
|
|
733
|
+
stop(taskId: string, reason: string): Promise<void>;
|
|
734
|
+
/** Run lazy thunks concurrently under the concurrency gate. Thunks
|
|
735
|
+
* MUST be `() => Promise<T>` (not already-started promises) so the
|
|
736
|
+
* runtime can bound concurrency. A thunk that throws (or whose agent fails)
|
|
737
|
+
* resolves to `null` in the result array — the call itself never rejects, so
|
|
738
|
+
* `.filter(Boolean)` before use (FEATURE_246 Part E, harness parity). Abort
|
|
739
|
+
* still tears down the whole run. */
|
|
740
|
+
parallel<T>(items: readonly (() => Promise<T>)[], opts?: WorkflowParallelOptions): Promise<(T | null)[]>;
|
|
741
|
+
/**
|
|
742
|
+
* Stream items through ordered stages with NO barrier between stages: an
|
|
743
|
+
* item advances to stage N+1 as soon as its own stage N resolves,
|
|
744
|
+
* independent of other items (wall-clock = slowest single chain, not
|
|
745
|
+
* sum-of-slowest-per-stage). Each stage receives `(prev, item, index)`
|
|
746
|
+
* where `prev` is the previous stage's result (the original item at
|
|
747
|
+
* stage 1). A stage that throws drops that item to `null` and skips its
|
|
748
|
+
* remaining stages; results preserve input order. Agent spawns inside
|
|
749
|
+
* stages stay bounded by the workflow `maxConcurrency` gate. Optional:
|
|
750
|
+
* the restricted-script bootstrap always provides it; SDK consumers get
|
|
751
|
+
* it from the runtime. */
|
|
752
|
+
pipeline?(items: readonly unknown[], ...stages: readonly ((prev: unknown, item: unknown, index: number) => unknown)[]): Promise<unknown[]>;
|
|
753
|
+
/** Synthesize across inputs. Runs as a gated agent through the runtime
|
|
754
|
+
* (spawn → wait), so it counts toward maxAgents / concurrency / budget
|
|
755
|
+
* and emits run-graph events — it is NOT a backend side-channel. */
|
|
756
|
+
synthesize(input: WorkflowSynthesizeInput): Promise<WorkflowSynthesis>;
|
|
757
|
+
/**
|
|
758
|
+
* Run another saved/built-in workflow inline as a sub-step (FEATURE_246 Part E,
|
|
759
|
+
* harness parity). Resolves the module by name via the host-injected resolver
|
|
760
|
+
* and runs it under THIS run's runtime — sharing the same concurrency cap,
|
|
761
|
+
* agent counter, token budget, and abort signal. **One level only**: calling
|
|
762
|
+
* `workflow(...)` from inside a nested workflow throws. Returns whatever the
|
|
763
|
+
* sub-workflow's `run` returns. Optional: present when a resolver is wired
|
|
764
|
+
* (the restricted-script bootstrap provides it; SDK consumers may omit). */
|
|
765
|
+
workflow?(name: string, args?: unknown): Promise<unknown>;
|
|
766
|
+
/** Persist a named artifact. */
|
|
767
|
+
artifact(name: string, value: unknown): Promise<WorkflowArtifactRef>;
|
|
768
|
+
/** Emit a free-text progress log event. */
|
|
769
|
+
log(event: WorkflowLogEvent): void;
|
|
770
|
+
}
|
|
771
|
+
/** Metadata a workflow declares (name, description, default caps). */
|
|
772
|
+
interface WorkflowMeta {
|
|
773
|
+
readonly name: string;
|
|
774
|
+
readonly description: string;
|
|
775
|
+
/** Best-effort expected child-agent count for progress UI; not a hard cap. */
|
|
776
|
+
readonly plannedAgents?: number;
|
|
777
|
+
readonly maxAgents?: number;
|
|
778
|
+
readonly maxConcurrency?: number;
|
|
779
|
+
readonly tokenBudget?: number;
|
|
780
|
+
/** True when the workflow only ever spawns read-only agents (no file
|
|
781
|
+
* writes) — surfaced in the approval prompt. */
|
|
782
|
+
readonly readOnly?: boolean;
|
|
783
|
+
/** Declared phase names, for the approval prompt preview. */
|
|
784
|
+
readonly phases?: readonly string[];
|
|
785
|
+
}
|
|
786
|
+
/** Summary shown to the user before a workflow's first run. */
|
|
787
|
+
interface WorkflowApprovalSummary {
|
|
788
|
+
readonly name: string;
|
|
789
|
+
readonly description: string;
|
|
790
|
+
readonly phases: readonly string[];
|
|
791
|
+
readonly plannedAgents?: number;
|
|
792
|
+
readonly maxAgents: number | null;
|
|
793
|
+
readonly maxConcurrency: number | null;
|
|
794
|
+
readonly tokenBudget: number | null;
|
|
795
|
+
/** Whether the workflow may write files (false for read-only workflows). */
|
|
796
|
+
readonly writesFiles: boolean;
|
|
797
|
+
}
|
|
798
|
+
/** Approval gate — returns true to proceed, false to cancel the run. */
|
|
799
|
+
type WorkflowApproval = (summary: WorkflowApprovalSummary) => boolean | Promise<boolean>;
|
|
800
|
+
/** A workflow's entry function: coordinates agents via the `WorkflowApi`. */
|
|
801
|
+
type WorkflowRun<TArgs = unknown, TResult = unknown> = (wf: WorkflowApi, args: TArgs) => Promise<TResult>;
|
|
802
|
+
/** A self-contained workflow: metadata + entry function. Built-in
|
|
803
|
+
* workflows (Phase C) and saved `.kodax/workflows/*.ts` (Phase E) both
|
|
804
|
+
* materialize to this shape. */
|
|
805
|
+
interface WorkflowModule<TArgs = unknown, TResult = unknown> {
|
|
806
|
+
readonly meta: WorkflowMeta;
|
|
807
|
+
readonly run: WorkflowRun<TArgs, TResult>;
|
|
808
|
+
}
|
|
809
|
+
/** Injected execution backend over the host's Runtime-owned Actor plane. */
|
|
810
|
+
interface WorkflowAgentBackend {
|
|
811
|
+
spawn(input: WorkflowSpawnAgentInput): Promise<WorkflowTaskHandle>;
|
|
812
|
+
/** Wait until the global Actor scheduler can admit a step. False means no slot can ever exist. */
|
|
813
|
+
waitForAgentCapacity?(signal?: AbortSignal): Promise<boolean>;
|
|
814
|
+
wait(taskId: string, opts?: WorkflowWaitOptions): Promise<WorkflowTaskResult>;
|
|
815
|
+
output(taskId: string): Promise<WorkflowTaskSnapshot>;
|
|
816
|
+
send(taskId: string, content: string): Promise<void>;
|
|
817
|
+
stop(taskId: string, reason: string): Promise<void>;
|
|
818
|
+
/** Optional late summary stream for presentation-only async digests. */
|
|
819
|
+
subscribeTaskSummaryUpdates?(listener: (taskId: string, update: WorkflowTaskSummaryEventUpdate) => void): () => void;
|
|
820
|
+
/** Optional durable artifact writer (Phase D wires the run graph).
|
|
821
|
+
* `wf.synthesize` is NOT a backend method — it runs as a gated agent
|
|
822
|
+
* through `spawn`/`wait` so it counts toward the runtime's caps. */
|
|
823
|
+
writeArtifact?(name: string, value: unknown): Promise<WorkflowArtifactRef>;
|
|
824
|
+
}
|
|
825
|
+
type WorkflowRunStatus = 'running' | 'completed' | 'failed' | 'stopped';
|
|
826
|
+
type WorkflowOutcomeStatus = 'completed' | 'partial' | 'failed' | 'interrupted';
|
|
827
|
+
interface WorkflowOutcomeResult {
|
|
828
|
+
readonly taskId: string;
|
|
829
|
+
readonly name: string;
|
|
830
|
+
readonly status: WorkflowTaskStatus;
|
|
831
|
+
readonly summary: string;
|
|
832
|
+
readonly structured?: unknown;
|
|
833
|
+
readonly artifacts: readonly string[];
|
|
834
|
+
readonly usage?: WorkflowTaskUsage;
|
|
835
|
+
}
|
|
836
|
+
interface WorkflowOutcomeError {
|
|
837
|
+
readonly taskId?: string;
|
|
838
|
+
readonly name?: string;
|
|
839
|
+
readonly message: string;
|
|
840
|
+
}
|
|
841
|
+
interface WorkflowOutcomeUsage extends WorkflowTaskUsage {
|
|
842
|
+
readonly totalSpawned: number;
|
|
843
|
+
}
|
|
844
|
+
/** Stable terminal payload exposed through the Workflow protocol owner's Agent output. */
|
|
845
|
+
interface WorkflowOutcome {
|
|
846
|
+
readonly runId: string;
|
|
847
|
+
readonly status: WorkflowOutcomeStatus;
|
|
848
|
+
readonly summary: string;
|
|
849
|
+
readonly results: readonly WorkflowOutcomeResult[];
|
|
850
|
+
readonly artifacts: readonly WorkflowArtifactRef[];
|
|
851
|
+
readonly coverage: readonly string[];
|
|
852
|
+
readonly unresolved: readonly string[];
|
|
853
|
+
readonly errors: readonly WorkflowOutcomeError[];
|
|
854
|
+
readonly usage: WorkflowOutcomeUsage;
|
|
855
|
+
}
|
|
856
|
+
/** Immutable snapshot of a workflow run's accumulated state. */
|
|
857
|
+
interface WorkflowRunState {
|
|
858
|
+
readonly runId: string;
|
|
859
|
+
readonly status: WorkflowRunStatus;
|
|
860
|
+
readonly totalSpawned: number;
|
|
861
|
+
readonly results: readonly WorkflowTaskResult[];
|
|
862
|
+
readonly events: readonly WorkflowEvent[];
|
|
863
|
+
readonly artifacts: readonly WorkflowArtifactRef[];
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
type WorkflowProcessStatus = 'running' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
|
867
|
+
type WorkflowProcessItemStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'skipped';
|
|
868
|
+
type WorkflowProcessItemKind = 'phase' | 'agent' | 'step' | 'artifact';
|
|
869
|
+
/**
|
|
870
|
+
* FEATURE_246 resume telemetry — how an agent item came to be in a resumed run.
|
|
871
|
+
* `ran` = executed live this run; `replayed-from-cache` = returned instantly from
|
|
872
|
+
* a prior run's content-addressed result cache (resumeFromRunId). Only populated
|
|
873
|
+
* on resumed runs; absent on a fresh run (treat absent as `ran`).
|
|
874
|
+
*/
|
|
875
|
+
type WorkflowProcessItemOrigin = 'ran' | 'replayed-from-cache';
|
|
876
|
+
type WorkflowProcessSummaryStatus = 'pending' | 'result' | 'notice' | 'unavailable';
|
|
877
|
+
type WorkflowProcessSource = 'command' | 'review' | 'sdk' | 'capsule' | 'extension' | 'automation';
|
|
878
|
+
interface WorkflowProcessItem {
|
|
879
|
+
readonly id: string;
|
|
880
|
+
readonly title: string;
|
|
881
|
+
readonly kind: WorkflowProcessItemKind;
|
|
882
|
+
readonly status: WorkflowProcessItemStatus;
|
|
883
|
+
readonly phaseId?: string;
|
|
884
|
+
readonly parentId?: string;
|
|
885
|
+
readonly agentId?: string;
|
|
886
|
+
readonly childAgentId?: string;
|
|
887
|
+
readonly provider?: string;
|
|
888
|
+
readonly model?: string;
|
|
889
|
+
readonly startedAt?: string;
|
|
890
|
+
readonly endedAt?: string;
|
|
891
|
+
readonly summary?: string;
|
|
892
|
+
readonly summaryStatus?: WorkflowProcessSummaryStatus;
|
|
893
|
+
readonly error?: string;
|
|
894
|
+
/** FEATURE_246 resume telemetry — see {@link WorkflowProcessItemOrigin}. */
|
|
895
|
+
readonly origin?: WorkflowProcessItemOrigin;
|
|
896
|
+
}
|
|
897
|
+
interface WorkflowEventCorrelation {
|
|
898
|
+
readonly workflowRunId: string;
|
|
899
|
+
readonly childAgentId?: string;
|
|
900
|
+
readonly phaseId?: string;
|
|
901
|
+
readonly itemId?: string;
|
|
902
|
+
}
|
|
903
|
+
interface WorkflowProcessCounts {
|
|
904
|
+
readonly pending: number;
|
|
905
|
+
readonly running: number;
|
|
906
|
+
readonly completed: number;
|
|
907
|
+
readonly failed: number;
|
|
908
|
+
readonly cancelled: number;
|
|
909
|
+
readonly skipped: number;
|
|
910
|
+
}
|
|
911
|
+
interface WorkflowProcessProgress {
|
|
912
|
+
readonly spawnedAgents: number;
|
|
913
|
+
readonly finishedAgents: number;
|
|
914
|
+
readonly activeAgents: number;
|
|
915
|
+
readonly failedAgents: number;
|
|
916
|
+
readonly stoppedAgents: number;
|
|
917
|
+
readonly agentCap?: number;
|
|
918
|
+
readonly plannedItems?: number;
|
|
919
|
+
/** FEATURE_246 resume telemetry — count of agents that replayed from a prior
|
|
920
|
+
* run's cache (origin `replayed-from-cache`). Present only when > 0, so a
|
|
921
|
+
* fresh run's progress is unchanged. */
|
|
922
|
+
readonly replayedAgents?: number;
|
|
923
|
+
}
|
|
924
|
+
interface WorkflowProcessTokenUsage {
|
|
925
|
+
readonly spent: number;
|
|
926
|
+
readonly total?: number;
|
|
927
|
+
}
|
|
928
|
+
interface WorkflowProcessArtifact {
|
|
929
|
+
readonly name: string;
|
|
930
|
+
readonly path?: string;
|
|
931
|
+
readonly description?: string;
|
|
932
|
+
}
|
|
933
|
+
interface WorkflowProcessSnapshot {
|
|
934
|
+
readonly runId: string;
|
|
935
|
+
readonly workflowName: string;
|
|
936
|
+
readonly displayName?: string;
|
|
937
|
+
readonly status: WorkflowProcessStatus;
|
|
938
|
+
readonly startedAt: string;
|
|
939
|
+
readonly updatedAt: string;
|
|
940
|
+
readonly elapsedMs?: number;
|
|
941
|
+
readonly goal?: string;
|
|
942
|
+
readonly source?: WorkflowProcessSource;
|
|
943
|
+
readonly savedWorkflowName?: string;
|
|
944
|
+
readonly sourceRunId?: string;
|
|
945
|
+
readonly sourceWorkflowName?: string;
|
|
946
|
+
readonly revisionOf?: string;
|
|
947
|
+
/** FEATURE_246 resume telemetry — the prior run this run resumed from
|
|
948
|
+
* (content-addressed replay). Absent on a fresh (non-resumed) run. */
|
|
949
|
+
readonly resumedFromRunId?: string;
|
|
950
|
+
readonly hostMetadata?: Record<string, string>;
|
|
951
|
+
readonly activePhaseId?: string;
|
|
952
|
+
readonly activePhaseIndex?: number;
|
|
953
|
+
readonly phaseCount?: number;
|
|
954
|
+
readonly items: readonly WorkflowProcessItem[];
|
|
955
|
+
readonly counts: WorkflowProcessCounts;
|
|
956
|
+
readonly progress: WorkflowProcessProgress;
|
|
957
|
+
readonly tokens?: WorkflowProcessTokenUsage;
|
|
958
|
+
readonly latestMessage?: string;
|
|
959
|
+
readonly resultSummary?: string;
|
|
960
|
+
readonly error?: string;
|
|
961
|
+
readonly artifacts?: readonly WorkflowProcessArtifact[];
|
|
962
|
+
}
|
|
963
|
+
type WorkflowProcessEvent = {
|
|
964
|
+
readonly type: 'workflow_started';
|
|
965
|
+
readonly snapshot: WorkflowProcessSnapshot;
|
|
966
|
+
} | {
|
|
967
|
+
readonly type: 'workflow_updated';
|
|
968
|
+
readonly snapshot: WorkflowProcessSnapshot;
|
|
969
|
+
readonly message?: string;
|
|
970
|
+
} | {
|
|
971
|
+
readonly type: 'workflow_finished';
|
|
972
|
+
readonly snapshot: WorkflowProcessSnapshot;
|
|
973
|
+
};
|
|
974
|
+
interface WorkflowProcessTrackerOptions {
|
|
975
|
+
readonly runId: string;
|
|
976
|
+
readonly workflowName: string;
|
|
977
|
+
readonly displayName?: string;
|
|
978
|
+
readonly goal?: string;
|
|
979
|
+
readonly source?: WorkflowProcessSource;
|
|
980
|
+
readonly savedWorkflowName?: string;
|
|
981
|
+
readonly sourceRunId?: string;
|
|
982
|
+
readonly sourceWorkflowName?: string;
|
|
983
|
+
readonly revisionOf?: string;
|
|
984
|
+
/** FEATURE_246 resume telemetry — the prior run this run resumed from. */
|
|
985
|
+
readonly resumedFromRunId?: string;
|
|
986
|
+
readonly hostMetadata?: Record<string, string>;
|
|
987
|
+
readonly phases?: readonly string[];
|
|
988
|
+
readonly maxAgents?: number;
|
|
989
|
+
readonly plannedAgents?: number;
|
|
990
|
+
readonly tokenBudget?: number;
|
|
991
|
+
readonly resultSummary?: string;
|
|
992
|
+
readonly artifacts?: readonly WorkflowArtifactRef[];
|
|
993
|
+
readonly now?: () => string;
|
|
994
|
+
}
|
|
995
|
+
interface WorkflowTaskSummaryUpdate {
|
|
996
|
+
readonly summary?: string;
|
|
997
|
+
readonly summaryStatus: WorkflowProcessSummaryStatus;
|
|
998
|
+
}
|
|
999
|
+
interface WorkflowProcessTracker {
|
|
1000
|
+
applyEvent(event: WorkflowEvent): WorkflowProcessEvent;
|
|
1001
|
+
updateTaskSummary(taskId: string, update: WorkflowTaskSummaryUpdate): WorkflowProcessEvent | undefined;
|
|
1002
|
+
setStatus(status: WorkflowProcessStatus, message?: string): WorkflowProcessEvent;
|
|
1003
|
+
setResultSummary(resultSummary: string | undefined): WorkflowProcessEvent;
|
|
1004
|
+
getSnapshot(): WorkflowProcessSnapshot;
|
|
1005
|
+
}
|
|
1006
|
+
declare function isFinalWorkflowProcessStatus(status: WorkflowProcessStatus): boolean;
|
|
1007
|
+
declare function normalizeHostMetadata(value: unknown): Record<string, string> | undefined;
|
|
1008
|
+
declare function createWorkflowProcessTracker(options: WorkflowProcessTrackerOptions): WorkflowProcessTracker;
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* FEATURE_246 Part A0 (ADR-046) — neutral workflow run lifecycle manager.
|
|
1012
|
+
*
|
|
1013
|
+
* Domain-neutral run registry + lifecycle (pause / resume / stop), process-event
|
|
1014
|
+
* tracking, and terminal settle — lifted out of `@kodax-ai/coding` so any agent
|
|
1015
|
+
* (including non-coding SDK hosts) can host and manage workflow runs.
|
|
1016
|
+
*
|
|
1017
|
+
* It never knows HOW a run executes: the caller injects a `runFn` thunk that
|
|
1018
|
+
* receives lifecycle hooks (`onEvent` / `signal` / `beforeSpawn`) and returns a
|
|
1019
|
+
* caller-shaped outcome, plus a `classify` mapping that outcome to a neutral
|
|
1020
|
+
* terminal status and an `onError` that synthesizes a failure outcome. The
|
|
1021
|
+
* coding layer wires `runFn` to its `runWorkflowModule` / `runWorkflowFromOptions`
|
|
1022
|
+
* (backend + run-graph + worktrees); SDK hosts wire their own. Dependency arrows
|
|
1023
|
+
* therefore point only coding → agent — no cycle.
|
|
1024
|
+
*/
|
|
1025
|
+
|
|
1026
|
+
type ManagedWorkflowStatus = 'running' | 'paused' | 'completed' | 'failed' | 'denied' | 'stopped';
|
|
1027
|
+
/** Provenance/display metadata for a run's process tracker. */
|
|
1028
|
+
type WorkflowProcessMetadata = Pick<WorkflowProcessTrackerOptions, 'displayName' | 'goal' | 'source' | 'savedWorkflowName' | 'sourceRunId' | 'sourceWorkflowName' | 'revisionOf' | 'resumedFromRunId' | 'hostMetadata'>;
|
|
1029
|
+
interface ManagedWorkflowSnapshot {
|
|
1030
|
+
readonly stop?: {
|
|
1031
|
+
readonly state: 'unknown' | 'confirmed';
|
|
1032
|
+
};
|
|
1033
|
+
readonly runId: string;
|
|
1034
|
+
readonly workflow: string;
|
|
1035
|
+
readonly status: ManagedWorkflowStatus;
|
|
1036
|
+
readonly totalSpawned: number;
|
|
1037
|
+
readonly eventCount: number;
|
|
1038
|
+
readonly startedAt: number;
|
|
1039
|
+
readonly endedAt?: number;
|
|
1040
|
+
readonly error?: string;
|
|
1041
|
+
readonly resultText?: string;
|
|
1042
|
+
}
|
|
1043
|
+
interface ManagedWorkflowRun<TOutcome = unknown> {
|
|
1044
|
+
readonly runId: string;
|
|
1045
|
+
readonly done: Promise<TOutcome>;
|
|
1046
|
+
getSnapshot(): ManagedWorkflowSnapshot | undefined;
|
|
1047
|
+
getProcessSnapshot(): WorkflowProcessSnapshot | undefined;
|
|
1048
|
+
}
|
|
1049
|
+
/** Lifecycle hooks the manager injects into the caller's `runFn`. */
|
|
1050
|
+
interface ManagedRunHooks {
|
|
1051
|
+
/** Forward every workflow event so the manager can track spawn/progress. */
|
|
1052
|
+
readonly onEvent: (event: WorkflowEvent) => void;
|
|
1053
|
+
/** Abort signal owned by the manager (fires on stop()). */
|
|
1054
|
+
readonly signal: AbortSignal;
|
|
1055
|
+
/** Await before launching each agent so pause() can gate new spawns. */
|
|
1056
|
+
readonly beforeSpawn: () => Promise<void>;
|
|
1057
|
+
}
|
|
1058
|
+
/** Neutral terminal classification of a caller-shaped outcome. */
|
|
1059
|
+
interface ManagedRunClassification {
|
|
1060
|
+
readonly status: 'completed' | 'failed' | 'denied';
|
|
1061
|
+
readonly error?: Error;
|
|
1062
|
+
readonly resultText?: string;
|
|
1063
|
+
}
|
|
1064
|
+
interface StartManagedRunInput<TOutcome> {
|
|
1065
|
+
readonly runId: string;
|
|
1066
|
+
/** Display name (usually the workflow's `meta.name`). */
|
|
1067
|
+
readonly workflow: string;
|
|
1068
|
+
readonly phases?: readonly string[];
|
|
1069
|
+
readonly maxAgents?: number;
|
|
1070
|
+
readonly plannedAgents?: number;
|
|
1071
|
+
readonly tokenBudget?: number;
|
|
1072
|
+
readonly processMetadata?: WorkflowProcessMetadata;
|
|
1073
|
+
readonly signal?: AbortSignal;
|
|
1074
|
+
/** Executes the run with the manager's lifecycle hooks injected. */
|
|
1075
|
+
readonly runFn: (hooks: ManagedRunHooks) => Promise<TOutcome>;
|
|
1076
|
+
/** Map the caller's terminal outcome to a neutral status for the snapshot. */
|
|
1077
|
+
readonly classify: (outcome: TOutcome) => ManagedRunClassification;
|
|
1078
|
+
/** Synthesize a caller-shaped outcome when `runFn` throws. */
|
|
1079
|
+
readonly onError: (error: unknown) => TOutcome;
|
|
1080
|
+
}
|
|
1081
|
+
interface WorkflowRunManager {
|
|
1082
|
+
start<TOutcome>(input: StartManagedRunInput<TOutcome>): ManagedWorkflowRun<TOutcome>;
|
|
1083
|
+
list(): readonly ManagedWorkflowSnapshot[];
|
|
1084
|
+
get(runId: string): ManagedWorkflowSnapshot | undefined;
|
|
1085
|
+
subscribeWorkflowProcess(listener: (event: WorkflowProcessEvent) => void): () => void;
|
|
1086
|
+
getWorkflowProcessSnapshot(runId: string): WorkflowProcessSnapshot | undefined;
|
|
1087
|
+
listWorkflowProcessSnapshots(options?: {
|
|
1088
|
+
readonly activeOnly?: boolean;
|
|
1089
|
+
readonly limit?: number;
|
|
1090
|
+
}): readonly WorkflowProcessSnapshot[];
|
|
1091
|
+
pause(runId: string): boolean;
|
|
1092
|
+
resume(runId: string): boolean;
|
|
1093
|
+
stop(runId: string, reason?: string): boolean;
|
|
1094
|
+
}
|
|
1095
|
+
declare function createWorkflowRunManager(deps?: {
|
|
1096
|
+
readonly now?: () => number;
|
|
1097
|
+
}): WorkflowRunManager;
|
|
1098
|
+
declare function getDefaultWorkflowRunManager(): WorkflowRunManager;
|
|
1099
|
+
|
|
1100
|
+
type DispatchableAgentOrigin = 'native' | 'constructed' | 'external';
|
|
1101
|
+
type AgentExecutorProtocol = 'native' | 'a2a' | 'mcp' | 'http';
|
|
1102
|
+
type ExternalAgentProtocol = Exclude<AgentExecutorProtocol, 'native'>;
|
|
1103
|
+
type CapabilitySupport = 'supported' | 'unsupported' | 'conditional';
|
|
1104
|
+
type AgentJsonValue = string | number | boolean | null | AgentJsonObject | readonly AgentJsonValue[];
|
|
1105
|
+
interface AgentJsonObject {
|
|
1106
|
+
readonly [key: string]: AgentJsonValue;
|
|
1107
|
+
}
|
|
1108
|
+
interface AgentCapabilityDeclaration {
|
|
1109
|
+
readonly streaming: CapabilitySupport;
|
|
1110
|
+
readonly durableTasks: CapabilitySupport;
|
|
1111
|
+
readonly inputRequired: CapabilitySupport;
|
|
1112
|
+
readonly cancellation: CapabilitySupport;
|
|
1113
|
+
readonly artifacts: CapabilitySupport;
|
|
1114
|
+
}
|
|
1115
|
+
interface AgentEffectDeclaration {
|
|
1116
|
+
readonly remote: 'none' | 'read' | 'write' | 'unknown';
|
|
1117
|
+
readonly workspace: 'none' | 'proposal' | 'direct';
|
|
1118
|
+
}
|
|
1119
|
+
interface ExternalAgentEffectDeclaration extends AgentEffectDeclaration {
|
|
1120
|
+
readonly workspace: 'none' | 'proposal';
|
|
1121
|
+
}
|
|
1122
|
+
interface DispatchableAgentDescriptor {
|
|
1123
|
+
readonly agentId: string;
|
|
1124
|
+
readonly displayName: string;
|
|
1125
|
+
readonly description?: string;
|
|
1126
|
+
readonly origin: DispatchableAgentOrigin;
|
|
1127
|
+
readonly protocol: AgentExecutorProtocol;
|
|
1128
|
+
readonly configurationRevision: string;
|
|
1129
|
+
readonly skills: readonly string[];
|
|
1130
|
+
readonly inputModalities: readonly string[];
|
|
1131
|
+
readonly outputModalities: readonly string[];
|
|
1132
|
+
readonly capabilities: AgentCapabilityDeclaration;
|
|
1133
|
+
readonly effects: AgentEffectDeclaration;
|
|
1134
|
+
}
|
|
1135
|
+
type AgentDispatchabilityStatus = 'dispatchable' | 'degraded' | 'busy' | 'unavailable';
|
|
1136
|
+
interface AgentDispatchabilitySnapshot {
|
|
1137
|
+
readonly status: AgentDispatchabilityStatus;
|
|
1138
|
+
readonly checkedAt: string;
|
|
1139
|
+
readonly reasons: readonly string[];
|
|
1140
|
+
readonly retryAfterMs?: number;
|
|
1141
|
+
}
|
|
1142
|
+
interface DispatchableAgentListing {
|
|
1143
|
+
readonly descriptor: DispatchableAgentDescriptor;
|
|
1144
|
+
readonly dispatchability: AgentDispatchabilitySnapshot;
|
|
1145
|
+
}
|
|
1146
|
+
interface AgentDispatchContext {
|
|
1147
|
+
readonly actorId: string;
|
|
1148
|
+
readonly projectId?: string;
|
|
1149
|
+
readonly workflowId?: string;
|
|
1150
|
+
readonly parentTaskId?: string;
|
|
1151
|
+
readonly runId?: string;
|
|
1152
|
+
readonly nodeId?: string;
|
|
1153
|
+
readonly dataClassifications?: readonly string[];
|
|
1154
|
+
readonly budget?: number;
|
|
1155
|
+
}
|
|
1156
|
+
interface AgentCapabilityRequirements {
|
|
1157
|
+
readonly streaming?: boolean;
|
|
1158
|
+
readonly durableTasks?: boolean;
|
|
1159
|
+
readonly inputRequired?: boolean;
|
|
1160
|
+
readonly cancellation?: boolean;
|
|
1161
|
+
readonly artifacts?: boolean;
|
|
1162
|
+
}
|
|
1163
|
+
interface DispatchableAgentQuery extends AgentDispatchContext {
|
|
1164
|
+
readonly requiredSkills?: readonly string[];
|
|
1165
|
+
readonly requiredCapabilities?: AgentCapabilityRequirements;
|
|
1166
|
+
readonly readOnly?: boolean;
|
|
1167
|
+
}
|
|
1168
|
+
interface ExternalAgentHealth {
|
|
1169
|
+
readonly status: 'healthy' | 'degraded' | 'unhealthy';
|
|
1170
|
+
readonly checkedAt: string;
|
|
1171
|
+
readonly retryAfterMs?: number;
|
|
1172
|
+
readonly diagnostic?: string;
|
|
1173
|
+
}
|
|
1174
|
+
interface ExternalAgentRegistration {
|
|
1175
|
+
readonly agentId: string;
|
|
1176
|
+
readonly displayName: string;
|
|
1177
|
+
readonly description?: string;
|
|
1178
|
+
readonly managementOwner?: string;
|
|
1179
|
+
readonly enabled: boolean;
|
|
1180
|
+
readonly executorId: string;
|
|
1181
|
+
readonly protocol: ExternalAgentProtocol;
|
|
1182
|
+
/**
|
|
1183
|
+
* Stable content identity for this execution route. Producers must issue a
|
|
1184
|
+
* new value whenever immutable execution content changes. The same immutable
|
|
1185
|
+
* content may reuse its stable revision after removal or Runtime restart;
|
|
1186
|
+
* different content must never reuse a revision.
|
|
1187
|
+
*/
|
|
1188
|
+
readonly configurationRevision: string;
|
|
1189
|
+
readonly endpointIdentityHash: string;
|
|
1190
|
+
readonly credentialRef?: string;
|
|
1191
|
+
/** Public, JSON-safe executor configuration. Secrets must remain references. */
|
|
1192
|
+
readonly executorConfig?: AgentJsonObject;
|
|
1193
|
+
readonly skills?: readonly string[];
|
|
1194
|
+
readonly inputModalities?: readonly string[];
|
|
1195
|
+
readonly outputModalities?: readonly string[];
|
|
1196
|
+
readonly capabilities: AgentCapabilityDeclaration;
|
|
1197
|
+
readonly effects: ExternalAgentEffectDeclaration;
|
|
1198
|
+
readonly health?: ExternalAgentHealth;
|
|
1199
|
+
readonly maxConcurrency?: number;
|
|
1200
|
+
readonly minimumBudget?: number;
|
|
1201
|
+
readonly allowedDataClassifications?: readonly string[];
|
|
1202
|
+
}
|
|
1203
|
+
interface ExternalAgentRegistrationSummary {
|
|
1204
|
+
readonly agentId: string;
|
|
1205
|
+
readonly displayName: string;
|
|
1206
|
+
readonly description?: string;
|
|
1207
|
+
readonly managementOwner?: string;
|
|
1208
|
+
readonly enabled: boolean;
|
|
1209
|
+
readonly executorId: string;
|
|
1210
|
+
readonly protocol: ExternalAgentProtocol;
|
|
1211
|
+
readonly configurationRevision: string;
|
|
1212
|
+
readonly endpointIdentityHash: string;
|
|
1213
|
+
readonly credentialConfigured: boolean;
|
|
1214
|
+
readonly capabilities: AgentCapabilityDeclaration;
|
|
1215
|
+
readonly effects: ExternalAgentEffectDeclaration;
|
|
1216
|
+
readonly health?: ExternalAgentHealth;
|
|
1217
|
+
readonly diagnostics: readonly string[];
|
|
1218
|
+
}
|
|
1219
|
+
interface AgentDispatchPolicyInput {
|
|
1220
|
+
readonly registration: ExternalAgentRegistration;
|
|
1221
|
+
readonly query: DispatchableAgentQuery;
|
|
1222
|
+
}
|
|
1223
|
+
interface AgentDispatchPolicyDecision {
|
|
1224
|
+
readonly allowed: boolean;
|
|
1225
|
+
readonly reasons?: readonly string[];
|
|
1226
|
+
}
|
|
1227
|
+
type AgentDispatchPolicy = (input: AgentDispatchPolicyInput) => AgentDispatchPolicyDecision | Promise<AgentDispatchPolicyDecision>;
|
|
1228
|
+
interface AgentCredentialBroker {
|
|
1229
|
+
isAvailable?(credentialRef: string): boolean | Promise<boolean>;
|
|
1230
|
+
withCredential<T>(credentialRef: string, use: (credential: string) => Promise<T>): Promise<T>;
|
|
1231
|
+
}
|
|
1232
|
+
interface AgentArtifactReference {
|
|
1233
|
+
readonly name: string;
|
|
1234
|
+
readonly mimeType?: string;
|
|
1235
|
+
readonly size?: number;
|
|
1236
|
+
readonly hash?: string;
|
|
1237
|
+
readonly uri?: string;
|
|
1238
|
+
readonly provenance?: string;
|
|
1239
|
+
readonly producingAgentId?: string;
|
|
1240
|
+
readonly remoteTaskId?: string;
|
|
1241
|
+
}
|
|
1242
|
+
interface AgentArtifactPolicyInput {
|
|
1243
|
+
readonly registration: ExternalAgentRegistration;
|
|
1244
|
+
readonly artifact: AgentArtifactReference;
|
|
1245
|
+
}
|
|
1246
|
+
interface AgentArtifactPolicyDecision {
|
|
1247
|
+
readonly allowed: boolean;
|
|
1248
|
+
readonly reason?: string;
|
|
1249
|
+
}
|
|
1250
|
+
type AgentArtifactPolicy = (input: AgentArtifactPolicyInput) => AgentArtifactPolicyDecision | Promise<AgentArtifactPolicyDecision>;
|
|
1251
|
+
interface AgentTaskUsage {
|
|
1252
|
+
readonly inputTokens?: number;
|
|
1253
|
+
readonly outputTokens?: number;
|
|
1254
|
+
readonly totalTokens?: number;
|
|
1255
|
+
readonly cost?: number;
|
|
1256
|
+
readonly currency?: string;
|
|
1257
|
+
}
|
|
1258
|
+
type AgentTaskState = 'submitted' | 'working' | 'input-required' | 'auth-required' | 'completed' | 'failed' | 'canceled' | 'rejected' | 'unknown';
|
|
1259
|
+
type AgentTaskCancellation = 'none' | 'requested' | 'confirmed' | 'unsupported' | 'failed' | 'unknown';
|
|
1260
|
+
interface AgentTaskProgress {
|
|
1261
|
+
readonly message?: string;
|
|
1262
|
+
readonly percent?: number;
|
|
1263
|
+
}
|
|
1264
|
+
interface AgentTaskCorrelation {
|
|
1265
|
+
readonly parentTaskId?: string;
|
|
1266
|
+
readonly workflowId?: string;
|
|
1267
|
+
readonly runId?: string;
|
|
1268
|
+
readonly nodeId?: string;
|
|
1269
|
+
}
|
|
1270
|
+
interface AgentTaskRegistrationSnapshot {
|
|
1271
|
+
readonly agentId: string;
|
|
1272
|
+
readonly origin: DispatchableAgentOrigin;
|
|
1273
|
+
readonly executorId: string;
|
|
1274
|
+
readonly protocol: AgentExecutorProtocol;
|
|
1275
|
+
readonly configurationRevision: string;
|
|
1276
|
+
readonly endpointIdentityHash?: string;
|
|
1277
|
+
readonly capabilities: AgentCapabilityDeclaration;
|
|
1278
|
+
readonly effects: AgentEffectDeclaration;
|
|
1279
|
+
}
|
|
1280
|
+
interface AgentExecutorTaskReference {
|
|
1281
|
+
readonly idempotencyKey: string;
|
|
1282
|
+
readonly remoteTaskId?: string;
|
|
1283
|
+
readonly metadata?: AgentJsonObject;
|
|
1284
|
+
}
|
|
1285
|
+
interface AgentTaskSnapshot extends AgentTaskCorrelation {
|
|
1286
|
+
readonly taskId: string;
|
|
1287
|
+
readonly route: 'local' | 'external';
|
|
1288
|
+
readonly agentId: string;
|
|
1289
|
+
readonly objective: string;
|
|
1290
|
+
readonly state: AgentTaskState;
|
|
1291
|
+
readonly cancellation: AgentTaskCancellation;
|
|
1292
|
+
readonly registration: AgentTaskRegistrationSnapshot;
|
|
1293
|
+
readonly idempotencyKey: string;
|
|
1294
|
+
readonly dispatchAttempt: number;
|
|
1295
|
+
readonly createdAt: string;
|
|
1296
|
+
readonly updatedAt: string;
|
|
1297
|
+
readonly remoteTaskId?: string;
|
|
1298
|
+
readonly executorReference?: AgentExecutorTaskReference;
|
|
1299
|
+
readonly progress?: AgentTaskProgress;
|
|
1300
|
+
readonly output?: string;
|
|
1301
|
+
readonly error?: string;
|
|
1302
|
+
readonly cancellationError?: string;
|
|
1303
|
+
readonly artifacts?: readonly AgentArtifactReference[];
|
|
1304
|
+
readonly usage?: AgentTaskUsage;
|
|
1305
|
+
}
|
|
1306
|
+
interface AgentExecutorTaskSnapshot {
|
|
1307
|
+
readonly state: AgentTaskState;
|
|
1308
|
+
readonly progress?: AgentTaskProgress;
|
|
1309
|
+
readonly output?: string;
|
|
1310
|
+
readonly error?: string;
|
|
1311
|
+
readonly artifacts?: readonly AgentArtifactReference[];
|
|
1312
|
+
readonly usage?: AgentTaskUsage;
|
|
1313
|
+
}
|
|
1314
|
+
interface AgentTaskStartInput {
|
|
1315
|
+
readonly taskId?: string;
|
|
1316
|
+
readonly agentId: string;
|
|
1317
|
+
readonly objective: string;
|
|
1318
|
+
readonly context: AgentDispatchContext;
|
|
1319
|
+
readonly readOnly?: boolean;
|
|
1320
|
+
readonly requiredSkills?: readonly string[];
|
|
1321
|
+
readonly requiredCapabilities?: AgentCapabilityRequirements;
|
|
1322
|
+
readonly expectedConfigurationRevision?: string;
|
|
1323
|
+
readonly idempotencyKey?: string;
|
|
1324
|
+
readonly input?: string;
|
|
1325
|
+
}
|
|
1326
|
+
interface AgentContinuationInput {
|
|
1327
|
+
readonly content: string;
|
|
1328
|
+
}
|
|
1329
|
+
interface AgentExecutorEvent {
|
|
1330
|
+
readonly state?: AgentTaskState;
|
|
1331
|
+
readonly progress?: AgentTaskProgress;
|
|
1332
|
+
readonly output?: string;
|
|
1333
|
+
readonly error?: string;
|
|
1334
|
+
readonly artifacts?: readonly AgentArtifactReference[];
|
|
1335
|
+
readonly usage?: AgentTaskUsage;
|
|
1336
|
+
}
|
|
1337
|
+
interface AgentTaskEvent extends AgentExecutorEvent {
|
|
1338
|
+
readonly taskId: string;
|
|
1339
|
+
readonly seq: number;
|
|
1340
|
+
readonly timestamp: string;
|
|
1341
|
+
readonly type: 'submitted' | 'state' | 'progress' | 'output' | 'artifact' | 'usage' | 'error' | 'cancellation';
|
|
1342
|
+
readonly cancellation?: AgentTaskCancellation;
|
|
1343
|
+
}
|
|
1344
|
+
interface AgentExecutorPreflightResult {
|
|
1345
|
+
readonly ok: boolean;
|
|
1346
|
+
readonly reasons?: readonly string[];
|
|
1347
|
+
}
|
|
1348
|
+
interface AgentExecutor {
|
|
1349
|
+
preflight?(input: AgentTaskStartInput): Promise<AgentExecutorPreflightResult>;
|
|
1350
|
+
start(input: AgentTaskStartInput, signal?: AbortSignal): Promise<AgentExecutorTaskReference>;
|
|
1351
|
+
events(reference: AgentExecutorTaskReference): AsyncIterable<AgentExecutorEvent>;
|
|
1352
|
+
get(reference: AgentExecutorTaskReference): Promise<AgentExecutorTaskSnapshot>;
|
|
1353
|
+
sendInput(reference: AgentExecutorTaskReference, input: AgentContinuationInput): Promise<void>;
|
|
1354
|
+
cancel(reference: AgentExecutorTaskReference, reason?: string): Promise<AgentExecutorTaskSnapshot>;
|
|
1355
|
+
reconcile(reference: AgentExecutorTaskReference): Promise<AgentExecutorTaskSnapshot>;
|
|
1356
|
+
dispose(): Promise<void>;
|
|
1357
|
+
}
|
|
1358
|
+
interface AgentExecutorFactoryContext {
|
|
1359
|
+
withCredential<T>(credentialRef: string, use: (credential: string) => Promise<T>): Promise<T>;
|
|
1360
|
+
authorizeArtifact(artifact: AgentArtifactReference): Promise<void>;
|
|
1361
|
+
}
|
|
1362
|
+
interface AgentExecutorFactory {
|
|
1363
|
+
readonly executorId: string;
|
|
1364
|
+
readonly protocol: ExternalAgentProtocol;
|
|
1365
|
+
create(registration: ExternalAgentRegistration, context: AgentExecutorFactoryContext): Promise<AgentExecutor>;
|
|
1366
|
+
}
|
|
1367
|
+
interface AgentPreflightInput {
|
|
1368
|
+
readonly agentId: string;
|
|
1369
|
+
readonly query: DispatchableAgentQuery;
|
|
1370
|
+
readonly expectedConfigurationRevision?: string;
|
|
1371
|
+
}
|
|
1372
|
+
interface AgentPreflightResult {
|
|
1373
|
+
readonly ok: boolean;
|
|
1374
|
+
readonly descriptor?: DispatchableAgentDescriptor;
|
|
1375
|
+
readonly dispatchability: AgentDispatchabilitySnapshot;
|
|
1376
|
+
readonly reasons: readonly string[];
|
|
1377
|
+
}
|
|
1378
|
+
interface AgentTaskFilter {
|
|
1379
|
+
readonly agentId?: string;
|
|
1380
|
+
readonly parentTaskId?: string;
|
|
1381
|
+
readonly workflowId?: string;
|
|
1382
|
+
readonly runId?: string;
|
|
1383
|
+
readonly state?: AgentTaskState | readonly AgentTaskState[];
|
|
1384
|
+
}
|
|
1385
|
+
interface LocalAgentTaskInput extends AgentTaskCorrelation {
|
|
1386
|
+
readonly taskId: string;
|
|
1387
|
+
readonly agentId: string;
|
|
1388
|
+
readonly objective: string;
|
|
1389
|
+
readonly configurationRevision: string;
|
|
1390
|
+
readonly origin?: 'native' | 'constructed';
|
|
1391
|
+
}
|
|
1392
|
+
interface LocalAgentTaskUpdate {
|
|
1393
|
+
readonly state?: AgentTaskState;
|
|
1394
|
+
readonly progress?: AgentTaskProgress;
|
|
1395
|
+
readonly output?: string;
|
|
1396
|
+
readonly error?: string;
|
|
1397
|
+
readonly artifacts?: readonly AgentArtifactReference[];
|
|
1398
|
+
readonly usage?: AgentTaskUsage;
|
|
1399
|
+
}
|
|
1400
|
+
interface AgentExecutorPlaneStore {
|
|
1401
|
+
loadRegistrations(): Promise<readonly ExternalAgentRegistration[]>;
|
|
1402
|
+
saveRegistrations(registrations: readonly ExternalAgentRegistration[]): Promise<void>;
|
|
1403
|
+
/**
|
|
1404
|
+
* Optional compatibility extension for durable executor recovery across a
|
|
1405
|
+
* registration update/removal. Built-in stores implement both hooks. A
|
|
1406
|
+
* custom store that omits them can only recover through a still-current
|
|
1407
|
+
* registration with the same revision; otherwise recovery fails closed.
|
|
1408
|
+
* Implement both hooks or neither. The plane is the single writer and
|
|
1409
|
+
* serializes whole-map replacements. Credential fields in snapshots are
|
|
1410
|
+
* references only; `executorConfig` must likewise contain public data or secret
|
|
1411
|
+
* references, never secret material. A store must never resolve or persist a
|
|
1412
|
+
* referenced secret value.
|
|
1413
|
+
*/
|
|
1414
|
+
loadTaskRegistrationSnapshots?(): Promise<readonly ExternalAgentRegistration[]>;
|
|
1415
|
+
saveTaskRegistrationSnapshots?(registrations: readonly ExternalAgentRegistration[]): Promise<void>;
|
|
1416
|
+
loadTasks(): Promise<readonly AgentTaskSnapshot[]>;
|
|
1417
|
+
saveTask(task: AgentTaskSnapshot): Promise<void>;
|
|
1418
|
+
loadEvents(taskId: string): Promise<readonly AgentTaskEvent[]>;
|
|
1419
|
+
appendEvent(event: AgentTaskEvent): Promise<void>;
|
|
1420
|
+
}
|
|
1421
|
+
interface AgentRegistrationMutationOptions {
|
|
1422
|
+
/** `null` means that no registration may exist; `undefined` disables CAS. */
|
|
1423
|
+
readonly expectedConfigurationRevision?: string | null;
|
|
1424
|
+
/** `null` means that no manager may own the registration; `undefined` disables owner CAS. */
|
|
1425
|
+
readonly expectedManagementOwner?: string | null;
|
|
1426
|
+
}
|
|
1427
|
+
interface AgentRegistrationEnabledMutationOptions extends AgentRegistrationMutationOptions {
|
|
1428
|
+
/** Atomically claims an unowned registration; a different existing owner is rejected. */
|
|
1429
|
+
readonly claimOwner?: string;
|
|
1430
|
+
}
|
|
1431
|
+
interface AgentRegistrationService {
|
|
1432
|
+
list(): Promise<readonly ExternalAgentRegistrationSummary[]>;
|
|
1433
|
+
upsert(input: ExternalAgentRegistration, options?: AgentRegistrationMutationOptions): Promise<ExternalAgentRegistrationSummary>;
|
|
1434
|
+
setEnabled(agentId: string, enabled: boolean, options?: AgentRegistrationEnabledMutationOptions): Promise<ExternalAgentRegistrationSummary | undefined>;
|
|
1435
|
+
remove(agentId: string, options?: AgentRegistrationMutationOptions): Promise<boolean>;
|
|
1436
|
+
}
|
|
1437
|
+
interface AgentTaskService {
|
|
1438
|
+
start(input: AgentTaskStartInput, signal?: AbortSignal): Promise<AgentTaskSnapshot>;
|
|
1439
|
+
list(filter?: AgentTaskFilter): Promise<readonly AgentTaskSnapshot[]>;
|
|
1440
|
+
get(taskId: string): Promise<AgentTaskSnapshot>;
|
|
1441
|
+
events(taskId: string, cursor?: number): Promise<readonly AgentTaskEvent[]>;
|
|
1442
|
+
wait(taskId: string, timeoutMs?: number): Promise<AgentTaskSnapshot>;
|
|
1443
|
+
sendInput(taskId: string, input: AgentContinuationInput): Promise<AgentTaskSnapshot>;
|
|
1444
|
+
cancel(taskId: string, reason?: string): Promise<AgentTaskSnapshot>;
|
|
1445
|
+
reconcile(taskId: string): Promise<AgentTaskSnapshot>;
|
|
1446
|
+
recordLocal(input: LocalAgentTaskInput): Promise<AgentTaskSnapshot>;
|
|
1447
|
+
updateLocal(taskId: string, update: LocalAgentTaskUpdate): Promise<AgentTaskSnapshot>;
|
|
1448
|
+
}
|
|
1449
|
+
interface AgentExecutorPlaneBinding {
|
|
1450
|
+
readonly plane: AgentExecutorPlane;
|
|
1451
|
+
readonly context: AgentDispatchContext;
|
|
1452
|
+
}
|
|
1453
|
+
interface AgentExecutorPlane {
|
|
1454
|
+
readonly registrations: AgentRegistrationService;
|
|
1455
|
+
readonly tasks: AgentTaskService;
|
|
1456
|
+
listDispatchable(query: DispatchableAgentQuery, localAgents?: readonly DispatchableAgentDescriptor[]): Promise<readonly DispatchableAgentListing[]>;
|
|
1457
|
+
describe(agentId: string, query: DispatchableAgentQuery, localAgents?: readonly DispatchableAgentDescriptor[]): Promise<DispatchableAgentListing | undefined>;
|
|
1458
|
+
preflight(input: AgentPreflightInput, localAgents?: readonly DispatchableAgentDescriptor[]): Promise<AgentPreflightResult>;
|
|
1459
|
+
close(): Promise<void>;
|
|
1460
|
+
}
|
|
1461
|
+
interface AgentExecutorPlaneBackgroundErrorContext {
|
|
1462
|
+
readonly operation: 'event-pump-recovery' | 'task-admission-event' | 'executor-dispose';
|
|
1463
|
+
readonly taskId?: string;
|
|
1464
|
+
readonly agentId?: string;
|
|
1465
|
+
readonly configurationRevision?: string;
|
|
1466
|
+
}
|
|
1467
|
+
type AgentExecutorPlaneBackgroundErrorHandler = (error: Error, context: AgentExecutorPlaneBackgroundErrorContext) => void | Promise<void>;
|
|
1468
|
+
interface CreateAgentExecutorPlaneOptions {
|
|
1469
|
+
readonly factories: readonly AgentExecutorFactory[];
|
|
1470
|
+
readonly policy: AgentDispatchPolicy;
|
|
1471
|
+
readonly credentialBroker?: AgentCredentialBroker;
|
|
1472
|
+
readonly artifactPolicy?: AgentArtifactPolicy;
|
|
1473
|
+
/** Receives failures from detached event handling and best-effort resource cleanup. */
|
|
1474
|
+
readonly onBackgroundError?: AgentExecutorPlaneBackgroundErrorHandler;
|
|
1475
|
+
readonly store?: AgentExecutorPlaneStore;
|
|
1476
|
+
readonly now?: () => Date;
|
|
1477
|
+
readonly createTaskId?: () => string;
|
|
1478
|
+
readonly createIdempotencyKey?: () => string;
|
|
1479
|
+
/** Overall bound for draining admitted work and disposing executors during close. */
|
|
1480
|
+
readonly closeTimeoutMs?: number;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
export { ASK_USER_BACK_SIGNAL as A, ASK_USER_CUSTOM_INPUT_SIGNAL as a, LearningCapabilityError as aE, learningEventIdFor as b$, WorkflowEventRecorder as b6, asSingleSelection as bS, assertLearnedCapabilityTransition as bT, canTransitionLearnedCapability as bU, createWorkflowProcessTracker as bV, createWorkflowRunManager as bW, getActiveUserInteraction as bX, getDefaultWorkflowRunManager as bY, isAskUserCustomInputAnswer as bZ, isFinalWorkflowProcessStatus as b_, learningEventKindForLifecycle as c0, normalizeHostMetadata as c1, setActiveUserInteraction as c2, slugifyLearnedCapabilityName as c3 };
|
|
1484
|
+
export type { AskUserSelectionAnswer as $, AgentExecutorProtocol as B, AgentExecutorTaskReference as C, AgentExecutorTaskSnapshot as D, AgentJsonObject as E, AgentJsonValue as F, AgentPreflightInput as G, AgentPreflightResult as H, AgentRegistrationEnabledMutationOptions as I, AgentRegistrationMutationOptions as J, AgentRegistrationService as K, AgentTaskCancellation as L, AgentTaskCorrelation as M, AgentTaskEvent as N, AgentTaskFilter as O, AgentTaskProgress as P, AgentTaskRegistrationSnapshot as Q, AgentTaskService as R, AgentTaskSnapshot as S, AgentTaskStartInput as T, AgentTaskState as U, AgentTaskUsage as V, AskUserAnswer as W, AskUserCustomInputAnswer as X, AskUserMultiOptions as Y, AskUserQuestionItem as Z, AskUserQuestionOptions as _, WorkflowApi as a$, CapabilitySupport as a0, CompactionAnchor as a1, CompactionConfig as a2, CompactionDetails as a3, CompactionReport as a4, CompactionRequestMetrics as a5, CompactionResult as a6, CompactionUpdate as a7, CreateAgentExecutorPlaneOptions as a8, DispatchableAgentDescriptor as a9, LearnedCapabilityScope as aA, LearnedCapabilitySource as aB, LearningAction as aC, LearningActionDriver as aD, LearningCapabilityErrorCode as aF, LearningClientEventState as aG, LearningClientRecord as aH, LearningEvent as aI, LearningEventKind as aJ, LearningExplicitUserAuthority as aK, LearningNotificationState as aL, LearningPage as aM, LearningQuery as aN, LearningSubscribeOptions as aO, LearningSurfaceSnapshot as aP, LocalAgentTaskInput as aQ, LocalAgentTaskUpdate as aR, ManagedRunClassification as aS, ManagedRunHooks as aT, ManagedWorkflowRun as aU, ManagedWorkflowSnapshot as aV, ManagedWorkflowStatus as aW, StartManagedRunInput as aX, UserInteraction as aY, UserInteractionPromptContext as aZ, WorkflowAgentBackend as a_, DispatchableAgentListing as aa, DispatchableAgentOrigin as ab, DispatchableAgentQuery as ac, ExternalAgentEffectDeclaration as ad, ExternalAgentHealth as ae, ExternalAgentProtocol as af, ExternalAgentRegistration as ag, ExternalAgentRegistrationSummary as ah, FileOperations as ai, KodaXFileInputArtifact as aj, KodaXImageInputArtifact as ak, KodaXImageMediaType as al, KodaXInputArtifact as am, KodaXInputArtifactSource as an, KodaXVideoInputArtifact as ao, KodaXVideoMediaType as ap, LearnedCapabilityArtifact as aq, LearnedCapabilityCanary as ar, LearnedCapabilityCanaryBinding as as, LearnedCapabilityCanaryInvocation as at, LearnedCapabilityCarrier as au, LearnedCapabilityLifecycle as av, LearnedCapabilityProvenance as aw, LearnedCapabilityRecord as ax, LearnedCapabilityRecordV1 as ay, LearnedCapabilityRecordV2 as az, AgentArtifactPolicy as b, WorkflowApproval as b0, WorkflowApprovalSummary as b1, WorkflowArtifactRef as b2, WorkflowBudget as b3, WorkflowEvent as b4, WorkflowEventCorrelation as b5, WorkflowEventType as b7, WorkflowIsolation as b8, WorkflowLimits as b9, WorkflowRun as bA, WorkflowRunManager as bB, WorkflowRunState as bC, WorkflowRunStatus as bD, WorkflowSpawnAgentInput as bE, WorkflowSynthesis as bF, WorkflowSynthesizeInput as bG, WorkflowTaskHandle as bH, WorkflowTaskResult as bI, WorkflowTaskSnapshot as bJ, WorkflowTaskStatus as bK, WorkflowTaskSummaryEventUpdate as bL, WorkflowTaskSummaryKind as bM, WorkflowTaskSummaryUpdate as bN, WorkflowTaskUsage as bO, WorkflowTaskVerification as bP, WorkflowTaskVerificationResult as bQ, WorkflowWaitOptions as bR, WorkflowLogEvent as ba, WorkflowMeta as bb, WorkflowModelHint as bc, WorkflowModule as bd, WorkflowOutcome as be, WorkflowOutcomeError as bf, WorkflowOutcomeResult as bg, WorkflowOutcomeStatus as bh, WorkflowOutcomeUsage as bi, WorkflowParallelOptions as bj, WorkflowProcessArtifact as bk, WorkflowProcessCounts as bl, WorkflowProcessEvent as bm, WorkflowProcessItem as bn, WorkflowProcessItemKind as bo, WorkflowProcessItemOrigin as bp, WorkflowProcessItemStatus as bq, WorkflowProcessMetadata as br, WorkflowProcessProgress as bs, WorkflowProcessSnapshot as bt, WorkflowProcessSource as bu, WorkflowProcessStatus as bv, WorkflowProcessSummaryStatus as bw, WorkflowProcessTokenUsage as bx, WorkflowProcessTracker as by, WorkflowProcessTrackerOptions as bz, AgentArtifactPolicyDecision as c, AgentArtifactPolicyInput as d, AgentArtifactReference as e, AgentCapabilityDeclaration as f, AgentCapabilityRequirements as g, AgentContinuationInput as h, AgentCredentialBroker as i, AgentDispatchContext as j, AgentDispatchPolicy as k, AgentDispatchPolicyDecision as l, AgentDispatchPolicyInput as m, AgentDispatchabilitySnapshot as n, AgentDispatchabilityStatus as o, AgentEffectDeclaration as p, AgentExecutor as q, AgentExecutorEvent as r, AgentExecutorFactory as s, AgentExecutorFactoryContext as t, AgentExecutorPlane as u, AgentExecutorPlaneBackgroundErrorContext as v, AgentExecutorPlaneBackgroundErrorHandler as w, AgentExecutorPlaneBinding as x, AgentExecutorPlaneStore as y, AgentExecutorPreflightResult as z };
|