@qwen-code/qwen-code 0.13.0-preview.3 → 0.13.0-preview.5
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/cli.js +223 -102
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -171203,7 +171203,7 @@ __export(geminiContentGenerator_exports, {
|
|
|
171203
171203
|
createGeminiContentGenerator: () => createGeminiContentGenerator
|
|
171204
171204
|
});
|
|
171205
171205
|
function createGeminiContentGenerator(config2, gcConfig) {
|
|
171206
|
-
const version2 = "0.13.0-preview.
|
|
171206
|
+
const version2 = "0.13.0-preview.5";
|
|
171207
171207
|
const userAgent2 = config2.userAgent || `QwenCode/${version2} (${process.platform}; ${process.arch})`;
|
|
171208
171208
|
const baseHeaders = {
|
|
171209
171209
|
"User-Agent": userAgent2
|
|
@@ -174648,7 +174648,7 @@ var init_chatCompressionService = __esm({
|
|
|
174648
174648
|
static {
|
|
174649
174649
|
__name(this, "ChatCompressionService");
|
|
174650
174650
|
}
|
|
174651
|
-
async compress(chat, promptId, force, model, config2, hasFailedCompressionAttempt) {
|
|
174651
|
+
async compress(chat, promptId, force, model, config2, hasFailedCompressionAttempt, signal) {
|
|
174652
174652
|
const curatedHistory = chat.getHistory(true);
|
|
174653
174653
|
const threshold = config2.getChatCompression()?.contextPercentageThreshold ?? COMPRESSION_TOKEN_THRESHOLD;
|
|
174654
174654
|
if (curatedHistory.length === 0 || threshold <= 0 || hasFailedCompressionAttempt && !force) {
|
|
@@ -174679,7 +174679,7 @@ var init_chatCompressionService = __esm({
|
|
|
174679
174679
|
if (hookSystem) {
|
|
174680
174680
|
const trigger = force ? PreCompactTrigger.Manual : PreCompactTrigger.Auto;
|
|
174681
174681
|
try {
|
|
174682
|
-
await hookSystem.firePreCompactEvent(trigger, "");
|
|
174682
|
+
await hookSystem.firePreCompactEvent(trigger, "", signal);
|
|
174683
174683
|
} catch (err2) {
|
|
174684
174684
|
config2.getDebugLogger().warn(`PreCompact hook failed: ${err2}`);
|
|
174685
174685
|
}
|
|
@@ -174778,7 +174778,8 @@ var init_chatCompressionService = __esm({
|
|
|
174778
174778
|
} else {
|
|
174779
174779
|
uiTelemetryService.setLastPromptTokenCount(newTokenCount);
|
|
174780
174780
|
try {
|
|
174781
|
-
|
|
174781
|
+
const permissionMode = String(config2.getApprovalMode());
|
|
174782
|
+
await config2.getHookSystem()?.fireSessionStartEvent(SessionStartSource.Compact, model ?? "", permissionMode, void 0, signal);
|
|
174782
174783
|
} catch (err2) {
|
|
174783
174784
|
config2.getDebugLogger().warn(`SessionStart hook failed: ${err2}`);
|
|
174784
174785
|
}
|
|
@@ -175075,7 +175076,7 @@ var init_types7 = __esm({
|
|
|
175075
175076
|
function generateToolUseId() {
|
|
175076
175077
|
return `toolu_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
|
175077
175078
|
}
|
|
175078
|
-
async function firePreToolUseHook(messageBus, toolName, toolInput, toolUseId, permissionMode) {
|
|
175079
|
+
async function firePreToolUseHook(messageBus, toolName, toolInput, toolUseId, permissionMode, signal) {
|
|
175079
175080
|
if (!messageBus) {
|
|
175080
175081
|
return { shouldProceed: true };
|
|
175081
175082
|
}
|
|
@@ -175088,7 +175089,8 @@ async function firePreToolUseHook(messageBus, toolName, toolInput, toolUseId, pe
|
|
|
175088
175089
|
tool_name: toolName,
|
|
175089
175090
|
tool_input: toolInput,
|
|
175090
175091
|
tool_use_id: toolUseId
|
|
175091
|
-
}
|
|
175092
|
+
},
|
|
175093
|
+
signal
|
|
175092
175094
|
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
175093
175095
|
if (!response.success || !response.output) {
|
|
175094
175096
|
return { shouldProceed: true };
|
|
@@ -175125,7 +175127,7 @@ async function firePreToolUseHook(messageBus, toolName, toolInput, toolUseId, pe
|
|
|
175125
175127
|
return { shouldProceed: true };
|
|
175126
175128
|
}
|
|
175127
175129
|
}
|
|
175128
|
-
async function firePostToolUseHook(messageBus, toolName, toolInput, toolResponse, toolUseId, permissionMode) {
|
|
175130
|
+
async function firePostToolUseHook(messageBus, toolName, toolInput, toolResponse, toolUseId, permissionMode, signal) {
|
|
175129
175131
|
if (!messageBus) {
|
|
175130
175132
|
return { shouldStop: false };
|
|
175131
175133
|
}
|
|
@@ -175139,7 +175141,8 @@ async function firePostToolUseHook(messageBus, toolName, toolInput, toolResponse
|
|
|
175139
175141
|
tool_input: toolInput,
|
|
175140
175142
|
tool_response: toolResponse,
|
|
175141
175143
|
tool_use_id: toolUseId
|
|
175142
|
-
}
|
|
175144
|
+
},
|
|
175145
|
+
signal
|
|
175143
175146
|
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
175144
175147
|
if (!response.success || !response.output) {
|
|
175145
175148
|
return { shouldStop: false };
|
|
@@ -175161,7 +175164,7 @@ async function firePostToolUseHook(messageBus, toolName, toolInput, toolResponse
|
|
|
175161
175164
|
return { shouldStop: false };
|
|
175162
175165
|
}
|
|
175163
175166
|
}
|
|
175164
|
-
async function firePostToolUseFailureHook(messageBus, toolUseId, toolName, toolInput, errorMessage, isInterrupt, permissionMode) {
|
|
175167
|
+
async function firePostToolUseFailureHook(messageBus, toolUseId, toolName, toolInput, errorMessage, isInterrupt, permissionMode, signal) {
|
|
175165
175168
|
if (!messageBus) {
|
|
175166
175169
|
return {};
|
|
175167
175170
|
}
|
|
@@ -175176,7 +175179,8 @@ async function firePostToolUseFailureHook(messageBus, toolUseId, toolName, toolI
|
|
|
175176
175179
|
tool_input: toolInput,
|
|
175177
175180
|
error: errorMessage,
|
|
175178
175181
|
is_interrupt: isInterrupt
|
|
175179
|
-
}
|
|
175182
|
+
},
|
|
175183
|
+
signal
|
|
175180
175184
|
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
175181
175185
|
if (!response.success || !response.output) {
|
|
175182
175186
|
return {};
|
|
@@ -175191,7 +175195,7 @@ async function firePostToolUseFailureHook(messageBus, toolUseId, toolName, toolI
|
|
|
175191
175195
|
return {};
|
|
175192
175196
|
}
|
|
175193
175197
|
}
|
|
175194
|
-
async function fireNotificationHook(messageBus, message, notificationType, title) {
|
|
175198
|
+
async function fireNotificationHook(messageBus, message, notificationType, title, signal) {
|
|
175195
175199
|
if (!messageBus) {
|
|
175196
175200
|
return {};
|
|
175197
175201
|
}
|
|
@@ -175203,7 +175207,8 @@ async function fireNotificationHook(messageBus, message, notificationType, title
|
|
|
175203
175207
|
message,
|
|
175204
175208
|
notification_type: notificationType,
|
|
175205
175209
|
title
|
|
175206
|
-
}
|
|
175210
|
+
},
|
|
175211
|
+
signal
|
|
175207
175212
|
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
175208
175213
|
if (!response.success || !response.output) {
|
|
175209
175214
|
return {};
|
|
@@ -175218,7 +175223,7 @@ async function fireNotificationHook(messageBus, message, notificationType, title
|
|
|
175218
175223
|
return {};
|
|
175219
175224
|
}
|
|
175220
175225
|
}
|
|
175221
|
-
async function firePermissionRequestHook(messageBus, toolName, toolInput, permissionMode, permissionSuggestions) {
|
|
175226
|
+
async function firePermissionRequestHook(messageBus, toolName, toolInput, permissionMode, permissionSuggestions, signal) {
|
|
175222
175227
|
if (!messageBus) {
|
|
175223
175228
|
return { hasDecision: false };
|
|
175224
175229
|
}
|
|
@@ -175231,7 +175236,8 @@ async function firePermissionRequestHook(messageBus, toolName, toolInput, permis
|
|
|
175231
175236
|
tool_input: toolInput,
|
|
175232
175237
|
permission_mode: permissionMode,
|
|
175233
175238
|
permission_suggestions: permissionSuggestions
|
|
175234
|
-
}
|
|
175239
|
+
},
|
|
175240
|
+
signal
|
|
175235
175241
|
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
175236
175242
|
if (!response.success || !response.output) {
|
|
175237
175243
|
return { hasDecision: false };
|
|
@@ -178377,6 +178383,15 @@ function splitCommands(command2) {
|
|
|
178377
178383
|
let inSingleQuotes = false;
|
|
178378
178384
|
let inDoubleQuotes = false;
|
|
178379
178385
|
let i4 = 0;
|
|
178386
|
+
const previousNonWhitespaceChar = /* @__PURE__ */ __name((index) => {
|
|
178387
|
+
for (let j2 = index - 1; j2 >= 0; j2--) {
|
|
178388
|
+
const ch = command2[j2];
|
|
178389
|
+
if (ch && !/\s/.test(ch)) {
|
|
178390
|
+
return ch;
|
|
178391
|
+
}
|
|
178392
|
+
}
|
|
178393
|
+
return void 0;
|
|
178394
|
+
}, "previousNonWhitespaceChar");
|
|
178380
178395
|
while (i4 < command2.length) {
|
|
178381
178396
|
const char = command2[i4];
|
|
178382
178397
|
const nextChar = command2[i4 + 1];
|
|
@@ -178391,13 +178406,29 @@ function splitCommands(command2) {
|
|
|
178391
178406
|
inDoubleQuotes = !inDoubleQuotes;
|
|
178392
178407
|
}
|
|
178393
178408
|
if (!inSingleQuotes && !inDoubleQuotes) {
|
|
178394
|
-
if (char === "&" && nextChar === "&" || char === "|" && nextChar === "|") {
|
|
178409
|
+
if (char === "&" && nextChar === "&" || char === "|" && (nextChar === "|" || nextChar === "&")) {
|
|
178395
178410
|
commands.push(currentCommand.trim());
|
|
178396
178411
|
currentCommand = "";
|
|
178397
178412
|
i4++;
|
|
178398
|
-
} else if (char === ";"
|
|
178413
|
+
} else if (char === ";") {
|
|
178399
178414
|
commands.push(currentCommand.trim());
|
|
178400
178415
|
currentCommand = "";
|
|
178416
|
+
} else if (char === "&") {
|
|
178417
|
+
const prevChar = previousNonWhitespaceChar(i4);
|
|
178418
|
+
if (prevChar === ">" || prevChar === "<") {
|
|
178419
|
+
currentCommand += char;
|
|
178420
|
+
} else {
|
|
178421
|
+
commands.push(currentCommand.trim());
|
|
178422
|
+
currentCommand = "";
|
|
178423
|
+
}
|
|
178424
|
+
} else if (char === "|") {
|
|
178425
|
+
const prevChar = previousNonWhitespaceChar(i4);
|
|
178426
|
+
if (prevChar === ">") {
|
|
178427
|
+
currentCommand += char;
|
|
178428
|
+
} else {
|
|
178429
|
+
commands.push(currentCommand.trim());
|
|
178430
|
+
currentCommand = "";
|
|
178431
|
+
}
|
|
178401
178432
|
} else if (char === "\r" && nextChar === "\n") {
|
|
178402
178433
|
commands.push(currentCommand.trim());
|
|
178403
178434
|
currentCommand = "";
|
|
@@ -190414,7 +190445,7 @@ assistant: "I'm going to use the ${ToolNames.AGENT} tool to launch the greeting-
|
|
|
190414
190445
|
const agentType = this.params.subagent_type;
|
|
190415
190446
|
if (hookSystem) {
|
|
190416
190447
|
try {
|
|
190417
|
-
const startHookOutput = await hookSystem.fireSubagentStartEvent(agentId, agentType, PermissionMode.Default);
|
|
190448
|
+
const startHookOutput = await hookSystem.fireSubagentStartEvent(agentId, agentType, PermissionMode.Default, signal);
|
|
190418
190449
|
const additionalContext = startHookOutput?.getAdditionalContext();
|
|
190419
190450
|
if (additionalContext) {
|
|
190420
190451
|
contextState.set("hook_context", additionalContext);
|
|
@@ -190438,7 +190469,7 @@ assistant: "I'm going to use the ${ToolNames.AGENT} tool to launch the greeting-
|
|
|
190438
190469
|
break;
|
|
190439
190470
|
}
|
|
190440
190471
|
try {
|
|
190441
|
-
const stopHookOutput = await hookSystem.fireSubagentStopEvent(agentId, agentType, transcriptPath, subagent.getFinalText(), stopHookActive, PermissionMode.Default);
|
|
190472
|
+
const stopHookOutput = await hookSystem.fireSubagentStopEvent(agentId, agentType, transcriptPath, subagent.getFinalText(), stopHookActive, PermissionMode.Default, signal);
|
|
190442
190473
|
const typedStopOutput = stopHookOutput;
|
|
190443
190474
|
if (typedStopOutput?.isBlockingDecision() || typedStopOutput?.shouldStopExecution()) {
|
|
190444
190475
|
const continueReason = typedStopOutput.getEffectiveReason();
|
|
@@ -195957,7 +195988,7 @@ var init_client2 = __esm({
|
|
|
195957
195988
|
if (!boundedTurns) {
|
|
195958
195989
|
return new Turn(this.getChat(), prompt_id);
|
|
195959
195990
|
}
|
|
195960
|
-
const compressed = await this.tryCompressChat(prompt_id, false);
|
|
195991
|
+
const compressed = await this.tryCompressChat(prompt_id, false, signal);
|
|
195961
195992
|
if (compressed.compressionStatus === CompressionStatus.COMPRESSED) {
|
|
195962
195993
|
yield { type: GeminiEventType.ChatCompressed, value: compressed };
|
|
195963
195994
|
}
|
|
@@ -196045,7 +196076,7 @@ var init_client2 = __esm({
|
|
|
196045
196076
|
return turn;
|
|
196046
196077
|
}
|
|
196047
196078
|
}
|
|
196048
|
-
if (hooksEnabled && messageBus && !turn.pendingToolCalls.length) {
|
|
196079
|
+
if (hooksEnabled && messageBus && !turn.pendingToolCalls.length && signal && !signal.aborted) {
|
|
196049
196080
|
const history2 = this.getHistory();
|
|
196050
196081
|
const lastModelMessage = history2.filter((msg) => msg.role === "model").pop();
|
|
196051
196082
|
const responseText = lastModelMessage?.parts?.filter((p2) => "text" in p2).map((p2) => p2.text).join("") || "[no response text]";
|
|
@@ -196055,11 +196086,18 @@ var init_client2 = __esm({
|
|
|
196055
196086
|
input: {
|
|
196056
196087
|
stop_hook_active: true,
|
|
196057
196088
|
last_assistant_message: responseText
|
|
196058
|
-
}
|
|
196089
|
+
},
|
|
196090
|
+
signal
|
|
196059
196091
|
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
196092
|
+
if (signal.aborted) {
|
|
196093
|
+
return turn;
|
|
196094
|
+
}
|
|
196060
196095
|
const hookOutput = response.output ? createHookOutput("Stop", response.output) : void 0;
|
|
196061
196096
|
const stopOutput = hookOutput;
|
|
196062
196097
|
if (stopOutput?.isBlockingDecision() || stopOutput?.shouldStopExecution()) {
|
|
196098
|
+
if (signal.aborted) {
|
|
196099
|
+
return turn;
|
|
196100
|
+
}
|
|
196063
196101
|
if (stopOutput.systemMessage) {
|
|
196064
196102
|
yield {
|
|
196065
196103
|
type: GeminiEventType.HookSystemMessage,
|
|
@@ -196126,9 +196164,9 @@ var init_client2 = __esm({
|
|
|
196126
196164
|
throw new Error(`Failed to generate content with model ${currentAttemptModel}: ${getErrorMessage(error40)}`);
|
|
196127
196165
|
}
|
|
196128
196166
|
}
|
|
196129
|
-
async tryCompressChat(prompt_id, force = false) {
|
|
196167
|
+
async tryCompressChat(prompt_id, force = false, signal) {
|
|
196130
196168
|
const compressionService = new ChatCompressionService();
|
|
196131
|
-
const { newHistory, info: info2 } = await compressionService.compress(this.getChat(), prompt_id, force, this.config.getModel(), this.config, this.hasFailedCompressionAttempt);
|
|
196169
|
+
const { newHistory, info: info2 } = await compressionService.compress(this.getChat(), prompt_id, force, this.config.getModel(), this.config, this.hasFailedCompressionAttempt, signal);
|
|
196132
196170
|
if (info2.compressionStatus === CompressionStatus.COMPRESSED) {
|
|
196133
196171
|
if (newHistory) {
|
|
196134
196172
|
const chatRecordingService = this.config.getChatRecordingService();
|
|
@@ -264508,11 +264546,25 @@ var init_hookRunner = __esm({
|
|
|
264508
264546
|
}
|
|
264509
264547
|
/**
|
|
264510
264548
|
* Execute a single hook
|
|
264549
|
+
* @param hookConfig Hook configuration
|
|
264550
|
+
* @param eventName Event name
|
|
264551
|
+
* @param input Hook input
|
|
264552
|
+
* @param signal Optional AbortSignal to cancel hook execution
|
|
264511
264553
|
*/
|
|
264512
|
-
async executeHook(hookConfig, eventName, input) {
|
|
264554
|
+
async executeHook(hookConfig, eventName, input, signal) {
|
|
264513
264555
|
const startTime = Date.now();
|
|
264556
|
+
if (signal?.aborted) {
|
|
264557
|
+
const hookId = hookConfig.name || hookConfig.command || "unknown";
|
|
264558
|
+
return {
|
|
264559
|
+
hookConfig,
|
|
264560
|
+
eventName,
|
|
264561
|
+
success: false,
|
|
264562
|
+
error: new Error(`Hook execution cancelled (aborted): ${hookId}`),
|
|
264563
|
+
duration: 0
|
|
264564
|
+
};
|
|
264565
|
+
}
|
|
264514
264566
|
try {
|
|
264515
|
-
return await this.executeCommandHook(hookConfig, eventName, input, startTime);
|
|
264567
|
+
return await this.executeCommandHook(hookConfig, eventName, input, startTime, signal);
|
|
264516
264568
|
} catch (error40) {
|
|
264517
264569
|
const duration3 = Date.now() - startTime;
|
|
264518
264570
|
const hookId = hookConfig.name || hookConfig.command || "unknown";
|
|
@@ -264529,11 +264581,12 @@ var init_hookRunner = __esm({
|
|
|
264529
264581
|
}
|
|
264530
264582
|
/**
|
|
264531
264583
|
* Execute multiple hooks in parallel
|
|
264584
|
+
* @param signal Optional AbortSignal to cancel hook execution
|
|
264532
264585
|
*/
|
|
264533
|
-
async executeHooksParallel(hookConfigs, eventName, input, onHookStart, onHookEnd) {
|
|
264586
|
+
async executeHooksParallel(hookConfigs, eventName, input, onHookStart, onHookEnd, signal) {
|
|
264534
264587
|
const promises8 = hookConfigs.map(async (config2, index) => {
|
|
264535
264588
|
onHookStart?.(config2, index);
|
|
264536
|
-
const result = await this.executeHook(config2, eventName, input);
|
|
264589
|
+
const result = await this.executeHook(config2, eventName, input, signal);
|
|
264537
264590
|
onHookEnd?.(config2, result);
|
|
264538
264591
|
return result;
|
|
264539
264592
|
});
|
|
@@ -264541,14 +264594,18 @@ var init_hookRunner = __esm({
|
|
|
264541
264594
|
}
|
|
264542
264595
|
/**
|
|
264543
264596
|
* Execute multiple hooks sequentially
|
|
264597
|
+
* @param signal Optional AbortSignal to cancel hook execution
|
|
264544
264598
|
*/
|
|
264545
|
-
async executeHooksSequential(hookConfigs, eventName, input, onHookStart, onHookEnd) {
|
|
264599
|
+
async executeHooksSequential(hookConfigs, eventName, input, onHookStart, onHookEnd, signal) {
|
|
264546
264600
|
const results = [];
|
|
264547
264601
|
let currentInput = input;
|
|
264548
264602
|
for (let i4 = 0; i4 < hookConfigs.length; i4++) {
|
|
264603
|
+
if (signal?.aborted) {
|
|
264604
|
+
break;
|
|
264605
|
+
}
|
|
264549
264606
|
const config2 = hookConfigs[i4];
|
|
264550
264607
|
onHookStart?.(config2, i4);
|
|
264551
|
-
const result = await this.executeHook(config2, eventName, currentInput);
|
|
264608
|
+
const result = await this.executeHook(config2, eventName, currentInput, signal);
|
|
264552
264609
|
onHookEnd?.(config2, result);
|
|
264553
264610
|
results.push(result);
|
|
264554
264611
|
if (result.success && result.output) {
|
|
@@ -264591,8 +264648,13 @@ var init_hookRunner = __esm({
|
|
|
264591
264648
|
}
|
|
264592
264649
|
/**
|
|
264593
264650
|
* Execute a command hook
|
|
264651
|
+
* @param hookConfig Hook configuration
|
|
264652
|
+
* @param eventName Event name
|
|
264653
|
+
* @param input Hook input
|
|
264654
|
+
* @param startTime Start time for duration calculation
|
|
264655
|
+
* @param signal Optional AbortSignal to cancel hook execution
|
|
264594
264656
|
*/
|
|
264595
|
-
async executeCommandHook(hookConfig, eventName, input, startTime) {
|
|
264657
|
+
async executeCommandHook(hookConfig, eventName, input, startTime, signal) {
|
|
264596
264658
|
const timeout2 = hookConfig.timeout ?? DEFAULT_HOOK_TIMEOUT;
|
|
264597
264659
|
return new Promise((resolve35) => {
|
|
264598
264660
|
if (!hookConfig.command) {
|
|
@@ -264610,6 +264672,7 @@ var init_hookRunner = __esm({
|
|
|
264610
264672
|
let stdout2 = "";
|
|
264611
264673
|
let stderr = "";
|
|
264612
264674
|
let timedOut = false;
|
|
264675
|
+
let aborted2 = false;
|
|
264613
264676
|
const shellConfig = getShellConfiguration();
|
|
264614
264677
|
const command2 = this.expandCommand(hookConfig.command, input, shellConfig.shell);
|
|
264615
264678
|
const env6 = {
|
|
@@ -264627,15 +264690,28 @@ var init_hookRunner = __esm({
|
|
|
264627
264690
|
stdio: ["pipe", "pipe", "pipe"],
|
|
264628
264691
|
shell: false
|
|
264629
264692
|
});
|
|
264693
|
+
const killChild = /* @__PURE__ */ __name(() => {
|
|
264694
|
+
if (!child.killed) {
|
|
264695
|
+
child.kill("SIGTERM");
|
|
264696
|
+
setTimeout(() => {
|
|
264697
|
+
if (!child.killed) {
|
|
264698
|
+
child.kill("SIGKILL");
|
|
264699
|
+
}
|
|
264700
|
+
}, 2e3);
|
|
264701
|
+
}
|
|
264702
|
+
}, "killChild");
|
|
264630
264703
|
const timeoutHandle = setTimeout(() => {
|
|
264631
264704
|
timedOut = true;
|
|
264632
|
-
|
|
264633
|
-
setTimeout(() => {
|
|
264634
|
-
if (!child.killed) {
|
|
264635
|
-
child.kill("SIGKILL");
|
|
264636
|
-
}
|
|
264637
|
-
}, 5e3);
|
|
264705
|
+
killChild();
|
|
264638
264706
|
}, timeout2);
|
|
264707
|
+
const abortHandler = /* @__PURE__ */ __name(() => {
|
|
264708
|
+
aborted2 = true;
|
|
264709
|
+
clearTimeout(timeoutHandle);
|
|
264710
|
+
killChild();
|
|
264711
|
+
}, "abortHandler");
|
|
264712
|
+
if (signal) {
|
|
264713
|
+
signal.addEventListener("abort", abortHandler);
|
|
264714
|
+
}
|
|
264639
264715
|
if (child.stdin) {
|
|
264640
264716
|
child.stdin.on("error", (err2) => {
|
|
264641
264717
|
if (err2.code !== "EPIPE") {
|
|
@@ -264671,7 +264747,22 @@ var init_hookRunner = __esm({
|
|
|
264671
264747
|
});
|
|
264672
264748
|
child.on("close", (exitCode) => {
|
|
264673
264749
|
clearTimeout(timeoutHandle);
|
|
264750
|
+
if (signal) {
|
|
264751
|
+
signal.removeEventListener("abort", abortHandler);
|
|
264752
|
+
}
|
|
264674
264753
|
const duration3 = Date.now() - startTime;
|
|
264754
|
+
if (aborted2) {
|
|
264755
|
+
resolve35({
|
|
264756
|
+
hookConfig,
|
|
264757
|
+
eventName,
|
|
264758
|
+
success: false,
|
|
264759
|
+
error: new Error("Hook execution cancelled (aborted)"),
|
|
264760
|
+
stdout: stdout2,
|
|
264761
|
+
stderr,
|
|
264762
|
+
duration: duration3
|
|
264763
|
+
});
|
|
264764
|
+
return;
|
|
264765
|
+
}
|
|
264675
264766
|
if (timedOut) {
|
|
264676
264767
|
resolve35({
|
|
264677
264768
|
hookConfig,
|
|
@@ -265206,30 +265297,30 @@ var init_hookEventHandler = __esm({
|
|
|
265206
265297
|
* Fire a UserPromptSubmit event
|
|
265207
265298
|
* Called by handleHookExecutionRequest - executes hooks directly
|
|
265208
265299
|
*/
|
|
265209
|
-
async fireUserPromptSubmitEvent(prompt) {
|
|
265300
|
+
async fireUserPromptSubmitEvent(prompt, signal) {
|
|
265210
265301
|
const input = {
|
|
265211
265302
|
...this.createBaseInput(HookEventName.UserPromptSubmit),
|
|
265212
265303
|
prompt
|
|
265213
265304
|
};
|
|
265214
|
-
return this.executeHooks(HookEventName.UserPromptSubmit, input);
|
|
265305
|
+
return this.executeHooks(HookEventName.UserPromptSubmit, input, void 0, signal);
|
|
265215
265306
|
}
|
|
265216
265307
|
/**
|
|
265217
265308
|
* Fire a Stop event
|
|
265218
265309
|
* Called by handleHookExecutionRequest - executes hooks directly
|
|
265219
265310
|
*/
|
|
265220
|
-
async fireStopEvent(stopHookActive = false, lastAssistantMessage = "") {
|
|
265311
|
+
async fireStopEvent(stopHookActive = false, lastAssistantMessage = "", signal) {
|
|
265221
265312
|
const input = {
|
|
265222
265313
|
...this.createBaseInput(HookEventName.Stop),
|
|
265223
265314
|
stop_hook_active: stopHookActive,
|
|
265224
265315
|
last_assistant_message: lastAssistantMessage
|
|
265225
265316
|
};
|
|
265226
|
-
return this.executeHooks(HookEventName.Stop, input);
|
|
265317
|
+
return this.executeHooks(HookEventName.Stop, input, void 0, signal);
|
|
265227
265318
|
}
|
|
265228
265319
|
/**
|
|
265229
265320
|
* Fire a SessionStart event
|
|
265230
265321
|
* Called when a new session starts or resumes
|
|
265231
265322
|
*/
|
|
265232
|
-
async fireSessionStartEvent(source2, model, permissionMode, agentType) {
|
|
265323
|
+
async fireSessionStartEvent(source2, model, permissionMode, agentType, signal) {
|
|
265233
265324
|
const input = {
|
|
265234
265325
|
...this.createBaseInput(HookEventName.SessionStart),
|
|
265235
265326
|
permission_mode: permissionMode ?? PermissionMode.Default,
|
|
@@ -265239,26 +265330,26 @@ var init_hookEventHandler = __esm({
|
|
|
265239
265330
|
};
|
|
265240
265331
|
return this.executeHooks(HookEventName.SessionStart, input, {
|
|
265241
265332
|
trigger: source2
|
|
265242
|
-
});
|
|
265333
|
+
}, signal);
|
|
265243
265334
|
}
|
|
265244
265335
|
/**
|
|
265245
265336
|
* Fire a SessionEnd event
|
|
265246
265337
|
* Called when a session ends
|
|
265247
265338
|
*/
|
|
265248
|
-
async fireSessionEndEvent(reason) {
|
|
265339
|
+
async fireSessionEndEvent(reason, signal) {
|
|
265249
265340
|
const input = {
|
|
265250
265341
|
...this.createBaseInput(HookEventName.SessionEnd),
|
|
265251
265342
|
reason
|
|
265252
265343
|
};
|
|
265253
265344
|
return this.executeHooks(HookEventName.SessionEnd, input, {
|
|
265254
265345
|
trigger: reason
|
|
265255
|
-
});
|
|
265346
|
+
}, signal);
|
|
265256
265347
|
}
|
|
265257
265348
|
/**
|
|
265258
265349
|
* Fire a PreToolUse event
|
|
265259
265350
|
* Called before tool execution begins
|
|
265260
265351
|
*/
|
|
265261
|
-
async firePreToolUseEvent(toolName, toolInput, toolUseId, permissionMode) {
|
|
265352
|
+
async firePreToolUseEvent(toolName, toolInput, toolUseId, permissionMode, signal) {
|
|
265262
265353
|
const input = {
|
|
265263
265354
|
...this.createBaseInput(HookEventName.PreToolUse),
|
|
265264
265355
|
permission_mode: permissionMode,
|
|
@@ -265268,13 +265359,13 @@ var init_hookEventHandler = __esm({
|
|
|
265268
265359
|
};
|
|
265269
265360
|
return this.executeHooks(HookEventName.PreToolUse, input, {
|
|
265270
265361
|
toolName
|
|
265271
|
-
});
|
|
265362
|
+
}, signal);
|
|
265272
265363
|
}
|
|
265273
265364
|
/**
|
|
265274
265365
|
* Fire a PostToolUse event
|
|
265275
265366
|
* Called after successful tool execution
|
|
265276
265367
|
*/
|
|
265277
|
-
async firePostToolUseEvent(toolName, toolInput, toolResponse, toolUseId, permissionMode) {
|
|
265368
|
+
async firePostToolUseEvent(toolName, toolInput, toolResponse, toolUseId, permissionMode, signal) {
|
|
265278
265369
|
const input = {
|
|
265279
265370
|
...this.createBaseInput(HookEventName.PostToolUse),
|
|
265280
265371
|
permission_mode: permissionMode,
|
|
@@ -265285,13 +265376,13 @@ var init_hookEventHandler = __esm({
|
|
|
265285
265376
|
};
|
|
265286
265377
|
return this.executeHooks(HookEventName.PostToolUse, input, {
|
|
265287
265378
|
toolName
|
|
265288
|
-
});
|
|
265379
|
+
}, signal);
|
|
265289
265380
|
}
|
|
265290
265381
|
/**
|
|
265291
265382
|
* Fire a PostToolUseFailure event
|
|
265292
265383
|
* Called when tool execution fails
|
|
265293
265384
|
*/
|
|
265294
|
-
async firePostToolUseFailureEvent(toolUseId, toolName, toolInput, errorMessage, isInterrupt, permissionMode) {
|
|
265385
|
+
async firePostToolUseFailureEvent(toolUseId, toolName, toolInput, errorMessage, isInterrupt, permissionMode, signal) {
|
|
265295
265386
|
const input = {
|
|
265296
265387
|
...this.createBaseInput(HookEventName.PostToolUseFailure),
|
|
265297
265388
|
permission_mode: permissionMode ?? PermissionMode.Default,
|
|
@@ -265303,13 +265394,13 @@ var init_hookEventHandler = __esm({
|
|
|
265303
265394
|
};
|
|
265304
265395
|
return this.executeHooks(HookEventName.PostToolUseFailure, input, {
|
|
265305
265396
|
toolName
|
|
265306
|
-
});
|
|
265397
|
+
}, signal);
|
|
265307
265398
|
}
|
|
265308
265399
|
/**
|
|
265309
265400
|
* Fire a PreCompact event
|
|
265310
265401
|
* Called before conversation compaction begins
|
|
265311
265402
|
*/
|
|
265312
|
-
async firePreCompactEvent(trigger, customInstructions = "") {
|
|
265403
|
+
async firePreCompactEvent(trigger, customInstructions = "", signal) {
|
|
265313
265404
|
const input = {
|
|
265314
265405
|
...this.createBaseInput(HookEventName.PreCompact),
|
|
265315
265406
|
trigger,
|
|
@@ -265317,12 +265408,12 @@ var init_hookEventHandler = __esm({
|
|
|
265317
265408
|
};
|
|
265318
265409
|
return this.executeHooks(HookEventName.PreCompact, input, {
|
|
265319
265410
|
trigger
|
|
265320
|
-
});
|
|
265411
|
+
}, signal);
|
|
265321
265412
|
}
|
|
265322
265413
|
/**
|
|
265323
265414
|
* Fire a Notification event
|
|
265324
265415
|
*/
|
|
265325
|
-
async fireNotificationEvent(message, notificationType, title) {
|
|
265416
|
+
async fireNotificationEvent(message, notificationType, title, signal) {
|
|
265326
265417
|
const input = {
|
|
265327
265418
|
...this.createBaseInput(HookEventName.Notification),
|
|
265328
265419
|
message,
|
|
@@ -265331,13 +265422,13 @@ var init_hookEventHandler = __esm({
|
|
|
265331
265422
|
};
|
|
265332
265423
|
return this.executeHooks(HookEventName.Notification, input, {
|
|
265333
265424
|
notificationType
|
|
265334
|
-
});
|
|
265425
|
+
}, signal);
|
|
265335
265426
|
}
|
|
265336
265427
|
/**
|
|
265337
265428
|
* Fire a PermissionRequest event
|
|
265338
265429
|
* Called when a permission dialog is about to be shown to the user
|
|
265339
265430
|
*/
|
|
265340
|
-
async firePermissionRequestEvent(toolName, toolInput, permissionMode, permissionSuggestions) {
|
|
265431
|
+
async firePermissionRequestEvent(toolName, toolInput, permissionMode, permissionSuggestions, signal) {
|
|
265341
265432
|
const input = {
|
|
265342
265433
|
...this.createBaseInput(HookEventName.PermissionRequest),
|
|
265343
265434
|
permission_mode: permissionMode,
|
|
@@ -265347,13 +265438,13 @@ var init_hookEventHandler = __esm({
|
|
|
265347
265438
|
};
|
|
265348
265439
|
return this.executeHooks(HookEventName.PermissionRequest, input, {
|
|
265349
265440
|
toolName
|
|
265350
|
-
});
|
|
265441
|
+
}, signal);
|
|
265351
265442
|
}
|
|
265352
265443
|
/**
|
|
265353
265444
|
* Fire a SubagentStart event
|
|
265354
265445
|
* Called when a subagent is spawned via the Agent tool
|
|
265355
265446
|
*/
|
|
265356
|
-
async fireSubagentStartEvent(agentId, agentType, permissionMode) {
|
|
265447
|
+
async fireSubagentStartEvent(agentId, agentType, permissionMode, signal) {
|
|
265357
265448
|
const input = {
|
|
265358
265449
|
...this.createBaseInput(HookEventName.SubagentStart),
|
|
265359
265450
|
permission_mode: permissionMode,
|
|
@@ -265362,13 +265453,13 @@ var init_hookEventHandler = __esm({
|
|
|
265362
265453
|
};
|
|
265363
265454
|
return this.executeHooks(HookEventName.SubagentStart, input, {
|
|
265364
265455
|
agentType: String(agentType)
|
|
265365
|
-
});
|
|
265456
|
+
}, signal);
|
|
265366
265457
|
}
|
|
265367
265458
|
/**
|
|
265368
265459
|
* Fire a SubagentStop event
|
|
265369
265460
|
* Called when a subagent has finished responding
|
|
265370
265461
|
*/
|
|
265371
|
-
async fireSubagentStopEvent(agentId, agentType, agentTranscriptPath, lastAssistantMessage, stopHookActive, permissionMode) {
|
|
265462
|
+
async fireSubagentStopEvent(agentId, agentType, agentTranscriptPath, lastAssistantMessage, stopHookActive, permissionMode, signal) {
|
|
265372
265463
|
const input = {
|
|
265373
265464
|
...this.createBaseInput(HookEventName.SubagentStop),
|
|
265374
265465
|
permission_mode: permissionMode,
|
|
@@ -265380,13 +265471,13 @@ var init_hookEventHandler = __esm({
|
|
|
265380
265471
|
};
|
|
265381
265472
|
return this.executeHooks(HookEventName.SubagentStop, input, {
|
|
265382
265473
|
agentType: String(agentType)
|
|
265383
|
-
});
|
|
265474
|
+
}, signal);
|
|
265384
265475
|
}
|
|
265385
265476
|
/**
|
|
265386
265477
|
* Execute hooks for a specific event (direct execution without MessageBus)
|
|
265387
265478
|
* Used as fallback when MessageBus is not available
|
|
265388
265479
|
*/
|
|
265389
|
-
async executeHooks(eventName, input, context2) {
|
|
265480
|
+
async executeHooks(eventName, input, context2, signal) {
|
|
265390
265481
|
try {
|
|
265391
265482
|
const plan = this.hookPlanner.createExecutionPlan(eventName, context2);
|
|
265392
265483
|
if (!plan || plan.hookConfigs.length === 0) {
|
|
@@ -265401,7 +265492,7 @@ var init_hookEventHandler = __esm({
|
|
|
265401
265492
|
}, "onHookStart");
|
|
265402
265493
|
const onHookEnd = /* @__PURE__ */ __name((_config, _result) => {
|
|
265403
265494
|
}, "onHookEnd");
|
|
265404
|
-
const results = plan.sequential ? await this.hookRunner.executeHooksSequential(plan.hookConfigs, eventName, input, onHookStart, onHookEnd) : await this.hookRunner.executeHooksParallel(plan.hookConfigs, eventName, input, onHookStart, onHookEnd);
|
|
265495
|
+
const results = plan.sequential ? await this.hookRunner.executeHooksSequential(plan.hookConfigs, eventName, input, onHookStart, onHookEnd, signal) : await this.hookRunner.executeHooksParallel(plan.hookConfigs, eventName, input, onHookStart, onHookEnd, signal);
|
|
265405
265496
|
const aggregated = this.hookAggregator.aggregateResults(results, eventName);
|
|
265406
265497
|
this.processCommonHookOutputFields(aggregated);
|
|
265407
265498
|
return aggregated;
|
|
@@ -265509,76 +265600,76 @@ var init_hookSystem = __esm({
|
|
|
265509
265600
|
getAllHooks() {
|
|
265510
265601
|
return this.hookRegistry.getAllHooks();
|
|
265511
265602
|
}
|
|
265512
|
-
async fireUserPromptSubmitEvent(prompt) {
|
|
265513
|
-
const result = await this.hookEventHandler.fireUserPromptSubmitEvent(prompt);
|
|
265603
|
+
async fireUserPromptSubmitEvent(prompt, signal) {
|
|
265604
|
+
const result = await this.hookEventHandler.fireUserPromptSubmitEvent(prompt, signal);
|
|
265514
265605
|
return result.finalOutput ? createHookOutput("UserPromptSubmit", result.finalOutput) : void 0;
|
|
265515
265606
|
}
|
|
265516
|
-
async fireStopEvent(stopHookActive = false, lastAssistantMessage = "") {
|
|
265517
|
-
const result = await this.hookEventHandler.fireStopEvent(stopHookActive, lastAssistantMessage);
|
|
265607
|
+
async fireStopEvent(stopHookActive = false, lastAssistantMessage = "", signal) {
|
|
265608
|
+
const result = await this.hookEventHandler.fireStopEvent(stopHookActive, lastAssistantMessage, signal);
|
|
265518
265609
|
return result.finalOutput ? createHookOutput("Stop", result.finalOutput) : void 0;
|
|
265519
265610
|
}
|
|
265520
|
-
async fireSessionStartEvent(source2, model, permissionMode, agentType) {
|
|
265521
|
-
const result = await this.hookEventHandler.fireSessionStartEvent(source2, model, permissionMode, agentType);
|
|
265611
|
+
async fireSessionStartEvent(source2, model, permissionMode, agentType, signal) {
|
|
265612
|
+
const result = await this.hookEventHandler.fireSessionStartEvent(source2, model, permissionMode, agentType, signal);
|
|
265522
265613
|
return result.finalOutput ? createHookOutput("SessionStart", result.finalOutput) : void 0;
|
|
265523
265614
|
}
|
|
265524
|
-
async fireSessionEndEvent(reason) {
|
|
265525
|
-
const result = await this.hookEventHandler.fireSessionEndEvent(reason);
|
|
265615
|
+
async fireSessionEndEvent(reason, signal) {
|
|
265616
|
+
const result = await this.hookEventHandler.fireSessionEndEvent(reason, signal);
|
|
265526
265617
|
return result.finalOutput ? createHookOutput("SessionEnd", result.finalOutput) : void 0;
|
|
265527
265618
|
}
|
|
265528
265619
|
/**
|
|
265529
265620
|
* Fire a PreToolUse event - called before tool execution
|
|
265530
265621
|
*/
|
|
265531
|
-
async firePreToolUseEvent(toolName, toolInput, toolUseId, permissionMode) {
|
|
265532
|
-
const result = await this.hookEventHandler.firePreToolUseEvent(toolName, toolInput, toolUseId, permissionMode);
|
|
265622
|
+
async firePreToolUseEvent(toolName, toolInput, toolUseId, permissionMode, signal) {
|
|
265623
|
+
const result = await this.hookEventHandler.firePreToolUseEvent(toolName, toolInput, toolUseId, permissionMode, signal);
|
|
265533
265624
|
return result.finalOutput ? createHookOutput("PreToolUse", result.finalOutput) : void 0;
|
|
265534
265625
|
}
|
|
265535
265626
|
/**
|
|
265536
265627
|
* Fire a PostToolUse event - called after successful tool execution
|
|
265537
265628
|
*/
|
|
265538
|
-
async firePostToolUseEvent(toolName, toolInput, toolResponse, toolUseId, permissionMode) {
|
|
265539
|
-
const result = await this.hookEventHandler.firePostToolUseEvent(toolName, toolInput, toolResponse, toolUseId, permissionMode);
|
|
265629
|
+
async firePostToolUseEvent(toolName, toolInput, toolResponse, toolUseId, permissionMode, signal) {
|
|
265630
|
+
const result = await this.hookEventHandler.firePostToolUseEvent(toolName, toolInput, toolResponse, toolUseId, permissionMode, signal);
|
|
265540
265631
|
return result.finalOutput ? createHookOutput("PostToolUse", result.finalOutput) : void 0;
|
|
265541
265632
|
}
|
|
265542
265633
|
/**
|
|
265543
265634
|
* Fire a PostToolUseFailure event - called when tool execution fails
|
|
265544
265635
|
*/
|
|
265545
|
-
async firePostToolUseFailureEvent(toolUseId, toolName, toolInput, errorMessage, isInterrupt, permissionMode) {
|
|
265546
|
-
const result = await this.hookEventHandler.firePostToolUseFailureEvent(toolUseId, toolName, toolInput, errorMessage, isInterrupt, permissionMode);
|
|
265636
|
+
async firePostToolUseFailureEvent(toolUseId, toolName, toolInput, errorMessage, isInterrupt, permissionMode, signal) {
|
|
265637
|
+
const result = await this.hookEventHandler.firePostToolUseFailureEvent(toolUseId, toolName, toolInput, errorMessage, isInterrupt, permissionMode, signal);
|
|
265547
265638
|
return result.finalOutput ? createHookOutput("PostToolUseFailure", result.finalOutput) : void 0;
|
|
265548
265639
|
}
|
|
265549
265640
|
/**
|
|
265550
265641
|
* Fire a PreCompact event - called before conversation compaction
|
|
265551
265642
|
*/
|
|
265552
|
-
async firePreCompactEvent(trigger, customInstructions = "") {
|
|
265553
|
-
const result = await this.hookEventHandler.firePreCompactEvent(trigger, customInstructions);
|
|
265643
|
+
async firePreCompactEvent(trigger, customInstructions = "", signal) {
|
|
265644
|
+
const result = await this.hookEventHandler.firePreCompactEvent(trigger, customInstructions, signal);
|
|
265554
265645
|
return result.finalOutput ? createHookOutput("PreCompact", result.finalOutput) : void 0;
|
|
265555
265646
|
}
|
|
265556
265647
|
/**
|
|
265557
265648
|
* Fire a Notification event
|
|
265558
265649
|
*/
|
|
265559
|
-
async fireNotificationEvent(message, notificationType, title) {
|
|
265560
|
-
const result = await this.hookEventHandler.fireNotificationEvent(message, notificationType, title);
|
|
265650
|
+
async fireNotificationEvent(message, notificationType, title, signal) {
|
|
265651
|
+
const result = await this.hookEventHandler.fireNotificationEvent(message, notificationType, title, signal);
|
|
265561
265652
|
return result.finalOutput ? createHookOutput("Notification", result.finalOutput) : void 0;
|
|
265562
265653
|
}
|
|
265563
265654
|
/**
|
|
265564
265655
|
* Fire a SubagentStart event - called when a subagent is spawned
|
|
265565
265656
|
*/
|
|
265566
|
-
async fireSubagentStartEvent(agentId, agentType, permissionMode) {
|
|
265567
|
-
const result = await this.hookEventHandler.fireSubagentStartEvent(agentId, agentType, permissionMode);
|
|
265657
|
+
async fireSubagentStartEvent(agentId, agentType, permissionMode, signal) {
|
|
265658
|
+
const result = await this.hookEventHandler.fireSubagentStartEvent(agentId, agentType, permissionMode, signal);
|
|
265568
265659
|
return result.finalOutput ? createHookOutput("SubagentStart", result.finalOutput) : void 0;
|
|
265569
265660
|
}
|
|
265570
265661
|
/**
|
|
265571
265662
|
* Fire a SubagentStop event - called when a subagent finishes
|
|
265572
265663
|
*/
|
|
265573
|
-
async fireSubagentStopEvent(agentId, agentType, agentTranscriptPath, lastAssistantMessage, stopHookActive, permissionMode) {
|
|
265574
|
-
const result = await this.hookEventHandler.fireSubagentStopEvent(agentId, agentType, agentTranscriptPath, lastAssistantMessage, stopHookActive, permissionMode);
|
|
265664
|
+
async fireSubagentStopEvent(agentId, agentType, agentTranscriptPath, lastAssistantMessage, stopHookActive, permissionMode, signal) {
|
|
265665
|
+
const result = await this.hookEventHandler.fireSubagentStopEvent(agentId, agentType, agentTranscriptPath, lastAssistantMessage, stopHookActive, permissionMode, signal);
|
|
265575
265666
|
return result.finalOutput ? createHookOutput("SubagentStop", result.finalOutput) : void 0;
|
|
265576
265667
|
}
|
|
265577
265668
|
/**
|
|
265578
265669
|
* Fire a PermissionRequest event
|
|
265579
265670
|
*/
|
|
265580
|
-
async firePermissionRequestEvent(toolName, toolInput, permissionMode, permissionSuggestions) {
|
|
265581
|
-
const result = await this.hookEventHandler.firePermissionRequestEvent(toolName, toolInput, permissionMode, permissionSuggestions);
|
|
265671
|
+
async firePermissionRequestEvent(toolName, toolInput, permissionMode, permissionSuggestions, signal) {
|
|
265672
|
+
const result = await this.hookEventHandler.firePermissionRequestEvent(toolName, toolInput, permissionMode, permissionSuggestions, signal);
|
|
265582
265673
|
return result.finalOutput ? createHookOutput("PermissionRequest", result.finalOutput) : void 0;
|
|
265583
265674
|
}
|
|
265584
265675
|
};
|
|
@@ -265669,9 +265760,13 @@ var init_message_bus = __esm({
|
|
|
265669
265760
|
* This enables synchronous-style communication over the async MessageBus
|
|
265670
265761
|
* The correlation ID is generated internally and added to the request
|
|
265671
265762
|
*/
|
|
265672
|
-
async request(request4, responseType, timeoutMs = 6e4) {
|
|
265763
|
+
async request(request4, responseType, timeoutMs = 6e4, signal) {
|
|
265673
265764
|
const correlationId = randomUUID5();
|
|
265674
265765
|
return new Promise((resolve35, reject) => {
|
|
265766
|
+
if (signal?.aborted) {
|
|
265767
|
+
reject(new Error("Request aborted"));
|
|
265768
|
+
return;
|
|
265769
|
+
}
|
|
265675
265770
|
const timeoutId = setTimeout(() => {
|
|
265676
265771
|
cleanup();
|
|
265677
265772
|
reject(new Error(`Request timed out waiting for ${responseType}`));
|
|
@@ -265679,7 +265774,17 @@ var init_message_bus = __esm({
|
|
|
265679
265774
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
265680
265775
|
clearTimeout(timeoutId);
|
|
265681
265776
|
this.unsubscribe(responseType, responseHandler);
|
|
265777
|
+
if (signal) {
|
|
265778
|
+
signal.removeEventListener("abort", abortHandler);
|
|
265779
|
+
}
|
|
265682
265780
|
}, "cleanup");
|
|
265781
|
+
const abortHandler = /* @__PURE__ */ __name(() => {
|
|
265782
|
+
cleanup();
|
|
265783
|
+
reject(new Error("Request aborted"));
|
|
265784
|
+
}, "abortHandler");
|
|
265785
|
+
if (signal) {
|
|
265786
|
+
signal.addEventListener("abort", abortHandler);
|
|
265787
|
+
}
|
|
265683
265788
|
const responseHandler = /* @__PURE__ */ __name((response) => {
|
|
265684
265789
|
if ("correlationId" in response && response.correlationId === correlationId) {
|
|
265685
265790
|
cleanup();
|
|
@@ -269211,36 +269316,46 @@ var init_config3 = __esm({
|
|
|
269211
269316
|
});
|
|
269212
269317
|
return;
|
|
269213
269318
|
}
|
|
269319
|
+
if (request4.signal?.aborted) {
|
|
269320
|
+
this.messageBus?.publish({
|
|
269321
|
+
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
|
|
269322
|
+
correlationId: request4.correlationId,
|
|
269323
|
+
success: false,
|
|
269324
|
+
error: new Error("Hook execution cancelled (aborted)")
|
|
269325
|
+
});
|
|
269326
|
+
return;
|
|
269327
|
+
}
|
|
269214
269328
|
let result;
|
|
269215
269329
|
const input = request4.input || {};
|
|
269330
|
+
const signal = request4.signal;
|
|
269216
269331
|
switch (request4.eventName) {
|
|
269217
269332
|
case "UserPromptSubmit":
|
|
269218
|
-
result = await hookSystem.fireUserPromptSubmitEvent(input["prompt"] || "");
|
|
269333
|
+
result = await hookSystem.fireUserPromptSubmitEvent(input["prompt"] || "", signal);
|
|
269219
269334
|
break;
|
|
269220
269335
|
case "Stop":
|
|
269221
|
-
result = await hookSystem.fireStopEvent(input["stop_hook_active"] || false, input["last_assistant_message"] || "");
|
|
269336
|
+
result = await hookSystem.fireStopEvent(input["stop_hook_active"] || false, input["last_assistant_message"] || "", signal);
|
|
269222
269337
|
break;
|
|
269223
269338
|
case "PreToolUse": {
|
|
269224
|
-
result = await hookSystem.firePreToolUseEvent(input["tool_name"] || "", input["tool_input"] || {}, input["tool_use_id"] || "", input["permission_mode"] ?? PermissionMode.Default);
|
|
269339
|
+
result = await hookSystem.firePreToolUseEvent(input["tool_name"] || "", input["tool_input"] || {}, input["tool_use_id"] || "", input["permission_mode"] ?? PermissionMode.Default, signal);
|
|
269225
269340
|
break;
|
|
269226
269341
|
}
|
|
269227
269342
|
case "PostToolUse":
|
|
269228
|
-
result = await hookSystem.firePostToolUseEvent(input["tool_name"] || "", input["tool_input"] || {}, input["tool_response"] || {}, input["tool_use_id"] || "", input["permission_mode"] || "default");
|
|
269343
|
+
result = await hookSystem.firePostToolUseEvent(input["tool_name"] || "", input["tool_input"] || {}, input["tool_response"] || {}, input["tool_use_id"] || "", input["permission_mode"] || "default", signal);
|
|
269229
269344
|
break;
|
|
269230
269345
|
case "PostToolUseFailure":
|
|
269231
|
-
result = await hookSystem.firePostToolUseFailureEvent(input["tool_use_id"] || "", input["tool_name"] || "", input["tool_input"] || {}, input["error"] || "", input["is_interrupt"], input["permission_mode"] || "default");
|
|
269346
|
+
result = await hookSystem.firePostToolUseFailureEvent(input["tool_use_id"] || "", input["tool_name"] || "", input["tool_input"] || {}, input["error"] || "", input["is_interrupt"], input["permission_mode"] || "default", signal);
|
|
269232
269347
|
break;
|
|
269233
269348
|
case "Notification":
|
|
269234
|
-
result = await hookSystem.fireNotificationEvent(input["message"] || "", input["notification_type"] || "permission_prompt", input["title"] || void 0);
|
|
269349
|
+
result = await hookSystem.fireNotificationEvent(input["message"] || "", input["notification_type"] || "permission_prompt", input["title"] || void 0, signal);
|
|
269235
269350
|
break;
|
|
269236
269351
|
case "PermissionRequest":
|
|
269237
|
-
result = await hookSystem.firePermissionRequestEvent(input["tool_name"] || "", input["tool_input"] || {}, input["permission_mode"] || PermissionMode.Default, input["permission_suggestions"] || void 0);
|
|
269352
|
+
result = await hookSystem.firePermissionRequestEvent(input["tool_name"] || "", input["tool_input"] || {}, input["permission_mode"] || PermissionMode.Default, input["permission_suggestions"] || void 0, signal);
|
|
269238
269353
|
break;
|
|
269239
269354
|
case "SubagentStart":
|
|
269240
|
-
result = await hookSystem.fireSubagentStartEvent(input["agent_id"] || "", input["agent_type"] || "", input["permission_mode"] || PermissionMode.Default);
|
|
269355
|
+
result = await hookSystem.fireSubagentStartEvent(input["agent_id"] || "", input["agent_type"] || "", input["permission_mode"] || PermissionMode.Default, signal);
|
|
269241
269356
|
break;
|
|
269242
269357
|
case "SubagentStop":
|
|
269243
|
-
result = await hookSystem.fireSubagentStopEvent(input["agent_id"] || "", input["agent_type"] || "", input["agent_transcript_path"] || "", input["last_assistant_message"] || "", input["stop_hook_active"] || false, input["permission_mode"] || PermissionMode.Default);
|
|
269358
|
+
result = await hookSystem.fireSubagentStopEvent(input["agent_id"] || "", input["agent_type"] || "", input["agent_transcript_path"] || "", input["last_assistant_message"] || "", input["stop_hook_active"] || false, input["permission_mode"] || PermissionMode.Default, signal);
|
|
269244
269359
|
break;
|
|
269245
269360
|
default:
|
|
269246
269361
|
this.debugLogger.warn(`Unknown hook event: ${request4.eventName}`);
|
|
@@ -405768,7 +405883,7 @@ __name(getPackageJson, "getPackageJson");
|
|
|
405768
405883
|
// packages/cli/src/utils/version.ts
|
|
405769
405884
|
async function getCliVersion() {
|
|
405770
405885
|
const pkgJson = await getPackageJson();
|
|
405771
|
-
return "0.13.0-preview.
|
|
405886
|
+
return "0.13.0-preview.5";
|
|
405772
405887
|
}
|
|
405773
405888
|
__name(getCliVersion, "getCliVersion");
|
|
405774
405889
|
|
|
@@ -413398,7 +413513,7 @@ var formatDuration = /* @__PURE__ */ __name((milliseconds) => {
|
|
|
413398
413513
|
|
|
413399
413514
|
// packages/cli/src/generated/git-commit.ts
|
|
413400
413515
|
init_esbuild_shims();
|
|
413401
|
-
var GIT_COMMIT_INFO = "
|
|
413516
|
+
var GIT_COMMIT_INFO = "3b1b8da91";
|
|
413402
413517
|
|
|
413403
413518
|
// packages/cli/src/utils/systemInfo.ts
|
|
413404
413519
|
async function getNpmVersion() {
|
|
@@ -414416,7 +414531,8 @@ var clearCommand = {
|
|
|
414416
414531
|
try {
|
|
414417
414532
|
await config2.getHookSystem()?.fireSessionStartEvent(
|
|
414418
414533
|
SessionStartSource.Clear,
|
|
414419
|
-
config2.getModel() ?? ""
|
|
414534
|
+
config2.getModel() ?? "",
|
|
414535
|
+
String(config2.getApprovalMode())
|
|
414420
414536
|
);
|
|
414421
414537
|
} catch (err2) {
|
|
414422
414538
|
config2.getDebugLogger().warn(`SessionStart hook failed: ${err2}`);
|
|
@@ -463979,7 +464095,8 @@ function useResumeCommand(options2) {
|
|
|
463979
464095
|
try {
|
|
463980
464096
|
await config2.getHookSystem()?.fireSessionStartEvent(
|
|
463981
464097
|
SessionStartSource.Resume,
|
|
463982
|
-
config2.getModel() ?? ""
|
|
464098
|
+
config2.getModel() ?? "",
|
|
464099
|
+
String(config2.getApprovalMode())
|
|
463983
464100
|
);
|
|
463984
464101
|
} catch (err2) {
|
|
463985
464102
|
config2.getDebugLogger().warn(`SessionStart hook failed: ${err2}`);
|
|
@@ -471766,7 +471883,11 @@ var AppContainer = /* @__PURE__ */ __name((props) => {
|
|
|
471766
471883
|
const sessionStartSource = resumedSessionData ? SessionStartSource.Resume : SessionStartSource.Startup;
|
|
471767
471884
|
const hookSystem = config2.getHookSystem();
|
|
471768
471885
|
if (hookSystem) {
|
|
471769
|
-
hookSystem.fireSessionStartEvent(
|
|
471886
|
+
hookSystem.fireSessionStartEvent(
|
|
471887
|
+
sessionStartSource,
|
|
471888
|
+
config2.getModel() ?? "",
|
|
471889
|
+
String(config2.getApprovalMode())
|
|
471890
|
+
).then(() => {
|
|
471770
471891
|
debugLogger145.debug("SessionStart event completed successfully");
|
|
471771
471892
|
}).catch((err2) => {
|
|
471772
471893
|
debugLogger145.warn(`SessionStart hook failed: ${err2}`);
|
|
@@ -476768,7 +476889,7 @@ var QwenAgent = class {
|
|
|
476768
476889
|
async initialize(args2) {
|
|
476769
476890
|
this.clientCapabilities = args2.clientCapabilities;
|
|
476770
476891
|
const authMethods = buildAuthMethods();
|
|
476771
|
-
const version2 = "0.13.0-preview.
|
|
476892
|
+
const version2 = "0.13.0-preview.5";
|
|
476772
476893
|
return {
|
|
476773
476894
|
protocolVersion: PROTOCOL_VERSION,
|
|
476774
476895
|
agentInfo: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwen-code/qwen-code",
|
|
3
|
-
"version": "0.13.0-preview.
|
|
3
|
+
"version": "0.13.0-preview.5",
|
|
4
4
|
"description": "Qwen Code - AI-powered coding assistant",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"bundled"
|
|
22
22
|
],
|
|
23
23
|
"config": {
|
|
24
|
-
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.13.0-preview.
|
|
24
|
+
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.13.0-preview.5"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {},
|
|
27
27
|
"optionalDependencies": {
|