@ai-development-environment/control-agent 0.0.77 → 0.0.78

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.
@@ -12136,20 +12136,28 @@ function isExecutable(path) {
12136
12136
  return false;
12137
12137
  }
12138
12138
  }
12139
- function findExecutable(name, options = {}) {
12140
- const env = options.env ?? process.env;
12139
+ function toolDirectories(options = {}) {
12141
12140
  const home = options.home ?? homedir4();
12142
12141
  const platform2 = options.platform ?? process.platform;
12143
- const executable = platform2 === "win32" ? `${name}.exe` : name;
12144
- const directories = [
12145
- ...(env.PATH ?? "").split(delimiter).filter(Boolean),
12142
+ return [
12146
12143
  join6(home, ".local", "bin"),
12147
12144
  join6(home, ".bun", "bin"),
12148
12145
  join6(home, ".npm-global", "bin"),
12146
+ // Where the opencode.ai install script puts its binary.
12147
+ join6(home, ".opencode", "bin"),
12149
12148
  // Global npm installs land next to the node binary running this agent.
12150
12149
  options.nodeDirectory ?? dirname3(process.execPath),
12151
12150
  ...platform2 === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : []
12152
12151
  ];
12152
+ }
12153
+ function findExecutable(name, options = {}) {
12154
+ const env = options.env ?? process.env;
12155
+ const platform2 = options.platform ?? process.platform;
12156
+ const executable = platform2 === "win32" ? `${name}.exe` : name;
12157
+ const directories = [
12158
+ ...(env.PATH ?? "").split(delimiter).filter(Boolean),
12159
+ ...toolDirectories(options)
12160
+ ];
12153
12161
  const override = options.overrideVariable ? env[options.overrideVariable]?.trim() : void 0;
12154
12162
  const candidates = [
12155
12163
  ...override ? [override] : [],
@@ -12158,6 +12166,26 @@ function findExecutable(name, options = {}) {
12158
12166
  const canExecute = options.isExecutable ?? isExecutable;
12159
12167
  return [...new Set(candidates)].find(canExecute);
12160
12168
  }
12169
+ function extendedPath(options = {}) {
12170
+ const env = options.env ?? process.env;
12171
+ const existing = (env.PATH ?? "").split(delimiter).filter(Boolean);
12172
+ const additions = toolDirectories(options).filter(
12173
+ (directory) => !existing.includes(directory)
12174
+ );
12175
+ return [...existing, ...additions].join(delimiter);
12176
+ }
12177
+ function repairToolPath(options = {}) {
12178
+ const env = options.env ?? process.env;
12179
+ env.PATH = extendedPath(options);
12180
+ }
12181
+ function prependPathDirectory(directory, env = process.env) {
12182
+ const existing = (env.PATH ?? "").split(delimiter).filter(Boolean);
12183
+ if (existing[0] === directory) return;
12184
+ env.PATH = [
12185
+ directory,
12186
+ ...existing.filter((entry) => entry !== directory)
12187
+ ].join(delimiter);
12188
+ }
12161
12189
 
12162
12190
  // src/process-runner.ts
12163
12191
  import { spawn as spawn5 } from "node:child_process";
@@ -16909,7 +16937,7 @@ var CodebaseMonitor = class {
16909
16937
  // src/runs/run-manager.ts
16910
16938
  import { execFile as execFile4 } from "node:child_process";
16911
16939
  import { mkdir as mkdir6, rm as rm13 } from "node:fs/promises";
16912
- import { dirname as dirname9, join as join17 } from "node:path";
16940
+ import { dirname as dirname10, join as join17 } from "node:path";
16913
16941
  import { promisify as promisify4 } from "node:util";
16914
16942
 
16915
16943
  // src/runs/journal.ts
@@ -43291,10 +43319,24 @@ var CodexAppServer = class {
43291
43319
  this.initialized ??= this.start();
43292
43320
  return this.initialized;
43293
43321
  }
43322
+ // The service PATH omits Homebrew and npm, so resolve the install once and
43323
+ // use the absolute path for every codex invocation.
43324
+ executable() {
43325
+ const executable = findExecutable("codex", {
43326
+ overrideVariable: "CONTROL_AGENT_CODEX_EXECUTABLE"
43327
+ });
43328
+ if (!executable) {
43329
+ throw new Error(
43330
+ "codex was not found. Install it (brew install codex, or npm install -g @openai/codex) or set CONTROL_AGENT_CODEX_EXECUTABLE to its full path."
43331
+ );
43332
+ }
43333
+ return executable;
43334
+ }
43294
43335
  async start() {
43295
- const modelCatalogPath = await this.createBundledModelCatalog();
43336
+ const executable = this.executable();
43337
+ const modelCatalogPath = await this.createBundledModelCatalog(executable);
43296
43338
  const modelCatalogDirectory = this.modelCatalogDirectory;
43297
- const child = spawn7("codex", codexAppServerArgs(modelCatalogPath), {
43339
+ const child = spawn7(executable, codexAppServerArgs(modelCatalogPath), {
43298
43340
  stdio: ["pipe", "pipe", "pipe"],
43299
43341
  env: process.env
43300
43342
  });
@@ -43362,11 +43404,11 @@ var CodexAppServer = class {
43362
43404
  );
43363
43405
  }
43364
43406
  }
43365
- async createBundledModelCatalog() {
43407
+ async createBundledModelCatalog(executable) {
43366
43408
  const directory = await mkdtemp7(join16(tmpdir7(), "aide-codex-models-"));
43367
43409
  try {
43368
43410
  const { stdout } = await execFileAsync2(
43369
- "codex",
43411
+ executable,
43370
43412
  ["debug", "models", "--bundled"],
43371
43413
  {
43372
43414
  encoding: "utf8",
@@ -43804,6 +43846,7 @@ var CodexAdapter = class {
43804
43846
  };
43805
43847
 
43806
43848
  // src/runs/opencode-adapter.ts
43849
+ import { dirname as dirname9 } from "node:path";
43807
43850
  import { pathToFileURL } from "node:url";
43808
43851
 
43809
43852
  // ../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
@@ -49475,7 +49518,18 @@ var OpenCodeAdapter = class {
49475
49518
  };
49476
49519
  runtime;
49477
49520
  async client() {
49478
- this.runtime ??= await createOpencode();
49521
+ if (!this.runtime) {
49522
+ const executable = findExecutable("opencode", {
49523
+ overrideVariable: "CONTROL_AGENT_OPENCODE_EXECUTABLE"
49524
+ });
49525
+ if (!executable) {
49526
+ throw new Error(
49527
+ "opencode was not found. Install it (brew install sst/tap/opencode, or npm install -g opencode-ai) or set CONTROL_AGENT_OPENCODE_EXECUTABLE to its full path."
49528
+ );
49529
+ }
49530
+ prependPathDirectory(dirname9(executable));
49531
+ this.runtime = await createOpencode();
49532
+ }
49479
49533
  return this.runtime.client;
49480
49534
  }
49481
49535
  async catalog() {
@@ -50097,7 +50151,7 @@ var RunManager = class {
50097
50151
  5
50098
50152
  );
50099
50153
  await this.completeCommand(command3.id, "SUCCEEDED");
50100
- await rm13(join17(dirname9(configPath()), "runs", run.id, "attachments"), {
50154
+ await rm13(join17(dirname10(configPath()), "runs", run.id, "attachments"), {
50101
50155
  recursive: true,
50102
50156
  force: true
50103
50157
  }).catch(() => void 0);
@@ -50279,7 +50333,7 @@ var RunManager = class {
50279
50333
  this.active.delete(run.id);
50280
50334
  this.interruptionRequests.delete(run.id);
50281
50335
  this.executingCommands.delete(command3.id);
50282
- await rm13(join17(dirname9(configPath()), "runs", run.id, "attachments"), {
50336
+ await rm13(join17(dirname10(configPath()), "runs", run.id, "attachments"), {
50283
50337
  recursive: true,
50284
50338
  force: true
50285
50339
  }).catch(() => void 0);
@@ -50507,7 +50561,7 @@ var RunManager = class {
50507
50561
  }
50508
50562
  async stageAttachments(runId, attachments) {
50509
50563
  if (!attachments.length) return [];
50510
- const directory = join17(dirname9(configPath()), "runs", runId, "attachments");
50564
+ const directory = join17(dirname10(configPath()), "runs", runId, "attachments");
50511
50565
  await mkdir6(directory, { recursive: true, mode: 448 });
50512
50566
  return Promise.all(
50513
50567
  attachments.map(async (attachment) => {
@@ -51285,6 +51339,7 @@ async function doctor() {
51285
51339
  if (checks.some((check) => !check.ok)) process.exitCode = 1;
51286
51340
  }
51287
51341
  async function main() {
51342
+ repairToolPath();
51288
51343
  const [command3, ...args] = process.argv.slice(2);
51289
51344
  if (!command3 || command3 === "help" || command3 === "--help") {
51290
51345
  usage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-development-environment/control-agent",
3
- "version": "0.0.77",
3
+ "version": "0.0.78",
4
4
  "description": "Control agent for the AI Development Environment",
5
5
  "license": "MIT",
6
6
  "repository": {