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

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 +588 -12
  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);
@@ -27444,6 +27943,7 @@ var AIR_EXTENSION_CAPABILITIES_KEY = "capabilities";
27444
27943
  var AIR_DIFF_PATCH_KEY = "diffPatch";
27445
27944
  var AIR_SESSION_FAILURE_KEY = "sessionFailure";
27446
27945
  var AIR_AGENT_FILE_CHANGE_REPORT_KEY = "agentFileChangeReport";
27946
+ var AIR_CUSTOM_INSTRUCTIONS_KEY = "customInstructions";
27447
27947
  var AIR_NATIVE_SUBAGENT_SESSIONS_KEY = "nativeSubagentSessions";
27448
27948
  var AIR_ASYNC_TASKS_KEY = "asyncTasks";
27449
27949
  var AIR_RECOMMENDED_CONFIG_VALUE_KEY = "recommendedValue";
@@ -27458,6 +27958,7 @@ var AIR_PERMISSION_KEY = "permission";
27458
27958
  var AIR_CONTEXT_COMPACTION_KEY = "contextCompaction";
27459
27959
  var AIR_RAW_INPUT_RENDERING_KEY = "rawInputRendering";
27460
27960
  var AIR_PLAN_CONTENT_DELTA_KEY = "planContentDelta";
27961
+ var AIR_CODEX_HOOKS_KEY = "codexHooks";
27461
27962
  var AIR_CONTENT_DELTA_KEY = "contentDelta";
27462
27963
  var AIR_SUBAGENT_KEY = "subagent";
27463
27964
  var AIR_CUSTOM_ANSWER_KEY = "customAnswer";
@@ -27496,6 +27997,13 @@ function clientSupportsAirCapability(capabilities, capability) {
27496
27997
  const supported = air[AIR_EXTENSION_CAPABILITIES_KEY];
27497
27998
  return typeof version2 === "number" && Number.isInteger(version2) && version2 >= AIR_EXTENSION_VERSION && Array.isArray(supported) && supported.includes(capability);
27498
27999
  }
28000
+ function airCustomInstructions(meta3) {
28001
+ const root = asRecord(meta3);
28002
+ const jetbrains = asRecord(root[JETBRAINS_META_KEY]);
28003
+ const air = asRecord(jetbrains[AIR_META_KEY]);
28004
+ const instructions = air[AIR_CUSTOM_INSTRUCTIONS_KEY];
28005
+ return typeof instructions === "string" ? instructions : void 0;
28006
+ }
27499
28007
  function asRecord(value) {
27500
28008
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
27501
28009
  }
@@ -33533,7 +34041,7 @@ var package_default = {
33533
34041
  publishConfig: {
33534
34042
  access: "public"
33535
34043
  },
33536
- version: "2.1.2-preview.4",
34044
+ version: "2.1.2-preview.6",
33537
34045
  description: "",
33538
34046
  main: "dist/index.js",
33539
34047
  bin: {
@@ -33587,6 +34095,7 @@ var package_default = {
33587
34095
  license: "Apache-2.0",
33588
34096
  type: "module",
33589
34097
  devDependencies: {
34098
+ "@types/cross-spawn": "^6.0.6",
33590
34099
  "@types/node": "^26.1.0",
33591
34100
  ajv: "^8.20.0",
33592
34101
  esbuild: "^0.28.2",
@@ -33598,6 +34107,7 @@ var package_default = {
33598
34107
  dependencies: {
33599
34108
  "@agentclientprotocol/sdk": "^1.5.0",
33600
34109
  "@openai/codex": "^0.160.1",
34110
+ "cross-spawn": "^7.0.6",
33601
34111
  diff: "^9.0.0",
33602
34112
  open: "^11.0.1",
33603
34113
  "vscode-jsonrpc": "^9.0.1",
@@ -34440,12 +34950,14 @@ var CodexAcpClient = class {
34440
34950
  }
34441
34951
  async newSession(request) {
34442
34952
  const additionalDirectories = readAdditionalDirectories(request.cwd, request.additionalDirectories, request._meta);
34953
+ const developerInstructions = airCustomInstructions(request._meta);
34443
34954
  await this.refreshSkills(request.cwd, additionalDirectories);
34444
34955
  const sessionConfig = await this.createSessionConfig(request.cwd, additionalDirectories, request.mcpServers);
34445
34956
  const response = await this.codexClient.threadStart({
34446
34957
  config: sessionConfig.config,
34447
34958
  modelProvider: this.getModelProvider(),
34448
- cwd: request.cwd
34959
+ cwd: request.cwd,
34960
+ ...developerInstructions !== void 0 && { developerInstructions }
34449
34961
  });
34450
34962
  const codexModels = await this.fetchAvailableModels();
34451
34963
  if (codexModels.length === 0) {
@@ -35782,6 +36294,12 @@ var CodexAppServerClient = class {
35782
36294
  async configRead(params) {
35783
36295
  return await this.sendRequest({ method: "config/read", params });
35784
36296
  }
36297
+ async hooksList(params) {
36298
+ return await this.sendRequest({ method: "hooks/list", params });
36299
+ }
36300
+ async configBatchWrite(params) {
36301
+ return await this.sendRequest({ method: "config/batchWrite", params });
36302
+ }
35785
36303
  async accountRead(params) {
35786
36304
  return await this.sendRequest({ method: "account/read", params });
35787
36305
  }
@@ -37614,6 +38132,33 @@ function clientSupportsSubagents(capabilities) {
37614
38132
  return clientSupportsAirCapability(capabilities, AIR_NATIVE_SUBAGENT_SESSIONS_KEY);
37615
38133
  }
37616
38134
 
38135
+ // src/CodexHookTrust.ts
38136
+ var CODEX_HOOKS_LIST_METHOD = "_codex/hooks/list";
38137
+ var CODEX_HOOKS_TRUST_METHOD = "_codex/hooks/trust";
38138
+ async function listCodexHooks(client, cwd) {
38139
+ const [entry] = (await client.hooksList({ cwds: [cwd] })).data;
38140
+ if (entry === void 0) throw new Error("Codex could not list hooks for the requested directory");
38141
+ return { ...entry, hooks: entry.hooks.filter((hook) => hook.source === "sessionFlags") };
38142
+ }
38143
+ async function trustCodexHooks(client, cwd, requested) {
38144
+ const isListed = (hooks, request) => hooks.find((hook) => hook.key === request.key && hook.currentHash === request.currentHash);
38145
+ const current = (await listCodexHooks(client, cwd)).hooks;
38146
+ const edits = requested.map((request) => {
38147
+ const hook = isListed(current, request);
38148
+ if (hook === void 0) throw new Error("A Codex hook changed before trust was recorded");
38149
+ return hook;
38150
+ }).filter((hook) => hook.trustStatus !== "trusted").map((hook) => ({
38151
+ keyPath: `hooks.state.${JSON.stringify(hook.key)}.trusted_hash`,
38152
+ value: hook.currentHash,
38153
+ mergeStrategy: "replace"
38154
+ }));
38155
+ if (edits.length > 0) {
38156
+ await client.configBatchWrite({ edits, reloadUserConfig: true });
38157
+ }
38158
+ const verified = (await listCodexHooks(client, cwd)).hooks;
38159
+ return requested.every((request) => isListed(verified, request)?.trustStatus === "trusted");
38160
+ }
38161
+
37617
38162
  // src/CodexAcpServer.ts
37618
38163
  import { randomUUID as randomUUID3 } from "node:crypto";
37619
38164
 
@@ -38342,11 +38887,13 @@ var CodexAcpServer = class {
38342
38887
  AIR_SESSION_FAILURE_KEY,
38343
38888
  AIR_DIFF_PATCH_KEY,
38344
38889
  AIR_AGENT_FILE_CHANGE_REPORT_KEY,
38890
+ AIR_CUSTOM_INSTRUCTIONS_KEY,
38345
38891
  AIR_NATIVE_SUBAGENT_SESSIONS_KEY,
38346
38892
  AIR_ASYNC_TASKS_KEY,
38347
38893
  AIR_RECOMMENDED_CONFIG_VALUE_KEY,
38348
38894
  AIR_RAW_INPUT_RENDERING_KEY,
38349
- AIR_PLAN_CONTENT_DELTA_KEY
38895
+ AIR_PLAN_CONTENT_DELTA_KEY,
38896
+ AIR_CODEX_HOOKS_KEY
38350
38897
  ]
38351
38898
  }
38352
38899
  }
@@ -38354,6 +38901,14 @@ var CodexAcpServer = class {
38354
38901
  }
38355
38902
  };
38356
38903
  }
38904
+ async listHooks(cwd) {
38905
+ if (this.providerUpdate !== null) await this.providerUpdate;
38906
+ return await this.runWithProcessCheck(() => listCodexHooks(this.codexAcpClient.appServerClient, cwd));
38907
+ }
38908
+ async trustHooks(cwd, hooks) {
38909
+ if (this.providerUpdate !== null) await this.providerUpdate;
38910
+ return { trusted: await this.runWithProcessCheck(() => trustCodexHooks(this.codexAcpClient.appServerClient, cwd, hooks)) };
38911
+ }
38357
38912
  async extMethod(method, params) {
38358
38913
  const methodRequest = { method, params };
38359
38914
  if (!isExtMethodRequest(methodRequest)) {
@@ -39149,7 +39704,7 @@ Check ${configPath} and project .codex directories, especially their config.toml
39149
39704
  await exited;
39150
39705
  clearTimeout(forceKill);
39151
39706
  state.stderr = "";
39152
- state.connection = startCodexConnection(state.codexPath);
39707
+ state.connection = startCodexConnection(state.codexPath, void 0, state.appServerStartupArgs);
39153
39708
  this.captureStderr();
39154
39709
  this.observeCodexProcess();
39155
39710
  return new CodexAcpClient(
@@ -41125,6 +41680,20 @@ function spawnCodexCli(codexPath, args) {
41125
41680
  return spawn2(process.execPath, [bundledCodexPath, ...args], options);
41126
41681
  }
41127
41682
 
41683
+ // src/CodexHookConfig.ts
41684
+ function prepareCodexHookConfig(config2) {
41685
+ if (config2?.["hooks"] === void 0) return { sessionConfig: config2, appServerStartupArgs: ["app-server"] };
41686
+ const { hooks, ...sessionConfig } = config2;
41687
+ return { sessionConfig, appServerStartupArgs: ["app-server", "-c", `hooks=${toToml(hooks)}`] };
41688
+ }
41689
+ function toToml(value) {
41690
+ if (Array.isArray(value)) return `[${value.map(toToml).join(", ")}]`;
41691
+ if (value !== null && typeof value === "object") {
41692
+ return `{ ${Object.entries(value).map(([key, item]) => `${JSON.stringify(key)} = ${toToml(item)}`).join(", ")} }`;
41693
+ }
41694
+ return JSON.stringify(value);
41695
+ }
41696
+
41128
41697
  // src/index.ts
41129
41698
  var emptyExtensionParamsParser = external_exports.preprocess(
41130
41699
  (params) => params ?? {},
@@ -41153,6 +41722,11 @@ var asyncTaskStopParamsParser = external_exports.object({
41153
41722
  sessionId: external_exports.string().trim().min(1),
41154
41723
  asyncTaskId: external_exports.string().trim().min(1)
41155
41724
  }).passthrough();
41725
+ var hooksListParamsParser = external_exports.object({ cwd: external_exports.string().trim().min(1) });
41726
+ var hooksTrustParamsParser = external_exports.object({
41727
+ cwd: external_exports.string().trim().min(1),
41728
+ hooks: external_exports.array(external_exports.object({ key: external_exports.string().min(1), currentHash: external_exports.string().min(1) })).min(1)
41729
+ });
41156
41730
  if (process.argv.includes("--version")) {
41157
41731
  console.log(`${package_default.name} ${package_default.version}`);
41158
41732
  process.exit(0);
@@ -41178,6 +41752,7 @@ function startAcpServer() {
41178
41752
  const authRequestString = process.env["DEFAULT_AUTH_REQUEST"];
41179
41753
  const modelProvider = process.env["MODEL_PROVIDER"];
41180
41754
  const config2 = configString ? JSON.parse(configString) : void 0;
41755
+ const hookConfig = prepareCodexHookConfig(config2);
41181
41756
  const parsedAuthRequest = authRequestString ? JSON.parse(authRequestString) : void 0;
41182
41757
  const defaultAuthRequest = parsedAuthRequest && isCodexAuthRequest(parsedAuthRequest) ? parsedAuthRequest : void 0;
41183
41758
  logger.log("Startup", {
@@ -41190,9 +41765,10 @@ function startAcpServer() {
41190
41765
  defaultAuthRequest: defaultAuthRequest ?? null
41191
41766
  });
41192
41767
  const codexProcessState = {
41193
- connection: startCodexConnection(codexPath),
41768
+ connection: startCodexConnection(codexPath, void 0, hookConfig.appServerStartupArgs),
41194
41769
  codexPath,
41195
- config: config2,
41770
+ config: hookConfig.sessionConfig,
41771
+ appServerStartupArgs: hookConfig.appServerStartupArgs,
41196
41772
  modelProvider,
41197
41773
  stderr: ""
41198
41774
  };
@@ -41208,7 +41784,7 @@ function startAcpServer() {
41208
41784
  const acpJsonStream = createJsonStream(process.stdin, process.stdout);
41209
41785
  function createAgent(connection) {
41210
41786
  const appServerClient = new CodexAppServerClient(codexProcessState.connection.connection);
41211
- const codexClient = new CodexAcpClient(appServerClient, config2, modelProvider);
41787
+ const codexClient = new CodexAcpClient(appServerClient, hookConfig.sessionConfig, modelProvider);
41212
41788
  return new CodexAcpServer(
41213
41789
  connection,
41214
41790
  codexClient,
@@ -41233,5 +41809,5 @@ function startAcpServer() {
41233
41809
  codexAcpServer = null;
41234
41810
  }
41235
41811
  });
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);
41812
+ }).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
41813
  }
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.6",
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",