@4pm/cli 1.2.4-b → 1.2.6
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/index.js +20 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29826,7 +29826,7 @@ async function runAiFailover(plan, commandId, cwd2, handlers) {
|
|
|
29826
29826
|
let finalExit = -1;
|
|
29827
29827
|
for (let i = 0; i < total; i++) {
|
|
29828
29828
|
const attempt = plan.attempts[i];
|
|
29829
|
-
if (total > 1) handlers.onAttemptStart(attempt.label, i, total);
|
|
29829
|
+
if (total > 1) handlers.onAttemptStart(attempt.label, i, total, attempt.cmd);
|
|
29830
29830
|
const parser = createAiStreamParser(attempt.cmd);
|
|
29831
29831
|
let captured = "";
|
|
29832
29832
|
const emit = (raw) => {
|
|
@@ -29934,6 +29934,10 @@ function resolveClaudeAuthMode(config) {
|
|
|
29934
29934
|
function isUnifiedConfig(config) {
|
|
29935
29935
|
return Array.isArray(config.aiProfiles) && config.aiProfiles.some(isUsableCredential);
|
|
29936
29936
|
}
|
|
29937
|
+
function activeProvider(config) {
|
|
29938
|
+
const v = config.aiCli?.trim();
|
|
29939
|
+
return v && AI_PROVIDERS.includes(v) ? v : null;
|
|
29940
|
+
}
|
|
29937
29941
|
function claudeProfilesOf(config) {
|
|
29938
29942
|
if (isUnifiedConfig(config)) return config.aiProfiles.filter((c) => c.provider === "claude");
|
|
29939
29943
|
return config.claudeHome ?? [];
|
|
@@ -30007,7 +30011,18 @@ function planAiRun(prompt, config, hint = {}) {
|
|
|
30007
30011
|
}
|
|
30008
30012
|
function planUnifiedRun(prompt, config, workingCredential) {
|
|
30009
30013
|
const baseEnv = config.aiEnv ?? {};
|
|
30010
|
-
const
|
|
30014
|
+
const active = activeProvider(config);
|
|
30015
|
+
const usable = config.aiProfiles.filter(isUsableCredential);
|
|
30016
|
+
const scoped = active ? usable.filter((c) => c.provider === active) : usable;
|
|
30017
|
+
if (active && scoped.length === 0) {
|
|
30018
|
+
return {
|
|
30019
|
+
cmd: active,
|
|
30020
|
+
attempts: [
|
|
30021
|
+
{ cmd: active, label: "default", dir: null, key: null, args: buildRunArgs({ profile: "" }, active, prompt), env: { ...baseEnv } }
|
|
30022
|
+
]
|
|
30023
|
+
};
|
|
30024
|
+
}
|
|
30025
|
+
const resolved = scoped.map((cred) => {
|
|
30011
30026
|
const cmd = cred.provider;
|
|
30012
30027
|
const dir2 = resolveHomePath(cred.profile);
|
|
30013
30028
|
return { cred, cmd, dir: dir2, key: credentialKey(cmd, dir2), envVar: profileEnvVar(cmd) };
|
|
@@ -33103,8 +33118,8 @@ var WsClient = class {
|
|
|
33103
33118
|
this.bus.push({ source: origin, kind: "out", text: resultBuf });
|
|
33104
33119
|
}
|
|
33105
33120
|
},
|
|
33106
|
-
onAttemptStart: (label, index, total) => {
|
|
33107
|
-
const text = `\u2192 trying ${
|
|
33121
|
+
onAttemptStart: (label, index, total, cmd2) => {
|
|
33122
|
+
const text = `\u2192 trying ${cmd2} profile "${label}" (${index + 1}/${total})\u2026`;
|
|
33108
33123
|
this.bus.push({ source: origin, kind: "log", text });
|
|
33109
33124
|
this.send(WsChannels.COMMAND_OUTPUT, { commandId, seq: seq++, chunk: `${text}
|
|
33110
33125
|
`, log: true });
|
|
@@ -33619,7 +33634,7 @@ function isAlive(pid) {
|
|
|
33619
33634
|
function lockHolder(profileDir2) {
|
|
33620
33635
|
try {
|
|
33621
33636
|
const pid = Number.parseInt(readFileSync15(lockPath(profileDir2), "utf8").trim(), 10);
|
|
33622
|
-
if (Number.isInteger(pid) && pid > 0 && isAlive(pid)) return pid;
|
|
33637
|
+
if (Number.isInteger(pid) && pid > 0 && pid !== process.pid && isAlive(pid)) return pid;
|
|
33623
33638
|
} catch {
|
|
33624
33639
|
}
|
|
33625
33640
|
return null;
|