@keyou007/agent-bot 0.1.11 → 0.1.12

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 (82) hide show
  1. package/.env.example +1 -1
  2. package/CHANGELOG.md +10 -0
  3. package/README.md +41 -35
  4. package/README.zh.md +41 -35
  5. package/config.example.yaml +11 -1
  6. package/dist/cli/FeishuAppConfiguration.js +1 -1
  7. package/dist/cli/FeishuAppConfiguration.js.map +1 -1
  8. package/dist/cli/FeishuAppRegistration.js +2 -2
  9. package/dist/cli/FeishuAppRegistration.js.map +1 -1
  10. package/dist/cli/Initializer.js +1 -1
  11. package/dist/cli/Initializer.js.map +1 -1
  12. package/dist/cli/ServerStarter.js +7 -2
  13. package/dist/cli/ServerStarter.js.map +1 -1
  14. package/dist/cli/controlProtocol.js.map +1 -1
  15. package/dist/cli/help.js +20 -16
  16. package/dist/cli/help.js.map +1 -1
  17. package/dist/cli/taskGroupOptions.js +95 -0
  18. package/dist/cli/taskGroupOptions.js.map +1 -0
  19. package/dist/cli.js +74 -2
  20. package/dist/cli.js.map +1 -1
  21. package/dist/codex/CodexRuntime.js +35 -9
  22. package/dist/codex/CodexRuntime.js.map +1 -1
  23. package/dist/config/loadConfig.js +11 -1
  24. package/dist/config/loadConfig.js.map +1 -1
  25. package/dist/config/schema.js +6 -1
  26. package/dist/config/schema.js.map +1 -1
  27. package/dist/console/ConsoleConnector.js +1 -1
  28. package/dist/console/ConsoleConnector.js.map +1 -1
  29. package/dist/console/ConsoleTurnPresenter.js +14 -7
  30. package/dist/console/ConsoleTurnPresenter.js.map +1 -1
  31. package/dist/deprecated-cli.js +5 -0
  32. package/dist/deprecated-cli.js.map +1 -0
  33. package/dist/feishu/CardRenderer.js +5 -4
  34. package/dist/feishu/CardRenderer.js.map +1 -1
  35. package/dist/feishu/FeishuTurnPresenter.js +9 -5
  36. package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
  37. package/dist/feishu/transport.js +1 -1
  38. package/dist/feishu/transport.js.map +1 -1
  39. package/dist/index.js +20 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/presentation/OutboundRouter.js +2 -2
  42. package/dist/presentation/OutboundRouter.js.map +1 -1
  43. package/dist/presentation/TurnStateReducer.js +2 -1
  44. package/dist/presentation/TurnStateReducer.js.map +1 -1
  45. package/dist/proxy/ProxySessionController.js +78 -22
  46. package/dist/proxy/ProxySessionController.js.map +1 -1
  47. package/dist/runtime/createAgentRuntimeRegistry.js +1 -1
  48. package/dist/runtime/createAgentRuntimeRegistry.js.map +1 -1
  49. package/dist/supervision/systemEnvironment.js +129 -0
  50. package/dist/supervision/systemEnvironment.js.map +1 -0
  51. package/dist/supervisor.js +13 -1
  52. package/dist/supervisor.js.map +1 -1
  53. package/docs/technical-reference.md +21 -17
  54. package/docs/technical-reference.zh.md +21 -17
  55. package/npm-shrinkwrap.json +4 -3
  56. package/package.json +3 -2
  57. package/skills/agent-bot/SKILL.md +61 -28
  58. package/src/cli/FeishuAppConfiguration.ts +2 -2
  59. package/src/cli/FeishuAppRegistration.ts +4 -4
  60. package/src/cli/Initializer.ts +2 -2
  61. package/src/cli/ServerStarter.ts +8 -3
  62. package/src/cli/controlProtocol.ts +21 -1
  63. package/src/cli/help.ts +20 -16
  64. package/src/cli/taskGroupOptions.ts +149 -0
  65. package/src/cli.ts +98 -4
  66. package/src/codex/CodexRuntime.ts +46 -13
  67. package/src/config/loadConfig.ts +11 -1
  68. package/src/config/schema.ts +7 -1
  69. package/src/console/ConsoleConnector.ts +1 -1
  70. package/src/console/ConsoleTurnPresenter.ts +20 -7
  71. package/src/deprecated-cli.ts +9 -0
  72. package/src/feishu/CardRenderer.ts +5 -4
  73. package/src/feishu/FeishuTurnPresenter.ts +15 -1
  74. package/src/feishu/transport.ts +1 -1
  75. package/src/index.ts +33 -2
  76. package/src/presentation/OutboundRouter.ts +15 -3
  77. package/src/presentation/TurnStateReducer.ts +2 -0
  78. package/src/presentation/turnViewTypes.ts +1 -0
  79. package/src/proxy/ProxySessionController.ts +166 -22
  80. package/src/runtime/createAgentRuntimeRegistry.ts +1 -1
  81. package/src/supervision/systemEnvironment.ts +174 -0
  82. package/src/supervisor.ts +12 -1
@@ -8,7 +8,7 @@ export function createAgentRuntimeRegistry(config, logger) {
8
8
  const runtimes = {};
9
9
  for (const [agentName, agent] of Object.entries(config.agents)) {
10
10
  const runtimeLogger = logger.child({ agentName, runtimeKind: agent.kind });
11
- if (agent.kind === "codex") {
11
+ if (agent.kind === "app-server") {
12
12
  const processManager = new CodexProcessManager(agent.command, agent.args, agent.env, runtimeLogger);
13
13
  runtimes[agentName] = new CodexRuntime(processManager, runtimeLogger);
14
14
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"createAgentRuntimeRegistry.js","sourceRoot":"","sources":["../../src/runtime/createAgentRuntimeRegistry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,UAAU,0BAA0B,CAAC,MAAiB,EAAE,MAAc;IAC1E,MAAM,QAAQ,GAAiC,EAAE,CAAC;IAClD,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/D,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3E,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;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AE,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3E,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAChC,MAAM,cAAc,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;YACpG,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,YAAY,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;YACtE,SAAS;QACX,CAAC;QACD,MAAM,cAAc,GAAG,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAC5D,MAAM,cAAc,GAAG,IAAI,iBAAiB,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;QAC9F,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,129 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import path from "node:path";
3
+ const PROCESS_LOCAL_ENVIRONMENT_PREFIXES = ["AGENT_BOT_", "FEISHU_"];
4
+ export function refreshedSystemEnvironment(inherited = process.env, platform = process.platform, loadWindowsEnvironment = readWindowsEnvironment) {
5
+ const fallback = { ...inherited };
6
+ if (platform !== "win32") {
7
+ return { environment: fallback, refreshed: false, pathChanged: false };
8
+ }
9
+ try {
10
+ const snapshot = loadWindowsEnvironment();
11
+ const environment = mergeWindowsEnvironment(inherited, snapshot);
12
+ return {
13
+ environment,
14
+ refreshed: true,
15
+ pathChanged: environmentValue(environment, "Path") !== environmentValue(inherited, "Path"),
16
+ };
17
+ }
18
+ catch (error) {
19
+ return {
20
+ environment: fallback,
21
+ refreshed: false,
22
+ pathChanged: false,
23
+ error: error instanceof Error ? error.message : String(error),
24
+ };
25
+ }
26
+ }
27
+ export function mergeWindowsEnvironment(inherited, snapshot) {
28
+ const environment = { ...inherited };
29
+ applyEnvironment(environment, snapshot.machine);
30
+ applyEnvironment(environment, snapshot.user);
31
+ const machinePath = environmentValue(snapshot.machine, "Path")?.trim();
32
+ const userPath = environmentValue(snapshot.user, "Path")?.trim();
33
+ if (machinePath || userPath) {
34
+ const inheritedPath = environmentValue(inherited, "Path")?.trim();
35
+ setEnvironmentValue(environment, "Path", mergePathValues(expandEnvironmentReferences([machinePath, userPath, inheritedPath].filter(Boolean).join(";"), environment)));
36
+ }
37
+ return environment;
38
+ }
39
+ function readWindowsEnvironment() {
40
+ const systemRoot = process.env.SystemRoot ?? "C:\\Windows";
41
+ const executable = path.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
42
+ const script = [
43
+ "[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)",
44
+ "$machine = @{}",
45
+ "foreach ($entry in [Environment]::GetEnvironmentVariables([EnvironmentVariableTarget]::Machine).GetEnumerator()) { $machine[[string]$entry.Key] = [string]$entry.Value }",
46
+ "$user = @{}",
47
+ "foreach ($entry in [Environment]::GetEnvironmentVariables([EnvironmentVariableTarget]::User).GetEnumerator()) { $user[[string]$entry.Key] = [string]$entry.Value }",
48
+ "[pscustomobject]@{ machine = $machine; user = $user } | ConvertTo-Json -Compress -Depth 3",
49
+ ].join("; ");
50
+ const result = spawnSync(executable, [
51
+ "-NoLogo",
52
+ "-NoProfile",
53
+ "-NonInteractive",
54
+ "-ExecutionPolicy",
55
+ "Bypass",
56
+ "-Command",
57
+ script,
58
+ ], {
59
+ encoding: "utf8",
60
+ windowsHide: true,
61
+ timeout: 5_000,
62
+ maxBuffer: 8 * 1024 * 1024,
63
+ });
64
+ if (result.error)
65
+ throw result.error;
66
+ if (result.status !== 0) {
67
+ throw new Error(result.stderr.trim() || `PowerShell exited with code ${result.status ?? "unknown"}.`);
68
+ }
69
+ const parsed = JSON.parse(result.stdout);
70
+ return {
71
+ machine: environmentRecord(parsed.machine),
72
+ user: environmentRecord(parsed.user),
73
+ };
74
+ }
75
+ function environmentRecord(value) {
76
+ if (!value || typeof value !== "object" || Array.isArray(value))
77
+ return {};
78
+ return Object.fromEntries(Object.entries(value).flatMap(([name, entry]) => typeof entry === "string" ? [[name, entry]] : []));
79
+ }
80
+ function applyEnvironment(target, source) {
81
+ for (const [name, value] of Object.entries(source)) {
82
+ if (name.toLowerCase() === "path" || isProcessLocalEnvironmentName(name))
83
+ continue;
84
+ setEnvironmentValue(target, name, value);
85
+ }
86
+ }
87
+ function isProcessLocalEnvironmentName(name) {
88
+ const normalized = name.toUpperCase();
89
+ return PROCESS_LOCAL_ENVIRONMENT_PREFIXES.some((prefix) => normalized.startsWith(prefix));
90
+ }
91
+ function setEnvironmentValue(environment, name, value) {
92
+ for (const existingName of Object.keys(environment)) {
93
+ if (existingName !== name && existingName.toLowerCase() === name.toLowerCase()) {
94
+ delete environment[existingName];
95
+ }
96
+ }
97
+ environment[name] = value;
98
+ }
99
+ function environmentValue(environment, name) {
100
+ const key = Object.keys(environment).find((candidate) => candidate.toLowerCase() === name.toLowerCase());
101
+ return key === undefined ? undefined : environment[key];
102
+ }
103
+ function expandEnvironmentReferences(value, environment) {
104
+ let expanded = value;
105
+ for (let attempt = 0; attempt < 5; attempt += 1) {
106
+ const next = expanded.replace(/%([^%]+)%/g, (match, name) => environmentValue(environment, name) ?? match);
107
+ if (next === expanded)
108
+ break;
109
+ expanded = next;
110
+ }
111
+ return expanded;
112
+ }
113
+ function mergePathValues(value) {
114
+ const seen = new Set();
115
+ return value
116
+ .split(";")
117
+ .map((entry) => entry.trim())
118
+ .filter((entry) => {
119
+ if (!entry)
120
+ return false;
121
+ const normalized = entry.replace(/[\\/]+$/, "").toLowerCase();
122
+ if (seen.has(normalized))
123
+ return false;
124
+ seen.add(normalized);
125
+ return true;
126
+ })
127
+ .join(";");
128
+ }
129
+ //# sourceMappingURL=systemEnvironment.js.map
@@ -0,0 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AC,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE,CAClE,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC;QAChD,IAAI,IAAI,KAAK,QAAQ;YAAE,MAAM;QAC7B,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC5B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACzB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9D,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,OAAO,KAAK,CAAC;QACvC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
@@ -6,6 +6,7 @@ import { loadConfig } from "./config/loadConfig.js";
6
6
  import { requireServerFeishuTransport } from "./feishu/transport.js";
7
7
  import { crashRestartDelayMs, describeRestartReason, INTENTIONAL_RESTART_DELAY_MS, RESTART_EXIT_CODE, STABLE_UPTIME_MS, STOP_EXIT_CODE, } from "./supervision/restartPolicy.js";
8
8
  import { SupervisorDiagnostics, nodeDiagnosticReportArguments } from "./supervision/SupervisorDiagnostics.js";
9
+ import { refreshedSystemEnvironment } from "./supervision/systemEnvironment.js";
9
10
  const childEntry = fileURLToPath(new URL("./index.js", import.meta.url));
10
11
  const config = loadConfig();
11
12
  requireServerFeishuTransport(config.feishu);
@@ -30,13 +31,24 @@ async function startChild() {
30
31
  const restartReason = nextStartReason;
31
32
  nextStartReason = "Supervisor 重新拉起进程";
32
33
  const workerStderr = diagnostics.openWorkerStderr();
34
+ const environmentRefresh = refreshedSystemEnvironment();
35
+ if (environmentRefresh.error) {
36
+ writeSupervisorLog("environment_refresh_failed", { error: environmentRefresh.error });
37
+ }
38
+ else if (environmentRefresh.refreshed) {
39
+ writeSupervisorLog("environment_refreshed", { pathChanged: environmentRefresh.pathChanged });
40
+ }
33
41
  try {
34
42
  child = spawn(process.execPath, [
35
43
  ...nodeDiagnosticReportArguments(diagnostics.paths.crashReportDirectory),
36
44
  childEntry,
37
45
  ], {
38
46
  cwd: process.cwd(),
39
- env: { ...process.env, AGENT_BOT_SUPERVISED: "1", AGENT_BOT_RESTART_REASON: restartReason },
47
+ env: {
48
+ ...environmentRefresh.environment,
49
+ AGENT_BOT_SUPERVISED: "1",
50
+ AGENT_BOT_RESTART_REASON: restartReason,
51
+ },
40
52
  stdio: ["ignore", "ignore", workerStderr],
41
53
  windowsHide: true,
42
54
  });
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.js","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,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AAC,CAAC;AAC9D,CAAC;AAED,SAAS,IAAI,CAAC,MAAsB;IAClC,IAAI,QAAQ;QAAE,OAAO;IACrB,QAAQ,GAAG,IAAI,CAAC;IAChB,IAAI,YAAY;QAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAC7C,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa,EAAE,IAA6B;IACtE,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC3C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;AAC7C,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,CAAC,CAAC;AACzE,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;IAC1D,YAAY,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,UAAU,EAAE,EAAE,cAAc,CAAC,CAAC;AACrE,CAAC;KAAM,CAAC;IACN,KAAK,UAAU,EAAE,CAAC;AACpB,CAAC"}
@@ -12,7 +12,7 @@ Agent Bot is a Node.js 22+ ESM TypeScript application built around these compone
12
12
  - The worker starts the configured Codex and ACP runtimes, Feishu transport, Console transport, local control server, and SQLite store.
13
13
  - Feishu events and Console input are normalized into the same task controller.
14
14
  - Presentation components maintain one progress card per turn and send the final Markdown response separately.
15
- - Codex agents use Codex App Server over stdio; other configured agents use ACP.
15
+ - App Server agents use the App Server protocol over stdio; other configured agents use ACP.
16
16
 
17
17
  Relevant source areas:
18
18
 
@@ -35,7 +35,7 @@ The default user-data root is `~/.agent-bot`. `AGENT_BOT_HOME` replaces that roo
35
35
 
36
36
  The CLI also supports explicit directory-based profiles. Without `--profile`, commands use the main profile and the normal environment-based path rules. `--profile <directory>` pins both `AGENT_BOT_HOME` and `AGENT_BOT_CONFIG` for the command and every spawned supervisor or worker, with the configuration fixed at `<directory>/config.yaml`. It also clears inherited Feishu credential variables before loading the selected profile's `.env`, which prevents a secondary service launched from inside the primary Agent Bot process tree from accidentally reusing the primary bot. It cannot be combined with `--config`. Alternative profiles must be selected explicitly on every command; Agent Bot does not maintain a named-profile registry.
37
37
 
38
- The CLI reads the system locale through Node.js internationalization support. Locales beginning with `zh` use Chinese interface text; English and every unsupported locale use English. This applies to help, status, progress, prompts, and CLI-owned errors. JSON field names and enum values are not localized. System-generated restart reasons remain Chinese because they are rendered in Chinese Lark status cards; an explicit `--reason` is preserved verbatim. `agent-bot server status` reports the running worker's Lark App ID as `feishuAppId` in JSON; when the server is stopped or predates that health field, the CLI falls back to the selected profile's configured App ID.
38
+ The CLI reads the system locale through Node.js internationalization support. Locales beginning with `zh` use Chinese interface text; English and every unsupported locale use English. This applies to help, status, progress, prompts, and CLI-owned errors. JSON field names and enum values are not localized. System-generated restart reasons remain Chinese because they are rendered in Chinese Lark status cards; an explicit `--reason` is preserved verbatim. `agentbot server status` reports the running worker's Lark App ID as `feishuAppId` in JSON; when the server is stopped or predates that health field, the CLI falls back to the selected profile's configured App ID.
39
39
 
40
40
  | Default path | Contents |
41
41
  | ------------------------------------ | ---------------------------------- |
@@ -58,7 +58,7 @@ Relative `storage.sqlitePath` and `logging.path` values resolve against the dire
58
58
 
59
59
  ## Initialization
60
60
 
61
- `agent-bot init` copies the packaged `config.example.yaml` and `.env.example` when their target files do not exist, creates the data and log directories, and restricts `.env` permissions where the platform supports POSIX modes.
61
+ `agentbot init` copies the packaged `config.example.yaml` and `.env.example` when their target files do not exist, creates the data and log directories, and restricts `.env` permissions where the platform supports POSIX modes.
62
62
 
63
63
  Credential behavior:
64
64
 
@@ -90,9 +90,9 @@ Optional polling failures and timeouts return a partial configuration result ins
90
90
 
91
91
  The generated authorization links do not contain the app secret.
92
92
 
93
- `agent-bot --profile <directory> init --reset` fully resets an explicitly selected Profile. The Profile server must be stopped first. The command moves the active `config.yaml`, `.env`, `data/`, and `logs/` into a unique timestamped directory under `<profile>/.reset-backups/`, creates clean replacements from the packaged templates, and proceeds through normal initialization. Existing reset backups and unrelated files are retained. Because backups can contain old app secrets and conversation data, protect the Profile directory accordingly. The remote Feishu app is not deleted. `--reset --skip-feishu` creates a clean Console-only Profile, while `--reset` and `--reconfigure-feishu` cannot be combined.
93
+ `agentbot --profile <directory> init --reset` fully resets an explicitly selected Profile. The Profile server must be stopped first. The command moves the active `config.yaml`, `.env`, `data/`, and `logs/` into a unique timestamped directory under `<profile>/.reset-backups/`, creates clean replacements from the packaged templates, and proceeds through normal initialization. Existing reset backups and unrelated files are retained. Because backups can contain old app secrets and conversation data, protect the Profile directory accordingly. The remote Feishu app is not deleted. `--reset --skip-feishu` creates a clean Console-only Profile, while `--reset` and `--reconfigure-feishu` cannot be combined.
94
94
 
95
- After Feishu initialization succeeds, the CLI releases the initialization lock and starts the detached supervisor through the same readiness path as `agent-bot server start`. It waits up to 45 seconds for the worker to connect to Feishu and become ready. If the selected profile is already running, no second supervisor is created. `--skip-feishu` skips automatic server startup, and `--json` includes the resulting `server.status` without adding non-JSON output.
95
+ After Feishu initialization succeeds, the CLI releases the initialization lock and starts the detached supervisor through the same readiness path as `agentbot server start`. It waits up to 45 seconds for the worker to connect to Feishu and become ready. If the selected profile is already running, no second supervisor is created. `--skip-feishu` skips automatic server startup, and `--json` includes the resulting `server.status` without adding non-JSON output.
96
96
 
97
97
  ## Feishu App Requirements
98
98
 
@@ -118,7 +118,7 @@ Optional configuration:
118
118
  | Image and chat permissions | Generated group avatars |
119
119
  | `card.action.trigger` | Interactive card actions |
120
120
 
121
- Optional authorization failures are returned in the final initialization result with the affected feature names. Rerunning `agent-bot init` repeats the audit.
121
+ Optional authorization failures are returned in the final initialization result with the affected feature names. Rerunning `agentbot init` repeats the audit.
122
122
 
123
123
  ## Configuration Model
124
124
 
@@ -136,7 +136,7 @@ console:
136
136
 
137
137
  agents:
138
138
  codex:
139
- kind: "codex"
139
+ kind: "app-server"
140
140
  title: "Codex"
141
141
  command: "codex"
142
142
  args: ["app-server", "--enable", "goals", "--listen", "stdio://"]
@@ -156,7 +156,7 @@ logging:
156
156
 
157
157
  `feishu.respondToAllGroupMessages` defaults to `true`. Set it to `false` to ignore group messages unless they mention the current bot. The worker resolves the bot's Open ID at startup so mentioning another member does not trigger it. Private messages are always accepted. Initialization requests all-user group-message delivery regardless of this runtime option, allowing it to be changed later without another authorization.
158
158
 
159
- `agent-bot server start` requires both Feishu credentials. The worker starts the SDK's persistent connection without inspecting SDK logs or private connection state, then sends startup status cards as an outbound readiness check. Each startup card includes the Agent Bot version read from the installed package metadata. It normally targets known private chats and recently active groups. If the database has no known chat yet, it sends the card to `feishu.userOpenId` using an `open_id` private message. When notification targets exist, at least one card must be delivered before the server reports ready; individual target failures remain isolated. If neither a known chat nor `feishu.userOpenId` is available, startup continues without the outbound check. Missing credentials still fail startup with an initialization hint. `agent-bot console` is the explicit local-only path and does not require Feishu credentials.
159
+ `agentbot server start` requires both Feishu credentials. The worker starts the SDK's persistent connection without inspecting SDK logs or private connection state, then sends startup status cards as an outbound readiness check. Each startup card includes the Agent Bot version read from the installed package metadata. It normally targets known private chats and recently active groups. If the database has no known chat yet, it sends the card to `feishu.userOpenId` using an `open_id` private message. When notification targets exist, at least one card must be delivered before the server reports ready; individual target failures remain isolated. If neither a known chat nor `feishu.userOpenId` is available, startup continues without the outbound check. Missing credentials still fail startup with an initialization hint. `agentbot console` is the explicit local-only path and does not require Feishu credentials.
160
160
 
161
161
  At least one agent must be configured. `defaults.agent` must name a configured agent.
162
162
 
@@ -164,7 +164,7 @@ At least one agent must be configured. `defaults.agent` must name a configured a
164
164
 
165
165
  The configured Agent standard name is the runtime isolation key. Every configured Agent owns a separate, lazily started child process and runtime instance, even when multiple Agents use the same `kind`. Tasks using different Agents never share a command, environment, protocol connection, session map, or event stream. Tasks using the same Agent share that Agent process while keeping separate protocol sessions.
166
166
 
167
- `kind` selects only the connection adapter. An agent with `kind: "codex"` uses its own Codex App Server process. Agent Bot passes project directory, model, reasoning effort, permission mode, text input, and local images through the App Server protocol. `/sessions` aggregates tasks reported by every configured Codex Agent while preserving the owning Agent for Switch, Status, Stop, New, and Fork actions.
167
+ `kind` selects only the connection adapter. An agent with `kind: "app-server"` uses its own App Server process, whether the executable is Codex, TraeX, or another compatible product. Agent Bot passes project directory, model, reasoning effort, permission mode, text input, and local images through the App Server protocol. `/sessions` aggregates tasks reported by every configured App Server Agent while preserving the owning Agent for Switch, Status, Stop, New, and Fork actions. The previous `kind: "codex"` value is normalized to `app-server` when existing profiles are loaded.
168
168
 
169
169
  An agent with `kind: "acp"`, or without a `kind`, uses its own ACP process. Multiple tasks create separate ACP sessions on that connection. Agent-specific `env` values are added only to that Agent's environment.
170
170
 
@@ -217,6 +217,8 @@ Incoming rich-text images are downloaded into the inbound image cache and passed
217
217
 
218
218
  Each task entry exposes `NewGroup` and `ForkGroup` callbacks. The callback payload keeps the selected task ID and source context, while the Lark operator `open_id` is used to invite the user to the new group. `NewGroup` resolves the selected task's project and execution settings; `ForkGroup` resolves its latest available completed turn.
219
219
 
220
+ The CLI exposes the same task-targeted operations through `agentbot task newgroup <task> [title] [--agent <name>] [--dir <cwd> | --nodir]` and `agentbot task forkgroup <task> [title]`. Both commands require a running Server and send the stable local task ID over the Profile's local control endpoint. Since a CLI process has no Lark operator, the Server invites `feishu.userOpenId`, which initialization stores as `FEISHU_USER_OPEN_ID`. New-group creation inherits the selected task's Agent and execution settings by default. `--agent <standard-name>` selects another configured runtime while retaining the source project shape; execution settings are omitted so that runtime applies its own defaults. ForkGroup uses the source task's latest available completed turn and leaves an active source turn running. Both control responses include the new chat, group context, source task, and created task; `--json` prints that structure without localization.
221
+
220
222
  ## Codex Provider Settings
221
223
 
222
224
  Provider is a task-level setting stored as `model_provider` alongside model, reasoning effort, and permission mode. Agent Bot passes `modelProvider` through `thread/start`, `thread/resume`, and `thread/fork` whenever a task explicitly inherits or selects one. For a brand-new task with no inherited Provider, Agent Bot omits `modelProvider`; the Codex App Server therefore uses the effective `model_provider` from Codex configuration and returns the selected Provider in its thread response for persistence.
@@ -248,11 +250,13 @@ SQLite stores:
248
250
 
249
251
  On startup, Agent Bot reconciles persisted active work with Codex through `thread/read`. It also reconciles when turn identifiers change, terminal notifications arrive, or control requests fail.
250
252
 
251
- The final-delivery ledger prevents duplicate successful replies. App Server requests use finite timeouts so a stalled request cannot permanently occupy a message route.
253
+ The final-delivery ledger prevents duplicate successful replies. App Server requests use finite timeouts so a stalled request cannot permanently occupy a message route. Session lifecycle requests allow 60 seconds because compatible third-party Agents may need more than 30 seconds for `thread/start`; control requests remain shorter.
252
254
 
253
255
  ## Supervisor And Restart
254
256
 
255
- `agent-bot server start` starts a detached supervisor. The supervisor restarts the worker after unexpected exits and applies exponential backoff from one to 30 seconds after repeated crashes.
257
+ `agentbot server start` starts a detached supervisor. The supervisor restarts the worker after unexpected exits and applies exponential backoff from one to 30 seconds after repeated crashes.
258
+
259
+ On Windows, the CLI refreshes Machine and User environment variables before the initial Supervisor launch, a Worker refreshes them before launching a replacement Supervisor, and the Supervisor refreshes them before every Worker launch. Fresh values override inherited values, while `PATH` retains process-only entries after the current Machine and User paths. `AGENT_BOT_*` and `FEISHU_*` values remain process-local so an active Profile cannot accidentally switch data roots or bot credentials. A registry-read failure falls back to the inherited environment without blocking startup and is recorded when a runtime logger is available.
256
260
 
257
261
  Supervisor crash diagnostics are isolated to the selected profile:
258
262
 
@@ -275,7 +279,7 @@ The first safe-restart status card is delayed by three seconds so a task's final
275
279
 
276
280
  Pending safe-restart cards include a bottom `Cancel` action. The action carries the scheduler's monotonic schedule ID, so an old card cannot cancel a newer restart. A successful cancellation updates every existing status card in place and removes the action; the action is also absent once the scheduler enters the irreversible restarting phase.
277
281
 
278
- The local control server implements task mutations and service restart requests. Read-only task queries access SQLite directly.
282
+ The local control server implements task mutations, task-targeted NewGroup and ForkGroup operations, and service restart requests. Read-only task queries access SQLite directly.
279
283
 
280
284
  ## Permission Modes
281
285
 
@@ -289,16 +293,16 @@ Model, reasoning effort, permission mode, and project shape are inherited where
289
293
  The packaged Agent Bot skill can be installed into the shared agent skill directory:
290
294
 
291
295
  ```powershell
292
- agent-bot skills install
293
- agent-bot skills status
294
- agent-bot skills uninstall
296
+ agentbot skills install
297
+ agentbot skills status
298
+ agentbot skills uninstall
295
299
  ```
296
300
 
297
301
  The default target is `~/.agents/skills`. `AGENT_BOT_SKILLS_DIR` or `--target` selects another root. Installation is a managed copy; uninstall does not remove an unrelated same-named directory.
298
302
 
299
303
  ## npm Package And Releases
300
304
 
301
- The public package is `@keyou007/agent-bot`; its executable remains `agent-bot`. The package uses a `files` allowlist so runtime code, templates, the managed skill, source code, and user-facing documentation are published without tests or internal design plans.
305
+ The public package is `@keyou007/agent-bot`; its primary executable is `agentbot`. The deprecated `agent-bot` executable remains as a forwarding compatibility entry and prints a localized warning before each invocation. The package uses a `files` allowlist so runtime code, templates, the managed skill, source code, and user-facing documentation are published without tests or internal design plans.
302
306
 
303
307
  `npm-shrinkwrap.json` is published with the CLI to keep transitive runtime dependencies reproducible. Direct runtime and development dependencies are also pinned to exact versions.
304
308
 
@@ -343,4 +347,4 @@ npm run build
343
347
  npm link
344
348
  ```
345
349
 
346
- `npm link` registers the checkout's `agent-bot` executable globally. Without it, built CLI commands can be invoked through `npm run cli --`. `npm run dev` runs one foreground worker, while `npm start` runs the supervisor in the current terminal.
350
+ `npm link` registers the checkout's `agentbot` executable and deprecated `agent-bot` compatibility executable globally. Without it, built CLI commands can be invoked through `npm run cli --`. `npm run dev` runs one foreground worker, while `npm start` runs the supervisor in the current terminal.
@@ -12,7 +12,7 @@ Agent Bot 是基于 Node.js 22+、ESM 和 TypeScript 的应用,主要组件如
12
12
  - Worker 启动 Codex/ACP Runtime、飞书传输、Console 传输、本地控制服务和 SQLite
13
13
  - 飞书事件和 Console 输入统一进入任务控制器
14
14
  - 展示层为每个 turn 维护一张进度卡,并单独发送 Markdown 最终回答
15
- - Codex Agent 通过 stdio 连接 Codex App Server,其他 Agent 使用 ACP
15
+ - App Server Agent 通过 stdio 连接 App Server,其他 Agent 使用 ACP
16
16
 
17
17
  主要源码目录:
18
18
 
@@ -35,7 +35,7 @@ Agent Bot 是基于 Node.js 22+、ESM 和 TypeScript 的应用,主要组件如
35
35
 
36
36
  CLI 还支持显式指定目录的 Profile。不使用 `--profile` 时,命令使用主 Profile 以及原有的环境变量路径规则。`--profile <目录>` 会为当前命令及其启动的 Supervisor、Worker 固定 `AGENT_BOT_HOME` 和 `AGENT_BOT_CONFIG`,配置文件固定为 `<目录>/config.yaml`。它还会先清除继承的飞书凭据环境变量,再加载所选 Profile 的 `.env`,避免从主 Agent Bot 进程树中启动辅助实例时误用主机器人的凭据。`--profile` 不能和 `--config` 同时使用。其他 Profile 必须在每次命令中显式选择;Agent Bot 不维护按名称注册的 Profile。
37
37
 
38
- CLI 通过 Node.js 国际化能力读取系统 Locale。以 `zh` 开头的 Locale 使用中文界面;英文及所有未支持 Locale 使用英文。帮助、状态、进度、交互提示和 CLI 自身错误都遵循此规则;JSON 字段名及枚举值不做本地化。系统生成的重启原因仍使用中文,因为它会显示在中文 Lark 状态卡中;显式传入的 `--reason` 保持原样。`agent-bot server status` 会报告运行中 Worker 的 Lark App ID,JSON 字段名为 `feishuAppId`;服务停止或旧版健康协议尚未提供该字段时,CLI 会回退到当前 Profile 配置的 App ID。
38
+ CLI 通过 Node.js 国际化能力读取系统 Locale。以 `zh` 开头的 Locale 使用中文界面;英文及所有未支持 Locale 使用英文。帮助、状态、进度、交互提示和 CLI 自身错误都遵循此规则;JSON 字段名及枚举值不做本地化。系统生成的重启原因仍使用中文,因为它会显示在中文 Lark 状态卡中;显式传入的 `--reason` 保持原样。`agentbot server status` 会报告运行中 Worker 的 Lark App ID,JSON 字段名为 `feishuAppId`;服务停止或旧版健康协议尚未提供该字段时,CLI 会回退到当前 Profile 配置的 App ID。
39
39
 
40
40
  | 默认路径 | 内容 |
41
41
  | ------------------------------------ | -------------------- |
@@ -58,7 +58,7 @@ CLI 通过 Node.js 国际化能力读取系统 Locale。以 `zh` 开头的 Local
58
58
 
59
59
  ## 初始化
60
60
 
61
- 目标文件不存在时,`agent-bot init` 会复制随包提供的 `config.example.yaml` 和 `.env.example`,创建数据和日志目录,并在平台支持时把 `.env` 权限限制为 POSIX `0600`。
61
+ 目标文件不存在时,`agentbot init` 会复制随包提供的 `config.example.yaml` 和 `.env.example`,创建数据和日志目录,并在平台支持时把 `.env` 权限限制为 POSIX `0600`。
62
62
 
63
63
  凭据处理规则:
64
64
 
@@ -90,9 +90,9 @@ https://open.feishu.cn/app/<appId>/auth?q=im%3Amessage.group_msg&op_from=openapi
90
90
 
91
91
  生成的授权链接不包含 App Secret。
92
92
 
93
- `agent-bot --profile <目录> init --reset` 会完整重置显式指定的 Profile。执行前必须先停止该 Profile 的 Server。命令会把当前 `config.yaml`、`.env`、`data/` 和 `logs/` 移入 `<profile>/.reset-backups/` 下唯一的时间戳目录,从随包模板创建干净的新文件和目录,再继续正常初始化。已有重置备份及其他无关文件会保留。备份中可能含有旧 App Secret 和会话数据,应妥善保护 Profile 目录。远端旧飞书应用不会被删除。`--reset --skip-feishu` 可创建干净的 Console-only Profile,`--reset` 不能与 `--reconfigure-feishu` 同时使用。
93
+ `agentbot --profile <目录> init --reset` 会完整重置显式指定的 Profile。执行前必须先停止该 Profile 的 Server。命令会把当前 `config.yaml`、`.env`、`data/` 和 `logs/` 移入 `<profile>/.reset-backups/` 下唯一的时间戳目录,从随包模板创建干净的新文件和目录,再继续正常初始化。已有重置备份及其他无关文件会保留。备份中可能含有旧 App Secret 和会话数据,应妥善保护 Profile 目录。远端旧飞书应用不会被删除。`--reset --skip-feishu` 可创建干净的 Console-only Profile,`--reset` 不能与 `--reconfigure-feishu` 同时使用。
94
94
 
95
- 飞书初始化成功后,CLI 会先释放初始化锁,再通过与 `agent-bot server start` 相同的就绪检查流程启动后台 Supervisor,并等待最多 45 秒,直到 Worker 连接飞书并进入就绪状态。如果当前 Profile 的服务已经运行,不会创建第二个 Supervisor。`--skip-feishu` 会跳过自动启动;`--json` 会把结果写入 `server.status`,不会混入非 JSON 文本。
95
+ 飞书初始化成功后,CLI 会先释放初始化锁,再通过与 `agentbot server start` 相同的就绪检查流程启动后台 Supervisor,并等待最多 45 秒,直到 Worker 连接飞书并进入就绪状态。如果当前 Profile 的服务已经运行,不会创建第二个 Supervisor。`--skip-feishu` 会跳过自动启动;`--json` 会把结果写入 `server.status`,不会混入非 JSON 文本。
96
96
 
97
97
  ## 飞书应用要求
98
98
 
@@ -118,7 +118,7 @@ https://open.feishu.cn/app/<appId>/auth?q=im%3Amessage.group_msg&op_from=openapi
118
118
  | 图片和群权限 | 生成并设置群头像 |
119
119
  | `card.action.trigger` | 交互卡片操作 |
120
120
 
121
- 可选授权失败时,最终初始化结果会列出受影响功能。重新运行 `agent-bot init` 会再次审计。
121
+ 可选授权失败时,最终初始化结果会列出受影响功能。重新运行 `agentbot init` 会再次审计。
122
122
 
123
123
  ## 配置模型
124
124
 
@@ -136,7 +136,7 @@ console:
136
136
 
137
137
  agents:
138
138
  codex:
139
- kind: "codex"
139
+ kind: "app-server"
140
140
  title: "Codex"
141
141
  command: "codex"
142
142
  args: ["app-server", "--enable", "goals", "--listen", "stdio://"]
@@ -156,7 +156,7 @@ logging:
156
156
 
157
157
  `feishu.respondToAllGroupMessages` 默认为 `true`。设为 `false` 后,未 @ 当前机器人的群消息会被忽略;Worker 启动时会解析机器人的 Open ID,因此 @ 其他成员不会误触发。私聊始终正常处理。无论该运行时配置如何,初始化都会申请接收全部群消息的权限,之后切换配置无需再次授权。
158
158
 
159
- `agent-bot server start` 要求同时配置飞书 `appId` 和 `appSecret`。Worker 启动 SDK 长连接时不读取 SDK 日志或私有连接状态,随后通过发送启动状态卡片检查出站能力。每张启动卡片都会显示从已安装包元数据读取的 Agent Bot 版本。通知通常发往已知私聊和最近活跃的群聊;数据库里尚无已知会话时,改用 `feishu.userOpenId`,按 `open_id` 私聊发送。存在通知目标时,至少一张卡片发送成功后 Server 才报告就绪,单个目标发送失败仍相互隔离。如果既没有已知会话,也没有 `feishu.userOpenId`,启动会跳过出站检查并继续。缺少凭据时仍会启动失败并提示先初始化。`agent-bot console` 是明确的纯本地入口,不需要飞书凭据。
159
+ `agentbot server start` 要求同时配置飞书 `appId` 和 `appSecret`。Worker 启动 SDK 长连接时不读取 SDK 日志或私有连接状态,随后通过发送启动状态卡片检查出站能力。每张启动卡片都会显示从已安装包元数据读取的 Agent Bot 版本。通知通常发往已知私聊和最近活跃的群聊;数据库里尚无已知会话时,改用 `feishu.userOpenId`,按 `open_id` 私聊发送。存在通知目标时,至少一张卡片发送成功后 Server 才报告就绪,单个目标发送失败仍相互隔离。如果既没有已知会话,也没有 `feishu.userOpenId`,启动会跳过出站检查并继续。缺少凭据时仍会启动失败并提示先初始化。`agentbot console` 是明确的纯本地入口,不需要飞书凭据。
160
160
 
161
161
  必须至少配置一个 Agent,`defaults.agent` 必须指向已配置的 Agent。
162
162
 
@@ -164,7 +164,7 @@ logging:
164
164
 
165
165
  Agent 配置的标准名是运行时隔离键。每个配置的 Agent 都拥有独立、按需启动的子进程和 Runtime 实例,即使多个 Agent 使用相同的 `kind` 也不会合并。不同 Agent 的任务不会共享命令、环境变量、协议连接、会话映射或事件流;同一 Agent 的多个任务共享该 Agent 进程,但使用独立的协议会话。
166
166
 
167
- `kind` 只用于选择连接适配器。`kind: "codex"` 的每个 Agent 使用各自的 Codex App Server 进程。Agent Bot 通过 App Server 协议传递项目目录、模型、思考强度、权限模式、文字输入和本地图片。`/sessions` 会聚合所有 Codex Agent 返回的任务,同时保留任务所属 Agent,确保 Switch、Status、Stop、New 和 Fork 操作回到正确进程。
167
+ `kind` 只用于选择连接适配器。`kind: "app-server"` 的每个 Agent 使用各自的 App Server 进程,不论其可执行程序是 Codex、TraeX 还是其他兼容产品。Agent Bot 通过 App Server 协议传递项目目录、模型、思考强度、权限模式、文字输入和本地图片。`/sessions` 会聚合所有 App Server Agent 返回的任务,同时保留任务所属 Agent,确保 Switch、Status、Stop、New 和 Fork 操作回到正确进程。加载已有 Profile 时,旧的 `kind: "codex"` 会被规范化为 `app-server`。
168
168
 
169
169
  `kind: "acp"` 或未填写 `kind` 的 Agent 使用各自的 ACP 进程。同一 Agent 的多个任务会在该连接上创建独立 ACP session。Agent 配置中的 `env` 只会加入该 Agent 的环境变量。
170
170
 
@@ -217,6 +217,8 @@ Agent Bot 会在每个 `thread/fork` 请求中默认发送实验性的 `excludeT
217
217
 
218
218
  每个任务条目都提供 `NewGroup` 和 `ForkGroup` 回调。回调数据保留所选任务 ID 与来源上下文,并使用飞书操作者的 `open_id` 邀请用户进入新群。`NewGroup` 解析所选任务的项目和执行设置;`ForkGroup` 解析该任务最新可用的已完成 turn。
219
219
 
220
+ CLI 通过 `agentbot task newgroup <任务> [标题] [--agent <标准名>] [--dir <目录> | --nodir]` 和 `agentbot task forkgroup <任务> [标题]` 提供相同的指定任务操作。两个命令都要求 Server 正在运行,并通过当前 Profile 的本地控制端点发送稳定的本地任务 ID。CLI 进程没有飞书操作者,因此 Server 会邀请 `feishu.userOpenId`,该值由初始化保存为 `FEISHU_USER_OPEN_ID`。NewGroup 默认继承指定任务的 Agent 和执行设置;`--agent <标准名>` 可选择另一个已配置的 Runtime,同时继续继承来源项目形态,并省略执行设置以采用目标 Runtime 自己的默认值。ForkGroup 使用来源任务最新可用的已完成 turn,并让来源任务的活动 turn 继续执行。两类控制响应都包含新群、群上下文、来源任务和新任务;`--json` 会输出不做本地化的结构化结果。
221
+
220
222
  ## Codex Provider 设置
221
223
 
222
224
  Provider 是任务级设置,以 `model_provider` 与模型、思考强度和权限模式一起持久化。任务明确继承或选择 Provider 时,Agent Bot 通过 `thread/start`、`thread/resume` 和 `thread/fork` 传递 `modelProvider`。全新任务没有可继承 Provider 时,Agent Bot 省略该参数,由 Codex App Server 使用 Codex 配置中生效的 `model_provider`,再从 thread 响应中读取实际 Provider 并保存。
@@ -248,11 +250,13 @@ SQLite 保存:
248
250
 
249
251
  启动时,Agent Bot 通过 `thread/read` 将持久化的活动工作与 Codex 状态校准。Turn 标识变化、收到终态通知或控制请求失败时也会重新校准。
250
252
 
251
- 最终消息投递账本用于避免重复发送成功回答。App Server 请求使用有限超时,避免阻塞的请求永久占用消息路由。
253
+ 最终消息投递账本用于避免重复发送成功回答。App Server 请求使用有限超时,避免阻塞的请求永久占用消息路由。会话生命周期请求允许 60 秒,因为兼容的第三方 Agent 完成 `thread/start` 可能需要超过 30 秒;控制请求仍使用更短的超时。
252
254
 
253
255
  ## Supervisor 与重启
254
256
 
255
- `agent-bot server start` 启动后台 supervisor。Worker 意外退出后会自动拉起;连续崩溃时使用 1 到 30 秒的指数退避。
257
+ `agentbot server start` 启动后台 supervisor。Worker 意外退出后会自动拉起;连续崩溃时使用 1 到 30 秒的指数退避。
258
+
259
+ Windows 下,CLI 在首次启动 Supervisor 前、Worker 在启动替换 Supervisor 前,以及 Supervisor 在每次启动 Worker 前,都会重新读取系统和用户环境变量。新值会覆盖继承值,`PATH` 在最新系统和用户路径之后保留进程专用条目。`AGENT_BOT_*` 和 `FEISHU_*` 仍保持进程级隔离,避免正在运行的 Profile 意外切换数据目录或机器人凭据。注册表读取失败时会回退到继承环境而不阻止启动,在运行时日志可用时会记录该错误。
256
260
 
257
261
  Supervisor 的崩溃诊断文件按当前 Profile 隔离:
258
262
 
@@ -275,7 +279,7 @@ Supervisor、Worker、替换 Supervisor 和 Console Worker 默认启用 Node fat
275
279
 
276
280
  等待中的安全重启状态卡底部带有 `Cancel` 操作。回调会携带调度器单调递增的计划 ID,因此旧卡片不会取消较新的重启。取消成功后,所有已发送的状态卡都会原地更新并移除按钮;调度器进入不可逆的正在重启阶段后也不再显示该按钮。
277
281
 
278
- 本地控制服务负责修改任务和请求服务重启;只读任务查询直接访问 SQLite。
282
+ 本地控制服务负责修改任务、执行指定任务的 NewGroup 和 ForkGroup,以及请求服务重启;只读任务查询直接访问 SQLite。
279
283
 
280
284
  ## 权限模式
281
285
 
@@ -289,16 +293,16 @@ Supervisor、Worker、替换 Supervisor 和 Console Worker 默认启用 Node fat
289
293
  随包提供的 Agent Bot Skill 可安装到共享 Agent Skill 目录:
290
294
 
291
295
  ```powershell
292
- agent-bot skills install
293
- agent-bot skills status
294
- agent-bot skills uninstall
296
+ agentbot skills install
297
+ agentbot skills status
298
+ agentbot skills uninstall
295
299
  ```
296
300
 
297
301
  默认目标为 `~/.agents/skills`,可通过 `AGENT_BOT_SKILLS_DIR` 或 `--target` 修改。安装使用受管复制;卸载不会删除无关的同名目录。
298
302
 
299
303
  ## npm 包与发布
300
304
 
301
- 公开包名为 `@keyou007/agent-bot`,安装后的可执行命令仍为 `agent-bot`。包使用 `files` 白名单,只发布运行代码、模板、受管 Skill、源码和用户文档,不包含测试及内部设计计划。
305
+ 公开包名为 `@keyou007/agent-bot`,安装后的主命令为 `agentbot`。已弃用的 `agent-bot` 作为转发兼容入口暂时保留,每次调用前都会根据系统语言显示警告。包使用 `files` 白名单,只发布运行代码、模板、受管 Skill、源码和用户文档,不包含测试及内部设计计划。
302
306
 
303
307
  CLI 随包发布 `npm-shrinkwrap.json`,以固定传递运行依赖;直接运行依赖和开发依赖也使用精确版本。
304
308
 
@@ -343,4 +347,4 @@ npm run build
343
347
  npm link
344
348
  ```
345
349
 
346
- `npm link` 会把当前 checkout 的 `agent-bot` 命令注册到全局。未执行时,可通过 `npm run cli --` 调用构建后的 CLI。`npm run dev` 运行单个前台 worker,`npm start` 在当前终端运行 supervisor。
350
+ `npm link` 会把当前 checkout 的 `agentbot` 主命令和已弃用的 `agent-bot` 兼容命令注册到全局。未执行时,可通过 `npm run cli --` 调用构建后的 CLI。`npm run dev` 运行单个前台 worker,`npm start` 在当前终端运行 supervisor。
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@keyou007/agent-bot",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@keyou007/agent-bot",
9
- "version": "0.1.11",
9
+ "version": "0.1.12",
10
10
  "license": "GPL-3.0-only",
11
11
  "dependencies": {
12
12
  "@agentclientprotocol/sdk": "1.2.1",
@@ -20,7 +20,8 @@
20
20
  "zod": "4.4.3"
21
21
  },
22
22
  "bin": {
23
- "agent-bot": "dist/cli.js"
23
+ "agent-bot": "dist/deprecated-cli.js",
24
+ "agentbot": "dist/cli.js"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@types/better-sqlite3": "7.6.13",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyou007/agent-bot",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "description": "Using Codex in Lark/Feishu feels just like using native Codex.",
6
6
  "license": "GPL-3.0-only",
@@ -21,7 +21,8 @@
21
21
  "cli"
22
22
  ],
23
23
  "bin": {
24
- "agent-bot": "dist/cli.js"
24
+ "agentbot": "dist/cli.js",
25
+ "agent-bot": "dist/deprecated-cli.js"
25
26
  },
26
27
  "files": [
27
28
  ".env.example",