claude-code-rust 0.9.0 → 0.11.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/README.md +16 -9
- package/agent-sdk/README.md +1 -1
- package/agent-sdk/dist/bridge/commands.js +71 -2
- package/agent-sdk/dist/bridge/events.js +127 -12
- package/agent-sdk/dist/bridge/history.js +9 -4
- package/agent-sdk/dist/bridge/logger.js +253 -0
- package/agent-sdk/dist/bridge/mcp.js +81 -5
- package/agent-sdk/dist/bridge/message_handlers.js +318 -67
- package/agent-sdk/dist/bridge/session_lifecycle.js +774 -58
- package/agent-sdk/dist/bridge/shared.js +0 -7
- package/agent-sdk/dist/bridge/state_parsing.js +61 -0
- package/agent-sdk/dist/bridge/tool_calls.js +269 -66
- package/agent-sdk/dist/bridge/tooling.js +60 -27
- package/agent-sdk/dist/bridge/user_interaction.js +34 -23
- package/agent-sdk/dist/bridge.js +406 -42
- package/agent-sdk/dist/bridge.test.js +765 -23
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { asRecordOrNull } from "./shared.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { emitPermissionRequestEvent, emitQuestionRequestEvent, } from "./events.js";
|
|
3
|
+
import { bridgeLogger, LOG_TARGETS } from "./logger.js";
|
|
4
|
+
import { emitToolCallUpdate, setToolCallStatus } from "./tool_calls.js";
|
|
4
5
|
export const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
5
6
|
export const QUESTION_CHOICE_KIND = "question_choice";
|
|
6
7
|
export const EXIT_PLAN_MODE_TOOL_NAME = "ExitPlanMode";
|
|
@@ -31,7 +32,20 @@ export async function requestExitPlanModeApproval(session, toolUseId, inputData,
|
|
|
31
32
|
toolName: EXIT_PLAN_MODE_TOOL_NAME,
|
|
32
33
|
inputData,
|
|
33
34
|
});
|
|
34
|
-
|
|
35
|
+
bridgeLogger.info({
|
|
36
|
+
target: LOG_TARGETS.BRIDGE_PERMISSION,
|
|
37
|
+
eventName: "permission_request_created",
|
|
38
|
+
message: "exit plan mode permission request created",
|
|
39
|
+
outcome: "start",
|
|
40
|
+
sessionId: session.sessionId,
|
|
41
|
+
toolCallId: toolUseId,
|
|
42
|
+
count: request.options.length,
|
|
43
|
+
fields: {
|
|
44
|
+
tool_name: EXIT_PLAN_MODE_TOOL_NAME,
|
|
45
|
+
option_count: request.options.length,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
emitPermissionRequestEvent(session.sessionId, request);
|
|
35
49
|
});
|
|
36
50
|
if (outcome.outcome !== "selected" || outcome.option_id === "reject") {
|
|
37
51
|
setToolCallStatus(session, toolUseId, "failed", "Plan rejected");
|
|
@@ -159,16 +173,7 @@ export async function requestAskUserQuestionAnswers(session, toolUseId, inputDat
|
|
|
159
173
|
status: "in_progress",
|
|
160
174
|
raw_input: promptToolCall.raw_input,
|
|
161
175
|
};
|
|
162
|
-
|
|
163
|
-
type: "tool_call_update",
|
|
164
|
-
tool_call_update: { tool_call_id: toolUseId, fields },
|
|
165
|
-
});
|
|
166
|
-
const tracked = session.toolCalls.get(toolUseId);
|
|
167
|
-
if (tracked) {
|
|
168
|
-
tracked.title = promptToolCall.title;
|
|
169
|
-
tracked.status = "in_progress";
|
|
170
|
-
tracked.raw_input = promptToolCall.raw_input;
|
|
171
|
-
}
|
|
176
|
+
emitToolCallUpdate(session, toolUseId, fields, "status");
|
|
172
177
|
const request = buildQuestionRequest(promptToolCall, prompt, index, prompts.length);
|
|
173
178
|
const outcome = await new Promise((resolve) => {
|
|
174
179
|
session.pendingQuestions.set(toolUseId, {
|
|
@@ -176,7 +181,21 @@ export async function requestAskUserQuestionAnswers(session, toolUseId, inputDat
|
|
|
176
181
|
toolName: ASK_USER_QUESTION_TOOL_NAME,
|
|
177
182
|
inputData,
|
|
178
183
|
});
|
|
179
|
-
|
|
184
|
+
bridgeLogger.info({
|
|
185
|
+
target: LOG_TARGETS.BRIDGE_PERMISSION,
|
|
186
|
+
eventName: "question_request_created",
|
|
187
|
+
message: "ask user question request created",
|
|
188
|
+
outcome: "start",
|
|
189
|
+
sessionId: session.sessionId,
|
|
190
|
+
toolCallId: toolUseId,
|
|
191
|
+
count: request.prompt.options.length,
|
|
192
|
+
fields: {
|
|
193
|
+
tool_name: ASK_USER_QUESTION_TOOL_NAME,
|
|
194
|
+
question_index: index,
|
|
195
|
+
total_questions: prompts.length,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
emitQuestionRequestEvent(session.sessionId, request);
|
|
180
199
|
});
|
|
181
200
|
if (outcome.outcome !== "answered") {
|
|
182
201
|
setToolCallStatus(session, toolUseId, "failed", "Question cancelled");
|
|
@@ -201,15 +220,7 @@ export async function requestAskUserQuestionAnswers(session, toolUseId, inputDat
|
|
|
201
220
|
raw_output: summary,
|
|
202
221
|
content: [{ type: "content", content: { type: "text", text: summary } }],
|
|
203
222
|
};
|
|
204
|
-
|
|
205
|
-
type: "tool_call_update",
|
|
206
|
-
tool_call_update: { tool_call_id: toolUseId, fields: progressFields },
|
|
207
|
-
});
|
|
208
|
-
if (tracked) {
|
|
209
|
-
tracked.status = progressFields.status ?? tracked.status;
|
|
210
|
-
tracked.raw_output = summary;
|
|
211
|
-
tracked.content = progressFields.content ?? tracked.content;
|
|
212
|
-
}
|
|
223
|
+
emitToolCallUpdate(session, toolUseId, progressFields, "summary");
|
|
213
224
|
}
|
|
214
225
|
return {
|
|
215
226
|
behavior: "allow",
|