@agentchatme/claude-code 0.0.139411411 → 0.0.13941141111

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.
@@ -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.13131/node_modules/@agentchatme/agent-core/dist/chunk-M2X5WY7Q.js
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.13131";
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.13131/node_modules/@agentchatme/agent-core/dist/daemon-entry.js
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
- const batch = candidates.slice(0, claimedCount);
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"
@@ -8988,20 +9527,21 @@ async function runDaemon(opts) {
8988
9527
  import * as fs5 from "fs";
8989
9528
  import * as path6 from "path";
8990
9529
  import * as crypto2 from "crypto";
8991
- import { spawn, spawnSync } from "child_process";
8992
9530
 
8993
- // node_modules/.pnpm/@agentchatme+agent-core@0.0.13131/node_modules/@agentchatme/agent-core/dist/index.js
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);
8994
9533
  var SESSION_TTL_MS = 48 * 60 * 60 * 1e3;
8995
9534
  var SessionStateSchema = external_exports.object({
8996
9535
  continuations: external_exports.number().int().min(0),
8997
9536
  updated_at: external_exports.string(),
8998
- // Ack cursor for the batch the session-start hook injected but has NOT
8999
- // yet committed. Committed by the user-prompt hook — proof the session
9000
- // actually ran a turn. A session that dies before its first prompt
9001
- // (arg-error invocations, crashed startups) leaves this uncommitted and
9002
- // the batch re-digests next session instead of being consumed by a
9003
- // ghost. Live-fire lesson, 2026-07-12.
9004
- pending_ack: external_exports.string().optional()
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()
9005
9545
  });
9006
9546
  var StateSchema = external_exports.object({
9007
9547
  sessions: external_exports.record(SessionStateSchema).default({}),
@@ -9016,16 +9556,34 @@ var StateSchema = external_exports.object({
9016
9556
  offer_declined_at: external_exports.string().optional()
9017
9557
  });
9018
9558
  var OFFER_COOLDOWN_MS = 24 * 60 * 60 * 1e3;
9559
+ var spawnCommand = import_cross_spawn.default;
9560
+ var spawnCommandSync = import_cross_spawn.default.sync;
9019
9561
 
9020
9562
  // src/version.ts
9021
- var VERSION2 = "0.0.139411411";
9563
+ var VERSION2 = "0.0.13941141111";
9564
+
9565
+ // src/runtime-version.ts
9566
+ var MIN_CLAUDE_CODE_VERSION = "2.1.219";
9567
+ function semverAtLeast(actual, minimum) {
9568
+ const parse = (value) => {
9569
+ const match = value.match(/(\d+)\.(\d+)\.(\d+)/);
9570
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
9571
+ };
9572
+ const a = parse(actual);
9573
+ const b = parse(minimum);
9574
+ if (a === null || b === null) return false;
9575
+ for (let index = 0; index < 3; index++) {
9576
+ if (a[index] !== b[index]) return (a[index] ?? 0) > (b[index] ?? 0);
9577
+ }
9578
+ return true;
9579
+ }
9022
9580
 
9023
9581
  // src/adapter.ts
9024
9582
  var TURN_TIMEOUT_MS = 24e4;
9025
9583
  var MAX_EVENT_TAIL_CHARS = 1024 * 1024;
9026
9584
  var MAX_STDERR_CHARS = 16384;
9027
- var AGENTCHAT_MCP_PACKAGE = "@agentchatme/mcp@0.1.11214";
9028
- var AGENTCHAT_TOOL_ALLOW = "mcp__agentchat";
9585
+ var AGENTCHAT_MCP_PACKAGE = "@agentchatme/mcp@0.1.1121411";
9586
+ var AGENTCHAT_TOOL_ALLOW = "mcp__agentchat__*";
9029
9587
  var PARENT_ENV_KEYS = [
9030
9588
  "CLAUDECODE",
9031
9589
  "CLAUDE_CODE_CHILD_SESSION",
@@ -9037,7 +9595,7 @@ var PARENT_ENV_KEYS = [
9037
9595
  "AI_AGENT"
9038
9596
  ];
9039
9597
  function claudeIsLoggedIn(configDir) {
9040
- const status = spawnSync("claude", ["auth", "status"], {
9598
+ const status = spawnCommandSync("claude", ["auth", "status"], {
9041
9599
  encoding: "utf-8",
9042
9600
  timeout: 1e4,
9043
9601
  env: { ...process.env, CLAUDE_CONFIG_DIR: configDir }
@@ -9045,7 +9603,7 @@ function claudeIsLoggedIn(configDir) {
9045
9603
  if (!status.error && status.status === 0) return true;
9046
9604
  if (fs5.existsSync(path6.join(configDir, ".credentials.json"))) return true;
9047
9605
  if (process.platform !== "darwin") return false;
9048
- const keychain = spawnSync(
9606
+ const keychain = spawnCommandSync(
9049
9607
  "security",
9050
9608
  ["find-generic-password", "-s", "Claude Code-credentials"],
9051
9609
  { encoding: "utf-8", timeout: 5e3 }
@@ -9057,6 +9615,10 @@ function buildClaudeEnv(configDir, source = process.env) {
9057
9615
  for (const key of PARENT_ENV_KEYS) delete env[key];
9058
9616
  env["CLAUDE_CONFIG_DIR"] = configDir;
9059
9617
  env["DISABLE_AUTOUPDATER"] = "1";
9618
+ const configuredConnectTimeout = Number(env["MCP_CONNECT_TIMEOUT_MS"]);
9619
+ if (!Number.isFinite(configuredConnectTimeout) || configuredConnectTimeout < 3e4) {
9620
+ env["MCP_CONNECT_TIMEOUT_MS"] = "30000";
9621
+ }
9060
9622
  env["AGENTCHAT_HOOKS_ENABLED"] = "0";
9061
9623
  return env;
9062
9624
  }
@@ -9074,26 +9636,137 @@ function buildClaudeArgs(ctx, mcpConfigPath, uuid, resume) {
9074
9636
  "--verbose"
9075
9637
  ];
9076
9638
  }
9077
- function buildTurnMcpConfig(identityHome2) {
9639
+ function buildTurnMcpConfig(identityHome2, idempotencyKey) {
9078
9640
  return {
9079
9641
  mcpServers: {
9080
9642
  agentchat: {
9081
9643
  command: "npx",
9082
9644
  args: ["-y", AGENTCHAT_MCP_PACKAGE],
9645
+ // Without this, Claude can emit system/init while the server is still
9646
+ // pending and begin a turn that has no AgentChat send tool.
9647
+ alwaysLoad: true,
9083
9648
  env: {
9084
9649
  AGENTCHAT_HOME: identityHome2,
9085
9650
  AGENTCHAT_CLIENT_NAME: "claude-code",
9086
- AGENTCHAT_CLIENT_VERSION: VERSION2
9651
+ AGENTCHAT_CLIENT_VERSION: VERSION2,
9652
+ AGENTCHAT_TURN_IDEMPOTENCY_KEY: idempotencyKey
9087
9653
  }
9088
9654
  }
9089
9655
  }
9090
9656
  };
9091
9657
  }
9658
+ function turnIdempotencyKey(ctx, identityNamespace) {
9659
+ const messageIds = ctx.pendingBatch?.messageIds ?? [ctx.messageId];
9660
+ 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");
9661
+ return `ac_turn_${digest}`;
9662
+ }
9663
+ var SEND_TOOL = "mcp__agentchat__agentchat_send_message";
9664
+ var ClaudeTurnEvents = class {
9665
+ initSeen = false;
9666
+ mcpConnected = false;
9667
+ initFailure = null;
9668
+ terminalSeen = false;
9669
+ terminalFailure = false;
9670
+ pending = /* @__PURE__ */ new Set();
9671
+ successfulSends = 0;
9672
+ sendFailure = null;
9673
+ consume(event) {
9674
+ if (typeof event !== "object" || event === null) return;
9675
+ const record = event;
9676
+ if (record["type"] === "system" && record["subtype"] === "init") {
9677
+ this.initSeen = true;
9678
+ const servers = Array.isArray(record["mcp_servers"]) ? record["mcp_servers"] : [];
9679
+ const agentchat = servers.find(
9680
+ (candidate) => typeof candidate === "object" && candidate !== null && candidate["name"] === "agentchat"
9681
+ );
9682
+ this.mcpConnected = agentchat?.["status"] === "connected";
9683
+ if (!this.mcpConnected) {
9684
+ const status = typeof agentchat?.["status"] === "string" ? agentchat["status"] : "missing";
9685
+ this.initFailure = `AgentChat MCP status is ${status}`;
9686
+ }
9687
+ const skipped = Array.isArray(record["mcp_server_errors"]) ? record["mcp_server_errors"] : [];
9688
+ const error = skipped.find(
9689
+ (candidate) => typeof candidate === "object" && candidate !== null && candidate["name"] === "agentchat"
9690
+ );
9691
+ if (error !== void 0) {
9692
+ const message = typeof error["message"] === "string" ? `: ${error["message"]}` : "";
9693
+ this.initFailure = `AgentChat MCP configuration was skipped${message}`;
9694
+ }
9695
+ }
9696
+ if (record["type"] === "assistant") {
9697
+ const message = record["message"];
9698
+ const content = Array.isArray(message?.["content"]) ? message["content"] : [];
9699
+ for (const block of content) {
9700
+ if (typeof block !== "object" || block === null) continue;
9701
+ const tool = block;
9702
+ if (tool["type"] === "tool_use" && tool["name"] === SEND_TOOL && typeof tool["id"] === "string") {
9703
+ this.pending.add(tool["id"]);
9704
+ }
9705
+ }
9706
+ }
9707
+ if (record["type"] === "user") {
9708
+ const message = record["message"];
9709
+ const content = Array.isArray(message?.["content"]) ? message["content"] : [];
9710
+ for (const block of content) {
9711
+ if (typeof block !== "object" || block === null) continue;
9712
+ const result = block;
9713
+ const id = typeof result["tool_use_id"] === "string" ? result["tool_use_id"] : null;
9714
+ if (result["type"] !== "tool_result" || id === null || !this.pending.has(id)) {
9715
+ continue;
9716
+ }
9717
+ this.pending.delete(id);
9718
+ if (result["is_error"] === true) {
9719
+ this.sendFailure = "AgentChat send tool returned an error";
9720
+ } else {
9721
+ this.successfulSends += 1;
9722
+ }
9723
+ }
9724
+ }
9725
+ if (record["type"] === "result") {
9726
+ this.terminalSeen = true;
9727
+ this.terminalFailure = record["is_error"] === true || typeof record["subtype"] === "string" && record["subtype"] !== "success";
9728
+ }
9729
+ }
9730
+ outcome() {
9731
+ if (!this.initSeen) {
9732
+ return { ok: false, sent: false, detail: "Claude emitted no system/init event" };
9733
+ }
9734
+ if (!this.mcpConnected || this.initFailure !== null) {
9735
+ return {
9736
+ ok: false,
9737
+ sent: this.successfulSends > 0,
9738
+ detail: this.initFailure ?? "AgentChat MCP did not connect"
9739
+ };
9740
+ }
9741
+ if (!this.terminalSeen || this.terminalFailure) {
9742
+ return {
9743
+ ok: false,
9744
+ sent: this.successfulSends > 0,
9745
+ detail: this.terminalSeen ? "Claude reported a failed terminal result" : "Claude emitted no terminal result event"
9746
+ };
9747
+ }
9748
+ if (this.sendFailure !== null) {
9749
+ return {
9750
+ ok: false,
9751
+ sent: this.successfulSends > 0,
9752
+ detail: this.sendFailure
9753
+ };
9754
+ }
9755
+ if (this.pending.size > 0) {
9756
+ return {
9757
+ ok: false,
9758
+ sent: this.successfulSends > 0,
9759
+ detail: `${this.pending.size} AgentChat send tool call(s) never completed`
9760
+ };
9761
+ }
9762
+ return { ok: true, sent: this.successfulSends > 0 };
9763
+ }
9764
+ };
9092
9765
  function killProcessTree(child) {
9093
9766
  if (child.pid === void 0) return;
9094
9767
  try {
9095
9768
  if (process.platform === "win32") {
9096
- spawnSync("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
9769
+ spawnCommandSync("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
9097
9770
  windowsHide: true,
9098
9771
  stdio: "ignore"
9099
9772
  });
@@ -9128,8 +9801,15 @@ var ClaudeAdapter = class {
9128
9801
  this.sessionNamespace = identityNamespace;
9129
9802
  }
9130
9803
  async preflight() {
9131
- const which = spawnSync("claude", ["--version"], { encoding: "utf-8" });
9804
+ const which = spawnCommandSync("claude", ["--version"], { encoding: "utf-8" });
9132
9805
  if (which.error) return { ok: false, detail: "claude CLI not found on PATH" };
9806
+ const rendered = String(which.stdout || which.stderr).trim();
9807
+ if (which.status !== 0 || !semverAtLeast(rendered, MIN_CLAUDE_CODE_VERSION)) {
9808
+ return {
9809
+ ok: false,
9810
+ detail: `${rendered || `claude exited ${which.status}`}; AgentChat requires Claude Code >= ${MIN_CLAUDE_CODE_VERSION}`
9811
+ };
9812
+ }
9133
9813
  if (!claudeIsLoggedIn(this.claudeConfigDir)) {
9134
9814
  return { ok: false, detail: "claude is not logged in (run `claude` once and sign in)" };
9135
9815
  }
@@ -9157,7 +9837,12 @@ var ClaudeAdapter = class {
9157
9837
  try {
9158
9838
  atomicWriteFile(
9159
9839
  mcpConfigPath,
9160
- JSON.stringify(buildTurnMcpConfig(this.identityHome)),
9840
+ JSON.stringify(
9841
+ buildTurnMcpConfig(
9842
+ this.identityHome,
9843
+ turnIdempotencyKey(ctx, this.sessionNamespace)
9844
+ )
9845
+ ),
9161
9846
  384
9162
9847
  );
9163
9848
  } catch (err) {
@@ -9172,35 +9857,29 @@ var ClaudeAdapter = class {
9172
9857
  settled = true;
9173
9858
  resolve5(result);
9174
9859
  };
9175
- const child = spawn("claude", args, {
9860
+ const child = spawnCommand("claude", args, {
9176
9861
  cwd: this.workdir,
9177
9862
  stdio: ["pipe", "pipe", "pipe"],
9178
9863
  env,
9179
9864
  detached: process.platform !== "win32"
9180
9865
  });
9181
- let sawSend = false;
9182
- let isError;
9866
+ const events = new ClaudeTurnEvents();
9183
9867
  let buf = "";
9184
9868
  let stderr = "";
9869
+ const consumeLine = (line) => {
9870
+ if (!line.trim()) return;
9871
+ try {
9872
+ events.consume(JSON.parse(line));
9873
+ } catch {
9874
+ }
9875
+ };
9185
9876
  child.stdout.on("data", (d) => {
9186
- buf += d;
9877
+ buf += String(d);
9187
9878
  let nl;
9188
9879
  while ((nl = buf.indexOf("\n")) >= 0) {
9189
9880
  const line = buf.slice(0, nl);
9190
9881
  buf = buf.slice(nl + 1);
9191
- if (!line.trim()) continue;
9192
- try {
9193
- const e = JSON.parse(line);
9194
- if (e.type === "assistant" && Array.isArray(e.message?.content)) {
9195
- for (const c of e.message.content) {
9196
- if (c?.type === "tool_use" && typeof c.name === "string" && c.name.includes("agentchat_send_message")) {
9197
- sawSend = true;
9198
- }
9199
- }
9200
- }
9201
- if (e.type === "result") isError = e.is_error === true;
9202
- } catch {
9203
- }
9882
+ consumeLine(line);
9204
9883
  }
9205
9884
  if (buf.length > MAX_EVENT_TAIL_CHARS) buf = buf.slice(-MAX_EVENT_TAIL_CHARS);
9206
9885
  });
@@ -9224,9 +9903,18 @@ var ClaudeAdapter = class {
9224
9903
  });
9225
9904
  child.on("close", (code) => {
9226
9905
  clearTimeout(killTimer);
9227
- if (code === 0 && isError !== true) {
9228
- log.info(`claude turn done for ${ctx.conversationId} (sent=${sawSend})`);
9229
- finish({ ok: true, detail: sawSend ? "replied" : "silent" });
9906
+ consumeLine(buf);
9907
+ if (code === 0) {
9908
+ const outcome = events.outcome();
9909
+ if (!outcome.ok) {
9910
+ finish({
9911
+ ok: false,
9912
+ detail: outcome.detail ?? "AgentChat send outcome was not successful"
9913
+ });
9914
+ return;
9915
+ }
9916
+ log.info(`claude turn done for ${ctx.conversationId} (sent=${outcome.sent})`);
9917
+ finish({ ok: true, detail: outcome.sent ? "replied" : "silent" });
9230
9918
  } else {
9231
9919
  const detail = `claude exited ${code}${stderr ? `: ${stderr.slice(0, 500)}` : ""}`;
9232
9920
  finish({ ok: false, fatal: fatalRuntimeError(detail), detail });