@autohq/cli 0.1.539 → 0.1.541

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.
@@ -30870,7 +30870,7 @@ Object.assign(lookup, {
30870
30870
  // package.json
30871
30871
  var package_default = {
30872
30872
  name: "@autohq/cli",
30873
- version: "0.1.539",
30873
+ version: "0.1.541",
30874
30874
  license: "SEE LICENSE IN README.md",
30875
30875
  publishConfig: {
30876
30876
  access: "public"
@@ -75803,7 +75803,7 @@ import {
75803
75803
  writeFileSync as writeFileSync4
75804
75804
  } from "fs";
75805
75805
  import { tmpdir } from "os";
75806
- import { delimiter, dirname as dirname5, join as join3 } from "path";
75806
+ import { basename as basename2, delimiter, dirname as dirname5, isAbsolute as isAbsolute2, join as join3 } from "path";
75807
75807
 
75808
75808
  // src/commands/agent-bridge/harness/codex/options.ts
75809
75809
  import { join as join2 } from "path";
@@ -75987,6 +75987,7 @@ var CODEX_EDIT_PROBE = {
75987
75987
  ].join("\n")
75988
75988
  };
75989
75989
  var PROBE_TIMEOUT_MS = 15e3;
75990
+ var MAX_CODEX_SHIM_BYTES = 4096;
75990
75991
  var MAX_EVIDENCE_LENGTH = 300;
75991
75992
  var CODEX_PLATFORM_VENDOR_TARGETS = {
75992
75993
  linux: {
@@ -76029,8 +76030,8 @@ function codexEditFallthroughMarker(item) {
76029
76030
  return `agent_bridge_codex_edit_fallthrough item_id=${item.id} exit_code=127`;
76030
76031
  }
76031
76032
  function resolveCodexVendorLayout() {
76032
- const wrapper = whichOnPath(CODEX_EXECUTABLE_PATH);
76033
- if (!wrapper) {
76033
+ const wrappers = executableCodexCandidates(CODEX_EXECUTABLE_PATH);
76034
+ if (wrappers.length === 0) {
76034
76035
  throw new Error("codex executable not found on PATH");
76035
76036
  }
76036
76037
  const target = CODEX_PLATFORM_VENDOR_TARGETS[process.platform]?.[process.arch];
@@ -76039,40 +76040,92 @@ function resolveCodexVendorLayout() {
76039
76040
  `unsupported platform for codex vendor layout: ${process.platform}/${process.arch}`
76040
76041
  );
76041
76042
  }
76042
- const packageRoot = join3(dirname5(realpathSync3(wrapper)), "..");
76043
76043
  const platformPackage = `@openai/codex-${platformPackageSuffix()}`;
76044
- const candidates = [
76045
- join3(packageRoot, "node_modules", platformPackage, "vendor", target),
76046
- join3(packageRoot, "vendor", target)
76047
- ];
76048
- for (const vendorDir of candidates) {
76049
- const binary = join3(vendorDir, "bin", "codex");
76050
- const codexPathDir = join3(vendorDir, "codex-path");
76051
- if (existsSync5(binary) && existsSync5(codexPathDir)) {
76052
- return { binary, codexPathDir };
76044
+ const attemptedVendorDirs = [];
76045
+ for (const wrapper of wrappers) {
76046
+ const packageRoot = join3(dirname5(realpathSync3(wrapper)), "..");
76047
+ const vendorDirs = [
76048
+ join3(packageRoot, "node_modules", platformPackage, "vendor", target),
76049
+ join3(packageRoot, "vendor", target)
76050
+ ];
76051
+ attemptedVendorDirs.push(...vendorDirs);
76052
+ for (const vendorDir of vendorDirs) {
76053
+ const binary = join3(vendorDir, "bin", "codex");
76054
+ const codexPathDir = join3(vendorDir, "codex-path");
76055
+ if (isExecutable(binary) && existsSync5(codexPathDir)) {
76056
+ return { binary, codexPathDir };
76057
+ }
76053
76058
  }
76054
76059
  }
76055
76060
  throw new Error(
76056
- `codex vendor layout not found (wrapper=${wrapper} candidates=${candidates.join(",")})`
76061
+ `codex vendor layout not found (wrappers=${wrappers.join(",")} candidates=${attemptedVendorDirs.join(",")})`
76057
76062
  );
76058
76063
  }
76059
76064
  function platformPackageSuffix() {
76060
76065
  const os = process.platform === "darwin" ? "darwin" : "linux";
76061
76066
  return `${os}-${process.arch}`;
76062
76067
  }
76063
- function whichOnPath(command) {
76068
+ function executableCandidatesOnPath(command) {
76069
+ const candidates = [];
76070
+ const seen = /* @__PURE__ */ new Set();
76064
76071
  for (const dir of (process.env.PATH ?? "").split(delimiter)) {
76065
76072
  if (!dir) {
76066
76073
  continue;
76067
76074
  }
76068
76075
  const candidate = join3(dir, command);
76069
- try {
76070
- accessSync(candidate, constants.X_OK);
76071
- return candidate;
76072
- } catch {
76076
+ if (!seen.has(candidate) && isExecutable(candidate)) {
76077
+ seen.add(candidate);
76078
+ candidates.push(candidate);
76073
76079
  }
76074
76080
  }
76075
- return null;
76081
+ return candidates;
76082
+ }
76083
+ function executableCodexCandidates(command) {
76084
+ const candidates = executableCandidatesOnPath(command);
76085
+ const seen = new Set(candidates);
76086
+ for (let index = 0; index < candidates.length; index += 1) {
76087
+ const candidate = candidates[index];
76088
+ if (!candidate) {
76089
+ continue;
76090
+ }
76091
+ const target = directCodexShimTarget(candidate);
76092
+ if (target && !seen.has(target)) {
76093
+ seen.add(target);
76094
+ candidates.push(target);
76095
+ }
76096
+ }
76097
+ return candidates;
76098
+ }
76099
+ function directCodexShimTarget(candidate) {
76100
+ try {
76101
+ const resolved = realpathSync3(candidate);
76102
+ const metadata = lstatSync3(resolved);
76103
+ if (!metadata.isFile() || metadata.size > MAX_CODEX_SHIM_BYTES) {
76104
+ return null;
76105
+ }
76106
+ const script = readFileSync7(resolved, "utf8");
76107
+ if (!/^#!\/(?:bin\/|usr\/bin\/env )(?:ba)?sh\r?\n/.test(script)) {
76108
+ return null;
76109
+ }
76110
+ const targets = script.split(/\r?\n/).map(
76111
+ (line) => line.match(/^\s*exec\s+(?:"([^"]+)"|'([^']+)'|([^\s]+))\s+"\$@"\s*$/)
76112
+ ).filter((match) => match !== null).map((match) => match[1] ?? match[2] ?? match[3] ?? "");
76113
+ const [target] = targets;
76114
+ if (!target || targets.length !== 1) {
76115
+ return null;
76116
+ }
76117
+ return isAbsolute2(target) && basename2(target) === CODEX_EXECUTABLE_PATH && isExecutable(target) ? target : null;
76118
+ } catch {
76119
+ return null;
76120
+ }
76121
+ }
76122
+ function isExecutable(path2) {
76123
+ try {
76124
+ accessSync(path2, constants.X_OK);
76125
+ return true;
76126
+ } catch {
76127
+ return false;
76128
+ }
76076
76129
  }
76077
76130
  function provisionApplyPatchAlias(layout) {
76078
76131
  const alias = join3(layout.codexPathDir, CODEX_APPLY_PATCH_ALIAS);
@@ -76388,10 +76441,17 @@ var CodexAgentBridgeSessionImpl = class {
76388
76441
  this.input.writeOutput?.(
76389
76442
  `agent_bridge_codex_startup_started codex_home=${options.codexHome}`
76390
76443
  );
76391
- ensureCodexEditCapability({
76392
- command: options.command,
76393
- ...this.input.writeOutput ? { writeOutput: this.input.writeOutput } : {}
76394
- });
76444
+ try {
76445
+ ensureCodexEditCapability({
76446
+ command: options.command,
76447
+ ...this.input.writeOutput ? { writeOutput: this.input.writeOutput } : {}
76448
+ });
76449
+ } catch (error51) {
76450
+ throw new AgentBridgeTerminalPrepareError(
76451
+ error51 instanceof Error ? error51.message : String(error51),
76452
+ { cause: error51 }
76453
+ );
76454
+ }
76395
76455
  const proc = spawn(options.command, options.args, {
76396
76456
  env: options.env,
76397
76457
  stdio: ["pipe", "pipe", "pipe"]
package/dist/index.js CHANGED
@@ -81644,7 +81644,7 @@ var init_package = __esm({
81644
81644
  "package.json"() {
81645
81645
  package_default = {
81646
81646
  name: "@autohq/cli",
81647
- version: "0.1.539",
81647
+ version: "0.1.541",
81648
81648
  license: "SEE LICENSE IN README.md",
81649
81649
  publishConfig: {
81650
81650
  access: "public"
@@ -81769,10 +81769,10 @@ var init_project_apply_filesystem_source = __esm({
81769
81769
  // src/commands/agents/authoring.ts
81770
81770
  import { readFileSync as readFileSync8, readdirSync as readdirSync3, statSync as statSync3 } from "fs";
81771
81771
  import {
81772
- basename as basename3,
81772
+ basename as basename4,
81773
81773
  dirname as dirname8,
81774
81774
  extname,
81775
- isAbsolute as isAbsolute2,
81775
+ isAbsolute as isAbsolute3,
81776
81776
  join as join7,
81777
81777
  resolve as resolve3
81778
81778
  } from "path";
@@ -81831,7 +81831,7 @@ function readLocalAgentAuthoringStatuses(input) {
81831
81831
  );
81832
81832
  const paths = agentAuthoringFiles(agentsDirectory);
81833
81833
  return paths.map((path2) => {
81834
- const fallbackName = basename3(path2, extname(path2));
81834
+ const fallbackName = basename4(path2, extname(path2));
81835
81835
  try {
81836
81836
  const result = compileAgentFile(path2);
81837
81837
  return {
@@ -81970,7 +81970,7 @@ function importPaths(document) {
81970
81970
  });
81971
81971
  }
81972
81972
  function resolveImportPath(importPath, importerPath) {
81973
- if (isAbsolute2(importPath) || /^[A-Za-z]+:\/\//.test(importPath)) {
81973
+ if (isAbsolute3(importPath) || /^[A-Za-z]+:\/\//.test(importPath)) {
81974
81974
  throw new Error(`Agent import must be a relative path: ${importPath}`);
81975
81975
  }
81976
81976
  const resolved = resolve3(dirname8(importerPath), importPath);
@@ -82143,7 +82143,7 @@ function resolveFileBackedString(value, input) {
82143
82143
  );
82144
82144
  }
82145
82145
  const filePath = file2.trim();
82146
- if (isAbsolute2(filePath) || /^[A-Za-z]+:\/\//.test(filePath)) {
82146
+ if (isAbsolute3(filePath) || /^[A-Za-z]+:\/\//.test(filePath)) {
82147
82147
  throw new Error(
82148
82148
  `Invalid agent authoring file ${input.path}: ${input.field}.file must be a relative path`
82149
82149
  );
@@ -84966,7 +84966,7 @@ var init_project_apply_files2 = __esm({
84966
84966
 
84967
84967
  // src/commands/apply/files.ts
84968
84968
  import { existsSync as existsSync6, readFileSync as readFileSync9, realpathSync as realpathSync3, statSync as statSync4 } from "fs";
84969
- import { basename as basename4, dirname as dirname9, extname as extname3, isAbsolute as isAbsolute3, resolve as resolve4 } from "path";
84969
+ import { basename as basename5, dirname as dirname9, extname as extname3, isAbsolute as isAbsolute4, resolve as resolve4 } from "path";
84970
84970
  function readProjectApplyBundleInput(options) {
84971
84971
  if (options.file && options.directory) {
84972
84972
  throw new Error("Cannot use --file with --directory.");
@@ -85071,7 +85071,7 @@ function filesystemAssetReader(projectRoot) {
85071
85071
  function applyFileProjectRoot(file2) {
85072
85072
  let dir = dirname9(resolve4(file2));
85073
85073
  while (true) {
85074
- if (basename4(dir) === ".auto") {
85074
+ if (basename5(dir) === ".auto") {
85075
85075
  return dirname9(dir);
85076
85076
  }
85077
85077
  if (directoryHasAutoRoot(dir)) {
@@ -85099,7 +85099,7 @@ function isInside(path2, parent) {
85099
85099
  return path2.startsWith(`${parent}/`);
85100
85100
  }
85101
85101
  function validateAgentAvatarAsset(input) {
85102
- if (isAbsolute3(input.asset)) {
85102
+ if (isAbsolute4(input.asset)) {
85103
85103
  throw new Error(
85104
85104
  `Invalid identity avatar asset for "${input.resourceName}": asset path must be relative`
85105
85105
  );
@@ -98837,7 +98837,7 @@ import {
98837
98837
  writeFileSync as writeFileSync5
98838
98838
  } from "fs";
98839
98839
  import { tmpdir } from "os";
98840
- import { delimiter, dirname as dirname7, join as join5 } from "path";
98840
+ import { basename as basename3, delimiter, dirname as dirname7, isAbsolute as isAbsolute2, join as join5 } from "path";
98841
98841
 
98842
98842
  // src/commands/agent-bridge/harness/codex/options.ts
98843
98843
  import { join as join4 } from "path";
@@ -99021,6 +99021,7 @@ var CODEX_EDIT_PROBE = {
99021
99021
  ].join("\n")
99022
99022
  };
99023
99023
  var PROBE_TIMEOUT_MS = 15e3;
99024
+ var MAX_CODEX_SHIM_BYTES = 4096;
99024
99025
  var MAX_EVIDENCE_LENGTH = 300;
99025
99026
  var CODEX_PLATFORM_VENDOR_TARGETS = {
99026
99027
  linux: {
@@ -99063,8 +99064,8 @@ function codexEditFallthroughMarker(item) {
99063
99064
  return `agent_bridge_codex_edit_fallthrough item_id=${item.id} exit_code=127`;
99064
99065
  }
99065
99066
  function resolveCodexVendorLayout() {
99066
- const wrapper = whichOnPath(CODEX_EXECUTABLE_PATH);
99067
- if (!wrapper) {
99067
+ const wrappers = executableCodexCandidates(CODEX_EXECUTABLE_PATH);
99068
+ if (wrappers.length === 0) {
99068
99069
  throw new Error("codex executable not found on PATH");
99069
99070
  }
99070
99071
  const target = CODEX_PLATFORM_VENDOR_TARGETS[process.platform]?.[process.arch];
@@ -99073,40 +99074,92 @@ function resolveCodexVendorLayout() {
99073
99074
  `unsupported platform for codex vendor layout: ${process.platform}/${process.arch}`
99074
99075
  );
99075
99076
  }
99076
- const packageRoot = join5(dirname7(realpathSync2(wrapper)), "..");
99077
99077
  const platformPackage = `@openai/codex-${platformPackageSuffix()}`;
99078
- const candidates = [
99079
- join5(packageRoot, "node_modules", platformPackage, "vendor", target),
99080
- join5(packageRoot, "vendor", target)
99081
- ];
99082
- for (const vendorDir of candidates) {
99083
- const binary = join5(vendorDir, "bin", "codex");
99084
- const codexPathDir = join5(vendorDir, "codex-path");
99085
- if (existsSync4(binary) && existsSync4(codexPathDir)) {
99086
- return { binary, codexPathDir };
99078
+ const attemptedVendorDirs = [];
99079
+ for (const wrapper of wrappers) {
99080
+ const packageRoot = join5(dirname7(realpathSync2(wrapper)), "..");
99081
+ const vendorDirs = [
99082
+ join5(packageRoot, "node_modules", platformPackage, "vendor", target),
99083
+ join5(packageRoot, "vendor", target)
99084
+ ];
99085
+ attemptedVendorDirs.push(...vendorDirs);
99086
+ for (const vendorDir of vendorDirs) {
99087
+ const binary = join5(vendorDir, "bin", "codex");
99088
+ const codexPathDir = join5(vendorDir, "codex-path");
99089
+ if (isExecutable(binary) && existsSync4(codexPathDir)) {
99090
+ return { binary, codexPathDir };
99091
+ }
99087
99092
  }
99088
99093
  }
99089
99094
  throw new Error(
99090
- `codex vendor layout not found (wrapper=${wrapper} candidates=${candidates.join(",")})`
99095
+ `codex vendor layout not found (wrappers=${wrappers.join(",")} candidates=${attemptedVendorDirs.join(",")})`
99091
99096
  );
99092
99097
  }
99093
99098
  function platformPackageSuffix() {
99094
99099
  const os = process.platform === "darwin" ? "darwin" : "linux";
99095
99100
  return `${os}-${process.arch}`;
99096
99101
  }
99097
- function whichOnPath(command) {
99102
+ function executableCandidatesOnPath(command) {
99103
+ const candidates = [];
99104
+ const seen = /* @__PURE__ */ new Set();
99098
99105
  for (const dir of (process.env.PATH ?? "").split(delimiter)) {
99099
99106
  if (!dir) {
99100
99107
  continue;
99101
99108
  }
99102
99109
  const candidate = join5(dir, command);
99103
- try {
99104
- accessSync(candidate, constants.X_OK);
99105
- return candidate;
99106
- } catch {
99110
+ if (!seen.has(candidate) && isExecutable(candidate)) {
99111
+ seen.add(candidate);
99112
+ candidates.push(candidate);
99107
99113
  }
99108
99114
  }
99109
- return null;
99115
+ return candidates;
99116
+ }
99117
+ function executableCodexCandidates(command) {
99118
+ const candidates = executableCandidatesOnPath(command);
99119
+ const seen = new Set(candidates);
99120
+ for (let index = 0; index < candidates.length; index += 1) {
99121
+ const candidate = candidates[index];
99122
+ if (!candidate) {
99123
+ continue;
99124
+ }
99125
+ const target = directCodexShimTarget(candidate);
99126
+ if (target && !seen.has(target)) {
99127
+ seen.add(target);
99128
+ candidates.push(target);
99129
+ }
99130
+ }
99131
+ return candidates;
99132
+ }
99133
+ function directCodexShimTarget(candidate) {
99134
+ try {
99135
+ const resolved = realpathSync2(candidate);
99136
+ const metadata = lstatSync2(resolved);
99137
+ if (!metadata.isFile() || metadata.size > MAX_CODEX_SHIM_BYTES) {
99138
+ return null;
99139
+ }
99140
+ const script = readFileSync7(resolved, "utf8");
99141
+ if (!/^#!\/(?:bin\/|usr\/bin\/env )(?:ba)?sh\r?\n/.test(script)) {
99142
+ return null;
99143
+ }
99144
+ const targets = script.split(/\r?\n/).map(
99145
+ (line) => line.match(/^\s*exec\s+(?:"([^"]+)"|'([^']+)'|([^\s]+))\s+"\$@"\s*$/)
99146
+ ).filter((match) => match !== null).map((match) => match[1] ?? match[2] ?? match[3] ?? "");
99147
+ const [target] = targets;
99148
+ if (!target || targets.length !== 1) {
99149
+ return null;
99150
+ }
99151
+ return isAbsolute2(target) && basename3(target) === CODEX_EXECUTABLE_PATH && isExecutable(target) ? target : null;
99152
+ } catch {
99153
+ return null;
99154
+ }
99155
+ }
99156
+ function isExecutable(path2) {
99157
+ try {
99158
+ accessSync(path2, constants.X_OK);
99159
+ return true;
99160
+ } catch {
99161
+ return false;
99162
+ }
99110
99163
  }
99111
99164
  function provisionApplyPatchAlias(layout) {
99112
99165
  const alias = join5(layout.codexPathDir, CODEX_APPLY_PATCH_ALIAS);
@@ -99422,10 +99475,17 @@ var CodexAgentBridgeSessionImpl = class {
99422
99475
  this.input.writeOutput?.(
99423
99476
  `agent_bridge_codex_startup_started codex_home=${options.codexHome}`
99424
99477
  );
99425
- ensureCodexEditCapability({
99426
- command: options.command,
99427
- ...this.input.writeOutput ? { writeOutput: this.input.writeOutput } : {}
99428
- });
99478
+ try {
99479
+ ensureCodexEditCapability({
99480
+ command: options.command,
99481
+ ...this.input.writeOutput ? { writeOutput: this.input.writeOutput } : {}
99482
+ });
99483
+ } catch (error51) {
99484
+ throw new AgentBridgeTerminalPrepareError(
99485
+ error51 instanceof Error ? error51.message : String(error51),
99486
+ { cause: error51 }
99487
+ );
99488
+ }
99429
99489
  const proc = spawn2(options.command, options.args, {
99430
99490
  env: options.env,
99431
99491
  stdio: ["pipe", "pipe", "pipe"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.539",
3
+ "version": "0.1.541",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"