@fangyb/ahchat-bridge 0.1.16 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -46793,6 +46793,34 @@ var AgentManager = class {
46793
46793
  this.queryFn = QA$;
46794
46794
  return this.queryFn;
46795
46795
  }
46796
+ fallbackCwd(agentConfig, scope, requestedCwd) {
46797
+ const normalized = requestedCwd.trim();
46798
+ const basename = normalized ? import_node_path8.default.basename(import_node_path8.default.normalize(normalized)) : "";
46799
+ const suffix = basename && basename !== "." && basename !== import_node_path8.default.sep ? basename : scope.kind === "group" ? `Group-${scope.groupId}` : agentConfig.id;
46800
+ return import_node_path8.default.join(this.workspacesDir, suffix);
46801
+ }
46802
+ async resolveRuntimeCwd(agentConfig, scope, requestedCwd) {
46803
+ let cwd = requestedCwd;
46804
+ if (isRunningAsRoot() && cwd.startsWith("/root/")) {
46805
+ cwd = this.fallbackCwd(agentConfig, scope, cwd);
46806
+ }
46807
+ try {
46808
+ await import_promises8.default.mkdir(cwd, { recursive: true });
46809
+ return cwd;
46810
+ } catch (e7) {
46811
+ const fallback = this.fallbackCwd(agentConfig, scope, cwd);
46812
+ if (fallback === cwd) throw e7;
46813
+ logger10.warn("Working directory inaccessible; using local fallback", {
46814
+ agentId: agentConfig.id,
46815
+ scope: scopeKey(scope),
46816
+ requested: cwd,
46817
+ fallback,
46818
+ error: e7
46819
+ });
46820
+ await import_promises8.default.mkdir(fallback, { recursive: true });
46821
+ return fallback;
46822
+ }
46823
+ }
46796
46824
  /**
46797
46825
  * Parse agent.config and resolve any subscriptionId reference into the legacy
46798
46826
  * inline fields (subscriptionType / apiKey / apiBaseUrl). Downstream code in
@@ -47005,8 +47033,7 @@ var AgentManager = class {
47005
47033
  return existing;
47006
47034
  }
47007
47035
  const inputController = new InputController();
47008
- const agentCwd = isRunningAsRoot() && cwd.startsWith("/root/") ? import_node_path8.default.join(this.workspacesDir, agentConfig.id) : cwd;
47009
- await import_promises8.default.mkdir(agentCwd, { recursive: true });
47036
+ const agentCwd = await this.resolveRuntimeCwd(agentConfig, scope, cwd);
47010
47037
  const cfg = await this.resolveAgentConfig(agentConfig);
47011
47038
  if (cfg.instructions?.trim()) {
47012
47039
  await import_promises8.default.writeFile(import_node_path8.default.join(agentCwd, "CLAUDE.md"), cfg.instructions.trim(), "utf-8");