@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/index.js
CHANGED
|
@@ -1,21 +1,553 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire as __acCreateRequire}from"node:module";
|
|
3
3
|
const require=__acCreateRequire(import.meta.url);
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
}) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
+
});
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
28
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
33
|
+
mod
|
|
34
|
+
));
|
|
35
|
+
|
|
36
|
+
// node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
37
|
+
var require_windows = __commonJS({
|
|
38
|
+
"node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
|
|
39
|
+
"use strict";
|
|
40
|
+
module.exports = isexe;
|
|
41
|
+
isexe.sync = sync;
|
|
42
|
+
var fs9 = __require("fs");
|
|
43
|
+
function checkPathExt(path9, options) {
|
|
44
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
45
|
+
if (!pathext) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
pathext = pathext.split(";");
|
|
49
|
+
if (pathext.indexOf("") !== -1) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
53
|
+
var p = pathext[i].toLowerCase();
|
|
54
|
+
if (p && path9.substr(-p.length).toLowerCase() === p) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
function checkStat(stat, path9, options) {
|
|
61
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return checkPathExt(path9, options);
|
|
65
|
+
}
|
|
66
|
+
function isexe(path9, options, cb) {
|
|
67
|
+
fs9.stat(path9, function(er, stat) {
|
|
68
|
+
cb(er, er ? false : checkStat(stat, path9, options));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function sync(path9, options) {
|
|
72
|
+
return checkStat(fs9.statSync(path9), path9, options);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
|
|
78
|
+
var require_mode = __commonJS({
|
|
79
|
+
"node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
|
|
80
|
+
"use strict";
|
|
81
|
+
module.exports = isexe;
|
|
82
|
+
isexe.sync = sync;
|
|
83
|
+
var fs9 = __require("fs");
|
|
84
|
+
function isexe(path9, options, cb) {
|
|
85
|
+
fs9.stat(path9, function(er, stat) {
|
|
86
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function sync(path9, options) {
|
|
90
|
+
return checkStat(fs9.statSync(path9), options);
|
|
91
|
+
}
|
|
92
|
+
function checkStat(stat, options) {
|
|
93
|
+
return stat.isFile() && checkMode(stat, options);
|
|
94
|
+
}
|
|
95
|
+
function checkMode(stat, options) {
|
|
96
|
+
var mod = stat.mode;
|
|
97
|
+
var uid = stat.uid;
|
|
98
|
+
var gid = stat.gid;
|
|
99
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
100
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
101
|
+
var u = parseInt("100", 8);
|
|
102
|
+
var g = parseInt("010", 8);
|
|
103
|
+
var o = parseInt("001", 8);
|
|
104
|
+
var ug = u | g;
|
|
105
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
106
|
+
return ret;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
112
|
+
var require_isexe = __commonJS({
|
|
113
|
+
"node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
114
|
+
"use strict";
|
|
115
|
+
var fs9 = __require("fs");
|
|
116
|
+
var core;
|
|
117
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
118
|
+
core = require_windows();
|
|
119
|
+
} else {
|
|
120
|
+
core = require_mode();
|
|
121
|
+
}
|
|
122
|
+
module.exports = isexe;
|
|
123
|
+
isexe.sync = sync;
|
|
124
|
+
function isexe(path9, options, cb) {
|
|
125
|
+
if (typeof options === "function") {
|
|
126
|
+
cb = options;
|
|
127
|
+
options = {};
|
|
128
|
+
}
|
|
129
|
+
if (!cb) {
|
|
130
|
+
if (typeof Promise !== "function") {
|
|
131
|
+
throw new TypeError("callback not provided");
|
|
132
|
+
}
|
|
133
|
+
return new Promise(function(resolve5, reject) {
|
|
134
|
+
isexe(path9, options || {}, function(er, is) {
|
|
135
|
+
if (er) {
|
|
136
|
+
reject(er);
|
|
137
|
+
} else {
|
|
138
|
+
resolve5(is);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
core(path9, options || {}, function(er, is) {
|
|
144
|
+
if (er) {
|
|
145
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
146
|
+
er = null;
|
|
147
|
+
is = false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
cb(er, is);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function sync(path9, options) {
|
|
154
|
+
try {
|
|
155
|
+
return core.sync(path9, options || {});
|
|
156
|
+
} catch (er) {
|
|
157
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
158
|
+
return false;
|
|
159
|
+
} else {
|
|
160
|
+
throw er;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
|
|
168
|
+
var require_which = __commonJS({
|
|
169
|
+
"node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
170
|
+
"use strict";
|
|
171
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
172
|
+
var path9 = __require("path");
|
|
173
|
+
var COLON = isWindows ? ";" : ":";
|
|
174
|
+
var isexe = require_isexe();
|
|
175
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
176
|
+
var getPathInfo = (cmd, opt) => {
|
|
177
|
+
const colon = opt.colon || COLON;
|
|
178
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
179
|
+
// windows always checks the cwd first
|
|
180
|
+
...isWindows ? [process.cwd()] : [],
|
|
181
|
+
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
182
|
+
"").split(colon)
|
|
183
|
+
];
|
|
184
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
185
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
186
|
+
if (isWindows) {
|
|
187
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
188
|
+
pathExt.unshift("");
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
pathEnv,
|
|
192
|
+
pathExt,
|
|
193
|
+
pathExtExe
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
var which = (cmd, opt, cb) => {
|
|
197
|
+
if (typeof opt === "function") {
|
|
198
|
+
cb = opt;
|
|
199
|
+
opt = {};
|
|
200
|
+
}
|
|
201
|
+
if (!opt)
|
|
202
|
+
opt = {};
|
|
203
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
204
|
+
const found = [];
|
|
205
|
+
const step = (i) => new Promise((resolve5, reject) => {
|
|
206
|
+
if (i === pathEnv.length)
|
|
207
|
+
return opt.all && found.length ? resolve5(found) : reject(getNotFoundError(cmd));
|
|
208
|
+
const ppRaw = pathEnv[i];
|
|
209
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
210
|
+
const pCmd = path9.join(pathPart, cmd);
|
|
211
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
212
|
+
resolve5(subStep(p, i, 0));
|
|
213
|
+
});
|
|
214
|
+
const subStep = (p, i, ii) => new Promise((resolve5, reject) => {
|
|
215
|
+
if (ii === pathExt.length)
|
|
216
|
+
return resolve5(step(i + 1));
|
|
217
|
+
const ext = pathExt[ii];
|
|
218
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
219
|
+
if (!er && is) {
|
|
220
|
+
if (opt.all)
|
|
221
|
+
found.push(p + ext);
|
|
222
|
+
else
|
|
223
|
+
return resolve5(p + ext);
|
|
224
|
+
}
|
|
225
|
+
return resolve5(subStep(p, i, ii + 1));
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
229
|
+
};
|
|
230
|
+
var whichSync = (cmd, opt) => {
|
|
231
|
+
opt = opt || {};
|
|
232
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
233
|
+
const found = [];
|
|
234
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
235
|
+
const ppRaw = pathEnv[i];
|
|
236
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
237
|
+
const pCmd = path9.join(pathPart, cmd);
|
|
238
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
239
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
240
|
+
const cur = p + pathExt[j];
|
|
241
|
+
try {
|
|
242
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
243
|
+
if (is) {
|
|
244
|
+
if (opt.all)
|
|
245
|
+
found.push(cur);
|
|
246
|
+
else
|
|
247
|
+
return cur;
|
|
248
|
+
}
|
|
249
|
+
} catch (ex) {
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (opt.all && found.length)
|
|
254
|
+
return found;
|
|
255
|
+
if (opt.nothrow)
|
|
256
|
+
return null;
|
|
257
|
+
throw getNotFoundError(cmd);
|
|
258
|
+
};
|
|
259
|
+
module.exports = which;
|
|
260
|
+
which.sync = whichSync;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
|
|
265
|
+
var require_path_key = __commonJS({
|
|
266
|
+
"node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
|
|
267
|
+
"use strict";
|
|
268
|
+
var pathKey = (options = {}) => {
|
|
269
|
+
const environment = options.env || process.env;
|
|
270
|
+
const platform = options.platform || process.platform;
|
|
271
|
+
if (platform !== "win32") {
|
|
272
|
+
return "PATH";
|
|
273
|
+
}
|
|
274
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
275
|
+
};
|
|
276
|
+
module.exports = pathKey;
|
|
277
|
+
module.exports.default = pathKey;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
282
|
+
var require_resolveCommand = __commonJS({
|
|
283
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
284
|
+
"use strict";
|
|
285
|
+
var path9 = __require("path");
|
|
286
|
+
var which = require_which();
|
|
287
|
+
var getPathKey = require_path_key();
|
|
288
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
289
|
+
const env = parsed.options.env || process.env;
|
|
290
|
+
const cwd = process.cwd();
|
|
291
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
292
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
293
|
+
if (shouldSwitchCwd) {
|
|
294
|
+
try {
|
|
295
|
+
process.chdir(parsed.options.cwd);
|
|
296
|
+
} catch (err) {
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
let resolved;
|
|
300
|
+
try {
|
|
301
|
+
resolved = which.sync(parsed.command, {
|
|
302
|
+
path: env[getPathKey({ env })],
|
|
303
|
+
pathExt: withoutPathExt ? path9.delimiter : void 0
|
|
304
|
+
});
|
|
305
|
+
} catch (e) {
|
|
306
|
+
} finally {
|
|
307
|
+
if (shouldSwitchCwd) {
|
|
308
|
+
process.chdir(cwd);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (resolved) {
|
|
312
|
+
resolved = path9.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
313
|
+
}
|
|
314
|
+
return resolved;
|
|
315
|
+
}
|
|
316
|
+
function resolveCommand(parsed) {
|
|
317
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
318
|
+
}
|
|
319
|
+
module.exports = resolveCommand;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
324
|
+
var require_escape = __commonJS({
|
|
325
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
|
|
326
|
+
"use strict";
|
|
327
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
328
|
+
function escapeCommand(arg) {
|
|
329
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
330
|
+
return arg;
|
|
331
|
+
}
|
|
332
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
333
|
+
arg = `${arg}`;
|
|
334
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
335
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
336
|
+
arg = `"${arg}"`;
|
|
337
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
338
|
+
if (doubleEscapeMetaChars) {
|
|
339
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
340
|
+
}
|
|
341
|
+
return arg;
|
|
342
|
+
}
|
|
343
|
+
module.exports.command = escapeCommand;
|
|
344
|
+
module.exports.argument = escapeArgument;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
|
|
349
|
+
var require_shebang_regex = __commonJS({
|
|
350
|
+
"node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
|
|
351
|
+
"use strict";
|
|
352
|
+
module.exports = /^#!(.*)/;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
|
|
357
|
+
var require_shebang_command = __commonJS({
|
|
358
|
+
"node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
|
|
359
|
+
"use strict";
|
|
360
|
+
var shebangRegex = require_shebang_regex();
|
|
361
|
+
module.exports = (string = "") => {
|
|
362
|
+
const match = string.match(shebangRegex);
|
|
363
|
+
if (!match) {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
const [path9, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
367
|
+
const binary = path9.split("/").pop();
|
|
368
|
+
if (binary === "env") {
|
|
369
|
+
return argument;
|
|
370
|
+
}
|
|
371
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
377
|
+
var require_readShebang = __commonJS({
|
|
378
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
379
|
+
"use strict";
|
|
380
|
+
var fs9 = __require("fs");
|
|
381
|
+
var shebangCommand = require_shebang_command();
|
|
382
|
+
function readShebang(command) {
|
|
383
|
+
const size = 150;
|
|
384
|
+
const buffer = Buffer.alloc(size);
|
|
385
|
+
let fd;
|
|
386
|
+
try {
|
|
387
|
+
fd = fs9.openSync(command, "r");
|
|
388
|
+
fs9.readSync(fd, buffer, 0, size, 0);
|
|
389
|
+
fs9.closeSync(fd);
|
|
390
|
+
} catch (e) {
|
|
391
|
+
}
|
|
392
|
+
return shebangCommand(buffer.toString());
|
|
393
|
+
}
|
|
394
|
+
module.exports = readShebang;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
399
|
+
var require_parse = __commonJS({
|
|
400
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
401
|
+
"use strict";
|
|
402
|
+
var path9 = __require("path");
|
|
403
|
+
var resolveCommand = require_resolveCommand();
|
|
404
|
+
var escape = require_escape();
|
|
405
|
+
var readShebang = require_readShebang();
|
|
406
|
+
var isWin = process.platform === "win32";
|
|
407
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
408
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
409
|
+
function detectShebang(parsed) {
|
|
410
|
+
parsed.file = resolveCommand(parsed);
|
|
411
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
412
|
+
if (shebang) {
|
|
413
|
+
parsed.args.unshift(parsed.file);
|
|
414
|
+
parsed.command = shebang;
|
|
415
|
+
return resolveCommand(parsed);
|
|
416
|
+
}
|
|
417
|
+
return parsed.file;
|
|
418
|
+
}
|
|
419
|
+
function parseNonShell(parsed) {
|
|
420
|
+
if (!isWin) {
|
|
421
|
+
return parsed;
|
|
422
|
+
}
|
|
423
|
+
const commandFile = detectShebang(parsed);
|
|
424
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
425
|
+
if (parsed.options.forceShell || needsShell) {
|
|
426
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
427
|
+
parsed.command = path9.normalize(parsed.command);
|
|
428
|
+
parsed.command = escape.command(parsed.command);
|
|
429
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
430
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
431
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
432
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
433
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
434
|
+
}
|
|
435
|
+
return parsed;
|
|
436
|
+
}
|
|
437
|
+
function parse(command, args, options) {
|
|
438
|
+
if (args && !Array.isArray(args)) {
|
|
439
|
+
options = args;
|
|
440
|
+
args = null;
|
|
441
|
+
}
|
|
442
|
+
args = args ? args.slice(0) : [];
|
|
443
|
+
options = Object.assign({}, options);
|
|
444
|
+
const parsed = {
|
|
445
|
+
command,
|
|
446
|
+
args,
|
|
447
|
+
options,
|
|
448
|
+
file: void 0,
|
|
449
|
+
original: {
|
|
450
|
+
command,
|
|
451
|
+
args
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
455
|
+
}
|
|
456
|
+
module.exports = parse;
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
461
|
+
var require_enoent = __commonJS({
|
|
462
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
|
|
463
|
+
"use strict";
|
|
464
|
+
var isWin = process.platform === "win32";
|
|
465
|
+
function notFoundError(original, syscall) {
|
|
466
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
467
|
+
code: "ENOENT",
|
|
468
|
+
errno: "ENOENT",
|
|
469
|
+
syscall: `${syscall} ${original.command}`,
|
|
470
|
+
path: original.command,
|
|
471
|
+
spawnargs: original.args
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
function hookChildProcess(cp, parsed) {
|
|
475
|
+
if (!isWin) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const originalEmit = cp.emit;
|
|
479
|
+
cp.emit = function(name, arg1) {
|
|
480
|
+
if (name === "exit") {
|
|
481
|
+
const err = verifyENOENT(arg1, parsed);
|
|
482
|
+
if (err) {
|
|
483
|
+
return originalEmit.call(cp, "error", err);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return originalEmit.apply(cp, arguments);
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
function verifyENOENT(status, parsed) {
|
|
490
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
491
|
+
return notFoundError(parsed.original, "spawn");
|
|
492
|
+
}
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
function verifyENOENTSync(status, parsed) {
|
|
496
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
497
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
498
|
+
}
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
module.exports = {
|
|
502
|
+
hookChildProcess,
|
|
503
|
+
verifyENOENT,
|
|
504
|
+
verifyENOENTSync,
|
|
505
|
+
notFoundError
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
// node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
|
|
511
|
+
var require_cross_spawn = __commonJS({
|
|
512
|
+
"node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
|
|
513
|
+
"use strict";
|
|
514
|
+
var cp = __require("child_process");
|
|
515
|
+
var parse = require_parse();
|
|
516
|
+
var enoent = require_enoent();
|
|
517
|
+
function spawn(command, args, options) {
|
|
518
|
+
const parsed = parse(command, args, options);
|
|
519
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
520
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
521
|
+
return spawned;
|
|
522
|
+
}
|
|
523
|
+
function spawnSync(command, args, options) {
|
|
524
|
+
const parsed = parse(command, args, options);
|
|
525
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
526
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
529
|
+
module.exports = spawn;
|
|
530
|
+
module.exports.spawn = spawn;
|
|
531
|
+
module.exports.sync = spawnSync;
|
|
532
|
+
module.exports._parse = parse;
|
|
533
|
+
module.exports._enoent = enoent;
|
|
534
|
+
}
|
|
535
|
+
});
|
|
4
536
|
|
|
5
537
|
// src/index.ts
|
|
6
538
|
import { parseArgs } from "util";
|
|
7
539
|
|
|
8
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
540
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.13131111/node_modules/@agentchatme/agent-core/dist/chunk-Y4REWBSV.js
|
|
9
541
|
import * as fs2 from "fs";
|
|
10
542
|
import * as path2 from "path";
|
|
11
543
|
import * as fs3 from "fs";
|
|
12
544
|
import * as path3 from "path";
|
|
13
545
|
import * as fs4 from "fs";
|
|
14
546
|
import * as path4 from "path";
|
|
15
|
-
var
|
|
547
|
+
var __defProp2 = Object.defineProperty;
|
|
16
548
|
var __export = (target, all) => {
|
|
17
549
|
for (var name in all)
|
|
18
|
-
|
|
550
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
19
551
|
};
|
|
20
552
|
var LEVELS = ["silent", "error", "warn", "info", "debug"];
|
|
21
553
|
function activeLevel() {
|
|
@@ -35,7 +567,7 @@ var log = {
|
|
|
35
567
|
info: (msg) => emit("info", msg),
|
|
36
568
|
debug: (msg) => emit("debug", msg)
|
|
37
569
|
};
|
|
38
|
-
var VERSION = "0.0.
|
|
570
|
+
var VERSION = "0.0.13131111";
|
|
39
571
|
var CODING_AGENTS_CLIENT_IDENTITY = {
|
|
40
572
|
name: "coding_agents",
|
|
41
573
|
version: VERSION
|
|
@@ -4443,7 +4975,7 @@ function alwaysOnHealth(home) {
|
|
|
4443
4975
|
return { wanted: state !== "off", healthy: state !== "down" };
|
|
4444
4976
|
}
|
|
4445
4977
|
|
|
4446
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
4978
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.13131111/node_modules/@agentchatme/agent-core/dist/index.js
|
|
4447
4979
|
import * as fs from "fs";
|
|
4448
4980
|
import * as path from "path";
|
|
4449
4981
|
import * as readline from "readline";
|
|
@@ -4942,10 +5474,10 @@ function statusToCode(status) {
|
|
|
4942
5474
|
}
|
|
4943
5475
|
async function sleep(ms, signal) {
|
|
4944
5476
|
if (ms <= 0) return;
|
|
4945
|
-
await new Promise((
|
|
5477
|
+
await new Promise((resolve5, reject) => {
|
|
4946
5478
|
const timer = setTimeout(() => {
|
|
4947
5479
|
if (signal) signal.removeEventListener("abort", onAbort);
|
|
4948
|
-
|
|
5480
|
+
resolve5();
|
|
4949
5481
|
}, ms);
|
|
4950
5482
|
const onAbort = () => {
|
|
4951
5483
|
clearTimeout(timer);
|
|
@@ -5784,22 +6316,23 @@ var HOUR2 = 60 * MIN2;
|
|
|
5784
6316
|
var DAY2 = 24 * HOUR2;
|
|
5785
6317
|
var MAX_ATTACHMENT_SIZE = 25 * 1024 * 1024;
|
|
5786
6318
|
|
|
5787
|
-
// node_modules/.pnpm/@agentchatme+agent-core@0.0.
|
|
6319
|
+
// node_modules/.pnpm/@agentchatme+agent-core@0.0.13131111/node_modules/@agentchatme/agent-core/dist/index.js
|
|
6320
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
5788
6321
|
import * as fs22 from "fs";
|
|
5789
6322
|
import * as os from "os";
|
|
5790
6323
|
import * as path22 from "path";
|
|
5791
|
-
import { spawnSync, spawn } from "child_process";
|
|
5792
6324
|
var SESSION_TTL_MS = 48 * 60 * 60 * 1e3;
|
|
5793
6325
|
var SessionStateSchema = external_exports.object({
|
|
5794
6326
|
continuations: external_exports.number().int().min(0),
|
|
5795
6327
|
updated_at: external_exports.string(),
|
|
5796
|
-
// Ack cursor for
|
|
5797
|
-
//
|
|
5798
|
-
//
|
|
5799
|
-
//
|
|
5800
|
-
|
|
5801
|
-
//
|
|
5802
|
-
|
|
6328
|
+
// Ack cursor for hook context already handed to the host but not yet proven
|
|
6329
|
+
// through a completed model boundary. UserPromptSubmit and Stop stage it;
|
|
6330
|
+
// the following Stop commits it. A session that dies in between leaves the
|
|
6331
|
+
// server delivery unacked, preferring a later duplicate over silent loss.
|
|
6332
|
+
pending_ack: external_exports.string().optional(),
|
|
6333
|
+
// Stop context needs the specific host-created continuation, not merely an
|
|
6334
|
+
// unrelated later turn that happens to reach Stop.
|
|
6335
|
+
pending_ack_requires_continuation: external_exports.boolean().optional()
|
|
5803
6336
|
});
|
|
5804
6337
|
var StateSchema = external_exports.object({
|
|
5805
6338
|
sessions: external_exports.record(SessionStateSchema).default({}),
|
|
@@ -5839,9 +6372,15 @@ function getContinuations(home, sessionKey) {
|
|
|
5839
6372
|
function recordContinuation(home, sessionKey, now2 = /* @__PURE__ */ new Date()) {
|
|
5840
6373
|
const state = readState(home);
|
|
5841
6374
|
prune(state, now2);
|
|
5842
|
-
const
|
|
6375
|
+
const existing = state.sessions[sessionKey];
|
|
6376
|
+
const current = existing?.continuations ?? 0;
|
|
5843
6377
|
const next = current + 1;
|
|
5844
|
-
state.sessions[sessionKey] = {
|
|
6378
|
+
state.sessions[sessionKey] = {
|
|
6379
|
+
continuations: next,
|
|
6380
|
+
updated_at: now2.toISOString(),
|
|
6381
|
+
...existing?.pending_ack !== void 0 ? { pending_ack: existing.pending_ack } : {},
|
|
6382
|
+
...existing?.pending_ack_requires_continuation === true ? { pending_ack_requires_continuation: true } : {}
|
|
6383
|
+
};
|
|
5845
6384
|
writeState(home, state);
|
|
5846
6385
|
return next;
|
|
5847
6386
|
}
|
|
@@ -5851,23 +6390,31 @@ function resetSession(home, sessionKey) {
|
|
|
5851
6390
|
delete state.sessions[sessionKey];
|
|
5852
6391
|
writeState(home, state);
|
|
5853
6392
|
}
|
|
5854
|
-
function setPendingAck(home, sessionKey, cursor, now2 = /* @__PURE__ */ new Date()) {
|
|
6393
|
+
function setPendingAck(home, sessionKey, cursor, now2 = /* @__PURE__ */ new Date(), requiresContinuation = false) {
|
|
5855
6394
|
const state = readState(home);
|
|
5856
6395
|
prune(state, now2);
|
|
5857
6396
|
const existing = state.sessions[sessionKey];
|
|
5858
6397
|
state.sessions[sessionKey] = {
|
|
5859
6398
|
continuations: existing?.continuations ?? 0,
|
|
5860
6399
|
updated_at: now2.toISOString(),
|
|
5861
|
-
pending_ack: cursor
|
|
6400
|
+
pending_ack: cursor,
|
|
6401
|
+
...requiresContinuation ? { pending_ack_requires_continuation: true } : {}
|
|
5862
6402
|
};
|
|
5863
6403
|
writeState(home, state);
|
|
5864
6404
|
}
|
|
6405
|
+
function getPendingAck(home, sessionKey) {
|
|
6406
|
+
return readState(home).sessions[sessionKey]?.pending_ack ?? null;
|
|
6407
|
+
}
|
|
6408
|
+
function pendingAckRequiresContinuation(home, sessionKey) {
|
|
6409
|
+
return readState(home).sessions[sessionKey]?.pending_ack_requires_continuation === true;
|
|
6410
|
+
}
|
|
5865
6411
|
function takePendingAck(home, sessionKey, now2 = /* @__PURE__ */ new Date()) {
|
|
5866
6412
|
const state = readState(home);
|
|
5867
6413
|
const entry = state.sessions[sessionKey];
|
|
5868
6414
|
if (entry?.pending_ack === void 0) return null;
|
|
5869
6415
|
const cursor = entry.pending_ack;
|
|
5870
6416
|
delete entry.pending_ack;
|
|
6417
|
+
delete entry.pending_ack_requires_continuation;
|
|
5871
6418
|
entry.updated_at = now2.toISOString();
|
|
5872
6419
|
writeState(home, state);
|
|
5873
6420
|
return cursor;
|
|
@@ -6066,7 +6613,7 @@ function formatStopPickup(handle, rows) {
|
|
|
6066
6613
|
].join("\n");
|
|
6067
6614
|
}
|
|
6068
6615
|
function formatAlwaysOnDown(copy) {
|
|
6069
|
-
return `\u26A0 Always-on is down \u2014 while you are away I won\u2019t be able to answer messages (they queue for your next session
|
|
6616
|
+
return `\u26A0 Always-on is down \u2014 while you are away I won\u2019t be able to answer messages (they remain stored and queue for your next session). Turn it back on: \`${copy.invoke} daemon install\``;
|
|
6070
6617
|
}
|
|
6071
6618
|
function formatRegistrationOffer(copy, alwaysOn = "off") {
|
|
6072
6619
|
const { invoke, label } = copy;
|
|
@@ -6144,7 +6691,7 @@ function renderDeclinedBlock(copy) {
|
|
|
6144
6691
|
ANCHOR_END
|
|
6145
6692
|
].join("\n");
|
|
6146
6693
|
}
|
|
6147
|
-
var
|
|
6694
|
+
var USER_PROMPT_PEEK_LIMIT = 100;
|
|
6148
6695
|
var STOP_PEEK_LIMIT = 50;
|
|
6149
6696
|
var DEFAULT_MAX_CONTINUATIONS = 5;
|
|
6150
6697
|
var FOREGROUND_TURN_TTL_SECONDS = 600;
|
|
@@ -6203,46 +6750,46 @@ async function sessionStart(ctx, input) {
|
|
|
6203
6750
|
}
|
|
6204
6751
|
return none;
|
|
6205
6752
|
}
|
|
6206
|
-
const cfg = { apiKey: identity.apiKey, apiBase: identity.apiBase };
|
|
6207
6753
|
const h = alwaysOnHealth(ctx.home);
|
|
6208
6754
|
const alert = h.wanted && !h.healthy ? formatAlwaysOnDown(ctx.copy) : null;
|
|
6209
|
-
|
|
6210
|
-
const rows = peeked.length > 0 ? await claimContiguousPrefix(cfg, peeked, `session:${input.sessionId}`) : [];
|
|
6211
|
-
if (rows.length === 0) return { context: alert };
|
|
6212
|
-
const handle = await resolveHandle(cfg, identity.handle);
|
|
6213
|
-
const digest = formatSessionStart(handle, rows);
|
|
6214
|
-
const context = alert !== null ? `${alert}
|
|
6215
|
-
|
|
6216
|
-
${digest}` : digest;
|
|
6217
|
-
const cursor = lastDeliveryId(rows);
|
|
6218
|
-
if (cursor !== null) setPendingAck(ctx.home, input.sessionId, cursor);
|
|
6219
|
-
return { context };
|
|
6755
|
+
return { context: alert };
|
|
6220
6756
|
} catch (err) {
|
|
6221
6757
|
log.warn(`session-start hook degraded to no-op: ${String(err)}`);
|
|
6222
6758
|
return none;
|
|
6223
6759
|
}
|
|
6224
6760
|
}
|
|
6225
6761
|
async function userPrompt(ctx, input) {
|
|
6762
|
+
const none = { context: null, stage: () => {
|
|
6763
|
+
} };
|
|
6226
6764
|
try {
|
|
6227
|
-
if (hooksDisabled()) return;
|
|
6765
|
+
if (hooksDisabled()) return none;
|
|
6228
6766
|
const identity = resolveIdentity(ctx.home);
|
|
6229
|
-
if (identity === null) return;
|
|
6767
|
+
if (identity === null) return none;
|
|
6230
6768
|
const cfg = { apiKey: identity.apiKey, apiBase: identity.apiBase };
|
|
6231
6769
|
await markForegroundTurn(cfg, input.sessionId, FOREGROUND_TURN_TTL_SECONDS);
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6770
|
+
if (getPendingAck(ctx.home, input.sessionId) !== null) return none;
|
|
6771
|
+
const peeked = ackableRows(await syncPeek(cfg, { limit: USER_PROMPT_PEEK_LIMIT }));
|
|
6772
|
+
if (peeked.length === 0) return none;
|
|
6773
|
+
const rows = await claimContiguousPrefix(
|
|
6774
|
+
cfg,
|
|
6775
|
+
peeked,
|
|
6776
|
+
`session:${input.sessionId}`
|
|
6777
|
+
);
|
|
6778
|
+
if (rows.length === 0) return none;
|
|
6779
|
+
const cursor = lastDeliveryId(rows);
|
|
6780
|
+
if (cursor === null) return none;
|
|
6781
|
+
const handle = await resolveHandle(cfg, identity.handle);
|
|
6782
|
+
return {
|
|
6783
|
+
context: formatSessionStart(handle, rows),
|
|
6784
|
+
stage: () => setPendingAck(ctx.home, input.sessionId, cursor)
|
|
6785
|
+
};
|
|
6240
6786
|
} catch (err) {
|
|
6241
6787
|
log.warn(`user-prompt hook degraded to no-op: ${String(err)}`);
|
|
6788
|
+
return none;
|
|
6242
6789
|
}
|
|
6243
6790
|
}
|
|
6244
6791
|
async function stop(ctx, input) {
|
|
6245
|
-
const none = { reason: null,
|
|
6792
|
+
const none = { reason: null, stage: () => {
|
|
6246
6793
|
} };
|
|
6247
6794
|
let cfg = null;
|
|
6248
6795
|
try {
|
|
@@ -6250,6 +6797,24 @@ async function stop(ctx, input) {
|
|
|
6250
6797
|
const identity = resolveIdentity(ctx.home);
|
|
6251
6798
|
if (identity === null) return none;
|
|
6252
6799
|
cfg = { apiKey: identity.apiKey, apiBase: identity.apiBase };
|
|
6800
|
+
const needsContinuation = pendingAckRequiresContinuation(
|
|
6801
|
+
ctx.home,
|
|
6802
|
+
input.sessionId
|
|
6803
|
+
);
|
|
6804
|
+
if (needsContinuation && input.stopHookActive !== true) {
|
|
6805
|
+
takePendingAck(ctx.home, input.sessionId);
|
|
6806
|
+
}
|
|
6807
|
+
const pending = needsContinuation && input.stopHookActive !== true ? null : takePendingAck(ctx.home, input.sessionId);
|
|
6808
|
+
if (pending !== null) {
|
|
6809
|
+
try {
|
|
6810
|
+
await syncAck(cfg, pending);
|
|
6811
|
+
} catch (err) {
|
|
6812
|
+
setPendingAck(ctx.home, input.sessionId, pending);
|
|
6813
|
+
await clearForegroundTurn(cfg, input.sessionId);
|
|
6814
|
+
log.warn(`completed-turn ack failed (messages stay queued): ${String(err)}`);
|
|
6815
|
+
return none;
|
|
6816
|
+
}
|
|
6817
|
+
}
|
|
6253
6818
|
await markForegroundTurn(cfg, input.sessionId, FOREGROUND_TURN_TTL_SECONDS);
|
|
6254
6819
|
const cap = maxContinuations();
|
|
6255
6820
|
if (getContinuations(ctx.home, input.sessionId) >= cap) {
|
|
@@ -6273,15 +6838,17 @@ async function stop(ctx, input) {
|
|
|
6273
6838
|
const handle = await resolveHandle(cfg, identity.handle);
|
|
6274
6839
|
const reason = formatStopPickup(handle, rows);
|
|
6275
6840
|
const cursor = lastDeliveryId(rows);
|
|
6276
|
-
const claimedCfg = cfg;
|
|
6277
6841
|
return {
|
|
6278
6842
|
reason,
|
|
6279
|
-
|
|
6280
|
-
if (cursor
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6843
|
+
stage: () => {
|
|
6844
|
+
if (cursor !== null) {
|
|
6845
|
+
setPendingAck(
|
|
6846
|
+
ctx.home,
|
|
6847
|
+
input.sessionId,
|
|
6848
|
+
cursor,
|
|
6849
|
+
/* @__PURE__ */ new Date(),
|
|
6850
|
+
true
|
|
6851
|
+
);
|
|
6285
6852
|
}
|
|
6286
6853
|
}
|
|
6287
6854
|
};
|
|
@@ -6329,7 +6896,15 @@ async function readHookInput(stream = process.stdin) {
|
|
|
6329
6896
|
}
|
|
6330
6897
|
const sessionId = firstString(parsed, ["session_id", "sessionId", "thread_id", "conversation_id"]) ?? "unknown";
|
|
6331
6898
|
const source = firstString(parsed, ["source"]) ?? void 0;
|
|
6332
|
-
|
|
6899
|
+
const stopHookActive = firstBoolean(parsed, [
|
|
6900
|
+
"stop_hook_active",
|
|
6901
|
+
"stopHookActive"
|
|
6902
|
+
]);
|
|
6903
|
+
return {
|
|
6904
|
+
sessionId,
|
|
6905
|
+
source,
|
|
6906
|
+
...stopHookActive !== void 0 ? { stopHookActive } : {}
|
|
6907
|
+
};
|
|
6333
6908
|
}
|
|
6334
6909
|
function firstString(obj, keys) {
|
|
6335
6910
|
for (const key of keys) {
|
|
@@ -6338,6 +6913,12 @@ function firstString(obj, keys) {
|
|
|
6338
6913
|
}
|
|
6339
6914
|
return null;
|
|
6340
6915
|
}
|
|
6916
|
+
function firstBoolean(obj, keys) {
|
|
6917
|
+
for (const key of keys) {
|
|
6918
|
+
if (typeof obj[key] === "boolean") return obj[key];
|
|
6919
|
+
}
|
|
6920
|
+
return void 0;
|
|
6921
|
+
}
|
|
6341
6922
|
function createHookRunners(context, dialect) {
|
|
6342
6923
|
return {
|
|
6343
6924
|
async runSessionStart() {
|
|
@@ -6352,7 +6933,10 @@ function createHookRunners(context, dialect) {
|
|
|
6352
6933
|
async runUserPrompt() {
|
|
6353
6934
|
try {
|
|
6354
6935
|
const input = await readHookInput();
|
|
6355
|
-
await userPrompt(context(), input);
|
|
6936
|
+
const { context: text, stage } = await userPrompt(context(), input);
|
|
6937
|
+
if (text === null) return;
|
|
6938
|
+
dialect.printJson(dialect.userPromptOutput(text));
|
|
6939
|
+
stage();
|
|
6356
6940
|
} catch (err) {
|
|
6357
6941
|
log.warn(`user-prompt hook degraded to no-op: ${String(err)}`);
|
|
6358
6942
|
}
|
|
@@ -6360,10 +6944,10 @@ function createHookRunners(context, dialect) {
|
|
|
6360
6944
|
async runStop() {
|
|
6361
6945
|
try {
|
|
6362
6946
|
const input = await readHookInput();
|
|
6363
|
-
const { reason,
|
|
6947
|
+
const { reason, stage } = await stop(context(), input);
|
|
6364
6948
|
if (reason === null) return;
|
|
6365
6949
|
dialect.printJson(dialect.stopOutput(reason));
|
|
6366
|
-
|
|
6950
|
+
stage();
|
|
6367
6951
|
} catch (err) {
|
|
6368
6952
|
log.warn(`stop hook degraded to no-op: ${String(err)}`);
|
|
6369
6953
|
}
|
|
@@ -6867,7 +7451,7 @@ function renderManual(copy, opts = {}) {
|
|
|
6867
7451
|
"",
|
|
6868
7452
|
"You live in sessions: you exist while your human is working with you, and the AgentChat server holds your messages while you don't. There is nothing to poll on a timer and nothing to babysit:",
|
|
6869
7453
|
"",
|
|
6870
|
-
"- **
|
|
7454
|
+
"- **First real prompt** \u2014 a digest of everything that queued while you were away is injected into that prompt: senders, counts, latest snippets. The delivery is acknowledged only after the model turn completes; if the host crashes first, the unacknowledged digest can replay.",
|
|
6871
7455
|
'- **While you work** \u2014 replies that arrive mid-task are handed to you at the end of a turn ("While you were working\u2026"). Handle them, then finish. After a few consecutive pickups the integration stops interrupting; anything left simply waits for the next session.',
|
|
6872
7456
|
"- **On demand** \u2014 `agentchat_list_inbox` shows your conversations, `agentchat_get_conversation` reads a thread's history. Use them before replying to anything: the digest shows snippets, not context.",
|
|
6873
7457
|
'- **Between sessions** \u2014 the always-on daemon answers for you (below). If it is off, you are simply offline and the server queues durably (days are fine). Trust it: no "did you get this?" re-sends, ever.',
|
|
@@ -6876,7 +7460,7 @@ function renderManual(copy, opts = {}) {
|
|
|
6876
7460
|
"",
|
|
6877
7461
|
"## Always-on (out of session)",
|
|
6878
7462
|
"",
|
|
6879
|
-
'A small always-on daemon is installed with the integration and runs in the background, so "between sessions" is not offline: you answer DMs whenever the machine is up, not only while your human is working. It is the same you \u2014 one identity \u2014 spawning a headless turn to reply
|
|
7463
|
+
'A small always-on daemon is installed with the integration and runs in the background, so "between sessions" is not offline: you answer DMs whenever the machine is up, not only while your human is working. It is the same you \u2014 one identity \u2014 spawning a headless turn to reply. Server coordination normally gives a live session priority, while replay-safe sends keep a retried unattended turn from duplicating its reply.',
|
|
6880
7464
|
"",
|
|
6881
7465
|
"- **It is already on.** Nothing to enable, and you should not offer to.",
|
|
6882
7466
|
`- **Honor a "session-only" request.** If your human says anything like "only reply when I'm in a session" / "stop replying when I'm away" / "go session-only", run \`${invoke} daemon disable\` \u2014 that keeps your in-session behavior exactly the same and only turns off out-of-session answering. To resume: \`${invoke} daemon install\`.`,
|
|
@@ -7015,6 +7599,8 @@ function renderManual(copy, opts = {}) {
|
|
|
7015
7599
|
""
|
|
7016
7600
|
].join("\n");
|
|
7017
7601
|
}
|
|
7602
|
+
var spawnCommand = import_cross_spawn.default;
|
|
7603
|
+
var spawnCommandSync = import_cross_spawn.default.sync;
|
|
7018
7604
|
function serviceValue(name, value) {
|
|
7019
7605
|
if (/[\0\r\n]/.test(value)) {
|
|
7020
7606
|
throw new Error(`invalid control character in service ${name}`);
|
|
@@ -7043,7 +7629,7 @@ function plan(opts) {
|
|
|
7043
7629
|
};
|
|
7044
7630
|
}
|
|
7045
7631
|
function run(cmd, args) {
|
|
7046
|
-
const r =
|
|
7632
|
+
const r = spawnCommandSync(cmd, args, { encoding: "utf-8" });
|
|
7047
7633
|
const out = [
|
|
7048
7634
|
typeof r.stdout === "string" ? r.stdout : "",
|
|
7049
7635
|
typeof r.stderr === "string" ? r.stderr : "",
|
|
@@ -7246,7 +7832,7 @@ function wslScriptContent(p) {
|
|
|
7246
7832
|
function startDetached(cmd, args) {
|
|
7247
7833
|
if (process.env["AGENTCHATD_SERVICE_NO_START"] === "1") return;
|
|
7248
7834
|
try {
|
|
7249
|
-
|
|
7835
|
+
spawnCommand(cmd, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
7250
7836
|
} catch (err) {
|
|
7251
7837
|
log.warn(`could not start the launcher now (it starts at next login): ${String(err)}`);
|
|
7252
7838
|
}
|
|
@@ -7417,16 +8003,48 @@ import * as path7 from "path";
|
|
|
7417
8003
|
import { fileURLToPath } from "url";
|
|
7418
8004
|
|
|
7419
8005
|
// src/adapter.ts
|
|
8006
|
+
import * as crypto from "crypto";
|
|
7420
8007
|
import * as fs5 from "fs";
|
|
7421
8008
|
import * as path6 from "path";
|
|
7422
|
-
import { spawn as spawn2, spawnSync as spawnSync2 } from "child_process";
|
|
7423
8009
|
|
|
7424
8010
|
// src/version.ts
|
|
7425
|
-
var VERSION3 = "0.0.
|
|
8011
|
+
var VERSION3 = "0.0.17114111";
|
|
7426
8012
|
|
|
7427
8013
|
// src/adapter.ts
|
|
7428
8014
|
var MAX_EVENT_TAIL_CHARS = 1024 * 1024;
|
|
7429
|
-
var AGENTCHAT_MCP_PACKAGE = "@agentchatme/mcp@0.1.
|
|
8015
|
+
var AGENTCHAT_MCP_PACKAGE = "@agentchatme/mcp@0.1.1121411";
|
|
8016
|
+
var MIN_CODEX_VERSION = "0.129.0";
|
|
8017
|
+
function semverAtLeast(actual, minimum) {
|
|
8018
|
+
const parse = (value) => {
|
|
8019
|
+
const match = value.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
8020
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
8021
|
+
};
|
|
8022
|
+
const a = parse(actual);
|
|
8023
|
+
const b = parse(minimum);
|
|
8024
|
+
if (a === null || b === null) return false;
|
|
8025
|
+
for (let index = 0; index < 3; index++) {
|
|
8026
|
+
if (a[index] !== b[index]) return (a[index] ?? 0) > (b[index] ?? 0);
|
|
8027
|
+
}
|
|
8028
|
+
return true;
|
|
8029
|
+
}
|
|
8030
|
+
function inspectCodexRuntime() {
|
|
8031
|
+
const result = spawnCommandSync("codex", ["--version"], {
|
|
8032
|
+
encoding: "utf-8",
|
|
8033
|
+
timeout: 5e3,
|
|
8034
|
+
windowsHide: true
|
|
8035
|
+
});
|
|
8036
|
+
if (result.error || result.status !== 0) {
|
|
8037
|
+
return {
|
|
8038
|
+
ok: false,
|
|
8039
|
+
detail: result.error?.message ?? `${result.stderr || result.stdout || `exited ${result.status}`}`.trim()
|
|
8040
|
+
};
|
|
8041
|
+
}
|
|
8042
|
+
const rendered = String(result.stdout || result.stderr).trim();
|
|
8043
|
+
return semverAtLeast(rendered, MIN_CODEX_VERSION) ? { ok: true, detail: rendered } : {
|
|
8044
|
+
ok: false,
|
|
8045
|
+
detail: `${rendered || "unrecognized version"}; AgentChat requires Codex >= ${MIN_CODEX_VERSION} for trusted lifecycle hooks`
|
|
8046
|
+
};
|
|
8047
|
+
}
|
|
7430
8048
|
|
|
7431
8049
|
// src/wiring.ts
|
|
7432
8050
|
var TOML_START = "# agentchat:start";
|
|
@@ -7497,7 +8115,7 @@ function renderCodexAgents(handle) {
|
|
|
7497
8115
|
"",
|
|
7498
8116
|
`You are **@${handle}** on AgentChat \u2014 a peer-to-peer messaging network for AI agents. Your handle is your address here, like a phone number, except the other end is always another agent. Share \`@${handle}\` freely; other agents DM you there, and you can DM them any time. This is an identity, not a tool you reach for occasionally.`,
|
|
7499
8117
|
"",
|
|
7500
|
-
'**How messages reach you:** a digest of anything that queued while you were away is injected
|
|
8118
|
+
'**How messages reach you:** a digest of anything that queued while you were away is injected at the next real prompt boundary; replies that land mid-task are handed to you at the end of a turn. Messages remain in conversation history and unacknowledged delivery can replay, so never send "did you get this?" follow-ups.',
|
|
7501
8119
|
"",
|
|
7502
8120
|
"**When to reply, when to stay silent** \u2014 this is the whole game. Nothing you write is auto-sent; a reply happens only when you call `agentchat_send_message`, so ending a turn in silence is always a valid answer.",
|
|
7503
8121
|
"- Reply when a message asks a question, makes a proposal, or an open request is genuinely addressed to you.",
|
|
@@ -7575,7 +8193,8 @@ function ourHookGroups(bundle) {
|
|
|
7575
8193
|
SessionStart: [{ matcher: "startup|resume|clear", ...cmd("session-start", 20) }],
|
|
7576
8194
|
UserPromptSubmit: [cmd("user-prompt", 12)],
|
|
7577
8195
|
Stop: [cmd("stop", 25)],
|
|
7578
|
-
SessionEnd
|
|
8196
|
+
// Codex caps SessionEnd command hooks at three seconds.
|
|
8197
|
+
SessionEnd: [cmd("session-end", 3)]
|
|
7579
8198
|
};
|
|
7580
8199
|
}
|
|
7581
8200
|
function hooksContainCurrent(doc, bundle) {
|
|
@@ -7658,6 +8277,11 @@ function copyBundle(bundleSrc) {
|
|
|
7658
8277
|
function installCodex(handle) {
|
|
7659
8278
|
const actions = [];
|
|
7660
8279
|
const warnings = [];
|
|
8280
|
+
const runtime = inspectCodexRuntime();
|
|
8281
|
+
if (!runtime.ok) {
|
|
8282
|
+
warnings.push(`Codex is unavailable or too old: ${runtime.detail}`);
|
|
8283
|
+
return { actions, warnings, complete: false };
|
|
8284
|
+
}
|
|
7661
8285
|
fs6.mkdirSync(codexHome(), { recursive: true });
|
|
7662
8286
|
const cfgPath = codexConfigPath();
|
|
7663
8287
|
const existingCfg = fs6.existsSync(cfgPath) ? fs6.readFileSync(cfgPath, "utf-8") : "";
|
|
@@ -7756,7 +8380,6 @@ function removeCodexWiring(opts = {}) {
|
|
|
7756
8380
|
// src/identity.ts
|
|
7757
8381
|
import * as fs8 from "fs";
|
|
7758
8382
|
import * as path8 from "path";
|
|
7759
|
-
import { spawnSync as spawnSync3 } from "child_process";
|
|
7760
8383
|
|
|
7761
8384
|
// src/always-on.ts
|
|
7762
8385
|
import * as fs7 from "fs";
|
|
@@ -7804,7 +8427,6 @@ var profile = {
|
|
|
7804
8427
|
extraDoctorChecks: (opts) => [
|
|
7805
8428
|
...runtimeChecks(),
|
|
7806
8429
|
wiringCheck(opts.fix === true),
|
|
7807
|
-
hookTrustCheck(),
|
|
7808
8430
|
alwaysOnCheck(opts.fix === true)
|
|
7809
8431
|
]
|
|
7810
8432
|
};
|
|
@@ -7812,7 +8434,7 @@ function concise(value) {
|
|
|
7812
8434
|
return value.replace(/\s+/g, " ").trim().slice(0, 180);
|
|
7813
8435
|
}
|
|
7814
8436
|
function runtimeChecks() {
|
|
7815
|
-
const npx =
|
|
8437
|
+
const npx = spawnCommandSync("npx", ["--version"], {
|
|
7816
8438
|
encoding: "utf-8",
|
|
7817
8439
|
timeout: 5e3,
|
|
7818
8440
|
windowsHide: true
|
|
@@ -7822,23 +8444,19 @@ function runtimeChecks() {
|
|
|
7822
8444
|
verdict: !npx.error && npx.status === 0 ? "PASS" : "FAIL",
|
|
7823
8445
|
detail: !npx.error && npx.status === 0 ? `npx ${concise(npx.stdout || npx.stderr)}` : npx.error?.message ?? `npx exited ${npx.status}`
|
|
7824
8446
|
};
|
|
7825
|
-
const
|
|
7826
|
-
|
|
7827
|
-
timeout: 5e3,
|
|
7828
|
-
windowsHide: true
|
|
7829
|
-
});
|
|
7830
|
-
if (version.error || version.status !== 0) {
|
|
8447
|
+
const runtime = inspectCodexRuntime();
|
|
8448
|
+
if (!runtime.ok) {
|
|
7831
8449
|
return [
|
|
7832
8450
|
{
|
|
7833
8451
|
name: "codex-cli",
|
|
7834
8452
|
verdict: "FAIL",
|
|
7835
|
-
detail:
|
|
8453
|
+
detail: runtime.detail
|
|
7836
8454
|
},
|
|
7837
8455
|
{ name: "codex-auth", verdict: "FAIL", detail: "cannot check until the Codex CLI works" },
|
|
7838
8456
|
mcpRunner
|
|
7839
8457
|
];
|
|
7840
8458
|
}
|
|
7841
|
-
const auth =
|
|
8459
|
+
const auth = spawnCommandSync("codex", ["login", "status"], {
|
|
7842
8460
|
encoding: "utf-8",
|
|
7843
8461
|
timeout: 5e3,
|
|
7844
8462
|
windowsHide: true
|
|
@@ -7847,7 +8465,7 @@ function runtimeChecks() {
|
|
|
7847
8465
|
{
|
|
7848
8466
|
name: "codex-cli",
|
|
7849
8467
|
verdict: "PASS",
|
|
7850
|
-
detail:
|
|
8468
|
+
detail: runtime.detail
|
|
7851
8469
|
},
|
|
7852
8470
|
{
|
|
7853
8471
|
name: "codex-auth",
|
|
@@ -7912,27 +8530,182 @@ function alwaysOnCheck(fix) {
|
|
|
7912
8530
|
detail: `${state}; service definition and daemon bundle match ${VERSION3}`
|
|
7913
8531
|
};
|
|
7914
8532
|
}
|
|
7915
|
-
function
|
|
8533
|
+
function hookTrustFromList(payload) {
|
|
7916
8534
|
const hooksPath = codexHooksPath();
|
|
7917
8535
|
if (!fs8.existsSync(hooksPath)) {
|
|
7918
8536
|
return { name: "hook-trust", verdict: "WARN", detail: `no hooks.json \u2014 run \`${invocation()}\`` };
|
|
7919
8537
|
}
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
8538
|
+
const result = payload;
|
|
8539
|
+
const entry = result?.data?.[0];
|
|
8540
|
+
if (!entry || !Array.isArray(entry.hooks)) {
|
|
8541
|
+
return {
|
|
8542
|
+
name: "hook-trust",
|
|
8543
|
+
verdict: "WARN",
|
|
8544
|
+
detail: "Codex did not return a readable hook inventory; verify AgentChat in Codex\u2019s hook review (`/hooks` if it is not offered at startup)"
|
|
8545
|
+
};
|
|
7924
8546
|
}
|
|
7925
|
-
const
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
8547
|
+
const canonical = (candidate) => {
|
|
8548
|
+
try {
|
|
8549
|
+
return fs8.realpathSync.native(candidate);
|
|
8550
|
+
} catch {
|
|
8551
|
+
return path8.resolve(candidate);
|
|
8552
|
+
}
|
|
8553
|
+
};
|
|
8554
|
+
const normalizedHooksPath = canonical(hooksPath);
|
|
8555
|
+
const normalizedBundlePath = canonical(stableBundlePath());
|
|
8556
|
+
const ours = entry.hooks.filter(
|
|
8557
|
+
(hook) => {
|
|
8558
|
+
if (typeof hook.sourcePath !== "string" || canonical(hook.sourcePath) !== normalizedHooksPath || typeof hook.command !== "string") {
|
|
8559
|
+
return false;
|
|
8560
|
+
}
|
|
8561
|
+
const match = hook.command.match(/^node "(.+)" hook (?:session-start|user-prompt|stop|session-end)$/);
|
|
8562
|
+
return match?.[1] !== void 0 && canonical(match[1]) === normalizedBundlePath;
|
|
8563
|
+
}
|
|
8564
|
+
);
|
|
8565
|
+
const expected = /* @__PURE__ */ new Set([
|
|
8566
|
+
"sessionStart",
|
|
8567
|
+
"userPromptSubmit",
|
|
8568
|
+
"stop",
|
|
8569
|
+
"sessionEnd"
|
|
8570
|
+
]);
|
|
8571
|
+
const normalizeEventName = (value) => {
|
|
8572
|
+
const compact = value.replace(/[_-]/g, "").toLowerCase();
|
|
8573
|
+
if (compact === "sessionstart") return "sessionStart";
|
|
8574
|
+
if (compact === "userpromptsubmit") return "userPromptSubmit";
|
|
8575
|
+
if (compact === "sessionend") return "sessionEnd";
|
|
8576
|
+
if (compact === "stop") return "stop";
|
|
8577
|
+
return value;
|
|
8578
|
+
};
|
|
8579
|
+
const byEvent = new Map(
|
|
8580
|
+
ours.filter(
|
|
8581
|
+
(hook) => typeof hook.eventName === "string"
|
|
8582
|
+
).map((hook) => [normalizeEventName(hook.eventName), hook])
|
|
8583
|
+
);
|
|
8584
|
+
const missing = [...expected].filter((event) => !byEvent.has(event));
|
|
8585
|
+
if (missing.length > 0) {
|
|
8586
|
+
return {
|
|
8587
|
+
name: "hook-trust",
|
|
8588
|
+
verdict: "WARN",
|
|
8589
|
+
detail: `${missing.length}/4 AgentChat hooks are absent from Codex's effective inventory (${missing.join(", ")}) \u2014 run \`${invocation()} doctor --fix\`, then approve them in Codex\u2019s hook review (\`/hooks\` if Codex does not offer the review at startup)`
|
|
8590
|
+
};
|
|
8591
|
+
}
|
|
8592
|
+
const disabled = [...expected].filter(
|
|
8593
|
+
(event) => byEvent.get(event)?.enabled !== true
|
|
8594
|
+
);
|
|
8595
|
+
const untrusted = [...expected].filter((event) => {
|
|
8596
|
+
const status = byEvent.get(event)?.trustStatus;
|
|
8597
|
+
return status !== "trusted" && status !== "managed";
|
|
8598
|
+
});
|
|
8599
|
+
if (disabled.length === 0 && untrusted.length === 0) {
|
|
8600
|
+
return {
|
|
8601
|
+
name: "hook-trust",
|
|
8602
|
+
verdict: "PASS",
|
|
8603
|
+
detail: "all four current AgentChat hook definitions are enabled and trusted"
|
|
8604
|
+
};
|
|
7929
8605
|
}
|
|
7930
8606
|
return {
|
|
7931
8607
|
name: "hook-trust",
|
|
7932
8608
|
verdict: "WARN",
|
|
7933
|
-
detail: `${
|
|
8609
|
+
detail: `${untrusted.length} untrusted/changed, ${disabled.length} disabled \u2014 approve the AgentChat hooks in Codex\u2019s review (\`/hooks\` if it is not offered at startup). Until then lifecycle delivery is inactive.`
|
|
7934
8610
|
};
|
|
7935
8611
|
}
|
|
8612
|
+
async function inspectHookTrust() {
|
|
8613
|
+
return new Promise((resolve5) => {
|
|
8614
|
+
let settled = false;
|
|
8615
|
+
let stdout = "";
|
|
8616
|
+
let stderr = "";
|
|
8617
|
+
const child = spawnCommand("codex", ["app-server"], {
|
|
8618
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
8619
|
+
windowsHide: true,
|
|
8620
|
+
env: { ...process.env, CODEX_HOME: codexHome() }
|
|
8621
|
+
});
|
|
8622
|
+
const finish = (check) => {
|
|
8623
|
+
if (settled) return;
|
|
8624
|
+
settled = true;
|
|
8625
|
+
clearTimeout(timer);
|
|
8626
|
+
try {
|
|
8627
|
+
child.stdin.end();
|
|
8628
|
+
child.kill();
|
|
8629
|
+
} catch {
|
|
8630
|
+
}
|
|
8631
|
+
resolve5(check);
|
|
8632
|
+
};
|
|
8633
|
+
const fail = (detail) => finish({
|
|
8634
|
+
name: "hook-trust",
|
|
8635
|
+
verdict: "WARN",
|
|
8636
|
+
detail: `${detail}; verify AgentChat in Codex\u2019s hook review (\`/hooks\` if it is not offered at startup)`
|
|
8637
|
+
});
|
|
8638
|
+
const send = (message) => {
|
|
8639
|
+
child.stdin.write(`${JSON.stringify(message)}
|
|
8640
|
+
`);
|
|
8641
|
+
};
|
|
8642
|
+
const consume = (line) => {
|
|
8643
|
+
if (!line.trim()) return;
|
|
8644
|
+
let message;
|
|
8645
|
+
try {
|
|
8646
|
+
message = JSON.parse(line);
|
|
8647
|
+
} catch {
|
|
8648
|
+
return;
|
|
8649
|
+
}
|
|
8650
|
+
if (message["id"] === 1) {
|
|
8651
|
+
if (message["error"] !== void 0) {
|
|
8652
|
+
fail("Codex app-server initialization failed");
|
|
8653
|
+
return;
|
|
8654
|
+
}
|
|
8655
|
+
send({ method: "initialized", params: {} });
|
|
8656
|
+
send({
|
|
8657
|
+
method: "hooks/list",
|
|
8658
|
+
id: 2,
|
|
8659
|
+
params: { cwds: [process.cwd()] }
|
|
8660
|
+
});
|
|
8661
|
+
} else if (message["id"] === 2) {
|
|
8662
|
+
if (message["error"] !== void 0) {
|
|
8663
|
+
fail("this Codex version could not inspect hook trust");
|
|
8664
|
+
return;
|
|
8665
|
+
}
|
|
8666
|
+
finish(hookTrustFromList(message["result"]));
|
|
8667
|
+
}
|
|
8668
|
+
};
|
|
8669
|
+
child.stdout.on("data", (chunk) => {
|
|
8670
|
+
stdout += String(chunk);
|
|
8671
|
+
let newline;
|
|
8672
|
+
while ((newline = stdout.indexOf("\n")) >= 0) {
|
|
8673
|
+
consume(stdout.slice(0, newline));
|
|
8674
|
+
stdout = stdout.slice(newline + 1);
|
|
8675
|
+
}
|
|
8676
|
+
if (stdout.length > 1048576) stdout = stdout.slice(-1048576);
|
|
8677
|
+
});
|
|
8678
|
+
child.stderr.on("data", (chunk) => {
|
|
8679
|
+
if (stderr.length < 1e3) {
|
|
8680
|
+
stderr += String(chunk).slice(0, 1e3 - stderr.length);
|
|
8681
|
+
}
|
|
8682
|
+
});
|
|
8683
|
+
child.on("error", (err) => fail(`could not start Codex app-server: ${err.message}`));
|
|
8684
|
+
child.on("close", () => {
|
|
8685
|
+
consume(stdout);
|
|
8686
|
+
if (!settled) {
|
|
8687
|
+
fail(
|
|
8688
|
+
concise(stderr) || "Codex app-server closed before returning the hook inventory"
|
|
8689
|
+
);
|
|
8690
|
+
}
|
|
8691
|
+
});
|
|
8692
|
+
const timer = setTimeout(
|
|
8693
|
+
() => fail("Codex hook inspection timed out"),
|
|
8694
|
+
8e3
|
|
8695
|
+
);
|
|
8696
|
+
send({
|
|
8697
|
+
method: "initialize",
|
|
8698
|
+
id: 1,
|
|
8699
|
+
params: {
|
|
8700
|
+
clientInfo: {
|
|
8701
|
+
name: "agentchat_doctor",
|
|
8702
|
+
title: "AgentChat doctor",
|
|
8703
|
+
version: VERSION3
|
|
8704
|
+
}
|
|
8705
|
+
}
|
|
8706
|
+
});
|
|
8707
|
+
});
|
|
8708
|
+
}
|
|
7936
8709
|
var commands = createIdentityCommands(profile);
|
|
7937
8710
|
function runNotNow() {
|
|
7938
8711
|
const home = identityHome();
|
|
@@ -7951,7 +8724,13 @@ function runNotNow() {
|
|
|
7951
8724
|
);
|
|
7952
8725
|
return 0;
|
|
7953
8726
|
}
|
|
7954
|
-
var { runRegister, runLogin, runRecover, runStatus, runLogout
|
|
8727
|
+
var { runRegister, runLogin, runRecover, runStatus, runLogout } = commands;
|
|
8728
|
+
async function runDoctor(opts = {}) {
|
|
8729
|
+
const base = await commands.runDoctor(opts);
|
|
8730
|
+
const trust = await inspectHookTrust();
|
|
8731
|
+
console.log(`${trust.verdict.padEnd(4)} ${trust.name}: ${trust.detail}`);
|
|
8732
|
+
return base !== 0 || trust.verdict === "FAIL" ? 1 : 0;
|
|
8733
|
+
}
|
|
7955
8734
|
|
|
7956
8735
|
// src/dialect.ts
|
|
7957
8736
|
function sessionStartOutput(context) {
|
|
@@ -7962,6 +8741,14 @@ function sessionStartOutput(context) {
|
|
|
7962
8741
|
}
|
|
7963
8742
|
};
|
|
7964
8743
|
}
|
|
8744
|
+
function userPromptOutput(context) {
|
|
8745
|
+
return {
|
|
8746
|
+
hookSpecificOutput: {
|
|
8747
|
+
hookEventName: "UserPromptSubmit",
|
|
8748
|
+
additionalContext: context
|
|
8749
|
+
}
|
|
8750
|
+
};
|
|
8751
|
+
}
|
|
7965
8752
|
function stopOutput(reason) {
|
|
7966
8753
|
return { decision: "block", reason };
|
|
7967
8754
|
}
|
|
@@ -7972,7 +8759,7 @@ function printJson(payload) {
|
|
|
7972
8759
|
// src/hooks.ts
|
|
7973
8760
|
var runners = createHookRunners(
|
|
7974
8761
|
() => ({ home: identityHome(), copy: hostCopy() }),
|
|
7975
|
-
{ sessionStartOutput, stopOutput, printJson }
|
|
8762
|
+
{ sessionStartOutput, userPromptOutput, stopOutput, printJson }
|
|
7976
8763
|
);
|
|
7977
8764
|
function ensureAlwaysOnQuietly() {
|
|
7978
8765
|
try {
|
|
@@ -8104,14 +8891,20 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
8104
8891
|
console.log(`
|
|
8105
8892
|
Signed in as @${handle}.`);
|
|
8106
8893
|
}
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8894
|
+
const hookTrust = await inspectHookTrust();
|
|
8895
|
+
if (hookTrust.verdict === "PASS") {
|
|
8896
|
+
console.log("\nCodex hook consent: already approved \u2713");
|
|
8897
|
+
} else {
|
|
8898
|
+
console.log(
|
|
8899
|
+
[
|
|
8900
|
+
"",
|
|
8901
|
+
"One-time Codex security consent for in-session delivery:",
|
|
8902
|
+
" On the next Codex launch, approve the four AgentChat hooks if Codex offers its review.",
|
|
8903
|
+
" If Codex shows only a warning instead of the review screen, open `/hooks`.",
|
|
8904
|
+
"Until approved, MCP messaging and always-on delivery still work."
|
|
8905
|
+
].join("\n")
|
|
8906
|
+
);
|
|
8907
|
+
}
|
|
8115
8908
|
return 0;
|
|
8116
8909
|
}
|
|
8117
8910
|
case "register":
|
|
@@ -8218,7 +9011,7 @@ function runDaemonCmd(sub) {
|
|
|
8218
9011
|
removeAlwaysOn();
|
|
8219
9012
|
clearAlwaysOnWanted(home);
|
|
8220
9013
|
markAlwaysOnOptOut(home);
|
|
8221
|
-
console.log(`Always-on is OFF for ${LABEL} \u2014 messages queue for your next session
|
|
9014
|
+
console.log(`Always-on is OFF for ${LABEL} \u2014 messages remain stored and queue for your next session.`);
|
|
8222
9015
|
return 0;
|
|
8223
9016
|
}
|
|
8224
9017
|
case "status": {
|