saarthiclaw 0.2.2 → 0.2.3
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/CHANGELOG.md +8 -0
- package/README.md +2 -0
- package/dist/chunks/{chunk-DSQDVSZS.js → chunk-44LLGJXH.js} +6 -6
- package/dist/chunks/{chunk-TTT3KK46.js → chunk-BBQ26JQA.js} +5 -5
- package/dist/chunks/{chunk-OS5GVLKA.js → chunk-CGJ4VEUD.js} +1 -1
- package/dist/chunks/{chunk-3UFD5346.js → chunk-CGTA77EE.js} +5 -5
- package/dist/chunks/{chunk-ZXVP7JFV.js → chunk-CUC6MUW7.js} +11 -13
- package/dist/chunks/{chunk-E4DRW4AW.js → chunk-H2FAKNUI.js} +10 -2
- package/dist/chunks/{chunk-OICPXSO2.js → chunk-HFMRQTXE.js} +1 -1
- package/dist/chunks/{chunk-GX2I7K4S.js → chunk-KAWTUWO2.js} +15 -5
- package/dist/chunks/{chunk-EG5A2Q6X.js → chunk-OJCC4JH2.js} +1 -1
- package/dist/chunks/{chunk-SKYTL7AH.js → chunk-OLL2WJVK.js} +17 -8
- package/dist/chunks/chunk-R4PMMMD5.js +407 -0
- package/dist/chunks/{chunk-VDYO3QC7.js → chunk-XNIFO3FV.js} +6 -6
- package/dist/chunks/{client-5WRI2PBK.js → client-O4UP5DCM.js} +3 -5
- package/dist/chunks/{context-AP3U34DQ.js → context-OL7JU4XA.js} +5 -7
- package/dist/chunks/{doctor-O3R2YTRO.js → doctor-OBO4MCDY.js} +11 -6
- package/dist/chunks/{errors-ZXTAHCZI.js → errors-OJZTUG74.js} +2 -4
- package/dist/chunks/{orchestrator-NIDJK4C3.js → orchestrator-HUHXYUUM.js} +9 -11
- package/dist/chunks/{orchestrator-KNCW4K57.js → orchestrator-IKYROOM5.js} +10 -12
- package/dist/chunks/orchestrator-QAFNDXD2.js +22 -0
- package/dist/chunks/{session-CRFC3IEU.js → session-ZC5D2O77.js} +6 -3
- package/dist/chunks/{store-KW257WIV.js → store-JG5OKLEO.js} +5 -5
- package/dist/chunks/{sync-S2A65FIE.js → sync-LTPGXMRU.js} +7 -9
- package/dist/chunks/{team-RBSOK3HT.js → team-AOMHCEDT.js} +25 -20
- package/dist/chunks/{telegram-JSGRYPIX.js → telegram-KO7VH46G.js} +14 -16
- package/dist/chunks/{wakeup-4IP4JXVF.js → wakeup-YZNEVSVH.js} +16 -18
- package/dist/index.js +20 -19
- package/package.json +1 -1
- package/dist/chunks/chunk-BTFIQWAE.js +0 -185
- package/dist/chunks/chunk-G6GCAEKE.js +0 -64
- package/dist/chunks/chunk-XTVJWMUH.js +0 -143
- package/dist/chunks/orchestrator-JFJU4FGP.js +0 -24
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NonInteractiveError
|
|
3
|
-
} from "./chunk-IT46XDPQ.js";
|
|
4
|
-
import {
|
|
5
|
-
PathSafetyError
|
|
6
|
-
} from "./chunk-XTVJWMUH.js";
|
|
7
|
-
import {
|
|
8
|
-
mapAiError
|
|
9
|
-
} from "./chunk-BTFIQWAE.js";
|
|
10
|
-
import {
|
|
11
|
-
ConfigError
|
|
12
|
-
} from "./chunk-2GDAWRT7.js";
|
|
13
|
-
|
|
14
|
-
// cli/errors.ts
|
|
15
|
-
import chalk from "chalk";
|
|
16
|
-
var UserFacingError = class extends Error {
|
|
17
|
-
constructor(message, hint) {
|
|
18
|
-
super(message);
|
|
19
|
-
this.hint = hint;
|
|
20
|
-
this.name = "UserFacingError";
|
|
21
|
-
}
|
|
22
|
-
hint;
|
|
23
|
-
};
|
|
24
|
-
function looksLikeAiError(e) {
|
|
25
|
-
if (!e || typeof e !== "object") return false;
|
|
26
|
-
const name = e.name ?? "";
|
|
27
|
-
return name.startsWith("AI_") || name === "MissingApiKeyError" || "statusCode" in e;
|
|
28
|
-
}
|
|
29
|
-
function reportError(error, debug) {
|
|
30
|
-
let title;
|
|
31
|
-
let hint;
|
|
32
|
-
if (error instanceof UserFacingError) {
|
|
33
|
-
title = error.message;
|
|
34
|
-
hint = error.hint;
|
|
35
|
-
} else if (error instanceof ConfigError) {
|
|
36
|
-
title = "Configuration problem";
|
|
37
|
-
hint = `${error.message}
|
|
38
|
-
Fix the file above or re-run \`saarthiclaw init\`.`;
|
|
39
|
-
} else if (error instanceof NonInteractiveError || error instanceof PathSafetyError) {
|
|
40
|
-
title = error.message;
|
|
41
|
-
} else if (looksLikeAiError(error)) {
|
|
42
|
-
const f = mapAiError(error);
|
|
43
|
-
title = f.title;
|
|
44
|
-
hint = f.hint;
|
|
45
|
-
} else {
|
|
46
|
-
title = error instanceof Error ? error.message : String(error);
|
|
47
|
-
hint = debug ? void 0 : "Run again with --debug for details, or `saarthiclaw doctor` to check your setup.";
|
|
48
|
-
}
|
|
49
|
-
console.error(`
|
|
50
|
-
${chalk.red("✖")} ${chalk.bold(title)}`);
|
|
51
|
-
if (hint) for (const line of hint.split("\n")) console.error(chalk.dim(` ${line}`));
|
|
52
|
-
if (debug && error instanceof Error && error.stack) {
|
|
53
|
-
console.error(chalk.dim(`
|
|
54
|
-
${error.stack}`));
|
|
55
|
-
const cause = error.cause;
|
|
56
|
-
if (cause) console.error(chalk.dim(`Caused by: ${cause instanceof Error ? cause.stack : String(cause)}`));
|
|
57
|
-
}
|
|
58
|
-
console.error("");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
UserFacingError,
|
|
63
|
-
reportError
|
|
64
|
-
};
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// modes/agent/path-safety.ts
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
var PathSafetyError = class extends Error {
|
|
6
|
-
constructor(message) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = "PathSafetyError";
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
var SECRET_PATTERNS = [
|
|
12
|
-
".env",
|
|
13
|
-
".env.*",
|
|
14
|
-
"*.pem",
|
|
15
|
-
"*.key",
|
|
16
|
-
"*.p12",
|
|
17
|
-
"*.pfx",
|
|
18
|
-
"id_rsa*",
|
|
19
|
-
"id_dsa*",
|
|
20
|
-
"id_ecdsa*",
|
|
21
|
-
"id_ed25519*",
|
|
22
|
-
".npmrc",
|
|
23
|
-
".yarnrc.yml",
|
|
24
|
-
".pypirc",
|
|
25
|
-
".netrc",
|
|
26
|
-
".pgpass",
|
|
27
|
-
".ssh",
|
|
28
|
-
".aws",
|
|
29
|
-
".saarthiclaw"
|
|
30
|
-
];
|
|
31
|
-
function toPosix(p) {
|
|
32
|
-
return p.replace(/\\/g, "/");
|
|
33
|
-
}
|
|
34
|
-
var regexCache = /* @__PURE__ */ new Map();
|
|
35
|
-
function globToRegExp(glob) {
|
|
36
|
-
const cached = regexCache.get(glob);
|
|
37
|
-
if (cached) return cached;
|
|
38
|
-
let re = "";
|
|
39
|
-
for (let i = 0; i < glob.length; i++) {
|
|
40
|
-
const c = glob[i];
|
|
41
|
-
if (c === "*") {
|
|
42
|
-
if (glob[i + 1] === "*") {
|
|
43
|
-
re += ".*";
|
|
44
|
-
i++;
|
|
45
|
-
if (glob[i + 1] === "/") i++;
|
|
46
|
-
} else {
|
|
47
|
-
re += "[^/]*";
|
|
48
|
-
}
|
|
49
|
-
} else if (c === "?") {
|
|
50
|
-
re += "[^/]";
|
|
51
|
-
} else {
|
|
52
|
-
re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const out = new RegExp(`^${re}$`, "i");
|
|
56
|
-
regexCache.set(glob, out);
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
function matchesPattern(relPosix, pattern) {
|
|
60
|
-
const p = toPosix(pattern).replace(/^\.\//, "").replace(/\/$/, "");
|
|
61
|
-
if (!p) return false;
|
|
62
|
-
const norm = relPosix.replace(/^\.\//, "");
|
|
63
|
-
const segments = norm.split("/").filter((s) => s && s !== ".");
|
|
64
|
-
if (!p.includes("/")) {
|
|
65
|
-
const re2 = globToRegExp(p);
|
|
66
|
-
return segments.some((s) => re2.test(s));
|
|
67
|
-
}
|
|
68
|
-
const re = globToRegExp(p);
|
|
69
|
-
for (let i = 1; i <= segments.length; i++) {
|
|
70
|
-
if (re.test(segments.slice(0, i).join("/"))) return true;
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
function isSecretPath(relPosix) {
|
|
75
|
-
return SECRET_PATTERNS.some((p) => matchesPattern(relPosix, p));
|
|
76
|
-
}
|
|
77
|
-
function isExcludedPath(relPosix, patterns) {
|
|
78
|
-
return patterns.some((p) => matchesPattern(relPosix, p));
|
|
79
|
-
}
|
|
80
|
-
function lexists(p) {
|
|
81
|
-
try {
|
|
82
|
-
fs.lstatSync(p);
|
|
83
|
-
return true;
|
|
84
|
-
} catch {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function isInside(root, target) {
|
|
89
|
-
const rel = path.relative(root, target);
|
|
90
|
-
return rel === "" || !rel.startsWith(`..${path.sep}`) && rel !== ".." && !path.isAbsolute(rel);
|
|
91
|
-
}
|
|
92
|
-
var realRootCache;
|
|
93
|
-
function realRootOf(rootAbs) {
|
|
94
|
-
if (realRootCache?.root === rootAbs) return realRootCache.real;
|
|
95
|
-
const real = fs.realpathSync(rootAbs);
|
|
96
|
-
realRootCache = { root: rootAbs, real };
|
|
97
|
-
return real;
|
|
98
|
-
}
|
|
99
|
-
function resolveInsideRoot(root, input) {
|
|
100
|
-
if (typeof input !== "string") throw new PathSafetyError("Path must be a string");
|
|
101
|
-
if (input.includes("\0")) throw new PathSafetyError("Path contains a NUL byte");
|
|
102
|
-
let p = toPosix(input.trim());
|
|
103
|
-
if (!p) p = ".";
|
|
104
|
-
const rootAbs = path.resolve(root);
|
|
105
|
-
if (process.platform !== "win32" && (/^[a-zA-Z]:\//.test(p) || p.startsWith("//"))) {
|
|
106
|
-
throw new PathSafetyError(`Path escapes workspace: ${input}`);
|
|
107
|
-
}
|
|
108
|
-
const abs = path.resolve(rootAbs, p);
|
|
109
|
-
if (!isInside(rootAbs, abs)) {
|
|
110
|
-
throw new PathSafetyError(`Path escapes workspace: ${input}`);
|
|
111
|
-
}
|
|
112
|
-
const realRoot = realRootOf(rootAbs);
|
|
113
|
-
let probe = abs;
|
|
114
|
-
while (!lexists(probe)) {
|
|
115
|
-
const parent = path.dirname(probe);
|
|
116
|
-
if (parent === probe) break;
|
|
117
|
-
probe = parent;
|
|
118
|
-
}
|
|
119
|
-
let realProbe;
|
|
120
|
-
try {
|
|
121
|
-
realProbe = fs.realpathSync(probe);
|
|
122
|
-
} catch {
|
|
123
|
-
throw new PathSafetyError(`Path is a dangling symlink: ${input}`);
|
|
124
|
-
}
|
|
125
|
-
if (!isInside(realRoot, realProbe)) {
|
|
126
|
-
throw new PathSafetyError(`Path resolves outside workspace via symlink: ${input}`);
|
|
127
|
-
}
|
|
128
|
-
return abs;
|
|
129
|
-
}
|
|
130
|
-
function relativePosix(root, abs) {
|
|
131
|
-
const rel = path.relative(path.resolve(root), abs);
|
|
132
|
-
return rel ? toPosix(rel) : ".";
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export {
|
|
136
|
-
PathSafetyError,
|
|
137
|
-
toPosix,
|
|
138
|
-
globToRegExp,
|
|
139
|
-
isSecretPath,
|
|
140
|
-
isExcludedPath,
|
|
141
|
-
resolveInsideRoot,
|
|
142
|
-
relativePosix
|
|
143
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
runPlanMode,
|
|
3
|
-
stepPrompt
|
|
4
|
-
} from "./chunk-VDYO3QC7.js";
|
|
5
|
-
import "./chunk-OICPXSO2.js";
|
|
6
|
-
import "./chunk-DSQDVSZS.js";
|
|
7
|
-
import "./chunk-OS5GVLKA.js";
|
|
8
|
-
import "./chunk-QRAFFI5V.js";
|
|
9
|
-
import "./chunk-SKYTL7AH.js";
|
|
10
|
-
import "./chunk-E4DRW4AW.js";
|
|
11
|
-
import "./chunk-HGBZ55ND.js";
|
|
12
|
-
import "./chunk-GX2I7K4S.js";
|
|
13
|
-
import "./chunk-5WH3FNFK.js";
|
|
14
|
-
import "./chunk-EG5A2Q6X.js";
|
|
15
|
-
import "./chunk-G6GCAEKE.js";
|
|
16
|
-
import "./chunk-IT46XDPQ.js";
|
|
17
|
-
import "./chunk-XTVJWMUH.js";
|
|
18
|
-
import "./chunk-BTFIQWAE.js";
|
|
19
|
-
import "./chunk-2GDAWRT7.js";
|
|
20
|
-
import "./chunk-MMIJKDOU.js";
|
|
21
|
-
export {
|
|
22
|
-
runPlanMode,
|
|
23
|
-
stepPrompt
|
|
24
|
-
};
|