ai-project-manage-cli 8.1.13 → 8.1.14

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
@@ -133,6 +133,11 @@ var requestConfig = {
133
133
  method: "PUT",
134
134
  path: "/cli/webide/transition-prep-events"
135
135
  }),
136
+ /** 「继续」开跑后挂新 runId */
137
+ webideAttachContinueRun: defineEndpoint({
138
+ method: "PUT",
139
+ path: "/cli/webide/continue-run"
140
+ }),
136
141
  webideUpsertMessageLog: defineEndpoint({
137
142
  method: "PUT",
138
143
  path: "/cli/webide/message-logs"
@@ -44,6 +44,11 @@ var requestConfig = {
44
44
  method: "PUT",
45
45
  path: "/cli/webide/transition-prep-events"
46
46
  }),
47
+ /** 「继续」开跑后挂新 runId */
48
+ webideAttachContinueRun: defineEndpoint({
49
+ method: "PUT",
50
+ path: "/cli/webide/continue-run"
51
+ }),
47
52
  webideUpsertMessageLog: defineEndpoint({
48
53
  method: "PUT",
49
54
  path: "/cli/webide/message-logs"
@@ -2610,6 +2615,12 @@ function bytesToBase64(data) {
2610
2615
  function base64ToBytes(dataBase64) {
2611
2616
  return new Uint8Array(Buffer.from(dataBase64, "base64"));
2612
2617
  }
2618
+ var pendingCheckpointUploads = /* @__PURE__ */ new Map();
2619
+ async function flushPendingCheckpointUploads() {
2620
+ const pending2 = [...pendingCheckpointUploads.values()];
2621
+ if (pending2.length === 0) return;
2622
+ await Promise.allSettled(pending2);
2623
+ }
2613
2624
  function createRemoteLocalAgentStore(cfg2) {
2614
2625
  const api = createApmApiClient(cfg2);
2615
2626
  let minioCache = null;
@@ -2666,7 +2677,7 @@ function createRemoteLocalAgentStore(cfg2) {
2666
2677
  });
2667
2678
  return fromApiRun(row);
2668
2679
  }
2669
- async function putCheckpoint(input) {
2680
+ async function uploadCheckpointRemote(input) {
2670
2681
  const createdAt = Date.now();
2671
2682
  if (input.data.byteLength > INLINE_CHECKPOINT_MAX_BYTES) {
2672
2683
  const { client, bucket } = await getMinio();
@@ -2681,7 +2692,6 @@ function createRemoteLocalAgentStore(cfg2) {
2681
2692
  byteSize: input.data.byteLength,
2682
2693
  createdAt
2683
2694
  });
2684
- rememberCheckpoint(input.agentId, input.blobId, input.data);
2685
2695
  return;
2686
2696
  }
2687
2697
  await api.cli.cursorStorePutCheckpoint({
@@ -2691,7 +2701,30 @@ function createRemoteLocalAgentStore(cfg2) {
2691
2701
  byteSize: input.data.byteLength,
2692
2702
  createdAt
2693
2703
  });
2694
- rememberCheckpoint(input.agentId, input.blobId, input.data);
2704
+ }
2705
+ async function putCheckpoint(input) {
2706
+ const data = new Uint8Array(input.data);
2707
+ rememberCheckpoint(input.agentId, input.blobId, data);
2708
+ const key = checkpointCacheKey(input.agentId, input.blobId);
2709
+ if (pendingCheckpointUploads.has(key)) return;
2710
+ const startedAt = Date.now();
2711
+ const uploadPromise = uploadCheckpointRemote({
2712
+ agentId: input.agentId,
2713
+ blobId: input.blobId,
2714
+ data
2715
+ }).then(() => {
2716
+ console.log(
2717
+ `[apm] checkpoint \u8FDC\u7A0B\u4E0A\u4F20\u5B8C\u6210 agentId=${input.agentId} blobId=${input.blobId} bytes=${data.byteLength} ms=${Date.now() - startedAt}`
2718
+ );
2719
+ }).catch((err) => {
2720
+ console.warn(
2721
+ `[apm] checkpoint \u8FDC\u7A0B\u4E0A\u4F20\u5931\u8D25\uFF08\u672C\u5730\u5DF2\u7F13\u5B58\uFF09 agentId=${input.agentId} blobId=${input.blobId}:`,
2722
+ err instanceof Error ? err.message : err
2723
+ );
2724
+ }).finally(() => {
2725
+ pendingCheckpointUploads.delete(key);
2726
+ });
2727
+ pendingCheckpointUploads.set(key, uploadPromise);
2695
2728
  }
2696
2729
  async function readCheckpointBytes(input) {
2697
2730
  const memKey = checkpointCacheKey(input.agentId, input.blobId);
@@ -4281,6 +4314,7 @@ import { resolve as resolve7 } from "node:path";
4281
4314
  async function purgeCursorAgentStoreForAgent(cfg2, agentId) {
4282
4315
  const trimmedAgentId = agentId.trim();
4283
4316
  if (!trimmedAgentId) return false;
4317
+ await flushPendingCheckpointUploads();
4284
4318
  const store = createRemoteLocalAgentStore(cfg2);
4285
4319
  const runIds = [];
4286
4320
  let cursor;
@@ -4934,26 +4968,36 @@ function completeActionForInbound(action) {
4934
4968
  switch (action) {
4935
4969
  case "request-assessment":
4936
4970
  case "confirm-assumptions":
4971
+ case "start-assessment":
4972
+ case "continue-assessment":
4937
4973
  return "complete-assessment";
4938
4974
  case "request-design":
4939
4975
  case "request-revise-design":
4976
+ case "start-design":
4940
4977
  return "complete-design";
4941
4978
  case "request-write-plan":
4942
4979
  case "request-revise-plan":
4980
+ case "start-write-plan":
4943
4981
  return "complete-write-plan";
4944
4982
  case "request-develop":
4945
4983
  case "skip-plan":
4984
+ case "start-develop":
4946
4985
  return "complete-develop";
4947
4986
  case "request-start-project":
4987
+ case "start-project":
4948
4988
  return "complete-project";
4949
4989
  case "request-execute-sql":
4990
+ case "start-execute-sql":
4950
4991
  return "complete-execute-sql";
4951
4992
  case "request-bugfix":
4993
+ case "start-bugfix":
4952
4994
  return "complete-bugfix";
4953
4995
  case "request-organize-code":
4954
4996
  case "request-patch":
4997
+ case "start-organize-code":
4955
4998
  return "complete-organize-code";
4956
4999
  case "request-accept":
5000
+ case "start-accept":
4957
5001
  return "complete-accept";
4958
5002
  default:
4959
5003
  return null;
@@ -4964,6 +5008,13 @@ async function webIdeRunAction(cfg2, taskId, action, params) {
4964
5008
  await api.cli.webideRunAction({ taskId, action, params });
4965
5009
  console.log(`[apm] webide runAction ok action=${action} taskId=${taskId}`);
4966
5010
  }
5011
+ async function webIdeAttachContinueRun(cfg2, taskId, runId) {
5012
+ const api = createApmApiClient(cfg2);
5013
+ await api.cli.webideAttachContinueRun({ taskId, runId });
5014
+ console.log(
5015
+ `[apm] webide attachContinueRun ok runId=${runId} taskId=${taskId}`
5016
+ );
5017
+ }
4967
5018
  async function webIdeSyncTransitionPrepEvents(cfg2, taskId, startAction, prepEvents) {
4968
5019
  try {
4969
5020
  const api = createApmApiClient(cfg2);
@@ -5036,8 +5087,11 @@ async function handleWebIdeInboundMessage(cfg2, msg2, signal) {
5036
5087
  const messageId = msg2.messageId;
5037
5088
  const taskId = msg2.taskId;
5038
5089
  const branchCacheKey = taskId;
5090
+ const continuePayload = msg2.action === "continue" ? parseWebIdePromptPayload(msg2.content) : null;
5091
+ const previousAction = typeof continuePayload?.previousAction === "string" ? continuePayload.previousAction.trim() : "";
5092
+ const effectiveAction = msg2.action === "continue" && previousAction ? previousAction : msg2.action;
5039
5093
  console.log(
5040
- `[apm] webide-message action=${msg2.action} taskId=${taskId} messageId=${messageId}`
5094
+ `[apm] webide-message action=${msg2.action}${previousAction ? ` previousAction=${previousAction}` : ""} taskId=${taskId} messageId=${messageId}`
5041
5095
  );
5042
5096
  await updateStatus2(cfg2, messageId, "TYPING");
5043
5097
  syncLocalTaskStatus(workdir, taskId, msg2, "TYPING");
@@ -5140,7 +5194,7 @@ async function handleWebIdeInboundMessage(cfg2, msg2, signal) {
5140
5194
  eventSession.addCliStep("\u51C6\u5907\u7279\u6027\u5206\u652F", "\u5DF2\u7F13\u5B58\uFF0C\u8DF3\u8FC7", "skip");
5141
5195
  await syncPrepLog();
5142
5196
  }
5143
- if (shouldEnsureWebIdePullRequests(msg2.action)) {
5197
+ if (shouldEnsureWebIdePullRequests(effectiveAction)) {
5144
5198
  if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
5145
5199
  await runPrepStep(
5146
5200
  "\u9A8C\u6536\u524D\u63A8\u9001",
@@ -5246,8 +5300,8 @@ async function handleWebIdeInboundMessage(cfg2, msg2, signal) {
5246
5300
  "running"
5247
5301
  );
5248
5302
  await syncPrepLog();
5249
- const startLocalServices = isStartLocalServicesAction(msg2.action);
5250
- const designAction = isDesignAction(msg2.action);
5303
+ const startLocalServices = isStartLocalServicesAction(effectiveAction);
5304
+ const designAction = isDesignAction(effectiveAction);
5251
5305
  const useNewAgent = msg2.useNewAgent === true;
5252
5306
  const toolNames = Array.isArray(msg2.tools) ? msg2.tools.map((t) => String(t).trim()).filter(Boolean) : [];
5253
5307
  if (useNewAgent && !startLocalServices) {
@@ -5258,7 +5312,7 @@ async function handleWebIdeInboundMessage(cfg2, msg2, signal) {
5258
5312
  }
5259
5313
  }
5260
5314
  const savedAgentId = startLocalServices || useNewAgent ? void 0 : designAction ? loadWebIdeDesignAgentId(workdir, taskId) : loadWebIdeAgentId(workdir, taskId);
5261
- const promptPayload = toolNames.includes("MysqlExecute") ? parseWebIdePromptPayload(msg2.content) : null;
5315
+ const promptPayload = toolNames.includes("MysqlExecute") ? continuePayload ?? parseWebIdePromptPayload(msg2.content) : null;
5262
5316
  const sqlExecutionId = toolNames.includes("MysqlExecute") && typeof promptPayload?.executionId === "string" ? promptPayload.executionId.trim() : void 0;
5263
5317
  if (toolNames.includes("MysqlExecute") && !sqlExecutionId) {
5264
5318
  console.warn(
@@ -5348,6 +5402,15 @@ ${assumptionAnswersText}` : msg2.content,
5348
5402
  eventSession.getCliSteps()
5349
5403
  );
5350
5404
  await webIdeRunAction(cfg2, taskId, startAction, { runId });
5405
+ } else if (msg2.action === "continue") {
5406
+ try {
5407
+ await webIdeAttachContinueRun(cfg2, taskId, runId);
5408
+ } catch (err) {
5409
+ console.warn(
5410
+ "[apm] attach continue run failed:",
5411
+ err instanceof Error ? err.message : err
5412
+ );
5413
+ }
5351
5414
  }
5352
5415
  }
5353
5416
  }
@@ -5374,7 +5437,7 @@ ${assumptionAnswersText}` : msg2.content,
5374
5437
  detail,
5375
5438
  tokenUsage
5376
5439
  );
5377
- if (sqlExecutionId && msg2.action !== "request-bugfix") {
5440
+ if (sqlExecutionId && effectiveAction !== "request-bugfix") {
5378
5441
  try {
5379
5442
  await api.cli.webideFinalizeSqlExecution({
5380
5443
  executionId: sqlExecutionId,
@@ -5399,7 +5462,7 @@ ${assumptionAnswersText}` : msg2.content,
5399
5462
  "\u5DF2\u53D6\u6D88",
5400
5463
  tokenUsage
5401
5464
  );
5402
- if (sqlExecutionId && msg2.action !== "request-bugfix") {
5465
+ if (sqlExecutionId && effectiveAction !== "request-bugfix") {
5403
5466
  try {
5404
5467
  await api.cli.webideFinalizeSqlExecution({
5405
5468
  executionId: sqlExecutionId,
@@ -5426,7 +5489,7 @@ ${assumptionAnswersText}` : msg2.content,
5426
5489
  id: messageId,
5427
5490
  content: fallback
5428
5491
  });
5429
- if ((msg2.action === "write-plan" || msg2.action === "revise-plan") && outcome.createPlan && outcome.createPlan.trim()) {
5492
+ if ((effectiveAction === "write-plan" || effectiveAction === "revise-plan" || effectiveAction === "request-write-plan" || effectiveAction === "request-revise-plan" || effectiveAction === "start-write-plan") && outcome.createPlan && outcome.createPlan.trim()) {
5430
5493
  try {
5431
5494
  await api.cli.webideUpsertPlan({
5432
5495
  taskId,
@@ -5434,12 +5497,12 @@ ${assumptionAnswersText}` : msg2.content,
5434
5497
  });
5435
5498
  } catch (err) {
5436
5499
  console.warn(
5437
- `[apm] ${msg2.action} \u8865\u5199\u8BA1\u5212\u5931\u8D25:`,
5500
+ `[apm] ${effectiveAction} \u8865\u5199\u8BA1\u5212\u5931\u8D25:`,
5438
5501
  err instanceof Error ? err.message : err
5439
5502
  );
5440
5503
  }
5441
5504
  }
5442
- if (isDesignAction(msg2.action)) {
5505
+ if (isDesignAction(effectiveAction)) {
5443
5506
  if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
5444
5507
  try {
5445
5508
  const uploaded = await uploadWebIdeDesignArtifacts(
@@ -5448,7 +5511,7 @@ ${assumptionAnswersText}` : msg2.content,
5448
5511
  workdir
5449
5512
  );
5450
5513
  console.log(
5451
- `[apm] webide \u8BBE\u8BA1\u4EA7\u7269\u4E0A\u4F20 action=${msg2.action} uploaded=${uploaded.uploaded} skipped=${uploaded.skipped} files=${uploaded.artifacts.map((a) => a.name).join(",")}`
5514
+ `[apm] webide \u8BBE\u8BA1\u4EA7\u7269\u4E0A\u4F20 action=${effectiveAction} uploaded=${uploaded.uploaded} skipped=${uploaded.skipped} files=${uploaded.artifacts.map((a) => a.name).join(",")}`
5452
5515
  );
5453
5516
  } catch (err) {
5454
5517
  const detail = err instanceof Error ? err.message : String(err);
@@ -5463,27 +5526,27 @@ ${assumptionAnswersText}` : msg2.content,
5463
5526
  return;
5464
5527
  }
5465
5528
  }
5466
- if (shouldCommitAfterWebIdeMessage(msg2.action)) {
5529
+ if (shouldCommitAfterWebIdeMessage(effectiveAction)) {
5467
5530
  if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
5468
5531
  const committed = await commitWorkspaceReposIfDirty(
5469
5532
  workdir,
5470
- `chore(webide): sync after ${msg2.action} (${taskId})`
5533
+ `chore(webide): sync after ${effectiveAction} (${taskId})`
5471
5534
  );
5472
5535
  console.log(
5473
- `[apm] webide \u515C\u5E95 commit action=${msg2.action} repos=${committed}`
5536
+ `[apm] webide \u515C\u5E95 commit action=${effectiveAction} repos=${committed}`
5474
5537
  );
5475
5538
  if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
5476
5539
  const pushed = await pushWorkspaceRepos(workdir);
5477
5540
  console.log(
5478
- `[apm] webide \u81EA\u52A8 push action=${msg2.action} repos=${pushed}`
5541
+ `[apm] webide \u81EA\u52A8 push action=${effectiveAction} repos=${pushed}`
5479
5542
  );
5480
5543
  }
5481
- if (shouldEnsureWebIdePullRequestsAfterAgent(msg2.action)) {
5544
+ if (shouldEnsureWebIdePullRequestsAfterAgent(effectiveAction)) {
5482
5545
  if (signal.aborted) throw new Error("\u4EFB\u52A1\u5DF2\u53D6\u6D88");
5483
- if (!shouldCommitAfterWebIdeMessage(msg2.action)) {
5546
+ if (!shouldCommitAfterWebIdeMessage(effectiveAction)) {
5484
5547
  const pushed = await pushWorkspaceRepos(workdir);
5485
5548
  console.log(
5486
- `[apm] webide create-pr \u524D push action=${msg2.action} repos=${pushed}`
5549
+ `[apm] webide create-pr \u524D push action=${effectiveAction} repos=${pushed}`
5487
5550
  );
5488
5551
  }
5489
5552
  const prResult = await ensureWebIdePullRequests(cfg2, taskId, workdir);
@@ -5537,20 +5600,20 @@ ${assumptionAnswersText}` : msg2.content,
5537
5600
  null,
5538
5601
  tokenUsage
5539
5602
  );
5540
- const completeAction = completeActionForInbound(msg2.action);
5603
+ const completeAction = completeActionForInbound(effectiveAction);
5541
5604
  if (completeAction && !pausedForAssumptions) {
5542
5605
  await webIdeRunAction(cfg2, taskId, completeAction);
5543
5606
  } else if (pausedForAssumptions) {
5544
5607
  console.log(
5545
- `[apm] \u672C\u8F6E\u505C\u5728\u5F85\u786E\u8BA4\u5047\u8BBE\uFF0C\u8DF3\u8FC7 complete action=${msg2.action} taskId=${taskId}`
5608
+ `[apm] \u672C\u8F6E\u505C\u5728\u5F85\u786E\u8BA4\u5047\u8BBE\uFF0C\u8DF3\u8FC7 complete action=${effectiveAction} taskId=${taskId}`
5546
5609
  );
5547
5610
  }
5548
5611
  await updateStatus2(cfg2, messageId, "SUCCESS");
5549
5612
  syncLocalTaskStatus(workdir, taskId, msg2, "SUCCESS");
5550
5613
  console.log(
5551
- `[apm] webide-message \u5B8C\u6210 action=${msg2.action} messageId=${messageId} agentId=${outcome.agentId}`
5614
+ `[apm] webide-message \u5B8C\u6210 action=${msg2.action}${previousAction ? ` previousAction=${previousAction}` : ""} messageId=${messageId} agentId=${outcome.agentId}`
5552
5615
  );
5553
- if (msg2.action === "request-accept") {
5616
+ if (effectiveAction === "request-accept" || effectiveAction === "start-accept") {
5554
5617
  try {
5555
5618
  await cleanWebIdeWorkspaceCache(taskId, workdir, cfg2);
5556
5619
  } catch (err) {
@@ -5577,7 +5640,7 @@ ${assumptionAnswersText}` : msg2.content,
5577
5640
  statusErr instanceof Error ? statusErr.message : statusErr
5578
5641
  );
5579
5642
  }
5580
- const completeAction = completeActionForInbound(msg2.action);
5643
+ const completeAction = completeActionForInbound(effectiveAction);
5581
5644
  if (completeAction === "complete-assessment" && !pausedForAssumptions) {
5582
5645
  try {
5583
5646
  await webIdeRunAction(cfg2, taskId, completeAction, { force: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "8.1.13",
3
+ "version": "8.1.14",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,