@keyou007/agent-bot 0.1.9 → 0.1.11

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 (119) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +22 -10
  3. package/README.zh.md +22 -10
  4. package/assets/agent-bot-logo.png +0 -0
  5. package/dist/acp/AcpSessionManager.js +78 -46
  6. package/dist/acp/AcpSessionManager.js.map +1 -1
  7. package/dist/cli/FeishuAppConfiguration.js +84 -22
  8. package/dist/cli/FeishuAppConfiguration.js.map +1 -1
  9. package/dist/cli/FeishuAppRegistration.js +12 -9
  10. package/dist/cli/FeishuAppRegistration.js.map +1 -1
  11. package/dist/cli/Initializer.js +7 -6
  12. package/dist/cli/Initializer.js.map +1 -1
  13. package/dist/cli/LocalControlClient.js +3 -2
  14. package/dist/cli/LocalControlClient.js.map +1 -1
  15. package/dist/cli/LocalControlServer.js +2 -1
  16. package/dist/cli/LocalControlServer.js.map +1 -1
  17. package/dist/cli/OptionalAuthorizationSkip.js +27 -6
  18. package/dist/cli/OptionalAuthorizationSkip.js.map +1 -1
  19. package/dist/cli/ServerStarter.js +12 -3
  20. package/dist/cli/ServerStarter.js.map +1 -1
  21. package/dist/cli/SkillRegistry.js +5 -4
  22. package/dist/cli/SkillRegistry.js.map +1 -1
  23. package/dist/cli/VerificationOutput.js +2 -1
  24. package/dist/cli/VerificationOutput.js.map +1 -1
  25. package/dist/cli/help.js +48 -1
  26. package/dist/cli/help.js.map +1 -1
  27. package/dist/cli/i18n.js +27 -0
  28. package/dist/cli/i18n.js.map +1 -0
  29. package/dist/cli/initOptions.js +5 -4
  30. package/dist/cli/initOptions.js.map +1 -1
  31. package/dist/cli/packageVersion.js +2 -1
  32. package/dist/cli/packageVersion.js.map +1 -1
  33. package/dist/cli/profile.js +4 -3
  34. package/dist/cli/profile.js.map +1 -1
  35. package/dist/cli/serverStatus.js +15 -14
  36. package/dist/cli/serverStatus.js.map +1 -1
  37. package/dist/cli/taskChatRoute.js +3 -2
  38. package/dist/cli/taskChatRoute.js.map +1 -1
  39. package/dist/cli.js +165 -107
  40. package/dist/cli.js.map +1 -1
  41. package/dist/codex/AppServerConnection.js +15 -1
  42. package/dist/codex/AppServerConnection.js.map +1 -1
  43. package/dist/codex/CodexLocalActivityDetector.js +4 -1
  44. package/dist/codex/CodexLocalActivityDetector.js.map +1 -1
  45. package/dist/codex/CodexProcessManager.js +1 -0
  46. package/dist/codex/CodexProcessManager.js.map +1 -1
  47. package/dist/codex/CodexRuntime.js +77 -2
  48. package/dist/codex/CodexRuntime.js.map +1 -1
  49. package/dist/commands/CommandRouter.js +108 -47
  50. package/dist/commands/CommandRouter.js.map +1 -1
  51. package/dist/console/ConsoleTurnPresenter.js +1 -1
  52. package/dist/console/ConsoleTurnPresenter.js.map +1 -1
  53. package/dist/feishu/CardRenderer.js +345 -11
  54. package/dist/feishu/CardRenderer.js.map +1 -1
  55. package/dist/feishu/FeishuMessageClient.js +51 -5
  56. package/dist/feishu/FeishuMessageClient.js.map +1 -1
  57. package/dist/feishu/FeishuTurnPresenter.js +8 -3
  58. package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
  59. package/dist/index.js +18 -17
  60. package/dist/index.js.map +1 -1
  61. package/dist/proxy/ProxySessionController.js +595 -205
  62. package/dist/proxy/ProxySessionController.js.map +1 -1
  63. package/dist/runtime/AcpRuntimeAdapter.js +1 -0
  64. package/dist/runtime/AcpRuntimeAdapter.js.map +1 -1
  65. package/dist/runtime/AgentRuntimeRegistry.js +7 -4
  66. package/dist/runtime/AgentRuntimeRegistry.js.map +1 -1
  67. package/dist/runtime/createAgentRuntimeRegistry.js +22 -0
  68. package/dist/runtime/createAgentRuntimeRegistry.js.map +1 -0
  69. package/dist/startup/SessionMetadataHydrator.js +2 -2
  70. package/dist/startup/SessionMetadataHydrator.js.map +1 -1
  71. package/dist/startup/StartupNotifier.js +1 -0
  72. package/dist/startup/StartupNotifier.js.map +1 -1
  73. package/dist/state/StateStore.js +21 -15
  74. package/dist/state/StateStore.js.map +1 -1
  75. package/dist/supervision/SafeRestartScheduler.js +5 -0
  76. package/dist/supervision/SafeRestartScheduler.js.map +1 -1
  77. package/docs/technical-reference.md +27 -6
  78. package/docs/technical-reference.zh.md +27 -6
  79. package/npm-shrinkwrap.json +2 -2
  80. package/package.json +2 -1
  81. package/skills/agent-bot/SKILL.md +19 -9
  82. package/src/acp/AcpSessionManager.ts +73 -54
  83. package/src/cli/FeishuAppConfiguration.ts +130 -18
  84. package/src/cli/FeishuAppRegistration.ts +24 -9
  85. package/src/cli/Initializer.ts +25 -6
  86. package/src/cli/LocalControlClient.ts +9 -2
  87. package/src/cli/LocalControlServer.ts +2 -1
  88. package/src/cli/OptionalAuthorizationSkip.ts +51 -6
  89. package/src/cli/ServerStarter.ts +20 -3
  90. package/src/cli/SkillRegistry.ts +17 -4
  91. package/src/cli/VerificationOutput.ts +4 -1
  92. package/src/cli/help.ts +50 -1
  93. package/src/cli/i18n.ts +38 -0
  94. package/src/cli/initOptions.ts +17 -4
  95. package/src/cli/packageVersion.ts +5 -1
  96. package/src/cli/profile.ts +13 -3
  97. package/src/cli/serverStatus.ts +19 -14
  98. package/src/cli/taskChatRoute.ts +9 -2
  99. package/src/cli.ts +290 -103
  100. package/src/codex/AppServerConnection.ts +21 -1
  101. package/src/codex/CodexLocalActivityDetector.ts +8 -1
  102. package/src/codex/CodexProcessManager.ts +1 -0
  103. package/src/codex/CodexRuntime.ts +91 -2
  104. package/src/commands/CommandRouter.ts +123 -46
  105. package/src/commands/commandTypes.ts +6 -11
  106. package/src/console/ConsoleTurnPresenter.ts +1 -1
  107. package/src/feishu/CardRenderer.ts +418 -11
  108. package/src/feishu/FeishuMessageClient.ts +66 -3
  109. package/src/feishu/FeishuTurnPresenter.ts +7 -2
  110. package/src/index.ts +21 -22
  111. package/src/proxy/ProxySessionController.ts +712 -208
  112. package/src/runtime/AcpRuntimeAdapter.ts +1 -0
  113. package/src/runtime/AgentRuntimeRegistry.ts +7 -6
  114. package/src/runtime/createAgentRuntimeRegistry.ts +25 -0
  115. package/src/runtime/types.ts +18 -0
  116. package/src/startup/SessionMetadataHydrator.ts +2 -2
  117. package/src/startup/StartupNotifier.ts +1 -0
  118. package/src/state/StateStore.ts +29 -15
  119. package/src/supervision/SafeRestartScheduler.ts +5 -0
@@ -2,6 +2,7 @@ import { createHash, randomUUID } from "node:crypto";
2
2
  import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
+ import { cliText } from "./i18n.js";
5
6
 
6
7
  const SKILL_NAME = "agent-bot";
7
8
  const MARKER_FILE = ".agent-bot-managed.json";
@@ -65,7 +66,10 @@ export class SkillRegistry {
65
66
  this.assertValidSource();
66
67
  const existing = fs.existsSync(this.targetPath);
67
68
  if (existing && this.readMarker()?.managedBy !== "agent-bot") {
68
- throw new Error(`The target directory exists and is not managed by Agent Bot: ${this.targetPath}`);
69
+ throw new Error(cliText(
70
+ `The target directory exists and is not managed by Agent Bot: ${this.targetPath}`,
71
+ `目标目录已存在且不由 Agent Bot 管理:${this.targetPath}`,
72
+ ));
69
73
  }
70
74
 
71
75
  const before = existing ? this.status() : undefined;
@@ -93,7 +97,10 @@ export class SkillRegistry {
93
97
  uninstall(): boolean {
94
98
  if (!fs.existsSync(this.targetPath)) return false;
95
99
  if (this.readMarker()?.managedBy !== "agent-bot") {
96
- throw new Error(`Refusing to remove a directory that is not managed by Agent Bot: ${this.targetPath}`);
100
+ throw new Error(cliText(
101
+ `Refusing to remove a directory that is not managed by Agent Bot: ${this.targetPath}`,
102
+ `拒绝删除不由 Agent Bot 管理的目录:${this.targetPath}`,
103
+ ));
97
104
  }
98
105
  this.removeManagedTarget();
99
106
  return true;
@@ -101,13 +108,19 @@ export class SkillRegistry {
101
108
 
102
109
  private assertValidSource(): void {
103
110
  if (!fs.existsSync(path.join(this.sourcePath, "SKILL.md"))) {
104
- throw new Error(`The built-in Agent Bot Skill was not found: ${this.sourcePath}`);
111
+ throw new Error(cliText(
112
+ `The built-in Agent Bot Skill was not found: ${this.sourcePath}`,
113
+ `未找到内置 Agent Bot Skill:${this.sourcePath}`,
114
+ ));
105
115
  }
106
116
  }
107
117
 
108
118
  private assertSafeTarget(): void {
109
119
  if (path.dirname(this.targetPath) !== this.skillsRoot || path.basename(this.targetPath) !== SKILL_NAME) {
110
- throw new Error(`Unsafe Skill target path: ${this.targetPath}`);
120
+ throw new Error(cliText(
121
+ `Unsafe Skill target path: ${this.targetPath}`,
122
+ `不安全的 Skill 目标路径:${this.targetPath}`,
123
+ ));
111
124
  }
112
125
  }
113
126
 
@@ -1,9 +1,12 @@
1
1
  import qrcode from "qrcode-terminal";
2
+ import { cliText, type CliLanguage } from "./i18n.js";
2
3
 
3
4
  export interface VerificationOutputOptions {
4
5
  verificationUrl: string;
5
6
  json: boolean;
6
7
  qrInstruction: string;
8
+ linkLabel?: string;
9
+ language?: CliLanguage;
7
10
  }
8
11
 
9
12
  export function printVerificationQrAndLink(
@@ -18,5 +21,5 @@ export function printVerificationQrAndLink(
18
21
  write(`\n${options.qrInstruction}\n\n`);
19
22
  renderQr(options.verificationUrl, (output) => write(`${output}\n`));
20
23
  }
21
- write(`Authorization link:\n${options.verificationUrl}\n\n`);
24
+ write(`${options.linkLabel ?? cliText("Authorization link", "授权链接", options.language)}${cliText(":", ":", options.language)}\n${options.verificationUrl}\n\n`);
22
25
  }
package/src/cli/help.ts CHANGED
@@ -1,4 +1,53 @@
1
- export function renderCliHelp(version: string): string {
1
+ import { cliLanguage, type CliLanguage } from "./i18n.js";
2
+
3
+ export function renderCliHelp(version: string, language: CliLanguage = cliLanguage): string {
4
+ if (language === "zh") {
5
+ return `Agent Bot ${version}
6
+ 通过飞书使用本地 Codex 和 ACP Agent。
7
+
8
+ 用法:
9
+ agent-bot [选项] <命令>
10
+
11
+ 常用命令:
12
+ init 初始化飞书应用并启动服务
13
+ init --reset 重置并重新配置显式指定的 Profile
14
+ console 打开本地控制台
15
+ server start 在后台启动 Agent Bot
16
+ server status 显示服务、飞书 App ID 和安全重启状态
17
+ server restart 安排安全重启
18
+ server stop 停止 Agent Bot
19
+ task list 列出任务
20
+ task status <任务> 显示任务状态
21
+ task chat <任务> 显示任务绑定的飞书会话
22
+ task prompt <任务> <提示词> 向任务发送提示词
23
+ task stop <任务> 停止任务
24
+ task title <任务> <标题> 重命名任务
25
+ skills status 显示内置 Skill 状态
26
+ skills install 安装内置 Skill
27
+
28
+ 选项:
29
+ --profile <目录> 使用独立的 Profile 目录
30
+ --config <路径> 使用指定的配置文件
31
+ --json 在支持时输出 JSON
32
+ -h, --help 显示帮助
33
+ -v, --version 显示版本
34
+
35
+ 初始化选项:
36
+ --reset 备份并重置显式指定的 Profile
37
+ --skip-feishu 仅初始化 Console 环境
38
+ --reconfigure-feishu 仅替换现有飞书凭据
39
+
40
+ 示例:
41
+ agent-bot init
42
+ agent-bot --profile ~/.agent-bot init --reset
43
+ agent-bot --profile ~/.agent-bot-rescue init
44
+ agent-bot server start
45
+ agent-bot server status
46
+ agent-bot task list
47
+ agent-bot server restart --reason "更新 Agent Bot"
48
+ `;
49
+ }
50
+
2
51
  return `Agent Bot ${version}
3
52
  Use local Codex and ACP agents from Lark/Feishu.
4
53
 
@@ -0,0 +1,38 @@
1
+ export type CliLanguage = "en" | "zh";
2
+
3
+ export function detectCliLanguage(locale = systemLocale()): CliLanguage {
4
+ return /^zh(?:[-_]|$)/i.test(locale.trim()) ? "zh" : "en";
5
+ }
6
+
7
+ export const cliLanguage = detectCliLanguage();
8
+
9
+ export function cliText(
10
+ english: string,
11
+ chinese: string,
12
+ language: CliLanguage = cliLanguage,
13
+ ): string {
14
+ return language === "zh" ? chinese : english;
15
+ }
16
+
17
+ export function localizeCliErrorMessage(
18
+ message: string,
19
+ language: CliLanguage = cliLanguage,
20
+ ): string {
21
+ if (language !== "zh") return message;
22
+
23
+ const missingConfig = /^Config file does not exist: (.+)$/u.exec(message);
24
+ if (missingConfig) return `配置文件不存在:${missingConfig[1]}`;
25
+
26
+ const missingAgent = /^Default agent "(.+)" is not configured\.$/u.exec(message);
27
+ if (missingAgent) return `默认 Agent“${missingAgent[1]}”尚未配置。`;
28
+
29
+ return message;
30
+ }
31
+
32
+ function systemLocale(): string {
33
+ try {
34
+ return Intl.DateTimeFormat().resolvedOptions().locale || "en";
35
+ } catch {
36
+ return "en";
37
+ }
38
+ }
@@ -12,7 +12,10 @@ export function parseInitCommandOptions(
12
12
  const supported = new Set(["--json", "--skip-feishu", "--reconfigure-feishu", "--reset"]);
13
13
  const unsupported = input.filter((value) => !supported.has(value));
14
14
  if (unsupported.length > 0) {
15
- throw new Error(`Unsupported init options: ${unsupported.join(" ")}`);
15
+ throw new Error(cliText(
16
+ `Unsupported init options: ${unsupported.join(" ")}`,
17
+ `不支持的 init 选项:${unsupported.join(" ")}`,
18
+ ));
16
19
  }
17
20
  const options = {
18
21
  json: input.includes("--json"),
@@ -21,13 +24,23 @@ export function parseInitCommandOptions(
21
24
  reset: input.includes("--reset"),
22
25
  };
23
26
  if (options.skipFeishu && options.reconfigureFeishu) {
24
- throw new Error("--skip-feishu and --reconfigure-feishu cannot be used together.");
27
+ throw new Error(cliText(
28
+ "--skip-feishu and --reconfigure-feishu cannot be used together.",
29
+ "--skip-feishu 和 --reconfigure-feishu 不能同时使用。",
30
+ ));
25
31
  }
26
32
  if (options.reset && !explicitProfile) {
27
- throw new Error("--reset requires an explicit --profile <directory>.");
33
+ throw new Error(cliText(
34
+ "--reset requires an explicit --profile <directory>.",
35
+ "--reset 需要显式指定 --profile <目录>。",
36
+ ));
28
37
  }
29
38
  if (options.reset && options.reconfigureFeishu) {
30
- throw new Error("--reset cannot be combined with --reconfigure-feishu because reset already replaces Lark credentials.");
39
+ throw new Error(cliText(
40
+ "--reset cannot be combined with --reconfigure-feishu because reset already replaces Lark credentials.",
41
+ "--reset 不能与 --reconfigure-feishu 同时使用,因为重置已经会替换飞书凭据。",
42
+ ));
31
43
  }
32
44
  return options;
33
45
  }
46
+ import { cliText } from "./i18n.js";
@@ -1,4 +1,5 @@
1
1
  import fs from "node:fs";
2
+ import { cliText } from "./i18n.js";
2
3
  import { fileURLToPath } from "node:url";
3
4
 
4
5
  export function readPackageVersion(
@@ -8,7 +9,10 @@ export function readPackageVersion(
8
9
  fs.readFileSync(fileURLToPath(packageJsonUrl), "utf8"),
9
10
  ) as { version?: unknown };
10
11
  if (typeof metadata.version !== "string" || !metadata.version.trim()) {
11
- throw new Error("package.json does not contain a valid version.");
12
+ throw new Error(cliText(
13
+ "package.json does not contain a valid version.",
14
+ "package.json 中不包含有效版本号。",
15
+ ));
12
16
  }
13
17
  return metadata.version;
14
18
  }
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { cliText } from "./i18n.js";
2
3
  import {
3
4
  AGENT_BOT_EXPLICIT_PROFILE_ENV,
4
5
  AGENT_BOT_HOME_ENV,
@@ -22,7 +23,10 @@ export function parseGlobalOptions(input: string[]): ParsedGlobalOptions {
22
23
  const configPath = removeOption(args, "--config");
23
24
  const profilePath = removeOption(args, "--profile");
24
25
  if (configPath && profilePath) {
25
- throw new Error("--profile and --config cannot be used together. A profile always uses config.yaml in its directory.");
26
+ throw new Error(cliText(
27
+ "--profile and --config cannot be used together. A profile always uses config.yaml in its directory.",
28
+ "--profile 和 --config 不能同时使用。Profile 始终使用其目录中的 config.yaml。",
29
+ ));
26
30
  }
27
31
  return {
28
32
  args,
@@ -49,11 +53,17 @@ export function applyExplicitProfile(
49
53
 
50
54
  function removeOption(args: string[], option: string): string | undefined {
51
55
  const indexes = args.flatMap((value, index) => value === option ? [index] : []);
52
- if (indexes.length > 1) throw new Error(`${option} can only be specified once.`);
56
+ if (indexes.length > 1) throw new Error(cliText(
57
+ `${option} can only be specified once.`,
58
+ `${option} 只能指定一次。`,
59
+ ));
53
60
  const index = indexes[0];
54
61
  if (index === undefined) return undefined;
55
62
  const value = args[index + 1];
56
- if (!value || value.startsWith("--")) throw new Error(`${option} requires a directory or file path.`);
63
+ if (!value || value.startsWith("--")) throw new Error(cliText(
64
+ `${option} requires a directory or file path.`,
65
+ `${option} 需要目录或文件路径。`,
66
+ ));
57
67
  args.splice(index, 2);
58
68
  return value;
59
69
  }
@@ -12,28 +12,33 @@ export function withConfiguredFeishuAppId(
12
12
  };
13
13
  }
14
14
 
15
- export function formatServerStatus(data: unknown): string {
15
+ export function formatServerStatus(data: unknown, language: CliLanguage = cliLanguage): string {
16
16
  const value = data && typeof data === "object" ? data as Record<string, unknown> : {};
17
17
  const activity = value.activity && typeof value.activity === "object"
18
18
  ? value.activity as Record<string, unknown>
19
19
  : {};
20
20
  const state = value.running === false
21
- ? "not running"
21
+ ? cliText("not running", "未运行", language)
22
22
  : value.ready === false
23
- ? "starting (connecting to Lark)"
24
- : "running";
23
+ ? cliText("starting (connecting to Lark)", "正在启动(连接飞书中)", language)
24
+ : cliText("running", "运行中", language);
25
25
  const safeRestart = value.safeRestartScheduled
26
- ? `pending (${String(value.safeRestartReason ?? "no reason provided")})`
27
- : "not scheduled";
26
+ ? cliText(
27
+ `pending (${String(value.safeRestartReason ?? "no reason provided")})`,
28
+ `等待中(${String(value.safeRestartReason ?? "未提供原因")})`,
29
+ language,
30
+ )
31
+ : cliText("not scheduled", "未计划", language);
28
32
  return [
29
- `Agent Bot server: ${state}`,
30
- `Lark App ID: ${value.feishuAppId ?? "not configured"}`,
31
- `PID: ${value.pid ?? "-"}`,
32
- `Started at: ${value.startedAt ?? "-"}`,
33
- `Supervisor: ${value.supervised ? "enabled" : "disabled"}`,
34
- `Running tasks: ${activity.runningSessions ?? 0}`,
35
- `Pending final deliveries: ${activity.pendingFinalDeliveries ?? 0}`,
36
- `Safe restart: ${safeRestart}`,
33
+ `${cliText("Agent Bot server: ", "Agent Bot 服务:", language)}${state}`,
34
+ `${cliText("Lark App ID: ", "飞书 App ID:", language)}${value.feishuAppId ?? cliText("not configured", "未配置", language)}`,
35
+ `${cliText("PID: ", "PID:", language)}${value.pid ?? "-"}`,
36
+ `${cliText("Started at: ", "启动时间:", language)}${value.startedAt ?? "-"}`,
37
+ `${cliText("Supervisor: ", "Supervisor:", language)}${value.supervised ? cliText("enabled", "已启用", language) : cliText("disabled", "未启用", language)}`,
38
+ `${cliText("Running tasks: ", "运行中任务:", language)}${activity.runningSessions ?? 0}`,
39
+ `${cliText("Pending final deliveries: ", "待发送最终结果:", language)}${activity.pendingFinalDeliveries ?? 0}`,
40
+ `${cliText("Safe restart: ", "安全重启:", language)}${safeRestart}`,
37
41
  "",
38
42
  ].join("\n");
39
43
  }
44
+ import { cliLanguage, cliText, type CliLanguage } from "./i18n.js";
@@ -1,5 +1,6 @@
1
1
  import { baseChatContextKey, isThreadContextKey } from "../feishu/contextKey.js";
2
2
  import type { SessionRecord } from "../state/StateStore.js";
3
+ import { cliText } from "./i18n.js";
3
4
 
4
5
  const CHAT_CONTEXT_PREFIX = "chat_id:";
5
6
  const THREAD_CONTEXT_MARKER = ":thread_id:";
@@ -15,10 +16,16 @@ export function taskChatRoute(session: SessionRecord): TaskChatRoute {
15
16
  const contextKey = session.contextKey;
16
17
  const baseContextKey = baseChatContextKey(contextKey);
17
18
  if (!baseContextKey.startsWith(CHAT_CONTEXT_PREFIX)) {
18
- throw new Error(`The task is not bound to a Lark chat: ${session.remoteSessionId ?? session.acpSessionId ?? session.localSessionId}`);
19
+ throw new Error(cliText(
20
+ `The task is not bound to a Lark chat: ${session.remoteSessionId ?? session.acpSessionId ?? session.localSessionId}`,
21
+ `任务未绑定飞书会话:${session.remoteSessionId ?? session.acpSessionId ?? session.localSessionId}`,
22
+ ));
19
23
  }
20
24
  const chatId = baseContextKey.slice(CHAT_CONTEXT_PREFIX.length);
21
- if (!chatId) throw new Error(`The task has an invalid Lark chat ID: ${contextKey}`);
25
+ if (!chatId) throw new Error(cliText(
26
+ `The task has an invalid Lark chat ID: ${contextKey}`,
27
+ `任务的飞书会话 ID 无效:${contextKey}`,
28
+ ));
22
29
  const threadId = isThreadContextKey(contextKey)
23
30
  ? contextKey.slice(contextKey.indexOf(THREAD_CONTEXT_MARKER) + THREAD_CONTEXT_MARKER.length)
24
31
  : undefined;