@kenkaiiii/gg-boss 4.10.1 → 4.11.0
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/dist/{chunk-EV37X3XL.js → chunk-D3OOVNMX.js} +1041 -282
- package/dist/{chunk-EV37X3XL.js.map → chunk-D3OOVNMX.js.map} +1 -1
- package/dist/cli.js +19 -258
- package/dist/cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
|
@@ -3225,8 +3225,8 @@ var require_utils = __commonJS({
|
|
|
3225
3225
|
}
|
|
3226
3226
|
return ind;
|
|
3227
3227
|
}
|
|
3228
|
-
function removeDotSegments(
|
|
3229
|
-
let input =
|
|
3228
|
+
function removeDotSegments(path46) {
|
|
3229
|
+
let input = path46;
|
|
3230
3230
|
const output = [];
|
|
3231
3231
|
let nextSlash = -1;
|
|
3232
3232
|
let len = 0;
|
|
@@ -3426,8 +3426,8 @@ var require_schemes = __commonJS({
|
|
|
3426
3426
|
wsComponent.secure = void 0;
|
|
3427
3427
|
}
|
|
3428
3428
|
if (wsComponent.resourceName) {
|
|
3429
|
-
const [
|
|
3430
|
-
wsComponent.path =
|
|
3429
|
+
const [path46, query] = wsComponent.resourceName.split("?");
|
|
3430
|
+
wsComponent.path = path46 && path46 !== "/" ? path46 : void 0;
|
|
3431
3431
|
wsComponent.query = query;
|
|
3432
3432
|
wsComponent.resourceName = void 0;
|
|
3433
3433
|
}
|
|
@@ -6835,12 +6835,12 @@ var require_dist = __commonJS({
|
|
|
6835
6835
|
throw new Error(`Unknown format "${name}"`);
|
|
6836
6836
|
return f;
|
|
6837
6837
|
};
|
|
6838
|
-
function addFormats(ajv, list,
|
|
6838
|
+
function addFormats(ajv, list, fs39, exportName) {
|
|
6839
6839
|
var _a6;
|
|
6840
6840
|
var _b;
|
|
6841
6841
|
(_a6 = (_b = ajv.opts.code).formats) !== null && _a6 !== void 0 ? _a6 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6842
6842
|
for (const f of list)
|
|
6843
|
-
ajv.addFormat(f,
|
|
6843
|
+
ajv.addFormat(f, fs39[f]);
|
|
6844
6844
|
}
|
|
6845
6845
|
module.exports = exports = formatsPlugin;
|
|
6846
6846
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6855,8 +6855,8 @@ var require_windows = __commonJS({
|
|
|
6855
6855
|
init_esm_shims();
|
|
6856
6856
|
module.exports = isexe;
|
|
6857
6857
|
isexe.sync = sync;
|
|
6858
|
-
var
|
|
6859
|
-
function checkPathExt(
|
|
6858
|
+
var fs39 = __require("fs");
|
|
6859
|
+
function checkPathExt(path46, options) {
|
|
6860
6860
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
6861
6861
|
if (!pathext) {
|
|
6862
6862
|
return true;
|
|
@@ -6867,25 +6867,25 @@ var require_windows = __commonJS({
|
|
|
6867
6867
|
}
|
|
6868
6868
|
for (var i = 0; i < pathext.length; i++) {
|
|
6869
6869
|
var p = pathext[i].toLowerCase();
|
|
6870
|
-
if (p &&
|
|
6870
|
+
if (p && path46.substr(-p.length).toLowerCase() === p) {
|
|
6871
6871
|
return true;
|
|
6872
6872
|
}
|
|
6873
6873
|
}
|
|
6874
6874
|
return false;
|
|
6875
6875
|
}
|
|
6876
|
-
function checkStat(stat,
|
|
6876
|
+
function checkStat(stat, path46, options) {
|
|
6877
6877
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
6878
6878
|
return false;
|
|
6879
6879
|
}
|
|
6880
|
-
return checkPathExt(
|
|
6880
|
+
return checkPathExt(path46, options);
|
|
6881
6881
|
}
|
|
6882
|
-
function isexe(
|
|
6883
|
-
|
|
6884
|
-
cb(er, er ? false : checkStat(stat,
|
|
6882
|
+
function isexe(path46, options, cb) {
|
|
6883
|
+
fs39.stat(path46, function(er, stat) {
|
|
6884
|
+
cb(er, er ? false : checkStat(stat, path46, options));
|
|
6885
6885
|
});
|
|
6886
6886
|
}
|
|
6887
|
-
function sync(
|
|
6888
|
-
return checkStat(
|
|
6887
|
+
function sync(path46, options) {
|
|
6888
|
+
return checkStat(fs39.statSync(path46), path46, options);
|
|
6889
6889
|
}
|
|
6890
6890
|
}
|
|
6891
6891
|
});
|
|
@@ -6897,14 +6897,14 @@ var require_mode = __commonJS({
|
|
|
6897
6897
|
init_esm_shims();
|
|
6898
6898
|
module.exports = isexe;
|
|
6899
6899
|
isexe.sync = sync;
|
|
6900
|
-
var
|
|
6901
|
-
function isexe(
|
|
6902
|
-
|
|
6900
|
+
var fs39 = __require("fs");
|
|
6901
|
+
function isexe(path46, options, cb) {
|
|
6902
|
+
fs39.stat(path46, function(er, stat) {
|
|
6903
6903
|
cb(er, er ? false : checkStat(stat, options));
|
|
6904
6904
|
});
|
|
6905
6905
|
}
|
|
6906
|
-
function sync(
|
|
6907
|
-
return checkStat(
|
|
6906
|
+
function sync(path46, options) {
|
|
6907
|
+
return checkStat(fs39.statSync(path46), options);
|
|
6908
6908
|
}
|
|
6909
6909
|
function checkStat(stat, options) {
|
|
6910
6910
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -6930,7 +6930,7 @@ var require_isexe = __commonJS({
|
|
|
6930
6930
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
6931
6931
|
"use strict";
|
|
6932
6932
|
init_esm_shims();
|
|
6933
|
-
var
|
|
6933
|
+
var fs39 = __require("fs");
|
|
6934
6934
|
var core;
|
|
6935
6935
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
6936
6936
|
core = require_windows();
|
|
@@ -6939,7 +6939,7 @@ var require_isexe = __commonJS({
|
|
|
6939
6939
|
}
|
|
6940
6940
|
module.exports = isexe;
|
|
6941
6941
|
isexe.sync = sync;
|
|
6942
|
-
function isexe(
|
|
6942
|
+
function isexe(path46, options, cb) {
|
|
6943
6943
|
if (typeof options === "function") {
|
|
6944
6944
|
cb = options;
|
|
6945
6945
|
options = {};
|
|
@@ -6949,7 +6949,7 @@ var require_isexe = __commonJS({
|
|
|
6949
6949
|
throw new TypeError("callback not provided");
|
|
6950
6950
|
}
|
|
6951
6951
|
return new Promise(function(resolve2, reject) {
|
|
6952
|
-
isexe(
|
|
6952
|
+
isexe(path46, options || {}, function(er, is) {
|
|
6953
6953
|
if (er) {
|
|
6954
6954
|
reject(er);
|
|
6955
6955
|
} else {
|
|
@@ -6958,7 +6958,7 @@ var require_isexe = __commonJS({
|
|
|
6958
6958
|
});
|
|
6959
6959
|
});
|
|
6960
6960
|
}
|
|
6961
|
-
core(
|
|
6961
|
+
core(path46, options || {}, function(er, is) {
|
|
6962
6962
|
if (er) {
|
|
6963
6963
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
6964
6964
|
er = null;
|
|
@@ -6968,9 +6968,9 @@ var require_isexe = __commonJS({
|
|
|
6968
6968
|
cb(er, is);
|
|
6969
6969
|
});
|
|
6970
6970
|
}
|
|
6971
|
-
function sync(
|
|
6971
|
+
function sync(path46, options) {
|
|
6972
6972
|
try {
|
|
6973
|
-
return core.sync(
|
|
6973
|
+
return core.sync(path46, options || {});
|
|
6974
6974
|
} catch (er) {
|
|
6975
6975
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
6976
6976
|
return false;
|
|
@@ -6988,7 +6988,7 @@ var require_which = __commonJS({
|
|
|
6988
6988
|
"use strict";
|
|
6989
6989
|
init_esm_shims();
|
|
6990
6990
|
var isWindows3 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
6991
|
-
var
|
|
6991
|
+
var path46 = __require("path");
|
|
6992
6992
|
var COLON = isWindows3 ? ";" : ":";
|
|
6993
6993
|
var isexe = require_isexe();
|
|
6994
6994
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -7026,7 +7026,7 @@ var require_which = __commonJS({
|
|
|
7026
7026
|
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
7027
7027
|
const ppRaw = pathEnv[i];
|
|
7028
7028
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
7029
|
-
const pCmd =
|
|
7029
|
+
const pCmd = path46.join(pathPart, cmd);
|
|
7030
7030
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
7031
7031
|
resolve2(subStep(p, i, 0));
|
|
7032
7032
|
});
|
|
@@ -7053,7 +7053,7 @@ var require_which = __commonJS({
|
|
|
7053
7053
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
7054
7054
|
const ppRaw = pathEnv[i];
|
|
7055
7055
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
7056
|
-
const pCmd =
|
|
7056
|
+
const pCmd = path46.join(pathPart, cmd);
|
|
7057
7057
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
7058
7058
|
for (let j = 0; j < pathExt.length; j++) {
|
|
7059
7059
|
const cur = p + pathExt[j];
|
|
@@ -7103,7 +7103,7 @@ var require_resolveCommand = __commonJS({
|
|
|
7103
7103
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
7104
7104
|
"use strict";
|
|
7105
7105
|
init_esm_shims();
|
|
7106
|
-
var
|
|
7106
|
+
var path46 = __require("path");
|
|
7107
7107
|
var which = require_which();
|
|
7108
7108
|
var getPathKey = require_path_key();
|
|
7109
7109
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -7121,7 +7121,7 @@ var require_resolveCommand = __commonJS({
|
|
|
7121
7121
|
try {
|
|
7122
7122
|
resolved = which.sync(parsed.command, {
|
|
7123
7123
|
path: env2[getPathKey({ env: env2 })],
|
|
7124
|
-
pathExt: withoutPathExt ?
|
|
7124
|
+
pathExt: withoutPathExt ? path46.delimiter : void 0
|
|
7125
7125
|
});
|
|
7126
7126
|
} catch (e) {
|
|
7127
7127
|
} finally {
|
|
@@ -7130,7 +7130,7 @@ var require_resolveCommand = __commonJS({
|
|
|
7130
7130
|
}
|
|
7131
7131
|
}
|
|
7132
7132
|
if (resolved) {
|
|
7133
|
-
resolved =
|
|
7133
|
+
resolved = path46.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
7134
7134
|
}
|
|
7135
7135
|
return resolved;
|
|
7136
7136
|
}
|
|
@@ -7187,8 +7187,8 @@ var require_shebang_command = __commonJS({
|
|
|
7187
7187
|
if (!match) {
|
|
7188
7188
|
return null;
|
|
7189
7189
|
}
|
|
7190
|
-
const [
|
|
7191
|
-
const binary =
|
|
7190
|
+
const [path46, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
7191
|
+
const binary = path46.split("/").pop();
|
|
7192
7192
|
if (binary === "env") {
|
|
7193
7193
|
return argument;
|
|
7194
7194
|
}
|
|
@@ -7202,16 +7202,16 @@ var require_readShebang = __commonJS({
|
|
|
7202
7202
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
7203
7203
|
"use strict";
|
|
7204
7204
|
init_esm_shims();
|
|
7205
|
-
var
|
|
7205
|
+
var fs39 = __require("fs");
|
|
7206
7206
|
var shebangCommand = require_shebang_command();
|
|
7207
7207
|
function readShebang(command) {
|
|
7208
7208
|
const size = 150;
|
|
7209
7209
|
const buffer = Buffer.alloc(size);
|
|
7210
7210
|
let fd2;
|
|
7211
7211
|
try {
|
|
7212
|
-
fd2 =
|
|
7213
|
-
|
|
7214
|
-
|
|
7212
|
+
fd2 = fs39.openSync(command, "r");
|
|
7213
|
+
fs39.readSync(fd2, buffer, 0, size, 0);
|
|
7214
|
+
fs39.closeSync(fd2);
|
|
7215
7215
|
} catch (e) {
|
|
7216
7216
|
}
|
|
7217
7217
|
return shebangCommand(buffer.toString());
|
|
@@ -7225,7 +7225,7 @@ var require_parse = __commonJS({
|
|
|
7225
7225
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
7226
7226
|
"use strict";
|
|
7227
7227
|
init_esm_shims();
|
|
7228
|
-
var
|
|
7228
|
+
var path46 = __require("path");
|
|
7229
7229
|
var resolveCommand = require_resolveCommand();
|
|
7230
7230
|
var escape4 = require_escape();
|
|
7231
7231
|
var readShebang = require_readShebang();
|
|
@@ -7250,7 +7250,7 @@ var require_parse = __commonJS({
|
|
|
7250
7250
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
7251
7251
|
if (parsed.options.forceShell || needsShell) {
|
|
7252
7252
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
7253
|
-
parsed.command =
|
|
7253
|
+
parsed.command = path46.normalize(parsed.command);
|
|
7254
7254
|
parsed.command = escape4.command(parsed.command);
|
|
7255
7255
|
parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
|
|
7256
7256
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -17765,10 +17765,10 @@ var require_react_reconciler_development = __commonJS({
|
|
|
17765
17765
|
fiber = fiber.next, id2--;
|
|
17766
17766
|
return fiber;
|
|
17767
17767
|
}
|
|
17768
|
-
function copyWithSetImpl(obj,
|
|
17769
|
-
if (index >=
|
|
17770
|
-
var key =
|
|
17771
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
17768
|
+
function copyWithSetImpl(obj, path46, index, value) {
|
|
17769
|
+
if (index >= path46.length) return value;
|
|
17770
|
+
var key = path46[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
|
|
17771
|
+
updated[key] = copyWithSetImpl(obj[key], path46, index + 1, value);
|
|
17772
17772
|
return updated;
|
|
17773
17773
|
}
|
|
17774
17774
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -17795,11 +17795,11 @@ var require_react_reconciler_development = __commonJS({
|
|
|
17795
17795
|
);
|
|
17796
17796
|
return updated;
|
|
17797
17797
|
}
|
|
17798
|
-
function copyWithDeleteImpl(obj,
|
|
17799
|
-
var key =
|
|
17800
|
-
if (index + 1 ===
|
|
17798
|
+
function copyWithDeleteImpl(obj, path46, index) {
|
|
17799
|
+
var key = path46[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
|
|
17800
|
+
if (index + 1 === path46.length)
|
|
17801
17801
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
17802
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
17802
|
+
updated[key] = copyWithDeleteImpl(obj[key], path46, index + 1);
|
|
17803
17803
|
return updated;
|
|
17804
17804
|
}
|
|
17805
17805
|
function shouldSuspendImpl() {
|
|
@@ -31076,29 +31076,29 @@ var require_react_reconciler_development = __commonJS({
|
|
|
31076
31076
|
var didWarnAboutNestedUpdates = false;
|
|
31077
31077
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
31078
31078
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, scheduleRetry = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
31079
|
-
overrideHookState = function(fiber, id2,
|
|
31079
|
+
overrideHookState = function(fiber, id2, path46, value) {
|
|
31080
31080
|
id2 = findHook(fiber, id2);
|
|
31081
|
-
null !== id2 && (
|
|
31081
|
+
null !== id2 && (path46 = copyWithSetImpl(id2.memoizedState, path46, 0, value), id2.memoizedState = path46, id2.baseState = path46, fiber.memoizedProps = assign({}, fiber.memoizedProps), path46 = enqueueConcurrentRenderForLane(fiber, 2), null !== path46 && scheduleUpdateOnFiber(path46, fiber, 2));
|
|
31082
31082
|
};
|
|
31083
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
31083
|
+
overrideHookStateDeletePath = function(fiber, id2, path46) {
|
|
31084
31084
|
id2 = findHook(fiber, id2);
|
|
31085
|
-
null !== id2 && (
|
|
31085
|
+
null !== id2 && (path46 = copyWithDeleteImpl(id2.memoizedState, path46, 0), id2.memoizedState = path46, id2.baseState = path46, fiber.memoizedProps = assign({}, fiber.memoizedProps), path46 = enqueueConcurrentRenderForLane(fiber, 2), null !== path46 && scheduleUpdateOnFiber(path46, fiber, 2));
|
|
31086
31086
|
};
|
|
31087
31087
|
overrideHookStateRenamePath = function(fiber, id2, oldPath, newPath) {
|
|
31088
31088
|
id2 = findHook(fiber, id2);
|
|
31089
31089
|
null !== id2 && (oldPath = copyWithRename(id2.memoizedState, oldPath, newPath), id2.memoizedState = oldPath, id2.baseState = oldPath, fiber.memoizedProps = assign({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), null !== oldPath && scheduleUpdateOnFiber(oldPath, fiber, 2));
|
|
31090
31090
|
};
|
|
31091
|
-
overrideProps = function(fiber,
|
|
31092
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
31091
|
+
overrideProps = function(fiber, path46, value) {
|
|
31092
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path46, 0, value);
|
|
31093
31093
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
31094
|
-
|
|
31095
|
-
null !==
|
|
31094
|
+
path46 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
31095
|
+
null !== path46 && scheduleUpdateOnFiber(path46, fiber, 2);
|
|
31096
31096
|
};
|
|
31097
|
-
overridePropsDeletePath = function(fiber,
|
|
31098
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
31097
|
+
overridePropsDeletePath = function(fiber, path46) {
|
|
31098
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path46, 0);
|
|
31099
31099
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
31100
|
-
|
|
31101
|
-
null !==
|
|
31100
|
+
path46 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
31101
|
+
null !== path46 && scheduleUpdateOnFiber(path46, fiber, 2);
|
|
31102
31102
|
};
|
|
31103
31103
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
31104
31104
|
fiber.pendingProps = copyWithRename(
|
|
@@ -34333,15 +34333,15 @@ function redactSensitive(body) {
|
|
|
34333
34333
|
}
|
|
34334
34334
|
return null;
|
|
34335
34335
|
}
|
|
34336
|
-
async function checkCredentialsFileSafety(
|
|
34336
|
+
async function checkCredentialsFileSafety(path46, onWarn = (m) => console.warn(`anthropic-sdk: ${m}`)) {
|
|
34337
34337
|
if (typeof process === "undefined" || process.platform === "win32")
|
|
34338
34338
|
return;
|
|
34339
|
-
const
|
|
34340
|
-
let resolved =
|
|
34339
|
+
const fs39 = await import("fs");
|
|
34340
|
+
let resolved = path46;
|
|
34341
34341
|
let st;
|
|
34342
34342
|
try {
|
|
34343
|
-
resolved = await
|
|
34344
|
-
st = await
|
|
34343
|
+
resolved = await fs39.promises.realpath(path46);
|
|
34344
|
+
st = await fs39.promises.stat(resolved);
|
|
34345
34345
|
} catch {
|
|
34346
34346
|
return;
|
|
34347
34347
|
}
|
|
@@ -34357,27 +34357,27 @@ async function checkCredentialsFileSafety(path45, onWarn = (m) => console.warn(`
|
|
|
34357
34357
|
}
|
|
34358
34358
|
}
|
|
34359
34359
|
async function writeCredentialsFileAtomic(targetPath, data) {
|
|
34360
|
-
const
|
|
34361
|
-
const
|
|
34362
|
-
const dir =
|
|
34363
|
-
await
|
|
34360
|
+
const fs39 = await import("fs");
|
|
34361
|
+
const path46 = await import("path");
|
|
34362
|
+
const dir = path46.dirname(targetPath);
|
|
34363
|
+
await fs39.promises.mkdir(dir, { recursive: true, mode: 448 });
|
|
34364
34364
|
const tmpPath = `${targetPath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
34365
34365
|
try {
|
|
34366
|
-
const fh = await
|
|
34366
|
+
const fh = await fs39.promises.open(tmpPath, "w", 384);
|
|
34367
34367
|
try {
|
|
34368
34368
|
await fh.writeFile(JSON.stringify(data, null, 2));
|
|
34369
34369
|
await fh.sync();
|
|
34370
34370
|
} finally {
|
|
34371
34371
|
await fh.close();
|
|
34372
34372
|
}
|
|
34373
|
-
await
|
|
34373
|
+
await fs39.promises.rename(tmpPath, targetPath);
|
|
34374
34374
|
} catch (err) {
|
|
34375
|
-
await
|
|
34375
|
+
await fs39.promises.unlink(tmpPath).catch(() => {
|
|
34376
34376
|
});
|
|
34377
34377
|
throw err;
|
|
34378
34378
|
}
|
|
34379
34379
|
try {
|
|
34380
|
-
const dirFh = await
|
|
34380
|
+
const dirFh = await fs39.promises.open(dir, "r");
|
|
34381
34381
|
try {
|
|
34382
34382
|
await dirFh.sync();
|
|
34383
34383
|
} finally {
|
|
@@ -34679,12 +34679,12 @@ var loadConfigWithSource = async (profile) => {
|
|
|
34679
34679
|
return null;
|
|
34680
34680
|
}
|
|
34681
34681
|
validateProfileName(profileName);
|
|
34682
|
-
const
|
|
34683
|
-
const
|
|
34684
|
-
const configPath =
|
|
34682
|
+
const fs39 = await import("fs");
|
|
34683
|
+
const path46 = await import("path");
|
|
34684
|
+
const configPath = path46.join(rootConfigPath, "configs", `${profileName}.json`);
|
|
34685
34685
|
let configRaw;
|
|
34686
34686
|
try {
|
|
34687
|
-
configRaw = await
|
|
34687
|
+
configRaw = await fs39.promises.readFile(configPath, "utf-8");
|
|
34688
34688
|
} catch (err) {
|
|
34689
34689
|
if (err?.code !== "ENOENT") {
|
|
34690
34690
|
throw new Error(`failed to read config file ${configPath}: ${err}`);
|
|
@@ -34765,37 +34765,37 @@ var getCredentialsPath = async (config2, profile) => {
|
|
|
34765
34765
|
return null;
|
|
34766
34766
|
}
|
|
34767
34767
|
validateProfileName(profileName);
|
|
34768
|
-
const
|
|
34769
|
-
return
|
|
34768
|
+
const path46 = await import("path");
|
|
34769
|
+
return path46.join(rootConfigPath, "credentials", `${profileName}.json`);
|
|
34770
34770
|
};
|
|
34771
34771
|
var getRootConfigPath = async () => {
|
|
34772
34772
|
if (!supportsLocalConfigFiles()) {
|
|
34773
34773
|
return null;
|
|
34774
34774
|
}
|
|
34775
|
-
const
|
|
34775
|
+
const path46 = await import("path");
|
|
34776
34776
|
const configDir = readEnv("ANTHROPIC_CONFIG_DIR");
|
|
34777
34777
|
if (configDir) {
|
|
34778
34778
|
return configDir;
|
|
34779
34779
|
}
|
|
34780
|
-
const
|
|
34781
|
-
if (
|
|
34780
|
+
const os13 = getPlatformHeaders()["X-Stainless-OS"];
|
|
34781
|
+
if (os13 === "Windows") {
|
|
34782
34782
|
const appData = readEnv("APPDATA");
|
|
34783
34783
|
if (appData) {
|
|
34784
|
-
return
|
|
34784
|
+
return path46.join(appData, "Anthropic");
|
|
34785
34785
|
}
|
|
34786
34786
|
const userProfile = readEnv("USERPROFILE");
|
|
34787
34787
|
if (userProfile) {
|
|
34788
|
-
return
|
|
34788
|
+
return path46.join(userProfile, "AppData", "Roaming", "Anthropic");
|
|
34789
34789
|
}
|
|
34790
34790
|
return null;
|
|
34791
34791
|
}
|
|
34792
34792
|
const xdgConfigHome = readEnv("XDG_CONFIG_HOME");
|
|
34793
34793
|
if (xdgConfigHome) {
|
|
34794
|
-
return
|
|
34794
|
+
return path46.join(xdgConfigHome, "anthropic");
|
|
34795
34795
|
}
|
|
34796
34796
|
const home = readEnv("HOME");
|
|
34797
34797
|
if (home) {
|
|
34798
|
-
return
|
|
34798
|
+
return path46.join(home, ".config", "anthropic");
|
|
34799
34799
|
}
|
|
34800
34800
|
return null;
|
|
34801
34801
|
};
|
|
@@ -34812,11 +34812,11 @@ var getActiveProfileName = async () => {
|
|
|
34812
34812
|
if (profileName) {
|
|
34813
34813
|
return profileName;
|
|
34814
34814
|
}
|
|
34815
|
-
const
|
|
34816
|
-
const
|
|
34817
|
-
const filePath =
|
|
34815
|
+
const fs39 = await import("fs");
|
|
34816
|
+
const path46 = await import("path");
|
|
34817
|
+
const filePath = path46.join(rootConfigPath, "active_config");
|
|
34818
34818
|
try {
|
|
34819
|
-
return (await
|
|
34819
|
+
return (await fs39.promises.readFile(filePath, "utf-8")).trim() || "default";
|
|
34820
34820
|
} catch (err) {
|
|
34821
34821
|
if (err?.code !== "ENOENT") {
|
|
34822
34822
|
throw new Error(`failed to read ${filePath}: ${err}`);
|
|
@@ -34827,21 +34827,21 @@ var getActiveProfileName = async () => {
|
|
|
34827
34827
|
|
|
34828
34828
|
// ../../node_modules/.pnpm/@anthropic-ai+sdk@0.94.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs
|
|
34829
34829
|
init_esm_shims();
|
|
34830
|
-
function identityTokenFromFile(
|
|
34831
|
-
if (!
|
|
34830
|
+
function identityTokenFromFile(path46) {
|
|
34831
|
+
if (!path46) {
|
|
34832
34832
|
throw new AnthropicError("Identity token file path is empty");
|
|
34833
34833
|
}
|
|
34834
34834
|
return async () => {
|
|
34835
|
-
const
|
|
34835
|
+
const fs39 = await import("fs");
|
|
34836
34836
|
let content;
|
|
34837
34837
|
try {
|
|
34838
|
-
content = await
|
|
34838
|
+
content = await fs39.promises.readFile(path46, "utf-8");
|
|
34839
34839
|
} catch (err) {
|
|
34840
|
-
throw new AnthropicError(`Failed to read identity token file at ${
|
|
34840
|
+
throw new AnthropicError(`Failed to read identity token file at ${path46}: ${err}`);
|
|
34841
34841
|
}
|
|
34842
34842
|
const token = content.trim();
|
|
34843
34843
|
if (!token) {
|
|
34844
|
-
throw new AnthropicError(`Identity token file at ${
|
|
34844
|
+
throw new AnthropicError(`Identity token file at ${path46} is empty`);
|
|
34845
34845
|
}
|
|
34846
34846
|
return token;
|
|
34847
34847
|
};
|
|
@@ -34916,11 +34916,11 @@ function oidcFederationProvider(config2) {
|
|
|
34916
34916
|
init_esm_shims();
|
|
34917
34917
|
function userOAuthProvider(config2) {
|
|
34918
34918
|
return async (opts) => {
|
|
34919
|
-
const
|
|
34919
|
+
const fs39 = await import("fs");
|
|
34920
34920
|
await checkCredentialsFileSafety(config2.credentialsPath, config2.onSafetyWarning);
|
|
34921
34921
|
let raw;
|
|
34922
34922
|
try {
|
|
34923
|
-
raw = await
|
|
34923
|
+
raw = await fs39.promises.readFile(config2.credentialsPath, "utf-8");
|
|
34924
34924
|
} catch (err) {
|
|
34925
34925
|
throw new WorkloadIdentityError(`Credentials file not found at ${config2.credentialsPath}: ${err}`);
|
|
34926
34926
|
}
|
|
@@ -35084,11 +35084,11 @@ function resolveIdentityTokenProvider(auth2) {
|
|
|
35084
35084
|
}
|
|
35085
35085
|
function cachedExchangeProvider(exchange, credentialsPath, onCacheWriteError, onSafetyWarning) {
|
|
35086
35086
|
return async (opts) => {
|
|
35087
|
-
const
|
|
35087
|
+
const fs39 = await import("fs");
|
|
35088
35088
|
await checkCredentialsFileSafety(credentialsPath, onSafetyWarning);
|
|
35089
35089
|
let existing;
|
|
35090
35090
|
try {
|
|
35091
|
-
const raw = await
|
|
35091
|
+
const raw = await fs39.promises.readFile(credentialsPath, "utf-8");
|
|
35092
35092
|
existing = JSON.parse(raw);
|
|
35093
35093
|
const token = existing?.["access_token"];
|
|
35094
35094
|
if (token && !opts?.forceRefresh) {
|
|
@@ -35927,12 +35927,12 @@ function encodeURIPath(str2) {
|
|
|
35927
35927
|
return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
35928
35928
|
}
|
|
35929
35929
|
var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
35930
|
-
var createPathTagFunction = (pathEncoder = encodeURIPath) => function
|
|
35930
|
+
var createPathTagFunction = (pathEncoder = encodeURIPath) => function path46(statics, ...params) {
|
|
35931
35931
|
if (statics.length === 1)
|
|
35932
35932
|
return statics[0];
|
|
35933
35933
|
let postPath = false;
|
|
35934
35934
|
const invalidSegments = [];
|
|
35935
|
-
const
|
|
35935
|
+
const path47 = statics.reduce((previousValue, currentValue, index) => {
|
|
35936
35936
|
if (/[?#]/.test(currentValue)) {
|
|
35937
35937
|
postPath = true;
|
|
35938
35938
|
}
|
|
@@ -35949,7 +35949,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path45(sta
|
|
|
35949
35949
|
}
|
|
35950
35950
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
35951
35951
|
}, "");
|
|
35952
|
-
const pathOnly =
|
|
35952
|
+
const pathOnly = path47.split(/[?#]/, 1)[0];
|
|
35953
35953
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
35954
35954
|
let match;
|
|
35955
35955
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -35970,10 +35970,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path45(sta
|
|
|
35970
35970
|
}, "");
|
|
35971
35971
|
throw new AnthropicError(`Path parameters result in path with invalid segments:
|
|
35972
35972
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
35973
|
-
${
|
|
35973
|
+
${path47}
|
|
35974
35974
|
${underline}`);
|
|
35975
35975
|
}
|
|
35976
|
-
return
|
|
35976
|
+
return path47;
|
|
35977
35977
|
};
|
|
35978
35978
|
var path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
35979
35979
|
|
|
@@ -40734,9 +40734,9 @@ var BaseAnthropic = class {
|
|
|
40734
40734
|
makeStatusError(status, error51, message, headers) {
|
|
40735
40735
|
return APIError.generate(status, error51, message, headers);
|
|
40736
40736
|
}
|
|
40737
|
-
buildURL(
|
|
40737
|
+
buildURL(path46, query, defaultBaseURL) {
|
|
40738
40738
|
const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
40739
|
-
const url2 = isAbsoluteURL(
|
|
40739
|
+
const url2 = isAbsoluteURL(path46) ? new URL(path46) : new URL(baseURL + (baseURL.endsWith("/") && path46.startsWith("/") ? path46.slice(1) : path46));
|
|
40740
40740
|
const defaultQuery = this.defaultQuery();
|
|
40741
40741
|
const pathQuery = Object.fromEntries(url2.searchParams);
|
|
40742
40742
|
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
@@ -40780,24 +40780,24 @@ var BaseAnthropic = class {
|
|
|
40780
40780
|
request.headers = headers;
|
|
40781
40781
|
}
|
|
40782
40782
|
}
|
|
40783
|
-
get(
|
|
40784
|
-
return this.methodRequest("get",
|
|
40783
|
+
get(path46, opts) {
|
|
40784
|
+
return this.methodRequest("get", path46, opts);
|
|
40785
40785
|
}
|
|
40786
|
-
post(
|
|
40787
|
-
return this.methodRequest("post",
|
|
40786
|
+
post(path46, opts) {
|
|
40787
|
+
return this.methodRequest("post", path46, opts);
|
|
40788
40788
|
}
|
|
40789
|
-
patch(
|
|
40790
|
-
return this.methodRequest("patch",
|
|
40789
|
+
patch(path46, opts) {
|
|
40790
|
+
return this.methodRequest("patch", path46, opts);
|
|
40791
40791
|
}
|
|
40792
|
-
put(
|
|
40793
|
-
return this.methodRequest("put",
|
|
40792
|
+
put(path46, opts) {
|
|
40793
|
+
return this.methodRequest("put", path46, opts);
|
|
40794
40794
|
}
|
|
40795
|
-
delete(
|
|
40796
|
-
return this.methodRequest("delete",
|
|
40795
|
+
delete(path46, opts) {
|
|
40796
|
+
return this.methodRequest("delete", path46, opts);
|
|
40797
40797
|
}
|
|
40798
|
-
methodRequest(method,
|
|
40798
|
+
methodRequest(method, path46, opts) {
|
|
40799
40799
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
40800
|
-
return { method, path:
|
|
40800
|
+
return { method, path: path46, ...opts2 };
|
|
40801
40801
|
}));
|
|
40802
40802
|
}
|
|
40803
40803
|
request(options, remainingRetries = null) {
|
|
@@ -40902,8 +40902,8 @@ var BaseAnthropic = class {
|
|
|
40902
40902
|
}));
|
|
40903
40903
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
40904
40904
|
}
|
|
40905
|
-
getAPIList(
|
|
40906
|
-
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
40905
|
+
getAPIList(path46, Page3, opts) {
|
|
40906
|
+
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path46, ...opts2 })) : { method: "get", path: path46, ...opts });
|
|
40907
40907
|
}
|
|
40908
40908
|
requestAPIList(Page3, options) {
|
|
40909
40909
|
const request = this.makeRequest(options, null, void 0);
|
|
@@ -40997,14 +40997,14 @@ var BaseAnthropic = class {
|
|
|
40997
40997
|
}
|
|
40998
40998
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
40999
40999
|
const options = { ...inputOptions };
|
|
41000
|
-
const { method, path:
|
|
41000
|
+
const { method, path: path46, query, defaultBaseURL } = options;
|
|
41001
41001
|
if (this._authState.resolution) {
|
|
41002
41002
|
await this._authState.resolution;
|
|
41003
41003
|
}
|
|
41004
41004
|
if (!this._baseURLIsExplicit && this._authState.baseURL && this.baseURL !== this._authState.baseURL) {
|
|
41005
41005
|
this.baseURL = this._authState.baseURL;
|
|
41006
41006
|
}
|
|
41007
|
-
const url2 = this.buildURL(
|
|
41007
|
+
const url2 = this.buildURL(path46, query, defaultBaseURL);
|
|
41008
41008
|
if ("timeout" in options)
|
|
41009
41009
|
validatePositiveInteger("timeout", options.timeout);
|
|
41010
41010
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -41891,10 +41891,10 @@ function mergeDefs(...defs) {
|
|
|
41891
41891
|
function cloneDef(schema) {
|
|
41892
41892
|
return mergeDefs(schema._zod.def);
|
|
41893
41893
|
}
|
|
41894
|
-
function getElementAtPath(obj,
|
|
41895
|
-
if (!
|
|
41894
|
+
function getElementAtPath(obj, path46) {
|
|
41895
|
+
if (!path46)
|
|
41896
41896
|
return obj;
|
|
41897
|
-
return
|
|
41897
|
+
return path46.reduce((acc, key) => acc?.[key], obj);
|
|
41898
41898
|
}
|
|
41899
41899
|
function promiseAllObject(promisesObj) {
|
|
41900
41900
|
const keys = Object.keys(promisesObj);
|
|
@@ -42303,11 +42303,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
42303
42303
|
}
|
|
42304
42304
|
return false;
|
|
42305
42305
|
}
|
|
42306
|
-
function prefixIssues(
|
|
42306
|
+
function prefixIssues(path46, issues) {
|
|
42307
42307
|
return issues.map((iss) => {
|
|
42308
42308
|
var _a6;
|
|
42309
42309
|
(_a6 = iss).path ?? (_a6.path = []);
|
|
42310
|
-
iss.path.unshift(
|
|
42310
|
+
iss.path.unshift(path46);
|
|
42311
42311
|
return iss;
|
|
42312
42312
|
});
|
|
42313
42313
|
}
|
|
@@ -42454,16 +42454,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
42454
42454
|
}
|
|
42455
42455
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
42456
42456
|
const fieldErrors = { _errors: [] };
|
|
42457
|
-
const processError = (error52,
|
|
42457
|
+
const processError = (error52, path46 = []) => {
|
|
42458
42458
|
for (const issue2 of error52.issues) {
|
|
42459
42459
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
42460
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
42460
|
+
issue2.errors.map((issues) => processError({ issues }, [...path46, ...issue2.path]));
|
|
42461
42461
|
} else if (issue2.code === "invalid_key") {
|
|
42462
|
-
processError({ issues: issue2.issues }, [...
|
|
42462
|
+
processError({ issues: issue2.issues }, [...path46, ...issue2.path]);
|
|
42463
42463
|
} else if (issue2.code === "invalid_element") {
|
|
42464
|
-
processError({ issues: issue2.issues }, [...
|
|
42464
|
+
processError({ issues: issue2.issues }, [...path46, ...issue2.path]);
|
|
42465
42465
|
} else {
|
|
42466
|
-
const fullpath = [...
|
|
42466
|
+
const fullpath = [...path46, ...issue2.path];
|
|
42467
42467
|
if (fullpath.length === 0) {
|
|
42468
42468
|
fieldErrors._errors.push(mapper(issue2));
|
|
42469
42469
|
} else {
|
|
@@ -42490,17 +42490,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
42490
42490
|
}
|
|
42491
42491
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
42492
42492
|
const result = { errors: [] };
|
|
42493
|
-
const processError = (error52,
|
|
42493
|
+
const processError = (error52, path46 = []) => {
|
|
42494
42494
|
var _a6, _b;
|
|
42495
42495
|
for (const issue2 of error52.issues) {
|
|
42496
42496
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
42497
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
42497
|
+
issue2.errors.map((issues) => processError({ issues }, [...path46, ...issue2.path]));
|
|
42498
42498
|
} else if (issue2.code === "invalid_key") {
|
|
42499
|
-
processError({ issues: issue2.issues }, [...
|
|
42499
|
+
processError({ issues: issue2.issues }, [...path46, ...issue2.path]);
|
|
42500
42500
|
} else if (issue2.code === "invalid_element") {
|
|
42501
|
-
processError({ issues: issue2.issues }, [...
|
|
42501
|
+
processError({ issues: issue2.issues }, [...path46, ...issue2.path]);
|
|
42502
42502
|
} else {
|
|
42503
|
-
const fullpath = [...
|
|
42503
|
+
const fullpath = [...path46, ...issue2.path];
|
|
42504
42504
|
if (fullpath.length === 0) {
|
|
42505
42505
|
result.errors.push(mapper(issue2));
|
|
42506
42506
|
continue;
|
|
@@ -42532,8 +42532,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
42532
42532
|
}
|
|
42533
42533
|
function toDotPath(_path) {
|
|
42534
42534
|
const segs = [];
|
|
42535
|
-
const
|
|
42536
|
-
for (const seg of
|
|
42535
|
+
const path46 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
42536
|
+
for (const seg of path46) {
|
|
42537
42537
|
if (typeof seg === "number")
|
|
42538
42538
|
segs.push(`[${seg}]`);
|
|
42539
42539
|
else if (typeof seg === "symbol")
|
|
@@ -55306,13 +55306,13 @@ function resolveRef(ref, ctx) {
|
|
|
55306
55306
|
if (!ref.startsWith("#")) {
|
|
55307
55307
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
55308
55308
|
}
|
|
55309
|
-
const
|
|
55310
|
-
if (
|
|
55309
|
+
const path46 = ref.slice(1).split("/").filter(Boolean);
|
|
55310
|
+
if (path46.length === 0) {
|
|
55311
55311
|
return ctx.rootSchema;
|
|
55312
55312
|
}
|
|
55313
55313
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
55314
|
-
if (
|
|
55315
|
-
const key =
|
|
55314
|
+
if (path46[0] === defsKey) {
|
|
55315
|
+
const key = path46[1];
|
|
55316
55316
|
if (!key || !ctx.defs[key]) {
|
|
55317
55317
|
throw new Error(`Reference not found: ${ref}`);
|
|
55318
55318
|
}
|
|
@@ -57541,12 +57541,12 @@ function encodeURIPath2(str2) {
|
|
|
57541
57541
|
return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
57542
57542
|
}
|
|
57543
57543
|
var EMPTY2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
57544
|
-
var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function
|
|
57544
|
+
var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path46(statics, ...params) {
|
|
57545
57545
|
if (statics.length === 1)
|
|
57546
57546
|
return statics[0];
|
|
57547
57547
|
let postPath = false;
|
|
57548
57548
|
const invalidSegments = [];
|
|
57549
|
-
const
|
|
57549
|
+
const path47 = statics.reduce((previousValue, currentValue, index) => {
|
|
57550
57550
|
if (/[?#]/.test(currentValue)) {
|
|
57551
57551
|
postPath = true;
|
|
57552
57552
|
}
|
|
@@ -57563,7 +57563,7 @@ var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path45(s
|
|
|
57563
57563
|
}
|
|
57564
57564
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
57565
57565
|
}, "");
|
|
57566
|
-
const pathOnly =
|
|
57566
|
+
const pathOnly = path47.split(/[?#]/, 1)[0];
|
|
57567
57567
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
57568
57568
|
let match;
|
|
57569
57569
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -57584,10 +57584,10 @@ var createPathTagFunction2 = (pathEncoder = encodeURIPath2) => function path45(s
|
|
|
57584
57584
|
}, "");
|
|
57585
57585
|
throw new OpenAIError(`Path parameters result in path with invalid segments:
|
|
57586
57586
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
57587
|
-
${
|
|
57587
|
+
${path47}
|
|
57588
57588
|
${underline}`);
|
|
57589
57589
|
}
|
|
57590
|
-
return
|
|
57590
|
+
return path47;
|
|
57591
57591
|
};
|
|
57592
57592
|
var path2 = /* @__PURE__ */ createPathTagFunction2(encodeURIPath2);
|
|
57593
57593
|
|
|
@@ -62713,9 +62713,9 @@ var OpenAI = class {
|
|
|
62713
62713
|
this.apiKey = token;
|
|
62714
62714
|
return true;
|
|
62715
62715
|
}
|
|
62716
|
-
buildURL(
|
|
62716
|
+
buildURL(path46, query, defaultBaseURL) {
|
|
62717
62717
|
const baseURL = !__classPrivateFieldGet2(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
62718
|
-
const url2 = isAbsoluteURL2(
|
|
62718
|
+
const url2 = isAbsoluteURL2(path46) ? new URL(path46) : new URL(baseURL + (baseURL.endsWith("/") && path46.startsWith("/") ? path46.slice(1) : path46));
|
|
62719
62719
|
const defaultQuery = this.defaultQuery();
|
|
62720
62720
|
const pathQuery = Object.fromEntries(url2.searchParams);
|
|
62721
62721
|
if (!isEmptyObj2(defaultQuery) || !isEmptyObj2(pathQuery)) {
|
|
@@ -62740,24 +62740,24 @@ var OpenAI = class {
|
|
|
62740
62740
|
*/
|
|
62741
62741
|
async prepareRequest(request, { url: url2, options }) {
|
|
62742
62742
|
}
|
|
62743
|
-
get(
|
|
62744
|
-
return this.methodRequest("get",
|
|
62743
|
+
get(path46, opts) {
|
|
62744
|
+
return this.methodRequest("get", path46, opts);
|
|
62745
62745
|
}
|
|
62746
|
-
post(
|
|
62747
|
-
return this.methodRequest("post",
|
|
62746
|
+
post(path46, opts) {
|
|
62747
|
+
return this.methodRequest("post", path46, opts);
|
|
62748
62748
|
}
|
|
62749
|
-
patch(
|
|
62750
|
-
return this.methodRequest("patch",
|
|
62749
|
+
patch(path46, opts) {
|
|
62750
|
+
return this.methodRequest("patch", path46, opts);
|
|
62751
62751
|
}
|
|
62752
|
-
put(
|
|
62753
|
-
return this.methodRequest("put",
|
|
62752
|
+
put(path46, opts) {
|
|
62753
|
+
return this.methodRequest("put", path46, opts);
|
|
62754
62754
|
}
|
|
62755
|
-
delete(
|
|
62756
|
-
return this.methodRequest("delete",
|
|
62755
|
+
delete(path46, opts) {
|
|
62756
|
+
return this.methodRequest("delete", path46, opts);
|
|
62757
62757
|
}
|
|
62758
|
-
methodRequest(method,
|
|
62758
|
+
methodRequest(method, path46, opts) {
|
|
62759
62759
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
62760
|
-
return { method, path:
|
|
62760
|
+
return { method, path: path46, ...opts2 };
|
|
62761
62761
|
}));
|
|
62762
62762
|
}
|
|
62763
62763
|
request(options, remainingRetries = null) {
|
|
@@ -62875,8 +62875,8 @@ var OpenAI = class {
|
|
|
62875
62875
|
}));
|
|
62876
62876
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
62877
62877
|
}
|
|
62878
|
-
getAPIList(
|
|
62879
|
-
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
62878
|
+
getAPIList(path46, Page3, opts) {
|
|
62879
|
+
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path46, ...opts2 })) : { method: "get", path: path46, ...opts });
|
|
62880
62880
|
}
|
|
62881
62881
|
requestAPIList(Page3, options) {
|
|
62882
62882
|
const request = this.makeRequest(options, null, void 0);
|
|
@@ -62967,8 +62967,8 @@ var OpenAI = class {
|
|
|
62967
62967
|
}
|
|
62968
62968
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
62969
62969
|
const options = { ...inputOptions };
|
|
62970
|
-
const { method, path:
|
|
62971
|
-
const url2 = this.buildURL(
|
|
62970
|
+
const { method, path: path46, query, defaultBaseURL } = options;
|
|
62971
|
+
const url2 = this.buildURL(path46, query, defaultBaseURL);
|
|
62972
62972
|
if ("timeout" in options)
|
|
62973
62973
|
validatePositiveInteger2("timeout", options.timeout);
|
|
62974
62974
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -64703,11 +64703,11 @@ async function* runStream2(options) {
|
|
|
64703
64703
|
}
|
|
64704
64704
|
}
|
|
64705
64705
|
if (getEnvironment()?.GGAI_DUMP_REQUEST) {
|
|
64706
|
-
const
|
|
64706
|
+
const fs39 = await import("fs");
|
|
64707
64707
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
64708
64708
|
const dumpPath = `/tmp/ggai-request-${ts}.json`;
|
|
64709
|
-
|
|
64710
|
-
|
|
64709
|
+
fs39.writeFileSync(dumpPath, JSON.stringify(params, null, 2));
|
|
64710
|
+
fs39.appendFileSync(
|
|
64711
64711
|
"/tmp/ggai-requests.log",
|
|
64712
64712
|
`[${ts}] ${dumpPath} messages=${params.messages.length}
|
|
64713
64713
|
`
|
|
@@ -67448,37 +67448,41 @@ var Agent = class {
|
|
|
67448
67448
|
}
|
|
67449
67449
|
};
|
|
67450
67450
|
|
|
67451
|
-
// ../gg-core/dist/chunk-
|
|
67451
|
+
// ../gg-core/dist/chunk-RVK5N64M.js
|
|
67452
67452
|
init_esm_shims();
|
|
67453
67453
|
var MODELS = [
|
|
67454
67454
|
// ── Anthropic ──────────────────────────────────────────
|
|
67455
|
-
|
|
67456
|
-
|
|
67457
|
-
|
|
67458
|
-
|
|
67459
|
-
|
|
67460
|
-
|
|
67461
|
-
|
|
67462
|
-
|
|
67463
|
-
|
|
67464
|
-
|
|
67465
|
-
|
|
67466
|
-
|
|
67467
|
-
|
|
67468
|
-
|
|
67469
|
-
|
|
67470
|
-
|
|
67471
|
-
|
|
67472
|
-
|
|
67473
|
-
|
|
67474
|
-
|
|
67475
|
-
|
|
67476
|
-
|
|
67477
|
-
|
|
67478
|
-
|
|
67479
|
-
|
|
67480
|
-
|
|
67481
|
-
|
|
67455
|
+
// NOTE: Claude Fable 5 (`claude-fable-5`) and Claude Mythos 5
|
|
67456
|
+
// (`claude-mythos-5`) are temporarily unavailable, so they're commented out
|
|
67457
|
+
// here to keep them out of the /model selector and avoid user confusion.
|
|
67458
|
+
// Re-enable once they're generally available again.
|
|
67459
|
+
// {
|
|
67460
|
+
// id: "claude-fable-5",
|
|
67461
|
+
// name: "Claude Fable 5",
|
|
67462
|
+
// provider: "anthropic",
|
|
67463
|
+
// contextWindow: 1_000_000,
|
|
67464
|
+
// maxOutputTokens: 128_000,
|
|
67465
|
+
// supportsThinking: true,
|
|
67466
|
+
// supportsImages: true,
|
|
67467
|
+
// supportsVideo: false,
|
|
67468
|
+
// costTier: "high",
|
|
67469
|
+
// maxThinkingLevel: "max",
|
|
67470
|
+
// },
|
|
67471
|
+
// {
|
|
67472
|
+
// // Mythos-class model offered through Project Glasswing (limited
|
|
67473
|
+
// // availability, invitation-only). Same underlying model as Fable 5 with
|
|
67474
|
+
// // some safeguards lifted; kept here so approved accounts can select it.
|
|
67475
|
+
// id: "claude-mythos-5",
|
|
67476
|
+
// name: "Claude Mythos 5",
|
|
67477
|
+
// provider: "anthropic",
|
|
67478
|
+
// contextWindow: 1_000_000,
|
|
67479
|
+
// maxOutputTokens: 128_000,
|
|
67480
|
+
// supportsThinking: true,
|
|
67481
|
+
// supportsImages: true,
|
|
67482
|
+
// supportsVideo: false,
|
|
67483
|
+
// costTier: "high",
|
|
67484
|
+
// maxThinkingLevel: "max",
|
|
67485
|
+
// },
|
|
67482
67486
|
{
|
|
67483
67487
|
id: "claude-opus-4-8",
|
|
67484
67488
|
name: "Claude Opus 4.8",
|
|
@@ -67608,6 +67612,20 @@ var MODELS = [
|
|
|
67608
67612
|
maxThinkingLevel: "high"
|
|
67609
67613
|
},
|
|
67610
67614
|
// ── Z.AI (GLM) ─────────────────────────────────────────
|
|
67615
|
+
// GLM-5.2: coding-first flagship with a usable 1M-token context window
|
|
67616
|
+
// (5x jump over GLM-5.1's ~200K) and 131K max output. Released 2026-06-13.
|
|
67617
|
+
{
|
|
67618
|
+
id: "glm-5.2",
|
|
67619
|
+
name: "GLM-5.2",
|
|
67620
|
+
provider: "glm",
|
|
67621
|
+
contextWindow: 1e6,
|
|
67622
|
+
maxOutputTokens: 131072,
|
|
67623
|
+
supportsThinking: true,
|
|
67624
|
+
supportsImages: false,
|
|
67625
|
+
supportsVideo: false,
|
|
67626
|
+
costTier: "medium",
|
|
67627
|
+
maxThinkingLevel: "high"
|
|
67628
|
+
},
|
|
67611
67629
|
{
|
|
67612
67630
|
id: "glm-5.1",
|
|
67613
67631
|
name: "GLM-5.1",
|
|
@@ -67745,7 +67763,7 @@ function getDefaultModel(provider) {
|
|
|
67745
67763
|
if (provider === "xiaomi") return MODELS.find((m) => m.id === "mimo-v2.5-pro");
|
|
67746
67764
|
if (provider === "openai") return MODELS.find((m) => m.id === "gpt-5.5");
|
|
67747
67765
|
if (provider === "gemini") return MODELS.find((m) => m.id === "gemini-3.1-flash-lite-preview");
|
|
67748
|
-
if (provider === "glm") return MODELS.find((m) => m.id === "glm-5.
|
|
67766
|
+
if (provider === "glm") return MODELS.find((m) => m.id === "glm-5.2");
|
|
67749
67767
|
if (provider === "moonshot") return MODELS.find((m) => m.id === "kimi-k2.7-code");
|
|
67750
67768
|
if (provider === "minimax") return MODELS.find((m) => m.id === "MiniMax-M3");
|
|
67751
67769
|
if (provider === "deepseek") return MODELS.find((m) => m.id === "deepseek-v4-pro");
|
|
@@ -68246,12 +68264,12 @@ function macOsProductVersion() {
|
|
|
68246
68264
|
}
|
|
68247
68265
|
}
|
|
68248
68266
|
function deviceModel() {
|
|
68249
|
-
const
|
|
68267
|
+
const os13 = type();
|
|
68250
68268
|
const version2 = release();
|
|
68251
68269
|
const osArch = arch();
|
|
68252
|
-
if (
|
|
68253
|
-
if (
|
|
68254
|
-
return `${
|
|
68270
|
+
if (os13 === "Darwin") return `macOS ${macOsProductVersion() ?? version2} ${osArch}`;
|
|
68271
|
+
if (os13 === "Windows_NT") return `Windows ${version2} ${osArch}`;
|
|
68272
|
+
return `${os13} ${version2} ${osArch}`.trim();
|
|
68255
68273
|
}
|
|
68256
68274
|
function deviceId() {
|
|
68257
68275
|
const idPath = path32.join(getAppPaths().agentDir, "kimi_device_id");
|
|
@@ -70084,18 +70102,18 @@ import fs10 from "fs/promises";
|
|
|
70084
70102
|
import { spawn as spawn4 } from "child_process";
|
|
70085
70103
|
import { createReadStream } from "fs";
|
|
70086
70104
|
var localOperations = {
|
|
70087
|
-
readFile: (
|
|
70088
|
-
writeFile: async (
|
|
70105
|
+
readFile: (path46) => fs10.readFile(path46, "utf-8"),
|
|
70106
|
+
writeFile: async (path46, content) => {
|
|
70089
70107
|
const { dirname: dirname3 } = await import("path");
|
|
70090
|
-
await fs10.mkdir(dirname3(
|
|
70091
|
-
await fs10.writeFile(
|
|
70108
|
+
await fs10.mkdir(dirname3(path46), { recursive: true });
|
|
70109
|
+
await fs10.writeFile(path46, content, "utf-8");
|
|
70092
70110
|
},
|
|
70093
|
-
stat: (
|
|
70094
|
-
lstat: (
|
|
70095
|
-
readdir: (
|
|
70096
|
-
mkdir: (
|
|
70111
|
+
stat: (path46) => fs10.stat(path46),
|
|
70112
|
+
lstat: (path46) => fs10.lstat(path46),
|
|
70113
|
+
readdir: (path46, options) => fs10.readdir(path46, options),
|
|
70114
|
+
mkdir: (path46) => fs10.mkdir(path46, { recursive: true }).then(() => {
|
|
70097
70115
|
}),
|
|
70098
|
-
createReadStream: (
|
|
70116
|
+
createReadStream: (path46, encoding) => createReadStream(path46, { encoding }),
|
|
70099
70117
|
spawn: (command, args, options) => spawn4(command, args, {
|
|
70100
70118
|
cwd: options.cwd,
|
|
70101
70119
|
env: options.env,
|
|
@@ -70857,16 +70875,16 @@ var Diff = class {
|
|
|
70857
70875
|
}
|
|
70858
70876
|
}
|
|
70859
70877
|
}
|
|
70860
|
-
addToPath(
|
|
70861
|
-
const last =
|
|
70878
|
+
addToPath(path46, added, removed, oldPosInc, options) {
|
|
70879
|
+
const last = path46.lastComponent;
|
|
70862
70880
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
70863
70881
|
return {
|
|
70864
|
-
oldPos:
|
|
70882
|
+
oldPos: path46.oldPos + oldPosInc,
|
|
70865
70883
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
70866
70884
|
};
|
|
70867
70885
|
} else {
|
|
70868
70886
|
return {
|
|
70869
|
-
oldPos:
|
|
70887
|
+
oldPos: path46.oldPos + oldPosInc,
|
|
70870
70888
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
70871
70889
|
};
|
|
70872
70890
|
}
|
|
@@ -75191,7 +75209,8 @@ var EventBus = class {
|
|
|
75191
75209
|
toolCallId: event.toolCallId,
|
|
75192
75210
|
result: event.result,
|
|
75193
75211
|
isError: event.isError,
|
|
75194
|
-
durationMs: event.durationMs
|
|
75212
|
+
durationMs: event.durationMs,
|
|
75213
|
+
details: event.details
|
|
75195
75214
|
});
|
|
75196
75215
|
break;
|
|
75197
75216
|
case "turn_end":
|
|
@@ -83450,6 +83469,193 @@ var BUNDLED_AGENTS = [
|
|
|
83450
83469
|
}
|
|
83451
83470
|
];
|
|
83452
83471
|
|
|
83472
|
+
// ../ggcoder/dist/utils/session-title.js
|
|
83473
|
+
init_esm_shims();
|
|
83474
|
+
var TITLE_PROMPT = `Generate an extremely short title (3-7 words) summarizing what the user is asking for. Just the title, nothing else. No quotes, no punctuation at the end.`;
|
|
83475
|
+
async function generateSessionTitle(opts) {
|
|
83476
|
+
let apiKey = opts.apiKey;
|
|
83477
|
+
let accountId = opts.accountId;
|
|
83478
|
+
if (opts.resolveCredentials) {
|
|
83479
|
+
const creds = await opts.resolveCredentials();
|
|
83480
|
+
apiKey = creds.apiKey;
|
|
83481
|
+
accountId = creds.accountId;
|
|
83482
|
+
}
|
|
83483
|
+
const model = opts.provider === "anthropic" ? "claude-haiku-4-5-20251001" : opts.provider === "openai" ? "gpt-5.1-codex-mini" : opts.provider === "glm" ? "glm-4.7-flash" : opts.provider === "moonshot" ? "kimi-k2.7-code" : "claude-haiku-4-5-20251001";
|
|
83484
|
+
const messages = [
|
|
83485
|
+
{ role: "system", content: TITLE_PROMPT },
|
|
83486
|
+
{
|
|
83487
|
+
role: "user",
|
|
83488
|
+
content: `User asked: "${truncate2(opts.userMessage, 300)}"
|
|
83489
|
+
|
|
83490
|
+
Assistant began: "${truncate2(opts.assistantPreview, 200)}"`
|
|
83491
|
+
}
|
|
83492
|
+
];
|
|
83493
|
+
try {
|
|
83494
|
+
const result = stream({
|
|
83495
|
+
provider: opts.provider,
|
|
83496
|
+
model,
|
|
83497
|
+
messages,
|
|
83498
|
+
maxTokens: 30,
|
|
83499
|
+
temperature: 0,
|
|
83500
|
+
apiKey,
|
|
83501
|
+
baseUrl: opts.baseUrl,
|
|
83502
|
+
accountId
|
|
83503
|
+
});
|
|
83504
|
+
result.response.catch(() => {
|
|
83505
|
+
});
|
|
83506
|
+
const response = await result;
|
|
83507
|
+
const msg = response.message;
|
|
83508
|
+
const text = typeof msg.content === "string" ? msg.content : msg.content.filter((c2) => c2.type === "text").map((c2) => c2.text).join("");
|
|
83509
|
+
return text.trim().replace(/[."]+$/, "") || "New conversation";
|
|
83510
|
+
} catch {
|
|
83511
|
+
return fallbackTitle(opts.userMessage);
|
|
83512
|
+
}
|
|
83513
|
+
}
|
|
83514
|
+
function truncate2(s, max) {
|
|
83515
|
+
if (s.length <= max)
|
|
83516
|
+
return s;
|
|
83517
|
+
return s.slice(0, max) + "\u2026";
|
|
83518
|
+
}
|
|
83519
|
+
function fallbackTitle(userMessage) {
|
|
83520
|
+
if (!userMessage)
|
|
83521
|
+
return "New conversation";
|
|
83522
|
+
const cleaned = userMessage.replace(/^\/\S+\s*/, "").replace(/\s+/g, " ").trim();
|
|
83523
|
+
const first = cleaned.split(/[.\n]/)[0]?.trim() ?? cleaned;
|
|
83524
|
+
if (first.length <= 50)
|
|
83525
|
+
return first;
|
|
83526
|
+
const t = first.slice(0, 50);
|
|
83527
|
+
const sp = t.lastIndexOf(" ");
|
|
83528
|
+
return (sp > 20 ? t.slice(0, sp) : t) + "\u2026";
|
|
83529
|
+
}
|
|
83530
|
+
|
|
83531
|
+
// ../ggcoder/dist/core/ideal-review.js
|
|
83532
|
+
init_esm_shims();
|
|
83533
|
+
var IDEAL_REVIEW_PROMPT = "Ideal? Review the actual work against the user's request before the final response. Is it simple, focused, correct, and aligned? Did you over-edit, leave TODOs, miss an obvious case the request called for, or introduce risk? Judge this by reading the code you changed \u2014 do NOT run builds, typechecks, linters, or test suites now; that happens at commit time via /commit. If anything is wrong, fix it now. If everything is good, respond with the final answer only; do not mention this ideal review unless it changed the work.";
|
|
83534
|
+
function evaluateIdealReview(stats) {
|
|
83535
|
+
const reasons = [];
|
|
83536
|
+
let score = 0;
|
|
83537
|
+
if (stats.changedLines >= 120) {
|
|
83538
|
+
score += 2;
|
|
83539
|
+
reasons.push(`${stats.changedLines} changed lines`);
|
|
83540
|
+
} else if (stats.changedLines >= 60) {
|
|
83541
|
+
score += 1;
|
|
83542
|
+
reasons.push(`${stats.changedLines} changed lines`);
|
|
83543
|
+
}
|
|
83544
|
+
if (stats.toolCalls >= 8) {
|
|
83545
|
+
score += 1;
|
|
83546
|
+
reasons.push(`${stats.toolCalls} tool calls`);
|
|
83547
|
+
}
|
|
83548
|
+
if (stats.writeCalls + stats.editCalls >= 4) {
|
|
83549
|
+
score += 2;
|
|
83550
|
+
reasons.push(`${stats.writeCalls + stats.editCalls} file mutation calls`);
|
|
83551
|
+
} else if (stats.writeCalls + stats.editCalls >= 2) {
|
|
83552
|
+
score += 1;
|
|
83553
|
+
reasons.push(`${stats.writeCalls + stats.editCalls} file mutation calls`);
|
|
83554
|
+
}
|
|
83555
|
+
if (stats.bashCalls > 0 && stats.writeCalls + stats.editCalls > 0) {
|
|
83556
|
+
score += 1;
|
|
83557
|
+
reasons.push("shell command plus file mutation");
|
|
83558
|
+
}
|
|
83559
|
+
if (stats.toolFailures > 0) {
|
|
83560
|
+
score += 2;
|
|
83561
|
+
reasons.push(`${stats.toolFailures} failed tool calls`);
|
|
83562
|
+
}
|
|
83563
|
+
if (stats.turns >= 6) {
|
|
83564
|
+
score += 1;
|
|
83565
|
+
reasons.push(`${stats.turns} agent turns`);
|
|
83566
|
+
}
|
|
83567
|
+
return { shouldReview: score >= 4, score, reasons };
|
|
83568
|
+
}
|
|
83569
|
+
function buildIdealReviewMessage(reasons) {
|
|
83570
|
+
const reasonText = reasons.length > 0 ? ` Triggered because: ${reasons.join(", ")}.` : "";
|
|
83571
|
+
return {
|
|
83572
|
+
role: "user",
|
|
83573
|
+
content: `${IDEAL_REVIEW_PROMPT}${reasonText}`
|
|
83574
|
+
};
|
|
83575
|
+
}
|
|
83576
|
+
|
|
83577
|
+
// ../ggcoder/dist/core/loop-breaker.js
|
|
83578
|
+
init_esm_shims();
|
|
83579
|
+
var CONSECUTIVE_FAILURE_LIMIT = 3;
|
|
83580
|
+
var SIGNATURE_REPEAT_LIMIT = 3;
|
|
83581
|
+
var SAME_FILE_EDIT_LIMIT = 5;
|
|
83582
|
+
var LOOP_BREAK_PROMPT = "Stuck? You've repeated essentially the same action and it keeps failing or not advancing. Stop and break the pattern. Read the latest error or result literally \u2014 not what you expected it to say. Then question the assumption underneath your approach: the file, path, API, command, or premise you've been treating as true may be wrong. Either try a fundamentally different approach or, if you genuinely cannot make progress, stop and tell the user what's blocking you and what you need. Do NOT repeat the previous attempt with minor tweaks. Do not mention this note unless it changed your approach.";
|
|
83583
|
+
function toolCallSignature(name, args) {
|
|
83584
|
+
return `${name}\0${canonicalize(args)}`;
|
|
83585
|
+
}
|
|
83586
|
+
function canonicalize(value) {
|
|
83587
|
+
if (value === null || typeof value !== "object") {
|
|
83588
|
+
return JSON.stringify(value) ?? "null";
|
|
83589
|
+
}
|
|
83590
|
+
if (Array.isArray(value)) {
|
|
83591
|
+
return `[${value.map(canonicalize).join(",")}]`;
|
|
83592
|
+
}
|
|
83593
|
+
const entries = Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
83594
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalize(v)}`).join(",")}}`;
|
|
83595
|
+
}
|
|
83596
|
+
var TEXT_REPETITION_MIN_LENGTH = 40;
|
|
83597
|
+
var TEXT_REPETITION_MIN_REPEATS = 3;
|
|
83598
|
+
var TEXT_REPETITION_TAIL = 4096;
|
|
83599
|
+
function detectTextRepetition(text) {
|
|
83600
|
+
if (text.length < TEXT_REPETITION_MIN_LENGTH * TEXT_REPETITION_MIN_REPEATS) {
|
|
83601
|
+
return false;
|
|
83602
|
+
}
|
|
83603
|
+
const tail = text.slice(-TEXT_REPETITION_TAIL);
|
|
83604
|
+
const maxBlock = Math.floor(tail.length / TEXT_REPETITION_MIN_REPEATS);
|
|
83605
|
+
for (let block2 = TEXT_REPETITION_MIN_LENGTH; block2 <= maxBlock; block2++) {
|
|
83606
|
+
const unit = tail.slice(tail.length - block2);
|
|
83607
|
+
let repeats = 1;
|
|
83608
|
+
let offset = tail.length - block2 * 2;
|
|
83609
|
+
while (offset >= 0 && tail.slice(offset, offset + block2) === unit) {
|
|
83610
|
+
repeats++;
|
|
83611
|
+
offset -= block2;
|
|
83612
|
+
}
|
|
83613
|
+
if (repeats >= TEXT_REPETITION_MIN_REPEATS)
|
|
83614
|
+
return true;
|
|
83615
|
+
}
|
|
83616
|
+
return false;
|
|
83617
|
+
}
|
|
83618
|
+
function evaluateLoopBreak(stats) {
|
|
83619
|
+
const reasons = [];
|
|
83620
|
+
if (stats.consecutiveFailures >= CONSECUTIVE_FAILURE_LIMIT) {
|
|
83621
|
+
reasons.push(`${stats.consecutiveFailures} consecutive failed tool calls`);
|
|
83622
|
+
}
|
|
83623
|
+
if (stats.maxSignatureRepeats >= SIGNATURE_REPEAT_LIMIT) {
|
|
83624
|
+
reasons.push(`identical tool call repeated ${stats.maxSignatureRepeats}x`);
|
|
83625
|
+
}
|
|
83626
|
+
if (stats.maxSameFileEdits >= SAME_FILE_EDIT_LIMIT) {
|
|
83627
|
+
reasons.push(`${stats.maxSameFileEdits} edits to the same file`);
|
|
83628
|
+
}
|
|
83629
|
+
if (stats.textRepetitionDetected) {
|
|
83630
|
+
reasons.push("repeated output detected");
|
|
83631
|
+
}
|
|
83632
|
+
return { shouldBreak: reasons.length > 0, reasons };
|
|
83633
|
+
}
|
|
83634
|
+
function buildLoopBreakMessage(reasons) {
|
|
83635
|
+
const reasonText = reasons.length > 0 ? ` Triggered because: ${reasons.join(", ")}.` : "";
|
|
83636
|
+
return {
|
|
83637
|
+
role: "user",
|
|
83638
|
+
content: `${LOOP_BREAK_PROMPT}${reasonText}`
|
|
83639
|
+
};
|
|
83640
|
+
}
|
|
83641
|
+
|
|
83642
|
+
// ../ggcoder/dist/core/regrounding.js
|
|
83643
|
+
init_esm_shims();
|
|
83644
|
+
function buildRegroundingMessage(originalRequest) {
|
|
83645
|
+
const trimmed = originalRequest.trim();
|
|
83646
|
+
const pin = trimmed.length > 0 ? `
|
|
83647
|
+
|
|
83648
|
+
The user's original request was:
|
|
83649
|
+
|
|
83650
|
+
${trimmed}
|
|
83651
|
+
|
|
83652
|
+
` : " The original request is in the earlier messages that remain. ";
|
|
83653
|
+
return {
|
|
83654
|
+
role: "user",
|
|
83655
|
+
content: "Re-ground. The conversation was just compacted, so earlier detail is now a summary and easy to drift from." + pin + "Before continuing, re-anchor on two things: that original request, and the specific objective you're working on right now. Verify your next step still serves the original ask \u2014 not a reshaped or narrowed version of it. If the summary dropped a constraint, file, or requirement you were tracking, recover it from the messages that remain before acting. Then continue. Do not restate this note; just proceed correctly."
|
|
83656
|
+
};
|
|
83657
|
+
}
|
|
83658
|
+
|
|
83453
83659
|
// ../ggcoder/dist/core/agent-session.js
|
|
83454
83660
|
import crypto8 from "crypto";
|
|
83455
83661
|
import fs29 from "fs/promises";
|
|
@@ -83465,6 +83671,34 @@ var AgentSession = class {
|
|
|
83465
83671
|
tools = [];
|
|
83466
83672
|
skills = [];
|
|
83467
83673
|
cacheKeyLogged = false;
|
|
83674
|
+
// ── Self-correction hook state (mirrors the TUI's useAgentLoop refs) ──
|
|
83675
|
+
// Reset at the start of every run; observed from the event stream; read by
|
|
83676
|
+
// the loop-break (mid-loop) and ideal-review (pre-stop) callbacks.
|
|
83677
|
+
hookStats = {
|
|
83678
|
+
changedLines: 0,
|
|
83679
|
+
toolCalls: 0,
|
|
83680
|
+
toolFailures: 0,
|
|
83681
|
+
turns: 0,
|
|
83682
|
+
writeCalls: 0,
|
|
83683
|
+
editCalls: 0,
|
|
83684
|
+
bashCalls: 0
|
|
83685
|
+
};
|
|
83686
|
+
hookText = "";
|
|
83687
|
+
hookConsecutiveFailures = 0;
|
|
83688
|
+
hookMaxSignatureRepeats = 0;
|
|
83689
|
+
hookMaxSameFileEdits = 0;
|
|
83690
|
+
hookSignatureCounts = /* @__PURE__ */ new Map();
|
|
83691
|
+
hookFileEditCounts = /* @__PURE__ */ new Map();
|
|
83692
|
+
hookToolCalls = /* @__PURE__ */ new Map();
|
|
83693
|
+
idealReviewInjected = false;
|
|
83694
|
+
loopBreakInjected = false;
|
|
83695
|
+
regroundingInjected = false;
|
|
83696
|
+
compactionOccurred = false;
|
|
83697
|
+
originalRequest = "";
|
|
83698
|
+
// Messages queued by the user while a run is in flight. Drained at the
|
|
83699
|
+
// mid-loop steering boundary (user steering wins over the hooks), mirroring
|
|
83700
|
+
// the TUI's getSteeringMessages.
|
|
83701
|
+
userQueue = [];
|
|
83468
83702
|
processManager;
|
|
83469
83703
|
lspManager;
|
|
83470
83704
|
mcpManager;
|
|
@@ -83475,6 +83709,8 @@ var AgentSession = class {
|
|
|
83475
83709
|
maxTokens;
|
|
83476
83710
|
thinkingLevel;
|
|
83477
83711
|
customSystemPrompt;
|
|
83712
|
+
/** Shared with the tool layer so plan-mode restrictions read live state. */
|
|
83713
|
+
planModeRef = { current: false };
|
|
83478
83714
|
sessionId = "";
|
|
83479
83715
|
sessionPath = "";
|
|
83480
83716
|
lastPersistedIndex = 0;
|
|
@@ -83519,7 +83755,14 @@ var AgentSession = class {
|
|
|
83519
83755
|
lspDiagnostics: this.settingsManager.get("lspDiagnostics"),
|
|
83520
83756
|
// Lazy — sessionId isn't assigned yet when createTools() runs, so we
|
|
83521
83757
|
// must defer reading the cache key until the sub-agent actually fires.
|
|
83522
|
-
getCacheKey: () => this.getPromptCacheKey()
|
|
83758
|
+
getCacheKey: () => this.getPromptCacheKey(),
|
|
83759
|
+
// Plan mode: only wired when the host supplies callbacks. The ref is
|
|
83760
|
+
// shared so bash/edit/write enforce read-only restrictions live.
|
|
83761
|
+
...this.opts.onEnterPlan || this.opts.onExitPlan ? {
|
|
83762
|
+
planModeRef: this.planModeRef,
|
|
83763
|
+
onEnterPlan: this.opts.onEnterPlan,
|
|
83764
|
+
onExitPlan: this.opts.onExitPlan
|
|
83765
|
+
} : {}
|
|
83523
83766
|
});
|
|
83524
83767
|
this.tools = tools;
|
|
83525
83768
|
this.processManager = processManager;
|
|
@@ -83630,6 +83873,173 @@ ${parsed.args}` : promptText;
|
|
|
83630
83873
|
this.lastPersistedIndex = this.messages.length;
|
|
83631
83874
|
await this.runLoop();
|
|
83632
83875
|
}
|
|
83876
|
+
/**
|
|
83877
|
+
* Prompt with multimodal attachments (images / videos) alongside optional
|
|
83878
|
+
* text. Images and videos become native content blocks the model can see;
|
|
83879
|
+
* non-media files are surfaced as a text note with their saved path so the
|
|
83880
|
+
* agent can open them with its tools. Slash-command parsing is skipped —
|
|
83881
|
+
* attachments are always a direct conversational turn.
|
|
83882
|
+
*/
|
|
83883
|
+
async promptWithAttachments(text, attachments) {
|
|
83884
|
+
const parts = [];
|
|
83885
|
+
const fileNotes = [];
|
|
83886
|
+
for (const a of attachments) {
|
|
83887
|
+
if (a.kind === "image") {
|
|
83888
|
+
parts.push({ type: "image", mediaType: a.mediaType, data: a.data });
|
|
83889
|
+
} else if (a.kind === "video") {
|
|
83890
|
+
parts.push({ type: "video", mediaType: a.mediaType, data: a.data });
|
|
83891
|
+
} else if (a.path) {
|
|
83892
|
+
fileNotes.push(`- ${a.name} (saved at ${a.path})`);
|
|
83893
|
+
}
|
|
83894
|
+
}
|
|
83895
|
+
const textParts = [];
|
|
83896
|
+
if (text.trim())
|
|
83897
|
+
textParts.push(text.trim());
|
|
83898
|
+
if (fileNotes.length > 0) {
|
|
83899
|
+
textParts.push(`Attached files (inspect with your tools):
|
|
83900
|
+
${fileNotes.join("\n")}`);
|
|
83901
|
+
}
|
|
83902
|
+
if (textParts.length > 0)
|
|
83903
|
+
parts.unshift({ type: "text", text: textParts.join("\n\n") });
|
|
83904
|
+
if (parts.length === 0)
|
|
83905
|
+
return;
|
|
83906
|
+
const userMessage = { role: "user", content: parts };
|
|
83907
|
+
this.messages.push(userMessage);
|
|
83908
|
+
await this.persistMessage(userMessage);
|
|
83909
|
+
this.lastPersistedIndex = this.messages.length;
|
|
83910
|
+
await this.runLoop();
|
|
83911
|
+
}
|
|
83912
|
+
/**
|
|
83913
|
+
* Reset per-run self-correction hook state. Mirrors the TUI's run_start
|
|
83914
|
+
* resets so each run evaluates the hooks from a clean slate. `originalRequest`
|
|
83915
|
+
* is the verbatim user ask, pinned for post-compaction re-grounding.
|
|
83916
|
+
*/
|
|
83917
|
+
resetHookState(originalRequest) {
|
|
83918
|
+
this.hookStats = {
|
|
83919
|
+
changedLines: 0,
|
|
83920
|
+
toolCalls: 0,
|
|
83921
|
+
toolFailures: 0,
|
|
83922
|
+
turns: 0,
|
|
83923
|
+
writeCalls: 0,
|
|
83924
|
+
editCalls: 0,
|
|
83925
|
+
bashCalls: 0
|
|
83926
|
+
};
|
|
83927
|
+
this.hookText = "";
|
|
83928
|
+
this.hookConsecutiveFailures = 0;
|
|
83929
|
+
this.hookMaxSignatureRepeats = 0;
|
|
83930
|
+
this.hookMaxSameFileEdits = 0;
|
|
83931
|
+
this.hookSignatureCounts.clear();
|
|
83932
|
+
this.hookFileEditCounts.clear();
|
|
83933
|
+
this.hookToolCalls.clear();
|
|
83934
|
+
this.idealReviewInjected = false;
|
|
83935
|
+
this.loopBreakInjected = false;
|
|
83936
|
+
this.regroundingInjected = false;
|
|
83937
|
+
this.compactionOccurred = false;
|
|
83938
|
+
this.originalRequest = originalRequest;
|
|
83939
|
+
}
|
|
83940
|
+
/**
|
|
83941
|
+
* Fold one agent event into the hook stat accumulators. Pure bookkeeping —
|
|
83942
|
+
* the same signals the TUI's useAgentLoop collects, so the loop-break and
|
|
83943
|
+
* ideal-review decisions match across the CLI and the app.
|
|
83944
|
+
*/
|
|
83945
|
+
trackHookEvent(event) {
|
|
83946
|
+
switch (event.type) {
|
|
83947
|
+
case "text_delta":
|
|
83948
|
+
this.hookText += event.text;
|
|
83949
|
+
break;
|
|
83950
|
+
case "tool_call_start":
|
|
83951
|
+
this.hookToolCalls.set(event.toolCallId, { name: event.name, args: event.args ?? {} });
|
|
83952
|
+
break;
|
|
83953
|
+
case "tool_call_end": {
|
|
83954
|
+
const call = this.hookToolCalls.get(event.toolCallId);
|
|
83955
|
+
const name = call?.name ?? "";
|
|
83956
|
+
const args = call?.args;
|
|
83957
|
+
this.hookStats.toolCalls += 1;
|
|
83958
|
+
if (event.isError)
|
|
83959
|
+
this.hookStats.toolFailures += 1;
|
|
83960
|
+
if (name === "write")
|
|
83961
|
+
this.hookStats.writeCalls += 1;
|
|
83962
|
+
if (name === "edit")
|
|
83963
|
+
this.hookStats.editCalls += 1;
|
|
83964
|
+
if (name === "bash")
|
|
83965
|
+
this.hookStats.bashCalls += 1;
|
|
83966
|
+
this.hookConsecutiveFailures = event.isError ? this.hookConsecutiveFailures + 1 : 0;
|
|
83967
|
+
const sig = toolCallSignature(name, args);
|
|
83968
|
+
const sigNext = (this.hookSignatureCounts.get(sig) ?? 0) + 1;
|
|
83969
|
+
this.hookSignatureCounts.set(sig, sigNext);
|
|
83970
|
+
if (sigNext > this.hookMaxSignatureRepeats)
|
|
83971
|
+
this.hookMaxSignatureRepeats = sigNext;
|
|
83972
|
+
if ((name === "edit" || name === "write") && args) {
|
|
83973
|
+
const filePath = args.file_path;
|
|
83974
|
+
if (typeof filePath === "string") {
|
|
83975
|
+
const fileNext = (this.hookFileEditCounts.get(filePath) ?? 0) + 1;
|
|
83976
|
+
this.hookFileEditCounts.set(filePath, fileNext);
|
|
83977
|
+
if (fileNext > this.hookMaxSameFileEdits)
|
|
83978
|
+
this.hookMaxSameFileEdits = fileNext;
|
|
83979
|
+
}
|
|
83980
|
+
}
|
|
83981
|
+
if (name === "edit" && !event.isError) {
|
|
83982
|
+
const diff3 = event.details?.diff ?? event.result;
|
|
83983
|
+
const added = (diff3.match(/^\+[^+]/gm) ?? []).length;
|
|
83984
|
+
const removed = (diff3.match(/^-[^-]/gm) ?? []).length;
|
|
83985
|
+
this.hookStats.changedLines += added + removed;
|
|
83986
|
+
}
|
|
83987
|
+
break;
|
|
83988
|
+
}
|
|
83989
|
+
case "turn_end":
|
|
83990
|
+
this.hookStats.turns = event.turn;
|
|
83991
|
+
break;
|
|
83992
|
+
}
|
|
83993
|
+
}
|
|
83994
|
+
/**
|
|
83995
|
+
* Mid-loop steering hook: fires the loop-breaker when the agent looks stuck,
|
|
83996
|
+
* then post-compaction re-grounding. At most one of each per run. Mirrors the
|
|
83997
|
+
* TUI's getSteeringMessages ordering (minus user steering, which the app
|
|
83998
|
+
* delivers as normal prompts).
|
|
83999
|
+
*/
|
|
84000
|
+
getHookSteeringMessages() {
|
|
84001
|
+
if (this.userQueue.length > 0) {
|
|
84002
|
+
const merged = this.userQueue.splice(0).join("\n\n");
|
|
84003
|
+
return [{ role: "user", content: merged }];
|
|
84004
|
+
}
|
|
84005
|
+
if (!this.settingsManager.get("idealReviewEnabled"))
|
|
84006
|
+
return null;
|
|
84007
|
+
if (!this.loopBreakInjected) {
|
|
84008
|
+
const decision = evaluateLoopBreak({
|
|
84009
|
+
consecutiveFailures: this.hookConsecutiveFailures,
|
|
84010
|
+
maxSignatureRepeats: this.hookMaxSignatureRepeats,
|
|
84011
|
+
maxSameFileEdits: this.hookMaxSameFileEdits,
|
|
84012
|
+
textRepetitionDetected: detectTextRepetition(this.hookText)
|
|
84013
|
+
});
|
|
84014
|
+
if (decision.shouldBreak) {
|
|
84015
|
+
this.loopBreakInjected = true;
|
|
84016
|
+
this.eventBus.emit("hook", { kind: "loop_break" });
|
|
84017
|
+
return [buildLoopBreakMessage(decision.reasons)];
|
|
84018
|
+
}
|
|
84019
|
+
}
|
|
84020
|
+
if (!this.regroundingInjected && this.compactionOccurred) {
|
|
84021
|
+
this.regroundingInjected = true;
|
|
84022
|
+
this.eventBus.emit("hook", { kind: "regrounding" });
|
|
84023
|
+
return [buildRegroundingMessage(this.originalRequest)];
|
|
84024
|
+
}
|
|
84025
|
+
return null;
|
|
84026
|
+
}
|
|
84027
|
+
/**
|
|
84028
|
+
* Pre-stop follow-up hook: runs the ideal review once, when the agent would
|
|
84029
|
+
* otherwise finish and the change set is substantial enough to warrant it.
|
|
84030
|
+
*/
|
|
84031
|
+
getHookFollowUpMessages() {
|
|
84032
|
+
if (!this.settingsManager.get("idealReviewEnabled"))
|
|
84033
|
+
return null;
|
|
84034
|
+
if (this.idealReviewInjected)
|
|
84035
|
+
return null;
|
|
84036
|
+
const decision = evaluateIdealReview(this.hookStats);
|
|
84037
|
+
if (!decision.shouldReview)
|
|
84038
|
+
return null;
|
|
84039
|
+
this.idealReviewInjected = true;
|
|
84040
|
+
this.eventBus.emit("hook", { kind: "ideal" });
|
|
84041
|
+
return [buildIdealReviewMessage(decision.reasons)];
|
|
84042
|
+
}
|
|
83633
84043
|
/** Auto-compact if needed, run agent loop with auth retry, and persist messages. */
|
|
83634
84044
|
async runLoop() {
|
|
83635
84045
|
if (!this.cacheKeyLogged) {
|
|
@@ -83641,6 +84051,9 @@ ${parsed.args}` : promptText;
|
|
|
83641
84051
|
transient: String(!!this.opts.transient)
|
|
83642
84052
|
});
|
|
83643
84053
|
}
|
|
84054
|
+
const lastUser = [...this.messages].reverse().find((m) => m.role === "user");
|
|
84055
|
+
const originalRequest = typeof lastUser?.content === "string" ? lastUser.content : "";
|
|
84056
|
+
this.resetHookState(originalRequest);
|
|
83644
84057
|
let creds = await this.authStorage.resolveCredentials(this.provider);
|
|
83645
84058
|
if (this.settingsManager.get("autoCompact")) {
|
|
83646
84059
|
const contextWindow = getContextWindow(this.model, {
|
|
@@ -83650,6 +84063,7 @@ ${parsed.args}` : promptText;
|
|
|
83650
84063
|
const threshold = this.settingsManager.get("compactThreshold");
|
|
83651
84064
|
if (shouldCompact(this.messages, contextWindow, threshold)) {
|
|
83652
84065
|
await this.compact(creds);
|
|
84066
|
+
this.compactionOccurred = true;
|
|
83653
84067
|
}
|
|
83654
84068
|
}
|
|
83655
84069
|
const userAgent = this.provider === "anthropic" ? await getClaudeCliUserAgent() : void 0;
|
|
@@ -83679,9 +84093,14 @@ ${parsed.args}` : promptText;
|
|
|
83679
84093
|
userAgent,
|
|
83680
84094
|
// clearToolUses disabled — causes model to output unsolicited context summaries
|
|
83681
84095
|
// Single tool result shouldn't exceed 30% of context window (in chars)
|
|
83682
|
-
maxToolResultChars: Math.floor(getContextWindow(this.model, { provider: this.provider, accountId }) * 3.5 * 0.3)
|
|
84096
|
+
maxToolResultChars: Math.floor(getContextWindow(this.model, { provider: this.provider, accountId }) * 3.5 * 0.3),
|
|
84097
|
+
// Self-correction hooks (same as the TUI): loop-break + re-grounding are
|
|
84098
|
+
// polled mid-loop; the ideal review is polled when the agent would stop.
|
|
84099
|
+
getSteeringMessages: () => this.getHookSteeringMessages(),
|
|
84100
|
+
getFollowUpMessages: () => this.getHookFollowUpMessages()
|
|
83683
84101
|
});
|
|
83684
84102
|
for await (const event of generator) {
|
|
84103
|
+
this.trackHookEvent(event);
|
|
83685
84104
|
this.eventBus.forwardAgentEvent(event);
|
|
83686
84105
|
}
|
|
83687
84106
|
};
|
|
@@ -83833,12 +84252,93 @@ ${parsed.args}` : promptText;
|
|
|
83833
84252
|
cwd: this.cwd,
|
|
83834
84253
|
sessionId: this.sessionId,
|
|
83835
84254
|
sessionPath: this.sessionPath,
|
|
83836
|
-
messageCount: this.messages.length
|
|
84255
|
+
messageCount: this.messages.length,
|
|
84256
|
+
planMode: this.planModeRef.current
|
|
83837
84257
|
};
|
|
83838
84258
|
}
|
|
84259
|
+
getPlanMode() {
|
|
84260
|
+
return this.planModeRef.current;
|
|
84261
|
+
}
|
|
84262
|
+
/** Queue a user message to be injected mid-run as steering. Returns the new
|
|
84263
|
+
* queue length. No-op semantics are the caller's concern. */
|
|
84264
|
+
queueMessage(text) {
|
|
84265
|
+
this.userQueue.push(text);
|
|
84266
|
+
return this.userQueue.length;
|
|
84267
|
+
}
|
|
84268
|
+
/** Number of messages currently queued. */
|
|
84269
|
+
getQueuedCount() {
|
|
84270
|
+
return this.userQueue.length;
|
|
84271
|
+
}
|
|
84272
|
+
/** Clear the queue, returning the combined text (to restore to the composer). */
|
|
84273
|
+
drainQueue() {
|
|
84274
|
+
return this.userQueue.splice(0).join("\n\n");
|
|
84275
|
+
}
|
|
84276
|
+
/** Snapshot of background processes (bash run_in_background), newest-state. */
|
|
84277
|
+
listBackgroundProcesses() {
|
|
84278
|
+
return this.processManager?.list() ?? [];
|
|
84279
|
+
}
|
|
84280
|
+
/** Stop a background process by id. Returns a human-readable status string. */
|
|
84281
|
+
async killBackgroundProcess(id2) {
|
|
84282
|
+
if (!this.processManager)
|
|
84283
|
+
return `No background process with id "${id2}"`;
|
|
84284
|
+
return this.processManager.stop(id2);
|
|
84285
|
+
}
|
|
84286
|
+
/**
|
|
84287
|
+
* Toggle plan mode: flips the shared ref (so tools enforce read-only
|
|
84288
|
+
* restrictions) and rebuilds the system prompt in place so the model is told
|
|
84289
|
+
* about the mode change on its next turn. No-op when a custom system prompt
|
|
84290
|
+
* is in force (the host owns the prompt then).
|
|
84291
|
+
*/
|
|
84292
|
+
async setPlanMode(active) {
|
|
84293
|
+
this.planModeRef.current = active;
|
|
84294
|
+
if (this.customSystemPrompt)
|
|
84295
|
+
return;
|
|
84296
|
+
const rebuilt = await buildSystemPrompt(this.cwd, this.skills, active, void 0, this.tools.map((tool) => tool.name), void 0, this.provider);
|
|
84297
|
+
if (this.messages[0]?.role === "system") {
|
|
84298
|
+
this.messages[0] = { role: "system", content: rebuilt };
|
|
84299
|
+
} else {
|
|
84300
|
+
this.messages.unshift({ role: "system", content: rebuilt });
|
|
84301
|
+
}
|
|
84302
|
+
}
|
|
83839
84303
|
getMessages() {
|
|
83840
84304
|
return this.messages;
|
|
83841
84305
|
}
|
|
84306
|
+
/**
|
|
84307
|
+
* Generate a short LLM session title from the conversation so far (first user
|
|
84308
|
+
* message + first assistant reply). Best-effort; returns null on failure or
|
|
84309
|
+
* when there's no user message yet. Uses the cheapest model for the provider.
|
|
84310
|
+
*/
|
|
84311
|
+
async generateTitle() {
|
|
84312
|
+
const extractText = (content) => typeof content === "string" ? content : content.map((c2) => c2.type === "text" && "text" in c2 && typeof c2.text === "string" ? c2.text : "").join(" ");
|
|
84313
|
+
const userMsg = this.messages.find((m) => m.role === "user");
|
|
84314
|
+
const assistantMsg = this.messages.find((m) => m.role === "assistant");
|
|
84315
|
+
const userText = userMsg ? extractText(userMsg.content) : "";
|
|
84316
|
+
if (!userText.trim())
|
|
84317
|
+
return null;
|
|
84318
|
+
try {
|
|
84319
|
+
const creds = await this.authStorage.resolveCredentials(this.provider);
|
|
84320
|
+
const title = await generateSessionTitle({
|
|
84321
|
+
provider: this.provider,
|
|
84322
|
+
userMessage: userText,
|
|
84323
|
+
assistantPreview: assistantMsg ? extractText(assistantMsg.content).slice(0, 200) : "",
|
|
84324
|
+
apiKey: creds.accessToken,
|
|
84325
|
+
baseUrl: this.baseUrl ?? creds.baseUrl,
|
|
84326
|
+
accountId: creds.accountId
|
|
84327
|
+
});
|
|
84328
|
+
return title || null;
|
|
84329
|
+
} catch {
|
|
84330
|
+
return null;
|
|
84331
|
+
}
|
|
84332
|
+
}
|
|
84333
|
+
/** Current reasoning/thinking level, or undefined when thinking is off. */
|
|
84334
|
+
getThinkingLevel() {
|
|
84335
|
+
return this.thinkingLevel;
|
|
84336
|
+
}
|
|
84337
|
+
/** Set the reasoning/thinking level (undefined turns thinking off). Takes
|
|
84338
|
+
* effect on the next prompt, since the in-flight loop reads it at start. */
|
|
84339
|
+
setThinkingLevel(level) {
|
|
84340
|
+
this.thinkingLevel = level;
|
|
84341
|
+
}
|
|
83842
84342
|
/** Replace the abort signal (e.g. after cancellation). */
|
|
83843
84343
|
setSignal(signal) {
|
|
83844
84344
|
this.opts = { ...this.opts, signal };
|
|
@@ -88939,8 +89439,8 @@ var cleanupYogaNode = (node) => {
|
|
|
88939
89439
|
var currentUpdatePriority = import_constants3.NoEventPriority;
|
|
88940
89440
|
var currentRootNode;
|
|
88941
89441
|
async function loadPackageJson() {
|
|
88942
|
-
const
|
|
88943
|
-
const content =
|
|
89442
|
+
const fs39 = await import("fs");
|
|
89443
|
+
const content = fs39.readFileSync(new URL("../package.json", import.meta.url), "utf8");
|
|
88944
89444
|
return JSON.parse(content);
|
|
88945
89445
|
}
|
|
88946
89446
|
var packageJson = isDev() ? await loadPackageJson() : { name: void 0, version: void 0 };
|
|
@@ -90630,8 +91130,8 @@ function Text({ color: color2, backgroundColor, dimColor = false, bold = false,
|
|
|
90630
91130
|
}
|
|
90631
91131
|
|
|
90632
91132
|
// ../../node_modules/.pnpm/@kenkaiiii+ink@6.8.0-gg.2_@types+react@19.2.14_react@19.2.5/node_modules/@kenkaiiii/ink/build/components/ErrorOverview.js
|
|
90633
|
-
var cleanupPath = (
|
|
90634
|
-
return
|
|
91133
|
+
var cleanupPath = (path46) => {
|
|
91134
|
+
return path46?.replace(`file://${cwd()}/`, "");
|
|
90635
91135
|
};
|
|
90636
91136
|
var stackUtils = new import_stack_utils.default({
|
|
90637
91137
|
cwd: cwd(),
|
|
@@ -93308,9 +93808,6 @@ var notificationPath = resolve(__dirname2, "../../assets/end-notification.mp3");
|
|
|
93308
93808
|
init_esm_shims();
|
|
93309
93809
|
var import_react43 = __toESM(require_react(), 1);
|
|
93310
93810
|
|
|
93311
|
-
// ../ggcoder/dist/core/loop-breaker.js
|
|
93312
|
-
init_esm_shims();
|
|
93313
|
-
|
|
93314
93811
|
// ../ggcoder/dist/ui/hooks/useTranscriptHistory.js
|
|
93315
93812
|
init_esm_shims();
|
|
93316
93813
|
var import_react44 = __toESM(require_react(), 1);
|
|
@@ -93919,8 +94416,8 @@ function shortenValue(value, maxLength = MAX_DETAIL_LENGTH) {
|
|
|
93919
94416
|
const tailLength = maxLength - 1 - headLength;
|
|
93920
94417
|
return `${normalized.slice(0, headLength)}\u2026${normalized.slice(-tailLength)}`;
|
|
93921
94418
|
}
|
|
93922
|
-
function basename2(
|
|
93923
|
-
const trimmed =
|
|
94419
|
+
function basename2(path46) {
|
|
94420
|
+
const trimmed = path46.replace(/\/+$/u, "");
|
|
93924
94421
|
return trimmed.split("/").filter(Boolean).at(-1) ?? trimmed;
|
|
93925
94422
|
}
|
|
93926
94423
|
function uniqueValues(values) {
|
|
@@ -111271,9 +111768,6 @@ var getPendingUpdate = updater.getPendingUpdate;
|
|
|
111271
111768
|
var startPeriodicUpdateCheck = updater.startPeriodicUpdateCheck;
|
|
111272
111769
|
var stopPeriodicUpdateCheck = updater.stopPeriodicUpdateCheck;
|
|
111273
111770
|
|
|
111274
|
-
// ../ggcoder/dist/utils/session-title.js
|
|
111275
|
-
init_esm_shims();
|
|
111276
|
-
|
|
111277
111771
|
// ../ggcoder/dist/core/setup-history.js
|
|
111278
111772
|
init_esm_shims();
|
|
111279
111773
|
import fs33 from "fs";
|
|
@@ -111304,12 +111798,6 @@ init_esm_shims();
|
|
|
111304
111798
|
// ../ggcoder/dist/ui/submit-slash-commands.js
|
|
111305
111799
|
init_esm_shims();
|
|
111306
111800
|
|
|
111307
|
-
// ../ggcoder/dist/core/ideal-review.js
|
|
111308
|
-
init_esm_shims();
|
|
111309
|
-
|
|
111310
|
-
// ../ggcoder/dist/core/regrounding.js
|
|
111311
|
-
init_esm_shims();
|
|
111312
|
-
|
|
111313
111801
|
// ../ggcoder/dist/ui/thinking-level.js
|
|
111314
111802
|
init_esm_shims();
|
|
111315
111803
|
|
|
@@ -112403,6 +112891,276 @@ var DISABLE_MODIFY_OTHER_KEYS = "\x1B[>4;0m";
|
|
|
112403
112891
|
var SCREEN_CLEAR = DISABLE_MODIFY_OTHER_KEYS + "\x1B[2J\x1B[3J\x1B[H";
|
|
112404
112892
|
var VIEWPORT_CLEAR = DISABLE_MODIFY_OTHER_KEYS + "\x1B[2J\x1B[H";
|
|
112405
112893
|
|
|
112894
|
+
// ../ggcoder/dist/core/project-discovery.js
|
|
112895
|
+
init_esm_shims();
|
|
112896
|
+
import fs34 from "fs/promises";
|
|
112897
|
+
import { createReadStream as createReadStream3 } from "fs";
|
|
112898
|
+
import readline3 from "readline";
|
|
112899
|
+
import os12 from "os";
|
|
112900
|
+
import path40 from "path";
|
|
112901
|
+
async function discoverProjects() {
|
|
112902
|
+
const [gg, cc, cx] = await Promise.all([
|
|
112903
|
+
discoverGgcoderProjects(),
|
|
112904
|
+
discoverClaudeProjects(),
|
|
112905
|
+
discoverCodexProjects()
|
|
112906
|
+
]);
|
|
112907
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
112908
|
+
for (const p of [...gg, ...cc, ...cx]) {
|
|
112909
|
+
const existing = byPath.get(p.path);
|
|
112910
|
+
if (!existing) {
|
|
112911
|
+
byPath.set(p.path, p);
|
|
112912
|
+
continue;
|
|
112913
|
+
}
|
|
112914
|
+
byPath.set(p.path, {
|
|
112915
|
+
name: existing.name,
|
|
112916
|
+
path: existing.path,
|
|
112917
|
+
lastActiveMs: Math.max(existing.lastActiveMs, p.lastActiveMs),
|
|
112918
|
+
lastActiveDisplay: "",
|
|
112919
|
+
// recomputed below
|
|
112920
|
+
sources: mergeSources(existing.sources, p.sources)
|
|
112921
|
+
});
|
|
112922
|
+
}
|
|
112923
|
+
const merged = Array.from(byPath.values()).map((p) => ({
|
|
112924
|
+
...p,
|
|
112925
|
+
lastActiveDisplay: formatRelativeTime(p.lastActiveMs)
|
|
112926
|
+
}));
|
|
112927
|
+
merged.sort((a, b) => b.lastActiveMs - a.lastActiveMs);
|
|
112928
|
+
return merged;
|
|
112929
|
+
}
|
|
112930
|
+
var SOURCE_ORDER = {
|
|
112931
|
+
ggcoder: 0,
|
|
112932
|
+
"claude-code": 1,
|
|
112933
|
+
codex: 2
|
|
112934
|
+
};
|
|
112935
|
+
function mergeSources(a, b) {
|
|
112936
|
+
const set2 = /* @__PURE__ */ new Set([...a, ...b]);
|
|
112937
|
+
return Array.from(set2).sort((x, y) => SOURCE_ORDER[x] - SOURCE_ORDER[y]);
|
|
112938
|
+
}
|
|
112939
|
+
async function discoverGgcoderProjects() {
|
|
112940
|
+
const sessionsDir = getAppPaths().sessionsDir;
|
|
112941
|
+
let entries;
|
|
112942
|
+
try {
|
|
112943
|
+
entries = await fs34.readdir(sessionsDir);
|
|
112944
|
+
} catch {
|
|
112945
|
+
return [];
|
|
112946
|
+
}
|
|
112947
|
+
const results = [];
|
|
112948
|
+
for (const entry of entries) {
|
|
112949
|
+
const dir = path40.join(sessionsDir, entry);
|
|
112950
|
+
const mtime = await maxJsonlMtime(dir);
|
|
112951
|
+
if (mtime === null)
|
|
112952
|
+
continue;
|
|
112953
|
+
const decoded = path40.resolve("/" + entry.replace(/_/g, "/"));
|
|
112954
|
+
if (!await isDirectory(decoded))
|
|
112955
|
+
continue;
|
|
112956
|
+
results.push({
|
|
112957
|
+
name: path40.basename(decoded),
|
|
112958
|
+
path: decoded,
|
|
112959
|
+
lastActiveMs: mtime,
|
|
112960
|
+
lastActiveDisplay: formatRelativeTime(mtime),
|
|
112961
|
+
sources: ["ggcoder"]
|
|
112962
|
+
});
|
|
112963
|
+
}
|
|
112964
|
+
return results;
|
|
112965
|
+
}
|
|
112966
|
+
async function discoverClaudeProjects() {
|
|
112967
|
+
const projectsDir = path40.join(os12.homedir(), ".claude", "projects");
|
|
112968
|
+
let entries;
|
|
112969
|
+
try {
|
|
112970
|
+
entries = await fs34.readdir(projectsDir);
|
|
112971
|
+
} catch {
|
|
112972
|
+
return [];
|
|
112973
|
+
}
|
|
112974
|
+
const results = await Promise.all(entries.map(async (entry) => {
|
|
112975
|
+
const dir = path40.join(projectsDir, entry);
|
|
112976
|
+
const mtime = await maxJsonlMtime(dir);
|
|
112977
|
+
if (mtime === null)
|
|
112978
|
+
return null;
|
|
112979
|
+
const cwd2 = await readFirstFromJsonlDir(dir, claudeCwdExtractor) ?? fallbackDashDecode(entry);
|
|
112980
|
+
if (!cwd2)
|
|
112981
|
+
return null;
|
|
112982
|
+
if (!await isDirectory(cwd2))
|
|
112983
|
+
return null;
|
|
112984
|
+
return {
|
|
112985
|
+
name: path40.basename(cwd2),
|
|
112986
|
+
path: cwd2,
|
|
112987
|
+
lastActiveMs: mtime,
|
|
112988
|
+
lastActiveDisplay: formatRelativeTime(mtime),
|
|
112989
|
+
sources: ["claude-code"]
|
|
112990
|
+
};
|
|
112991
|
+
}));
|
|
112992
|
+
return results.filter((p) => p !== null);
|
|
112993
|
+
}
|
|
112994
|
+
async function discoverCodexProjects() {
|
|
112995
|
+
const sessionsDir = path40.join(os12.homedir(), ".codex", "sessions");
|
|
112996
|
+
if (!await isDirectory(sessionsDir))
|
|
112997
|
+
return [];
|
|
112998
|
+
const files = await collectJsonlFiles(sessionsDir, 4);
|
|
112999
|
+
if (files.length === 0)
|
|
113000
|
+
return [];
|
|
113001
|
+
files.sort((a, b) => b.mtime - a.mtime);
|
|
113002
|
+
const byCwd = /* @__PURE__ */ new Map();
|
|
113003
|
+
for (const f of files) {
|
|
113004
|
+
const cwd2 = await readFirstFromFile(f.path, codexCwdExtractor);
|
|
113005
|
+
if (!cwd2)
|
|
113006
|
+
continue;
|
|
113007
|
+
const prev = byCwd.get(cwd2);
|
|
113008
|
+
if (prev === void 0 || f.mtime > prev)
|
|
113009
|
+
byCwd.set(cwd2, f.mtime);
|
|
113010
|
+
}
|
|
113011
|
+
const results = [];
|
|
113012
|
+
for (const [cwd2, mtime] of byCwd) {
|
|
113013
|
+
if (!await isDirectory(cwd2))
|
|
113014
|
+
continue;
|
|
113015
|
+
results.push({
|
|
113016
|
+
name: path40.basename(cwd2),
|
|
113017
|
+
path: cwd2,
|
|
113018
|
+
lastActiveMs: mtime,
|
|
113019
|
+
lastActiveDisplay: formatRelativeTime(mtime),
|
|
113020
|
+
sources: ["codex"]
|
|
113021
|
+
});
|
|
113022
|
+
}
|
|
113023
|
+
return results;
|
|
113024
|
+
}
|
|
113025
|
+
async function isDirectory(p) {
|
|
113026
|
+
try {
|
|
113027
|
+
const s = await fs34.stat(p);
|
|
113028
|
+
return s.isDirectory();
|
|
113029
|
+
} catch {
|
|
113030
|
+
return false;
|
|
113031
|
+
}
|
|
113032
|
+
}
|
|
113033
|
+
async function maxJsonlMtime(dir) {
|
|
113034
|
+
if (!await isDirectory(dir))
|
|
113035
|
+
return null;
|
|
113036
|
+
const files = await collectJsonlFiles(dir, 2);
|
|
113037
|
+
if (files.length === 0)
|
|
113038
|
+
return null;
|
|
113039
|
+
let max = 0;
|
|
113040
|
+
for (const f of files)
|
|
113041
|
+
if (f.mtime > max)
|
|
113042
|
+
max = f.mtime;
|
|
113043
|
+
return max > 0 ? max : null;
|
|
113044
|
+
}
|
|
113045
|
+
async function collectJsonlFiles(dir, maxDepth) {
|
|
113046
|
+
const out = [];
|
|
113047
|
+
await walk(dir, 0);
|
|
113048
|
+
return out;
|
|
113049
|
+
async function walk(current, depth) {
|
|
113050
|
+
let entries;
|
|
113051
|
+
try {
|
|
113052
|
+
entries = await fs34.readdir(current, { withFileTypes: true });
|
|
113053
|
+
} catch {
|
|
113054
|
+
return;
|
|
113055
|
+
}
|
|
113056
|
+
for (const e of entries) {
|
|
113057
|
+
const full = path40.join(current, e.name);
|
|
113058
|
+
if (e.isFile() && e.name.endsWith(".jsonl")) {
|
|
113059
|
+
try {
|
|
113060
|
+
const s = await fs34.stat(full);
|
|
113061
|
+
out.push({ path: full, mtime: s.mtimeMs });
|
|
113062
|
+
} catch {
|
|
113063
|
+
}
|
|
113064
|
+
} else if (e.isDirectory() && depth < maxDepth) {
|
|
113065
|
+
await walk(full, depth + 1);
|
|
113066
|
+
}
|
|
113067
|
+
}
|
|
113068
|
+
}
|
|
113069
|
+
}
|
|
113070
|
+
var claudeCwdExtractor = (line) => {
|
|
113071
|
+
try {
|
|
113072
|
+
const parsed = JSON.parse(line);
|
|
113073
|
+
if (typeof parsed.cwd === "string" && parsed.cwd.startsWith("/"))
|
|
113074
|
+
return parsed.cwd;
|
|
113075
|
+
} catch {
|
|
113076
|
+
}
|
|
113077
|
+
return null;
|
|
113078
|
+
};
|
|
113079
|
+
var CODEX_CWD_RE = /<cwd>([^<]+)<\/cwd>/;
|
|
113080
|
+
var codexCwdExtractor = (line) => {
|
|
113081
|
+
try {
|
|
113082
|
+
const parsed = JSON.parse(line);
|
|
113083
|
+
const cwd2 = parsed.payload?.cwd;
|
|
113084
|
+
if (typeof cwd2 === "string" && cwd2.startsWith("/"))
|
|
113085
|
+
return cwd2;
|
|
113086
|
+
} catch {
|
|
113087
|
+
}
|
|
113088
|
+
const m = CODEX_CWD_RE.exec(line);
|
|
113089
|
+
if (m && m[1] && m[1].startsWith("/"))
|
|
113090
|
+
return m[1];
|
|
113091
|
+
return null;
|
|
113092
|
+
};
|
|
113093
|
+
async function readFirstFromJsonlDir(dir, extractor) {
|
|
113094
|
+
const files = await collectJsonlFiles(dir, 2);
|
|
113095
|
+
if (files.length === 0)
|
|
113096
|
+
return null;
|
|
113097
|
+
files.sort((a, b) => b.mtime - a.mtime);
|
|
113098
|
+
for (const f of files) {
|
|
113099
|
+
const v = await readFirstFromFile(f.path, extractor);
|
|
113100
|
+
if (v)
|
|
113101
|
+
return v;
|
|
113102
|
+
}
|
|
113103
|
+
return null;
|
|
113104
|
+
}
|
|
113105
|
+
async function readFirstFromFile(file2, extractor) {
|
|
113106
|
+
return new Promise((resolve2) => {
|
|
113107
|
+
const stream2 = createReadStream3(file2, { encoding: "utf-8" });
|
|
113108
|
+
const rl = readline3.createInterface({ input: stream2, crlfDelay: Infinity });
|
|
113109
|
+
let lines = 0;
|
|
113110
|
+
let done = false;
|
|
113111
|
+
const MAX_LINES2 = 200;
|
|
113112
|
+
const finish = (value) => {
|
|
113113
|
+
if (done)
|
|
113114
|
+
return;
|
|
113115
|
+
done = true;
|
|
113116
|
+
resolve2(value);
|
|
113117
|
+
rl.close();
|
|
113118
|
+
stream2.destroy();
|
|
113119
|
+
};
|
|
113120
|
+
rl.on("line", (line) => {
|
|
113121
|
+
if (done)
|
|
113122
|
+
return;
|
|
113123
|
+
lines++;
|
|
113124
|
+
if (lines > MAX_LINES2) {
|
|
113125
|
+
finish(null);
|
|
113126
|
+
return;
|
|
113127
|
+
}
|
|
113128
|
+
const v = extractor(line);
|
|
113129
|
+
if (v)
|
|
113130
|
+
finish(v);
|
|
113131
|
+
});
|
|
113132
|
+
rl.on("close", () => finish(null));
|
|
113133
|
+
rl.on("error", () => finish(null));
|
|
113134
|
+
stream2.on("error", () => finish(null));
|
|
113135
|
+
});
|
|
113136
|
+
}
|
|
113137
|
+
function fallbackDashDecode(entry) {
|
|
113138
|
+
if (!entry.startsWith("-"))
|
|
113139
|
+
return null;
|
|
113140
|
+
return "/" + entry.slice(1).replace(/-/g, "/");
|
|
113141
|
+
}
|
|
113142
|
+
function formatRelativeTime(ms) {
|
|
113143
|
+
if (ms === 0)
|
|
113144
|
+
return "\u2014";
|
|
113145
|
+
const diff3 = Date.now() - ms;
|
|
113146
|
+
if (diff3 < 6e4)
|
|
113147
|
+
return "just now";
|
|
113148
|
+
const min = 6e4;
|
|
113149
|
+
const hour = 60 * min;
|
|
113150
|
+
const day = 24 * hour;
|
|
113151
|
+
const week = 7 * day;
|
|
113152
|
+
const month = 30 * day;
|
|
113153
|
+
if (diff3 < hour)
|
|
113154
|
+
return `${Math.floor(diff3 / min)}m ago`;
|
|
113155
|
+
if (diff3 < day)
|
|
113156
|
+
return `${Math.floor(diff3 / hour)}h ago`;
|
|
113157
|
+
if (diff3 < week)
|
|
113158
|
+
return `${Math.floor(diff3 / day)}d ago`;
|
|
113159
|
+
if (diff3 < month)
|
|
113160
|
+
return `${Math.floor(diff3 / week)}w ago`;
|
|
113161
|
+
return `${Math.floor(diff3 / month)}mo ago`;
|
|
113162
|
+
}
|
|
113163
|
+
|
|
112406
113164
|
// src/boss-store.ts
|
|
112407
113165
|
init_esm_shims();
|
|
112408
113166
|
var import_react97 = __toESM(require_react(), 1);
|
|
@@ -113667,17 +114425,17 @@ var EventQueue = class {
|
|
|
113667
114425
|
|
|
113668
114426
|
// src/settings.ts
|
|
113669
114427
|
init_esm_shims();
|
|
113670
|
-
import
|
|
113671
|
-
import
|
|
114428
|
+
import fs35 from "fs/promises";
|
|
114429
|
+
import path41 from "path";
|
|
113672
114430
|
function settingsPath() {
|
|
113673
|
-
return
|
|
114431
|
+
return path41.join(getAppPaths().agentDir, "boss", "settings.json");
|
|
113674
114432
|
}
|
|
113675
114433
|
async function ensureDir() {
|
|
113676
|
-
await
|
|
114434
|
+
await fs35.mkdir(path41.dirname(settingsPath()), { recursive: true, mode: 448 });
|
|
113677
114435
|
}
|
|
113678
114436
|
async function loadSettings() {
|
|
113679
114437
|
try {
|
|
113680
|
-
const content = await
|
|
114438
|
+
const content = await fs35.readFile(settingsPath(), "utf-8");
|
|
113681
114439
|
const parsed = JSON.parse(content);
|
|
113682
114440
|
if (!parsed || typeof parsed !== "object") return {};
|
|
113683
114441
|
return parsed;
|
|
@@ -113692,8 +114450,8 @@ async function saveSettings(patch) {
|
|
|
113692
114450
|
const merged = { ...current, ...patch };
|
|
113693
114451
|
await ensureDir();
|
|
113694
114452
|
const tmp = `${settingsPath()}.${process.pid}.tmp`;
|
|
113695
|
-
await
|
|
113696
|
-
await
|
|
114453
|
+
await fs35.writeFile(tmp, JSON.stringify(merged, null, 2) + "\n", "utf-8");
|
|
114454
|
+
await fs35.rename(tmp, settingsPath());
|
|
113697
114455
|
});
|
|
113698
114456
|
writeChain = next.catch(() => void 0);
|
|
113699
114457
|
await next;
|
|
@@ -114085,18 +114843,18 @@ init_esm_shims();
|
|
|
114085
114843
|
// src/tasks-store.ts
|
|
114086
114844
|
init_esm_shims();
|
|
114087
114845
|
var import_react98 = __toESM(require_react(), 1);
|
|
114088
|
-
import
|
|
114089
|
-
import
|
|
114846
|
+
import fs36 from "fs/promises";
|
|
114847
|
+
import path43 from "path";
|
|
114090
114848
|
import crypto10 from "crypto";
|
|
114091
114849
|
function getPlanPath() {
|
|
114092
|
-
return
|
|
114850
|
+
return path43.join(getAppPaths().agentDir, "boss", "plan.json");
|
|
114093
114851
|
}
|
|
114094
114852
|
async function ensureDir2() {
|
|
114095
|
-
await
|
|
114853
|
+
await fs36.mkdir(path43.dirname(getPlanPath()), { recursive: true, mode: 448 });
|
|
114096
114854
|
}
|
|
114097
114855
|
async function loadPlan() {
|
|
114098
114856
|
try {
|
|
114099
|
-
const content = await
|
|
114857
|
+
const content = await fs36.readFile(getPlanPath(), "utf-8");
|
|
114100
114858
|
const parsed = JSON.parse(content);
|
|
114101
114859
|
return Array.isArray(parsed.tasks) ? parsed.tasks : [];
|
|
114102
114860
|
} catch {
|
|
@@ -114110,8 +114868,8 @@ async function persist(tasks) {
|
|
|
114110
114868
|
await ensureDir2();
|
|
114111
114869
|
const finalPath = getPlanPath();
|
|
114112
114870
|
const tmpPath = `${finalPath}.${process.pid}.tmp`;
|
|
114113
|
-
await
|
|
114114
|
-
await
|
|
114871
|
+
await fs36.writeFile(tmpPath, snapshot, "utf-8");
|
|
114872
|
+
await fs36.rename(tmpPath, finalPath);
|
|
114115
114873
|
});
|
|
114116
114874
|
persistChain = next.catch(() => void 0);
|
|
114117
114875
|
await next;
|
|
@@ -114381,11 +115139,11 @@ function createTaskTools(deps) {
|
|
|
114381
115139
|
init_esm_shims();
|
|
114382
115140
|
import { spawn as spawn8, execFileSync as execFileSync4 } from "child_process";
|
|
114383
115141
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
114384
|
-
import
|
|
114385
|
-
import
|
|
115142
|
+
import path44 from "path";
|
|
115143
|
+
import fs37 from "fs";
|
|
114386
115144
|
function readMp3DurationMs(file2) {
|
|
114387
115145
|
try {
|
|
114388
|
-
const buf =
|
|
115146
|
+
const buf = fs37.readFileSync(file2);
|
|
114389
115147
|
let i = 0;
|
|
114390
115148
|
if (buf.length >= 10 && buf[0] === 73 && buf[1] === 68 && buf[2] === 51) {
|
|
114391
115149
|
const tagSize = (buf[6] & 127) << 21 | (buf[7] & 127) << 14 | (buf[8] & 127) << 7 | buf[9] & 127;
|
|
@@ -114442,10 +115200,10 @@ function getSplashAudioDurationMs() {
|
|
|
114442
115200
|
return ms && ms > 0 ? ms : 1500;
|
|
114443
115201
|
}
|
|
114444
115202
|
function assetPath(name) {
|
|
114445
|
-
const here =
|
|
114446
|
-
const dist =
|
|
114447
|
-
if (
|
|
114448
|
-
return
|
|
115203
|
+
const here = path44.dirname(fileURLToPath5(import.meta.url));
|
|
115204
|
+
const dist = path44.join(here, name);
|
|
115205
|
+
if (fs37.existsSync(dist)) return dist;
|
|
115206
|
+
return path44.join(here, "..", "assets", name);
|
|
114449
115207
|
}
|
|
114450
115208
|
function splashAssetPath() {
|
|
114451
115209
|
return assetPath("splash.mp3");
|
|
@@ -114485,15 +115243,15 @@ function trySpawn(cmd, args) {
|
|
|
114485
115243
|
}
|
|
114486
115244
|
function isWsl() {
|
|
114487
115245
|
if (process.platform !== "linux") return false;
|
|
114488
|
-
return !!process.env.WSL_DISTRO_NAME ||
|
|
115246
|
+
return !!process.env.WSL_DISTRO_NAME || fs37.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop");
|
|
114489
115247
|
}
|
|
114490
115248
|
async function tryPlayOnWindowsHost(file2) {
|
|
114491
115249
|
try {
|
|
114492
|
-
const here =
|
|
114493
|
-
const devAssets =
|
|
114494
|
-
const resolved =
|
|
114495
|
-
const inDist = resolved === here || resolved.startsWith(here +
|
|
114496
|
-
const inAssets = resolved === devAssets || resolved.startsWith(devAssets +
|
|
115250
|
+
const here = path44.dirname(fileURLToPath5(import.meta.url));
|
|
115251
|
+
const devAssets = path44.resolve(here, "..", "assets");
|
|
115252
|
+
const resolved = path44.resolve(file2);
|
|
115253
|
+
const inDist = resolved === here || resolved.startsWith(here + path44.sep);
|
|
115254
|
+
const inAssets = resolved === devAssets || resolved.startsWith(devAssets + path44.sep);
|
|
114497
115255
|
if (!inDist && !inAssets) {
|
|
114498
115256
|
return false;
|
|
114499
115257
|
}
|
|
@@ -114557,7 +115315,7 @@ async function tryPlayOnWindowsHost(file2) {
|
|
|
114557
115315
|
}
|
|
114558
115316
|
}
|
|
114559
115317
|
async function playFile(file2) {
|
|
114560
|
-
if (!
|
|
115318
|
+
if (!fs37.existsSync(file2)) return;
|
|
114561
115319
|
const platform2 = process.platform;
|
|
114562
115320
|
if (platform2 === "darwin") {
|
|
114563
115321
|
await trySpawn("afplay", [file2]);
|
|
@@ -114655,37 +115413,37 @@ function truncateOversizedToolResults2(messages, opts = {}) {
|
|
|
114655
115413
|
|
|
114656
115414
|
// src/sessions.ts
|
|
114657
115415
|
init_esm_shims();
|
|
114658
|
-
import
|
|
114659
|
-
import
|
|
115416
|
+
import fs38 from "fs/promises";
|
|
115417
|
+
import path45 from "path";
|
|
114660
115418
|
import crypto11 from "crypto";
|
|
114661
115419
|
var BOSS_SUBDIR = "boss";
|
|
114662
115420
|
var SESSIONS_SUBDIR = "sessions";
|
|
114663
115421
|
function getBossDir() {
|
|
114664
|
-
return
|
|
115422
|
+
return path45.join(getAppPaths().agentDir, BOSS_SUBDIR);
|
|
114665
115423
|
}
|
|
114666
115424
|
function getSessionsDir() {
|
|
114667
|
-
return
|
|
115425
|
+
return path45.join(getBossDir(), SESSIONS_SUBDIR);
|
|
114668
115426
|
}
|
|
114669
115427
|
async function ensureSessionsDir() {
|
|
114670
115428
|
const dir = getSessionsDir();
|
|
114671
|
-
await
|
|
115429
|
+
await fs38.mkdir(dir, { recursive: true, mode: 448 });
|
|
114672
115430
|
return dir;
|
|
114673
115431
|
}
|
|
114674
115432
|
async function createSession2() {
|
|
114675
115433
|
await ensureSessionsDir();
|
|
114676
115434
|
const id2 = `${Date.now()}-${crypto11.randomBytes(4).toString("hex")}`;
|
|
114677
|
-
const filePath =
|
|
114678
|
-
await
|
|
115435
|
+
const filePath = path45.join(getSessionsDir(), `${id2}.jsonl`);
|
|
115436
|
+
await fs38.writeFile(filePath, "", "utf-8");
|
|
114679
115437
|
return { id: id2, filePath };
|
|
114680
115438
|
}
|
|
114681
115439
|
async function appendMessages(filePath, msgs) {
|
|
114682
115440
|
if (msgs.length === 0) return;
|
|
114683
115441
|
const lines = msgs.map((m) => JSON.stringify(m)).join("\n") + "\n";
|
|
114684
|
-
await
|
|
115442
|
+
await fs38.appendFile(filePath, lines, "utf-8");
|
|
114685
115443
|
}
|
|
114686
115444
|
async function loadSession2(filePath) {
|
|
114687
115445
|
try {
|
|
114688
|
-
const content = await
|
|
115446
|
+
const content = await fs38.readFile(filePath, "utf-8");
|
|
114689
115447
|
const lines = content.split("\n").filter((l) => l.length > 0);
|
|
114690
115448
|
const messages = [];
|
|
114691
115449
|
for (const line of lines) {
|
|
@@ -114701,8 +115459,8 @@ async function loadSession2(filePath) {
|
|
|
114701
115459
|
}
|
|
114702
115460
|
async function inspectSession(filePath, id2) {
|
|
114703
115461
|
try {
|
|
114704
|
-
const stat = await
|
|
114705
|
-
const content = await
|
|
115462
|
+
const stat = await fs38.stat(filePath);
|
|
115463
|
+
const content = await fs38.readFile(filePath, "utf-8");
|
|
114706
115464
|
const lines = content.split("\n").filter((l) => l.length > 0);
|
|
114707
115465
|
let firstUserMessage;
|
|
114708
115466
|
for (const line of lines) {
|
|
@@ -114735,7 +115493,7 @@ async function listSessions2() {
|
|
|
114735
115493
|
await ensureSessionsDir();
|
|
114736
115494
|
let entries;
|
|
114737
115495
|
try {
|
|
114738
|
-
entries = await
|
|
115496
|
+
entries = await fs38.readdir(getSessionsDir());
|
|
114739
115497
|
} catch {
|
|
114740
115498
|
return [];
|
|
114741
115499
|
}
|
|
@@ -114743,7 +115501,7 @@ async function listSessions2() {
|
|
|
114743
115501
|
for (const name of entries) {
|
|
114744
115502
|
if (!name.endsWith(".jsonl")) continue;
|
|
114745
115503
|
const id2 = name.replace(/\.jsonl$/, "");
|
|
114746
|
-
const info = await inspectSession(
|
|
115504
|
+
const info = await inspectSession(path45.join(getSessionsDir(), name), id2);
|
|
114747
115505
|
if (info) infos.push(info);
|
|
114748
115506
|
}
|
|
114749
115507
|
infos.sort((a, b) => b.lastModified - a.lastModified);
|
|
@@ -114754,7 +115512,7 @@ async function getMostRecent() {
|
|
|
114754
115512
|
return all[0] ?? null;
|
|
114755
115513
|
}
|
|
114756
115514
|
async function getSessionById(id2) {
|
|
114757
|
-
const filePath =
|
|
115515
|
+
const filePath = path45.join(getSessionsDir(), `${id2}.jsonl`);
|
|
114758
115516
|
return inspectSession(filePath, id2);
|
|
114759
115517
|
}
|
|
114760
115518
|
|
|
@@ -115573,6 +116331,7 @@ export {
|
|
|
115573
116331
|
MessageResponse,
|
|
115574
116332
|
ToolExecution,
|
|
115575
116333
|
ToolGroupExecution,
|
|
116334
|
+
discoverProjects,
|
|
115576
116335
|
bossToolGroupRenderers,
|
|
115577
116336
|
useBossState,
|
|
115578
116337
|
subscribeToBossStore,
|
|
@@ -115708,4 +116467,4 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
115708
116467
|
* LICENSE file in the root directory of this source tree.
|
|
115709
116468
|
*)
|
|
115710
116469
|
*/
|
|
115711
|
-
//# sourceMappingURL=chunk-
|
|
116470
|
+
//# sourceMappingURL=chunk-D3OOVNMX.js.map
|