@proagentstore/cli 0.4.126 → 0.4.127
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { unwrapLauncher } from "./launcher-wrapper.js";
|
|
2
3
|
import { statSync } from "node:fs";
|
|
3
4
|
import { homedir } from "node:os";
|
|
4
5
|
import { join } from "node:path";
|
|
@@ -66,7 +67,9 @@ export function detectEngineLogin(engine, deps = {}) {
|
|
|
66
67
|
*/
|
|
67
68
|
export function checkEngine(input, deps = {}) {
|
|
68
69
|
const engine = (["claude", "gemini", "codex", "grok", "generic"].includes(input.clientType ?? "") ? input.clientType : "claude");
|
|
69
|
-
|
|
70
|
+
// The ENGINE is what must be installed — after a `pas mcp-auth exec --` wrapper (#1006), not the wrapper.
|
|
71
|
+
const command = parseCommand(input.command);
|
|
72
|
+
const parsed = unwrapLauncher(command.bin, command.args);
|
|
70
73
|
const bin = parsed.bin || parseCommand(handlerFor(engine).cliCommand).bin || engine;
|
|
71
74
|
const { binaryPath, via } = resolveEngineSpawn(bin, [], deps);
|
|
72
75
|
const login = input.credentialInjected ? { login: "found", where: "platform" } : detectEngineLogin(engine, deps);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InputLedger } from "./input-ledger.js";
|
|
2
|
+
import { spawnTarget, unwrapLauncher } from "./launcher-wrapper.js";
|
|
2
3
|
import { runObjectiveBlock } from "./run-objective.js";
|
|
3
4
|
import { spawn } from "node:child_process";
|
|
4
5
|
import { classifyCommand, commandFromToolInput, fillTargetFromResult, toolCallOk, toolResultMark } from "./engine-acts.js";
|
|
@@ -83,6 +84,8 @@ export class HeadlessSession {
|
|
|
83
84
|
mode;
|
|
84
85
|
adapter;
|
|
85
86
|
cmdBin;
|
|
87
|
+
/** A launcher wrapper spawned in front of the engine (`pas mcp-auth exec --`), or empty. */
|
|
88
|
+
cmdPrefix;
|
|
86
89
|
cmdArgs;
|
|
87
90
|
binName;
|
|
88
91
|
/** Wall-clock of the last stdout/stderr byte — drives the persistent-raw idle heuristic. */
|
|
@@ -242,7 +245,10 @@ export class HeadlessSession {
|
|
|
242
245
|
constructor(config) {
|
|
243
246
|
this.config = config;
|
|
244
247
|
this.engineLabel = `${config.clientType}:${config.id}`;
|
|
245
|
-
|
|
248
|
+
// `pas mcp-auth exec -- codex …` (#1006): spawn the wrapper, but drive the engine after `--`.
|
|
249
|
+
const parsed = parseCommand(config.command);
|
|
250
|
+
const { prefix, bin, args } = unwrapLauncher(parsed.bin, parsed.args);
|
|
251
|
+
this.cmdPrefix = prefix;
|
|
246
252
|
// When no explicit command is configured, fall back to THIS engine's default
|
|
247
253
|
// command (codex/gemini/grok/…) — not a hard-coded "claude", which would drive a
|
|
248
254
|
// non-Claude session with the wrong CLI (and mode is already "raw" for it).
|
|
@@ -428,7 +434,8 @@ export class HeadlessSession {
|
|
|
428
434
|
this.buf = "";
|
|
429
435
|
const args = this.adapter.buildLaunchArgs(this.cmdArgs, this.claudeSessionId);
|
|
430
436
|
const env = this.spawnEnv;
|
|
431
|
-
const
|
|
437
|
+
const target = spawnTarget(this.cmdPrefix, this.cmdBin, args);
|
|
438
|
+
const launch = resolveEngineSpawn(target.command, target.args, { env });
|
|
432
439
|
const proc = spawn(launch.command, launch.args, {
|
|
433
440
|
cwd: this.config.workDir,
|
|
434
441
|
env,
|
|
@@ -587,7 +594,8 @@ export class HeadlessSession {
|
|
|
587
594
|
? buildCodexResumeArgs(this.cmdArgs, resumedCodexThreadId, text)
|
|
588
595
|
: this.adapter.buildTurnArgs(this.cmdArgs, text);
|
|
589
596
|
const env = this.spawnEnv;
|
|
590
|
-
const
|
|
597
|
+
const target = spawnTarget(this.cmdPrefix, this.cmdBin, turnArgs);
|
|
598
|
+
const launch = resolveEngineSpawn(target.command, target.args, { env });
|
|
591
599
|
const proc = spawn(launch.command, launch.args, {
|
|
592
600
|
cwd: this.config.workDir,
|
|
593
601
|
env,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pas mcp-auth exec -- <engine …>` (#1006, PAS #356) on the runner.
|
|
3
|
+
*
|
|
4
|
+
* The ProAppStore CLI runs a command with the owner's remote PAS MCP credential in that process's
|
|
5
|
+
* environment only. So the runner must SPAWN the wrapper (it is what supplies the token) while
|
|
6
|
+
* everything that understands an engine — the adapter choice (`codex exec` → structured), the turn
|
|
7
|
+
* and resume argument builders, the engine-installed check — works on the ENGINE command after `--`.
|
|
8
|
+
*
|
|
9
|
+
* Matched exactly, as in the API (`workers/api/src/lib/coding-command.ts`) and the SDK
|
|
10
|
+
* (`packages/sdk/src/engine-posture.ts`): `pas` followed by anything other than `mcp-auth exec --`
|
|
11
|
+
* is not a wrapper, and stays the binary.
|
|
12
|
+
*/
|
|
13
|
+
export const PAS_MCP_AUTH_WRAPPER = ["mcp-auth", "exec", "--"];
|
|
14
|
+
export function unwrapLauncher(bin, args) {
|
|
15
|
+
const isPas = (bin.split("/").pop() || "").toLowerCase() === "pas";
|
|
16
|
+
if (!isPas || !PAS_MCP_AUTH_WRAPPER.every((t, k) => args[k] === t) || args.length <= PAS_MCP_AUTH_WRAPPER.length) {
|
|
17
|
+
return { prefix: [], bin, args: [...args] };
|
|
18
|
+
}
|
|
19
|
+
const rest = args.slice(PAS_MCP_AUTH_WRAPPER.length);
|
|
20
|
+
return { prefix: [bin, ...PAS_MCP_AUTH_WRAPPER], bin: rest[0], args: rest.slice(1) };
|
|
21
|
+
}
|
|
22
|
+
/** What to actually spawn: the wrapper (if any) carrying the engine and its built args. */
|
|
23
|
+
export function spawnTarget(prefix, bin, args) {
|
|
24
|
+
return prefix.length ? { command: prefix[0], args: [...prefix.slice(1), bin, ...args] } : { command: bin, args: [...args] };
|
|
25
|
+
}
|