@claudexor/core 1.0.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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/adapter.d.ts +56 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +8 -0
- package/dist/adapter.js.map +1 -0
- package/dist/browser-mcp.d.ts +18 -0
- package/dist/browser-mcp.d.ts.map +1 -0
- package/dist/browser-mcp.js +32 -0
- package/dist/browser-mcp.js.map +1 -0
- package/dist/capabilities.d.ts +4 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +8 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/conformance.d.ts +25 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +60 -0
- package/dist/conformance.js.map +1 -0
- package/dist/diff.d.ts +71 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +325 -0
- package/dist/diff.js.map +1 -0
- package/dist/doctor.d.ts +7 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +75 -0
- package/dist/doctor.js.map +1 -0
- package/dist/effort.d.ts +18 -0
- package/dist/effort.d.ts.map +1 -0
- package/dist/effort.js +49 -0
- package/dist/effort.js.map +1 -0
- package/dist/env-scope.d.ts +38 -0
- package/dist/env-scope.d.ts.map +1 -0
- package/dist/env-scope.js +139 -0
- package/dist/env-scope.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/inactivity.d.ts +31 -0
- package/dist/inactivity.d.ts.map +1 -0
- package/dist/inactivity.js +77 -0
- package/dist/inactivity.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/model.d.ts +23 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +21 -0
- package/dist/model.js.map +1 -0
- package/dist/proc.d.ts +68 -0
- package/dist/proc.d.ts.map +1 -0
- package/dist/proc.js +283 -0
- package/dist/proc.js.map +1 -0
- package/dist/process-registry.d.ts +8 -0
- package/dist/process-registry.d.ts.map +1 -0
- package/dist/process-registry.js +20 -0
- package/dist/process-registry.js.map +1 -0
- package/dist/runloop.d.ts +35 -0
- package/dist/runloop.d.ts.map +1 -0
- package/dist/runloop.js +156 -0
- package/dist/runloop.js.map +1 -0
- package/dist/runtime-env.d.ts +16 -0
- package/dist/runtime-env.d.ts.map +1 -0
- package/dist/runtime-env.js +51 -0
- package/dist/runtime-env.js.map +1 -0
- package/package.json +40 -0
package/dist/diff.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE quote-aware unified-diff header parser. Three divergent parsers
|
|
3
|
+
* used to read patches: a regex in the orchestrator's diffStats that
|
|
4
|
+
* missed git-quoted headers (non-ASCII/spaces → protected-path and
|
|
5
|
+
* NEEDS_HUMAN gates silently skipped those files), a line-scan in the
|
|
6
|
+
* delivery gate that read `--- `-prefixed CONTENT lines as paths (SQL
|
|
7
|
+
* comments → false apply refusals), and a header tokenizer in
|
|
8
|
+
* context/evidence that never decoded octal escapes. All three rebase here.
|
|
9
|
+
*
|
|
10
|
+
* Structural rules, not regex governance: file metadata (`---`/`+++`,
|
|
11
|
+
* `rename from/to`, `new/deleted file mode`, binary markers) is honored only
|
|
12
|
+
* in HEADER position — between a `diff --git` line and that file's first
|
|
13
|
+
* `@@` hunk — so patch CONTENT can never masquerade as structure.
|
|
14
|
+
*
|
|
15
|
+
* PLAIN unified diffs (GNU `diff -ruN`, the workspace's non-git in-place
|
|
16
|
+
* fallback) have no `diff --git` anchors, so a document that opens with a
|
|
17
|
+
* plain file header is parsed in PLAIN mode: a file entry opens only on the
|
|
18
|
+
* full structural triple — a `--- ` line immediately followed by a `+++ `
|
|
19
|
+
* line and an `@@` hunk header — which keeps deleted `-- sql` content lines
|
|
20
|
+
* from masquerading as file boundaries. Without this mode every non-git
|
|
21
|
+
* in-place diff summarized to zero files, silently blinding diffstat and
|
|
22
|
+
* protected-path/risk gating for that whole run class. Inside a git-anchored
|
|
23
|
+
* document the git rules above apply unchanged (never mixed per document).
|
|
24
|
+
* Plain-mode entries default to modified (GNU diff marks absent files with
|
|
25
|
+
* epoch timestamps, not `/dev/null`, so added/deleted classification is
|
|
26
|
+
* honored only for explicit `/dev/null` headers) — conservative for gating:
|
|
27
|
+
* every touched path is visible to policy.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Decode one git C-quoted path token: strips surrounding quotes and decodes
|
|
31
|
+
* `\ooo` octal byte escapes plus the standard single-char escapes, yielding
|
|
32
|
+
* the real on-disk path (utf8).
|
|
33
|
+
*/
|
|
34
|
+
export function cUnquoteGitPath(raw) {
|
|
35
|
+
const trimmed = raw.trim();
|
|
36
|
+
if (!trimmed.startsWith('"') || !trimmed.endsWith('"') || trimmed.length < 2)
|
|
37
|
+
return trimmed;
|
|
38
|
+
const inner = trimmed.slice(1, -1);
|
|
39
|
+
const bytes = [];
|
|
40
|
+
let i = 0;
|
|
41
|
+
while (i < inner.length) {
|
|
42
|
+
const ch = inner[i];
|
|
43
|
+
if (ch !== "\\") {
|
|
44
|
+
const encoded = Buffer.from(ch, "utf8");
|
|
45
|
+
for (const b of encoded)
|
|
46
|
+
bytes.push(b);
|
|
47
|
+
i += 1;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const next = inner[i + 1] ?? "";
|
|
51
|
+
if (/[0-7]/.test(next)) {
|
|
52
|
+
let oct = "";
|
|
53
|
+
let j = i + 1;
|
|
54
|
+
while (j < inner.length && oct.length < 3 && /[0-7]/.test(inner[j])) {
|
|
55
|
+
oct += inner[j];
|
|
56
|
+
j += 1;
|
|
57
|
+
}
|
|
58
|
+
bytes.push(parseInt(oct, 8));
|
|
59
|
+
i = j;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const simple = { n: "\n", t: "\t", r: "\r", '"': '"', "\\": "\\", a: "\x07", b: "\b", f: "\f", v: "\v" };
|
|
63
|
+
bytes.push(...Buffer.from(simple[next] ?? next, "utf8"));
|
|
64
|
+
i += 2;
|
|
65
|
+
}
|
|
66
|
+
return Buffer.from(bytes).toString("utf8");
|
|
67
|
+
}
|
|
68
|
+
/** Split a `diff --git a/x b/x` remainder into its two path tokens (quote-aware). */
|
|
69
|
+
function splitHeaderPaths(rest) {
|
|
70
|
+
const tokens = [];
|
|
71
|
+
let i = 0;
|
|
72
|
+
while (i < rest.length && tokens.length < 2) {
|
|
73
|
+
while (rest[i] === " ")
|
|
74
|
+
i += 1;
|
|
75
|
+
if (i >= rest.length)
|
|
76
|
+
break;
|
|
77
|
+
if (rest[i] === '"') {
|
|
78
|
+
let j = i + 1;
|
|
79
|
+
while (j < rest.length) {
|
|
80
|
+
if (rest[j] === "\\") {
|
|
81
|
+
j += 2;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (rest[j] === '"')
|
|
85
|
+
break;
|
|
86
|
+
j += 1;
|
|
87
|
+
}
|
|
88
|
+
tokens.push(cUnquoteGitPath(rest.slice(i, j + 1)));
|
|
89
|
+
i = j + 1;
|
|
90
|
+
}
|
|
91
|
+
else if (tokens.length === 0) {
|
|
92
|
+
// Unquoted a-path: paths may CONTAIN spaces without quoting when git
|
|
93
|
+
// can still tokenize them; the reliable boundary is the ` b/` splitter.
|
|
94
|
+
const bIdx = rest.indexOf(" b/", i);
|
|
95
|
+
if (bIdx < 0) {
|
|
96
|
+
const start = i;
|
|
97
|
+
while (i < rest.length && rest[i] !== " ")
|
|
98
|
+
i += 1;
|
|
99
|
+
tokens.push(rest.slice(start, i));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
tokens.push(rest.slice(i, bIdx));
|
|
103
|
+
i = bIdx + 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
tokens.push(rest.slice(i).trim());
|
|
108
|
+
i = rest.length;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const [a, b] = tokens;
|
|
112
|
+
return a && b ? [a, b] : null;
|
|
113
|
+
}
|
|
114
|
+
const stripPrefix = (value, prefix) => value.startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
115
|
+
/** Strip the GNU-diff timestamp suffix (`\t2026-…`) from a plain header path. */
|
|
116
|
+
function plainHeaderPath(raw) {
|
|
117
|
+
const tab = raw.indexOf("\t");
|
|
118
|
+
return cUnquoteGitPath(tab >= 0 ? raw.slice(0, tab) : raw);
|
|
119
|
+
}
|
|
120
|
+
export function parseUnifiedDiff(diff) {
|
|
121
|
+
const files = [];
|
|
122
|
+
let current = null;
|
|
123
|
+
/** Document-level mode, decided by the FIRST structural anchor seen. */
|
|
124
|
+
let plainDoc = null;
|
|
125
|
+
let inHunk = false;
|
|
126
|
+
let sawGitPayload = false;
|
|
127
|
+
let sawBinaryStub = false;
|
|
128
|
+
let additions = 0;
|
|
129
|
+
let deletions = 0;
|
|
130
|
+
let hunks = 0;
|
|
131
|
+
const flush = () => {
|
|
132
|
+
if (!current)
|
|
133
|
+
return;
|
|
134
|
+
if (current.binary)
|
|
135
|
+
current.binaryStub = sawBinaryStub && !sawGitPayload;
|
|
136
|
+
files.push(current);
|
|
137
|
+
current = null;
|
|
138
|
+
sawGitPayload = false;
|
|
139
|
+
sawBinaryStub = false;
|
|
140
|
+
};
|
|
141
|
+
const lines = diff.split("\n");
|
|
142
|
+
// A plain-mode file boundary is the full structural triple: `--- ` +
|
|
143
|
+
// `+++ ` + `@@` on consecutive lines. INSIDE a hunk the bar is higher:
|
|
144
|
+
// content could forge the loose triple (a deleted `-- …` line + an added
|
|
145
|
+
// `++ …` line + the next hunk header), so a mid-hunk boundary must also
|
|
146
|
+
// carry a header witness — the GNU tab-separated timestamp (or /dev/null)
|
|
147
|
+
// on both path lines, which +/- content lines do not have.
|
|
148
|
+
const headerWitness = (l) => l !== undefined && (l.includes("\t") || l.slice(4).trim() === "/dev/null");
|
|
149
|
+
const plainFileHeaderAt = (idx, midHunk) => {
|
|
150
|
+
const triple = (lines[idx]?.startsWith("--- ") ?? false) &&
|
|
151
|
+
(lines[idx + 1]?.startsWith("+++ ") ?? false) &&
|
|
152
|
+
(lines[idx + 2]?.startsWith("@@") ?? false);
|
|
153
|
+
if (!triple)
|
|
154
|
+
return false;
|
|
155
|
+
return midHunk ? headerWitness(lines[idx]) && headerWitness(lines[idx + 1]) : true;
|
|
156
|
+
};
|
|
157
|
+
for (let idx = 0; idx < lines.length; idx += 1) {
|
|
158
|
+
const line = lines[idx];
|
|
159
|
+
if (line.startsWith("diff --git ")) {
|
|
160
|
+
if (plainDoc === null)
|
|
161
|
+
plainDoc = false;
|
|
162
|
+
flush();
|
|
163
|
+
inHunk = false;
|
|
164
|
+
const paths = splitHeaderPaths(line.slice("diff --git ".length));
|
|
165
|
+
current = {
|
|
166
|
+
oldPath: paths ? stripPrefix(paths[0], "a/") : null,
|
|
167
|
+
newPath: paths ? stripPrefix(paths[1], "b/") : null,
|
|
168
|
+
added: false,
|
|
169
|
+
deleted: false,
|
|
170
|
+
renamed: false,
|
|
171
|
+
binary: false,
|
|
172
|
+
binaryStub: false,
|
|
173
|
+
};
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
// A GNU `diff <opts> old new` command echo (never emitted by git) or a
|
|
177
|
+
// top-level binary stub decides plain mode when it arrives first.
|
|
178
|
+
if (plainDoc === null && current === null && (line.startsWith("diff ") || (line.startsWith("Binary files ") && line.endsWith(" differ")))) {
|
|
179
|
+
plainDoc = true;
|
|
180
|
+
}
|
|
181
|
+
if (plainDoc !== false && (current === null || (plainDoc === true && inHunk)) && plainFileHeaderAt(idx, plainDoc === true && inHunk)) {
|
|
182
|
+
// Plain-mode file boundary: before any file, or right after the
|
|
183
|
+
// previous plain file's hunks (GNU diff concatenates files this way).
|
|
184
|
+
plainDoc = true;
|
|
185
|
+
flush();
|
|
186
|
+
inHunk = false;
|
|
187
|
+
const oldRaw = plainHeaderPath(line.slice(4));
|
|
188
|
+
const newRaw = plainHeaderPath(lines[idx + 1].slice(4));
|
|
189
|
+
// Same prefix convention as git headers: relativized plain diffs (the
|
|
190
|
+
// workspace non-git fallback) arrive as a/<rel> b/<rel> and must
|
|
191
|
+
// project the bare repo-relative path for policy globs.
|
|
192
|
+
current = {
|
|
193
|
+
oldPath: oldRaw === "/dev/null" ? null : stripPrefix(oldRaw, "a/"),
|
|
194
|
+
newPath: newRaw === "/dev/null" ? null : stripPrefix(newRaw, "b/"),
|
|
195
|
+
added: oldRaw === "/dev/null",
|
|
196
|
+
deleted: newRaw === "/dev/null",
|
|
197
|
+
renamed: false,
|
|
198
|
+
binary: false,
|
|
199
|
+
binaryStub: false,
|
|
200
|
+
};
|
|
201
|
+
idx += 1; // consume the `+++ ` line; the `@@` line is handled next.
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (plainDoc === true && line.startsWith("Binary files ") && line.endsWith(" differ")) {
|
|
205
|
+
// Plain binary stub arrives with no ---/+++ header of its own. Hunk
|
|
206
|
+
// content cannot forge this line: content lines always carry a
|
|
207
|
+
// ' '/'+'/'-' prefix, so a bare `Binary files … differ` is structural.
|
|
208
|
+
flush();
|
|
209
|
+
inHunk = false;
|
|
210
|
+
const body = line.slice("Binary files ".length, -" differ".length);
|
|
211
|
+
const sep = body.indexOf(" and ");
|
|
212
|
+
files.push({
|
|
213
|
+
oldPath: sep >= 0 ? stripPrefix(body.slice(0, sep), "a/") : null,
|
|
214
|
+
newPath: sep >= 0 ? stripPrefix(body.slice(sep + " and ".length), "b/") : null,
|
|
215
|
+
added: false,
|
|
216
|
+
deleted: false,
|
|
217
|
+
renamed: false,
|
|
218
|
+
binary: true,
|
|
219
|
+
binaryStub: true,
|
|
220
|
+
});
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (plainDoc === true && line.startsWith("diff ")) {
|
|
224
|
+
// GNU `diff -ruN old new` command line between files: a separator.
|
|
225
|
+
flush();
|
|
226
|
+
inHunk = false;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (line.startsWith("@@")) {
|
|
230
|
+
inHunk = true;
|
|
231
|
+
hunks += 1;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (current && !inHunk) {
|
|
235
|
+
// HEADER position only: content lines can never reach these branches.
|
|
236
|
+
if (line.startsWith("new file mode "))
|
|
237
|
+
current.added = true;
|
|
238
|
+
else if (line.startsWith("deleted file mode "))
|
|
239
|
+
current.deleted = true;
|
|
240
|
+
else if (line.startsWith("rename from ")) {
|
|
241
|
+
current.renamed = true;
|
|
242
|
+
current.oldPath = cUnquoteGitPath(line.slice("rename from ".length));
|
|
243
|
+
}
|
|
244
|
+
else if (line.startsWith("rename to ")) {
|
|
245
|
+
current.renamed = true;
|
|
246
|
+
current.newPath = cUnquoteGitPath(line.slice("rename to ".length));
|
|
247
|
+
}
|
|
248
|
+
else if (line.startsWith("--- ")) {
|
|
249
|
+
const raw = cUnquoteGitPath(line.slice(4));
|
|
250
|
+
if (raw === "/dev/null") {
|
|
251
|
+
current.added = true;
|
|
252
|
+
current.oldPath = null;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
current.oldPath = stripPrefix(raw, "a/");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (line.startsWith("+++ ")) {
|
|
259
|
+
const raw = cUnquoteGitPath(line.slice(4));
|
|
260
|
+
if (raw === "/dev/null") {
|
|
261
|
+
current.deleted = true;
|
|
262
|
+
current.newPath = null;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
current.newPath = stripPrefix(raw, "b/");
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else if (line.startsWith("GIT binary patch")) {
|
|
269
|
+
current.binary = true;
|
|
270
|
+
sawGitPayload = true;
|
|
271
|
+
}
|
|
272
|
+
else if (line.startsWith("Binary files ") && line.endsWith(" differ")) {
|
|
273
|
+
current.binary = true;
|
|
274
|
+
sawBinaryStub = true;
|
|
275
|
+
}
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (inHunk) {
|
|
279
|
+
if (line.startsWith("+"))
|
|
280
|
+
additions += 1;
|
|
281
|
+
else if (line.startsWith("-"))
|
|
282
|
+
deletions += 1;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
flush();
|
|
286
|
+
return { files, additions, deletions, hunks };
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Path-oriented projection of a unified diff for policy/risk gating and
|
|
290
|
+
* diffstat honesty: which files the patch touches, which are NEW vs
|
|
291
|
+
* pre-existing, and the +/- counts. Quote-aware via parseUnifiedDiff — a
|
|
292
|
+
* git-quoted header (non-ASCII, spaces) must never silently DROP a file
|
|
293
|
+
* from protected-path/NEEDS_HUMAN classification.
|
|
294
|
+
*/
|
|
295
|
+
export function summarizeDiffPaths(diff) {
|
|
296
|
+
const parsed = parseUnifiedDiff(diff);
|
|
297
|
+
const paths = [];
|
|
298
|
+
const addedPaths = [];
|
|
299
|
+
const modifiedPaths = [];
|
|
300
|
+
const existingPaths = [];
|
|
301
|
+
for (const f of parsed.files) {
|
|
302
|
+
const path = f.newPath ?? f.oldPath;
|
|
303
|
+
if (!path)
|
|
304
|
+
continue;
|
|
305
|
+
paths.push(path);
|
|
306
|
+
if (f.added) {
|
|
307
|
+
addedPaths.push(path);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
modifiedPaths.push(path);
|
|
311
|
+
if (f.oldPath)
|
|
312
|
+
existingPaths.push(f.oldPath);
|
|
313
|
+
existingPaths.push(path);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
paths,
|
|
318
|
+
addedPaths,
|
|
319
|
+
modifiedPaths,
|
|
320
|
+
existingPaths: [...new Set(existingPaths)],
|
|
321
|
+
additions: parsed.additions,
|
|
322
|
+
deletions: parsed.deletions,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=diff.js.map
|
package/dist/diff.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAuBH;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAC7F,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAW,CAAC;QAC9B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACxC,KAAK,MAAM,CAAC,IAAI,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC,IAAI,CAAC,CAAC;YACP,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,IAAI,GAAG,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAA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C;aAAM,CAAC;YACN,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,CAAC,CAAC,OAAO;gBAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YAC7C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO;QACL,KAAK;QACL,UAAU;QACV,aAAa;QACb,aAAa,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;QAC1C,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC"}
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConformanceReport } from "@claudexor/schema";
|
|
2
|
+
import type { AdapterRegistry, DoctorSpec } from "./adapter.js";
|
|
3
|
+
/** Clear the doctor cache (call after auth/secrets/settings mutations). */
|
|
4
|
+
export declare function invalidateDoctorCache(): void;
|
|
5
|
+
/** Run conformance probes across all registered adapters; never throws. */
|
|
6
|
+
export declare function runDoctor(adapters: AdapterRegistry, spec: DoctorSpec): Promise<ConformanceReport[]>;
|
|
7
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAwBhE,2EAA2E;AAC3E,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAkBD,2EAA2E;AAC3E,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAiC9B"}
|
package/dist/doctor.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Short-lived doctor cache. Real-harness `doctor()` is expensive (version probe,
|
|
4
|
+
* native-auth check, and — for the api-key route — a paid isolated smoke), and
|
|
5
|
+
* the orchestrator calls statusAll more than once per run (reviewers + candidates).
|
|
6
|
+
* Without a cache an `ask "2+2"` could pay multiple smokes before work starts.
|
|
7
|
+
* The TTL bounds staleness; mutating auth/secrets/settings should call
|
|
8
|
+
* `invalidateDoctorCache()` for an immediate refresh.
|
|
9
|
+
*/
|
|
10
|
+
const DOCTOR_TTL_MS = Number(process.env.CLAUDEXOR_DOCTOR_TTL_MS ?? 90_000);
|
|
11
|
+
/**
|
|
12
|
+
* Non-OK results age out much faster: an out-of-band `codex login` /
|
|
13
|
+
* `claude /login` (which Claudexor cannot observe to invalidate) should become
|
|
14
|
+
* routable within seconds, not a full TTL. OK results keep the long TTL since
|
|
15
|
+
* readiness rarely degrades spontaneously and re-probing it is what costs money.
|
|
16
|
+
*/
|
|
17
|
+
const DOCTOR_NON_OK_TTL_MS = Number(process.env.CLAUDEXOR_DOCTOR_NON_OK_TTL_MS ?? 15_000);
|
|
18
|
+
const doctorCache = new Map();
|
|
19
|
+
/** Clear the doctor cache (call after auth/secrets/settings mutations). */
|
|
20
|
+
export function invalidateDoctorCache() {
|
|
21
|
+
doctorCache.clear();
|
|
22
|
+
}
|
|
23
|
+
function doctorCacheKey(adapterId, spec) {
|
|
24
|
+
// The key covers EVERY spec field that can change a probe's outcome: cwd,
|
|
25
|
+
// the auth-route preference, and any scoped env overlay. Omitting them
|
|
26
|
+
// would let a scoped-route probe poison (or be served) the default-route
|
|
27
|
+
// report for the same cwd — a latent cross-route cache bug even though
|
|
28
|
+
// today's scoped callers bypass runDoctor. Env entries can carry key
|
|
29
|
+
// MATERIAL, so they enter the key only as a digest, never as plaintext.
|
|
30
|
+
const envDigest = spec.env
|
|
31
|
+
? createHash("sha256")
|
|
32
|
+
.update(JSON.stringify(Object.entries(spec.env).sort(([a], [b]) => a.localeCompare(b))))
|
|
33
|
+
.digest("hex")
|
|
34
|
+
.slice(0, 16)
|
|
35
|
+
: "";
|
|
36
|
+
return `${adapterId}::${spec.cwd ?? ""}::${spec.authPreference ?? ""}::${envDigest}`;
|
|
37
|
+
}
|
|
38
|
+
/** Run conformance probes across all registered adapters; never throws. */
|
|
39
|
+
export async function runDoctor(adapters, spec) {
|
|
40
|
+
const reports = [];
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
for (const adapter of adapters.values()) {
|
|
43
|
+
// Fakes are cheap + deterministic and are reconfigured per test — never cache
|
|
44
|
+
// them (avoids cross-test contamination); only real adapters benefit.
|
|
45
|
+
const cacheable = DOCTOR_TTL_MS > 0 && !adapter.id.startsWith("fake");
|
|
46
|
+
const key = doctorCacheKey(adapter.id, spec);
|
|
47
|
+
if (cacheable) {
|
|
48
|
+
const hit = doctorCache.get(key);
|
|
49
|
+
const ttl = hit?.report.status === "ok" ? DOCTOR_TTL_MS : DOCTOR_NON_OK_TTL_MS;
|
|
50
|
+
if (hit && now - hit.at < ttl) {
|
|
51
|
+
reports.push(hit.report);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
let report;
|
|
56
|
+
try {
|
|
57
|
+
report = await adapter.doctor(spec);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
report = {
|
|
61
|
+
harness_id: adapter.id,
|
|
62
|
+
status: "unavailable",
|
|
63
|
+
checks: [],
|
|
64
|
+
enabled_intents: [],
|
|
65
|
+
disabled_intents: [],
|
|
66
|
+
reasons: [err instanceof Error ? err.message : String(err)],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (cacheable)
|
|
70
|
+
doctorCache.set(key, { report, at: now });
|
|
71
|
+
reports.push(report);
|
|
72
|
+
}
|
|
73
|
+
return reports;
|
|
74
|
+
}
|
|
75
|
+
//#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AM,CAAC,GAAG,CAAC,CAAC;aAC5D,CAAC;QACJ,CAAC;QACD,IAAI,SAAS;YAAE,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/effort.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EffortHint } from "@claudexor/schema";
|
|
2
|
+
/**
|
|
3
|
+
* Map a requested reasoning-effort hint onto the nearest level a harness
|
|
4
|
+
* actually supports.
|
|
5
|
+
*
|
|
6
|
+
* - `requested` null/undefined → null (no effort was asked for; pass no flag).
|
|
7
|
+
* - `supported` empty → null (effort is NOT a tunable surface for this adapter;
|
|
8
|
+
* it passes no effort flag at all — honest, not a silent clamp to a default).
|
|
9
|
+
* - `requested` exactly supported → returned unchanged.
|
|
10
|
+
* - otherwise CLAMP to the nearest supported level BY RANK: above the strongest
|
|
11
|
+
* supported → the strongest; below the weakest → the weakest; in-between → the
|
|
12
|
+
* closest by rank, ties resolving to the LOWER (cheaper) level.
|
|
13
|
+
*
|
|
14
|
+
* Pure and data-driven: the adapter feeds its own declared `effort_levels` and
|
|
15
|
+
* never hard-codes a clamp table.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeEffort(requested: EffortHint | null | undefined, supported: readonly EffortHint[]): EffortHint | null;
|
|
18
|
+
//# sourceMappingURL=effort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effort.d.ts","sourceRoot":"","sources":["../src/effort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAiBpD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACxC,SAAS,EAAE,SAAS,UAAU,EAAE,GAC/B,UAAU,GAAG,IAAI,CAiBnB"}
|
package/dist/effort.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EffortHint as EffortHintSchema } from "@claudexor/schema";
|
|
2
|
+
/**
|
|
3
|
+
* The full cross-harness reasoning-effort ladder, ordered weakest→strongest.
|
|
4
|
+
* DERIVED from the EffortHint enum's declaration order (the single source) so the
|
|
5
|
+
* ladder can never drift from the enum: a future level (e.g. `ultra`) appended to
|
|
6
|
+
* the enum is automatically ranked and every adapter clamps it with no code
|
|
7
|
+
* change. An EffortHint's RANK is its index here; the normalizer below clamps any
|
|
8
|
+
* requested level onto the nearest level a given adapter actually supports.
|
|
9
|
+
*/
|
|
10
|
+
const EFFORT_LADDER = EffortHintSchema.options;
|
|
11
|
+
function rank(level) {
|
|
12
|
+
return EFFORT_LADDER.indexOf(level);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Map a requested reasoning-effort hint onto the nearest level a harness
|
|
16
|
+
* actually supports.
|
|
17
|
+
*
|
|
18
|
+
* - `requested` null/undefined → null (no effort was asked for; pass no flag).
|
|
19
|
+
* - `supported` empty → null (effort is NOT a tunable surface for this adapter;
|
|
20
|
+
* it passes no effort flag at all — honest, not a silent clamp to a default).
|
|
21
|
+
* - `requested` exactly supported → returned unchanged.
|
|
22
|
+
* - otherwise CLAMP to the nearest supported level BY RANK: above the strongest
|
|
23
|
+
* supported → the strongest; below the weakest → the weakest; in-between → the
|
|
24
|
+
* closest by rank, ties resolving to the LOWER (cheaper) level.
|
|
25
|
+
*
|
|
26
|
+
* Pure and data-driven: the adapter feeds its own declared `effort_levels` and
|
|
27
|
+
* never hard-codes a clamp table.
|
|
28
|
+
*/
|
|
29
|
+
export function normalizeEffort(requested, supported) {
|
|
30
|
+
if (requested === null || requested === undefined)
|
|
31
|
+
return null;
|
|
32
|
+
if (supported.length === 0)
|
|
33
|
+
return null;
|
|
34
|
+
if (supported.includes(requested))
|
|
35
|
+
return requested;
|
|
36
|
+
const want = rank(requested);
|
|
37
|
+
let best = null;
|
|
38
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
39
|
+
for (const level of supported) {
|
|
40
|
+
const distance = Math.abs(rank(level) - want);
|
|
41
|
+
// Strictly-closer wins; on a tie keep the LOWER-ranked (cheaper) candidate.
|
|
42
|
+
if (distance < bestDistance || (distance === bestDistance && best !== null && rank(level) < rank(best))) {
|
|
43
|
+
best = level;
|
|
44
|
+
bestDistance = distance;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return best;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=effort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effort.js","sourceRoot":"","sources":["../src/effort.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,aAAa,GAA0B,gBAAgB,CAAC,OAAO,CAAC;AAEtE,SAAS,IAAI,CAAC,KAAiB;IAC7B,OAAO,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAwC,EACxC,SAAgC;IAEhC,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC/D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IAEpD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,IAAI,IAAI,GAAsB,IAAI,CAAC;IACnC,IAAI,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAC5C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9C,4EAA4E;QAC5E,IAAI,QAAQ,GAAG,YAAY,IAAI,CAAC,QAAQ,KAAK,YAAY,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACxG,IAAI,GAAG,KAAK,CAAC;YACb,YAAY,GAAG,QAAQ,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative env-scrub SSOT for harness children.
|
|
3
|
+
*
|
|
4
|
+
* Previously each adapter hand-rolled a partial denylist: codex scrubbed only
|
|
5
|
+
* OpenAI vars, claude only Anthropic/AWS/Google, cursor only its base-URL. The
|
|
6
|
+
* result was a cross-provider credential LEAK — a codex child inherited the
|
|
7
|
+
* user's `ANTHROPIC_API_KEY`, a claude child inherited `OPENAI_API_KEY`, etc.
|
|
8
|
+
*
|
|
9
|
+
* The contract is now uniform: scrub EVERY known provider credential / redirect
|
|
10
|
+
* env var from a harness child, then have the adapter re-add ONLY the single
|
|
11
|
+
* variable its chosen auth route legitimately needs (after the scrub). Base-URL
|
|
12
|
+
* redirects are always scrubbed so a redirect can never exfiltrate a seeded
|
|
13
|
+
* credential.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PROVIDER_SECRET_ENV: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* Build an env patch (`{VAR: null}`) that scrubs every provider secret EXCEPT the
|
|
18
|
+
* ones in `keep` (the vars the adapter's chosen route legitimately uses, which it
|
|
19
|
+
* sets explicitly afterward). Apply this AFTER spreading `spec.env`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function providerScrubEnv(keep?: readonly string[]): Record<string, null>;
|
|
22
|
+
/**
|
|
23
|
+
* Minimal env an interactive CLI genuinely needs to run (locale, terminal, temp,
|
|
24
|
+
* and PATH to find its own binary + tools). Everything else is dropped under
|
|
25
|
+
* `env_inheritance: "clean"` — agent env isolation. Exact var values still come
|
|
26
|
+
* from the parent; only the KEY SET is restricted. Provider secrets are NOT in
|
|
27
|
+
* the allowlist (defense-in-depth on top of providerScrubEnv), and the adapter
|
|
28
|
+
* re-adds its single chosen credential explicitly afterward.
|
|
29
|
+
*/
|
|
30
|
+
export declare const CLEAN_ENV_ALLOWLIST: readonly string[];
|
|
31
|
+
/**
|
|
32
|
+
* Build the base child env for a given inheritance mode. `mirror_native` copies
|
|
33
|
+
* the parent env (the native CLIs' default); `clean` copies only the minimal
|
|
34
|
+
* allowlist (agent isolation). The adapter's `spec.env` overrides + the
|
|
35
|
+
* providerScrubEnv patch are applied ON TOP of this by the spawn layer.
|
|
36
|
+
*/
|
|
37
|
+
export declare function composeBaseEnv(inheritance: "mirror_native" | "clean", source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
38
|
+
//# sourceMappingURL=env-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-scope.d.ts","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA6ChD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAOnF;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAoChD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,eAAe,GAAG,OAAO,EACtC,MAAM,GAAE,MAAM,CAAC,UAAwB,GACtC,MAAM,CAAC,UAAU,CASnB"}
|