condukt 0.25.0 → 0.27.0
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/dist/runtimes/claude/bridge-cache.d.ts +58 -0
- package/dist/runtimes/claude/bridge-cache.d.ts.map +1 -0
- package/dist/runtimes/claude/bridge-cache.js +257 -0
- package/dist/runtimes/claude/bridge-cache.js.map +1 -0
- package/dist/runtimes/claude/claude-runtime.d.ts +30 -0
- package/dist/runtimes/claude/claude-runtime.d.ts.map +1 -0
- package/dist/runtimes/claude/claude-runtime.js +88 -0
- package/dist/runtimes/claude/claude-runtime.js.map +1 -0
- package/dist/runtimes/claude/claude-session.d.ts +154 -0
- package/dist/runtimes/claude/claude-session.d.ts.map +1 -0
- package/dist/runtimes/claude/claude-session.js +851 -0
- package/dist/runtimes/claude/claude-session.js.map +1 -0
- package/dist/runtimes/claude/config-mapper.d.ts +69 -0
- package/dist/runtimes/claude/config-mapper.d.ts.map +1 -0
- package/dist/runtimes/claude/config-mapper.js +458 -0
- package/dist/runtimes/claude/config-mapper.js.map +1 -0
- package/dist/runtimes/claude/epoch-store.d.ts +28 -0
- package/dist/runtimes/claude/epoch-store.d.ts.map +1 -0
- package/dist/runtimes/claude/epoch-store.js +199 -0
- package/dist/runtimes/claude/epoch-store.js.map +1 -0
- package/dist/runtimes/claude/fallback-runtime.d.ts +14 -0
- package/dist/runtimes/claude/fallback-runtime.d.ts.map +1 -0
- package/dist/runtimes/claude/fallback-runtime.js +64 -0
- package/dist/runtimes/claude/fallback-runtime.js.map +1 -0
- package/dist/runtimes/claude/index.d.ts +24 -0
- package/dist/runtimes/claude/index.d.ts.map +1 -0
- package/dist/runtimes/claude/index.js +61 -0
- package/dist/runtimes/claude/index.js.map +1 -0
- package/dist/runtimes/claude/message-mapper.d.ts +135 -0
- package/dist/runtimes/claude/message-mapper.d.ts.map +1 -0
- package/dist/runtimes/claude/message-mapper.js +504 -0
- package/dist/runtimes/claude/message-mapper.js.map +1 -0
- package/dist/runtimes/claude/one-shot.d.ts +48 -0
- package/dist/runtimes/claude/one-shot.d.ts.map +1 -0
- package/dist/runtimes/claude/one-shot.js +186 -0
- package/dist/runtimes/claude/one-shot.js.map +1 -0
- package/dist/runtimes/claude/protocol-bridge.d.ts +138 -0
- package/dist/runtimes/claude/protocol-bridge.d.ts.map +1 -0
- package/dist/runtimes/claude/protocol-bridge.js +1170 -0
- package/dist/runtimes/claude/protocol-bridge.js.map +1 -0
- package/dist/runtimes/claude/protocol-router.d.ts +113 -0
- package/dist/runtimes/claude/protocol-router.d.ts.map +1 -0
- package/dist/runtimes/claude/protocol-router.js +514 -0
- package/dist/runtimes/claude/protocol-router.js.map +1 -0
- package/dist/runtimes/claude/session-epoch.d.ts +156 -0
- package/dist/runtimes/claude/session-epoch.d.ts.map +1 -0
- package/dist/runtimes/claude/session-epoch.js +365 -0
- package/dist/runtimes/claude/session-epoch.js.map +1 -0
- package/dist/runtimes/claude/session-recovery.d.ts +78 -0
- package/dist/runtimes/claude/session-recovery.d.ts.map +1 -0
- package/dist/runtimes/claude/session-recovery.js +259 -0
- package/dist/runtimes/claude/session-recovery.js.map +1 -0
- package/dist/runtimes/claude/sse.d.ts +16 -0
- package/dist/runtimes/claude/sse.d.ts.map +1 -0
- package/dist/runtimes/claude/sse.js +46 -0
- package/dist/runtimes/claude/sse.js.map +1 -0
- package/dist/runtimes/claude/translate-chat.d.ts +106 -0
- package/dist/runtimes/claude/translate-chat.d.ts.map +1 -0
- package/dist/runtimes/claude/translate-chat.js +857 -0
- package/dist/runtimes/claude/translate-chat.js.map +1 -0
- package/dist/runtimes/claude/translate-responses.d.ts +76 -0
- package/dist/runtimes/claude/translate-responses.d.ts.map +1 -0
- package/dist/runtimes/claude/translate-responses.js +625 -0
- package/dist/runtimes/claude/translate-responses.js.map +1 -0
- package/dist/runtimes/claude/usage-ledger.d.ts +108 -0
- package/dist/runtimes/claude/usage-ledger.d.ts.map +1 -0
- package/dist/runtimes/claude/usage-ledger.js +189 -0
- package/dist/runtimes/claude/usage-ledger.js.map +1 -0
- package/dist/runtimes/copilot/copilot-backend.d.ts +8 -0
- package/dist/runtimes/copilot/copilot-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.js +314 -135
- package/dist/runtimes/copilot/sdk-backend.js.map +1 -1
- package/dist/runtimes/mcp-env.d.ts +24 -0
- package/dist/runtimes/mcp-env.d.ts.map +1 -0
- package/dist/runtimes/mcp-env.js +81 -0
- package/dist/runtimes/mcp-env.js.map +1 -0
- package/dist/runtimes/mock/mock-runtime.d.ts +2 -2
- package/dist/runtimes/mock/mock-runtime.d.ts.map +1 -1
- package/dist/runtimes/mock/mock-runtime.js +38 -1
- package/dist/runtimes/mock/mock-runtime.js.map +1 -1
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +171 -3
- package/dist/src/agent.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/session-recovery-policy.d.ts +19 -0
- package/dist/src/session-recovery-policy.d.ts.map +1 -0
- package/dist/src/session-recovery-policy.js +43 -0
- package/dist/src/session-recovery-policy.js.map +1 -0
- package/dist/src/types.d.ts +118 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +11 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +20 -4
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pure mapping from Claude Agent SDK messages to condukt AgentSession events.
|
|
4
|
+
*
|
|
5
|
+
* The SDK and condukt describe the same stream differently:
|
|
6
|
+
*
|
|
7
|
+
* - Assistant frames carry `parent_tool_use_id`, so subagent tool calls and
|
|
8
|
+
* text can be nested in the UI exactly like the Copilot runtime.
|
|
9
|
+
* - `assistant.message.usage` is a non-final, per-block snapshot. It is used
|
|
10
|
+
* only to estimate the current context size; token accounting comes from
|
|
11
|
+
* `result.modelUsage` (see `usage-ledger.ts`).
|
|
12
|
+
* - `result.subtype === 'success'` is not proof of success: `is_error` can be
|
|
13
|
+
* set on a transient API failure. The mapper reports a `ResultOutcome` and
|
|
14
|
+
* leaves idle/error/recovery to the session.
|
|
15
|
+
* - There is no `task_completed` system subtype; `task_notification` ends a
|
|
16
|
+
* subagent task.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.createMapState = createMapState;
|
|
20
|
+
exports.mapSdkMessage = mapSdkMessage;
|
|
21
|
+
const usage_ledger_1 = require("./usage-ledger");
|
|
22
|
+
function createMapState() {
|
|
23
|
+
return {
|
|
24
|
+
sawPartial: false,
|
|
25
|
+
toolNames: new Map(),
|
|
26
|
+
toolBlocks: new Map(),
|
|
27
|
+
subagentNames: new Map(),
|
|
28
|
+
lastCallContextTokens: 0,
|
|
29
|
+
compactionInFlight: false,
|
|
30
|
+
compactionCompleted: false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function mapSdkMessage(msg, emitter, state, options) {
|
|
34
|
+
switch (msg.type) {
|
|
35
|
+
case 'assistant':
|
|
36
|
+
mapAssistant(msg, emitter, state, options);
|
|
37
|
+
return false;
|
|
38
|
+
case 'stream_event':
|
|
39
|
+
mapStreamEvent(msg, emitter, state, options);
|
|
40
|
+
return false;
|
|
41
|
+
case 'user':
|
|
42
|
+
mapUserMessage(msg, emitter, state);
|
|
43
|
+
return false;
|
|
44
|
+
case 'result':
|
|
45
|
+
mapResult(msg, emitter, state, options);
|
|
46
|
+
return true;
|
|
47
|
+
case 'system':
|
|
48
|
+
mapSystemMessage(msg, emitter, state, options);
|
|
49
|
+
return false;
|
|
50
|
+
case 'tool_progress':
|
|
51
|
+
// The SDK publishes elapsed time, never partial output. Emitting an
|
|
52
|
+
// empty tool_output here (the previous behaviour) only spammed the UI.
|
|
53
|
+
return false;
|
|
54
|
+
default:
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Assistant frames and streaming deltas
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
function asRecord(value) {
|
|
62
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
63
|
+
? value
|
|
64
|
+
: undefined;
|
|
65
|
+
}
|
|
66
|
+
function asArray(value) {
|
|
67
|
+
return Array.isArray(value) ? value : [];
|
|
68
|
+
}
|
|
69
|
+
function optionalString(value) {
|
|
70
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
71
|
+
}
|
|
72
|
+
function parentOf(frame) {
|
|
73
|
+
return optionalString(frame.parent_tool_use_id);
|
|
74
|
+
}
|
|
75
|
+
function mapAssistant(frame, emitter, state, options) {
|
|
76
|
+
const message = asRecord(frame.message);
|
|
77
|
+
const parent = parentOf(frame);
|
|
78
|
+
const model = optionalString(message?.model);
|
|
79
|
+
// Only main-loop frames name the model that `result.usage` bills. A
|
|
80
|
+
// subagent frame carries its own model, and using it would attribute the
|
|
81
|
+
// main-loop usage of a resumed first result to the wrong model.
|
|
82
|
+
if (model !== undefined && parent === undefined)
|
|
83
|
+
state.lastModel = model;
|
|
84
|
+
const error = optionalString(frame.error);
|
|
85
|
+
if (error !== undefined)
|
|
86
|
+
options.onAssistantError?.(error);
|
|
87
|
+
const usage = asRecord(message?.usage);
|
|
88
|
+
if (usage !== undefined) {
|
|
89
|
+
const contextTokens = nonNegative(usage.input_tokens)
|
|
90
|
+
+ nonNegative(usage.cache_read_input_tokens)
|
|
91
|
+
+ nonNegative(usage.cache_creation_input_tokens);
|
|
92
|
+
if (contextTokens > 0) {
|
|
93
|
+
state.lastCallContextTokens = contextTokens;
|
|
94
|
+
options.onAssistantUsage?.(contextTokens, nonNegative(usage.output_tokens));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (state.sawPartial)
|
|
98
|
+
return;
|
|
99
|
+
for (const block of asArray(message?.content)) {
|
|
100
|
+
const b = asRecord(block);
|
|
101
|
+
if (b === undefined)
|
|
102
|
+
continue;
|
|
103
|
+
if (b.type === 'text' && typeof b.text === 'string') {
|
|
104
|
+
emitter.text(b.text, parent);
|
|
105
|
+
}
|
|
106
|
+
else if (b.type === 'thinking' && typeof b.thinking === 'string') {
|
|
107
|
+
emitter.reasoning(b.thinking);
|
|
108
|
+
}
|
|
109
|
+
else if (b.type === 'tool_use') {
|
|
110
|
+
const name = optionalString(b.name) ?? 'tool';
|
|
111
|
+
const callId = optionalString(b.id);
|
|
112
|
+
if (callId !== undefined)
|
|
113
|
+
state.toolNames.set(callId, name);
|
|
114
|
+
emitter.toolStart(name, safeStringify(b.input), recordOf(b.input), callId, parent);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function mapStreamEvent(frame, emitter, state, _options) {
|
|
119
|
+
const event = asRecord(frame.event);
|
|
120
|
+
if (event === undefined)
|
|
121
|
+
return;
|
|
122
|
+
const parent = parentOf(frame);
|
|
123
|
+
const blockKey = `${parent ?? ''}#${typeof event.index === 'number' ? event.index : 0}`;
|
|
124
|
+
if (event.type === 'message_start') {
|
|
125
|
+
const message = asRecord(event.message);
|
|
126
|
+
const model = optionalString(message?.model);
|
|
127
|
+
if (model !== undefined && parent === undefined)
|
|
128
|
+
state.lastModel = model;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (event.type === 'content_block_start') {
|
|
132
|
+
state.sawPartial = true;
|
|
133
|
+
const block = asRecord(event.content_block);
|
|
134
|
+
if (block?.type === 'tool_use') {
|
|
135
|
+
const name = optionalString(block.name) ?? 'tool';
|
|
136
|
+
const callId = optionalString(block.id);
|
|
137
|
+
if (callId !== undefined)
|
|
138
|
+
state.toolNames.set(callId, name);
|
|
139
|
+
state.toolBlocks.set(blockKey, { name, id: callId, buffer: '', parentToolCallId: parent });
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (event.type === 'content_block_delta') {
|
|
144
|
+
state.sawPartial = true;
|
|
145
|
+
const delta = asRecord(event.delta);
|
|
146
|
+
if (delta?.type === 'text_delta' && typeof delta.text === 'string') {
|
|
147
|
+
emitter.text(delta.text, parent);
|
|
148
|
+
}
|
|
149
|
+
else if (delta?.type === 'thinking_delta' && typeof delta.thinking === 'string') {
|
|
150
|
+
emitter.reasoning(delta.thinking);
|
|
151
|
+
}
|
|
152
|
+
else if (delta?.type === 'input_json_delta' && typeof delta.partial_json === 'string') {
|
|
153
|
+
const block = state.toolBlocks.get(blockKey);
|
|
154
|
+
if (block !== undefined)
|
|
155
|
+
block.buffer += delta.partial_json;
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (event.type === 'content_block_stop') {
|
|
160
|
+
const block = state.toolBlocks.get(blockKey);
|
|
161
|
+
if (block === undefined)
|
|
162
|
+
return;
|
|
163
|
+
state.toolBlocks.delete(blockKey);
|
|
164
|
+
let args = {};
|
|
165
|
+
if (block.buffer.trim().length > 0) {
|
|
166
|
+
try {
|
|
167
|
+
const parsed = JSON.parse(block.buffer);
|
|
168
|
+
args = recordOf(parsed);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
args = { _raw: block.buffer };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
emitter.toolStart(block.name, block.buffer, args, block.id, block.parentToolCallId);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
// Tool results
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
const RICH_BLOCK_TYPES = new Set(['image', 'document']);
|
|
181
|
+
function mapUserMessage(frame, emitter, state) {
|
|
182
|
+
const message = asRecord(frame.message);
|
|
183
|
+
const parent = parentOf(frame);
|
|
184
|
+
for (const block of asArray(message?.content)) {
|
|
185
|
+
const b = asRecord(block);
|
|
186
|
+
if (b === undefined)
|
|
187
|
+
continue;
|
|
188
|
+
if (b.type !== 'tool_result')
|
|
189
|
+
continue;
|
|
190
|
+
const callId = optionalString(b.tool_use_id);
|
|
191
|
+
const name = callId !== undefined ? state.toolNames.get(callId) : undefined;
|
|
192
|
+
if (callId !== undefined)
|
|
193
|
+
state.toolNames.delete(callId);
|
|
194
|
+
const output = extractToolResultContent(b.content);
|
|
195
|
+
emitter.toolComplete(name ?? '', output, callId, parent);
|
|
196
|
+
const rich = richToolResultContents(b.content);
|
|
197
|
+
if (rich.length > 0)
|
|
198
|
+
emitter.toolCompleteRich(name ?? '', rich, callId);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function extractToolResultContent(content) {
|
|
202
|
+
if (typeof content === 'string')
|
|
203
|
+
return content;
|
|
204
|
+
if (Array.isArray(content)) {
|
|
205
|
+
return content
|
|
206
|
+
.map((entry) => {
|
|
207
|
+
const block = asRecord(entry);
|
|
208
|
+
if (block === undefined) {
|
|
209
|
+
try {
|
|
210
|
+
return JSON.stringify(entry);
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return String(entry);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (typeof block.text === 'string')
|
|
217
|
+
return block.text;
|
|
218
|
+
if (block.type === 'image' || block.type === 'document') {
|
|
219
|
+
const label = typeof block.type === 'string' ? block.type : 'content';
|
|
220
|
+
return `[${label}]`;
|
|
221
|
+
}
|
|
222
|
+
if (typeof block.content === 'string')
|
|
223
|
+
return block.content;
|
|
224
|
+
try {
|
|
225
|
+
return JSON.stringify(block);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return String(block);
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
.filter((text) => text.length > 0)
|
|
232
|
+
.join('\n');
|
|
233
|
+
}
|
|
234
|
+
if (content !== null && typeof content === 'object') {
|
|
235
|
+
try {
|
|
236
|
+
return JSON.stringify(content);
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return String(content);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return '';
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Converts non-text Anthropic tool-result blocks into condukt `ContentBlock`
|
|
246
|
+
* shapes so the UI can render them. Only blocks the UI understands are
|
|
247
|
+
* returned; anything else stays in the textual summary.
|
|
248
|
+
*/
|
|
249
|
+
function richToolResultContents(content) {
|
|
250
|
+
if (!Array.isArray(content))
|
|
251
|
+
return [];
|
|
252
|
+
const rich = [];
|
|
253
|
+
for (const entry of content) {
|
|
254
|
+
const block = asRecord(entry);
|
|
255
|
+
if (block === undefined || typeof block.type !== 'string')
|
|
256
|
+
continue;
|
|
257
|
+
if (!RICH_BLOCK_TYPES.has(block.type))
|
|
258
|
+
continue;
|
|
259
|
+
const source = asRecord(block.source);
|
|
260
|
+
if (block.type === 'image' && source?.type === 'base64' && typeof source.data === 'string') {
|
|
261
|
+
rich.push({
|
|
262
|
+
type: 'image',
|
|
263
|
+
data: source.data,
|
|
264
|
+
mimeType: optionalString(source.media_type) ?? optionalString(block.mimeType) ?? 'image/png',
|
|
265
|
+
});
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
const uri = optionalString(source?.url) ?? optionalString(block.uri);
|
|
269
|
+
rich.push({
|
|
270
|
+
type: 'resource',
|
|
271
|
+
...(uri !== undefined ? { uri } : {}),
|
|
272
|
+
name: optionalString(block.title) ?? optionalString(block.name) ?? String(block.type),
|
|
273
|
+
...(optionalString(source?.media_type) !== undefined
|
|
274
|
+
? { mimeType: optionalString(source?.media_type) }
|
|
275
|
+
: {}),
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return rich;
|
|
279
|
+
}
|
|
280
|
+
// ---------------------------------------------------------------------------
|
|
281
|
+
// Result
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
function mapResult(frame, emitter, state, options) {
|
|
284
|
+
const ledger = options.ledger
|
|
285
|
+
?? (state.ledger ??= new usage_ledger_1.ModelUsageLedger({ fallbackModel: options.fallbackModel }));
|
|
286
|
+
const modelUsage = asRecord(frame.modelUsage);
|
|
287
|
+
for (const record of ledger.observe({
|
|
288
|
+
uuid: optionalString(frame.uuid) ?? '',
|
|
289
|
+
durationMs: typeof frame.duration_ms === 'number' ? frame.duration_ms : undefined,
|
|
290
|
+
modelUsage,
|
|
291
|
+
mainLoopUsage: asRecord(frame.usage),
|
|
292
|
+
mainLoopModel: state.lastModel,
|
|
293
|
+
}, { resumed: options.resumed === true })) {
|
|
294
|
+
emitter.usage(record);
|
|
295
|
+
}
|
|
296
|
+
const subtype = optionalString(frame.subtype) ?? 'error_during_execution';
|
|
297
|
+
const errors = asArray(frame.errors)
|
|
298
|
+
.filter((entry) => typeof entry === 'string');
|
|
299
|
+
const outcome = {
|
|
300
|
+
subtype,
|
|
301
|
+
isError: frame.is_error === true,
|
|
302
|
+
apiErrorStatus: typeof frame.api_error_status === 'number' ? frame.api_error_status : undefined,
|
|
303
|
+
errors,
|
|
304
|
+
terminalReason: optionalString(frame.terminal_reason),
|
|
305
|
+
startupFailureReason: optionalString(frame.startup_failure_reason),
|
|
306
|
+
resumeReason: optionalString(frame.resume_reason),
|
|
307
|
+
stopReason: optionalString(frame.stop_reason) ?? null,
|
|
308
|
+
numTurns: typeof frame.num_turns === 'number' ? frame.num_turns : 0,
|
|
309
|
+
durationMs: typeof frame.duration_ms === 'number' ? frame.duration_ms : 0,
|
|
310
|
+
};
|
|
311
|
+
state.sawPartial = false;
|
|
312
|
+
state.toolBlocks.clear();
|
|
313
|
+
state.compactionInFlight = false;
|
|
314
|
+
state.compactionCompleted = false;
|
|
315
|
+
if (options.onResult !== undefined) {
|
|
316
|
+
options.onResult(outcome);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
// Standalone use (tests, non-recovering callers): no recovery decisions are
|
|
320
|
+
// possible, so keep the old terminal behaviour.
|
|
321
|
+
if (subtype === 'success' && !outcome.isError) {
|
|
322
|
+
emitter.idle();
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const message = errors[0]
|
|
326
|
+
?? (outcome.apiErrorStatus !== undefined
|
|
327
|
+
? `Claude API error (status ${outcome.apiErrorStatus})`
|
|
328
|
+
: `Claude session failed (${subtype})`);
|
|
329
|
+
emitter.error(new Error(message));
|
|
330
|
+
}
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
// System messages
|
|
333
|
+
// ---------------------------------------------------------------------------
|
|
334
|
+
function mapSystemMessage(frame, emitter, state, options) {
|
|
335
|
+
switch (frame.subtype) {
|
|
336
|
+
case 'init': {
|
|
337
|
+
options.onInit?.({
|
|
338
|
+
permissionMode: optionalString(frame.permissionMode) ?? 'unknown',
|
|
339
|
+
tools: asArray(frame.tools).filter((t) => typeof t === 'string'),
|
|
340
|
+
agents: asArray(frame.agents).filter((a) => typeof a === 'string'),
|
|
341
|
+
model: optionalString(frame.model) ?? '',
|
|
342
|
+
cwd: optionalString(frame.cwd) ?? '',
|
|
343
|
+
});
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
case 'status':
|
|
347
|
+
mapStatusMessage(frame, emitter, state, options);
|
|
348
|
+
return;
|
|
349
|
+
case 'compact_boundary': {
|
|
350
|
+
const metadata = asRecord(frame.compact_metadata);
|
|
351
|
+
const info = metadata === undefined
|
|
352
|
+
? undefined
|
|
353
|
+
: {
|
|
354
|
+
trigger: metadata.trigger === 'manual' ? 'manual' : 'auto',
|
|
355
|
+
preTokens: nonNegative(metadata.pre_tokens),
|
|
356
|
+
...(typeof metadata.post_tokens === 'number'
|
|
357
|
+
? { postTokens: nonNegative(metadata.post_tokens) }
|
|
358
|
+
: {}),
|
|
359
|
+
...(typeof metadata.duration_ms === 'number'
|
|
360
|
+
? { durationMs: nonNegative(metadata.duration_ms) }
|
|
361
|
+
: {}),
|
|
362
|
+
};
|
|
363
|
+
completeCompaction(emitter, state, options, info);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
case 'api_retry': {
|
|
367
|
+
const noResponse = asRecord(frame.no_response);
|
|
368
|
+
options.onApiRetry?.({
|
|
369
|
+
attempt: nonNegative(frame.attempt),
|
|
370
|
+
maxRetries: nonNegative(frame.max_retries),
|
|
371
|
+
delayMs: nonNegative(frame.retry_delay_ms),
|
|
372
|
+
status: typeof frame.error_status === 'number' ? frame.error_status : null,
|
|
373
|
+
error: optionalString(frame.error) ?? 'unknown',
|
|
374
|
+
noResponse: noResponse !== undefined,
|
|
375
|
+
});
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
case 'task_started': {
|
|
379
|
+
const taskId = optionalString(frame.task_id);
|
|
380
|
+
const name = optionalString(frame.subagent_type)
|
|
381
|
+
?? optionalString(frame.description)
|
|
382
|
+
?? taskId
|
|
383
|
+
?? 'subagent';
|
|
384
|
+
if (taskId !== undefined)
|
|
385
|
+
state.subagentNames.set(taskId, name);
|
|
386
|
+
emitter.subagentStart(name, {
|
|
387
|
+
...(taskId !== undefined ? { taskId } : {}),
|
|
388
|
+
toolCallId: optionalString(frame.tool_use_id) ?? taskId,
|
|
389
|
+
...(optionalString(frame.subagent_type) !== undefined
|
|
390
|
+
? { subagentType: optionalString(frame.subagent_type) }
|
|
391
|
+
: {}),
|
|
392
|
+
...(typeof frame.spawn_depth === 'number' ? { spawnDepth: frame.spawn_depth } : {}),
|
|
393
|
+
...(optionalString(frame.description) !== undefined
|
|
394
|
+
? { description: optionalString(frame.description) }
|
|
395
|
+
: {}),
|
|
396
|
+
...(typeof frame.is_backgrounded === 'boolean'
|
|
397
|
+
? { isBackgrounded: frame.is_backgrounded }
|
|
398
|
+
: {}),
|
|
399
|
+
...(optionalString(frame.task_type) !== undefined
|
|
400
|
+
? { taskType: optionalString(frame.task_type) }
|
|
401
|
+
: {}),
|
|
402
|
+
});
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
case 'task_notification': {
|
|
406
|
+
const taskId = optionalString(frame.task_id);
|
|
407
|
+
const name = (taskId !== undefined ? state.subagentNames.get(taskId) : undefined)
|
|
408
|
+
?? optionalString(frame.subagent_type)
|
|
409
|
+
?? taskId
|
|
410
|
+
?? 'subagent';
|
|
411
|
+
if (taskId !== undefined)
|
|
412
|
+
state.subagentNames.delete(taskId);
|
|
413
|
+
const usage = asRecord(frame.usage);
|
|
414
|
+
emitter.subagentEnd(name, {
|
|
415
|
+
...(taskId !== undefined ? { taskId } : {}),
|
|
416
|
+
toolCallId: optionalString(frame.tool_use_id) ?? taskId,
|
|
417
|
+
status: optionalString(frame.status) ?? 'completed',
|
|
418
|
+
...(usage !== undefined && typeof usage.total_tokens === 'number'
|
|
419
|
+
? { totalTokens: nonNegative(usage.total_tokens) }
|
|
420
|
+
: {}),
|
|
421
|
+
...(usage !== undefined && typeof usage.duration_ms === 'number'
|
|
422
|
+
? { duration: nonNegative(usage.duration_ms) }
|
|
423
|
+
: {}),
|
|
424
|
+
...(optionalString(frame.summary) !== undefined
|
|
425
|
+
? { summary: optionalString(frame.summary) }
|
|
426
|
+
: {}),
|
|
427
|
+
});
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
case 'permission_denied': {
|
|
431
|
+
const reasonType = optionalString(frame.decision_reason_type);
|
|
432
|
+
const reason = optionalString(frame.decision_reason);
|
|
433
|
+
emitter.permission({
|
|
434
|
+
kind: reasonType ?? 'permission_denied',
|
|
435
|
+
detail: reason ?? optionalString(frame.message) ?? optionalString(frame.tool_name),
|
|
436
|
+
approved: false,
|
|
437
|
+
tool: optionalString(frame.tool_name),
|
|
438
|
+
toolCallId: optionalString(frame.tool_use_id),
|
|
439
|
+
...(optionalString(frame.agent_id) !== undefined
|
|
440
|
+
? { agentId: optionalString(frame.agent_id) }
|
|
441
|
+
: {}),
|
|
442
|
+
...(reasonType !== undefined ? { reasonType } : {}),
|
|
443
|
+
...(reason !== undefined ? { reason } : {}),
|
|
444
|
+
...(optionalString(frame.message) !== undefined
|
|
445
|
+
? { message: optionalString(frame.message) }
|
|
446
|
+
: {}),
|
|
447
|
+
});
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
default:
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
function mapStatusMessage(frame, emitter, state, options) {
|
|
455
|
+
const compactResult = optionalString(frame.compact_result);
|
|
456
|
+
if (compactResult === 'failed') {
|
|
457
|
+
state.compactionInFlight = false;
|
|
458
|
+
// A failure is not a completion: no marker, no count increment. If a
|
|
459
|
+
// boundary still follows, it counts as a real completion.
|
|
460
|
+
state.compactionCompleted = false;
|
|
461
|
+
options.onCompactionFailed?.(optionalString(frame.compact_error));
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
if (compactResult === 'success') {
|
|
465
|
+
completeCompaction(emitter, state, options);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (frame.status === 'compacting' && !state.compactionInFlight && !state.compactionCompleted) {
|
|
469
|
+
state.compactionInFlight = true;
|
|
470
|
+
emitter.compaction('start');
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function completeCompaction(emitter, state, options, info) {
|
|
474
|
+
if (state.compactionCompleted) {
|
|
475
|
+
// A status success and a boundary describe the same compaction. Counting
|
|
476
|
+
// it twice would overstate `compactions.count`, so the first completion
|
|
477
|
+
// wins even when the second carries richer metadata.
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
state.compactionCompleted = true;
|
|
481
|
+
state.compactionInFlight = false;
|
|
482
|
+
emitter.compaction('complete');
|
|
483
|
+
options.onCompaction?.(info);
|
|
484
|
+
}
|
|
485
|
+
// ---------------------------------------------------------------------------
|
|
486
|
+
// Helpers
|
|
487
|
+
// ---------------------------------------------------------------------------
|
|
488
|
+
function nonNegative(value) {
|
|
489
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : 0;
|
|
490
|
+
}
|
|
491
|
+
function recordOf(value) {
|
|
492
|
+
return asRecord(value) ?? {};
|
|
493
|
+
}
|
|
494
|
+
function safeStringify(value) {
|
|
495
|
+
if (value === undefined)
|
|
496
|
+
return '';
|
|
497
|
+
try {
|
|
498
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
499
|
+
}
|
|
500
|
+
catch {
|
|
501
|
+
return String(value);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
//# sourceMappingURL=message-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-mapper.js","sourceRoot":"","sources":["../../../runtimes/claude/message-mapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAkIH,wCAUC;AAED,sCA6BC;AAvKD,iDAAkD;AA8HlD,SAAgB,cAAc;IAC5B,OAAO;QACL,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,IAAI,GAAG,EAAE;QACpB,UAAU,EAAE,IAAI,GAAG,EAAE;QACrB,aAAa,EAAE,IAAI,GAAG,EAAE;QACxB,qBAAqB,EAAE,CAAC;QACxB,kBAAkB,EAAE,KAAK;QACzB,mBAAmB,EAAE,KAAK;KAC3B,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAC3B,GAAe,EACf,OAA6B,EAC7B,KAAe,EACf,OAAmB;IAEnB,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,WAAW;YACd,YAAY,CAAC,GAAyC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACjF,OAAO,KAAK,CAAC;QACf,KAAK,cAAc;YACjB,cAAc,CAAC,GAAyC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YACnF,OAAO,KAAK,CAAC;QACf,KAAK,MAAM;YACT,cAAc,CAAC,GAAyC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1E,OAAO,KAAK,CAAC;QACf,KAAK,QAAQ;YACX,SAAS,CAAC,GAAyC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9E,OAAO,IAAI,CAAC;QACd,KAAK,QAAQ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C7B,KAAe,EACf,OAAmB,EACnB,IAA2B;IAE3B,IAAI,KAAK,CAAC,mBAAmB,EAAE,CAAC;QAC9B,yEAAyE;QACzE,wEAAwE;QACxE,qDAAqD;QACrD,OAAO;IACT,CAAC;IACD,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC;IACjC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnC,IAAI,CAAC;QACH,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SessionConfig, ToolUsageData } from '../../src/types';
|
|
2
|
+
export interface OneShotResult {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
/** Camel-case per-model usage records, ready for `ToolUsageData.usages`. */
|
|
5
|
+
readonly usages: ReadonlyArray<Record<string, unknown>>;
|
|
6
|
+
readonly model: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A single, isolated query: advisor, stand-in voter, or handoff summary.
|
|
10
|
+
*
|
|
11
|
+
* Isolation is deliberate and mirrors the Copilot one-shot session: no
|
|
12
|
+
* built-in tools, no MCP servers, no host settings discovery (`settingSources:
|
|
13
|
+
* []`), and `dontAsk` so nothing can prompt. `env` carries the protocol
|
|
14
|
+
* bridge's `ANTHROPIC_BASE_URL`/credentials; without it the CLI would call
|
|
15
|
+
* `api.anthropic.com` directly.
|
|
16
|
+
*/
|
|
17
|
+
export declare function runOneShot(opts: {
|
|
18
|
+
readonly model: string;
|
|
19
|
+
readonly prompt: string;
|
|
20
|
+
readonly cwd: string;
|
|
21
|
+
readonly system?: string;
|
|
22
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
23
|
+
/**
|
|
24
|
+
* Cancels the call. Advisor and stand-in one-shots outlive the node's turn
|
|
25
|
+
* unless the session forwards its cancellation here; a stopped run must not
|
|
26
|
+
* keep billing an upstream until it finishes on its own.
|
|
27
|
+
*/
|
|
28
|
+
readonly signal?: AbortSignal;
|
|
29
|
+
}): Promise<OneShotResult>;
|
|
30
|
+
export interface AdvisorStandInServerOpts {
|
|
31
|
+
readonly config: SessionConfig;
|
|
32
|
+
readonly cwd: string;
|
|
33
|
+
/** Bridge environment forwarded to every one-shot call. */
|
|
34
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
35
|
+
/** Session cancellation, forwarded so a stopped run stops billing. */
|
|
36
|
+
readonly signal?: AbortSignal;
|
|
37
|
+
readonly onToolUsage: (data: ToolUsageData) => void;
|
|
38
|
+
}
|
|
39
|
+
/** Name the session registers the internal advisor/stand-in server under. */
|
|
40
|
+
export declare const CONDUKT_MCP_SERVER_NAME = "condukt";
|
|
41
|
+
/**
|
|
42
|
+
* Qualified names of the internal tools. Under `dontAsk` only tools listed in
|
|
43
|
+
* `allowedTools` may run, and this server is added after `mapConfig`, so the
|
|
44
|
+
* session must add these itself or the model is denied its own advisor.
|
|
45
|
+
*/
|
|
46
|
+
export declare const INTERNAL_MCP_TOOL_NAMES: readonly string[];
|
|
47
|
+
export declare function buildAdvisorStandInServer(opts: AdvisorStandInServerOpts): import("@anthropic-ai/claude-agent-sdk").McpSdkServerConfigWithInstance | null;
|
|
48
|
+
//# sourceMappingURL=one-shot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-shot.d.ts","sourceRoot":"","sources":["../../../runtimes/claude/one-shot.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGpE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B,GAAG,OAAO,CAAC,aAAa,CAAC,CAiDzB;AA8BD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,C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