@ai-development-environment/control-agent 0.0.80 → 0.0.81

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.
Files changed (2) hide show
  1. package/dist/control-agent.js +135 -34
  2. package/package.json +1 -1
@@ -4184,7 +4184,7 @@ var require_cross_spawn = __commonJS({
4184
4184
  var cp3 = __require("child_process");
4185
4185
  var parse2 = require_parse();
4186
4186
  var enoent = require_enoent();
4187
- function spawn8(command3, args, options) {
4187
+ function spawn9(command3, args, options) {
4188
4188
  const parsed = parse2(command3, args, options);
4189
4189
  const spawned = cp3.spawn(parsed.command, parsed.args, parsed.options);
4190
4190
  enoent.hookChildProcess(spawned, parsed);
@@ -4196,8 +4196,8 @@ var require_cross_spawn = __commonJS({
4196
4196
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
4197
4197
  return result;
4198
4198
  }
4199
- module.exports = spawn8;
4200
- module.exports.spawn = spawn8;
4199
+ module.exports = spawn9;
4200
+ module.exports.spawn = spawn9;
4201
4201
  module.exports.sync = spawnSync2;
4202
4202
  module.exports._parse = parse2;
4203
4203
  module.exports._enoent = enoent;
@@ -14286,12 +14286,16 @@ import { tmpdir as tmpdir5 } from "node:os";
14286
14286
  import { join as join12 } from "node:path";
14287
14287
 
14288
14288
  // src/runs/git-checkpoint.ts
14289
- import { execFile as execFile2 } from "node:child_process";
14289
+ import { execFile as execFile2, spawn as spawn6 } from "node:child_process";
14290
14290
  import { copyFile, mkdtemp as mkdtemp4, rm as rm7 } from "node:fs/promises";
14291
14291
  import { tmpdir as tmpdir4 } from "node:os";
14292
14292
  import { join as join11 } from "node:path";
14293
14293
  import { promisify as promisify2 } from "node:util";
14294
14294
  var execFileAsync = promisify2(execFile2);
14295
+ var PATCH_LIMIT = 2e6;
14296
+ var SUMMARY_LIMIT = 24e4;
14297
+ var MANIFEST_LIMIT = 2e6;
14298
+ var TRUNCATION_RESERVE = 200;
14295
14299
  async function git2(cwd, args, env) {
14296
14300
  const result = await execFileAsync("git", args, {
14297
14301
  cwd,
@@ -14308,24 +14312,111 @@ async function optionalGit(cwd, args) {
14308
14312
  return null;
14309
14313
  }
14310
14314
  }
14315
+ function cappedGit(cwd, args, limit) {
14316
+ const budget = limit - TRUNCATION_RESERVE;
14317
+ return new Promise((resolve8, reject) => {
14318
+ const child = spawn6("git", args, {
14319
+ cwd,
14320
+ env: {
14321
+ ...process.env,
14322
+ GIT_TERMINAL_PROMPT: "0",
14323
+ GIT_OPTIONAL_LOCKS: "0"
14324
+ },
14325
+ shell: false,
14326
+ stdio: ["ignore", "pipe", "pipe"]
14327
+ });
14328
+ const chunks = [];
14329
+ const errorChunks = [];
14330
+ let collected = 0;
14331
+ let errorCollected = 0;
14332
+ let truncated = false;
14333
+ let settled = false;
14334
+ child.stdout.on("data", (chunk) => {
14335
+ if (truncated) return;
14336
+ const remaining = budget - collected;
14337
+ if (chunk.length >= remaining) {
14338
+ chunks.push(chunk.subarray(0, remaining));
14339
+ collected = budget;
14340
+ truncated = true;
14341
+ child.stdout.destroy();
14342
+ if (child.exitCode === null && !child.killed) child.kill("SIGTERM");
14343
+ return;
14344
+ }
14345
+ chunks.push(chunk);
14346
+ collected += chunk.length;
14347
+ });
14348
+ child.stderr.on("data", (chunk) => {
14349
+ if (errorCollected >= 8192) return;
14350
+ errorChunks.push(chunk);
14351
+ errorCollected += chunk.length;
14352
+ });
14353
+ child.once("error", (error) => {
14354
+ if (settled) return;
14355
+ settled = true;
14356
+ reject(error);
14357
+ });
14358
+ child.once("close", (exitCode) => {
14359
+ if (settled) return;
14360
+ settled = true;
14361
+ if (!truncated && exitCode !== 0) {
14362
+ const message = Buffer.concat(errorChunks).toString("utf8").trim() || `git ${args[0]} exited with code ${exitCode}`;
14363
+ reject(new Error(message));
14364
+ return;
14365
+ }
14366
+ const output = Buffer.concat(chunks).toString("utf8");
14367
+ resolve8(
14368
+ truncated ? `${output.trimEnd()}
14369
+
14370
+ [Truncated after ${budget} bytes]` : output.trim()
14371
+ );
14372
+ });
14373
+ });
14374
+ }
14375
+ async function optionalCappedGit(cwd, args, limit) {
14376
+ try {
14377
+ return await cappedGit(cwd, args, limit) || null;
14378
+ } catch {
14379
+ return null;
14380
+ }
14381
+ }
14382
+ function manifestPayload(manifest) {
14383
+ let value = manifest;
14384
+ let json = JSON.stringify({ porcelainV2: value });
14385
+ while (json.length > MANIFEST_LIMIT && value.length > 0) {
14386
+ value = value.slice(
14387
+ 0,
14388
+ Math.floor(value.length * MANIFEST_LIMIT / json.length) - 1
14389
+ );
14390
+ json = JSON.stringify({ porcelainV2: value });
14391
+ }
14392
+ return json;
14393
+ }
14311
14394
  async function compareGitCheckpoint(cwd, target2, current) {
14312
14395
  if (!target2.worktreeTree || !current.worktreeTree) {
14313
14396
  throw new Error("The worktree checkpoint is incomplete");
14314
14397
  }
14315
- const worktreePatch = await git2(cwd, [
14316
- "diff",
14317
- "--binary",
14318
- "--find-renames",
14319
- target2.worktreeTree,
14320
- current.worktreeTree
14321
- ]);
14322
- const indexPatch = target2.indexTree && current.indexTree ? await git2(cwd, [
14323
- "diff",
14324
- "--binary",
14325
- "--find-renames",
14326
- target2.indexTree,
14327
- current.indexTree
14328
- ]) : "";
14398
+ const worktreePatch = await cappedGit(
14399
+ cwd,
14400
+ [
14401
+ "diff",
14402
+ "--binary",
14403
+ "--find-renames",
14404
+ target2.worktreeTree,
14405
+ current.worktreeTree
14406
+ ],
14407
+ PATCH_LIMIT
14408
+ );
14409
+ const indexPatch = target2.indexTree && current.indexTree ? await cappedGit(
14410
+ cwd,
14411
+ [
14412
+ "diff",
14413
+ "--binary",
14414
+ "--find-renames",
14415
+ target2.indexTree,
14416
+ current.indexTree
14417
+ ],
14418
+ PATCH_LIMIT
14419
+ ) : "";
14329
14420
  const upstream = await optionalGit(cwd, ["rev-parse", "@{upstream}"]);
14330
14421
  const pushedCount = target2.headSha && upstream ? Number(
14331
14422
  await optionalGit(cwd, [
@@ -14342,7 +14433,7 @@ ${worktreePatch}`,
14342
14433
  indexPatch && `Index changes that will be undone:
14343
14434
 
14344
14435
  ${indexPatch}`
14345
- ].filter(Boolean).join("\n\n").slice(0, 2e6),
14436
+ ].filter(Boolean).join("\n\n").slice(0, PATCH_LIMIT),
14346
14437
  pushedCommitWarning: pushedCount > 0 ? `${pushedCount} commit${pushedCount === 1 ? "" : "s"} after this question appear on the upstream branch. Remote refs will not be changed.` : null
14347
14438
  };
14348
14439
  }
@@ -14401,9 +14492,21 @@ async function captureGitCheckpoint(cwd, runId, kind) {
14401
14492
  ]);
14402
14493
  const upstreamSha = await optionalGit(cwd, ["rev-parse", "@{upstream}"]);
14403
14494
  const indexTree = await optionalGit(cwd, ["write-tree"]);
14404
- const manifest = await optionalGit(cwd, ["status", "--porcelain=v2", "-z"]);
14405
- const staged = await optionalGit(cwd, ["diff", "--cached", "--stat", "HEAD"]);
14406
- const unstaged = await optionalGit(cwd, ["diff", "--stat", "HEAD"]);
14495
+ const manifest = await optionalCappedGit(
14496
+ cwd,
14497
+ ["status", "--porcelain=v2", "-z"],
14498
+ MANIFEST_LIMIT
14499
+ );
14500
+ const staged = await optionalCappedGit(
14501
+ cwd,
14502
+ ["diff", "--cached", "--stat", "HEAD"],
14503
+ SUMMARY_LIMIT
14504
+ );
14505
+ const unstaged = await optionalCappedGit(
14506
+ cwd,
14507
+ ["diff", "--stat", "HEAD"],
14508
+ SUMMARY_LIMIT
14509
+ );
14407
14510
  const directory = await mkdtemp4(join11(tmpdir4(), "aide-run-index-"));
14408
14511
  let worktreeTree = null;
14409
14512
  let refName = null;
@@ -14451,17 +14554,15 @@ async function captureGitCheckpoint(cwd, runId, kind) {
14451
14554
  indexTree,
14452
14555
  worktreeTree,
14453
14556
  refName,
14454
- manifestJson: JSON.stringify({ porcelainV2: manifest ?? "" }),
14557
+ manifestJson: manifestPayload(manifest ?? ""),
14455
14558
  diffSummary: [staged && `Staged:
14456
14559
  ${staged}`, unstaged && `Working tree:
14457
14560
  ${unstaged}`].filter(Boolean).join("\n\n") || null,
14458
- diffPatch: headSha && worktreeTree ? (await git2(cwd, [
14459
- "diff",
14460
- "--binary",
14461
- "--find-renames",
14462
- headSha,
14463
- worktreeTree
14464
- ])).slice(0, 2e6) || null : null
14561
+ diffPatch: headSha && worktreeTree ? await cappedGit(
14562
+ cwd,
14563
+ ["diff", "--binary", "--find-renames", headSha, worktreeTree],
14564
+ PATCH_LIMIT
14565
+ ) || null : null
14465
14566
  };
14466
14567
  }
14467
14568
 
@@ -14576,7 +14677,7 @@ import { createWriteStream as createWriteStream2, watch } from "node:fs";
14576
14677
  import { mkdtemp as mkdtemp6, open as open2, readFile as readFile8, realpath as realpath8, rm as rm9, stat as stat10 } from "node:fs/promises";
14577
14678
  import { tmpdir as tmpdir6 } from "node:os";
14578
14679
  import { basename as basename5, dirname as dirname7, isAbsolute as isAbsolute6, join as join13, relative as relative7 } from "node:path";
14579
- import { spawn as spawn6 } from "node:child_process";
14680
+ import { spawn as spawn7 } from "node:child_process";
14580
14681
  var successfulProcess8 = {
14581
14682
  exitCode: 0,
14582
14683
  signal: null,
@@ -15576,7 +15677,7 @@ function imageContentType(path) {
15576
15677
  }
15577
15678
  async function writeGitObject(folder, specification, destination, timeoutMs, signal) {
15578
15679
  await new Promise((resolvePromise, rejectPromise) => {
15579
- const child = spawn6(
15680
+ const child = spawn7(
15580
15681
  "git",
15581
15682
  ["-C", folder, "cat-file", "blob", specification],
15582
15683
  { stdio: ["ignore", "pipe", "pipe"] }
@@ -43515,7 +43616,7 @@ var ClaudeAdapter = class {
43515
43616
  // src/runs/codex-adapter.ts
43516
43617
  import {
43517
43618
  execFile as execFile3,
43518
- spawn as spawn7
43619
+ spawn as spawn8
43519
43620
  } from "node:child_process";
43520
43621
  import { mkdtemp as mkdtemp7, rm as rm12, writeFile as writeFile8 } from "node:fs/promises";
43521
43622
  import { tmpdir as tmpdir7 } from "node:os";
@@ -43604,7 +43705,7 @@ var CodexAppServer = class {
43604
43705
  const executable = this.executable();
43605
43706
  const modelCatalogPath = await this.createBundledModelCatalog(executable);
43606
43707
  const modelCatalogDirectory = this.modelCatalogDirectory;
43607
- const child = spawn7(executable, codexAppServerArgs(modelCatalogPath), {
43708
+ const child = spawn8(executable, codexAppServerArgs(modelCatalogPath), {
43608
43709
  stdio: ["pipe", "pipe", "pipe"],
43609
43710
  env: process.env
43610
43711
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-development-environment/control-agent",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "description": "Control agent for the AI Development Environment",
5
5
  "license": "MIT",
6
6
  "repository": {