ai-project-manage-cli 7.1.4 → 7.1.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/dist/index.js CHANGED
@@ -6342,16 +6342,16 @@ var EventSession = class {
6342
6342
  return;
6343
6343
  }
6344
6344
  if (formatedEvent.type === "tool_call") {
6345
- const existingIndex = this.events.findIndex(
6346
- (e) => e.type === "tool_call" && e.call_id === formatedEvent.call_id
6347
- );
6348
- if (existingIndex >= 0) {
6349
- const existingToolCall = this.events[existingIndex];
6350
- existingToolCall.args = formatedEvent.args;
6351
- existingToolCall.result = formatedEvent.result;
6352
- existingToolCall.status = formatedEvent.status;
6353
- this.markDirty(existingIndex);
6354
- return;
6345
+ const callId = typeof formatedEvent.call_id === "string" ? formatedEvent.call_id.trim() : "";
6346
+ if (callId) {
6347
+ const existingIndex = this.events.findIndex(
6348
+ (e) => e.type === "tool_call" && typeof e.call_id === "string" && e.call_id === callId
6349
+ );
6350
+ if (existingIndex >= 0) {
6351
+ mergeToolCallEvent(this.events[existingIndex], formatedEvent);
6352
+ this.markDirty(existingIndex);
6353
+ return;
6354
+ }
6355
6355
  }
6356
6356
  this.events.push(formatedEvent);
6357
6357
  this.markDirty(this.events.length - 1);
@@ -6413,15 +6413,18 @@ var EventSession = class {
6413
6413
  type: "thinking",
6414
6414
  content: event.text || event.content || ""
6415
6415
  };
6416
- case "tool_call":
6416
+ case "tool_call": {
6417
+ const raw = event;
6418
+ const callId = String(raw.call_id ?? raw.callId ?? "").trim();
6417
6419
  return {
6418
6420
  type: "tool_call",
6419
6421
  args: event.args,
6420
6422
  result: event.result,
6421
6423
  status: event.status,
6422
- call_id: event.call_id,
6424
+ call_id: callId,
6423
6425
  name: event.name
6424
6426
  };
6427
+ }
6425
6428
  case "task":
6426
6429
  return {
6427
6430
  type: "task",
@@ -6486,6 +6489,24 @@ var EventSession = class {
6486
6489
  return this.events.map((event) => formatLogEvent(event.type, event)).join("\n");
6487
6490
  }
6488
6491
  };
6492
+ function mergeToolCallEvent(existing, incoming) {
6493
+ if (incoming.name) {
6494
+ existing.name = incoming.name;
6495
+ }
6496
+ if (incoming.status) {
6497
+ existing.status = incoming.status;
6498
+ }
6499
+ if (incoming.args != null && typeof incoming.args === "object" && !Array.isArray(incoming.args) && Object.keys(incoming.args).length > 0) {
6500
+ existing.args = { ...existing.args ?? {}, ...incoming.args };
6501
+ }
6502
+ if (incoming.result != null) {
6503
+ if (typeof incoming.result === "object" && !Array.isArray(incoming.result) && typeof existing.result === "object" && existing.result != null && !Array.isArray(existing.result)) {
6504
+ existing.result = { ...existing.result, ...incoming.result };
6505
+ } else {
6506
+ existing.result = incoming.result;
6507
+ }
6508
+ }
6509
+ }
6489
6510
  function formatLogEvent(type, event) {
6490
6511
  if (type === "input") {
6491
6512
  return `## \u7528\u6237\u8F93\u5165
@@ -327,16 +327,16 @@ var EventSession = class {
327
327
  return;
328
328
  }
329
329
  if (formatedEvent.type === "tool_call") {
330
- const existingIndex = this.events.findIndex(
331
- (e) => e.type === "tool_call" && e.call_id === formatedEvent.call_id
332
- );
333
- if (existingIndex >= 0) {
334
- const existingToolCall = this.events[existingIndex];
335
- existingToolCall.args = formatedEvent.args;
336
- existingToolCall.result = formatedEvent.result;
337
- existingToolCall.status = formatedEvent.status;
338
- this.markDirty(existingIndex);
339
- return;
330
+ const callId = typeof formatedEvent.call_id === "string" ? formatedEvent.call_id.trim() : "";
331
+ if (callId) {
332
+ const existingIndex = this.events.findIndex(
333
+ (e) => e.type === "tool_call" && typeof e.call_id === "string" && e.call_id === callId
334
+ );
335
+ if (existingIndex >= 0) {
336
+ mergeToolCallEvent(this.events[existingIndex], formatedEvent);
337
+ this.markDirty(existingIndex);
338
+ return;
339
+ }
340
340
  }
341
341
  this.events.push(formatedEvent);
342
342
  this.markDirty(this.events.length - 1);
@@ -398,15 +398,18 @@ var EventSession = class {
398
398
  type: "thinking",
399
399
  content: event.text || event.content || ""
400
400
  };
401
- case "tool_call":
401
+ case "tool_call": {
402
+ const raw = event;
403
+ const callId = String(raw.call_id ?? raw.callId ?? "").trim();
402
404
  return {
403
405
  type: "tool_call",
404
406
  args: event.args,
405
407
  result: event.result,
406
408
  status: event.status,
407
- call_id: event.call_id,
409
+ call_id: callId,
408
410
  name: event.name
409
411
  };
412
+ }
410
413
  case "task":
411
414
  return {
412
415
  type: "task",
@@ -471,6 +474,24 @@ var EventSession = class {
471
474
  return this.events.map((event) => formatLogEvent(event.type, event)).join("\n");
472
475
  }
473
476
  };
477
+ function mergeToolCallEvent(existing, incoming) {
478
+ if (incoming.name) {
479
+ existing.name = incoming.name;
480
+ }
481
+ if (incoming.status) {
482
+ existing.status = incoming.status;
483
+ }
484
+ if (incoming.args != null && typeof incoming.args === "object" && !Array.isArray(incoming.args) && Object.keys(incoming.args).length > 0) {
485
+ existing.args = { ...existing.args ?? {}, ...incoming.args };
486
+ }
487
+ if (incoming.result != null) {
488
+ if (typeof incoming.result === "object" && !Array.isArray(incoming.result) && typeof existing.result === "object" && existing.result != null && !Array.isArray(existing.result)) {
489
+ existing.result = { ...existing.result, ...incoming.result };
490
+ } else {
491
+ existing.result = incoming.result;
492
+ }
493
+ }
494
+ }
474
495
  function formatLogEvent(type, event) {
475
496
  if (type === "input") {
476
497
  return `## \u7528\u6237\u8F93\u5165
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "7.1.4",
3
+ "version": "7.1.5",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,