@keyou007/agent-bot 0.1.27-alpha.3 → 0.1.27-alpha.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.
Files changed (159) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +102 -18
  3. package/README.zh.md +102 -18
  4. package/assets/agent-bot.ico +0 -0
  5. package/assets/roboto-mono-OFL.txt +93 -0
  6. package/assets/roboto-mono-latin.woff2 +0 -0
  7. package/assets/workspace-drafts.js +88 -0
  8. package/assets/workspace-sessions.js +2676 -243
  9. package/assets/workspace.css +553 -44
  10. package/assets/workspace.js +3429 -327
  11. package/dist/cli/SelfUpdateObserver.js +124 -0
  12. package/dist/cli/SelfUpdateObserver.js.map +1 -0
  13. package/dist/cli/SelfUpdateRunner.js +267 -70
  14. package/dist/cli/SelfUpdateRunner.js.map +1 -1
  15. package/dist/cli/SelfUpdater.js +54 -15
  16. package/dist/cli/SelfUpdater.js.map +1 -1
  17. package/dist/cli/controlProtocol.js.map +1 -1
  18. package/dist/cli/help.js +6 -0
  19. package/dist/cli/help.js.map +1 -1
  20. package/dist/cli.js +85 -6
  21. package/dist/cli.js.map +1 -1
  22. package/dist/codex/CodexEventMapper.js +29 -5
  23. package/dist/codex/CodexEventMapper.js.map +1 -1
  24. package/dist/codex/CodexRuntime.js +3 -0
  25. package/dist/codex/CodexRuntime.js.map +1 -1
  26. package/dist/feishu/CardRenderer.js +45 -13
  27. package/dist/feishu/CardRenderer.js.map +1 -1
  28. package/dist/feishu/ConsoleFeishuClient.js +4 -0
  29. package/dist/feishu/ConsoleFeishuClient.js.map +1 -1
  30. package/dist/feishu/FeishuMarkdown.js +2 -14
  31. package/dist/feishu/FeishuMarkdown.js.map +1 -1
  32. package/dist/feishu/FeishuMessageClient.js +9 -0
  33. package/dist/feishu/FeishuMessageClient.js.map +1 -1
  34. package/dist/feishu/FeishuTurnPresenter.js +51 -22
  35. package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
  36. package/dist/index.js +47 -12
  37. package/dist/index.js.map +1 -1
  38. package/dist/local-files/DiagramPreview.js +11 -6
  39. package/dist/local-files/DiagramPreview.js.map +1 -1
  40. package/dist/local-files/GitDiffPreview.js +106 -14
  41. package/dist/local-files/GitDiffPreview.js.map +1 -1
  42. package/dist/local-files/LiveMarkup.js +104 -0
  43. package/dist/local-files/LiveMarkup.js.map +1 -0
  44. package/dist/local-files/LocalFileViewerServer.js +141 -122
  45. package/dist/local-files/LocalFileViewerServer.js.map +1 -1
  46. package/dist/local-files/MarkdownExport.js +54 -0
  47. package/dist/local-files/MarkdownExport.js.map +1 -0
  48. package/dist/local-files/PreviewCodeFont.js +11 -0
  49. package/dist/local-files/PreviewCodeFont.js.map +1 -0
  50. package/dist/local-files/PreviewSyntaxHighlight.js +73 -0
  51. package/dist/local-files/PreviewSyntaxHighlight.js.map +1 -1
  52. package/dist/local-files/ToolCommandDisplay.js +111 -0
  53. package/dist/local-files/ToolCommandDisplay.js.map +1 -0
  54. package/dist/local-files/TurnPreviewPage.js +53 -276
  55. package/dist/local-files/TurnPreviewPage.js.map +1 -1
  56. package/dist/local-files/WorkspaceFileEvents.js +206 -0
  57. package/dist/local-files/WorkspaceFileEvents.js.map +1 -0
  58. package/dist/local-files/WorkspaceFiles.js +79 -3
  59. package/dist/local-files/WorkspaceFiles.js.map +1 -1
  60. package/dist/local-files/WorkspaceImages.js +43 -0
  61. package/dist/local-files/WorkspaceImages.js.map +1 -0
  62. package/dist/local-files/WorkspacePage.js +24 -6
  63. package/dist/local-files/WorkspacePage.js.map +1 -1
  64. package/dist/local-files/WorkspaceSessions.js +1153 -104
  65. package/dist/local-files/WorkspaceSessions.js.map +1 -1
  66. package/dist/local-files/WorkspaceTimeline.js +129 -0
  67. package/dist/local-files/WorkspaceTimeline.js.map +1 -0
  68. package/dist/presentation/OutboundRouter.js +15 -6
  69. package/dist/presentation/OutboundRouter.js.map +1 -1
  70. package/dist/presentation/TurnStateReducer.js +31 -22
  71. package/dist/presentation/TurnStateReducer.js.map +1 -1
  72. package/dist/proxy/ProxySessionController.js +335 -113
  73. package/dist/proxy/ProxySessionController.js.map +1 -1
  74. package/dist/proxy/TaskMetadata.js +86 -0
  75. package/dist/proxy/TaskMetadata.js.map +1 -0
  76. package/dist/scheduling/ScheduleCards.js +10 -4
  77. package/dist/scheduling/ScheduleCards.js.map +1 -1
  78. package/dist/scheduling/ScheduleCommand.js +4 -0
  79. package/dist/scheduling/ScheduleCommand.js.map +1 -1
  80. package/dist/scheduling/ScheduledTaskStore.js +53 -12
  81. package/dist/scheduling/ScheduledTaskStore.js.map +1 -1
  82. package/dist/scheduling/types.js +19 -4
  83. package/dist/scheduling/types.js.map +1 -1
  84. package/dist/state/StateStore.js +213 -23
  85. package/dist/state/StateStore.js.map +1 -1
  86. package/dist/state/TurnPreviewJournal.js +157 -39
  87. package/dist/state/TurnPreviewJournal.js.map +1 -1
  88. package/dist/state/TurnToolText.js +172 -0
  89. package/dist/state/TurnToolText.js.map +1 -0
  90. package/dist/state/migrations.js +4 -0
  91. package/dist/state/migrations.js.map +1 -1
  92. package/dist/supervision/SafeRestartNotifier.js +9 -6
  93. package/dist/supervision/SafeRestartNotifier.js.map +1 -1
  94. package/dist/terminal/TerminalPage.js +5 -0
  95. package/dist/terminal/TerminalPage.js.map +1 -1
  96. package/dist/updates/AutomaticUpdatePreparer.js +63 -12
  97. package/dist/updates/AutomaticUpdatePreparer.js.map +1 -1
  98. package/dist/updates/ManualUpdateController.js +7 -2
  99. package/dist/updates/ManualUpdateController.js.map +1 -1
  100. package/dist/utils/promptAttachments.js +22 -0
  101. package/dist/utils/promptAttachments.js.map +1 -0
  102. package/dist/utils/promptQuotes.js +47 -0
  103. package/dist/utils/promptQuotes.js.map +1 -0
  104. package/dist/utils/toolTimestamp.js +6 -0
  105. package/dist/utils/toolTimestamp.js.map +1 -0
  106. package/npm-shrinkwrap.json +2 -2
  107. package/package.json +1 -1
  108. package/skills/agent-bot/SKILL.md +23 -2
  109. package/src/cli/SelfUpdateObserver.ts +111 -0
  110. package/src/cli/SelfUpdateRunner.ts +271 -85
  111. package/src/cli/SelfUpdater.ts +53 -16
  112. package/src/cli/controlProtocol.ts +1 -0
  113. package/src/cli/help.ts +6 -0
  114. package/src/cli.ts +71 -5
  115. package/src/codex/CodexEventMapper.ts +25 -5
  116. package/src/codex/CodexRuntime.ts +4 -0
  117. package/src/feishu/CardRenderer.ts +48 -13
  118. package/src/feishu/ConsoleFeishuClient.ts +6 -1
  119. package/src/feishu/FeishuMarkdown.ts +2 -14
  120. package/src/feishu/FeishuMessageClient.ts +10 -0
  121. package/src/feishu/FeishuTurnPresenter.ts +49 -16
  122. package/src/feishu/types.ts +1 -0
  123. package/src/index.ts +47 -12
  124. package/src/local-files/DiagramPreview.ts +11 -6
  125. package/src/local-files/GitDiffPreview.ts +107 -15
  126. package/src/local-files/LiveMarkup.ts +103 -0
  127. package/src/local-files/LocalFileViewerServer.ts +128 -125
  128. package/src/local-files/MarkdownExport.ts +54 -0
  129. package/src/local-files/PreviewCodeFont.ts +12 -0
  130. package/src/local-files/PreviewSyntaxHighlight.ts +75 -0
  131. package/src/local-files/ToolCommandDisplay.ts +104 -0
  132. package/src/local-files/TurnPreviewPage.ts +58 -261
  133. package/src/local-files/WorkspaceFileEvents.ts +186 -0
  134. package/src/local-files/WorkspaceFiles.ts +72 -5
  135. package/src/local-files/WorkspaceImages.ts +35 -0
  136. package/src/local-files/WorkspacePage.ts +24 -6
  137. package/src/local-files/WorkspaceSessions.ts +1057 -111
  138. package/src/local-files/WorkspaceTimeline.ts +135 -0
  139. package/src/presentation/OutboundRouter.ts +18 -4
  140. package/src/presentation/TurnStateReducer.ts +30 -19
  141. package/src/presentation/turnViewTypes.ts +3 -1
  142. package/src/proxy/ProxySessionController.ts +336 -96
  143. package/src/proxy/TaskMetadata.ts +81 -0
  144. package/src/runtime/types.ts +2 -1
  145. package/src/scheduling/ScheduleCards.ts +10 -4
  146. package/src/scheduling/ScheduleCommand.ts +4 -0
  147. package/src/scheduling/ScheduledTaskStore.ts +56 -9
  148. package/src/scheduling/types.ts +27 -4
  149. package/src/state/StateStore.ts +227 -24
  150. package/src/state/TurnPreviewJournal.ts +155 -38
  151. package/src/state/TurnToolText.ts +156 -0
  152. package/src/state/migrations.ts +4 -0
  153. package/src/supervision/SafeRestartNotifier.ts +9 -6
  154. package/src/terminal/TerminalPage.ts +5 -0
  155. package/src/updates/AutomaticUpdatePreparer.ts +52 -11
  156. package/src/updates/ManualUpdateController.ts +8 -3
  157. package/src/utils/promptAttachments.ts +27 -0
  158. package/src/utils/promptQuotes.ts +48 -0
  159. package/src/utils/toolTimestamp.ts +5 -0
@@ -75,7 +75,7 @@ export interface SafeRestartStatusView {
75
75
  remainingMs?: number;
76
76
  pendingFinalDeliveries: number;
77
77
  waitingTasks: Array<{
78
- id: string;
78
+ prompt?: string;
79
79
  localSessionId: string;
80
80
  isRunning: boolean;
81
81
  title?: string;
@@ -89,6 +89,7 @@ export interface PromptQueueCardView {
89
89
  prompts: Array<{
90
90
  id: string;
91
91
  text: string;
92
+ hasImages?: boolean;
92
93
  }>;
93
94
  }
94
95
 
@@ -316,6 +317,8 @@ export interface AppServerReleaseCardView {
316
317
  }
317
318
 
318
319
  export class CardRenderer {
320
+ constructor(private readonly fileChangeUrl?: (filePath: string) => string | undefined) {}
321
+
319
322
  renderThreadWriterConflict(view: ThreadWriterConflictCardView): Record<string, unknown> {
320
323
  if (view.status === "released") {
321
324
  return sectionCard("任务占用已解除", [markdown([
@@ -941,7 +944,7 @@ export class CardRenderer {
941
944
  vertical_align: "center",
942
945
  elements: [markdown(
943
946
  escapeCardHtml(
944
- `${index + 1}. ${truncateText(prompt.text.replace(/\s+/g, " ").trim(), 180)}`,
947
+ `${index + 1}. ${truncateText(prompt.text.replace(/\s+/g, " ").trim(), 180)}${prompt.hasImages ? " [图片]" : ""}`,
945
948
  ),
946
949
  )],
947
950
  },
@@ -1096,7 +1099,8 @@ export class CardRenderer {
1096
1099
  const visible = view.waitingTasks.slice(0, 10);
1097
1100
  elements.push({ tag: "hr" }, markdown(`**当前等待的任务(${view.waitingTasks.length})**`));
1098
1101
  for (const [index, task] of visible.entries()) {
1099
- const label = `${index + 1}. ${task.title ? `${inlineCode(truncateText(task.title, 80))} · ` : ""}${inlineCode(task.id)}`;
1102
+ const prompt = task.prompt?.replace(/\s+/gu, " ").trim() || (task.isRunning ? "Prompt 暂不可用" : "等待执行");
1103
+ const label = `${index + 1}. ${task.title ? `**${escapeCardMarkdownText(truncateText(task.title, 80))}** · ` : ""}${escapeCardMarkdownText(truncateText(prompt, 40))}`;
1100
1104
  elements.push({
1101
1105
  tag: "column_set",
1102
1106
  flex_mode: "none",
@@ -1281,7 +1285,7 @@ export class CardRenderer {
1281
1285
  }
1282
1286
 
1283
1287
  renderTurn(state: TurnViewState, previewUrl?: string): Record<string, unknown> {
1284
- const elements = renderGroupedTurnElements(state, "hidden");
1288
+ const elements = renderGroupedTurnElements(state, "hidden", this.fileChangeUrl);
1285
1289
  const footerActions: TaskListCardAction[] = [];
1286
1290
  if (isTurnStoppable(state.status)) {
1287
1291
  footerActions.push({
@@ -1382,7 +1386,7 @@ export class CardRenderer {
1382
1386
  } else if (state.historyDetail === "summary") {
1383
1387
  elements.push(markdown("当前仅保存轮次摘要,尚未加载历史执行详情。"));
1384
1388
  }
1385
- elements.push(...renderGroupedTurnElements(state, "always"));
1389
+ elements.push(...renderGroupedTurnElements(state, "always", this.fileChangeUrl));
1386
1390
  if (previewUrl) elements.push(taskActionRow([turnPreviewAction(previewUrl)]));
1387
1391
  return turnCard(title, "blue", elements, renderTurnSubtitle(state));
1388
1392
  }
@@ -1777,6 +1781,7 @@ function isTurnStoppable(status: TurnViewStatus): boolean {
1777
1781
  function renderGroupedTurnElements(
1778
1782
  state: TurnViewState,
1779
1783
  assistantTextMode: "hidden" | "always",
1784
+ fileChangeUrl?: (filePath: string) => string | undefined,
1780
1785
  ): Record<string, unknown>[] {
1781
1786
  const elements: Record<string, unknown>[] = [];
1782
1787
  const allActivities = turnActivities(state);
@@ -1800,7 +1805,7 @@ function renderGroupedTurnElements(
1800
1805
  ? [{ kind: "gap", id: "gap:truncated" }, ...visible.groups]
1801
1806
  : visible.groups;
1802
1807
  elements.push(...renderGroupedActivityGroups(visibleGroups, state.projectCwd));
1803
- if (state.fileSummary.length > 0) elements.push(fileSummaryPanel(state));
1808
+ if (state.fileSummary.length > 0) elements.push(fileSummaryPanel(state, fileChangeUrl));
1804
1809
 
1805
1810
  if (state.approval) elements.push(...renderApprovalElements(state, state.approval));
1806
1811
  if (state.statusMessage) elements.push(markdown(codeBlock(state.statusMessage, 2_000)));
@@ -1811,7 +1816,17 @@ function renderGroupedTurnElements(
1811
1816
  const heading = state.status === "completed" ? "回答" : "回答生成中";
1812
1817
  elements.push(markdown(`**${heading}**\n${truncateText(state.assistantText, 3_000)}`));
1813
1818
  }
1814
- if (elements.length === 0) elements.push(markdown(emptyTurnText(state.status, state.agentLabel)));
1819
+ if (elements.length === 0) {
1820
+ if (state.status === "starting" || state.status === "running" || state.status === "tool_running") {
1821
+ const value = (text: string | undefined, fallback: string): string =>
1822
+ escapeCardMarkdownText(text?.trim().replace(/[\r\n]+/g, " ") || fallback);
1823
+ elements.push({
1824
+ ...markdown(`Model: ${value(state.model, "默认")} · ${value(state.reasoningEffort, "自动")}`),
1825
+ text_size: "notation",
1826
+ });
1827
+ }
1828
+ elements.push(markdown(emptyTurnText(state.status, state.agentLabel)));
1829
+ }
1815
1830
  return elements;
1816
1831
  }
1817
1832
 
@@ -1823,8 +1838,8 @@ function renderApprovalElements(state: TurnViewState, request: ApprovalRequest):
1823
1838
  const reason = request.reason?.trim()
1824
1839
  || (request.title.trim() !== command ? request.title.trim() : "");
1825
1840
  if (reason && reason !== command) {
1826
- const preview = approvalTextPreview(reason, 1_000, escapeApprovalText);
1827
- elements.push(markdown(escapeApprovalText(preview)));
1841
+ const preview = approvalTextPreview(reason, 1_000, escapeCardMarkdownText);
1842
+ elements.push(markdown(escapeCardMarkdownText(preview)));
1828
1843
  if (preview !== reason) elements.push(markdown("<font color='grey'>说明较长,请在 Preview 中查看完整内容。</font>"));
1829
1844
  }
1830
1845
  const display = displayToolCommand(command) ?? command;
@@ -1888,7 +1903,7 @@ function approvalTextPreview(value: string, maxBytes: number, encode = (text: st
1888
1903
  return `${result}...`;
1889
1904
  }
1890
1905
 
1891
- function escapeApprovalText(value: string): string {
1906
+ function escapeCardMarkdownText(value: string): string {
1892
1907
  return escapeCardHtml(value).replace(/[\\`*_[\]#]/gu, (character) => `&#${character.codePointAt(0)};`);
1893
1908
  }
1894
1909
 
@@ -1909,16 +1924,36 @@ function planPanel(plan: TurnViewState["plan"]): Record<string, unknown> {
1909
1924
  });
1910
1925
  }
1911
1926
 
1912
- function fileSummaryPanel(state: TurnViewState): Record<string, unknown> {
1927
+ function fileSummaryPanel(state: TurnViewState, fileChangeUrl?: (filePath: string) => string | undefined): Record<string, unknown> {
1913
1928
  return collapsiblePanel(
1914
1929
  `文件变更 · ${state.fileSummary.length}`,
1915
1930
  state.fileSummary
1916
- .map((file) => `- ${escapeMarkdownFilePath(displayFilePath(file.path, state.projectCwd))} +${file.additions ?? 0} -${file.deletions ?? 0}`)
1931
+ .map((file) => {
1932
+ const displayPath = displayFilePath(file.path, state.projectCwd);
1933
+ let label = escapeMarkdownFilePath(displayPath);
1934
+ const pathApi = usesWindowsPaths(file.path, state.projectCwd ?? "") ? path.win32 : path;
1935
+ const absolutePath = pathApi.isAbsolute(file.path) ? pathApi.normalize(file.path)
1936
+ : state.projectCwd ? pathApi.resolve(state.projectCwd, file.path) : undefined;
1937
+ const target = absolutePath && fileChangeUrl?.(absolutePath);
1938
+ if (target) {
1939
+ const url = new URL(target);
1940
+ if (url.protocol === "http:" || url.protocol === "https:") {
1941
+ label = `[${escapeCardMarkdownText(pathApi.normalize(displayPath))}](${url.toString()})`;
1942
+ }
1943
+ }
1944
+ return `- ${label}${fileChangeSuffix(file)}`;
1945
+ })
1917
1946
  .join("\n"),
1918
1947
  { elementId: "turn_files" },
1919
1948
  );
1920
1949
  }
1921
1950
 
1951
+ function fileChangeSuffix(file: { additions?: number; deletions?: number }): string {
1952
+ const changes = [file.additions ? `+${file.additions}` : "", file.deletions ? `-${file.deletions}` : ""]
1953
+ .filter(Boolean).join(" ");
1954
+ return changes ? ` ${changes}` : "";
1955
+ }
1956
+
1922
1957
  function renderPlanStep(step: TurnViewState["plan"][number]): string {
1923
1958
  const marker = step.status === "completed" ? "✅" : step.status === "in_progress" ? "🔄" : "○";
1924
1959
  return `${marker} ${step.text}`;
@@ -2416,7 +2451,7 @@ function renderToolDetails(tool: ToolState, projectCwd?: string): string {
2416
2451
  const command = tool.command ?? tool.title;
2417
2452
  const fileSummary = tool.files?.length
2418
2453
  ? tool.files
2419
- .map((file) => `${displayFilePath(file.path, projectCwd)} +${file.additions ?? 0} -${file.deletions ?? 0}`)
2454
+ .map((file) => `${displayFilePath(file.path, projectCwd)}${fileChangeSuffix(file)}`)
2420
2455
  .join("\n")
2421
2456
  : undefined;
2422
2457
  const result = tool.error ?? tool.output ?? fileSummary;
@@ -1,4 +1,4 @@
1
- import type { FeishuOutbound } from "./types.js";
1
+ import type { FeishuOutbound, MessageReplyTarget } from "./types.js";
2
2
 
3
3
  export class ConsoleFeishuClient implements FeishuOutbound {
4
4
  async sendText(contextKey: string, text: string): Promise<string> {
@@ -6,6 +6,11 @@ export class ConsoleFeishuClient implements FeishuOutbound {
6
6
  return `console-text-${Date.now()}`;
7
7
  }
8
8
 
9
+ sendPromptImages(contextKey: string, text: string, files: string[], _target?: MessageReplyTarget, onPosting?: () => void): Promise<string> {
10
+ onPosting?.();
11
+ return this.sendText(contextKey, [text, `${files.length} 张图片附件`].filter(Boolean).join("\n"));
12
+ }
13
+
9
14
  async sendMarkdown(contextKey: string, markdown: string): Promise<string> {
10
15
  console.log(`\n[${contextKey}] ${markdown}\n`);
11
16
  return `console-markdown-${Date.now()}`;
@@ -8,9 +8,8 @@ interface FenceState {
8
8
  }
9
9
 
10
10
  const FENCE_OPENER = /^([ \t]*)((?:`{3,})|(?:~{3,}))(.*)$/;
11
- const MARKDOWN_LINK = /(!?)\[([^\]\r\n]*)\]\((<[^>\r\n]+>|[^)\r\n]+)\)/g;
11
+ const MARKDOWN_LINK = /(!?)\[([^\[\]\r\n]*)\]\((<[^>\r\n]+>|[^)\r\n]+)\)/g;
12
12
  const LOCAL_FILE_LINE_REFERENCE = /(:\d+(?::\d+)?)$/;
13
- const LOCAL_IMAGE_EXTENSIONS = new Set([".png", ".jpg", ".jpeg", ".gif", ".webp", ".tiff", ".bmp", ".ico"]);
14
13
 
15
14
  export type LocalFileUrlResolver = (filePath: string, reference?: string) => string | undefined;
16
15
 
@@ -61,7 +60,7 @@ function includeLocalFileLineReferences(
61
60
  const target = unwrapMarkdownTarget(rawTarget.trim());
62
61
  if (!isLocalFileTarget(target)) {
63
62
  const relative = resolveRelativeFileTarget(target, projectCwd);
64
- if (!relative || isLocalImageTarget(relative.filePath)) return link;
63
+ if (!relative) return link;
65
64
  const viewerUrl = localFileUrl?.(relative.filePath, relative.reference);
66
65
  if (!viewerUrl) {
67
66
  const displayPath = displayAbsolutePath(relative.filePath) + (relative.reference ?? "");
@@ -73,8 +72,6 @@ function includeLocalFileLineReferences(
73
72
  ? `${label}${relative.reference}` : label;
74
73
  return `[${normalizedLabel}](${url.toString()})`;
75
74
  }
76
- if (isLocalImageTarget(target)) return link;
77
-
78
75
  const reference = LOCAL_FILE_LINE_REFERENCE.exec(target)?.[1];
79
76
  const targetWithoutReference = reference ? target.slice(0, -reference.length) : target;
80
77
  const filePath = localFilePath(targetWithoutReference);
@@ -208,15 +205,6 @@ function usesWindowsPaths(...values: string[]): boolean {
208
205
  return values.some((value) => /^\/?[a-z]:[\\/]/i.test(value) || /^\\\\/.test(value));
209
206
  }
210
207
 
211
- function isLocalImageTarget(target: string): boolean {
212
- const reference = LOCAL_FILE_LINE_REFERENCE.exec(target)?.[1];
213
- const targetWithoutReference = reference ? target.slice(0, -reference.length) : target;
214
- const filePath = localFilePath(targetWithoutReference);
215
- if (!filePath) return false;
216
- const pathApi = usesWindowsPaths(filePath) ? path.win32 : path.posix;
217
- return LOCAL_IMAGE_EXTENSIONS.has(pathApi.extname(filePath).toLowerCase());
218
- }
219
-
220
208
  function unwrapMarkdownTarget(target: string): string {
221
209
  return target.startsWith("<") && target.endsWith(">") ? target.slice(1, -1) : target;
222
210
  }
@@ -335,6 +335,16 @@ export class FeishuMessageClient implements FeishuOutbound {
335
335
  return this.sendMessage(contextKey, "file", { file_key: fileKey });
336
336
  }
337
337
 
338
+ async sendPromptImages(contextKey: string, text: string, files: string[], target?: MessageReplyTarget, onPosting?: () => void): Promise<string | undefined> {
339
+ const keys = await Promise.all(files.map((file) => this.uploadImageCached(file)));
340
+ const content = { zh_cn: { content: [
341
+ ...(text ? [[{ tag: "text", text }]] : []),
342
+ ...keys.map((image_key) => [{ tag: "img", image_key }]),
343
+ ] } };
344
+ onPosting?.();
345
+ return target ? this.replyMessage(contextKey, target, "post", content) : this.sendMessage(contextKey, "post", content);
346
+ }
347
+
338
348
  async sendMarkdown(contextKey: string, markdown: string, idempotencyKey?: string): Promise<string | undefined> {
339
349
  const normalizedMarkdown = normalizeFeishuMarkdown(markdown);
340
350
  const elements = this.renderFinalAnswerElements(normalizedMarkdown);
@@ -77,6 +77,7 @@ interface TurnEntry {
77
77
  reactionId?: string;
78
78
  reactionEmoji?: string;
79
79
  scheduler?: CardUpdateScheduler<TurnViewState>;
80
+ localFirst?: boolean;
80
81
  elapsedTimer?: ReturnType<typeof setInterval>;
81
82
  finalizing?: Promise<void>;
82
83
  lastFinalizedStatus?: TurnViewState["status"];
@@ -90,6 +91,7 @@ export class FeishuTurnPresenter {
90
91
  private readonly sessionAgentLabels = new Map<string, string>();
91
92
  private readonly sessionModels = new Map<string, string>();
92
93
  private readonly sessionModelProviders = new Map<string, string>();
94
+ private readonly sessionReasoningEfforts = new Map<string, string>();
93
95
  private readonly entries = new Map<string, TurnEntry>();
94
96
  private readonly pendingEntries = new Map<string, TurnEntry>();
95
97
  private readonly renderer: CardRenderer;
@@ -114,24 +116,27 @@ export class FeishuTurnPresenter {
114
116
  agentLabel?: string,
115
117
  model?: string,
116
118
  modelProvider?: string,
119
+ reasoningEffort?: string,
117
120
  ): void {
118
121
  this.sessionContexts.set(sessionId, contextKey);
119
122
  if (taskTitle) this.sessionTitles.set(sessionId, taskTitle);
120
123
  if (projectCwd) this.sessionCwds.set(sessionId, projectCwd);
121
124
  if (agentLabel) this.sessionAgentLabels.set(sessionId, agentLabel);
122
- if (model || modelProvider) {
123
- this.updateSessionModel(sessionId, model, modelProvider);
124
- }
125
+ this.updateSessionModel(sessionId, model, modelProvider, reasoningEffort);
125
126
  }
126
127
 
127
- updateSessionModel(sessionId: string, model?: string, modelProvider?: string): void {
128
+ updateSessionModel(sessionId: string, model?: string, modelProvider?: string, reasoningEffort?: string): void {
128
129
  if (model) this.sessionModels.set(sessionId, model);
129
130
  if (modelProvider) this.sessionModelProviders.set(sessionId, modelProvider);
131
+ if (reasoningEffort) this.sessionReasoningEfforts.set(sessionId, reasoningEffort);
132
+ else this.sessionReasoningEfforts.delete(sessionId);
130
133
  const pending = this.pendingEntries.get(sessionId);
131
134
  const nextModel = this.sessionModels.get(sessionId);
132
135
  const nextProvider = this.sessionModelProviders.get(sessionId);
133
- if (!pending || (pending.state.model === nextModel && pending.state.modelProvider === nextProvider)) return;
134
- pending.state = { ...pending.state, model: nextModel, modelProvider: nextProvider };
136
+ const nextEffort = this.sessionReasoningEfforts.get(sessionId);
137
+ if (!pending || (pending.state.model === nextModel && pending.state.modelProvider === nextProvider
138
+ && pending.state.reasoningEffort === nextEffort)) return;
139
+ pending.state = { ...pending.state, model: nextModel, modelProvider: nextProvider, reasoningEffort: nextEffort };
135
140
  this.persist(pending.state.turnId, sessionId, pending.state, pending.contextKey);
136
141
  if (!pending.historySnapshot) pending.scheduler?.update(pending.state, "critical");
137
142
  }
@@ -153,6 +158,7 @@ export class FeishuTurnPresenter {
153
158
  this.sessionAgentLabels.delete(sessionId);
154
159
  this.sessionModels.delete(sessionId);
155
160
  this.sessionModelProviders.delete(sessionId);
161
+ this.sessionReasoningEfforts.delete(sessionId);
156
162
  }
157
163
 
158
164
  async startPendingTurn(
@@ -162,10 +168,12 @@ export class FeishuTurnPresenter {
162
168
  replyTarget?: MessageReplyTarget,
163
169
  prompt?: string,
164
170
  localImagePaths?: string[],
171
+ promptRequestId?: string,
172
+ localFirst?: boolean,
165
173
  ): Promise<string | undefined> {
166
174
  const existing = this.pendingEntries.get(sessionId);
167
175
  if (existing) {
168
- await existing.initializing;
176
+ if (!localFirst) await existing.initializing;
169
177
  if (existing.continuing) {
170
178
  existing.state = { ...existing.state, status: "running", error: undefined, completedAt: undefined, durationMs: undefined };
171
179
  this.persist(existing.state.turnId, sessionId, existing.state, existing.contextKey);
@@ -174,8 +182,10 @@ export class FeishuTurnPresenter {
174
182
  return existing.state.turnId;
175
183
  }
176
184
  const images = localImagePaths === undefined ? existing.state.promptImagePaths : [...new Set(localImagePaths)];
177
- if ((prompt && existing.state.prompt !== prompt) || JSON.stringify(images) !== JSON.stringify(existing.state.promptImagePaths)) {
178
- existing.state = { ...existing.state, ...(prompt ? { prompt } : {}), ...(images ? { promptImagePaths: images } : {}) };
185
+ if ((prompt && existing.state.prompt !== prompt) || JSON.stringify(images) !== JSON.stringify(existing.state.promptImagePaths)
186
+ || promptRequestId !== undefined && promptRequestId !== existing.state.promptRequestId) {
187
+ existing.state = { ...existing.state, ...(prompt ? { prompt } : {}), ...(images ? { promptImagePaths: images } : {}),
188
+ ...(promptRequestId ? { promptRequestId } : {}) };
179
189
  this.persist(existing.state.turnId, sessionId, existing.state, existing.contextKey);
180
190
  if (!existing.historySnapshot) existing.scheduler?.update(existing.state, "critical");
181
191
  }
@@ -195,12 +205,18 @@ export class FeishuTurnPresenter {
195
205
  this.sessionModels.get(sessionId),
196
206
  localImagePaths,
197
207
  this.sessionModelProviders.get(sessionId),
208
+ this.sessionReasoningEfforts.get(sessionId),
198
209
  );
199
- const entry = { contextKey, state, initializing: Promise.resolve() } as TurnEntry;
210
+ if (promptRequestId) state.promptRequestId = promptRequestId;
211
+ const entry: TurnEntry = { contextKey, state, localFirst, initializing: Promise.resolve() };
200
212
  this.entries.set(state.turnId, entry);
201
213
  this.pendingEntries.set(sessionId, entry);
202
214
  this.persist(state.turnId, sessionId, state, contextKey);
203
215
  entry.initializing = this.initializeEntry(entry);
216
+ if (localFirst) {
217
+ entry.initializing = entry.initializing.catch(error => { this.options.onError?.(error); });
218
+ return state.turnId;
219
+ }
204
220
  try {
205
221
  await entry.initializing;
206
222
  return state.turnId;
@@ -230,6 +246,14 @@ export class FeishuTurnPresenter {
230
246
  durationMs: entry.continuing ? undefined : Math.max(0, completedAt - entry.state.startedAt),
231
247
  };
232
248
  this.persist(entry.state.turnId, sessionId, entry.state, entry.contextKey);
249
+ if (entry.localFirst && !replacementCard) {
250
+ void this.presentPendingFailure(entry).catch(error => this.options.onError?.(error));
251
+ return false;
252
+ }
253
+ return this.presentPendingFailure(entry, replacementCard);
254
+ }
255
+
256
+ private async presentPendingFailure(entry: TurnEntry, replacementCard?: Record<string, unknown>): Promise<boolean> {
233
257
  await entry.initializing;
234
258
  try {
235
259
  await entry.scheduler?.flush(entry.state);
@@ -289,6 +313,7 @@ export class FeishuTurnPresenter {
289
313
  localImagePaths?: string[],
290
314
  ): Promise<void> {
291
315
  const activityId = `steer:${messageId ?? createId("message")}`;
316
+ const startedAt = Date.now();
292
317
  let entry = this.entries.get(turnId);
293
318
  const saved = entry?.state ?? this.store.getTurnSnapshot(turnId);
294
319
  if (isTurnViewState(saved) && saved.taskNotificationCard) return;
@@ -310,23 +335,28 @@ export class FeishuTurnPresenter {
310
335
  this.sessionModels.get(sessionId),
311
336
  undefined,
312
337
  this.sessionModelProviders.get(sessionId),
338
+ this.sessionReasoningEfforts.get(sessionId),
313
339
  ),
314
340
  status: "running" as const,
315
341
  };
316
342
  this.store.previews?.seed(initial);
317
- this.store.previews?.user(initial.previewTurnId ?? turnId, activityId, text, localImagePaths);
318
- const state = this.cardState(appendSteerMessageToState(initial, activityId, text, localImagePaths));
319
- entry = { contextKey, state, initializing: Promise.resolve() } as TurnEntry;
343
+ this.store.previews?.user(initial.previewTurnId ?? turnId, activityId, text, localImagePaths, startedAt);
344
+ const state = this.cardState(appendSteerMessageToState(initial, activityId, text, localImagePaths, startedAt));
345
+ entry = { contextKey, state, localFirst: messageId?.startsWith("workspace:"), initializing: Promise.resolve() };
320
346
  this.entries.set(turnId, entry);
321
347
  this.persist(turnId, sessionId, state, contextKey);
322
348
  entry.initializing = this.initializeEntry(entry);
349
+ if (entry.localFirst) {
350
+ entry.initializing = entry.initializing.catch(error => { this.options.onError?.(error); });
351
+ return;
352
+ }
323
353
  await entry.initializing;
324
354
  return;
325
355
  }
326
356
 
327
357
  await entry.initializing;
328
- this.store.previews?.user(entry.state.previewTurnId ?? turnId, activityId, text, localImagePaths);
329
- entry.state = this.cardState(appendSteerMessageToState(entry.state, activityId, text, localImagePaths));
358
+ this.store.previews?.user(entry.state.previewTurnId ?? turnId, activityId, text, localImagePaths, startedAt);
359
+ entry.state = this.cardState(appendSteerMessageToState(entry.state, activityId, text, localImagePaths, startedAt));
330
360
  this.persist(turnId, sessionId, entry.state, entry.contextKey);
331
361
  if (!entry.historySnapshot) entry.scheduler?.update(entry.state, "critical");
332
362
  }
@@ -394,9 +424,11 @@ export class FeishuTurnPresenter {
394
424
  pending.state.model,
395
425
  pending.state.promptImagePaths,
396
426
  pending.state.modelProvider,
427
+ pending.state.reasoningEffort,
397
428
  ),
398
429
  event,
399
430
  );
431
+ if (pending.state.promptRequestId) state.promptRequestId = pending.state.promptRequestId;
400
432
  this.flushPersistence();
401
433
  this.store.previews?.seed(state);
402
434
  this.store.previews?.event(event);
@@ -431,7 +463,7 @@ export class FeishuTurnPresenter {
431
463
  }
432
464
 
433
465
  await entry.initializing;
434
- if (!entry.scheduler && !(event.type === "turn_completed" && entry.state.taskNotificationCard)) return;
466
+ if (!entry.scheduler && !entry.localFirst && !(event.type === "turn_completed" && entry.state.taskNotificationCard)) return;
435
467
 
436
468
  if (event.type === "turn_status_unknown" && entry.state.status === "unknown") {
437
469
  if (this.pendingEntries.get(event.sessionId) === entry) this.pendingEntries.delete(event.sessionId);
@@ -593,6 +625,7 @@ export class FeishuTurnPresenter {
593
625
  this.sessionModels.get(event.sessionId),
594
626
  undefined,
595
627
  this.sessionModelProviders.get(event.sessionId),
628
+ this.sessionReasoningEfforts.get(event.sessionId),
596
629
  );
597
630
  this.store.previews?.seed(initial);
598
631
  event = presentationEvent(event, initial);
@@ -80,6 +80,7 @@ export interface FeishuOutbound {
80
80
  readReferencedMessage?(messageId: string): Promise<ReferencedMessageContent>;
81
81
  sendText(contextKey: string, text: string): Promise<string | undefined>;
82
82
  sendFile?(contextKey: string, filePath: string): Promise<string | undefined>;
83
+ sendPromptImages?(contextKey: string, text: string, files: string[], target?: MessageReplyTarget, onPosting?: () => void): Promise<string | undefined>;
83
84
  sendMarkdown(contextKey: string, markdown: string, idempotencyKey?: string): Promise<string | undefined>;
84
85
  sendInteractiveCard(contextKey: string, card: Record<string, unknown>, idempotencyKey?: string): Promise<string | undefined>;
85
86
  replyText?(
package/src/index.ts CHANGED
@@ -31,6 +31,7 @@ import { requireServerFeishuTransport } from "./feishu/transport.js";
31
31
  import { createLogger } from "./logging/logger.js";
32
32
  import { OutboundRouter, type OutboundRoute } from "./presentation/OutboundRouter.js";
33
33
  import { ProxySessionController } from "./proxy/ProxySessionController.js";
34
+ import { recordTaskMetadata } from "./proxy/TaskMetadata.js";
34
35
  import type { AgentEnvironmentContext } from "./runtime/agentEnvironment.js";
35
36
  import { createAgentRuntimeRegistry } from "./runtime/createAgentRuntimeRegistry.js";
36
37
  import { StateStore } from "./state/StateStore.js";
@@ -43,6 +44,7 @@ import { StartupNotifier } from "./startup/StartupNotifier.js";
43
44
  import { SessionMetadataHydrator } from "./startup/SessionMetadataHydrator.js";
44
45
  import { startFeishu } from "./startup/startFeishu.js";
45
46
  import { STOP_EXIT_CODE } from "./supervision/restartPolicy.js";
47
+ import { readSelfUpdateRecoveryAttemptIds, SELF_UPDATE_RECOVERY_ATTEMPTS_ENV } from "./cli/SelfUpdateRunner.js";
46
48
  import {
47
49
  RESTART_GROUP_CONTEXTS_ENV,
48
50
  RESTART_NOTIFICATION_TARGETS_ENV,
@@ -69,10 +71,13 @@ import {
69
71
  launchSelfUpdateRunner,
70
72
  readPendingSelfUpdate,
71
73
  releaseSelfUpdatePlan,
74
+ SelfUpdatePreparationError,
72
75
  } from "./cli/SelfUpdater.js";
73
76
 
74
77
  const processStartedAt = new Date();
75
78
  const agentBotVersion = readPackageVersion();
79
+ const updateRecoveryAttemptIds = readSelfUpdateRecoveryAttemptIds(process.env[SELF_UPDATE_RECOVERY_ATTEMPTS_ENV]);
80
+ delete process.env[SELF_UPDATE_RECOVERY_ATTEMPTS_ENV];
76
81
  const supervised = process.env.AGENT_BOT_SUPERVISED === "1";
77
82
  const startupReason = process.env.AGENT_BOT_RESTART_REASON?.trim()
78
83
  || (supervised ? "Supervisor 启动" : "直接启动");
@@ -136,7 +141,7 @@ let serverReady = false;
136
141
 
137
142
  const feishuOutbound = transport === "sdk" ? new FeishuMessageClient(config, logger) : undefined;
138
143
  if (feishuOutbound) {
139
- const renderer = new CardRenderer();
144
+ const renderer = new CardRenderer((filePath) => localFileViewer?.createFileUrl(filePath, undefined, { diff: true }));
140
145
  const presenter = new FeishuTurnPresenter(feishuOutbound, store, renderer, {
141
146
  normalIntervalMs: 2_000,
142
147
  criticalGapMs: 500,
@@ -209,20 +214,20 @@ const manualUpdates = new ManualUpdateController({
209
214
  readReleases: readPublishedReleases,
210
215
  checkSupport: () => checkAutomaticUpdateSupport({ home: agentBotHome(), configPath: activeConfigPath }),
211
216
  hasPendingUpdate: () => preparingSelfUpdate || shuttingDown || restartRequested || !!pendingSelfUpdatePlanPath || safeRestart.scheduled,
212
- applyUpdate: (version, contextKey, replyTarget) => prepareAndScheduleUpdate(version, {
217
+ applyUpdate: (version, contextKey, replyTarget, progress) => prepareAndScheduleUpdate(version, {
213
218
  contextKey,
214
219
  ...(replyTarget ? { replyMessageId: replyTarget.messageId } : {}),
215
- }, true),
220
+ }, true, progress),
216
221
  });
217
222
 
218
- async function prepareAndScheduleUpdate(version: string, target: RestartNotificationTarget, manual = false): Promise<void> {
223
+ async function prepareAndScheduleUpdate(version: string, target: RestartNotificationTarget, manual = false, progress?: { messageId: string; update(message: string): Promise<void> }): Promise<void> {
219
224
  if (preparingSelfUpdate || shuttingDown || restartRequested || pendingSelfUpdatePlanPath || safeRestart.scheduled) {
220
225
  throw new Error("已有更新或重启正在进行,请稍后重试。");
221
226
  }
222
227
  preparingSelfUpdate = true;
223
228
  try {
224
229
  const prepare = manual ? prepareSelectedUpdate : prepareAutomaticUpdate;
225
- const prepared = await prepare(version, { home: agentBotHome(), configPath: activeConfigPath });
230
+ const prepared = await prepare(version, { home: agentBotHome(), configPath: activeConfigPath }, undefined, progress?.update);
226
231
  try {
227
232
  if (shuttingDown || restartRequested || pendingSelfUpdatePlanPath || safeRestart.scheduled) {
228
233
  throw new Error("服务正在停止或已有更新/重启等待执行,本次更新已停止。");
@@ -234,6 +239,7 @@ async function prepareAndScheduleUpdate(version: string, target: RestartNotifica
234
239
  databasePath: config.storage.sqlitePath,
235
240
  restartService: true,
236
241
  notificationTarget: target,
242
+ notificationMessageId: progress?.messageId ?? (!manual ? store.getUpdateNotice(version)?.messageId : undefined),
237
243
  });
238
244
  pendingSelfUpdatePlanPath = prepared.planPath;
239
245
  }
@@ -245,6 +251,12 @@ async function prepareAndScheduleUpdate(version: string, target: RestartNotifica
245
251
  }
246
252
  throw error;
247
253
  }
254
+ } catch (error) {
255
+ if (error instanceof SelfUpdatePreparationError && !shuttingDown && !restartRequested && !pendingSelfUpdatePlanPath && !safeRestart.scheduled) {
256
+ safeRestart.schedule("更新准备失败,重启当前版本", target);
257
+ throw new Error(`更新准备失败,已安排安全重启。\n${error.message}`, { cause: error });
258
+ }
259
+ throw error;
248
260
  } finally {
249
261
  preparingSelfUpdate = false;
250
262
  }
@@ -278,7 +290,9 @@ function serverActivity() {
278
290
  const activity = store.getServerActivityState();
279
291
  const terminalBlockers = terminalServer?.listActiveTerminals() ?? [];
280
292
  const pendingInboundMessages = (controller?.pendingInboundMessages ?? 0) + (workspaceSessions?.preparingActions ?? 0);
281
- return { ...activity, pendingInboundMessages, activeTerminals: terminalBlockers.length, terminalBlockers };
293
+ const workspaceInboundAt = workspaceSessions?.latestInboundAt;
294
+ const latestInboundAt = workspaceInboundAt && workspaceInboundAt > (activity.latestInboundAt ?? "") ? workspaceInboundAt : activity.latestInboundAt;
295
+ return { ...activity, latestInboundAt, pendingInboundMessages, activeTerminals: terminalBlockers.length, terminalBlockers };
282
296
  }
283
297
 
284
298
  controller = new ProxySessionController(config, store, runtimes, outbound, logger, {
@@ -331,11 +345,13 @@ loadTurnDetails = (turnId) => controller.loadTurnDetails(turnId);
331
345
  if (localFileViewer && feishuOutbound) {
332
346
  workspaceSessions = new WorkspaceSessions(localFileViewer, {
333
347
  store, controller, logger,
348
+ loadTurnDetails: (turnId) => controller.loadTurnDetails(turnId),
334
349
  inboundImageDirectory: inboundImageDirectory(config.storage.sqlitePath),
335
350
  owner: () => config.feishu.userOpenId,
336
351
  password: browserPassword,
337
352
  isAppServer: (name) => config.agents[name]?.kind === "app-server",
338
- canSubmit: () => serverReady && !shuttingDown && !restartRequested && !safeRestart.scheduled,
353
+ sessionStorageBytes: (task) => runtimes.forAgent(task.agentName).getSessionStorageBytes?.(task.localSessionId),
354
+ canSubmit: () => serverReady && !shuttingDown && controller.acceptingInboundMessages,
339
355
  });
340
356
  localFileViewer.enableWorkspaceApp(workspaceSessions.start());
341
357
  }
@@ -386,7 +402,7 @@ taskScheduler = new TaskScheduler({
386
402
  drain: (sessionId) => controller.drainScheduledPrompts(sessionId),
387
403
  notify: (job, text) => controller.notifySchedule(job, text),
388
404
  });
389
- await controller.recoverInterruptedTasks().catch((error: unknown) => {
405
+ await controller.recoverInterruptedTasks(updateRecoveryAttemptIds).catch((error: unknown) => {
390
406
  logger.error({ error }, "Startup task recovery failed; the server will remain available.");
391
407
  });
392
408
  consoleConnector?.start();
@@ -510,13 +526,29 @@ async function initiateSelfUpdate(
510
526
  if (!commitRestart(force, activity.latestInboundAt)) return false;
511
527
  try {
512
528
  assertSelfUpdatePlanPath(planPath, agentBotHome());
513
- launchSelfUpdateRunner(planPath, {
514
- waitPids: [process.pid, ...(supervised ? [process.ppid] : [])],
515
- environment: replacementSupervisorEnvironment(
529
+ const recoveryAttemptIds = store.listIncompleteTurnAttempts().filter((attempt) => {
530
+ const session = store.getSession(attempt.localSessionId);
531
+ return session && (session.status === "starting" || session.status === "running")
532
+ && attempt.executionGeneration === store.executionGeneration(attempt.localSessionId)
533
+ && store.isLatestTurnAttempt(attempt.attemptId) && !store.hasCancellationRequestedForSession(attempt.localSessionId);
534
+ }).map((attempt) => attempt.attemptId);
535
+ finalizeSelfUpdatePlan(planPath, {
536
+ controlEndpoint: controlEndpoint(config.storage.sqlitePath), databasePath: config.storage.sqlitePath,
537
+ restartService: true, recoveryAttemptIds,
538
+ });
539
+ await launchSelfUpdateRunner(planPath, {
540
+ waitPids: [
541
+ ...(supervised ? [process.ppid] : []), process.pid,
542
+ ...runtimes.entries().flatMap(([, runtime]) => {
543
+ const pid = runtime.getProcessInfo?.().pid;
544
+ return pid ? [pid] : [];
545
+ }),
546
+ ],
547
+ environment: { ...replacementSupervisorEnvironment(
516
548
  reason,
517
549
  environmentRefresh.environment,
518
550
  allNotificationTargets,
519
- ),
551
+ ), AGENT_BOT_UPDATE_APP_ID: config.feishu.appId, AGENT_BOT_UPDATE_APP_SECRET: config.feishu.appSecret },
520
552
  });
521
553
  } catch (error) {
522
554
  restartRequested = false;
@@ -556,6 +588,7 @@ async function handleControlRequest(request: ControlRequest): Promise<ControlRes
556
588
  pid: process.pid,
557
589
  startedAt: processStartedAt.toISOString(),
558
590
  supervised,
591
+ supervisorPid: supervised ? process.ppid : null,
559
592
  feishuAppId: config.feishu.appId ?? null,
560
593
  agents: runtimes.entries().map(([name, runtime]) => {
561
594
  const processInfo = runtime.getProcessInfo?.() ?? {};
@@ -678,6 +711,8 @@ async function handleControlRequest(request: ControlRequest): Promise<ControlRes
678
711
  return { ok: true, data: controller.controlTaskMute(request.localSessionId, request.enabled) };
679
712
  case "task_shell":
680
713
  return { ok: true, data: await controller.controlRunTaskShell(request.localSessionId, request.command) };
714
+ case "task_metadata":
715
+ return { ok: true, data: recordTaskMetadata(store, request.localSessionId, request.command) };
681
716
  case "task_directory":
682
717
  return {
683
718
  ok: true,