@keyou007/agent-bot 0.1.19-alpha.0 → 0.1.19-alpha.1

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 (42) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +3 -0
  3. package/README.zh.md +3 -0
  4. package/dist/cli/controlProtocol.js.map +1 -1
  5. package/dist/cli/help.js +2 -0
  6. package/dist/cli/help.js.map +1 -1
  7. package/dist/cli.js +20 -0
  8. package/dist/cli.js.map +1 -1
  9. package/dist/codex/CodexProcessManager.js +48 -0
  10. package/dist/codex/CodexProcessManager.js.map +1 -1
  11. package/dist/codex/CodexRuntime.js +35 -2
  12. package/dist/codex/CodexRuntime.js.map +1 -1
  13. package/dist/commands/CommandRouter.js +5 -0
  14. package/dist/commands/CommandRouter.js.map +1 -1
  15. package/dist/feishu/CardRenderer.js +83 -0
  16. package/dist/feishu/CardRenderer.js.map +1 -1
  17. package/dist/feishu/MergedForwardMessage.js +6 -1
  18. package/dist/feishu/MergedForwardMessage.js.map +1 -1
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/proxy/ProxySessionController.js +449 -4
  22. package/dist/proxy/ProxySessionController.js.map +1 -1
  23. package/dist/state/StateStore.js +10 -0
  24. package/dist/state/StateStore.js.map +1 -1
  25. package/docs/technical-reference.md +1 -1
  26. package/docs/technical-reference.zh.md +1 -1
  27. package/npm-shrinkwrap.json +2 -2
  28. package/package.json +1 -1
  29. package/skills/agent-bot/SKILL.md +3 -0
  30. package/src/cli/controlProtocol.ts +8 -0
  31. package/src/cli/help.ts +2 -0
  32. package/src/cli.ts +33 -0
  33. package/src/codex/CodexProcessManager.ts +43 -0
  34. package/src/codex/CodexRuntime.ts +33 -2
  35. package/src/commands/CommandRouter.ts +4 -0
  36. package/src/commands/commandTypes.ts +1 -0
  37. package/src/feishu/CardRenderer.ts +96 -0
  38. package/src/feishu/MergedForwardMessage.ts +5 -1
  39. package/src/index.ts +2 -0
  40. package/src/proxy/ProxySessionController.ts +544 -6
  41. package/src/runtime/types.ts +6 -0
  42. package/src/state/StateStore.ts +11 -0
@@ -275,6 +275,17 @@ export interface ThreadWriterConflictCardView {
275
275
  };
276
276
  }
277
277
 
278
+ export interface AppServerReleaseCardView {
279
+ status: "waiting" | "releasing" | "released" | "cancelled" | "failed";
280
+ contextKey: string;
281
+ scheduleId: number;
282
+ agentName: string;
283
+ blockingTaskCount?: number;
284
+ releaseInSeconds?: number;
285
+ forced?: boolean;
286
+ error?: string;
287
+ }
288
+
278
289
  export class CardRenderer {
279
290
  private readonly thinkingCardLayout: ThinkingCardLayout;
280
291
 
@@ -371,6 +382,91 @@ export class CardRenderer {
371
382
  );
372
383
  }
373
384
 
385
+ renderAppServerRelease(view: AppServerReleaseCardView): Record<string, unknown> {
386
+ const agent = inlineCode(view.agentName);
387
+ if (view.status === "released") {
388
+ return sectionCard("任务已释放", [markdown([
389
+ `**Agent**:${agent}`,
390
+ view.forced ? "执行中的任务已中断。" : undefined,
391
+ "> 请在 Codex Desktop 点击 **Retry**。",
392
+ ].filter((line): line is string => Boolean(line)).join("\n"))], "green");
393
+ }
394
+ if (view.status === "cancelled") {
395
+ return sectionCard("已取消释放", [markdown(`**Agent**:${agent}\n> Agent Bot 将继续保持当前任务连接。`)], "grey");
396
+ }
397
+ if (view.status === "failed") {
398
+ return sectionCard("释放失败", [markdown([
399
+ `**Agent**:${agent}`,
400
+ view.error ? truncateText(view.error, 500) : "无法释放 App Server。",
401
+ ].join("\n"))], "red");
402
+ }
403
+ if (view.status === "releasing") {
404
+ return sectionCard("正在释放", [markdown(`**Agent**:${agent}\n正在停止 Agent Bot 的 App Server。`)], "blue");
405
+ }
406
+
407
+ const blockingTaskCount = Math.max(0, view.blockingTaskCount ?? 0);
408
+ const releaseInSeconds = Math.max(1, view.releaseInSeconds ?? 1);
409
+ return sectionCard("等待释放", [
410
+ markdown([
411
+ `**Agent**:${agent}`,
412
+ blockingTaskCount > 0
413
+ ? `**等待任务**:${blockingTaskCount}`
414
+ : `**自动释放**:${releaseInSeconds} 秒后`,
415
+ blockingTaskCount > 0
416
+ ? "> 任务结束后自动释放;立即释放会中断执行。"
417
+ : "> 可立即释放或取消。",
418
+ ].join("\n")),
419
+ {
420
+ tag: "column_set",
421
+ flex_mode: "none",
422
+ horizontal_spacing: "8px",
423
+ vertical_align: "center",
424
+ columns: [
425
+ {
426
+ tag: "column",
427
+ width: "auto",
428
+ vertical_align: "center",
429
+ elements: [{
430
+ tag: "button",
431
+ text: { tag: "plain_text", content: "Release Now" },
432
+ type: "danger",
433
+ size: "small",
434
+ behaviors: [{
435
+ type: "callback",
436
+ value: {
437
+ action: "app_server_release_now",
438
+ contextKey: view.contextKey,
439
+ scheduleId: view.scheduleId,
440
+ agentName: view.agentName,
441
+ },
442
+ }],
443
+ }],
444
+ },
445
+ {
446
+ tag: "column",
447
+ width: "auto",
448
+ vertical_align: "center",
449
+ elements: [{
450
+ tag: "button",
451
+ text: { tag: "plain_text", content: "Cancel" },
452
+ type: "default",
453
+ size: "small",
454
+ behaviors: [{
455
+ type: "callback",
456
+ value: {
457
+ action: "app_server_release_cancel",
458
+ contextKey: view.contextKey,
459
+ scheduleId: view.scheduleId,
460
+ agentName: view.agentName,
461
+ },
462
+ }],
463
+ }],
464
+ },
465
+ ],
466
+ },
467
+ ], "orange");
468
+ }
469
+
374
470
  renderShellCommandCard(view: ShellCommandCardView): Record<string, unknown> {
375
471
  const rawOutput = normalizeTerminalOutput(view.output).trimEnd();
376
472
  const displayOutput = truncateMiddle(
@@ -273,8 +273,12 @@ function renderPost(
273
273
  for (const rawElement of row) {
274
274
  if (!isRecord(rawElement)) continue;
275
275
  const tag = textValue(rawElement.tag);
276
- if (tag === "text" || tag === "a") {
276
+ if (tag === "text") {
277
277
  rowText += textValue(rawElement.text);
278
+ } else if (tag === "a") {
279
+ const text = textValue(rawElement.text);
280
+ const href = textValue(rawElement.href);
281
+ rowText += href && href !== text ? `${text || href} (${href})` : text || href;
278
282
  } else if (tag === "at") {
279
283
  rowText += renderMention(rawElement, mentions);
280
284
  } else if (tag === "img") {
package/src/index.ts CHANGED
@@ -432,6 +432,8 @@ async function handleControlRequest(request: ControlRequest): Promise<ControlRes
432
432
  return { ok: true, data: await controller.controlGetTaskStatus(request.localSessionId) };
433
433
  case "task_stop":
434
434
  return { ok: true, message: await controller.controlStopTask(request.localSessionId) };
435
+ case "task_release":
436
+ return { ok: true, data: await controller.controlReleaseTask(request.localSessionId) };
435
437
  case "task_archive":
436
438
  return { ok: true, data: await controller.controlArchiveTask(request.localSessionId) };
437
439
  case "task_dismiss":