@agentchatme/codex 0.0.171141 → 0.0.17114111
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.
- package/README.md +24 -12
- package/dist/daemon-main.js +692 -42
- package/dist/daemon-main.js.map +1 -1
- package/dist/index.js +891 -98
- package/dist/index.js.map +1 -1
- package/package.json +6 -8
package/dist/daemon-main.js
CHANGED
|
@@ -2275,7 +2275,7 @@ var require_websocket = __commonJS({
|
|
|
2275
2275
|
var http = __require("http");
|
|
2276
2276
|
var net = __require("net");
|
|
2277
2277
|
var tls = __require("tls");
|
|
2278
|
-
var { randomBytes, createHash } = __require("crypto");
|
|
2278
|
+
var { randomBytes, createHash: createHash2 } = __require("crypto");
|
|
2279
2279
|
var { Duplex, Readable } = __require("stream");
|
|
2280
2280
|
var { URL: URL2 } = __require("url");
|
|
2281
2281
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -2943,7 +2943,7 @@ var require_websocket = __commonJS({
|
|
|
2943
2943
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
2944
2944
|
return;
|
|
2945
2945
|
}
|
|
2946
|
-
const digest =
|
|
2946
|
+
const digest = createHash2("sha1").update(key + GUID).digest("base64");
|
|
2947
2947
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
2948
2948
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
2949
2949
|
return;
|
|
@@ -3312,7 +3312,7 @@ var require_websocket_server = __commonJS({
|
|
|
3312
3312
|
var EventEmitter2 = __require("events");
|
|
3313
3313
|
var http = __require("http");
|
|
3314
3314
|
var { Duplex } = __require("stream");
|
|
3315
|
-
var { createHash } = __require("crypto");
|
|
3315
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
3316
3316
|
var extension2 = require_extension();
|
|
3317
3317
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
3318
3318
|
var subprotocol2 = require_subprotocol();
|
|
@@ -3619,7 +3619,7 @@ var require_websocket_server = __commonJS({
|
|
|
3619
3619
|
);
|
|
3620
3620
|
}
|
|
3621
3621
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
3622
|
-
const digest =
|
|
3622
|
+
const digest = createHash2("sha1").update(key + GUID).digest("base64");
|
|
3623
3623
|
const headers = [
|
|
3624
3624
|
"HTTP/1.1 101 Switching Protocols",
|
|
3625
3625
|
"Upgrade: websocket",
|
|
@@ -3722,11 +3722,512 @@ var init_wrapper = __esm({
|
|
|
3722
3722
|
}
|
|
3723
3723
|
});
|
|
3724
3724
|
|
|
3725
|
+
// node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
3726
|
+
var require_windows = __commonJS({
|
|
3727
|
+
"node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
|
|
3728
|
+
"use strict";
|
|
3729
|
+
module.exports = isexe;
|
|
3730
|
+
isexe.sync = sync;
|
|
3731
|
+
var fs6 = __require("fs");
|
|
3732
|
+
function checkPathExt(path9, options) {
|
|
3733
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
3734
|
+
if (!pathext) {
|
|
3735
|
+
return true;
|
|
3736
|
+
}
|
|
3737
|
+
pathext = pathext.split(";");
|
|
3738
|
+
if (pathext.indexOf("") !== -1) {
|
|
3739
|
+
return true;
|
|
3740
|
+
}
|
|
3741
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
3742
|
+
var p = pathext[i].toLowerCase();
|
|
3743
|
+
if (p && path9.substr(-p.length).toLowerCase() === p) {
|
|
3744
|
+
return true;
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
return false;
|
|
3748
|
+
}
|
|
3749
|
+
function checkStat(stat, path9, options) {
|
|
3750
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
3751
|
+
return false;
|
|
3752
|
+
}
|
|
3753
|
+
return checkPathExt(path9, options);
|
|
3754
|
+
}
|
|
3755
|
+
function isexe(path9, options, cb) {
|
|
3756
|
+
fs6.stat(path9, function(er, stat) {
|
|
3757
|
+
cb(er, er ? false : checkStat(stat, path9, options));
|
|
3758
|
+
});
|
|
3759
|
+
}
|
|
3760
|
+
function sync(path9, options) {
|
|
3761
|
+
return checkStat(fs6.statSync(path9), path9, options);
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
});
|
|
3765
|
+
|
|
3766
|
+
// node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
|
|
3767
|
+
var require_mode = __commonJS({
|
|
3768
|
+
"node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
|
|
3769
|
+
"use strict";
|
|
3770
|
+
module.exports = isexe;
|
|
3771
|
+
isexe.sync = sync;
|
|
3772
|
+
var fs6 = __require("fs");
|
|
3773
|
+
function isexe(path9, options, cb) {
|
|
3774
|
+
fs6.stat(path9, function(er, stat) {
|
|
3775
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
3776
|
+
});
|
|
3777
|
+
}
|
|
3778
|
+
function sync(path9, options) {
|
|
3779
|
+
return checkStat(fs6.statSync(path9), options);
|
|
3780
|
+
}
|
|
3781
|
+
function checkStat(stat, options) {
|
|
3782
|
+
return stat.isFile() && checkMode(stat, options);
|
|
3783
|
+
}
|
|
3784
|
+
function checkMode(stat, options) {
|
|
3785
|
+
var mod = stat.mode;
|
|
3786
|
+
var uid = stat.uid;
|
|
3787
|
+
var gid = stat.gid;
|
|
3788
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
3789
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
3790
|
+
var u = parseInt("100", 8);
|
|
3791
|
+
var g = parseInt("010", 8);
|
|
3792
|
+
var o = parseInt("001", 8);
|
|
3793
|
+
var ug = u | g;
|
|
3794
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
3795
|
+
return ret;
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
});
|
|
3799
|
+
|
|
3800
|
+
// node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
3801
|
+
var require_isexe = __commonJS({
|
|
3802
|
+
"node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
3803
|
+
"use strict";
|
|
3804
|
+
var fs6 = __require("fs");
|
|
3805
|
+
var core;
|
|
3806
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
3807
|
+
core = require_windows();
|
|
3808
|
+
} else {
|
|
3809
|
+
core = require_mode();
|
|
3810
|
+
}
|
|
3811
|
+
module.exports = isexe;
|
|
3812
|
+
isexe.sync = sync;
|
|
3813
|
+
function isexe(path9, options, cb) {
|
|
3814
|
+
if (typeof options === "function") {
|
|
3815
|
+
cb = options;
|
|
3816
|
+
options = {};
|
|
3817
|
+
}
|
|
3818
|
+
if (!cb) {
|
|
3819
|
+
if (typeof Promise !== "function") {
|
|
3820
|
+
throw new TypeError("callback not provided");
|
|
3821
|
+
}
|
|
3822
|
+
return new Promise(function(resolve5, reject) {
|
|
3823
|
+
isexe(path9, options || {}, function(er, is) {
|
|
3824
|
+
if (er) {
|
|
3825
|
+
reject(er);
|
|
3826
|
+
} else {
|
|
3827
|
+
resolve5(is);
|
|
3828
|
+
}
|
|
3829
|
+
});
|
|
3830
|
+
});
|
|
3831
|
+
}
|
|
3832
|
+
core(path9, options || {}, function(er, is) {
|
|
3833
|
+
if (er) {
|
|
3834
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
3835
|
+
er = null;
|
|
3836
|
+
is = false;
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
cb(er, is);
|
|
3840
|
+
});
|
|
3841
|
+
}
|
|
3842
|
+
function sync(path9, options) {
|
|
3843
|
+
try {
|
|
3844
|
+
return core.sync(path9, options || {});
|
|
3845
|
+
} catch (er) {
|
|
3846
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
3847
|
+
return false;
|
|
3848
|
+
} else {
|
|
3849
|
+
throw er;
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
});
|
|
3855
|
+
|
|
3856
|
+
// node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
|
|
3857
|
+
var require_which = __commonJS({
|
|
3858
|
+
"node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
3859
|
+
"use strict";
|
|
3860
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
3861
|
+
var path9 = __require("path");
|
|
3862
|
+
var COLON = isWindows ? ";" : ":";
|
|
3863
|
+
var isexe = require_isexe();
|
|
3864
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
3865
|
+
var getPathInfo = (cmd, opt) => {
|
|
3866
|
+
const colon = opt.colon || COLON;
|
|
3867
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
3868
|
+
// windows always checks the cwd first
|
|
3869
|
+
...isWindows ? [process.cwd()] : [],
|
|
3870
|
+
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
3871
|
+
"").split(colon)
|
|
3872
|
+
];
|
|
3873
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
3874
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
3875
|
+
if (isWindows) {
|
|
3876
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
3877
|
+
pathExt.unshift("");
|
|
3878
|
+
}
|
|
3879
|
+
return {
|
|
3880
|
+
pathEnv,
|
|
3881
|
+
pathExt,
|
|
3882
|
+
pathExtExe
|
|
3883
|
+
};
|
|
3884
|
+
};
|
|
3885
|
+
var which = (cmd, opt, cb) => {
|
|
3886
|
+
if (typeof opt === "function") {
|
|
3887
|
+
cb = opt;
|
|
3888
|
+
opt = {};
|
|
3889
|
+
}
|
|
3890
|
+
if (!opt)
|
|
3891
|
+
opt = {};
|
|
3892
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
3893
|
+
const found = [];
|
|
3894
|
+
const step = (i) => new Promise((resolve5, reject) => {
|
|
3895
|
+
if (i === pathEnv.length)
|
|
3896
|
+
return opt.all && found.length ? resolve5(found) : reject(getNotFoundError(cmd));
|
|
3897
|
+
const ppRaw = pathEnv[i];
|
|
3898
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
3899
|
+
const pCmd = path9.join(pathPart, cmd);
|
|
3900
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
3901
|
+
resolve5(subStep(p, i, 0));
|
|
3902
|
+
});
|
|
3903
|
+
const subStep = (p, i, ii) => new Promise((resolve5, reject) => {
|
|
3904
|
+
if (ii === pathExt.length)
|
|
3905
|
+
return resolve5(step(i + 1));
|
|
3906
|
+
const ext = pathExt[ii];
|
|
3907
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
3908
|
+
if (!er && is) {
|
|
3909
|
+
if (opt.all)
|
|
3910
|
+
found.push(p + ext);
|
|
3911
|
+
else
|
|
3912
|
+
return resolve5(p + ext);
|
|
3913
|
+
}
|
|
3914
|
+
return resolve5(subStep(p, i, ii + 1));
|
|
3915
|
+
});
|
|
3916
|
+
});
|
|
3917
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
3918
|
+
};
|
|
3919
|
+
var whichSync = (cmd, opt) => {
|
|
3920
|
+
opt = opt || {};
|
|
3921
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
3922
|
+
const found = [];
|
|
3923
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
3924
|
+
const ppRaw = pathEnv[i];
|
|
3925
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
3926
|
+
const pCmd = path9.join(pathPart, cmd);
|
|
3927
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
3928
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
3929
|
+
const cur = p + pathExt[j];
|
|
3930
|
+
try {
|
|
3931
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
3932
|
+
if (is) {
|
|
3933
|
+
if (opt.all)
|
|
3934
|
+
found.push(cur);
|
|
3935
|
+
else
|
|
3936
|
+
return cur;
|
|
3937
|
+
}
|
|
3938
|
+
} catch (ex) {
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
if (opt.all && found.length)
|
|
3943
|
+
return found;
|
|
3944
|
+
if (opt.nothrow)
|
|
3945
|
+
return null;
|
|
3946
|
+
throw getNotFoundError(cmd);
|
|
3947
|
+
};
|
|
3948
|
+
module.exports = which;
|
|
3949
|
+
which.sync = whichSync;
|
|
3950
|
+
}
|
|
3951
|
+
});
|
|
3952
|
+
|
|
3953
|
+
// node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
|
|
3954
|
+
var require_path_key = __commonJS({
|
|
3955
|
+
"node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
|
|
3956
|
+
"use strict";
|
|
3957
|
+
var pathKey = (options = {}) => {
|
|
3958
|
+
const environment = options.env || process.env;
|
|
3959
|
+
const platform = options.platform || process.platform;
|
|
3960
|
+
if (platform !== "win32") {
|
|
3961
|
+
return "PATH";
|
|
3962
|
+
}
|
|
3963
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
3964
|
+
};
|
|
3965
|
+
module.exports = pathKey;
|
|
3966
|
+
module.exports.default = pathKey;
|
|
3967
|
+
}
|
|
3968
|
+
});
|
|
3969
|
+
|
|
3970
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
3971
|
+
var require_resolveCommand = __commonJS({
|
|
3972
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
3973
|
+
"use strict";
|
|
3974
|
+
var path9 = __require("path");
|
|
3975
|
+
var which = require_which();
|
|
3976
|
+
var getPathKey = require_path_key();
|
|
3977
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
3978
|
+
const env = parsed.options.env || process.env;
|
|
3979
|
+
const cwd = process.cwd();
|
|
3980
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
3981
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
3982
|
+
if (shouldSwitchCwd) {
|
|
3983
|
+
try {
|
|
3984
|
+
process.chdir(parsed.options.cwd);
|
|
3985
|
+
} catch (err) {
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
let resolved;
|
|
3989
|
+
try {
|
|
3990
|
+
resolved = which.sync(parsed.command, {
|
|
3991
|
+
path: env[getPathKey({ env })],
|
|
3992
|
+
pathExt: withoutPathExt ? path9.delimiter : void 0
|
|
3993
|
+
});
|
|
3994
|
+
} catch (e) {
|
|
3995
|
+
} finally {
|
|
3996
|
+
if (shouldSwitchCwd) {
|
|
3997
|
+
process.chdir(cwd);
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
if (resolved) {
|
|
4001
|
+
resolved = path9.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
4002
|
+
}
|
|
4003
|
+
return resolved;
|
|
4004
|
+
}
|
|
4005
|
+
function resolveCommand(parsed) {
|
|
4006
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
4007
|
+
}
|
|
4008
|
+
module.exports = resolveCommand;
|
|
4009
|
+
}
|
|
4010
|
+
});
|
|
4011
|
+
|
|
4012
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
4013
|
+
var require_escape = __commonJS({
|
|
4014
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
|
|
4015
|
+
"use strict";
|
|
4016
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
4017
|
+
function escapeCommand(arg) {
|
|
4018
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
4019
|
+
return arg;
|
|
4020
|
+
}
|
|
4021
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
4022
|
+
arg = `${arg}`;
|
|
4023
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
4024
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
4025
|
+
arg = `"${arg}"`;
|
|
4026
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
4027
|
+
if (doubleEscapeMetaChars) {
|
|
4028
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
4029
|
+
}
|
|
4030
|
+
return arg;
|
|
4031
|
+
}
|
|
4032
|
+
module.exports.command = escapeCommand;
|
|
4033
|
+
module.exports.argument = escapeArgument;
|
|
4034
|
+
}
|
|
4035
|
+
});
|
|
4036
|
+
|
|
4037
|
+
// node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
|
|
4038
|
+
var require_shebang_regex = __commonJS({
|
|
4039
|
+
"node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
|
|
4040
|
+
"use strict";
|
|
4041
|
+
module.exports = /^#!(.*)/;
|
|
4042
|
+
}
|
|
4043
|
+
});
|
|
4044
|
+
|
|
4045
|
+
// node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
|
|
4046
|
+
var require_shebang_command = __commonJS({
|
|
4047
|
+
"node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
|
|
4048
|
+
"use strict";
|
|
4049
|
+
var shebangRegex = require_shebang_regex();
|
|
4050
|
+
module.exports = (string = "") => {
|
|
4051
|
+
const match = string.match(shebangRegex);
|
|
4052
|
+
if (!match) {
|
|
4053
|
+
return null;
|
|
4054
|
+
}
|
|
4055
|
+
const [path9, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
4056
|
+
const binary = path9.split("/").pop();
|
|
4057
|
+
if (binary === "env") {
|
|
4058
|
+
return argument;
|
|
4059
|
+
}
|
|
4060
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
4061
|
+
};
|
|
4062
|
+
}
|
|
4063
|
+
});
|
|
4064
|
+
|
|
4065
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
4066
|
+
var require_readShebang = __commonJS({
|
|
4067
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
4068
|
+
"use strict";
|
|
4069
|
+
var fs6 = __require("fs");
|
|
4070
|
+
var shebangCommand = require_shebang_command();
|
|
4071
|
+
function readShebang(command) {
|
|
4072
|
+
const size = 150;
|
|
4073
|
+
const buffer = Buffer.alloc(size);
|
|
4074
|
+
let fd;
|
|
4075
|
+
try {
|
|
4076
|
+
fd = fs6.openSync(command, "r");
|
|
4077
|
+
fs6.readSync(fd, buffer, 0, size, 0);
|
|
4078
|
+
fs6.closeSync(fd);
|
|
4079
|
+
} catch (e) {
|
|
4080
|
+
}
|
|
4081
|
+
return shebangCommand(buffer.toString());
|
|
4082
|
+
}
|
|
4083
|
+
module.exports = readShebang;
|
|
4084
|
+
}
|
|
4085
|
+
});
|
|
4086
|
+
|
|
4087
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
4088
|
+
var require_parse = __commonJS({
|
|
4089
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
4090
|
+
"use strict";
|
|
4091
|
+
var path9 = __require("path");
|
|
4092
|
+
var resolveCommand = require_resolveCommand();
|
|
4093
|
+
var escape = require_escape();
|
|
4094
|
+
var readShebang = require_readShebang();
|
|
4095
|
+
var isWin = process.platform === "win32";
|
|
4096
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
4097
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
4098
|
+
function detectShebang(parsed) {
|
|
4099
|
+
parsed.file = resolveCommand(parsed);
|
|
4100
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
4101
|
+
if (shebang) {
|
|
4102
|
+
parsed.args.unshift(parsed.file);
|
|
4103
|
+
parsed.command = shebang;
|
|
4104
|
+
return resolveCommand(parsed);
|
|
4105
|
+
}
|
|
4106
|
+
return parsed.file;
|
|
4107
|
+
}
|
|
4108
|
+
function parseNonShell(parsed) {
|
|
4109
|
+
if (!isWin) {
|
|
4110
|
+
return parsed;
|
|
4111
|
+
}
|
|
4112
|
+
const commandFile = detectShebang(parsed);
|
|
4113
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
4114
|
+
if (parsed.options.forceShell || needsShell) {
|
|
4115
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
4116
|
+
parsed.command = path9.normalize(parsed.command);
|
|
4117
|
+
parsed.command = escape.command(parsed.command);
|
|
4118
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
4119
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
4120
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
4121
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
4122
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
4123
|
+
}
|
|
4124
|
+
return parsed;
|
|
4125
|
+
}
|
|
4126
|
+
function parse(command, args, options) {
|
|
4127
|
+
if (args && !Array.isArray(args)) {
|
|
4128
|
+
options = args;
|
|
4129
|
+
args = null;
|
|
4130
|
+
}
|
|
4131
|
+
args = args ? args.slice(0) : [];
|
|
4132
|
+
options = Object.assign({}, options);
|
|
4133
|
+
const parsed = {
|
|
4134
|
+
command,
|
|
4135
|
+
args,
|
|
4136
|
+
options,
|
|
4137
|
+
file: void 0,
|
|
4138
|
+
original: {
|
|
4139
|
+
command,
|
|
4140
|
+
args
|
|
4141
|
+
}
|
|
4142
|
+
};
|
|
4143
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
4144
|
+
}
|
|
4145
|
+
module.exports = parse;
|
|
4146
|
+
}
|
|
4147
|
+
});
|
|
4148
|
+
|
|
4149
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
4150
|
+
var require_enoent = __commonJS({
|
|
4151
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
|
|
4152
|
+
"use strict";
|
|
4153
|
+
var isWin = process.platform === "win32";
|
|
4154
|
+
function notFoundError(original, syscall) {
|
|
4155
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
4156
|
+
code: "ENOENT",
|
|
4157
|
+
errno: "ENOENT",
|
|
4158
|
+
syscall: `${syscall} ${original.command}`,
|
|
4159
|
+
path: original.command,
|
|
4160
|
+
spawnargs: original.args
|
|
4161
|
+
});
|
|
4162
|
+
}
|
|
4163
|
+
function hookChildProcess(cp, parsed) {
|
|
4164
|
+
if (!isWin) {
|
|
4165
|
+
return;
|
|
4166
|
+
}
|
|
4167
|
+
const originalEmit = cp.emit;
|
|
4168
|
+
cp.emit = function(name, arg1) {
|
|
4169
|
+
if (name === "exit") {
|
|
4170
|
+
const err = verifyENOENT(arg1, parsed);
|
|
4171
|
+
if (err) {
|
|
4172
|
+
return originalEmit.call(cp, "error", err);
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
return originalEmit.apply(cp, arguments);
|
|
4176
|
+
};
|
|
4177
|
+
}
|
|
4178
|
+
function verifyENOENT(status, parsed) {
|
|
4179
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
4180
|
+
return notFoundError(parsed.original, "spawn");
|
|
4181
|
+
}
|
|
4182
|
+
return null;
|
|
4183
|
+
}
|
|
4184
|
+
function verifyENOENTSync(status, parsed) {
|
|
4185
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
4186
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
4187
|
+
}
|
|
4188
|
+
return null;
|
|
4189
|
+
}
|
|
4190
|
+
module.exports = {
|
|
4191
|
+
hookChildProcess,
|
|
4192
|
+
verifyENOENT,
|
|
4193
|
+
verifyENOENTSync,
|
|
4194
|
+
notFoundError
|
|
4195
|
+
};
|
|
4196
|
+
}
|
|
4197
|
+
});
|
|
4198
|
+
|
|
4199
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
|
|
4200
|
+
var require_cross_spawn = __commonJS({
|
|
4201
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
|
|
4202
|
+
"use strict";
|
|
4203
|
+
var cp = __require("child_process");
|
|
4204
|
+
var parse = require_parse();
|
|
4205
|
+
var enoent = require_enoent();
|
|
4206
|
+
function spawn(command, args, options) {
|
|
4207
|
+
const parsed = parse(command, args, options);
|
|
4208
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
4209
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
4210
|
+
return spawned;
|
|
4211
|
+
}
|
|
4212
|
+
function spawnSync(command, args, options) {
|
|
4213
|
+
const parsed = parse(command, args, options);
|
|
4214
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
4215
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
4216
|
+
return result;
|
|
4217
|
+
}
|
|
4218
|
+
module.exports = spawn;
|
|
4219
|
+
module.exports.spawn = spawn;
|
|
4220
|
+
module.exports.sync = spawnSync;
|
|
4221
|
+
module.exports._parse = parse;
|
|
4222
|
+
module.exports._enoent = enoent;
|
|
4223
|
+
}
|
|
4224
|
+
});
|
|
4225
|
+
|
|
3725
4226
|
// src/daemon-main.ts
|
|
3726
4227
|
import { parseArgs } from "util";
|
|
3727
4228
|
import * as path8 from "path";
|
|
3728
4229
|
|
|
3729
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
4230
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.13131111/node_modules/@agentchatme/agent-core/dist/chunk-Y4REWBSV.js
|
|
3730
4231
|
import * as fs from "fs";
|
|
3731
4232
|
import * as path from "path";
|
|
3732
4233
|
import * as fs2 from "fs";
|
|
@@ -3757,7 +4258,7 @@ var log = {
|
|
|
3757
4258
|
info: (msg) => emit("info", msg),
|
|
3758
4259
|
debug: (msg) => emit("debug", msg)
|
|
3759
4260
|
};
|
|
3760
|
-
var VERSION = "0.0.
|
|
4261
|
+
var VERSION = "0.0.13131111";
|
|
3761
4262
|
var CODING_AGENTS_CLIENT_IDENTITY = {
|
|
3762
4263
|
name: "coding_agents",
|
|
3763
4264
|
version: VERSION
|
|
@@ -8010,7 +8511,7 @@ function idle(home) {
|
|
|
8010
8511
|
}
|
|
8011
8512
|
}
|
|
8012
8513
|
|
|
8013
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
8514
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.13131111/node_modules/@agentchatme/agent-core/dist/daemon-entry.js
|
|
8014
8515
|
init_wrapper();
|
|
8015
8516
|
import { EventEmitter } from "events";
|
|
8016
8517
|
import * as path32 from "path";
|
|
@@ -8655,7 +9156,7 @@ var Daemon = class {
|
|
|
8655
9156
|
candidates.map((row) => row.id)
|
|
8656
9157
|
);
|
|
8657
9158
|
const claimedCount = claim.claimedCount;
|
|
8658
|
-
|
|
9159
|
+
let batch = candidates.slice(0, claimedCount);
|
|
8659
9160
|
if (claimedCount < candidates.length) {
|
|
8660
9161
|
if (claim.deferred) {
|
|
8661
9162
|
this.foregroundClaimsBlockedUntil = Math.max(
|
|
@@ -8684,6 +9185,44 @@ var Daemon = class {
|
|
|
8684
9185
|
}
|
|
8685
9186
|
if (batch.length === 0) return;
|
|
8686
9187
|
while (!this.stopping) {
|
|
9188
|
+
const renewed = await this.coord.claimBatch(batch.map((row) => row.id));
|
|
9189
|
+
if (renewed.claimedCount < batch.length) {
|
|
9190
|
+
const lost = batch.slice(renewed.claimedCount);
|
|
9191
|
+
batch = batch.slice(0, renewed.claimedCount);
|
|
9192
|
+
if (renewed.deferred) {
|
|
9193
|
+
this.foregroundClaimsBlockedUntil = Math.max(
|
|
9194
|
+
this.foregroundClaimsBlockedUntil,
|
|
9195
|
+
Date.now() + FOREGROUND_RECHECK_MS
|
|
9196
|
+
);
|
|
9197
|
+
for (const row of lost) {
|
|
9198
|
+
const state = this.seen.get(row.id);
|
|
9199
|
+
if (state) {
|
|
9200
|
+
state.status = "queued";
|
|
9201
|
+
state.updatedAt = Date.now();
|
|
9202
|
+
}
|
|
9203
|
+
}
|
|
9204
|
+
const current = this.convQueues.get(conversationId) ?? [];
|
|
9205
|
+
this.convQueues.set(conversationId, [...lost, ...current]);
|
|
9206
|
+
} else {
|
|
9207
|
+
const conflict = lost[0];
|
|
9208
|
+
log.info(`msg ${conflict.id}: renewal lost to a live session \u2014 standing down`);
|
|
9209
|
+
this.seen.delete(conflict.id);
|
|
9210
|
+
this.markNoLongerPending();
|
|
9211
|
+
const tail = lost.slice(1);
|
|
9212
|
+
for (const row of tail) {
|
|
9213
|
+
const state = this.seen.get(row.id);
|
|
9214
|
+
if (state) {
|
|
9215
|
+
state.status = "queued";
|
|
9216
|
+
state.updatedAt = Date.now();
|
|
9217
|
+
}
|
|
9218
|
+
}
|
|
9219
|
+
if (tail.length > 0) {
|
|
9220
|
+
const current = this.convQueues.get(conversationId) ?? [];
|
|
9221
|
+
this.convQueues.set(conversationId, [...tail, ...current]);
|
|
9222
|
+
}
|
|
9223
|
+
}
|
|
9224
|
+
}
|
|
9225
|
+
if (batch.length === 0) return;
|
|
8687
9226
|
const states = batch.map((row) => this.seen.get(row.id));
|
|
8688
9227
|
if (states.some(
|
|
8689
9228
|
(state) => state === void 0 || state.status === "handled"
|
|
@@ -8985,22 +9524,24 @@ async function runDaemon(opts) {
|
|
|
8985
9524
|
}
|
|
8986
9525
|
|
|
8987
9526
|
// src/adapter.ts
|
|
9527
|
+
import * as crypto2 from "crypto";
|
|
8988
9528
|
import * as fs5 from "fs";
|
|
8989
9529
|
import * as path6 from "path";
|
|
8990
|
-
import { spawn, spawnSync } from "child_process";
|
|
8991
9530
|
|
|
8992
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
9531
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.13131111/node_modules/@agentchatme/agent-core/dist/index.js
|
|
9532
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
8993
9533
|
var SESSION_TTL_MS = 48 * 60 * 60 * 1e3;
|
|
8994
9534
|
var SessionStateSchema = external_exports.object({
|
|
8995
9535
|
continuations: external_exports.number().int().min(0),
|
|
8996
9536
|
updated_at: external_exports.string(),
|
|
8997
|
-
// Ack cursor for
|
|
8998
|
-
//
|
|
8999
|
-
//
|
|
9000
|
-
//
|
|
9001
|
-
|
|
9002
|
-
//
|
|
9003
|
-
|
|
9537
|
+
// Ack cursor for hook context already handed to the host but not yet proven
|
|
9538
|
+
// through a completed model boundary. UserPromptSubmit and Stop stage it;
|
|
9539
|
+
// the following Stop commits it. A session that dies in between leaves the
|
|
9540
|
+
// server delivery unacked, preferring a later duplicate over silent loss.
|
|
9541
|
+
pending_ack: external_exports.string().optional(),
|
|
9542
|
+
// Stop context needs the specific host-created continuation, not merely an
|
|
9543
|
+
// unrelated later turn that happens to reach Stop.
|
|
9544
|
+
pending_ack_requires_continuation: external_exports.boolean().optional()
|
|
9004
9545
|
});
|
|
9005
9546
|
var StateSchema = external_exports.object({
|
|
9006
9547
|
sessions: external_exports.record(SessionStateSchema).default({}),
|
|
@@ -9015,14 +9556,17 @@ var StateSchema = external_exports.object({
|
|
|
9015
9556
|
offer_declined_at: external_exports.string().optional()
|
|
9016
9557
|
});
|
|
9017
9558
|
var OFFER_COOLDOWN_MS = 24 * 60 * 60 * 1e3;
|
|
9559
|
+
var spawnCommand = import_cross_spawn.default;
|
|
9560
|
+
var spawnCommandSync = import_cross_spawn.default.sync;
|
|
9018
9561
|
|
|
9019
9562
|
// src/version.ts
|
|
9020
|
-
var VERSION2 = "0.0.
|
|
9563
|
+
var VERSION2 = "0.0.17114111";
|
|
9021
9564
|
|
|
9022
9565
|
// src/adapter.ts
|
|
9023
9566
|
var TURN_TIMEOUT_MS = 24e4;
|
|
9024
9567
|
var MAX_EVENT_TAIL_CHARS = 1024 * 1024;
|
|
9025
|
-
var AGENTCHAT_MCP_PACKAGE = "@agentchatme/mcp@0.1.
|
|
9568
|
+
var AGENTCHAT_MCP_PACKAGE = "@agentchatme/mcp@0.1.1121411";
|
|
9569
|
+
var MIN_CODEX_VERSION = "0.129.0";
|
|
9026
9570
|
var THREAD_STORE_VERSION = 1;
|
|
9027
9571
|
function loadCodexThreads(file, identityNamespace) {
|
|
9028
9572
|
const stored = readJsonFile(file);
|
|
@@ -9038,11 +9582,48 @@ function loadCodexThreads(file, identityNamespace) {
|
|
|
9038
9582
|
function tomlString(value) {
|
|
9039
9583
|
return JSON.stringify(value);
|
|
9040
9584
|
}
|
|
9041
|
-
function
|
|
9585
|
+
function semverAtLeast(actual, minimum) {
|
|
9586
|
+
const parse = (value) => {
|
|
9587
|
+
const match = value.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
9588
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
9589
|
+
};
|
|
9590
|
+
const a = parse(actual);
|
|
9591
|
+
const b = parse(minimum);
|
|
9592
|
+
if (a === null || b === null) return false;
|
|
9593
|
+
for (let index = 0; index < 3; index++) {
|
|
9594
|
+
if (a[index] !== b[index]) return (a[index] ?? 0) > (b[index] ?? 0);
|
|
9595
|
+
}
|
|
9596
|
+
return true;
|
|
9597
|
+
}
|
|
9598
|
+
function inspectCodexRuntime() {
|
|
9599
|
+
const result = spawnCommandSync("codex", ["--version"], {
|
|
9600
|
+
encoding: "utf-8",
|
|
9601
|
+
timeout: 5e3,
|
|
9602
|
+
windowsHide: true
|
|
9603
|
+
});
|
|
9604
|
+
if (result.error || result.status !== 0) {
|
|
9605
|
+
return {
|
|
9606
|
+
ok: false,
|
|
9607
|
+
detail: result.error?.message ?? `${result.stderr || result.stdout || `exited ${result.status}`}`.trim()
|
|
9608
|
+
};
|
|
9609
|
+
}
|
|
9610
|
+
const rendered = String(result.stdout || result.stderr).trim();
|
|
9611
|
+
return semverAtLeast(rendered, MIN_CODEX_VERSION) ? { ok: true, detail: rendered } : {
|
|
9612
|
+
ok: false,
|
|
9613
|
+
detail: `${rendered || "unrecognized version"}; AgentChat requires Codex >= ${MIN_CODEX_VERSION} for trusted lifecycle hooks`
|
|
9614
|
+
};
|
|
9615
|
+
}
|
|
9616
|
+
function turnIdempotencyKey(ctx, identityNamespace) {
|
|
9617
|
+
const messageIds = ctx.pendingBatch?.messageIds ?? [ctx.messageId];
|
|
9618
|
+
const digest = crypto2.createHash("sha256").update("agentchat-daemon-turn-v1\0").update(identityNamespace).update("\0").update(ctx.conversationId).update("\0").update(messageIds.join("\0")).digest("hex");
|
|
9619
|
+
return `ac_turn_${digest}`;
|
|
9620
|
+
}
|
|
9621
|
+
function turnConfig(identityHome2, idempotencyKey) {
|
|
9042
9622
|
const env = {
|
|
9043
9623
|
AGENTCHAT_HOME: identityHome2,
|
|
9044
9624
|
AGENTCHAT_CLIENT_NAME: "codex",
|
|
9045
|
-
AGENTCHAT_CLIENT_VERSION: VERSION2
|
|
9625
|
+
AGENTCHAT_CLIENT_VERSION: VERSION2,
|
|
9626
|
+
AGENTCHAT_TURN_IDEMPOTENCY_KEY: idempotencyKey
|
|
9046
9627
|
};
|
|
9047
9628
|
const config = [
|
|
9048
9629
|
["mcp_servers.agentchat.command", tomlString("npx")],
|
|
@@ -9059,12 +9640,12 @@ function turnConfig(identityHome2) {
|
|
|
9059
9640
|
];
|
|
9060
9641
|
return config.flatMap(([key, value]) => ["-c", `${key}=${value}`]);
|
|
9061
9642
|
}
|
|
9062
|
-
function buildCodexArgs(ctx, identityHome2, workdir, priorThread) {
|
|
9643
|
+
function buildCodexArgs(ctx, identityHome2, workdir, priorThread, idempotencyKey = turnIdempotencyKey(ctx, "unbound")) {
|
|
9063
9644
|
const prompt = buildPrompt(ctx);
|
|
9064
9645
|
const common = [
|
|
9065
9646
|
"--json",
|
|
9066
9647
|
"--skip-git-repo-check",
|
|
9067
|
-
...turnConfig(identityHome2)
|
|
9648
|
+
...turnConfig(identityHome2, idempotencyKey)
|
|
9068
9649
|
];
|
|
9069
9650
|
return priorThread ? ["exec", "resume", priorThread, ...common, prompt] : ["exec", ...common, "-C", workdir, prompt];
|
|
9070
9651
|
}
|
|
@@ -9072,7 +9653,7 @@ function killProcessTree(child) {
|
|
|
9072
9653
|
if (child.pid === void 0) return;
|
|
9073
9654
|
try {
|
|
9074
9655
|
if (process.platform === "win32") {
|
|
9075
|
-
|
|
9656
|
+
spawnCommandSync("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
9076
9657
|
windowsHide: true,
|
|
9077
9658
|
stdio: "ignore"
|
|
9078
9659
|
});
|
|
@@ -9089,6 +9670,60 @@ function killProcessTree(child) {
|
|
|
9089
9670
|
function fatalRuntimeError(detail) {
|
|
9090
9671
|
return /not logged in|authentication|unauthorized|invalid api key|login required/i.test(detail);
|
|
9091
9672
|
}
|
|
9673
|
+
function resultIsError(result) {
|
|
9674
|
+
if (typeof result !== "object" || result === null) return false;
|
|
9675
|
+
const record = result;
|
|
9676
|
+
return record["isError"] === true || record["is_error"] === true;
|
|
9677
|
+
}
|
|
9678
|
+
var CodexTurnEvents = class {
|
|
9679
|
+
threadId;
|
|
9680
|
+
pending = /* @__PURE__ */ new Set();
|
|
9681
|
+
anonymousPending = 0;
|
|
9682
|
+
successfulSends = 0;
|
|
9683
|
+
failure = null;
|
|
9684
|
+
consume(event) {
|
|
9685
|
+
if (typeof event !== "object" || event === null) return;
|
|
9686
|
+
const record = event;
|
|
9687
|
+
if (record["type"] === "thread.started" && typeof record["thread_id"] === "string") {
|
|
9688
|
+
this.threadId = record["thread_id"];
|
|
9689
|
+
}
|
|
9690
|
+
const item = record["item"];
|
|
9691
|
+
if (typeof item !== "object" || item === null) return;
|
|
9692
|
+
const tool = item;
|
|
9693
|
+
if (tool["type"] !== "mcp_tool_call" || tool["server"] !== "agentchat" || tool["tool"] !== "agentchat_send_message") {
|
|
9694
|
+
return;
|
|
9695
|
+
}
|
|
9696
|
+
const id = typeof tool["id"] === "string" ? tool["id"] : null;
|
|
9697
|
+
if (record["type"] === "item.started") {
|
|
9698
|
+
if (id !== null) this.pending.add(id);
|
|
9699
|
+
else this.anonymousPending += 1;
|
|
9700
|
+
return;
|
|
9701
|
+
}
|
|
9702
|
+
if (record["type"] !== "item.completed") return;
|
|
9703
|
+
if (id !== null) this.pending.delete(id);
|
|
9704
|
+
else this.anonymousPending = Math.max(0, this.anonymousPending - 1);
|
|
9705
|
+
if (tool["status"] === "completed" && tool["error"] == null && !resultIsError(tool["result"])) {
|
|
9706
|
+
this.successfulSends += 1;
|
|
9707
|
+
} else {
|
|
9708
|
+
const status = typeof tool["status"] === "string" ? tool["status"] : "missing status";
|
|
9709
|
+
this.failure = `AgentChat send did not complete (${status})`;
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
outcome() {
|
|
9713
|
+
if (this.failure !== null) {
|
|
9714
|
+
return { ok: false, sent: this.successfulSends > 0, detail: this.failure };
|
|
9715
|
+
}
|
|
9716
|
+
const pending = this.pending.size + this.anonymousPending;
|
|
9717
|
+
if (pending > 0) {
|
|
9718
|
+
return {
|
|
9719
|
+
ok: false,
|
|
9720
|
+
sent: this.successfulSends > 0,
|
|
9721
|
+
detail: `${pending} AgentChat send tool call(s) never completed`
|
|
9722
|
+
};
|
|
9723
|
+
}
|
|
9724
|
+
return { ok: true, sent: this.successfulSends > 0 };
|
|
9725
|
+
}
|
|
9726
|
+
};
|
|
9092
9727
|
function missingCodexThread(detail) {
|
|
9093
9728
|
return /no (?:conversation|rollout|session|thread).*found/i.test(detail) || /(?:conversation|rollout|session|thread).*(?:not found|does not exist)/i.test(detail) || /unable to (?:find|resume).*(?:conversation|rollout|session|thread)/i.test(detail);
|
|
9094
9729
|
}
|
|
@@ -9129,9 +9764,9 @@ var CodexAdapter = class {
|
|
|
9129
9764
|
}
|
|
9130
9765
|
}
|
|
9131
9766
|
async preflight() {
|
|
9132
|
-
const
|
|
9133
|
-
if (
|
|
9134
|
-
const status =
|
|
9767
|
+
const runtime = inspectCodexRuntime();
|
|
9768
|
+
if (!runtime.ok) return { ok: false, detail: runtime.detail };
|
|
9769
|
+
const status = spawnCommandSync("codex", ["login", "status"], {
|
|
9135
9770
|
encoding: "utf-8",
|
|
9136
9771
|
env: { ...process.env, CODEX_HOME: this.codexHome }
|
|
9137
9772
|
});
|
|
@@ -9157,7 +9792,13 @@ var CodexAdapter = class {
|
|
|
9157
9792
|
return result;
|
|
9158
9793
|
}
|
|
9159
9794
|
spawnTurn(ctx, prior) {
|
|
9160
|
-
const args = buildCodexArgs(
|
|
9795
|
+
const args = buildCodexArgs(
|
|
9796
|
+
ctx,
|
|
9797
|
+
this.identityHome,
|
|
9798
|
+
this.workdir,
|
|
9799
|
+
prior,
|
|
9800
|
+
turnIdempotencyKey(ctx, this.identityNamespace)
|
|
9801
|
+
);
|
|
9161
9802
|
return new Promise((resolve5) => {
|
|
9162
9803
|
let settled = false;
|
|
9163
9804
|
const finish = (result) => {
|
|
@@ -9165,7 +9806,7 @@ var CodexAdapter = class {
|
|
|
9165
9806
|
settled = true;
|
|
9166
9807
|
resolve5(result);
|
|
9167
9808
|
};
|
|
9168
|
-
const child =
|
|
9809
|
+
const child = spawnCommand("codex", args, {
|
|
9169
9810
|
// stdin MUST be closed or codex exec hangs forever waiting on EOF.
|
|
9170
9811
|
stdio: ["ignore", "pipe", "pipe"],
|
|
9171
9812
|
env: {
|
|
@@ -9178,23 +9819,23 @@ var CodexAdapter = class {
|
|
|
9178
9819
|
},
|
|
9179
9820
|
detached: process.platform !== "win32"
|
|
9180
9821
|
});
|
|
9181
|
-
|
|
9182
|
-
let threadId;
|
|
9822
|
+
const events = new CodexTurnEvents();
|
|
9183
9823
|
let stdout = "";
|
|
9184
9824
|
let stderr = "";
|
|
9825
|
+
const consumeLine = (line) => {
|
|
9826
|
+
if (!line.trim()) return;
|
|
9827
|
+
try {
|
|
9828
|
+
events.consume(JSON.parse(line));
|
|
9829
|
+
} catch {
|
|
9830
|
+
}
|
|
9831
|
+
};
|
|
9185
9832
|
child.stdout.on("data", (d) => {
|
|
9186
9833
|
stdout += String(d);
|
|
9187
9834
|
let nl;
|
|
9188
9835
|
while ((nl = stdout.indexOf("\n")) >= 0) {
|
|
9189
9836
|
const line = stdout.slice(0, nl);
|
|
9190
9837
|
stdout = stdout.slice(nl + 1);
|
|
9191
|
-
|
|
9192
|
-
try {
|
|
9193
|
-
const e = JSON.parse(line);
|
|
9194
|
-
if (e.type === "thread.started" && typeof e.thread_id === "string") threadId = e.thread_id;
|
|
9195
|
-
if (e.item?.type === "mcp_tool_call" && e.item.tool === "agentchat_send_message") sawSend = true;
|
|
9196
|
-
} catch {
|
|
9197
|
-
}
|
|
9838
|
+
consumeLine(line);
|
|
9198
9839
|
}
|
|
9199
9840
|
if (stdout.length > MAX_EVENT_TAIL_CHARS) {
|
|
9200
9841
|
stdout = stdout.slice(-MAX_EVENT_TAIL_CHARS);
|
|
@@ -9213,13 +9854,22 @@ var CodexAdapter = class {
|
|
|
9213
9854
|
});
|
|
9214
9855
|
child.on("close", (code) => {
|
|
9215
9856
|
clearTimeout(killTimer);
|
|
9216
|
-
|
|
9217
|
-
|
|
9857
|
+
consumeLine(stdout);
|
|
9858
|
+
if (events.threadId && !prior) {
|
|
9859
|
+
this.threads.set(ctx.conversationId, events.threadId);
|
|
9218
9860
|
this.persistThreads();
|
|
9219
9861
|
}
|
|
9220
9862
|
if (code === 0) {
|
|
9221
|
-
|
|
9222
|
-
|
|
9863
|
+
const outcome = events.outcome();
|
|
9864
|
+
if (!outcome.ok) {
|
|
9865
|
+
finish({
|
|
9866
|
+
ok: false,
|
|
9867
|
+
detail: outcome.detail ?? "AgentChat send outcome was not successful"
|
|
9868
|
+
});
|
|
9869
|
+
return;
|
|
9870
|
+
}
|
|
9871
|
+
log.info(`codex turn done for ${ctx.conversationId} (sent=${outcome.sent})`);
|
|
9872
|
+
finish({ ok: true, detail: outcome.sent ? "replied" : "silent" });
|
|
9223
9873
|
} else {
|
|
9224
9874
|
const detail = `codex exited ${code}${stderr ? `: ${stderr.slice(0, 500)}` : ""}`;
|
|
9225
9875
|
finish({ ok: false, fatal: fatalRuntimeError(detail), detail });
|