@fangyb/ahchat-bridge 0.1.16 → 0.1.18
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 +49 -3
- package/dist/cli.js +3010 -786
- package/dist/index.js +29 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45991,6 +45991,34 @@ var AgentManager = class {
|
|
|
45991
45991
|
this.queryFn = QA$;
|
|
45992
45992
|
return this.queryFn;
|
|
45993
45993
|
}
|
|
45994
|
+
fallbackCwd(agentConfig, scope, requestedCwd) {
|
|
45995
|
+
const normalized = requestedCwd.trim();
|
|
45996
|
+
const basename = normalized ? path8.basename(path8.normalize(normalized)) : "";
|
|
45997
|
+
const suffix = basename && basename !== "." && basename !== path8.sep ? basename : scope.kind === "group" ? `Group-${scope.groupId}` : agentConfig.id;
|
|
45998
|
+
return path8.join(this.workspacesDir, suffix);
|
|
45999
|
+
}
|
|
46000
|
+
async resolveRuntimeCwd(agentConfig, scope, requestedCwd) {
|
|
46001
|
+
let cwd = requestedCwd;
|
|
46002
|
+
if (isRunningAsRoot() && cwd.startsWith("/root/")) {
|
|
46003
|
+
cwd = this.fallbackCwd(agentConfig, scope, cwd);
|
|
46004
|
+
}
|
|
46005
|
+
try {
|
|
46006
|
+
await fs4.mkdir(cwd, { recursive: true });
|
|
46007
|
+
return cwd;
|
|
46008
|
+
} catch (e7) {
|
|
46009
|
+
const fallback = this.fallbackCwd(agentConfig, scope, cwd);
|
|
46010
|
+
if (fallback === cwd) throw e7;
|
|
46011
|
+
logger10.warn("Working directory inaccessible; using local fallback", {
|
|
46012
|
+
agentId: agentConfig.id,
|
|
46013
|
+
scope: scopeKey(scope),
|
|
46014
|
+
requested: cwd,
|
|
46015
|
+
fallback,
|
|
46016
|
+
error: e7
|
|
46017
|
+
});
|
|
46018
|
+
await fs4.mkdir(fallback, { recursive: true });
|
|
46019
|
+
return fallback;
|
|
46020
|
+
}
|
|
46021
|
+
}
|
|
45994
46022
|
/**
|
|
45995
46023
|
* Parse agent.config and resolve any subscriptionId reference into the legacy
|
|
45996
46024
|
* inline fields (subscriptionType / apiKey / apiBaseUrl). Downstream code in
|
|
@@ -46203,8 +46231,7 @@ var AgentManager = class {
|
|
|
46203
46231
|
return existing;
|
|
46204
46232
|
}
|
|
46205
46233
|
const inputController = new InputController();
|
|
46206
|
-
const agentCwd =
|
|
46207
|
-
await fs4.mkdir(agentCwd, { recursive: true });
|
|
46234
|
+
const agentCwd = await this.resolveRuntimeCwd(agentConfig, scope, cwd);
|
|
46208
46235
|
const cfg = await this.resolveAgentConfig(agentConfig);
|
|
46209
46236
|
if (cfg.instructions?.trim()) {
|
|
46210
46237
|
await fs4.writeFile(path8.join(agentCwd, "CLAUDE.md"), cfg.instructions.trim(), "utf-8");
|