@agentclientprotocol/codex-acp 2.1.2-preview.4 → 2.1.2-preview.5

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/index.js +576 -11
  2. package/package.json +3 -1
package/dist/index.js CHANGED
@@ -3691,6 +3691,503 @@ var require_main = __commonJS({
3691
3691
  }
3692
3692
  });
3693
3693
 
3694
+ // node_modules/isexe/windows.js
3695
+ var require_windows = __commonJS({
3696
+ "node_modules/isexe/windows.js"(exports, module) {
3697
+ module.exports = isexe;
3698
+ isexe.sync = sync;
3699
+ var fs8 = __require("fs");
3700
+ function checkPathExt(path8, options) {
3701
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
3702
+ if (!pathext) {
3703
+ return true;
3704
+ }
3705
+ pathext = pathext.split(";");
3706
+ if (pathext.indexOf("") !== -1) {
3707
+ return true;
3708
+ }
3709
+ for (var i = 0; i < pathext.length; i++) {
3710
+ var p = pathext[i].toLowerCase();
3711
+ if (p && path8.substr(-p.length).toLowerCase() === p) {
3712
+ return true;
3713
+ }
3714
+ }
3715
+ return false;
3716
+ }
3717
+ function checkStat(stat, path8, options) {
3718
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
3719
+ return false;
3720
+ }
3721
+ return checkPathExt(path8, options);
3722
+ }
3723
+ function isexe(path8, options, cb) {
3724
+ fs8.stat(path8, function(er, stat) {
3725
+ cb(er, er ? false : checkStat(stat, path8, options));
3726
+ });
3727
+ }
3728
+ function sync(path8, options) {
3729
+ return checkStat(fs8.statSync(path8), path8, options);
3730
+ }
3731
+ }
3732
+ });
3733
+
3734
+ // node_modules/isexe/mode.js
3735
+ var require_mode = __commonJS({
3736
+ "node_modules/isexe/mode.js"(exports, module) {
3737
+ module.exports = isexe;
3738
+ isexe.sync = sync;
3739
+ var fs8 = __require("fs");
3740
+ function isexe(path8, options, cb) {
3741
+ fs8.stat(path8, function(er, stat) {
3742
+ cb(er, er ? false : checkStat(stat, options));
3743
+ });
3744
+ }
3745
+ function sync(path8, options) {
3746
+ return checkStat(fs8.statSync(path8), options);
3747
+ }
3748
+ function checkStat(stat, options) {
3749
+ return stat.isFile() && checkMode(stat, options);
3750
+ }
3751
+ function checkMode(stat, options) {
3752
+ var mod = stat.mode;
3753
+ var uid = stat.uid;
3754
+ var gid = stat.gid;
3755
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
3756
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
3757
+ var u = parseInt("100", 8);
3758
+ var g = parseInt("010", 8);
3759
+ var o = parseInt("001", 8);
3760
+ var ug = u | g;
3761
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
3762
+ return ret;
3763
+ }
3764
+ }
3765
+ });
3766
+
3767
+ // node_modules/isexe/index.js
3768
+ var require_isexe = __commonJS({
3769
+ "node_modules/isexe/index.js"(exports, module) {
3770
+ var fs8 = __require("fs");
3771
+ var core;
3772
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
3773
+ core = require_windows();
3774
+ } else {
3775
+ core = require_mode();
3776
+ }
3777
+ module.exports = isexe;
3778
+ isexe.sync = sync;
3779
+ function isexe(path8, options, cb) {
3780
+ if (typeof options === "function") {
3781
+ cb = options;
3782
+ options = {};
3783
+ }
3784
+ if (!cb) {
3785
+ if (typeof Promise !== "function") {
3786
+ throw new TypeError("callback not provided");
3787
+ }
3788
+ return new Promise(function(resolve, reject) {
3789
+ isexe(path8, options || {}, function(er, is) {
3790
+ if (er) {
3791
+ reject(er);
3792
+ } else {
3793
+ resolve(is);
3794
+ }
3795
+ });
3796
+ });
3797
+ }
3798
+ core(path8, options || {}, function(er, is) {
3799
+ if (er) {
3800
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
3801
+ er = null;
3802
+ is = false;
3803
+ }
3804
+ }
3805
+ cb(er, is);
3806
+ });
3807
+ }
3808
+ function sync(path8, options) {
3809
+ try {
3810
+ return core.sync(path8, options || {});
3811
+ } catch (er) {
3812
+ if (options && options.ignoreErrors || er.code === "EACCES") {
3813
+ return false;
3814
+ } else {
3815
+ throw er;
3816
+ }
3817
+ }
3818
+ }
3819
+ }
3820
+ });
3821
+
3822
+ // node_modules/which/which.js
3823
+ var require_which = __commonJS({
3824
+ "node_modules/which/which.js"(exports, module) {
3825
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
3826
+ var path8 = __require("path");
3827
+ var COLON = isWindows ? ";" : ":";
3828
+ var isexe = require_isexe();
3829
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
3830
+ var getPathInfo = (cmd, opt) => {
3831
+ const colon = opt.colon || COLON;
3832
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
3833
+ // windows always checks the cwd first
3834
+ ...isWindows ? [process.cwd()] : [],
3835
+ ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
3836
+ "").split(colon)
3837
+ ];
3838
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
3839
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
3840
+ if (isWindows) {
3841
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
3842
+ pathExt.unshift("");
3843
+ }
3844
+ return {
3845
+ pathEnv,
3846
+ pathExt,
3847
+ pathExtExe
3848
+ };
3849
+ };
3850
+ var which = (cmd, opt, cb) => {
3851
+ if (typeof opt === "function") {
3852
+ cb = opt;
3853
+ opt = {};
3854
+ }
3855
+ if (!opt)
3856
+ opt = {};
3857
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
3858
+ const found = [];
3859
+ const step = (i) => new Promise((resolve, reject) => {
3860
+ if (i === pathEnv.length)
3861
+ return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
3862
+ const ppRaw = pathEnv[i];
3863
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
3864
+ const pCmd = path8.join(pathPart, cmd);
3865
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
3866
+ resolve(subStep(p, i, 0));
3867
+ });
3868
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
3869
+ if (ii === pathExt.length)
3870
+ return resolve(step(i + 1));
3871
+ const ext = pathExt[ii];
3872
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
3873
+ if (!er && is) {
3874
+ if (opt.all)
3875
+ found.push(p + ext);
3876
+ else
3877
+ return resolve(p + ext);
3878
+ }
3879
+ return resolve(subStep(p, i, ii + 1));
3880
+ });
3881
+ });
3882
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
3883
+ };
3884
+ var whichSync = (cmd, opt) => {
3885
+ opt = opt || {};
3886
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
3887
+ const found = [];
3888
+ for (let i = 0; i < pathEnv.length; i++) {
3889
+ const ppRaw = pathEnv[i];
3890
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
3891
+ const pCmd = path8.join(pathPart, cmd);
3892
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
3893
+ for (let j = 0; j < pathExt.length; j++) {
3894
+ const cur = p + pathExt[j];
3895
+ try {
3896
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
3897
+ if (is) {
3898
+ if (opt.all)
3899
+ found.push(cur);
3900
+ else
3901
+ return cur;
3902
+ }
3903
+ } catch (ex) {
3904
+ }
3905
+ }
3906
+ }
3907
+ if (opt.all && found.length)
3908
+ return found;
3909
+ if (opt.nothrow)
3910
+ return null;
3911
+ throw getNotFoundError(cmd);
3912
+ };
3913
+ module.exports = which;
3914
+ which.sync = whichSync;
3915
+ }
3916
+ });
3917
+
3918
+ // node_modules/path-key/index.js
3919
+ var require_path_key = __commonJS({
3920
+ "node_modules/path-key/index.js"(exports, module) {
3921
+ "use strict";
3922
+ var pathKey = (options = {}) => {
3923
+ const environment = options.env || process.env;
3924
+ const platform2 = options.platform || process.platform;
3925
+ if (platform2 !== "win32") {
3926
+ return "PATH";
3927
+ }
3928
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
3929
+ };
3930
+ module.exports = pathKey;
3931
+ module.exports.default = pathKey;
3932
+ }
3933
+ });
3934
+
3935
+ // node_modules/cross-spawn/lib/util/resolveCommand.js
3936
+ var require_resolveCommand = __commonJS({
3937
+ "node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
3938
+ "use strict";
3939
+ var path8 = __require("path");
3940
+ var which = require_which();
3941
+ var getPathKey = require_path_key();
3942
+ function resolveCommandAttempt(parsed, withoutPathExt) {
3943
+ const env = parsed.options.env || process.env;
3944
+ const cwd = process.cwd();
3945
+ const hasCustomCwd = parsed.options.cwd != null;
3946
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
3947
+ if (shouldSwitchCwd) {
3948
+ try {
3949
+ process.chdir(parsed.options.cwd);
3950
+ } catch (err) {
3951
+ }
3952
+ }
3953
+ let resolved;
3954
+ try {
3955
+ resolved = which.sync(parsed.command, {
3956
+ path: env[getPathKey({ env })],
3957
+ pathExt: withoutPathExt ? path8.delimiter : void 0
3958
+ });
3959
+ } catch (e) {
3960
+ } finally {
3961
+ if (shouldSwitchCwd) {
3962
+ process.chdir(cwd);
3963
+ }
3964
+ }
3965
+ if (resolved) {
3966
+ resolved = path8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
3967
+ }
3968
+ return resolved;
3969
+ }
3970
+ function resolveCommand(parsed) {
3971
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
3972
+ }
3973
+ module.exports = resolveCommand;
3974
+ }
3975
+ });
3976
+
3977
+ // node_modules/cross-spawn/lib/util/escape.js
3978
+ var require_escape = __commonJS({
3979
+ "node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
3980
+ "use strict";
3981
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
3982
+ function escapeCommand(arg) {
3983
+ arg = arg.replace(metaCharsRegExp, "^$1");
3984
+ return arg;
3985
+ }
3986
+ function escapeArgument2(arg, doubleEscapeMetaChars) {
3987
+ arg = `${arg}`;
3988
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
3989
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
3990
+ arg = `"${arg}"`;
3991
+ arg = arg.replace(metaCharsRegExp, "^$1");
3992
+ if (doubleEscapeMetaChars) {
3993
+ arg = arg.replace(metaCharsRegExp, "^$1");
3994
+ }
3995
+ return arg;
3996
+ }
3997
+ module.exports.command = escapeCommand;
3998
+ module.exports.argument = escapeArgument2;
3999
+ }
4000
+ });
4001
+
4002
+ // node_modules/shebang-regex/index.js
4003
+ var require_shebang_regex = __commonJS({
4004
+ "node_modules/shebang-regex/index.js"(exports, module) {
4005
+ "use strict";
4006
+ module.exports = /^#!(.*)/;
4007
+ }
4008
+ });
4009
+
4010
+ // node_modules/shebang-command/index.js
4011
+ var require_shebang_command = __commonJS({
4012
+ "node_modules/shebang-command/index.js"(exports, module) {
4013
+ "use strict";
4014
+ var shebangRegex = require_shebang_regex();
4015
+ module.exports = (string4 = "") => {
4016
+ const match = string4.match(shebangRegex);
4017
+ if (!match) {
4018
+ return null;
4019
+ }
4020
+ const [path8, argument] = match[0].replace(/#! ?/, "").split(" ");
4021
+ const binary = path8.split("/").pop();
4022
+ if (binary === "env") {
4023
+ return argument;
4024
+ }
4025
+ return argument ? `${binary} ${argument}` : binary;
4026
+ };
4027
+ }
4028
+ });
4029
+
4030
+ // node_modules/cross-spawn/lib/util/readShebang.js
4031
+ var require_readShebang = __commonJS({
4032
+ "node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
4033
+ "use strict";
4034
+ var fs8 = __require("fs");
4035
+ var shebangCommand = require_shebang_command();
4036
+ function readShebang(command) {
4037
+ const size = 150;
4038
+ const buffer = Buffer.alloc(size);
4039
+ let fd;
4040
+ try {
4041
+ fd = fs8.openSync(command, "r");
4042
+ fs8.readSync(fd, buffer, 0, size, 0);
4043
+ fs8.closeSync(fd);
4044
+ } catch (e) {
4045
+ }
4046
+ return shebangCommand(buffer.toString());
4047
+ }
4048
+ module.exports = readShebang;
4049
+ }
4050
+ });
4051
+
4052
+ // node_modules/cross-spawn/lib/parse.js
4053
+ var require_parse = __commonJS({
4054
+ "node_modules/cross-spawn/lib/parse.js"(exports, module) {
4055
+ "use strict";
4056
+ var path8 = __require("path");
4057
+ var resolveCommand = require_resolveCommand();
4058
+ var escape = require_escape();
4059
+ var readShebang = require_readShebang();
4060
+ var isWin = process.platform === "win32";
4061
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
4062
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
4063
+ function detectShebang(parsed) {
4064
+ parsed.file = resolveCommand(parsed);
4065
+ const shebang = parsed.file && readShebang(parsed.file);
4066
+ if (shebang) {
4067
+ parsed.args.unshift(parsed.file);
4068
+ parsed.command = shebang;
4069
+ return resolveCommand(parsed);
4070
+ }
4071
+ return parsed.file;
4072
+ }
4073
+ function parseNonShell(parsed) {
4074
+ if (!isWin) {
4075
+ return parsed;
4076
+ }
4077
+ const commandFile = detectShebang(parsed);
4078
+ const needsShell = !isExecutableRegExp.test(commandFile);
4079
+ if (parsed.options.forceShell || needsShell) {
4080
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
4081
+ parsed.command = path8.normalize(parsed.command);
4082
+ parsed.command = escape.command(parsed.command);
4083
+ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
4084
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
4085
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
4086
+ parsed.command = process.env.comspec || "cmd.exe";
4087
+ parsed.options.windowsVerbatimArguments = true;
4088
+ }
4089
+ return parsed;
4090
+ }
4091
+ function parse3(command, args, options) {
4092
+ if (args && !Array.isArray(args)) {
4093
+ options = args;
4094
+ args = null;
4095
+ }
4096
+ args = args ? args.slice(0) : [];
4097
+ options = Object.assign({}, options);
4098
+ const parsed = {
4099
+ command,
4100
+ args,
4101
+ options,
4102
+ file: void 0,
4103
+ original: {
4104
+ command,
4105
+ args
4106
+ }
4107
+ };
4108
+ return options.shell ? parsed : parseNonShell(parsed);
4109
+ }
4110
+ module.exports = parse3;
4111
+ }
4112
+ });
4113
+
4114
+ // node_modules/cross-spawn/lib/enoent.js
4115
+ var require_enoent = __commonJS({
4116
+ "node_modules/cross-spawn/lib/enoent.js"(exports, module) {
4117
+ "use strict";
4118
+ var isWin = process.platform === "win32";
4119
+ function notFoundError(original, syscall) {
4120
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
4121
+ code: "ENOENT",
4122
+ errno: "ENOENT",
4123
+ syscall: `${syscall} ${original.command}`,
4124
+ path: original.command,
4125
+ spawnargs: original.args
4126
+ });
4127
+ }
4128
+ function hookChildProcess(cp, parsed) {
4129
+ if (!isWin) {
4130
+ return;
4131
+ }
4132
+ const originalEmit = cp.emit;
4133
+ cp.emit = function(name, arg1) {
4134
+ if (name === "exit") {
4135
+ const err = verifyENOENT(arg1, parsed);
4136
+ if (err) {
4137
+ return originalEmit.call(cp, "error", err);
4138
+ }
4139
+ }
4140
+ return originalEmit.apply(cp, arguments);
4141
+ };
4142
+ }
4143
+ function verifyENOENT(status, parsed) {
4144
+ if (isWin && status === 1 && !parsed.file) {
4145
+ return notFoundError(parsed.original, "spawn");
4146
+ }
4147
+ return null;
4148
+ }
4149
+ function verifyENOENTSync(status, parsed) {
4150
+ if (isWin && status === 1 && !parsed.file) {
4151
+ return notFoundError(parsed.original, "spawnSync");
4152
+ }
4153
+ return null;
4154
+ }
4155
+ module.exports = {
4156
+ hookChildProcess,
4157
+ verifyENOENT,
4158
+ verifyENOENTSync,
4159
+ notFoundError
4160
+ };
4161
+ }
4162
+ });
4163
+
4164
+ // node_modules/cross-spawn/index.js
4165
+ var require_cross_spawn = __commonJS({
4166
+ "node_modules/cross-spawn/index.js"(exports, module) {
4167
+ "use strict";
4168
+ var cp = __require("child_process");
4169
+ var parse3 = require_parse();
4170
+ var enoent = require_enoent();
4171
+ function spawn3(command, args, options) {
4172
+ const parsed = parse3(command, args, options);
4173
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
4174
+ enoent.hookChildProcess(spawned, parsed);
4175
+ return spawned;
4176
+ }
4177
+ function spawnSync(command, args, options) {
4178
+ const parsed = parse3(command, args, options);
4179
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
4180
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
4181
+ return result;
4182
+ }
4183
+ module.exports = spawn3;
4184
+ module.exports.spawn = spawn3;
4185
+ module.exports.sync = spawnSync;
4186
+ module.exports._parse = parse3;
4187
+ module.exports._enoent = enoent;
4188
+ }
4189
+ });
4190
+
3694
4191
  // node_modules/@agentclientprotocol/sdk/dist/schema/index.js
3695
4192
  var AGENT_METHODS = {
3696
4193
  initialize: "initialize",
@@ -27126,6 +27623,7 @@ var legacyClientNotificationMethods = /* @__PURE__ */ new Set([
27126
27623
 
27127
27624
  // src/CodexJsonRpcConnection.ts
27128
27625
  var rpc = __toESM(require_main(), 1);
27626
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
27129
27627
  import { spawn } from "node:child_process";
27130
27628
  import { createRequire } from "node:module";
27131
27629
 
@@ -27339,14 +27837,15 @@ async function settledWithin(promise2, ms) {
27339
27837
  }
27340
27838
 
27341
27839
  // src/CodexJsonRpcConnection.ts
27342
- function startCodexConnection(codexPath, env) {
27840
+ var require2 = createRequire(import.meta.url);
27841
+ function startCodexConnection(codexPath, env, appServerStartupArgs = ["app-server"]) {
27343
27842
  const spawnEnv = env ?? process.env;
27344
27843
  let codex;
27345
27844
  if (codexPath) {
27346
- codex = process.platform === "win32" ? spawn(`"${codexPath}" app-server`, { shell: true, env: spawnEnv }) : spawn(codexPath, ["app-server"], { env: spawnEnv });
27845
+ codex = process.platform === "win32" ? (0, import_cross_spawn.default)(codexPath, appServerStartupArgs, { env: spawnEnv }) : spawn(codexPath, appServerStartupArgs, { env: spawnEnv });
27347
27846
  } else {
27348
- const bundledCodexPath = createRequire(import.meta.url).resolve("@openai/codex/bin/codex.js");
27349
- codex = spawn(process.execPath, [bundledCodexPath, "app-server"], { env: spawnEnv });
27847
+ const bundledCodexPath = require2.resolve("@openai/codex/bin/codex.js");
27848
+ codex = spawn(process.execPath, [bundledCodexPath, ...appServerStartupArgs], { env: spawnEnv });
27350
27849
  }
27351
27850
  attachLogs(codex);
27352
27851
  const reader = createJSONRPCReader(codex.stdout);
@@ -27458,6 +27957,7 @@ var AIR_PERMISSION_KEY = "permission";
27458
27957
  var AIR_CONTEXT_COMPACTION_KEY = "contextCompaction";
27459
27958
  var AIR_RAW_INPUT_RENDERING_KEY = "rawInputRendering";
27460
27959
  var AIR_PLAN_CONTENT_DELTA_KEY = "planContentDelta";
27960
+ var AIR_CODEX_HOOKS_KEY = "codexHooks";
27461
27961
  var AIR_CONTENT_DELTA_KEY = "contentDelta";
27462
27962
  var AIR_SUBAGENT_KEY = "subagent";
27463
27963
  var AIR_CUSTOM_ANSWER_KEY = "customAnswer";
@@ -33533,7 +34033,7 @@ var package_default = {
33533
34033
  publishConfig: {
33534
34034
  access: "public"
33535
34035
  },
33536
- version: "2.1.2-preview.4",
34036
+ version: "2.1.2-preview.5",
33537
34037
  description: "",
33538
34038
  main: "dist/index.js",
33539
34039
  bin: {
@@ -33587,6 +34087,7 @@ var package_default = {
33587
34087
  license: "Apache-2.0",
33588
34088
  type: "module",
33589
34089
  devDependencies: {
34090
+ "@types/cross-spawn": "^6.0.6",
33590
34091
  "@types/node": "^26.1.0",
33591
34092
  ajv: "^8.20.0",
33592
34093
  esbuild: "^0.28.2",
@@ -33598,6 +34099,7 @@ var package_default = {
33598
34099
  dependencies: {
33599
34100
  "@agentclientprotocol/sdk": "^1.5.0",
33600
34101
  "@openai/codex": "^0.160.1",
34102
+ "cross-spawn": "^7.0.6",
33601
34103
  diff: "^9.0.0",
33602
34104
  open: "^11.0.1",
33603
34105
  "vscode-jsonrpc": "^9.0.1",
@@ -35782,6 +36284,12 @@ var CodexAppServerClient = class {
35782
36284
  async configRead(params) {
35783
36285
  return await this.sendRequest({ method: "config/read", params });
35784
36286
  }
36287
+ async hooksList(params) {
36288
+ return await this.sendRequest({ method: "hooks/list", params });
36289
+ }
36290
+ async configBatchWrite(params) {
36291
+ return await this.sendRequest({ method: "config/batchWrite", params });
36292
+ }
35785
36293
  async accountRead(params) {
35786
36294
  return await this.sendRequest({ method: "account/read", params });
35787
36295
  }
@@ -37614,6 +38122,33 @@ function clientSupportsSubagents(capabilities) {
37614
38122
  return clientSupportsAirCapability(capabilities, AIR_NATIVE_SUBAGENT_SESSIONS_KEY);
37615
38123
  }
37616
38124
 
38125
+ // src/CodexHookTrust.ts
38126
+ var CODEX_HOOKS_LIST_METHOD = "_codex/hooks/list";
38127
+ var CODEX_HOOKS_TRUST_METHOD = "_codex/hooks/trust";
38128
+ async function listCodexHooks(client, cwd) {
38129
+ const [entry] = (await client.hooksList({ cwds: [cwd] })).data;
38130
+ if (entry === void 0) throw new Error("Codex could not list hooks for the requested directory");
38131
+ return { ...entry, hooks: entry.hooks.filter((hook) => hook.source === "sessionFlags") };
38132
+ }
38133
+ async function trustCodexHooks(client, cwd, requested) {
38134
+ const isListed = (hooks, request) => hooks.find((hook) => hook.key === request.key && hook.currentHash === request.currentHash);
38135
+ const current = (await listCodexHooks(client, cwd)).hooks;
38136
+ const edits = requested.map((request) => {
38137
+ const hook = isListed(current, request);
38138
+ if (hook === void 0) throw new Error("A Codex hook changed before trust was recorded");
38139
+ return hook;
38140
+ }).filter((hook) => hook.trustStatus !== "trusted").map((hook) => ({
38141
+ keyPath: `hooks.state.${JSON.stringify(hook.key)}.trusted_hash`,
38142
+ value: hook.currentHash,
38143
+ mergeStrategy: "replace"
38144
+ }));
38145
+ if (edits.length > 0) {
38146
+ await client.configBatchWrite({ edits, reloadUserConfig: true });
38147
+ }
38148
+ const verified = (await listCodexHooks(client, cwd)).hooks;
38149
+ return requested.every((request) => isListed(verified, request)?.trustStatus === "trusted");
38150
+ }
38151
+
37617
38152
  // src/CodexAcpServer.ts
37618
38153
  import { randomUUID as randomUUID3 } from "node:crypto";
37619
38154
 
@@ -38346,7 +38881,8 @@ var CodexAcpServer = class {
38346
38881
  AIR_ASYNC_TASKS_KEY,
38347
38882
  AIR_RECOMMENDED_CONFIG_VALUE_KEY,
38348
38883
  AIR_RAW_INPUT_RENDERING_KEY,
38349
- AIR_PLAN_CONTENT_DELTA_KEY
38884
+ AIR_PLAN_CONTENT_DELTA_KEY,
38885
+ AIR_CODEX_HOOKS_KEY
38350
38886
  ]
38351
38887
  }
38352
38888
  }
@@ -38354,6 +38890,14 @@ var CodexAcpServer = class {
38354
38890
  }
38355
38891
  };
38356
38892
  }
38893
+ async listHooks(cwd) {
38894
+ if (this.providerUpdate !== null) await this.providerUpdate;
38895
+ return await this.runWithProcessCheck(() => listCodexHooks(this.codexAcpClient.appServerClient, cwd));
38896
+ }
38897
+ async trustHooks(cwd, hooks) {
38898
+ if (this.providerUpdate !== null) await this.providerUpdate;
38899
+ return { trusted: await this.runWithProcessCheck(() => trustCodexHooks(this.codexAcpClient.appServerClient, cwd, hooks)) };
38900
+ }
38357
38901
  async extMethod(method, params) {
38358
38902
  const methodRequest = { method, params };
38359
38903
  if (!isExtMethodRequest(methodRequest)) {
@@ -39149,7 +39693,7 @@ Check ${configPath} and project .codex directories, especially their config.toml
39149
39693
  await exited;
39150
39694
  clearTimeout(forceKill);
39151
39695
  state.stderr = "";
39152
- state.connection = startCodexConnection(state.codexPath);
39696
+ state.connection = startCodexConnection(state.codexPath, void 0, state.appServerStartupArgs);
39153
39697
  this.captureStderr();
39154
39698
  this.observeCodexProcess();
39155
39699
  return new CodexAcpClient(
@@ -41125,6 +41669,20 @@ function spawnCodexCli(codexPath, args) {
41125
41669
  return spawn2(process.execPath, [bundledCodexPath, ...args], options);
41126
41670
  }
41127
41671
 
41672
+ // src/CodexHookConfig.ts
41673
+ function prepareCodexHookConfig(config2) {
41674
+ if (config2?.["hooks"] === void 0) return { sessionConfig: config2, appServerStartupArgs: ["app-server"] };
41675
+ const { hooks, ...sessionConfig } = config2;
41676
+ return { sessionConfig, appServerStartupArgs: ["app-server", "-c", `hooks=${toToml(hooks)}`] };
41677
+ }
41678
+ function toToml(value) {
41679
+ if (Array.isArray(value)) return `[${value.map(toToml).join(", ")}]`;
41680
+ if (value !== null && typeof value === "object") {
41681
+ return `{ ${Object.entries(value).map(([key, item]) => `${JSON.stringify(key)} = ${toToml(item)}`).join(", ")} }`;
41682
+ }
41683
+ return JSON.stringify(value);
41684
+ }
41685
+
41128
41686
  // src/index.ts
41129
41687
  var emptyExtensionParamsParser = external_exports.preprocess(
41130
41688
  (params) => params ?? {},
@@ -41153,6 +41711,11 @@ var asyncTaskStopParamsParser = external_exports.object({
41153
41711
  sessionId: external_exports.string().trim().min(1),
41154
41712
  asyncTaskId: external_exports.string().trim().min(1)
41155
41713
  }).passthrough();
41714
+ var hooksListParamsParser = external_exports.object({ cwd: external_exports.string().trim().min(1) });
41715
+ var hooksTrustParamsParser = external_exports.object({
41716
+ cwd: external_exports.string().trim().min(1),
41717
+ hooks: external_exports.array(external_exports.object({ key: external_exports.string().min(1), currentHash: external_exports.string().min(1) })).min(1)
41718
+ });
41156
41719
  if (process.argv.includes("--version")) {
41157
41720
  console.log(`${package_default.name} ${package_default.version}`);
41158
41721
  process.exit(0);
@@ -41178,6 +41741,7 @@ function startAcpServer() {
41178
41741
  const authRequestString = process.env["DEFAULT_AUTH_REQUEST"];
41179
41742
  const modelProvider = process.env["MODEL_PROVIDER"];
41180
41743
  const config2 = configString ? JSON.parse(configString) : void 0;
41744
+ const hookConfig = prepareCodexHookConfig(config2);
41181
41745
  const parsedAuthRequest = authRequestString ? JSON.parse(authRequestString) : void 0;
41182
41746
  const defaultAuthRequest = parsedAuthRequest && isCodexAuthRequest(parsedAuthRequest) ? parsedAuthRequest : void 0;
41183
41747
  logger.log("Startup", {
@@ -41190,9 +41754,10 @@ function startAcpServer() {
41190
41754
  defaultAuthRequest: defaultAuthRequest ?? null
41191
41755
  });
41192
41756
  const codexProcessState = {
41193
- connection: startCodexConnection(codexPath),
41757
+ connection: startCodexConnection(codexPath, void 0, hookConfig.appServerStartupArgs),
41194
41758
  codexPath,
41195
- config: config2,
41759
+ config: hookConfig.sessionConfig,
41760
+ appServerStartupArgs: hookConfig.appServerStartupArgs,
41196
41761
  modelProvider,
41197
41762
  stderr: ""
41198
41763
  };
@@ -41208,7 +41773,7 @@ function startAcpServer() {
41208
41773
  const acpJsonStream = createJsonStream(process.stdin, process.stdout);
41209
41774
  function createAgent(connection) {
41210
41775
  const appServerClient = new CodexAppServerClient(codexProcessState.connection.connection);
41211
- const codexClient = new CodexAcpClient(appServerClient, config2, modelProvider);
41776
+ const codexClient = new CodexAcpClient(appServerClient, hookConfig.sessionConfig, modelProvider);
41212
41777
  return new CodexAcpServer(
41213
41778
  connection,
41214
41779
  codexClient,
@@ -41233,5 +41798,5 @@ function startAcpServer() {
41233
41798
  codexAcpServer = null;
41234
41799
  }
41235
41800
  });
41236
- }).onRequest(methods.agent.initialize, (ctx) => getAgent().initialize(ctx.params)).onRequest(methods.agent.session.new, (ctx) => getAgent().newSession(ctx.params)).onRequest(methods.agent.session.load, (ctx) => getAgent().loadSession(ctx.params)).onRequest(methods.agent.session.fork, (ctx) => getAgent().forkSession(ctx.params)).onRequest(methods.agent.session.list, (ctx) => getAgent().listSessions(ctx.params)).onRequest(methods.agent.session.delete, (ctx) => getAgent().deleteSession(ctx.params)).onRequest(methods.agent.session.resume, (ctx) => getAgent().resumeSession(ctx.params)).onRequest(methods.agent.session.close, (ctx) => getAgent().closeSession(ctx.params)).onRequest(methods.agent.session.setMode, (ctx) => getAgent().setSessionMode(ctx.params)).onRequest(methods.agent.session.setConfigOption, (ctx) => getAgent().setSessionConfigOption(ctx.params)).onRequest(methods.agent.authenticate, (ctx) => getAgent().authenticate(ctx.params, ctx.requestId)).onRequest(methods.agent.logout, (ctx) => getAgent().logout(ctx.params)).onRequest(methods.agent.providers.list, (ctx) => getAgent().listProviders(ctx.params)).onRequest(methods.agent.providers.set, (ctx) => getAgent().setProvider(ctx.params)).onRequest(methods.agent.providers.disable, (ctx) => getAgent().disableProvider(ctx.params)).onRequest(methods.agent.session.prompt, (ctx) => getAgent().prompt(ctx.params, ctx.signal)).onNotification(methods.agent.session.cancel, (ctx) => getAgent().cancel(ctx.params)).onRequest("authentication/status", emptyExtensionParamsParser, (ctx) => getAgent().extMethod("authentication/status", ctx.params)).onRequest("authentication/logout", emptyExtensionParamsParser, (ctx) => getAgent().extMethod("authentication/logout", ctx.params)).onRequest(LEGACY_SET_SESSION_MODEL_METHOD, legacySetSessionModelParamsParser, (ctx) => getAgent().extMethod(LEGACY_SET_SESSION_MODEL_METHOD, ctx.params)).onRequest(SESSION_STEERING_METHOD, sessionSteerParamsParser, (ctx) => getAgent().extMethod(SESSION_STEERING_METHOD, ctx.params)).onRequest(ASYNC_TASK_STOP_METHOD, asyncTaskStopParamsParser, (ctx) => getAgent().extMethod(ASYNC_TASK_STOP_METHOD, ctx.params)).onRequest(GOAL_CONTROL_METHOD, goalControlParamsParser, (ctx) => getAgent().extMethod(GOAL_CONTROL_METHOD, ctx.params)).connect(acpJsonStream);
41801
+ }).onRequest(methods.agent.initialize, (ctx) => getAgent().initialize(ctx.params)).onRequest(methods.agent.session.new, (ctx) => getAgent().newSession(ctx.params)).onRequest(methods.agent.session.load, (ctx) => getAgent().loadSession(ctx.params)).onRequest(methods.agent.session.fork, (ctx) => getAgent().forkSession(ctx.params)).onRequest(methods.agent.session.list, (ctx) => getAgent().listSessions(ctx.params)).onRequest(methods.agent.session.delete, (ctx) => getAgent().deleteSession(ctx.params)).onRequest(methods.agent.session.resume, (ctx) => getAgent().resumeSession(ctx.params)).onRequest(methods.agent.session.close, (ctx) => getAgent().closeSession(ctx.params)).onRequest(methods.agent.session.setMode, (ctx) => getAgent().setSessionMode(ctx.params)).onRequest(methods.agent.session.setConfigOption, (ctx) => getAgent().setSessionConfigOption(ctx.params)).onRequest(methods.agent.authenticate, (ctx) => getAgent().authenticate(ctx.params, ctx.requestId)).onRequest(methods.agent.logout, (ctx) => getAgent().logout(ctx.params)).onRequest(methods.agent.providers.list, (ctx) => getAgent().listProviders(ctx.params)).onRequest(methods.agent.providers.set, (ctx) => getAgent().setProvider(ctx.params)).onRequest(methods.agent.providers.disable, (ctx) => getAgent().disableProvider(ctx.params)).onRequest(methods.agent.session.prompt, (ctx) => getAgent().prompt(ctx.params, ctx.signal)).onNotification(methods.agent.session.cancel, (ctx) => getAgent().cancel(ctx.params)).onRequest("authentication/status", emptyExtensionParamsParser, (ctx) => getAgent().extMethod("authentication/status", ctx.params)).onRequest("authentication/logout", emptyExtensionParamsParser, (ctx) => getAgent().extMethod("authentication/logout", ctx.params)).onRequest(LEGACY_SET_SESSION_MODEL_METHOD, legacySetSessionModelParamsParser, (ctx) => getAgent().extMethod(LEGACY_SET_SESSION_MODEL_METHOD, ctx.params)).onRequest(SESSION_STEERING_METHOD, sessionSteerParamsParser, (ctx) => getAgent().extMethod(SESSION_STEERING_METHOD, ctx.params)).onRequest(ASYNC_TASK_STOP_METHOD, asyncTaskStopParamsParser, (ctx) => getAgent().extMethod(ASYNC_TASK_STOP_METHOD, ctx.params)).onRequest(CODEX_HOOKS_LIST_METHOD, hooksListParamsParser, (ctx) => getAgent().listHooks(ctx.params.cwd)).onRequest(CODEX_HOOKS_TRUST_METHOD, hooksTrustParamsParser, (ctx) => getAgent().trustHooks(ctx.params.cwd, ctx.params.hooks)).onRequest(GOAL_CONTROL_METHOD, goalControlParamsParser, (ctx) => getAgent().extMethod(GOAL_CONTROL_METHOD, ctx.params)).connect(acpJsonStream);
41237
41802
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.1.2-preview.4",
6
+ "version": "2.1.2-preview.5",
7
7
  "description": "",
8
8
  "main": "dist/index.js",
9
9
  "bin": {
@@ -57,6 +57,7 @@
57
57
  "license": "Apache-2.0",
58
58
  "type": "module",
59
59
  "devDependencies": {
60
+ "@types/cross-spawn": "^6.0.6",
60
61
  "@types/node": "^26.1.0",
61
62
  "ajv": "^8.20.0",
62
63
  "esbuild": "^0.28.2",
@@ -68,6 +69,7 @@
68
69
  "dependencies": {
69
70
  "@agentclientprotocol/sdk": "^1.5.0",
70
71
  "@openai/codex": "^0.160.1",
72
+ "cross-spawn": "^7.0.6",
71
73
  "diff": "^9.0.0",
72
74
  "open": "^11.0.1",
73
75
  "vscode-jsonrpc": "^9.0.1",