agentschat-mcp 0.36.26 → 0.36.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/codex/README.md +3 -3
- package/codex/app-server.ts +25 -3
- package/codex/bots-config.ts +3 -2
- package/codex/bridge.ts +7 -6
- package/codex/config.ts +13 -4
- package/codex/inbox-sync.ts +14 -2
- package/codex/loop-grants.ts +13 -5
- package/codex/manager.ts +8 -3
- package/codex/owner.ts +28 -3
- package/codex/runtime-home.ts +11 -1
- package/codex/thread-history.ts +13 -3
- package/codex/transport.ts +14 -4
- package/connector/README.md +1 -1
- package/cordis.patch.yml +4 -2
- package/dist/codex-bots.js +39 -14
- package/dist/codex-bridge.js +150 -41
- package/dist/connector.js +17 -3
- package/dist/dsh.js +18 -5
- package/dist/server.js +191 -48
- package/dsh/README.md +1 -1
- package/dsh/inbound-bridge/index.js +83 -9
- package/dsh/tests/dsh.test.ts +194 -10
- package/package.json +3 -3
- package/skills/onboarding.md +6 -6
- package/src/cli.mjs +2 -2
- package/src/grok-bind.ts +24 -2
- package/src/profile-selection.ts +36 -6
- package/src/profile-store.ts +27 -3
- package/src/read-cursor.ts +28 -4
- package/src/server.ts +1 -1
- package/src/session-bind.ts +58 -14
package/dist/connector.js
CHANGED
|
@@ -744,8 +744,17 @@ import {
|
|
|
744
744
|
import { dirname, isAbsolute, join, parse, resolve, sep } from "path";
|
|
745
745
|
var MAX_CURSOR_BYTES = 4 * 1024 * 1024;
|
|
746
746
|
var MAX_CURSOR_ENTRIES = 50000;
|
|
747
|
-
var
|
|
747
|
+
var MAX_CURSOR_PATH_LEN = 4096;
|
|
748
|
+
var RESERVED_PROTO_KEYS = new Set([
|
|
749
|
+
"__proto__",
|
|
750
|
+
"constructor",
|
|
751
|
+
"prototype",
|
|
752
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
753
|
+
]);
|
|
748
754
|
var tmpCounter = 0;
|
|
755
|
+
function isReservedCursorKey(key) {
|
|
756
|
+
return RESERVED_PROTO_KEYS.has(key.toLowerCase());
|
|
757
|
+
}
|
|
749
758
|
function scrubDiag(value) {
|
|
750
759
|
return redactSecrets(String(value ?? "")).replace(/\b(https?:\/\/)([^/\s@]*@)/gi, "$1[REDACTED]@").replace(/\b(?:Bearer|Basic)\s+[^\s"'<>\\]+/gi, "[REDACTED]").replace(/(?:ac_|mcp_at_|mcp_rt_|mcp_|agent_key_|sk-|rk_live_|rk_test_|whsec_|gh[pousr]_|github_pat_|glpat-|xox[baprs]-|hf_|npm_|mr_|AIza|AKIA|ASIA)[A-Za-z0-9+/=._-]{8,}/g, "[REDACTED]").replace(/[\x00-\x1f\x7f-\x9f\u2028\u2029]/g, " ");
|
|
751
760
|
}
|
|
@@ -842,7 +851,7 @@ function loadCursor(file, warn) {
|
|
|
842
851
|
}
|
|
843
852
|
const entries = [];
|
|
844
853
|
for (const [k, v] of Object.entries(parsed)) {
|
|
845
|
-
if (
|
|
854
|
+
if (isReservedCursorKey(k))
|
|
846
855
|
continue;
|
|
847
856
|
if (typeof v !== "string") {
|
|
848
857
|
throw new Error(`cursor value for ${scrubDiag(k)} must be a string`);
|
|
@@ -865,6 +874,11 @@ function loadCursor(file, warn) {
|
|
|
865
874
|
}
|
|
866
875
|
}
|
|
867
876
|
function persistCursor(file, cursor, warn, fsOps) {
|
|
877
|
+
if (typeof file !== "string" || !file || file.length > MAX_CURSOR_PATH_LEN || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(file)) {
|
|
878
|
+
warn(`[agentchat] WARNING: failed to persist read cursor to ${scrubDiag(file)}: invalid cursor file path
|
|
879
|
+
`);
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
868
882
|
try {
|
|
869
883
|
const parentStat = lstatSync(dirname(file));
|
|
870
884
|
if (parentStat.isSymbolicLink() || !parentStat.isDirectory() || !hasSafeAncestorDirs(file)) {
|
|
@@ -893,7 +907,7 @@ function persistCursor(file, cursor, warn, fsOps) {
|
|
|
893
907
|
}
|
|
894
908
|
const validEntries = [];
|
|
895
909
|
for (const [k, v] of cursor) {
|
|
896
|
-
if (!k || k.length > 256 ||
|
|
910
|
+
if (!k || k.length > 256 || isReservedCursorKey(k) || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(k) || typeof v !== "string" || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(v) || v.length > 256) {
|
|
897
911
|
continue;
|
|
898
912
|
}
|
|
899
913
|
validEntries.push([k, v]);
|
package/dist/dsh.js
CHANGED
|
@@ -1022,6 +1022,12 @@ import { isAbsolute as isAbsolute2, join as join2, parse, resolve } from "node:p
|
|
|
1022
1022
|
|
|
1023
1023
|
// src/profile-store.ts
|
|
1024
1024
|
var MAX_PROFILE_JSON_BYTES = 64 * 1024;
|
|
1025
|
+
var RESERVED_PROTO_STEMS = new Set([
|
|
1026
|
+
"__proto__",
|
|
1027
|
+
"constructor",
|
|
1028
|
+
"prototype",
|
|
1029
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
1030
|
+
]);
|
|
1025
1031
|
var DARWIN_SYSTEM_SYMLINKS = new Set(["/var", "/tmp", "/etc"]);
|
|
1026
1032
|
var NON_PROFILE_JSON_FILES = new Set([
|
|
1027
1033
|
"session-binds.json",
|
|
@@ -1057,6 +1063,13 @@ var LOCK_FILE_MAX_BYTES = 64 * 1024;
|
|
|
1057
1063
|
var SESSION_BINDS_MAX_BYTES = 1024 * 1024;
|
|
1058
1064
|
var MAX_SESSION_BINDS_ENTRIES = 1024;
|
|
1059
1065
|
var CONTROL_CHAR_RE = /[\x00-\x1f\x7f-\x9f\u2028\u2029]/;
|
|
1066
|
+
var WINDOWS_DEVICE_STEM_RE = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
1067
|
+
var UNSAFE_BIND_KEYS = new Set([
|
|
1068
|
+
"__proto__",
|
|
1069
|
+
"constructor",
|
|
1070
|
+
"prototype",
|
|
1071
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
1072
|
+
]);
|
|
1060
1073
|
var RESERVED_BIND_SIDECARS = new Set([
|
|
1061
1074
|
"session-binds",
|
|
1062
1075
|
"session-binds.meta",
|
|
@@ -1168,16 +1181,16 @@ function isValidBindToken(value) {
|
|
|
1168
1181
|
return value.length > 0 && value.length <= 256 && !CONTROL_CHAR_RE.test(value);
|
|
1169
1182
|
}
|
|
1170
1183
|
function isValidBoundProfileName(value) {
|
|
1171
|
-
if (!isValidBindToken(value) || value === "." || value
|
|
1184
|
+
if (!isValidBindToken(value) || value === "." || value.includes("..") || value.includes("/") || value.includes("\\")) {
|
|
1172
1185
|
return false;
|
|
1173
1186
|
}
|
|
1174
|
-
const
|
|
1187
|
+
const rawStem = value.replace(/\.json$/i, "");
|
|
1188
|
+
const stem = rawStem.toLowerCase();
|
|
1175
1189
|
const normalizedStem = stem.replace(/[^a-z0-9_-]/g, "_");
|
|
1176
|
-
return Boolean(stem) && !isUnsafeBindKey(value) && !isUnsafeBindKey(stem) && !RESERVED_BIND_SIDECARS.has(stem) && !RESERVED_BIND_SIDECARS.has(normalizedStem);
|
|
1190
|
+
return Boolean(stem) && !WINDOWS_DEVICE_STEM_RE.test(rawStem) && !isUnsafeBindKey(value) && !isUnsafeBindKey(stem) && !RESERVED_BIND_SIDECARS.has(stem) && !RESERVED_BIND_SIDECARS.has(normalizedStem);
|
|
1177
1191
|
}
|
|
1178
1192
|
function isUnsafeBindKey(key) {
|
|
1179
|
-
|
|
1180
|
-
return lower === "__proto__" || lower === "constructor" || lower === "prototype";
|
|
1193
|
+
return UNSAFE_BIND_KEYS.has(key.toLowerCase());
|
|
1181
1194
|
}
|
|
1182
1195
|
function parseSessionBinds(raw) {
|
|
1183
1196
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
package/dist/server.js
CHANGED
|
@@ -2030,16 +2030,38 @@ var FORBIDDEN_CREDENTIAL_KEYS = new Set([
|
|
|
2030
2030
|
"bearer",
|
|
2031
2031
|
"cookie"
|
|
2032
2032
|
]);
|
|
2033
|
-
var PROTOTYPE_KEYS = new Set([
|
|
2033
|
+
var PROTOTYPE_KEYS = new Set([
|
|
2034
|
+
"__proto__",
|
|
2035
|
+
"constructor",
|
|
2036
|
+
"prototype",
|
|
2037
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
2038
|
+
]);
|
|
2039
|
+
var WINDOWS_DEVICE_STEM_RE = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
2034
2040
|
var RESERVED_SIDECAR_STEMS = new Set([
|
|
2035
2041
|
"grok-binds",
|
|
2042
|
+
"grok-binds.meta",
|
|
2043
|
+
"grok-binds-meta",
|
|
2044
|
+
"grok-binds_meta",
|
|
2036
2045
|
"session-binds",
|
|
2046
|
+
"session-binds.meta",
|
|
2047
|
+
"session-binds-meta",
|
|
2048
|
+
"session-binds_meta",
|
|
2037
2049
|
"agy-binds",
|
|
2050
|
+
"agy-binds.meta",
|
|
2051
|
+
"agy-binds-meta",
|
|
2052
|
+
"agy-binds_meta",
|
|
2053
|
+
"agy-session-binds",
|
|
2054
|
+
"agy-session-binds.meta",
|
|
2055
|
+
"agy-session-binds_meta",
|
|
2056
|
+
"identity-guard",
|
|
2038
2057
|
"cursor",
|
|
2039
2058
|
"read-cursors",
|
|
2059
|
+
"mention-timestamps",
|
|
2040
2060
|
"wake-pids",
|
|
2041
2061
|
"config",
|
|
2042
|
-
"codex-bots"
|
|
2062
|
+
"codex-bots",
|
|
2063
|
+
"dsh",
|
|
2064
|
+
"muse"
|
|
2043
2065
|
]);
|
|
2044
2066
|
function safeLstat(target) {
|
|
2045
2067
|
try {
|
|
@@ -2141,9 +2163,13 @@ function isUnsafeMetadataOrLinkLocalHost(hostname) {
|
|
|
2141
2163
|
}
|
|
2142
2164
|
if (/^fe[89ab][0-9a-f]*:/.test(lower))
|
|
2143
2165
|
return true;
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
const
|
|
2166
|
+
const mappedPrefix = lower.match(/^(?:::ffff:|0:0:0:0:0:ffff:|0:0:0:0:ffff:0:)(.+)$/);
|
|
2167
|
+
if (mappedPrefix) {
|
|
2168
|
+
const tail = mappedPrefix[1];
|
|
2169
|
+
if (/^[0-9a-f]{1,4}$/.test(tail))
|
|
2170
|
+
return true;
|
|
2171
|
+
const zeroMatch = tail.match(/^0+:(.+)$/);
|
|
2172
|
+
const afterZero = zeroMatch ? zeroMatch[1] : "";
|
|
2147
2173
|
const tailParts = afterZero && (afterZero.includes(".") || afterZero.includes(":")) ? afterZero : tail;
|
|
2148
2174
|
if (tailParts === "0.0.0.0" || tailParts === "100.100.100.200" || /^0\.\d+\.\d+\.\d+$/.test(tailParts))
|
|
2149
2175
|
return true;
|
|
@@ -2228,8 +2254,10 @@ function projectProfileSelector(cwd) {
|
|
|
2228
2254
|
};
|
|
2229
2255
|
if (doc.profile !== undefined) {
|
|
2230
2256
|
const value = doc.profile.trim();
|
|
2231
|
-
const
|
|
2232
|
-
|
|
2257
|
+
const basePart = value.replace(/\\/g, "/").split("/").pop() || "";
|
|
2258
|
+
const stemLower = basePart.replace(/\.json$/i, "").toLowerCase();
|
|
2259
|
+
const isBareName = !value.includes("/") && !value.includes("\\");
|
|
2260
|
+
if (value === "." || value === ".." || isBareName && value.includes("..") || !stemLower || PROTOTYPE_KEYS.has(stemLower) || WINDOWS_DEVICE_STEM_RE.test(stemLower) || isBareName && RESERVED_SIDECAR_STEMS.has(stemLower)) {
|
|
2233
2261
|
throw new Error("Invalid project profile");
|
|
2234
2262
|
}
|
|
2235
2263
|
if (value.startsWith("~/") || value.startsWith("~\\")) {
|
|
@@ -2270,7 +2298,17 @@ function projectProfileSelector(cwd) {
|
|
|
2270
2298
|
import { join as join2 } from "node:path";
|
|
2271
2299
|
var DEFAULT_GROK_BINDS_FILENAME = "grok-binds.json";
|
|
2272
2300
|
var GROK_BINDS_META_FILENAME = "grok-binds.meta.json";
|
|
2301
|
+
var UNSAFE_GROK_OBJECT_KEYS = new Set([
|
|
2302
|
+
"__proto__",
|
|
2303
|
+
"constructor",
|
|
2304
|
+
"prototype",
|
|
2305
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
2306
|
+
]);
|
|
2307
|
+
var WINDOWS_DEVICE_STEM_RE2 = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
2273
2308
|
function isUnsafeObjectKey(key) {
|
|
2309
|
+
return UNSAFE_GROK_OBJECT_KEYS.has(key.toLowerCase());
|
|
2310
|
+
}
|
|
2311
|
+
function isUnsafeProtoSlot(key) {
|
|
2274
2312
|
const lower = key.toLowerCase();
|
|
2275
2313
|
return lower === "__proto__" || lower === "constructor" || lower === "prototype";
|
|
2276
2314
|
}
|
|
@@ -2290,16 +2328,24 @@ var RESERVED_BIND_BASENAMES = new Set([
|
|
|
2290
2328
|
"grok-binds",
|
|
2291
2329
|
"grok-binds-meta",
|
|
2292
2330
|
"grok-binds.meta",
|
|
2331
|
+
"grok-binds_meta",
|
|
2293
2332
|
"session-binds",
|
|
2294
2333
|
"session-binds.meta",
|
|
2334
|
+
"session-binds-meta",
|
|
2335
|
+
"session-binds_meta",
|
|
2295
2336
|
"agy-session-binds",
|
|
2337
|
+
"agy-session-binds.meta",
|
|
2338
|
+
"agy-session-binds_meta",
|
|
2296
2339
|
"agy-binds",
|
|
2297
2340
|
"agy-binds.meta",
|
|
2341
|
+
"agy-binds-meta",
|
|
2342
|
+
"agy-binds_meta",
|
|
2298
2343
|
"identity-guard",
|
|
2299
2344
|
"cursor",
|
|
2300
2345
|
"read-cursors",
|
|
2301
2346
|
"mention-timestamps",
|
|
2302
2347
|
"wake-pids",
|
|
2348
|
+
"codex-bots",
|
|
2303
2349
|
"dsh",
|
|
2304
2350
|
"config",
|
|
2305
2351
|
"muse"
|
|
@@ -2313,8 +2359,9 @@ function isSafeProfileBindName(name) {
|
|
|
2313
2359
|
if (isUnsafeObjectKey(name) || hasPathOrTraversalSyntax(name))
|
|
2314
2360
|
return false;
|
|
2315
2361
|
const base = name.replace(/\.json$/i, "").trim().toLowerCase();
|
|
2316
|
-
if (!base || isUnsafeObjectKey(base) || RESERVED_BIND_BASENAMES.has(base))
|
|
2362
|
+
if (!base || isUnsafeObjectKey(base) || WINDOWS_DEVICE_STEM_RE2.test(base) || RESERVED_BIND_BASENAMES.has(base)) {
|
|
2317
2363
|
return false;
|
|
2364
|
+
}
|
|
2318
2365
|
return true;
|
|
2319
2366
|
}
|
|
2320
2367
|
function parseGrokBinds(raw) {
|
|
@@ -2360,7 +2407,7 @@ function decideGrokBind(input) {
|
|
|
2360
2407
|
if (input.explicitIdentity || input.hasToken)
|
|
2361
2408
|
return { kind: "skip" };
|
|
2362
2409
|
const id = typeof input.conversationId === "string" ? input.conversationId.trim() : "";
|
|
2363
|
-
if (!id ||
|
|
2410
|
+
if (!id || isUnsafeProtoSlot(id) || hasControlChars(id))
|
|
2364
2411
|
return { kind: "skip" };
|
|
2365
2412
|
const binds = input.binds && typeof input.binds === "object" ? input.binds : {};
|
|
2366
2413
|
const profileName = Object.hasOwn(binds, id) ? binds[id] : undefined;
|
|
@@ -3342,10 +3389,17 @@ import {
|
|
|
3342
3389
|
import { dirname as dirname3, join as join4, resolve as resolve3 } from "path";
|
|
3343
3390
|
var defaultWarn = (m) => process.stderr.write(m);
|
|
3344
3391
|
var MAX_PROFILE_JSON_BYTES = 64 * 1024;
|
|
3392
|
+
var MAX_PROFILE_PATH_LEN = 4096;
|
|
3345
3393
|
var CONTROL_CHAR_GLOBAL_RE = /[\x00-\x1f\x7f-\x9f\u2028\u2029]/g;
|
|
3394
|
+
var RESERVED_PROTO_STEMS = new Set([
|
|
3395
|
+
"__proto__",
|
|
3396
|
+
"constructor",
|
|
3397
|
+
"prototype",
|
|
3398
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
3399
|
+
]);
|
|
3346
3400
|
var DARWIN_SYSTEM_SYMLINKS = new Set(["/var", "/tmp", "/etc"]);
|
|
3347
3401
|
function sanitizeWarnPart(value) {
|
|
3348
|
-
return redactSecrets2(String(value ?? "")).replace(/\b(https?:\/\/?)([^/\s@]*@)/gi, "$1[REDACTED]@").replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, "[REDACTED]").replace(
|
|
3402
|
+
return redactSecrets2(String(value ?? "")).replace(/\b(https?:\/\/?)([^/\s@]*@)/gi, "$1[REDACTED]@").replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, "[REDACTED]").replace(/(?:ac_|mcp_at_|mcp_rt_|mcp_|agent_key_|sk-|whsec_|rk_(?:live|test)_|gh[pousr]_|github_pat_|glpat-|xox[baprs]-|hf_|npm_|mr_|AIza|(?:AKIA|ASIA))[A-Za-z0-9_+/=.-]{8,}/g, "[REDACTED]").replace(CONTROL_CHAR_GLOBAL_RE, "?");
|
|
3349
3403
|
}
|
|
3350
3404
|
function safeLstat2(target) {
|
|
3351
3405
|
try {
|
|
@@ -3418,6 +3472,9 @@ function hasSafeAncestorDirs(targetPath) {
|
|
|
3418
3472
|
return true;
|
|
3419
3473
|
}
|
|
3420
3474
|
function safeWriteProfile(path, data, warn = defaultWarn) {
|
|
3475
|
+
if (typeof path !== "string" || !path || path.length > MAX_PROFILE_PATH_LEN || path.includes("\x00")) {
|
|
3476
|
+
throw new Error(`Refusing to write profile into invalid path: ${sanitizeWarnPart(path)}`);
|
|
3477
|
+
}
|
|
3421
3478
|
const parentDir = dirname3(path);
|
|
3422
3479
|
const parentStat = safeLstat2(parentDir);
|
|
3423
3480
|
if (!parentStat || parentStat.isSymbolicLink() || !parentStat.isDirectory() || !hasSafeAncestorDirs(path)) {
|
|
@@ -3427,6 +3484,9 @@ function safeWriteProfile(path, data, warn = defaultWarn) {
|
|
|
3427
3484
|
if (pathStat?.isSymbolicLink()) {
|
|
3428
3485
|
throw new Error(`Refusing to write profile through symlink: ${sanitizeWarnPart(path)}`);
|
|
3429
3486
|
}
|
|
3487
|
+
if (pathStat && !pathStat.isFile() && !pathStat.isDirectory()) {
|
|
3488
|
+
throw new Error(`Refusing to write profile into non-regular target: ${sanitizeWarnPart(path)}`);
|
|
3489
|
+
}
|
|
3430
3490
|
const tmp = path + ".tmp";
|
|
3431
3491
|
const tmpStat = safeLstat2(tmp);
|
|
3432
3492
|
if (tmpStat) {
|
|
@@ -3557,6 +3617,13 @@ var LOCK_KEY_MAX_CHARS = 128;
|
|
|
3557
3617
|
var SESSION_BINDS_MAX_BYTES = 1024 * 1024;
|
|
3558
3618
|
var MAX_SESSION_BINDS_ENTRIES = 1024;
|
|
3559
3619
|
var CONTROL_CHAR_RE = /[\x00-\x1f\x7f-\x9f\u2028\u2029]/;
|
|
3620
|
+
var WINDOWS_DEVICE_STEM_RE3 = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
3621
|
+
var UNSAFE_BIND_KEYS = new Set([
|
|
3622
|
+
"__proto__",
|
|
3623
|
+
"constructor",
|
|
3624
|
+
"prototype",
|
|
3625
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
3626
|
+
]);
|
|
3560
3627
|
var RESERVED_BIND_SIDECARS = new Set([
|
|
3561
3628
|
"session-binds",
|
|
3562
3629
|
"session-binds.meta",
|
|
@@ -3683,12 +3750,13 @@ function isValidBindToken(value) {
|
|
|
3683
3750
|
return value.length > 0 && value.length <= 256 && !CONTROL_CHAR_RE.test(value);
|
|
3684
3751
|
}
|
|
3685
3752
|
function isValidBoundProfileName(value) {
|
|
3686
|
-
if (!isValidBindToken(value) || value === "." || value
|
|
3753
|
+
if (!isValidBindToken(value) || value === "." || value.includes("..") || value.includes("/") || value.includes("\\")) {
|
|
3687
3754
|
return false;
|
|
3688
3755
|
}
|
|
3689
|
-
const
|
|
3756
|
+
const rawStem = value.replace(/\.json$/i, "");
|
|
3757
|
+
const stem = rawStem.toLowerCase();
|
|
3690
3758
|
const normalizedStem = stem.replace(/[^a-z0-9_-]/g, "_");
|
|
3691
|
-
return Boolean(stem) && !isUnsafeBindKey(value) && !isUnsafeBindKey(stem) && !RESERVED_BIND_SIDECARS.has(stem) && !RESERVED_BIND_SIDECARS.has(normalizedStem);
|
|
3759
|
+
return Boolean(stem) && !WINDOWS_DEVICE_STEM_RE3.test(rawStem) && !isUnsafeBindKey(value) && !isUnsafeBindKey(stem) && !RESERVED_BIND_SIDECARS.has(stem) && !RESERVED_BIND_SIDECARS.has(normalizedStem);
|
|
3692
3760
|
}
|
|
3693
3761
|
function lockFilePath(lockDir, agentId) {
|
|
3694
3762
|
const trimmed = String(agentId || "").trim();
|
|
@@ -3799,8 +3867,7 @@ function releaseAgentLock(opts) {
|
|
|
3799
3867
|
}
|
|
3800
3868
|
}
|
|
3801
3869
|
function isUnsafeBindKey(key) {
|
|
3802
|
-
|
|
3803
|
-
return lower === "__proto__" || lower === "constructor" || lower === "prototype";
|
|
3870
|
+
return UNSAFE_BIND_KEYS.has(key.toLowerCase());
|
|
3804
3871
|
}
|
|
3805
3872
|
function parseSessionBinds(raw) {
|
|
3806
3873
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
@@ -3843,13 +3910,14 @@ function loadSessionBinds(configDir) {
|
|
|
3843
3910
|
return merged;
|
|
3844
3911
|
}
|
|
3845
3912
|
function resolveAgentIdForProfileName(configDir, name) {
|
|
3846
|
-
if (!name || name === "." || name
|
|
3913
|
+
if (!name || name === "." || name.includes("..") || name.includes("/") || name.includes("\\") || CONTROL_CHAR_RE.test(name))
|
|
3847
3914
|
return null;
|
|
3848
3915
|
if (!isSafeDirOrMissing(configDir))
|
|
3849
3916
|
return null;
|
|
3850
|
-
const
|
|
3851
|
-
const
|
|
3852
|
-
|
|
3917
|
+
const rawStem = name.replace(/\.json$/i, "");
|
|
3918
|
+
const stem = rawStem.toLowerCase();
|
|
3919
|
+
const base = rawStem.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3920
|
+
if (!base || base.length > LOCK_KEY_MAX_CHARS || WINDOWS_DEVICE_STEM_RE3.test(rawStem) || WINDOWS_DEVICE_STEM_RE3.test(base) || isUnsafeBindKey(base) || RESERVED_BIND_SIDECARS.has(stem) || RESERVED_BIND_SIDECARS.has(base.toLowerCase())) {
|
|
3853
3921
|
return null;
|
|
3854
3922
|
}
|
|
3855
3923
|
const profilesDir = join5(configDir, "profiles");
|
|
@@ -3954,7 +4022,7 @@ function findBoundSessionForProfile(configDir, profileName, filter) {
|
|
|
3954
4022
|
return matches.length > 0 ? matches[matches.length - 1] : null;
|
|
3955
4023
|
}
|
|
3956
4024
|
function isSafeDetectedSessionId(sid) {
|
|
3957
|
-
return isValidBindToken(sid) && sid !== "." && sid
|
|
4025
|
+
return isValidBindToken(sid) && sid !== "." && !sid.includes("..") && !sid.includes("/") && !sid.includes("\\") && !isUnsafeBindKey(sid);
|
|
3958
4026
|
}
|
|
3959
4027
|
function cleanDetectedWorkspacePath(raw) {
|
|
3960
4028
|
if (typeof raw !== "string")
|
|
@@ -3965,6 +4033,9 @@ function cleanDetectedWorkspacePath(raw) {
|
|
|
3965
4033
|
return s;
|
|
3966
4034
|
}
|
|
3967
4035
|
function detectRuntimeSession(env = process.env, meta) {
|
|
4036
|
+
if (env.AGENTSCHAT_DSH_HEALTH_URL?.trim() || env.AGENTSCHAT_DSH_HOME?.trim()) {
|
|
4037
|
+
return null;
|
|
4038
|
+
}
|
|
3968
4039
|
const zcodeCtx = meta?.["com.zcode/request-context"];
|
|
3969
4040
|
const metaSessionId = typeof meta?.session_id === "string" && meta.session_id.trim() || typeof zcodeCtx?.session_id === "string" && zcodeCtx.session_id.trim() || "";
|
|
3970
4041
|
if (isSafeDetectedSessionId(metaSessionId)) {
|
|
@@ -4197,6 +4268,9 @@ function discoverWindowsAntigravityHost(currentPid) {
|
|
|
4197
4268
|
}
|
|
4198
4269
|
function discoverAntigravityHost(opts) {
|
|
4199
4270
|
if (!opts?.currentPid) {
|
|
4271
|
+
if (process.env.AGENTSCHAT_DSH_HEALTH_URL?.trim() || process.env.AGENTSCHAT_DSH_HOME?.trim() || process.env.DSH_HOME?.trim()) {
|
|
4272
|
+
return null;
|
|
4273
|
+
}
|
|
4200
4274
|
const envAddr = process.env.ANTIGRAVITY_LS_ADDRESS?.trim() || "";
|
|
4201
4275
|
const envCsrf = process.env.ANTIGRAVITY_CSRF_TOKEN?.trim() || "";
|
|
4202
4276
|
if (envAddr && envCsrf) {
|
|
@@ -4211,8 +4285,10 @@ function discoverAntigravityHost(opts) {
|
|
|
4211
4285
|
}
|
|
4212
4286
|
}
|
|
4213
4287
|
const now = Date.now();
|
|
4214
|
-
const cacheMs = opts?.cacheMs
|
|
4215
|
-
if (cachedAgyHost && now
|
|
4288
|
+
const cacheMs = typeof opts?.cacheMs === "number" && Number.isFinite(opts.cacheMs) && opts.cacheMs >= 0 ? opts.cacheMs : 5000;
|
|
4289
|
+
if (cachedAgyHost && now < cachedAgyHost.at)
|
|
4290
|
+
cachedAgyHost = null;
|
|
4291
|
+
if (cachedAgyHost && now - cachedAgyHost.at < cacheMs)
|
|
4216
4292
|
return cachedAgyHost.info;
|
|
4217
4293
|
try {
|
|
4218
4294
|
const startPid = opts?.currentPid ?? process.pid;
|
|
@@ -4234,7 +4310,7 @@ function discoverAntigravityHost(opts) {
|
|
|
4234
4310
|
break;
|
|
4235
4311
|
const ppid = Number(m[1]);
|
|
4236
4312
|
const cmd = m[2];
|
|
4237
|
-
if (hop > 0 && (cmd.includes("bun test") || cmd.includes("node --test")))
|
|
4313
|
+
if (hop > 0 && (cmd.includes("bun test") || cmd.includes("node --test") || matchesDshCommandLine(cmd)))
|
|
4238
4314
|
break;
|
|
4239
4315
|
if (cmd.includes("language_server") && cmd.includes("--csrf_token")) {
|
|
4240
4316
|
lsPid = pid;
|
|
@@ -4367,7 +4443,7 @@ function detectAntigravityCallerSession(opts) {
|
|
|
4367
4443
|
}
|
|
4368
4444
|
var cachedIsDshHost = null;
|
|
4369
4445
|
function matchesDshCommandLine(cmd) {
|
|
4370
|
-
return cmd.includes("@deepseek-ai") || cmd.includes("/.dsh/") || cmd.toLowerCase().includes("\\.dsh\\") || /\bdsh(?:\.cmd|\.exe)?\b/i.test(cmd);
|
|
4446
|
+
return cmd.includes("@deepseek-ai") || cmd.includes("/.dsh/") || cmd.toLowerCase().includes("\\.dsh\\") || /deepseek[- ]harness/i.test(cmd) || /\bdsh(?:\.cmd|\.exe)?\b/i.test(cmd);
|
|
4371
4447
|
}
|
|
4372
4448
|
function isDshHostProcess(opts) {
|
|
4373
4449
|
const env = opts?.env ?? process.env;
|
|
@@ -4375,8 +4451,10 @@ function isDshHostProcess(opts) {
|
|
|
4375
4451
|
return true;
|
|
4376
4452
|
}
|
|
4377
4453
|
const now = Date.now();
|
|
4378
|
-
const cacheMs = opts?.cacheMs
|
|
4379
|
-
if (cachedIsDshHost && now
|
|
4454
|
+
const cacheMs = typeof opts?.cacheMs === "number" && Number.isFinite(opts.cacheMs) && opts.cacheMs >= 0 ? opts.cacheMs : 15000;
|
|
4455
|
+
if (cachedIsDshHost && now < cachedIsDshHost.at)
|
|
4456
|
+
cachedIsDshHost = null;
|
|
4457
|
+
if (cachedIsDshHost && now - cachedIsDshHost.at < cacheMs)
|
|
4380
4458
|
return cachedIsDshHost.value;
|
|
4381
4459
|
try {
|
|
4382
4460
|
let pid = opts?.currentPid ?? process.pid;
|
|
@@ -4522,7 +4600,15 @@ function sessionDirMtime(dir) {
|
|
|
4522
4600
|
if (!dirStat || dirStat.isSymbolicLink() || !dirStat.isDirectory())
|
|
4523
4601
|
return 0;
|
|
4524
4602
|
let newest = 0;
|
|
4525
|
-
|
|
4603
|
+
let entries = [];
|
|
4604
|
+
try {
|
|
4605
|
+
entries = readdirSync2(dir);
|
|
4606
|
+
} catch {
|
|
4607
|
+
entries = ["session.v4.jsonl.zstd", "session.v4.jsonl"];
|
|
4608
|
+
}
|
|
4609
|
+
for (const file of entries) {
|
|
4610
|
+
if (!/^session(?:\.v\d+)?\.jsonl(?:\.zstd)?$/.test(file))
|
|
4611
|
+
continue;
|
|
4526
4612
|
const st = safeLstat3(join5(dir, file));
|
|
4527
4613
|
if (st && !st.isSymbolicLink() && st.isFile() && st.mtimeMs > newest) {
|
|
4528
4614
|
newest = st.mtimeMs;
|
|
@@ -4656,6 +4742,13 @@ var LOCK_FILE_MAX_BYTES2 = 64 * 1024;
|
|
|
4656
4742
|
var SESSION_BINDS_MAX_BYTES2 = 1024 * 1024;
|
|
4657
4743
|
var MAX_SESSION_BINDS_ENTRIES2 = 1024;
|
|
4658
4744
|
var CONTROL_CHAR_RE2 = /[\x00-\x1f\x7f-\x9f\u2028\u2029]/;
|
|
4745
|
+
var WINDOWS_DEVICE_STEM_RE4 = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
4746
|
+
var UNSAFE_BIND_KEYS2 = new Set([
|
|
4747
|
+
"__proto__",
|
|
4748
|
+
"constructor",
|
|
4749
|
+
"prototype",
|
|
4750
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
4751
|
+
]);
|
|
4659
4752
|
var RESERVED_BIND_SIDECARS2 = new Set([
|
|
4660
4753
|
"session-binds",
|
|
4661
4754
|
"session-binds.meta",
|
|
@@ -4767,16 +4860,16 @@ function isValidBindToken2(value) {
|
|
|
4767
4860
|
return value.length > 0 && value.length <= 256 && !CONTROL_CHAR_RE2.test(value);
|
|
4768
4861
|
}
|
|
4769
4862
|
function isValidBoundProfileName2(value) {
|
|
4770
|
-
if (!isValidBindToken2(value) || value === "." || value
|
|
4863
|
+
if (!isValidBindToken2(value) || value === "." || value.includes("..") || value.includes("/") || value.includes("\\")) {
|
|
4771
4864
|
return false;
|
|
4772
4865
|
}
|
|
4773
|
-
const
|
|
4866
|
+
const rawStem = value.replace(/\.json$/i, "");
|
|
4867
|
+
const stem = rawStem.toLowerCase();
|
|
4774
4868
|
const normalizedStem = stem.replace(/[^a-z0-9_-]/g, "_");
|
|
4775
|
-
return Boolean(stem) && !isUnsafeBindKey2(value) && !isUnsafeBindKey2(stem) && !RESERVED_BIND_SIDECARS2.has(stem) && !RESERVED_BIND_SIDECARS2.has(normalizedStem);
|
|
4869
|
+
return Boolean(stem) && !WINDOWS_DEVICE_STEM_RE4.test(rawStem) && !isUnsafeBindKey2(value) && !isUnsafeBindKey2(stem) && !RESERVED_BIND_SIDECARS2.has(stem) && !RESERVED_BIND_SIDECARS2.has(normalizedStem);
|
|
4776
4870
|
}
|
|
4777
4871
|
function isUnsafeBindKey2(key) {
|
|
4778
|
-
|
|
4779
|
-
return lower === "__proto__" || lower === "constructor" || lower === "prototype";
|
|
4872
|
+
return UNSAFE_BIND_KEYS2.has(key.toLowerCase());
|
|
4780
4873
|
}
|
|
4781
4874
|
function parseSessionBinds2(raw) {
|
|
4782
4875
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
@@ -5099,7 +5192,7 @@ class HeartbeatMonitor {
|
|
|
5099
5192
|
var package_default = {
|
|
5100
5193
|
name: "agentschat-mcp",
|
|
5101
5194
|
mcpName: "io.github.swswordholy-tech/agentschat-mcp",
|
|
5102
|
-
version: "0.36.
|
|
5195
|
+
version: "0.36.27",
|
|
5103
5196
|
description: "Connect Claude Code to AgentsChat — AI Agent social network. Core tools stay lean while extended tool groups load on demand for lower token overhead and cleaner role-specific context.",
|
|
5104
5197
|
type: "module",
|
|
5105
5198
|
bin: {
|
|
@@ -5169,7 +5262,7 @@ var package_default = {
|
|
|
5169
5262
|
license: "Apache-2.0",
|
|
5170
5263
|
repository: {
|
|
5171
5264
|
type: "git",
|
|
5172
|
-
url: "git+https://github.com/swswordholy-tech/
|
|
5265
|
+
url: "git+https://github.com/swswordholy-tech/AgentsChat.git",
|
|
5173
5266
|
directory: "mcp-plugin"
|
|
5174
5267
|
},
|
|
5175
5268
|
homepage: "https://agents-chat.com/",
|
|
@@ -5266,10 +5359,19 @@ import {
|
|
|
5266
5359
|
import { dirname as dirname5, join as join8, resolve as resolve7 } from "path";
|
|
5267
5360
|
var defaultWarn2 = (m) => process.stderr.write(m);
|
|
5268
5361
|
var MAX_PROFILE_JSON_BYTES2 = 64 * 1024;
|
|
5362
|
+
var MAX_PROFILE_PATH_LEN2 = 4096;
|
|
5363
|
+
var CONTROL_CHAR_RE3 = /[\x00-\x1f\x7f-\x9f\u2028\u2029]/;
|
|
5269
5364
|
var CONTROL_CHAR_GLOBAL_RE2 = /[\x00-\x1f\x7f-\x9f\u2028\u2029]/g;
|
|
5365
|
+
var WINDOWS_DEVICE_STEM_RE5 = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
5366
|
+
var RESERVED_PROTO_STEMS2 = new Set([
|
|
5367
|
+
"__proto__",
|
|
5368
|
+
"constructor",
|
|
5369
|
+
"prototype",
|
|
5370
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
5371
|
+
]);
|
|
5270
5372
|
var DARWIN_SYSTEM_SYMLINKS2 = new Set(["/var", "/tmp", "/etc"]);
|
|
5271
5373
|
function sanitizeWarnPart2(value) {
|
|
5272
|
-
return redactSecrets2(String(value ?? "")).replace(/\b(https?:\/\/?)([^/\s@]*@)/gi, "$1[REDACTED]@").replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, "[REDACTED]").replace(
|
|
5374
|
+
return redactSecrets2(String(value ?? "")).replace(/\b(https?:\/\/?)([^/\s@]*@)/gi, "$1[REDACTED]@").replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, "[REDACTED]").replace(/(?:ac_|mcp_at_|mcp_rt_|mcp_|agent_key_|sk-|whsec_|rk_(?:live|test)_|gh[pousr]_|github_pat_|glpat-|xox[baprs]-|hf_|npm_|mr_|AIza|(?:AKIA|ASIA))[A-Za-z0-9_+/=.-]{8,}/g, "[REDACTED]").replace(CONTROL_CHAR_GLOBAL_RE2, "?");
|
|
5273
5375
|
}
|
|
5274
5376
|
function safeLstat4(target) {
|
|
5275
5377
|
try {
|
|
@@ -5342,6 +5444,9 @@ function hasSafeAncestorDirs2(targetPath) {
|
|
|
5342
5444
|
return true;
|
|
5343
5445
|
}
|
|
5344
5446
|
function safeWriteProfile2(path, data, warn = defaultWarn2) {
|
|
5447
|
+
if (typeof path !== "string" || !path || path.length > MAX_PROFILE_PATH_LEN2 || path.includes("\x00")) {
|
|
5448
|
+
throw new Error(`Refusing to write profile into invalid path: ${sanitizeWarnPart2(path)}`);
|
|
5449
|
+
}
|
|
5345
5450
|
const parentDir = dirname5(path);
|
|
5346
5451
|
const parentStat = safeLstat4(parentDir);
|
|
5347
5452
|
if (!parentStat || parentStat.isSymbolicLink() || !parentStat.isDirectory() || !hasSafeAncestorDirs2(path)) {
|
|
@@ -5351,6 +5456,9 @@ function safeWriteProfile2(path, data, warn = defaultWarn2) {
|
|
|
5351
5456
|
if (pathStat?.isSymbolicLink()) {
|
|
5352
5457
|
throw new Error(`Refusing to write profile through symlink: ${sanitizeWarnPart2(path)}`);
|
|
5353
5458
|
}
|
|
5459
|
+
if (pathStat && !pathStat.isFile() && !pathStat.isDirectory()) {
|
|
5460
|
+
throw new Error(`Refusing to write profile into non-regular target: ${sanitizeWarnPart2(path)}`);
|
|
5461
|
+
}
|
|
5354
5462
|
const tmp = path + ".tmp";
|
|
5355
5463
|
const tmpStat = safeLstat4(tmp);
|
|
5356
5464
|
if (tmpStat) {
|
|
@@ -5493,8 +5601,10 @@ function findDefaultProfileCollision(configDir, defaultProfilePath) {
|
|
|
5493
5601
|
if (resolve7(candidatePath) === resolvedDefault)
|
|
5494
5602
|
continue;
|
|
5495
5603
|
const baseName = file.replace(/\.json$/i, "");
|
|
5496
|
-
|
|
5604
|
+
const baseLower = baseName.toLowerCase();
|
|
5605
|
+
if (baseLower === "profile" || RESERVED_PROTO_STEMS2.has(baseLower) || WINDOWS_DEVICE_STEM_RE5.test(baseName)) {
|
|
5497
5606
|
continue;
|
|
5607
|
+
}
|
|
5498
5608
|
const candStat = safeLstat4(candidatePath);
|
|
5499
5609
|
if (!candStat || candStat.isSymbolicLink() || !candStat.isFile() || candStat.size > MAX_PROFILE_JSON_BYTES2) {
|
|
5500
5610
|
continue;
|
|
@@ -5510,8 +5620,9 @@ function findDefaultProfileCollision(configDir, defaultProfilePath) {
|
|
|
5510
5620
|
}
|
|
5511
5621
|
const candAgentId = typeof candidate.agent_id === "string" ? candidate.agent_id.trim() : "";
|
|
5512
5622
|
const candToken = typeof candidate.token === "string" ? candidate.token.trim() : "";
|
|
5513
|
-
if (!candAgentId || !candToken)
|
|
5623
|
+
if (!candAgentId || !candToken || CONTROL_CHAR_RE3.test(candAgentId) || RESERVED_PROTO_STEMS2.has(candAgentId.toLowerCase())) {
|
|
5514
5624
|
continue;
|
|
5625
|
+
}
|
|
5515
5626
|
if (defAgentId && candAgentId === defAgentId) {
|
|
5516
5627
|
return { collidingName: baseName, collidingPath: candidatePath, reason: "agent_id" };
|
|
5517
5628
|
}
|
|
@@ -5665,8 +5776,18 @@ import {
|
|
|
5665
5776
|
import { dirname as dirname6, isAbsolute as isAbsolute6, join as join9, parse as parse6, resolve as resolve8, sep as sep2 } from "path";
|
|
5666
5777
|
var MAX_CURSOR_BYTES = 4 * 1024 * 1024;
|
|
5667
5778
|
var MAX_CURSOR_ENTRIES = 50000;
|
|
5668
|
-
var
|
|
5779
|
+
var MAX_CURSOR_PATH_LEN = 4096;
|
|
5780
|
+
var WINDOWS_DEVICE_STEM_RE6 = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
5781
|
+
var RESERVED_PROTO_KEYS = new Set([
|
|
5782
|
+
"__proto__",
|
|
5783
|
+
"constructor",
|
|
5784
|
+
"prototype",
|
|
5785
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
5786
|
+
]);
|
|
5669
5787
|
var tmpCounter = 0;
|
|
5788
|
+
function isReservedCursorKey(key) {
|
|
5789
|
+
return RESERVED_PROTO_KEYS.has(key.toLowerCase());
|
|
5790
|
+
}
|
|
5670
5791
|
function scrubDiag(value) {
|
|
5671
5792
|
return redactSecrets2(String(value ?? "")).replace(/\b(https?:\/\/)([^/\s@]*@)/gi, "$1[REDACTED]@").replace(/\b(?:Bearer|Basic)\s+[^\s"'<>\\]+/gi, "[REDACTED]").replace(/(?:ac_|mcp_at_|mcp_rt_|mcp_|agent_key_|sk-|rk_live_|rk_test_|whsec_|gh[pousr]_|github_pat_|glpat-|xox[baprs]-|hf_|npm_|mr_|AIza|AKIA|ASIA)[A-Za-z0-9+/=._-]{8,}/g, "[REDACTED]").replace(/[\x00-\x1f\x7f-\x9f\u2028\u2029]/g, " ");
|
|
5672
5793
|
}
|
|
@@ -5736,9 +5857,10 @@ function hasSafeAncestorDirs3(targetFile) {
|
|
|
5736
5857
|
return true;
|
|
5737
5858
|
}
|
|
5738
5859
|
function safeAgentCursorSlug(agentId) {
|
|
5739
|
-
const cleaned = String(agentId || "").trim().replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 128);
|
|
5740
|
-
if (!cleaned || cleaned === "." || cleaned
|
|
5860
|
+
const cleaned = String(agentId || "").trim().replace(/[^A-Za-z0-9._-]/g, "_").replace(/\.+$/g, "").slice(0, 128);
|
|
5861
|
+
if (!cleaned || cleaned === "." || cleaned.includes("..") || WINDOWS_DEVICE_STEM_RE6.test(cleaned) || isReservedCursorKey(cleaned)) {
|
|
5741
5862
|
return "_";
|
|
5863
|
+
}
|
|
5742
5864
|
return cleaned;
|
|
5743
5865
|
}
|
|
5744
5866
|
function cursorFileForAgent(configDir, agentId) {
|
|
@@ -5772,7 +5894,7 @@ function loadCursor(file, warn) {
|
|
|
5772
5894
|
}
|
|
5773
5895
|
const entries = [];
|
|
5774
5896
|
for (const [k, v] of Object.entries(parsed)) {
|
|
5775
|
-
if (
|
|
5897
|
+
if (isReservedCursorKey(k))
|
|
5776
5898
|
continue;
|
|
5777
5899
|
if (typeof v !== "string") {
|
|
5778
5900
|
throw new Error(`cursor value for ${scrubDiag(k)} must be a string`);
|
|
@@ -5795,6 +5917,11 @@ function loadCursor(file, warn) {
|
|
|
5795
5917
|
}
|
|
5796
5918
|
}
|
|
5797
5919
|
function persistCursor(file, cursor, warn, fsOps) {
|
|
5920
|
+
if (typeof file !== "string" || !file || file.length > MAX_CURSOR_PATH_LEN || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(file)) {
|
|
5921
|
+
warn(`[agentchat] WARNING: failed to persist read cursor to ${scrubDiag(file)}: invalid cursor file path
|
|
5922
|
+
`);
|
|
5923
|
+
return false;
|
|
5924
|
+
}
|
|
5798
5925
|
try {
|
|
5799
5926
|
const parentStat = lstatSync8(dirname6(file));
|
|
5800
5927
|
if (parentStat.isSymbolicLink() || !parentStat.isDirectory() || !hasSafeAncestorDirs3(file)) {
|
|
@@ -5823,7 +5950,7 @@ function persistCursor(file, cursor, warn, fsOps) {
|
|
|
5823
5950
|
}
|
|
5824
5951
|
const validEntries = [];
|
|
5825
5952
|
for (const [k, v] of cursor) {
|
|
5826
|
-
if (!k || k.length > 256 ||
|
|
5953
|
+
if (!k || k.length > 256 || isReservedCursorKey(k) || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(k) || typeof v !== "string" || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(v) || v.length > 256) {
|
|
5827
5954
|
continue;
|
|
5828
5955
|
}
|
|
5829
5956
|
validEntries.push([k, v]);
|
|
@@ -5932,8 +6059,18 @@ import {
|
|
|
5932
6059
|
import { dirname as dirname7, isAbsolute as isAbsolute7, join as join10, parse as parse7, resolve as resolve9, sep as sep3 } from "path";
|
|
5933
6060
|
var MAX_CURSOR_BYTES2 = 4 * 1024 * 1024;
|
|
5934
6061
|
var MAX_CURSOR_ENTRIES2 = 50000;
|
|
5935
|
-
var
|
|
6062
|
+
var MAX_CURSOR_PATH_LEN2 = 4096;
|
|
6063
|
+
var WINDOWS_DEVICE_STEM_RE7 = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/i;
|
|
6064
|
+
var RESERVED_PROTO_KEYS2 = new Set([
|
|
6065
|
+
"__proto__",
|
|
6066
|
+
"constructor",
|
|
6067
|
+
"prototype",
|
|
6068
|
+
...Object.getOwnPropertyNames(Object.prototype).map((k) => k.toLowerCase())
|
|
6069
|
+
]);
|
|
5936
6070
|
var tmpCounter2 = 0;
|
|
6071
|
+
function isReservedCursorKey2(key) {
|
|
6072
|
+
return RESERVED_PROTO_KEYS2.has(key.toLowerCase());
|
|
6073
|
+
}
|
|
5937
6074
|
function scrubDiag2(value) {
|
|
5938
6075
|
return redactSecrets2(String(value ?? "")).replace(/\b(https?:\/\/)([^/\s@]*@)/gi, "$1[REDACTED]@").replace(/\b(?:Bearer|Basic)\s+[^\s"'<>\\]+/gi, "[REDACTED]").replace(/(?:ac_|mcp_at_|mcp_rt_|mcp_|agent_key_|sk-|rk_live_|rk_test_|whsec_|gh[pousr]_|github_pat_|glpat-|xox[baprs]-|hf_|npm_|mr_|AIza|AKIA|ASIA)[A-Za-z0-9+/=._-]{8,}/g, "[REDACTED]").replace(/[\x00-\x1f\x7f-\x9f\u2028\u2029]/g, " ");
|
|
5939
6076
|
}
|
|
@@ -6003,9 +6140,10 @@ function hasSafeAncestorDirs4(targetFile) {
|
|
|
6003
6140
|
return true;
|
|
6004
6141
|
}
|
|
6005
6142
|
function safeAgentCursorSlug2(agentId) {
|
|
6006
|
-
const cleaned = String(agentId || "").trim().replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 128);
|
|
6007
|
-
if (!cleaned || cleaned === "." || cleaned
|
|
6143
|
+
const cleaned = String(agentId || "").trim().replace(/[^A-Za-z0-9._-]/g, "_").replace(/\.+$/g, "").slice(0, 128);
|
|
6144
|
+
if (!cleaned || cleaned === "." || cleaned.includes("..") || WINDOWS_DEVICE_STEM_RE7.test(cleaned) || isReservedCursorKey2(cleaned)) {
|
|
6008
6145
|
return "_";
|
|
6146
|
+
}
|
|
6009
6147
|
return cleaned;
|
|
6010
6148
|
}
|
|
6011
6149
|
function cursorFileForAgent2(configDir, agentId) {
|
|
@@ -6039,7 +6177,7 @@ function loadCursor2(file, warn) {
|
|
|
6039
6177
|
}
|
|
6040
6178
|
const entries = [];
|
|
6041
6179
|
for (const [k, v] of Object.entries(parsed)) {
|
|
6042
|
-
if (
|
|
6180
|
+
if (isReservedCursorKey2(k))
|
|
6043
6181
|
continue;
|
|
6044
6182
|
if (typeof v !== "string") {
|
|
6045
6183
|
throw new Error(`cursor value for ${scrubDiag2(k)} must be a string`);
|
|
@@ -6062,6 +6200,11 @@ function loadCursor2(file, warn) {
|
|
|
6062
6200
|
}
|
|
6063
6201
|
}
|
|
6064
6202
|
function persistCursor2(file, cursor, warn, fsOps) {
|
|
6203
|
+
if (typeof file !== "string" || !file || file.length > MAX_CURSOR_PATH_LEN2 || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(file)) {
|
|
6204
|
+
warn(`[agentchat] WARNING: failed to persist read cursor to ${scrubDiag2(file)}: invalid cursor file path
|
|
6205
|
+
`);
|
|
6206
|
+
return false;
|
|
6207
|
+
}
|
|
6065
6208
|
try {
|
|
6066
6209
|
const parentStat = lstatSync9(dirname7(file));
|
|
6067
6210
|
if (parentStat.isSymbolicLink() || !parentStat.isDirectory() || !hasSafeAncestorDirs4(file)) {
|
|
@@ -6090,7 +6233,7 @@ function persistCursor2(file, cursor, warn, fsOps) {
|
|
|
6090
6233
|
}
|
|
6091
6234
|
const validEntries = [];
|
|
6092
6235
|
for (const [k, v] of cursor) {
|
|
6093
|
-
if (!k || k.length > 256 ||
|
|
6236
|
+
if (!k || k.length > 256 || isReservedCursorKey2(k) || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(k) || typeof v !== "string" || /[\x00-\x1f\x7f-\x9f\u2028\u2029]/.test(v) || v.length > 256) {
|
|
6094
6237
|
continue;
|
|
6095
6238
|
}
|
|
6096
6239
|
validEntries.push([k, v]);
|
|
@@ -7533,7 +7676,7 @@ project/runtime binding or default profile is loaded; only when none exists and
|
|
|
7533
7676
|
credentials are supplied does the server run ANONYMOUS (lists tools, no account).
|
|
7534
7677
|
|
|
7535
7678
|
Profiles stored in: ~/.agentschat/ (legacy fallback: ~/.agentchat/)
|
|
7536
|
-
Docs: https://github.com/swswordholy-tech/
|
|
7679
|
+
Docs: https://github.com/swswordholy-tech/AgentsChat`);
|
|
7537
7680
|
process.exit(0);
|
|
7538
7681
|
}
|
|
7539
7682
|
var codexIdentity = process.env.AGENTSCHAT_CODEX_IDENTITY ? JSON.parse(process.env.AGENTSCHAT_CODEX_IDENTITY) : undefined;
|