@qwen-code/qwen-code 0.2.0 → 0.2.1-nightly.20251112.22edef0c
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 +245 -29
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -182650,7 +182650,7 @@ function createContentGeneratorConfig(config, authType, generationConfig) {
|
|
|
182650
182650
|
};
|
|
182651
182651
|
}
|
|
182652
182652
|
async function createContentGenerator(config, gcConfig, sessionId2) {
|
|
182653
|
-
const version2 = "0.2.
|
|
182653
|
+
const version2 = "0.2.1-nightly.20251112.22edef0c";
|
|
182654
182654
|
const userAgent2 = `QwenCode/${version2} (${process.platform}; ${process.arch})`;
|
|
182655
182655
|
const baseHeaders = {
|
|
182656
182656
|
"User-Agent": userAgent2
|
|
@@ -252075,6 +252075,8 @@ var init_src = __esm({
|
|
|
252075
252075
|
init_read_many_files();
|
|
252076
252076
|
init_mcp_client();
|
|
252077
252077
|
init_mcp_tool();
|
|
252078
|
+
init_task();
|
|
252079
|
+
init_todoWrite();
|
|
252078
252080
|
init_oauth_provider();
|
|
252079
252081
|
init_oauth_token_storage();
|
|
252080
252082
|
init_oauth_utils();
|
|
@@ -338601,7 +338603,7 @@ __name(getPackageJson, "getPackageJson");
|
|
|
338601
338603
|
// packages/cli/src/utils/version.ts
|
|
338602
338604
|
async function getCliVersion() {
|
|
338603
338605
|
const pkgJson = await getPackageJson();
|
|
338604
|
-
return "0.2.
|
|
338606
|
+
return "0.2.1-nightly.20251112.22edef0c";
|
|
338605
338607
|
}
|
|
338606
338608
|
__name(getCliVersion, "getCliVersion");
|
|
338607
338609
|
|
|
@@ -340212,7 +340214,7 @@ import { execSync as execSync4 } from "node:child_process";
|
|
|
340212
340214
|
|
|
340213
340215
|
// packages/cli/src/generated/git-commit.ts
|
|
340214
340216
|
init_esbuild_shims();
|
|
340215
|
-
var GIT_COMMIT_INFO2 = "
|
|
340217
|
+
var GIT_COMMIT_INFO2 = "e142fb67";
|
|
340216
340218
|
|
|
340217
340219
|
// packages/cli/src/utils/systemInfo.ts
|
|
340218
340220
|
async function getNpmVersion() {
|
|
@@ -353781,7 +353783,6 @@ init_esbuild_shims();
|
|
|
353781
353783
|
// packages/cli/src/zed-integration/acp.ts
|
|
353782
353784
|
init_esbuild_shims();
|
|
353783
353785
|
init_zod();
|
|
353784
|
-
import { EOL as EOL4 } from "node:os";
|
|
353785
353786
|
|
|
353786
353787
|
// packages/cli/src/zed-integration/schema.ts
|
|
353787
353788
|
init_esbuild_shims();
|
|
@@ -354187,7 +354188,7 @@ var Connection = class {
|
|
|
354187
354188
|
const decoder = new TextDecoder();
|
|
354188
354189
|
for await (const chunk of output) {
|
|
354189
354190
|
content += decoder.decode(chunk, { stream: true });
|
|
354190
|
-
const lines = content.split(
|
|
354191
|
+
const lines = content.split("\n");
|
|
354191
354192
|
content = lines.pop() || "";
|
|
354192
354193
|
for (const line of lines) {
|
|
354193
354194
|
const trimmedLine = line.trim();
|
|
@@ -354640,13 +354641,23 @@ var Session2 = class {
|
|
|
354640
354641
|
new Error(`Tool "${fc.name}" not found in registry.`)
|
|
354641
354642
|
);
|
|
354642
354643
|
}
|
|
354644
|
+
const isTodoWriteTool = fc.name === TodoWriteTool.Name || tool.name === TodoWriteTool.Name;
|
|
354645
|
+
let subAgentToolEventListeners = [];
|
|
354643
354646
|
try {
|
|
354644
354647
|
const invocation = tool.build(args);
|
|
354648
|
+
const isTaskTool = tool.name === TaskTool.Name;
|
|
354649
|
+
if (isTaskTool && "eventEmitter" in invocation) {
|
|
354650
|
+
const taskEventEmitter = invocation.eventEmitter;
|
|
354651
|
+
subAgentToolEventListeners = this.setupSubAgentToolTracking(
|
|
354652
|
+
taskEventEmitter,
|
|
354653
|
+
abortSignal
|
|
354654
|
+
);
|
|
354655
|
+
}
|
|
354645
354656
|
const confirmationDetails = await invocation.shouldConfirmExecute(abortSignal);
|
|
354646
354657
|
if (confirmationDetails) {
|
|
354647
|
-
const
|
|
354658
|
+
const content = [];
|
|
354648
354659
|
if (confirmationDetails.type === "edit") {
|
|
354649
|
-
|
|
354660
|
+
content.push({
|
|
354650
354661
|
type: "diff",
|
|
354651
354662
|
path: confirmationDetails.fileName,
|
|
354652
354663
|
oldText: confirmationDetails.originalContent,
|
|
@@ -354660,7 +354671,7 @@ var Session2 = class {
|
|
|
354660
354671
|
toolCallId: callId,
|
|
354661
354672
|
status: "pending",
|
|
354662
354673
|
title: invocation.getDescription(),
|
|
354663
|
-
content
|
|
354674
|
+
content,
|
|
354664
354675
|
locations: invocation.toolLocations(),
|
|
354665
354676
|
kind: tool.kind
|
|
354666
354677
|
}
|
|
@@ -354684,7 +354695,7 @@ var Session2 = class {
|
|
|
354684
354695
|
throw new Error(`Unexpected: ${resultOutcome}`);
|
|
354685
354696
|
}
|
|
354686
354697
|
}
|
|
354687
|
-
} else {
|
|
354698
|
+
} else if (!isTodoWriteTool) {
|
|
354688
354699
|
await this.sendUpdate({
|
|
354689
354700
|
sessionUpdate: "tool_call",
|
|
354690
354701
|
toolCallId: callId,
|
|
@@ -354696,13 +354707,31 @@ var Session2 = class {
|
|
|
354696
354707
|
});
|
|
354697
354708
|
}
|
|
354698
354709
|
const toolResult = await invocation.execute(abortSignal);
|
|
354699
|
-
|
|
354700
|
-
|
|
354701
|
-
|
|
354702
|
-
|
|
354703
|
-
|
|
354704
|
-
|
|
354705
|
-
|
|
354710
|
+
subAgentToolEventListeners.forEach((cleanup) => cleanup());
|
|
354711
|
+
if (isTodoWriteTool) {
|
|
354712
|
+
let todos = [];
|
|
354713
|
+
if (Array.isArray(args["todos"])) {
|
|
354714
|
+
todos = args["todos"];
|
|
354715
|
+
}
|
|
354716
|
+
if (toolResult.returnDisplay && typeof toolResult.returnDisplay === "object" && "type" in toolResult.returnDisplay && toolResult.returnDisplay.type === "todo_list" && "todos" in toolResult.returnDisplay && Array.isArray(toolResult.returnDisplay.todos)) {
|
|
354717
|
+
todos = toolResult.returnDisplay.todos;
|
|
354718
|
+
}
|
|
354719
|
+
if (todos.length > 0 || Array.isArray(args["todos"])) {
|
|
354720
|
+
const planEntries = convertTodosToPlanEntries(todos);
|
|
354721
|
+
await this.sendUpdate({
|
|
354722
|
+
sessionUpdate: "plan",
|
|
354723
|
+
entries: planEntries
|
|
354724
|
+
});
|
|
354725
|
+
}
|
|
354726
|
+
} else {
|
|
354727
|
+
const content = toToolCallContent(toolResult);
|
|
354728
|
+
await this.sendUpdate({
|
|
354729
|
+
sessionUpdate: "tool_call_update",
|
|
354730
|
+
toolCallId: callId,
|
|
354731
|
+
status: "completed",
|
|
354732
|
+
content: content ? [content] : []
|
|
354733
|
+
});
|
|
354734
|
+
}
|
|
354706
354735
|
const durationMs = Date.now() - startTime;
|
|
354707
354736
|
logToolCall(this.config, {
|
|
354708
354737
|
"event.name": "tool_call",
|
|
@@ -354717,6 +354746,7 @@ var Session2 = class {
|
|
|
354717
354746
|
});
|
|
354718
354747
|
return convertToFunctionResponse(fc.name, callId, toolResult.llmContent);
|
|
354719
354748
|
} catch (e2) {
|
|
354749
|
+
subAgentToolEventListeners.forEach((cleanup) => cleanup());
|
|
354720
354750
|
const error = e2 instanceof Error ? e2 : new Error(String(e2));
|
|
354721
354751
|
await this.sendUpdate({
|
|
354722
354752
|
sessionUpdate: "tool_call_update",
|
|
@@ -354729,6 +354759,196 @@ var Session2 = class {
|
|
|
354729
354759
|
return errorResponse(error);
|
|
354730
354760
|
}
|
|
354731
354761
|
}
|
|
354762
|
+
/**
|
|
354763
|
+
* Sets up event listeners to track sub-agent tool calls within a TaskTool execution.
|
|
354764
|
+
* Converts subagent tool call events into zedIntegration session updates.
|
|
354765
|
+
*
|
|
354766
|
+
* @param eventEmitter - The SubAgentEventEmitter from TaskTool
|
|
354767
|
+
* @param abortSignal - Signal to abort tracking if parent is cancelled
|
|
354768
|
+
* @returns Array of cleanup functions to remove event listeners
|
|
354769
|
+
*/
|
|
354770
|
+
setupSubAgentToolTracking(eventEmitter, abortSignal) {
|
|
354771
|
+
const cleanupFunctions2 = [];
|
|
354772
|
+
const toolRegistry = this.config.getToolRegistry();
|
|
354773
|
+
const subAgentToolStates = /* @__PURE__ */ new Map();
|
|
354774
|
+
const onToolCall = /* @__PURE__ */ __name((...args) => {
|
|
354775
|
+
const event = args[0];
|
|
354776
|
+
if (abortSignal.aborted) return;
|
|
354777
|
+
const subAgentTool = toolRegistry.getTool(event.name);
|
|
354778
|
+
let subAgentInvocation;
|
|
354779
|
+
let toolKind = "other";
|
|
354780
|
+
let locations = [];
|
|
354781
|
+
if (subAgentTool) {
|
|
354782
|
+
try {
|
|
354783
|
+
subAgentInvocation = subAgentTool.build(event.args);
|
|
354784
|
+
toolKind = this.mapToolKind(subAgentTool.kind);
|
|
354785
|
+
locations = subAgentInvocation.toolLocations().map((loc) => ({
|
|
354786
|
+
path: loc.path,
|
|
354787
|
+
line: loc.line ?? null
|
|
354788
|
+
}));
|
|
354789
|
+
} catch (e2) {
|
|
354790
|
+
console.warn(`Failed to build subagent tool ${event.name}:`, e2);
|
|
354791
|
+
}
|
|
354792
|
+
}
|
|
354793
|
+
subAgentToolStates.set(event.callId, {
|
|
354794
|
+
tool: subAgentTool,
|
|
354795
|
+
invocation: subAgentInvocation,
|
|
354796
|
+
args: event.args
|
|
354797
|
+
});
|
|
354798
|
+
if (event.name === TodoWriteTool.Name) {
|
|
354799
|
+
return;
|
|
354800
|
+
}
|
|
354801
|
+
void this.sendUpdate({
|
|
354802
|
+
sessionUpdate: "tool_call",
|
|
354803
|
+
toolCallId: event.callId,
|
|
354804
|
+
status: "in_progress",
|
|
354805
|
+
title: event.description || event.name,
|
|
354806
|
+
content: [],
|
|
354807
|
+
locations,
|
|
354808
|
+
kind: toolKind,
|
|
354809
|
+
rawInput: event.args
|
|
354810
|
+
});
|
|
354811
|
+
}, "onToolCall");
|
|
354812
|
+
const onToolResult = /* @__PURE__ */ __name((...args) => {
|
|
354813
|
+
const event = args[0];
|
|
354814
|
+
if (abortSignal.aborted) return;
|
|
354815
|
+
const state = subAgentToolStates.get(event.callId);
|
|
354816
|
+
if (event.name === TodoWriteTool.Name) {
|
|
354817
|
+
let todos;
|
|
354818
|
+
if (event.resultDisplay) {
|
|
354819
|
+
try {
|
|
354820
|
+
const parsed = typeof event.resultDisplay === "string" ? JSON.parse(event.resultDisplay) : event.resultDisplay;
|
|
354821
|
+
if (typeof parsed === "object" && parsed !== null && "type" in parsed && parsed.type === "todo_list" && "todos" in parsed && Array.isArray(parsed.todos)) {
|
|
354822
|
+
todos = parsed.todos;
|
|
354823
|
+
}
|
|
354824
|
+
} catch {
|
|
354825
|
+
}
|
|
354826
|
+
}
|
|
354827
|
+
if (!todos && state?.args && Array.isArray(state.args["todos"])) {
|
|
354828
|
+
todos = state.args["todos"];
|
|
354829
|
+
}
|
|
354830
|
+
if (todos) {
|
|
354831
|
+
const planEntries = convertTodosToPlanEntries(todos);
|
|
354832
|
+
void this.sendUpdate({
|
|
354833
|
+
sessionUpdate: "plan",
|
|
354834
|
+
entries: planEntries
|
|
354835
|
+
});
|
|
354836
|
+
}
|
|
354837
|
+
subAgentToolStates.delete(event.callId);
|
|
354838
|
+
return;
|
|
354839
|
+
}
|
|
354840
|
+
let content = [];
|
|
354841
|
+
if (event.resultDisplay && state?.invocation) {
|
|
354842
|
+
if (typeof event.resultDisplay === "string") {
|
|
354843
|
+
content = [
|
|
354844
|
+
{
|
|
354845
|
+
type: "content",
|
|
354846
|
+
content: {
|
|
354847
|
+
type: "text",
|
|
354848
|
+
text: event.resultDisplay
|
|
354849
|
+
}
|
|
354850
|
+
}
|
|
354851
|
+
];
|
|
354852
|
+
}
|
|
354853
|
+
}
|
|
354854
|
+
void this.sendUpdate({
|
|
354855
|
+
sessionUpdate: "tool_call_update",
|
|
354856
|
+
toolCallId: event.callId,
|
|
354857
|
+
status: event.success ? "completed" : "failed",
|
|
354858
|
+
content: content.length > 0 ? content : [],
|
|
354859
|
+
title: state?.invocation?.getDescription() ?? event.name,
|
|
354860
|
+
kind: state?.tool ? this.mapToolKind(state.tool.kind) : null,
|
|
354861
|
+
locations: state?.invocation?.toolLocations().map((loc) => ({
|
|
354862
|
+
path: loc.path,
|
|
354863
|
+
line: loc.line ?? null
|
|
354864
|
+
})) ?? null,
|
|
354865
|
+
rawInput: state?.args
|
|
354866
|
+
});
|
|
354867
|
+
subAgentToolStates.delete(event.callId);
|
|
354868
|
+
}, "onToolResult");
|
|
354869
|
+
const onToolWaitingApproval = /* @__PURE__ */ __name(async (...args) => {
|
|
354870
|
+
const event = args[0];
|
|
354871
|
+
if (abortSignal.aborted) return;
|
|
354872
|
+
const state = subAgentToolStates.get(event.callId);
|
|
354873
|
+
const content = [];
|
|
354874
|
+
if (event.confirmationDetails.type === "edit") {
|
|
354875
|
+
const editDetails = event.confirmationDetails;
|
|
354876
|
+
content.push({
|
|
354877
|
+
type: "diff",
|
|
354878
|
+
path: editDetails.fileName,
|
|
354879
|
+
oldText: editDetails.originalContent ?? "",
|
|
354880
|
+
newText: editDetails.newContent
|
|
354881
|
+
});
|
|
354882
|
+
}
|
|
354883
|
+
const fullConfirmationDetails = {
|
|
354884
|
+
...event.confirmationDetails,
|
|
354885
|
+
onConfirm: /* @__PURE__ */ __name(async () => {
|
|
354886
|
+
}, "onConfirm")
|
|
354887
|
+
};
|
|
354888
|
+
const params = {
|
|
354889
|
+
sessionId: this.id,
|
|
354890
|
+
options: toPermissionOptions(fullConfirmationDetails),
|
|
354891
|
+
toolCall: {
|
|
354892
|
+
toolCallId: event.callId,
|
|
354893
|
+
status: "pending",
|
|
354894
|
+
title: event.description || event.name,
|
|
354895
|
+
content,
|
|
354896
|
+
locations: state?.invocation?.toolLocations().map((loc) => ({
|
|
354897
|
+
path: loc.path,
|
|
354898
|
+
line: loc.line ?? null
|
|
354899
|
+
})) ?? [],
|
|
354900
|
+
kind: state?.tool ? this.mapToolKind(state.tool.kind) : "other",
|
|
354901
|
+
rawInput: state?.args
|
|
354902
|
+
}
|
|
354903
|
+
};
|
|
354904
|
+
try {
|
|
354905
|
+
const output = await this.client.requestPermission(params);
|
|
354906
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
354907
|
+
await event.respond(outcome);
|
|
354908
|
+
} catch (error) {
|
|
354909
|
+
console.error(
|
|
354910
|
+
`Permission request failed for subagent tool ${event.name}:`,
|
|
354911
|
+
error
|
|
354912
|
+
);
|
|
354913
|
+
await event.respond(ToolConfirmationOutcome.Cancel);
|
|
354914
|
+
}
|
|
354915
|
+
}, "onToolWaitingApproval");
|
|
354916
|
+
eventEmitter.on(SubAgentEventType.TOOL_CALL, onToolCall);
|
|
354917
|
+
eventEmitter.on(SubAgentEventType.TOOL_RESULT, onToolResult);
|
|
354918
|
+
eventEmitter.on(
|
|
354919
|
+
SubAgentEventType.TOOL_WAITING_APPROVAL,
|
|
354920
|
+
onToolWaitingApproval
|
|
354921
|
+
);
|
|
354922
|
+
cleanupFunctions2.push(() => {
|
|
354923
|
+
eventEmitter.off(SubAgentEventType.TOOL_CALL, onToolCall);
|
|
354924
|
+
eventEmitter.off(SubAgentEventType.TOOL_RESULT, onToolResult);
|
|
354925
|
+
eventEmitter.off(
|
|
354926
|
+
SubAgentEventType.TOOL_WAITING_APPROVAL,
|
|
354927
|
+
onToolWaitingApproval
|
|
354928
|
+
);
|
|
354929
|
+
});
|
|
354930
|
+
return cleanupFunctions2;
|
|
354931
|
+
}
|
|
354932
|
+
/**
|
|
354933
|
+
* Maps core Tool Kind enum to ACP ToolKind string literals.
|
|
354934
|
+
*
|
|
354935
|
+
* @param kind - The core Kind enum value
|
|
354936
|
+
* @returns The corresponding ACP ToolKind string literal
|
|
354937
|
+
*/
|
|
354938
|
+
mapToolKind(kind) {
|
|
354939
|
+
const kindMap = {
|
|
354940
|
+
[Kind.Read]: "read",
|
|
354941
|
+
[Kind.Edit]: "edit",
|
|
354942
|
+
[Kind.Delete]: "delete",
|
|
354943
|
+
[Kind.Move]: "move",
|
|
354944
|
+
[Kind.Search]: "search",
|
|
354945
|
+
[Kind.Execute]: "execute",
|
|
354946
|
+
[Kind.Think]: "think",
|
|
354947
|
+
[Kind.Fetch]: "fetch",
|
|
354948
|
+
[Kind.Other]: "other"
|
|
354949
|
+
};
|
|
354950
|
+
return kindMap[kind] ?? "other";
|
|
354951
|
+
}
|
|
354732
354952
|
async #resolvePrompt(message, abortSignal) {
|
|
354733
354953
|
const FILE_URI_SCHEME = "file://";
|
|
354734
354954
|
const embeddedContext = [];
|
|
@@ -355017,6 +355237,15 @@ Content from @${contextPart.uri}:
|
|
|
355017
355237
|
}
|
|
355018
355238
|
}
|
|
355019
355239
|
};
|
|
355240
|
+
function convertTodosToPlanEntries(todos) {
|
|
355241
|
+
return todos.map((todo) => ({
|
|
355242
|
+
content: todo.content,
|
|
355243
|
+
priority: "medium",
|
|
355244
|
+
// Default priority since todos don't have priority
|
|
355245
|
+
status: todo.status
|
|
355246
|
+
}));
|
|
355247
|
+
}
|
|
355248
|
+
__name(convertTodosToPlanEntries, "convertTodosToPlanEntries");
|
|
355020
355249
|
function toToolCallContent(toolResult) {
|
|
355021
355250
|
if (toolResult.error?.message) {
|
|
355022
355251
|
throw new Error(toolResult.error.message);
|
|
@@ -355027,19 +355256,6 @@ function toToolCallContent(toolResult) {
|
|
|
355027
355256
|
type: "content",
|
|
355028
355257
|
content: { type: "text", text: toolResult.returnDisplay }
|
|
355029
355258
|
};
|
|
355030
|
-
} else if ("type" in toolResult.returnDisplay && toolResult.returnDisplay.type === "todo_list") {
|
|
355031
|
-
const todoText = toolResult.returnDisplay.todos.map((todo) => {
|
|
355032
|
-
const statusIcon = {
|
|
355033
|
-
pending: "\u25CB",
|
|
355034
|
-
in_progress: "\u25D0",
|
|
355035
|
-
completed: "\u25CF"
|
|
355036
|
-
}[todo.status];
|
|
355037
|
-
return `${statusIcon} ${todo.content}`;
|
|
355038
|
-
}).join("\n");
|
|
355039
|
-
return {
|
|
355040
|
-
type: "content",
|
|
355041
|
-
content: { type: "text", text: todoText }
|
|
355042
|
-
};
|
|
355043
355259
|
} else if ("type" in toolResult.returnDisplay && toolResult.returnDisplay.type === "plan_summary") {
|
|
355044
355260
|
const planDisplay = toolResult.returnDisplay;
|
|
355045
355261
|
const planText = `${planDisplay.message}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwen-code/qwen-code",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-nightly.20251112.22edef0c",
|
|
4
4
|
"description": "Qwen Code - AI-powered coding assistant",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"config": {
|
|
22
|
-
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.2.
|
|
22
|
+
"sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.2.1-nightly.20251112.22edef0c"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"tiktoken": "^1.0.21"
|