@qwen-code/qwen-code 0.1.5 → 0.2.0-nightly.20251108.3c01c715

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.
Files changed (2) hide show
  1. package/cli.js +244 -27
  2. 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.1.5";
182653
+ const version2 = "0.2.0-nightly.20251108.3c01c715";
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.1.5";
338606
+ return "0.2.0-nightly.20251108.3c01c715";
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 = "2b2361f8";
340217
+ var GIT_COMMIT_INFO2 = "838a5cd1";
340216
340218
 
340217
340219
  // packages/cli/src/utils/systemInfo.ts
340218
340220
  async function getNpmVersion() {
@@ -354640,13 +354642,23 @@ var Session2 = class {
354640
354642
  new Error(`Tool "${fc.name}" not found in registry.`)
354641
354643
  );
354642
354644
  }
354645
+ const isTodoWriteTool = fc.name === TodoWriteTool.Name || tool.name === TodoWriteTool.Name;
354646
+ let subAgentToolEventListeners = [];
354643
354647
  try {
354644
354648
  const invocation = tool.build(args);
354649
+ const isTaskTool = tool.name === TaskTool.Name;
354650
+ if (isTaskTool && "eventEmitter" in invocation) {
354651
+ const taskEventEmitter = invocation.eventEmitter;
354652
+ subAgentToolEventListeners = this.setupSubAgentToolTracking(
354653
+ taskEventEmitter,
354654
+ abortSignal
354655
+ );
354656
+ }
354645
354657
  const confirmationDetails = await invocation.shouldConfirmExecute(abortSignal);
354646
354658
  if (confirmationDetails) {
354647
- const content2 = [];
354659
+ const content = [];
354648
354660
  if (confirmationDetails.type === "edit") {
354649
- content2.push({
354661
+ content.push({
354650
354662
  type: "diff",
354651
354663
  path: confirmationDetails.fileName,
354652
354664
  oldText: confirmationDetails.originalContent,
@@ -354660,7 +354672,7 @@ var Session2 = class {
354660
354672
  toolCallId: callId,
354661
354673
  status: "pending",
354662
354674
  title: invocation.getDescription(),
354663
- content: content2,
354675
+ content,
354664
354676
  locations: invocation.toolLocations(),
354665
354677
  kind: tool.kind
354666
354678
  }
@@ -354684,7 +354696,7 @@ var Session2 = class {
354684
354696
  throw new Error(`Unexpected: ${resultOutcome}`);
354685
354697
  }
354686
354698
  }
354687
- } else {
354699
+ } else if (!isTodoWriteTool) {
354688
354700
  await this.sendUpdate({
354689
354701
  sessionUpdate: "tool_call",
354690
354702
  toolCallId: callId,
@@ -354696,13 +354708,31 @@ var Session2 = class {
354696
354708
  });
354697
354709
  }
354698
354710
  const toolResult = await invocation.execute(abortSignal);
354699
- const content = toToolCallContent(toolResult);
354700
- await this.sendUpdate({
354701
- sessionUpdate: "tool_call_update",
354702
- toolCallId: callId,
354703
- status: "completed",
354704
- content: content ? [content] : []
354705
- });
354711
+ subAgentToolEventListeners.forEach((cleanup) => cleanup());
354712
+ if (isTodoWriteTool) {
354713
+ let todos = [];
354714
+ if (Array.isArray(args["todos"])) {
354715
+ todos = args["todos"];
354716
+ }
354717
+ 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)) {
354718
+ todos = toolResult.returnDisplay.todos;
354719
+ }
354720
+ if (todos.length > 0 || Array.isArray(args["todos"])) {
354721
+ const planEntries = convertTodosToPlanEntries(todos);
354722
+ await this.sendUpdate({
354723
+ sessionUpdate: "plan",
354724
+ entries: planEntries
354725
+ });
354726
+ }
354727
+ } else {
354728
+ const content = toToolCallContent(toolResult);
354729
+ await this.sendUpdate({
354730
+ sessionUpdate: "tool_call_update",
354731
+ toolCallId: callId,
354732
+ status: "completed",
354733
+ content: content ? [content] : []
354734
+ });
354735
+ }
354706
354736
  const durationMs = Date.now() - startTime;
354707
354737
  logToolCall(this.config, {
354708
354738
  "event.name": "tool_call",
@@ -354717,6 +354747,7 @@ var Session2 = class {
354717
354747
  });
354718
354748
  return convertToFunctionResponse(fc.name, callId, toolResult.llmContent);
354719
354749
  } catch (e2) {
354750
+ subAgentToolEventListeners.forEach((cleanup) => cleanup());
354720
354751
  const error = e2 instanceof Error ? e2 : new Error(String(e2));
354721
354752
  await this.sendUpdate({
354722
354753
  sessionUpdate: "tool_call_update",
@@ -354729,6 +354760,196 @@ var Session2 = class {
354729
354760
  return errorResponse(error);
354730
354761
  }
354731
354762
  }
354763
+ /**
354764
+ * Sets up event listeners to track sub-agent tool calls within a TaskTool execution.
354765
+ * Converts subagent tool call events into zedIntegration session updates.
354766
+ *
354767
+ * @param eventEmitter - The SubAgentEventEmitter from TaskTool
354768
+ * @param abortSignal - Signal to abort tracking if parent is cancelled
354769
+ * @returns Array of cleanup functions to remove event listeners
354770
+ */
354771
+ setupSubAgentToolTracking(eventEmitter, abortSignal) {
354772
+ const cleanupFunctions2 = [];
354773
+ const toolRegistry = this.config.getToolRegistry();
354774
+ const subAgentToolStates = /* @__PURE__ */ new Map();
354775
+ const onToolCall = /* @__PURE__ */ __name((...args) => {
354776
+ const event = args[0];
354777
+ if (abortSignal.aborted) return;
354778
+ const subAgentTool = toolRegistry.getTool(event.name);
354779
+ let subAgentInvocation;
354780
+ let toolKind = "other";
354781
+ let locations = [];
354782
+ if (subAgentTool) {
354783
+ try {
354784
+ subAgentInvocation = subAgentTool.build(event.args);
354785
+ toolKind = this.mapToolKind(subAgentTool.kind);
354786
+ locations = subAgentInvocation.toolLocations().map((loc) => ({
354787
+ path: loc.path,
354788
+ line: loc.line ?? null
354789
+ }));
354790
+ } catch (e2) {
354791
+ console.warn(`Failed to build subagent tool ${event.name}:`, e2);
354792
+ }
354793
+ }
354794
+ subAgentToolStates.set(event.callId, {
354795
+ tool: subAgentTool,
354796
+ invocation: subAgentInvocation,
354797
+ args: event.args
354798
+ });
354799
+ if (event.name === TodoWriteTool.Name) {
354800
+ return;
354801
+ }
354802
+ void this.sendUpdate({
354803
+ sessionUpdate: "tool_call",
354804
+ toolCallId: event.callId,
354805
+ status: "in_progress",
354806
+ title: event.description || event.name,
354807
+ content: [],
354808
+ locations,
354809
+ kind: toolKind,
354810
+ rawInput: event.args
354811
+ });
354812
+ }, "onToolCall");
354813
+ const onToolResult = /* @__PURE__ */ __name((...args) => {
354814
+ const event = args[0];
354815
+ if (abortSignal.aborted) return;
354816
+ const state = subAgentToolStates.get(event.callId);
354817
+ if (event.name === TodoWriteTool.Name) {
354818
+ let todos;
354819
+ if (event.resultDisplay) {
354820
+ try {
354821
+ const parsed = typeof event.resultDisplay === "string" ? JSON.parse(event.resultDisplay) : event.resultDisplay;
354822
+ if (typeof parsed === "object" && parsed !== null && "type" in parsed && parsed.type === "todo_list" && "todos" in parsed && Array.isArray(parsed.todos)) {
354823
+ todos = parsed.todos;
354824
+ }
354825
+ } catch {
354826
+ }
354827
+ }
354828
+ if (!todos && state?.args && Array.isArray(state.args["todos"])) {
354829
+ todos = state.args["todos"];
354830
+ }
354831
+ if (todos) {
354832
+ const planEntries = convertTodosToPlanEntries(todos);
354833
+ void this.sendUpdate({
354834
+ sessionUpdate: "plan",
354835
+ entries: planEntries
354836
+ });
354837
+ }
354838
+ subAgentToolStates.delete(event.callId);
354839
+ return;
354840
+ }
354841
+ let content = [];
354842
+ if (event.resultDisplay && state?.invocation) {
354843
+ if (typeof event.resultDisplay === "string") {
354844
+ content = [
354845
+ {
354846
+ type: "content",
354847
+ content: {
354848
+ type: "text",
354849
+ text: event.resultDisplay
354850
+ }
354851
+ }
354852
+ ];
354853
+ }
354854
+ }
354855
+ void this.sendUpdate({
354856
+ sessionUpdate: "tool_call_update",
354857
+ toolCallId: event.callId,
354858
+ status: event.success ? "completed" : "failed",
354859
+ content: content.length > 0 ? content : [],
354860
+ title: state?.invocation?.getDescription() ?? event.name,
354861
+ kind: state?.tool ? this.mapToolKind(state.tool.kind) : null,
354862
+ locations: state?.invocation?.toolLocations().map((loc) => ({
354863
+ path: loc.path,
354864
+ line: loc.line ?? null
354865
+ })) ?? null,
354866
+ rawInput: state?.args
354867
+ });
354868
+ subAgentToolStates.delete(event.callId);
354869
+ }, "onToolResult");
354870
+ const onToolWaitingApproval = /* @__PURE__ */ __name(async (...args) => {
354871
+ const event = args[0];
354872
+ if (abortSignal.aborted) return;
354873
+ const state = subAgentToolStates.get(event.callId);
354874
+ const content = [];
354875
+ if (event.confirmationDetails.type === "edit") {
354876
+ const editDetails = event.confirmationDetails;
354877
+ content.push({
354878
+ type: "diff",
354879
+ path: editDetails.fileName,
354880
+ oldText: editDetails.originalContent ?? "",
354881
+ newText: editDetails.newContent
354882
+ });
354883
+ }
354884
+ const fullConfirmationDetails = {
354885
+ ...event.confirmationDetails,
354886
+ onConfirm: /* @__PURE__ */ __name(async () => {
354887
+ }, "onConfirm")
354888
+ };
354889
+ const params = {
354890
+ sessionId: this.id,
354891
+ options: toPermissionOptions(fullConfirmationDetails),
354892
+ toolCall: {
354893
+ toolCallId: event.callId,
354894
+ status: "pending",
354895
+ title: event.description || event.name,
354896
+ content,
354897
+ locations: state?.invocation?.toolLocations().map((loc) => ({
354898
+ path: loc.path,
354899
+ line: loc.line ?? null
354900
+ })) ?? [],
354901
+ kind: state?.tool ? this.mapToolKind(state.tool.kind) : "other",
354902
+ rawInput: state?.args
354903
+ }
354904
+ };
354905
+ try {
354906
+ const output = await this.client.requestPermission(params);
354907
+ const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
354908
+ await event.respond(outcome);
354909
+ } catch (error) {
354910
+ console.error(
354911
+ `Permission request failed for subagent tool ${event.name}:`,
354912
+ error
354913
+ );
354914
+ await event.respond(ToolConfirmationOutcome.Cancel);
354915
+ }
354916
+ }, "onToolWaitingApproval");
354917
+ eventEmitter.on(SubAgentEventType.TOOL_CALL, onToolCall);
354918
+ eventEmitter.on(SubAgentEventType.TOOL_RESULT, onToolResult);
354919
+ eventEmitter.on(
354920
+ SubAgentEventType.TOOL_WAITING_APPROVAL,
354921
+ onToolWaitingApproval
354922
+ );
354923
+ cleanupFunctions2.push(() => {
354924
+ eventEmitter.off(SubAgentEventType.TOOL_CALL, onToolCall);
354925
+ eventEmitter.off(SubAgentEventType.TOOL_RESULT, onToolResult);
354926
+ eventEmitter.off(
354927
+ SubAgentEventType.TOOL_WAITING_APPROVAL,
354928
+ onToolWaitingApproval
354929
+ );
354930
+ });
354931
+ return cleanupFunctions2;
354932
+ }
354933
+ /**
354934
+ * Maps core Tool Kind enum to ACP ToolKind string literals.
354935
+ *
354936
+ * @param kind - The core Kind enum value
354937
+ * @returns The corresponding ACP ToolKind string literal
354938
+ */
354939
+ mapToolKind(kind) {
354940
+ const kindMap = {
354941
+ [Kind.Read]: "read",
354942
+ [Kind.Edit]: "edit",
354943
+ [Kind.Delete]: "delete",
354944
+ [Kind.Move]: "move",
354945
+ [Kind.Search]: "search",
354946
+ [Kind.Execute]: "execute",
354947
+ [Kind.Think]: "think",
354948
+ [Kind.Fetch]: "fetch",
354949
+ [Kind.Other]: "other"
354950
+ };
354951
+ return kindMap[kind] ?? "other";
354952
+ }
354732
354953
  async #resolvePrompt(message, abortSignal) {
354733
354954
  const FILE_URI_SCHEME = "file://";
354734
354955
  const embeddedContext = [];
@@ -355017,6 +355238,15 @@ Content from @${contextPart.uri}:
355017
355238
  }
355018
355239
  }
355019
355240
  };
355241
+ function convertTodosToPlanEntries(todos) {
355242
+ return todos.map((todo) => ({
355243
+ content: todo.content,
355244
+ priority: "medium",
355245
+ // Default priority since todos don't have priority
355246
+ status: todo.status
355247
+ }));
355248
+ }
355249
+ __name(convertTodosToPlanEntries, "convertTodosToPlanEntries");
355020
355250
  function toToolCallContent(toolResult) {
355021
355251
  if (toolResult.error?.message) {
355022
355252
  throw new Error(toolResult.error.message);
@@ -355027,19 +355257,6 @@ function toToolCallContent(toolResult) {
355027
355257
  type: "content",
355028
355258
  content: { type: "text", text: toolResult.returnDisplay }
355029
355259
  };
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
355260
  } else if ("type" in toolResult.returnDisplay && toolResult.returnDisplay.type === "plan_summary") {
355044
355261
  const planDisplay = toolResult.returnDisplay;
355045
355262
  const planText = `${planDisplay.message}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwen-code/qwen-code",
3
- "version": "0.1.5",
3
+ "version": "0.2.0-nightly.20251108.3c01c715",
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.1.5"
22
+ "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.2.0-nightly.20251108.3c01c715"
23
23
  },
24
24
  "dependencies": {
25
25
  "tiktoken": "^1.0.21"