astracode-agent 0.4.0 → 0.4.1
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 +36 -5
- package/dist/astracode-agent.cjs +1337 -458
- package/package.json +1 -1
package/dist/astracode-agent.cjs
CHANGED
|
@@ -55,43 +55,43 @@ var init_define_ASTRACODE_BUNDLED_SKILLS = __esm({
|
|
|
55
55
|
var require_shim_vscode = __commonJS({
|
|
56
56
|
"../packaging/bench/shim-vscode.js"(exports2, module2) {
|
|
57
57
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
58
|
-
var
|
|
59
|
-
var
|
|
58
|
+
var fs46 = require("node:fs");
|
|
59
|
+
var path54 = require("node:path");
|
|
60
60
|
function root2() {
|
|
61
61
|
const r = process.env.ASTRACODE_BENCH_ROOT;
|
|
62
62
|
if (!r) throw new Error("ASTRACODE_BENCH_ROOT is required");
|
|
63
|
-
return
|
|
63
|
+
return path54.resolve(r);
|
|
64
64
|
}
|
|
65
65
|
function roots() {
|
|
66
66
|
const extra = process.env.ASTRACODE_BENCH_ROOTS;
|
|
67
67
|
if (!extra) return [root2()];
|
|
68
|
-
return extra.split(
|
|
68
|
+
return extra.split(path54.delimiter).filter(Boolean).map((r) => path54.resolve(r));
|
|
69
69
|
}
|
|
70
70
|
function inTranscripts(full) {
|
|
71
71
|
const dir = process.env.ASTRACODE_TRANSCRIPTS_DIR;
|
|
72
72
|
if (!dir) return false;
|
|
73
|
-
let base =
|
|
73
|
+
let base = path54.resolve(dir);
|
|
74
74
|
try {
|
|
75
|
-
base =
|
|
75
|
+
base = fs46.realpathSync(base);
|
|
76
76
|
} catch {
|
|
77
77
|
}
|
|
78
|
-
return full.startsWith(base +
|
|
78
|
+
return full.startsWith(base + path54.sep);
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function resolve21(p) {
|
|
81
81
|
const bases = roots();
|
|
82
82
|
const raw = String(p).replace(/^file:\/\//, "");
|
|
83
|
-
const full =
|
|
83
|
+
const full = path54.isAbsolute(raw) ? path54.resolve(raw) : path54.resolve(bases[0], raw);
|
|
84
84
|
if (inTranscripts(full)) return full;
|
|
85
|
-
if (!bases.some((b) => full === b || full.startsWith(b +
|
|
85
|
+
if (!bases.some((b) => full === b || full.startsWith(b + path54.sep))) {
|
|
86
86
|
throw new Error(`refusing to touch ${full}: outside the fixture`);
|
|
87
87
|
}
|
|
88
88
|
return full;
|
|
89
89
|
}
|
|
90
90
|
var uri = (p) => ({
|
|
91
|
-
fsPath:
|
|
92
|
-
path:
|
|
91
|
+
fsPath: resolve21(p),
|
|
92
|
+
path: resolve21(p),
|
|
93
93
|
scheme: "file",
|
|
94
|
-
toString: () => `file://${
|
|
94
|
+
toString: () => `file://${resolve21(p)}`
|
|
95
95
|
});
|
|
96
96
|
function globToRegExp2(glob2) {
|
|
97
97
|
let re = "";
|
|
@@ -114,9 +114,9 @@ var require_shim_vscode = __commonJS({
|
|
|
114
114
|
return new RegExp(`^${re}$`);
|
|
115
115
|
}
|
|
116
116
|
function walk5(dir, out2 = []) {
|
|
117
|
-
for (const e of
|
|
117
|
+
for (const e of fs46.readdirSync(dir, { withFileTypes: true })) {
|
|
118
118
|
if (e.name === "node_modules" || e.name === ".git" || e.name === "dist") continue;
|
|
119
|
-
const full =
|
|
119
|
+
const full = path54.join(dir, e.name);
|
|
120
120
|
if (e.isDirectory()) walk5(full, out2);
|
|
121
121
|
else out2.push(full);
|
|
122
122
|
}
|
|
@@ -158,7 +158,7 @@ var require_shim_vscode = __commonJS({
|
|
|
158
158
|
*/
|
|
159
159
|
env: {
|
|
160
160
|
get appRoot() {
|
|
161
|
-
return process.env.ASTRACODE_BENCH_APP_ROOT ||
|
|
161
|
+
return process.env.ASTRACODE_BENCH_APP_ROOT || path54.join(root2(), ".no-app-root");
|
|
162
162
|
}
|
|
163
163
|
},
|
|
164
164
|
workspace: {
|
|
@@ -179,7 +179,7 @@ var require_shim_vscode = __commonJS({
|
|
|
179
179
|
// The real API names a folder after its directory, and the agent
|
|
180
180
|
// matches that name against the head of a path -- so inventing a name
|
|
181
181
|
// here would make the shim pass paths the product rejects.
|
|
182
|
-
name:
|
|
182
|
+
name: path54.basename(r),
|
|
183
183
|
index
|
|
184
184
|
}));
|
|
185
185
|
},
|
|
@@ -208,10 +208,10 @@ var require_shim_vscode = __commonJS({
|
|
|
208
208
|
asRelativePath: (u, includeWorkspaceFolder) => {
|
|
209
209
|
const full = u?.fsPath ?? String(u);
|
|
210
210
|
const all = roots();
|
|
211
|
-
const owner = all.find((r) => full === r || full.startsWith(r +
|
|
212
|
-
const rel =
|
|
211
|
+
const owner = all.find((r) => full === r || full.startsWith(r + path54.sep)) ?? all[0];
|
|
212
|
+
const rel = path54.relative(owner, full).split(path54.sep).join("/");
|
|
213
213
|
const include = includeWorkspaceFolder === void 0 ? all.length > 1 : includeWorkspaceFolder;
|
|
214
|
-
return include ? `${
|
|
214
|
+
return include ? `${path54.basename(owner)}/${rel}` : rel;
|
|
215
215
|
},
|
|
216
216
|
// Spans every folder, as the real findFiles does -- which is precisely how
|
|
217
217
|
// paths from a second repository reach a model that cannot open them.
|
|
@@ -228,7 +228,7 @@ var require_shim_vscode = __commonJS({
|
|
|
228
228
|
const out2 = [];
|
|
229
229
|
for (const r of roots()) {
|
|
230
230
|
for (const f of walk5(r)) {
|
|
231
|
-
const rel =
|
|
231
|
+
const rel = path54.relative(r, f).split(path54.sep).join("/");
|
|
232
232
|
if (!inc.test(rel)) continue;
|
|
233
233
|
if (exc && exc.test(rel)) continue;
|
|
234
234
|
out2.push(uri(f));
|
|
@@ -238,7 +238,7 @@ var require_shim_vscode = __commonJS({
|
|
|
238
238
|
return out2;
|
|
239
239
|
},
|
|
240
240
|
openTextDocument: async (u) => {
|
|
241
|
-
const text2 =
|
|
241
|
+
const text2 = fs46.existsSync(u.fsPath) ? fs46.readFileSync(u.fsPath, "utf8") : "";
|
|
242
242
|
const lines2 = text2.split("\n");
|
|
243
243
|
return {
|
|
244
244
|
uri: u,
|
|
@@ -259,10 +259,10 @@ var require_shim_vscode = __commonJS({
|
|
|
259
259
|
},
|
|
260
260
|
applyEdit: async (edit) => {
|
|
261
261
|
for (const op of edit.ops) {
|
|
262
|
-
if (op.kind === "delete")
|
|
262
|
+
if (op.kind === "delete") fs46.rmSync(op.path, { force: true });
|
|
263
263
|
else {
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
fs46.mkdirSync(path54.dirname(op.path), { recursive: true });
|
|
265
|
+
fs46.writeFileSync(op.path, op.text, "utf8");
|
|
266
266
|
UNSAVED.add(op.path);
|
|
267
267
|
}
|
|
268
268
|
}
|
|
@@ -289,7 +289,7 @@ var require_shim_vscode = __commonJS({
|
|
|
289
289
|
*/
|
|
290
290
|
readFile: async (u) => {
|
|
291
291
|
try {
|
|
292
|
-
return
|
|
292
|
+
return fs46.readFileSync(u.fsPath);
|
|
293
293
|
} catch (err2) {
|
|
294
294
|
if (err2 && err2.code === "ENOENT") {
|
|
295
295
|
const e = new Error(`file not found: ${u.fsPath}`);
|
|
@@ -313,20 +313,20 @@ var require_shim_vscode = __commonJS({
|
|
|
313
313
|
* would break the caller that relies on exactly that.
|
|
314
314
|
*/
|
|
315
315
|
createDirectory: async (u) => {
|
|
316
|
-
|
|
316
|
+
fs46.mkdirSync(u.fsPath, { recursive: true });
|
|
317
317
|
},
|
|
318
318
|
writeFile: async (u, data) => {
|
|
319
319
|
if (inTranscripts(u.fsPath)) throw new Error(`refusing to write ${u.fsPath}: transcripts are read-only`);
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
fs46.mkdirSync(path54.dirname(u.fsPath), { recursive: true });
|
|
321
|
+
fs46.writeFileSync(u.fsPath, Buffer.from(data));
|
|
322
322
|
},
|
|
323
323
|
stat: async (u) => {
|
|
324
|
-
const st =
|
|
324
|
+
const st = fs46.statSync(u.fsPath);
|
|
325
325
|
return { type: st.isDirectory() ? 2 : 1, size: st.size };
|
|
326
326
|
},
|
|
327
327
|
delete: async (u) => {
|
|
328
328
|
if (inTranscripts(u.fsPath)) throw new Error(`refusing to delete ${u.fsPath}: transcripts are read-only`);
|
|
329
|
-
|
|
329
|
+
fs46.rmSync(u.fsPath, { force: true, recursive: true });
|
|
330
330
|
}
|
|
331
331
|
},
|
|
332
332
|
onDidChangeVisibleTextEditors: () => ({ dispose() {
|
|
@@ -392,7 +392,7 @@ var require_shim_vscode = __commonJS({
|
|
|
392
392
|
Uri: {
|
|
393
393
|
file: uri,
|
|
394
394
|
parse: (s) => uri(s.replace(/^file:\/\//, "")),
|
|
395
|
-
joinPath: (base, ...parts2) => uri(
|
|
395
|
+
joinPath: (base, ...parts2) => uri(path54.join(base.fsPath ?? root2(), ...parts2))
|
|
396
396
|
},
|
|
397
397
|
Position: Position3,
|
|
398
398
|
Range,
|
|
@@ -679,16 +679,16 @@ var sleep;
|
|
|
679
679
|
var init_sleep = __esm({
|
|
680
680
|
"../editor/node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs"() {
|
|
681
681
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
682
|
-
sleep = (ms, signal) => new Promise((
|
|
682
|
+
sleep = (ms, signal) => new Promise((resolve21) => {
|
|
683
683
|
if (signal?.aborted)
|
|
684
|
-
return
|
|
684
|
+
return resolve21();
|
|
685
685
|
const onAbort = () => {
|
|
686
686
|
clearTimeout(timer);
|
|
687
|
-
|
|
687
|
+
resolve21();
|
|
688
688
|
};
|
|
689
689
|
const timer = setTimeout(() => {
|
|
690
690
|
signal?.removeEventListener("abort", onAbort);
|
|
691
|
-
|
|
691
|
+
resolve21();
|
|
692
692
|
}, ms);
|
|
693
693
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
694
694
|
});
|
|
@@ -1422,15 +1422,15 @@ function redactSensitive(body2) {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
return null;
|
|
1424
1424
|
}
|
|
1425
|
-
async function checkCredentialsFileSafety(
|
|
1425
|
+
async function checkCredentialsFileSafety(path54, onWarn = (m) => console.warn(`anthropic-sdk: ${m}`)) {
|
|
1426
1426
|
if (typeof process === "undefined" || process.platform === "win32")
|
|
1427
1427
|
return;
|
|
1428
|
-
const
|
|
1429
|
-
let resolved =
|
|
1428
|
+
const fs46 = await import("node:fs");
|
|
1429
|
+
let resolved = path54;
|
|
1430
1430
|
let st;
|
|
1431
1431
|
try {
|
|
1432
|
-
resolved = await
|
|
1433
|
-
st = await
|
|
1432
|
+
resolved = await fs46.promises.realpath(path54);
|
|
1433
|
+
st = await fs46.promises.stat(resolved);
|
|
1434
1434
|
} catch {
|
|
1435
1435
|
return;
|
|
1436
1436
|
}
|
|
@@ -1446,27 +1446,27 @@ async function checkCredentialsFileSafety(path52, onWarn = (m) => console.warn(`
|
|
|
1446
1446
|
}
|
|
1447
1447
|
}
|
|
1448
1448
|
async function writeCredentialsFileAtomic(targetPath, data) {
|
|
1449
|
-
const
|
|
1450
|
-
const
|
|
1451
|
-
const dir =
|
|
1452
|
-
await
|
|
1449
|
+
const fs46 = await import("node:fs");
|
|
1450
|
+
const path54 = await import("node:path");
|
|
1451
|
+
const dir = path54.dirname(targetPath);
|
|
1452
|
+
await fs46.promises.mkdir(dir, { recursive: true, mode: 448 });
|
|
1453
1453
|
const tmpPath = `${targetPath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
1454
1454
|
try {
|
|
1455
|
-
const fh = await
|
|
1455
|
+
const fh = await fs46.promises.open(tmpPath, "w", 384);
|
|
1456
1456
|
try {
|
|
1457
1457
|
await fh.writeFile(JSON.stringify(data, null, 2));
|
|
1458
1458
|
await fh.sync();
|
|
1459
1459
|
} finally {
|
|
1460
1460
|
await fh.close();
|
|
1461
1461
|
}
|
|
1462
|
-
await
|
|
1462
|
+
await fs46.promises.rename(tmpPath, targetPath);
|
|
1463
1463
|
} catch (err2) {
|
|
1464
|
-
await
|
|
1464
|
+
await fs46.promises.unlink(tmpPath).catch(() => {
|
|
1465
1465
|
});
|
|
1466
1466
|
throw err2;
|
|
1467
1467
|
}
|
|
1468
1468
|
try {
|
|
1469
|
-
const dirFh = await
|
|
1469
|
+
const dirFh = await fs46.promises.open(dir, "r");
|
|
1470
1470
|
try {
|
|
1471
1471
|
await dirFh.sync();
|
|
1472
1472
|
} finally {
|
|
@@ -1855,12 +1855,12 @@ var init_credentials = __esm({
|
|
|
1855
1855
|
return null;
|
|
1856
1856
|
}
|
|
1857
1857
|
validateProfileName(profileName);
|
|
1858
|
-
const
|
|
1859
|
-
const
|
|
1860
|
-
const configPath =
|
|
1858
|
+
const fs46 = await import("node:fs");
|
|
1859
|
+
const path54 = await import("node:path");
|
|
1860
|
+
const configPath = path54.join(rootConfigPath, "configs", `${profileName}.json`);
|
|
1861
1861
|
let configRaw;
|
|
1862
1862
|
try {
|
|
1863
|
-
configRaw = await
|
|
1863
|
+
configRaw = await fs46.promises.readFile(configPath, "utf-8");
|
|
1864
1864
|
} catch (err2) {
|
|
1865
1865
|
if (err2?.code !== "ENOENT") {
|
|
1866
1866
|
throw new Error(`failed to read config file ${configPath}: ${err2}`);
|
|
@@ -1941,14 +1941,14 @@ var init_credentials = __esm({
|
|
|
1941
1941
|
return null;
|
|
1942
1942
|
}
|
|
1943
1943
|
validateProfileName(profileName);
|
|
1944
|
-
const
|
|
1945
|
-
return
|
|
1944
|
+
const path54 = await import("node:path");
|
|
1945
|
+
return path54.join(rootConfigPath, "credentials", `${profileName}.json`);
|
|
1946
1946
|
};
|
|
1947
1947
|
getRootConfigPath = async () => {
|
|
1948
1948
|
if (!supportsLocalConfigFiles()) {
|
|
1949
1949
|
return null;
|
|
1950
1950
|
}
|
|
1951
|
-
const
|
|
1951
|
+
const path54 = await import("node:path");
|
|
1952
1952
|
const configDir2 = readEnv("ANTHROPIC_CONFIG_DIR");
|
|
1953
1953
|
if (configDir2) {
|
|
1954
1954
|
return configDir2;
|
|
@@ -1957,21 +1957,21 @@ var init_credentials = __esm({
|
|
|
1957
1957
|
if (os17 === "Windows") {
|
|
1958
1958
|
const appData = readEnv("APPDATA");
|
|
1959
1959
|
if (appData) {
|
|
1960
|
-
return
|
|
1960
|
+
return path54.join(appData, "Anthropic");
|
|
1961
1961
|
}
|
|
1962
1962
|
const userProfile = readEnv("USERPROFILE");
|
|
1963
1963
|
if (userProfile) {
|
|
1964
|
-
return
|
|
1964
|
+
return path54.join(userProfile, "AppData", "Roaming", "Anthropic");
|
|
1965
1965
|
}
|
|
1966
1966
|
return null;
|
|
1967
1967
|
}
|
|
1968
1968
|
const xdgConfigHome = readEnv("XDG_CONFIG_HOME");
|
|
1969
1969
|
if (xdgConfigHome) {
|
|
1970
|
-
return
|
|
1970
|
+
return path54.join(xdgConfigHome, "anthropic");
|
|
1971
1971
|
}
|
|
1972
1972
|
const home2 = readEnv("HOME");
|
|
1973
1973
|
if (home2) {
|
|
1974
|
-
return
|
|
1974
|
+
return path54.join(home2, ".config", "anthropic");
|
|
1975
1975
|
}
|
|
1976
1976
|
return null;
|
|
1977
1977
|
};
|
|
@@ -1988,11 +1988,11 @@ var init_credentials = __esm({
|
|
|
1988
1988
|
if (profileName) {
|
|
1989
1989
|
return profileName;
|
|
1990
1990
|
}
|
|
1991
|
-
const
|
|
1992
|
-
const
|
|
1993
|
-
const filePath =
|
|
1991
|
+
const fs46 = await import("node:fs");
|
|
1992
|
+
const path54 = await import("node:path");
|
|
1993
|
+
const filePath = path54.join(rootConfigPath, "active_config");
|
|
1994
1994
|
try {
|
|
1995
|
-
return (await
|
|
1995
|
+
return (await fs46.promises.readFile(filePath, "utf-8")).trim() || "default";
|
|
1996
1996
|
} catch (err2) {
|
|
1997
1997
|
if (err2?.code !== "ENOENT") {
|
|
1998
1998
|
throw new Error(`failed to read ${filePath}: ${err2}`);
|
|
@@ -2004,21 +2004,21 @@ var init_credentials = __esm({
|
|
|
2004
2004
|
});
|
|
2005
2005
|
|
|
2006
2006
|
// ../editor/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs
|
|
2007
|
-
function identityTokenFromFile(
|
|
2008
|
-
if (!
|
|
2007
|
+
function identityTokenFromFile(path54) {
|
|
2008
|
+
if (!path54) {
|
|
2009
2009
|
throw new AnthropicError("Identity token file path is empty");
|
|
2010
2010
|
}
|
|
2011
2011
|
return async () => {
|
|
2012
|
-
const
|
|
2012
|
+
const fs46 = await import("node:fs");
|
|
2013
2013
|
let content;
|
|
2014
2014
|
try {
|
|
2015
|
-
content = await
|
|
2015
|
+
content = await fs46.promises.readFile(path54, "utf-8");
|
|
2016
2016
|
} catch (err2) {
|
|
2017
|
-
throw new AnthropicError(`Failed to read identity token file at ${
|
|
2017
|
+
throw new AnthropicError(`Failed to read identity token file at ${path54}: ${err2}`);
|
|
2018
2018
|
}
|
|
2019
2019
|
const token = content.trim();
|
|
2020
2020
|
if (!token) {
|
|
2021
|
-
throw new AnthropicError(`Identity token file at ${
|
|
2021
|
+
throw new AnthropicError(`Identity token file at ${path54} is empty`);
|
|
2022
2022
|
}
|
|
2023
2023
|
return token;
|
|
2024
2024
|
};
|
|
@@ -2105,11 +2105,11 @@ var init_oidc_federation = __esm({
|
|
|
2105
2105
|
// ../editor/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.mjs
|
|
2106
2106
|
function userOAuthProvider(config3) {
|
|
2107
2107
|
return async (opts) => {
|
|
2108
|
-
const
|
|
2108
|
+
const fs46 = await import("node:fs");
|
|
2109
2109
|
await checkCredentialsFileSafety(config3.credentialsPath, config3.onSafetyWarning);
|
|
2110
2110
|
let raw;
|
|
2111
2111
|
try {
|
|
2112
|
-
raw = await
|
|
2112
|
+
raw = await fs46.promises.readFile(config3.credentialsPath, "utf-8");
|
|
2113
2113
|
} catch (err2) {
|
|
2114
2114
|
throw new WorkloadIdentityError(`Credentials file not found at ${config3.credentialsPath}: ${err2}`);
|
|
2115
2115
|
}
|
|
@@ -2282,11 +2282,11 @@ function resolveIdentityTokenProvider(auth) {
|
|
|
2282
2282
|
}
|
|
2283
2283
|
function cachedExchangeProvider(exchange2, credentialsPath, onCacheWriteError, onSafetyWarning) {
|
|
2284
2284
|
return async (opts) => {
|
|
2285
|
-
const
|
|
2285
|
+
const fs46 = await import("node:fs");
|
|
2286
2286
|
await checkCredentialsFileSafety(credentialsPath, onSafetyWarning);
|
|
2287
2287
|
let existing;
|
|
2288
2288
|
try {
|
|
2289
|
-
const raw = await
|
|
2289
|
+
const raw = await fs46.promises.readFile(credentialsPath, "utf-8");
|
|
2290
2290
|
existing = JSON.parse(raw);
|
|
2291
2291
|
const token = existing?.["access_token"];
|
|
2292
2292
|
if (token && !opts?.forceRefresh) {
|
|
@@ -2867,8 +2867,8 @@ var init_api_promise = __esm({
|
|
|
2867
2867
|
init_parse();
|
|
2868
2868
|
APIPromise = class _APIPromise extends Promise {
|
|
2869
2869
|
constructor(client, responsePromise, parseResponse = defaultParseResponse) {
|
|
2870
|
-
super((
|
|
2871
|
-
|
|
2870
|
+
super((resolve21) => {
|
|
2871
|
+
resolve21(null);
|
|
2872
2872
|
});
|
|
2873
2873
|
this.responsePromise = responsePromise;
|
|
2874
2874
|
this.parseResponse = parseResponse;
|
|
@@ -3373,12 +3373,12 @@ var init_path = __esm({
|
|
|
3373
3373
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
3374
3374
|
init_error();
|
|
3375
3375
|
EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
3376
|
-
createPathTagFunction = (pathEncoder = encodeURIPath) => function
|
|
3376
|
+
createPathTagFunction = (pathEncoder = encodeURIPath) => function path54(statics, ...params) {
|
|
3377
3377
|
if (statics.length === 1)
|
|
3378
3378
|
return statics[0];
|
|
3379
3379
|
let postPath = false;
|
|
3380
3380
|
const invalidSegments = [];
|
|
3381
|
-
const
|
|
3381
|
+
const path55 = statics.reduce((previousValue, currentValue, index) => {
|
|
3382
3382
|
if (/[?#]/.test(currentValue)) {
|
|
3383
3383
|
postPath = true;
|
|
3384
3384
|
}
|
|
@@ -3395,7 +3395,7 @@ var init_path = __esm({
|
|
|
3395
3395
|
}
|
|
3396
3396
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
3397
3397
|
}, "");
|
|
3398
|
-
const pathOnly =
|
|
3398
|
+
const pathOnly = path55.split(/[?#]/, 1)[0];
|
|
3399
3399
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
3400
3400
|
let match;
|
|
3401
3401
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -3416,10 +3416,10 @@ var init_path = __esm({
|
|
|
3416
3416
|
}, "");
|
|
3417
3417
|
throw new AnthropicError(`Path parameters result in path with invalid segments:
|
|
3418
3418
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
3419
|
-
${
|
|
3419
|
+
${path55}
|
|
3420
3420
|
${underline}`);
|
|
3421
3421
|
}
|
|
3422
|
-
return
|
|
3422
|
+
return path55;
|
|
3423
3423
|
};
|
|
3424
3424
|
path12 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
3425
3425
|
}
|
|
@@ -5427,16 +5427,16 @@ var init_async_queue = __esm({
|
|
|
5427
5427
|
if (__classPrivateFieldGet(this, _AsyncQueue_closed, "f") || signal?.aborted) {
|
|
5428
5428
|
return Promise.resolve({ done: true, value: void 0 });
|
|
5429
5429
|
}
|
|
5430
|
-
return new Promise((
|
|
5430
|
+
return new Promise((resolve21) => {
|
|
5431
5431
|
const waiter = (r) => {
|
|
5432
5432
|
signal?.removeEventListener("abort", onAbort);
|
|
5433
|
-
|
|
5433
|
+
resolve21(r);
|
|
5434
5434
|
};
|
|
5435
5435
|
const onAbort = () => {
|
|
5436
5436
|
const idx = __classPrivateFieldGet(this, _AsyncQueue_waiters, "f").indexOf(waiter);
|
|
5437
5437
|
if (idx >= 0)
|
|
5438
5438
|
__classPrivateFieldGet(this, _AsyncQueue_waiters, "f").splice(idx, 1);
|
|
5439
|
-
|
|
5439
|
+
resolve21({ done: true, value: void 0 });
|
|
5440
5440
|
};
|
|
5441
5441
|
__classPrivateFieldGet(this, _AsyncQueue_waiters, "f").push(waiter);
|
|
5442
5442
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
@@ -6076,13 +6076,13 @@ var init_json_schema = __esm({
|
|
|
6076
6076
|
|
|
6077
6077
|
// ../editor/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs
|
|
6078
6078
|
function promiseWithResolvers() {
|
|
6079
|
-
let
|
|
6079
|
+
let resolve21;
|
|
6080
6080
|
let reject;
|
|
6081
6081
|
const promise2 = new Promise((res, rej) => {
|
|
6082
|
-
|
|
6082
|
+
resolve21 = res;
|
|
6083
6083
|
reject = rej;
|
|
6084
6084
|
});
|
|
6085
|
-
return { promise: promise2, resolve:
|
|
6085
|
+
return { promise: promise2, resolve: resolve21, reject };
|
|
6086
6086
|
}
|
|
6087
6087
|
var init_promise = __esm({
|
|
6088
6088
|
"../editor/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs"() {
|
|
@@ -6235,10 +6235,10 @@ async function setupSkills(ctx) {
|
|
|
6235
6235
|
try {
|
|
6236
6236
|
const versionId = await resolveSkillVersion(client, skill.skill_id, skill.version);
|
|
6237
6237
|
const version3 = await client.beta.skills.versions.retrieve(versionId, { skill_id: skill.skill_id });
|
|
6238
|
-
let
|
|
6239
|
-
if (
|
|
6240
|
-
|
|
6241
|
-
const dest = path14.resolve(skillsRoot,
|
|
6238
|
+
let dirname25 = path14.basename(version3.name.trim());
|
|
6239
|
+
if (dirname25 === "" || dirname25 === "." || dirname25 === "..")
|
|
6240
|
+
dirname25 = skill.skill_id;
|
|
6241
|
+
const dest = path14.resolve(skillsRoot, dirname25);
|
|
6242
6242
|
if (dest !== skillsRoot && !dest.startsWith(skillsRoot + path14.sep)) {
|
|
6243
6243
|
log2.warn("skill name escapes the skills dir; skipping", {
|
|
6244
6244
|
component: "agent-tool-context",
|
|
@@ -6894,10 +6894,10 @@ async function settledOrAborted(p, signal) {
|
|
|
6894
6894
|
return;
|
|
6895
6895
|
}
|
|
6896
6896
|
let onAbort;
|
|
6897
|
-
const aborted2 = new Promise((
|
|
6898
|
-
onAbort =
|
|
6897
|
+
const aborted2 = new Promise((resolve21) => {
|
|
6898
|
+
onAbort = resolve21;
|
|
6899
6899
|
if (signal.aborted)
|
|
6900
|
-
|
|
6900
|
+
resolve21();
|
|
6901
6901
|
});
|
|
6902
6902
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
6903
6903
|
try {
|
|
@@ -7937,7 +7937,7 @@ function betaGrepTool(ctx) {
|
|
|
7937
7937
|
});
|
|
7938
7938
|
}
|
|
7939
7939
|
function runRipgrep(rg, pattern, searchPath, signal) {
|
|
7940
|
-
return new Promise((
|
|
7940
|
+
return new Promise((resolve21, reject) => {
|
|
7941
7941
|
const proc = cp.spawn(rg, ["-n", "--no-heading", "-e", pattern, "--", searchPath], {
|
|
7942
7942
|
...signal ? { signal } : {}
|
|
7943
7943
|
});
|
|
@@ -7959,12 +7959,12 @@ function runRipgrep(rg, pattern, searchPath, signal) {
|
|
|
7959
7959
|
if (signal?.aborted)
|
|
7960
7960
|
return reject(new ToolError("grep: aborted"));
|
|
7961
7961
|
if (truncated)
|
|
7962
|
-
return
|
|
7962
|
+
return resolve21(out2 + `
|
|
7963
7963
|
[output truncated at ${GREP_OUTPUT_LIMIT} bytes]`);
|
|
7964
7964
|
if (code === 0)
|
|
7965
|
-
return
|
|
7965
|
+
return resolve21(out2);
|
|
7966
7966
|
if (code === 1)
|
|
7967
|
-
return
|
|
7967
|
+
return resolve21("no matches");
|
|
7968
7968
|
reject(new ToolError(`grep: rg failed: ${errOut || `exit ${code}`}`));
|
|
7969
7969
|
});
|
|
7970
7970
|
proc.on("error", (e) => {
|
|
@@ -8150,8 +8150,8 @@ var init_node = __esm({
|
|
|
8150
8150
|
`;
|
|
8151
8151
|
__classPrivateFieldGet(this, _BashSession_proc, "f").stdin.write(wrapped);
|
|
8152
8152
|
if (__classPrivateFieldGet(this, _BashSession_buf, "f").indexOf(sentinel2) < 0) {
|
|
8153
|
-
const { promise: sentinelSeen, resolve:
|
|
8154
|
-
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel2, resolve:
|
|
8153
|
+
const { promise: sentinelSeen, resolve: resolve21 } = promiseWithResolvers();
|
|
8154
|
+
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel2, resolve: resolve21 }, "f");
|
|
8155
8155
|
let timer;
|
|
8156
8156
|
let onAbort;
|
|
8157
8157
|
try {
|
|
@@ -8249,8 +8249,8 @@ async function withTimeout(p, ms) {
|
|
|
8249
8249
|
try {
|
|
8250
8250
|
return await Promise.race([
|
|
8251
8251
|
p.then(() => false, () => false),
|
|
8252
|
-
new Promise((
|
|
8253
|
-
timer = setTimeout(() =>
|
|
8252
|
+
new Promise((resolve21) => {
|
|
8253
|
+
timer = setTimeout(() => resolve21(true), ms);
|
|
8254
8254
|
})
|
|
8255
8255
|
]);
|
|
8256
8256
|
} finally {
|
|
@@ -10084,12 +10084,12 @@ var init_BetaMessageStream = __esm({
|
|
|
10084
10084
|
}
|
|
10085
10085
|
return this._emit("error", new AnthropicError(String(error51)));
|
|
10086
10086
|
});
|
|
10087
|
-
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
10088
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise,
|
|
10087
|
+
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((resolve21, reject) => {
|
|
10088
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve21, "f");
|
|
10089
10089
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
10090
10090
|
}), "f");
|
|
10091
|
-
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((
|
|
10092
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise,
|
|
10091
|
+
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((resolve21, reject) => {
|
|
10092
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve21, "f");
|
|
10093
10093
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
10094
10094
|
}), "f");
|
|
10095
10095
|
__classPrivateFieldGet(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -10264,11 +10264,11 @@ var init_BetaMessageStream = __esm({
|
|
|
10264
10264
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
10265
10265
|
*/
|
|
10266
10266
|
emitted(event) {
|
|
10267
|
-
return new Promise((
|
|
10267
|
+
return new Promise((resolve21, reject) => {
|
|
10268
10268
|
__classPrivateFieldSet(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
10269
10269
|
if (event !== "error")
|
|
10270
10270
|
this.once("error", reject);
|
|
10271
|
-
this.once(event,
|
|
10271
|
+
this.once(event, resolve21);
|
|
10272
10272
|
});
|
|
10273
10273
|
}
|
|
10274
10274
|
async done() {
|
|
@@ -10638,7 +10638,7 @@ var init_BetaMessageStream = __esm({
|
|
|
10638
10638
|
if (done2) {
|
|
10639
10639
|
return { value: void 0, done: true };
|
|
10640
10640
|
}
|
|
10641
|
-
return new Promise((
|
|
10641
|
+
return new Promise((resolve21, reject) => readQueue.push({ resolve: resolve21, reject })).then((chunk3) => chunk3 ? { value: chunk3, done: false } : { value: void 0, done: true });
|
|
10642
10642
|
}
|
|
10643
10643
|
const chunk2 = pushQueue.shift();
|
|
10644
10644
|
return { value: chunk2, done: false };
|
|
@@ -12966,12 +12966,12 @@ var init_MessageStream = __esm({
|
|
|
12966
12966
|
}
|
|
12967
12967
|
return this._emit("error", new AnthropicError(String(error51)));
|
|
12968
12968
|
});
|
|
12969
|
-
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((
|
|
12970
|
-
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise,
|
|
12969
|
+
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((resolve21, reject) => {
|
|
12970
|
+
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve21, "f");
|
|
12971
12971
|
__classPrivateFieldSet(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
12972
12972
|
}), "f");
|
|
12973
|
-
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((
|
|
12974
|
-
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise,
|
|
12973
|
+
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((resolve21, reject) => {
|
|
12974
|
+
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve21, "f");
|
|
12975
12975
|
__classPrivateFieldSet(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
12976
12976
|
}), "f");
|
|
12977
12977
|
__classPrivateFieldGet(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -13146,11 +13146,11 @@ var init_MessageStream = __esm({
|
|
|
13146
13146
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
13147
13147
|
*/
|
|
13148
13148
|
emitted(event) {
|
|
13149
|
-
return new Promise((
|
|
13149
|
+
return new Promise((resolve21, reject) => {
|
|
13150
13150
|
__classPrivateFieldSet(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
13151
13151
|
if (event !== "error")
|
|
13152
13152
|
this.once("error", reject);
|
|
13153
|
-
this.once(event,
|
|
13153
|
+
this.once(event, resolve21);
|
|
13154
13154
|
});
|
|
13155
13155
|
}
|
|
13156
13156
|
async done() {
|
|
@@ -13475,7 +13475,7 @@ var init_MessageStream = __esm({
|
|
|
13475
13475
|
if (done2) {
|
|
13476
13476
|
return { value: void 0, done: true };
|
|
13477
13477
|
}
|
|
13478
|
-
return new Promise((
|
|
13478
|
+
return new Promise((resolve21, reject) => readQueue.push({ resolve: resolve21, reject })).then((chunk3) => chunk3 ? { value: chunk3, done: false } : { value: void 0, done: true });
|
|
13479
13479
|
}
|
|
13480
13480
|
const chunk2 = pushQueue.shift();
|
|
13481
13481
|
return { value: chunk2, done: false };
|
|
@@ -14280,9 +14280,9 @@ var init_client = __esm({
|
|
|
14280
14280
|
makeStatusError(status3, error51, message, headers) {
|
|
14281
14281
|
return APIError.generate(status3, error51, message, headers);
|
|
14282
14282
|
}
|
|
14283
|
-
buildURL(
|
|
14283
|
+
buildURL(path54, query, defaultBaseURL) {
|
|
14284
14284
|
const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
14285
|
-
const url2 = isAbsoluteURL(
|
|
14285
|
+
const url2 = isAbsoluteURL(path54) ? new URL(path54) : new URL(baseURL + (baseURL.endsWith("/") && path54.startsWith("/") ? path54.slice(1) : path54));
|
|
14286
14286
|
const defaultQuery = this.defaultQuery();
|
|
14287
14287
|
const pathQuery = Object.fromEntries(url2.searchParams);
|
|
14288
14288
|
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
@@ -14354,24 +14354,24 @@ var init_client = __esm({
|
|
|
14354
14354
|
backendMiddleware() {
|
|
14355
14355
|
return [];
|
|
14356
14356
|
}
|
|
14357
|
-
get(
|
|
14358
|
-
return this.methodRequest("get",
|
|
14357
|
+
get(path54, opts) {
|
|
14358
|
+
return this.methodRequest("get", path54, opts);
|
|
14359
14359
|
}
|
|
14360
|
-
post(
|
|
14361
|
-
return this.methodRequest("post",
|
|
14360
|
+
post(path54, opts) {
|
|
14361
|
+
return this.methodRequest("post", path54, opts);
|
|
14362
14362
|
}
|
|
14363
|
-
patch(
|
|
14364
|
-
return this.methodRequest("patch",
|
|
14363
|
+
patch(path54, opts) {
|
|
14364
|
+
return this.methodRequest("patch", path54, opts);
|
|
14365
14365
|
}
|
|
14366
|
-
put(
|
|
14367
|
-
return this.methodRequest("put",
|
|
14366
|
+
put(path54, opts) {
|
|
14367
|
+
return this.methodRequest("put", path54, opts);
|
|
14368
14368
|
}
|
|
14369
|
-
delete(
|
|
14370
|
-
return this.methodRequest("delete",
|
|
14369
|
+
delete(path54, opts) {
|
|
14370
|
+
return this.methodRequest("delete", path54, opts);
|
|
14371
14371
|
}
|
|
14372
|
-
methodRequest(method,
|
|
14372
|
+
methodRequest(method, path54, opts) {
|
|
14373
14373
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
14374
|
-
return { method, path:
|
|
14374
|
+
return { method, path: path54, ...opts2 };
|
|
14375
14375
|
}));
|
|
14376
14376
|
}
|
|
14377
14377
|
request(options, remainingRetries = null) {
|
|
@@ -14489,8 +14489,8 @@ var init_client = __esm({
|
|
|
14489
14489
|
armAbandonmentBackstop(response.body ?? response, controller);
|
|
14490
14490
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
14491
14491
|
}
|
|
14492
|
-
getAPIList(
|
|
14493
|
-
return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
14492
|
+
getAPIList(path54, Page2, opts) {
|
|
14493
|
+
return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path54, ...opts2 })) : { method: "get", path: path54, ...opts });
|
|
14494
14494
|
}
|
|
14495
14495
|
requestAPIList(Page2, options) {
|
|
14496
14496
|
const request = this.makeRequest(options, null, void 0);
|
|
@@ -14608,14 +14608,14 @@ var init_client = __esm({
|
|
|
14608
14608
|
}
|
|
14609
14609
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
14610
14610
|
const options = { ...inputOptions };
|
|
14611
|
-
const { method, path:
|
|
14611
|
+
const { method, path: path54, query, defaultBaseURL } = options;
|
|
14612
14612
|
if (this._authState.resolution) {
|
|
14613
14613
|
await this._authState.resolution;
|
|
14614
14614
|
}
|
|
14615
14615
|
if (!this._baseURLIsExplicit && this._authState.baseURL && this.baseURL !== this._authState.baseURL) {
|
|
14616
14616
|
this.baseURL = this._authState.baseURL;
|
|
14617
14617
|
}
|
|
14618
|
-
const url2 = this.buildURL(
|
|
14618
|
+
const url2 = this.buildURL(path54, query, defaultBaseURL);
|
|
14619
14619
|
if ("timeout" in options)
|
|
14620
14620
|
validatePositiveInteger("timeout", options.timeout);
|
|
14621
14621
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -16826,8 +16826,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
16826
16826
|
var moduleRtn;
|
|
16827
16827
|
var Module = moduleArg;
|
|
16828
16828
|
var readyPromiseResolve, readyPromiseReject;
|
|
16829
|
-
var readyPromise = new Promise((
|
|
16830
|
-
readyPromiseResolve =
|
|
16829
|
+
var readyPromise = new Promise((resolve21, reject) => {
|
|
16830
|
+
readyPromiseResolve = resolve21;
|
|
16831
16831
|
readyPromiseReject = reject;
|
|
16832
16832
|
});
|
|
16833
16833
|
var ENVIRONMENT_IS_WEB = typeof window == "object";
|
|
@@ -16849,11 +16849,11 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
16849
16849
|
throw toThrow;
|
|
16850
16850
|
}, "quit_");
|
|
16851
16851
|
var scriptDirectory = "";
|
|
16852
|
-
function locateFile(
|
|
16852
|
+
function locateFile(path54) {
|
|
16853
16853
|
if (Module["locateFile"]) {
|
|
16854
|
-
return Module["locateFile"](
|
|
16854
|
+
return Module["locateFile"](path54, scriptDirectory);
|
|
16855
16855
|
}
|
|
16856
|
-
return scriptDirectory +
|
|
16856
|
+
return scriptDirectory + path54;
|
|
16857
16857
|
}
|
|
16858
16858
|
__name(locateFile, "locateFile");
|
|
16859
16859
|
var readAsync, readBinary;
|
|
@@ -16868,10 +16868,10 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
16868
16868
|
}, "readBinary");
|
|
16869
16869
|
readAsync = /* @__PURE__ */ __name((filename, binary2 = true) => {
|
|
16870
16870
|
filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
|
|
16871
|
-
return new Promise((
|
|
16871
|
+
return new Promise((resolve21, reject) => {
|
|
16872
16872
|
fs.readFile(filename, binary2 ? void 0 : "utf8", (err2, data) => {
|
|
16873
16873
|
if (err2) reject(err2);
|
|
16874
|
-
else
|
|
16874
|
+
else resolve21(binary2 ? data.buffer : data);
|
|
16875
16875
|
});
|
|
16876
16876
|
});
|
|
16877
16877
|
}, "readAsync");
|
|
@@ -16912,13 +16912,13 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
16912
16912
|
}
|
|
16913
16913
|
readAsync = /* @__PURE__ */ __name((url2) => {
|
|
16914
16914
|
if (isFileURI(url2)) {
|
|
16915
|
-
return new Promise((reject,
|
|
16915
|
+
return new Promise((reject, resolve21) => {
|
|
16916
16916
|
var xhr = new XMLHttpRequest();
|
|
16917
16917
|
xhr.open("GET", url2, true);
|
|
16918
16918
|
xhr.responseType = "arraybuffer";
|
|
16919
16919
|
xhr.onload = () => {
|
|
16920
16920
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
16921
|
-
|
|
16921
|
+
resolve21(xhr.response);
|
|
16922
16922
|
}
|
|
16923
16923
|
reject(xhr.status);
|
|
16924
16924
|
};
|
|
@@ -17932,8 +17932,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
17932
17932
|
}
|
|
17933
17933
|
var libFile = locateFile(libName2);
|
|
17934
17934
|
if (flags2.loadAsync) {
|
|
17935
|
-
return new Promise(function(
|
|
17936
|
-
asyncLoad(libFile,
|
|
17935
|
+
return new Promise(function(resolve21, reject) {
|
|
17936
|
+
asyncLoad(libFile, resolve21, reject);
|
|
17937
17937
|
});
|
|
17938
17938
|
}
|
|
17939
17939
|
if (!readBinary) {
|
|
@@ -18817,7 +18817,7 @@ __export(main_exports, {
|
|
|
18817
18817
|
});
|
|
18818
18818
|
module.exports = __toCommonJS(main_exports);
|
|
18819
18819
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
18820
|
-
var
|
|
18820
|
+
var path53 = __toESM(require("node:path"));
|
|
18821
18821
|
|
|
18822
18822
|
// ../editor/src/agent/orchestrator.ts
|
|
18823
18823
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
@@ -18859,9 +18859,9 @@ var DebugSink = class _DebugSink {
|
|
|
18859
18859
|
fs2.writeFileSync(file2, "", { mode: 384 });
|
|
18860
18860
|
const ready = {};
|
|
18861
18861
|
const server = http.createServer((req, res) => ready.sink?.handle(req, res));
|
|
18862
|
-
await new Promise((
|
|
18862
|
+
await new Promise((resolve21, reject) => {
|
|
18863
18863
|
server.once("error", reject);
|
|
18864
|
-
server.listen(0, "127.0.0.1", () =>
|
|
18864
|
+
server.listen(0, "127.0.0.1", () => resolve21());
|
|
18865
18865
|
});
|
|
18866
18866
|
server.unref();
|
|
18867
18867
|
const port = server.address().port;
|
|
@@ -19209,26 +19209,26 @@ var AgentDebugger = class {
|
|
|
19209
19209
|
const kind = spec.logMessage ? `logpoint ("${spec.logMessage}")` : spec.condition ? `breakpoint when ${spec.condition}` : "breakpoint";
|
|
19210
19210
|
return `Set a ${kind} at ${spec.path}:${spec.line}.`;
|
|
19211
19211
|
}
|
|
19212
|
-
removeBreakpoint(
|
|
19213
|
-
const key = `${
|
|
19212
|
+
removeBreakpoint(path54, line) {
|
|
19213
|
+
const key = `${path54}:${line}`;
|
|
19214
19214
|
const bp = this.breakpoints.get(key);
|
|
19215
|
-
if (!bp) return `No breakpoint of yours at ${
|
|
19215
|
+
if (!bp) return `No breakpoint of yours at ${path54}:${line}.`;
|
|
19216
19216
|
this.driver.removeBreakpoints([bp.id]);
|
|
19217
19217
|
this.breakpoints.delete(key);
|
|
19218
|
-
return `Removed the breakpoint at ${
|
|
19218
|
+
return `Removed the breakpoint at ${path54}:${line}.`;
|
|
19219
19219
|
}
|
|
19220
19220
|
/** Paused, ended, or still running after `timeoutMs`; with the output since the last look. */
|
|
19221
19221
|
async wait(timeoutMs) {
|
|
19222
19222
|
if (!this.stopped && !this.ended) {
|
|
19223
19223
|
if (!this.running) return "Nothing is running under the debugger. Start it with debugger_start.";
|
|
19224
|
-
await new Promise((
|
|
19224
|
+
await new Promise((resolve21) => {
|
|
19225
19225
|
const timer = setTimeout(() => {
|
|
19226
19226
|
this.waiters = this.waiters.filter((w) => w !== done2);
|
|
19227
|
-
|
|
19227
|
+
resolve21();
|
|
19228
19228
|
}, timeoutMs);
|
|
19229
19229
|
const done2 = () => {
|
|
19230
19230
|
clearTimeout(timer);
|
|
19231
|
-
|
|
19231
|
+
resolve21();
|
|
19232
19232
|
};
|
|
19233
19233
|
this.waiters.push(done2);
|
|
19234
19234
|
});
|
|
@@ -19423,17 +19423,17 @@ async function handleDebuggerTool(name3, input, dbg, paths) {
|
|
|
19423
19423
|
});
|
|
19424
19424
|
}
|
|
19425
19425
|
case "debugger_breakpoint": {
|
|
19426
|
-
const
|
|
19426
|
+
const path54 = typeof input.path === "string" ? paths.resolve(input.path) : void 0;
|
|
19427
19427
|
const line = Number(input.line);
|
|
19428
|
-
if (!
|
|
19428
|
+
if (!path54) return "ERROR: `path` must be a file in the workspace.";
|
|
19429
19429
|
if (!Number.isInteger(line) || line < 1) return "ERROR: `line` is a 1-based line number.";
|
|
19430
|
-
if (input.remove === true) return dbg.removeBreakpoint(
|
|
19430
|
+
if (input.remove === true) return dbg.removeBreakpoint(path54, line);
|
|
19431
19431
|
const message = typeof input.log_message === "string" ? input.log_message.trim() : "";
|
|
19432
19432
|
if (message && !/\{[^}]+\}/.test(message)) {
|
|
19433
19433
|
return 'ERROR: a logpoint logs only what is in braces. Name the values, e.g. "subtotal={subtotal} shipping={order.shipping} ({typeof order.shipping})".';
|
|
19434
19434
|
}
|
|
19435
19435
|
return dbg.setBreakpoint({
|
|
19436
|
-
path:
|
|
19436
|
+
path: path54,
|
|
19437
19437
|
line,
|
|
19438
19438
|
condition: typeof input.condition === "string" && input.condition.trim() ? input.condition : void 0,
|
|
19439
19439
|
logMessage: typeof input.log_message === "string" && input.log_message.trim() ? input.log_message : void 0
|
|
@@ -20426,7 +20426,7 @@ function basePayload(event) {
|
|
|
20426
20426
|
};
|
|
20427
20427
|
}
|
|
20428
20428
|
function runOne(hook, payload) {
|
|
20429
|
-
return new Promise((
|
|
20429
|
+
return new Promise((resolve21) => {
|
|
20430
20430
|
const started = Date.now();
|
|
20431
20431
|
let stdout = "";
|
|
20432
20432
|
let stderr = "";
|
|
@@ -20463,7 +20463,7 @@ function runOne(hook, payload) {
|
|
|
20463
20463
|
stderrHead: stderr.slice(0, 400)
|
|
20464
20464
|
};
|
|
20465
20465
|
record(entry, stdout, stderr);
|
|
20466
|
-
|
|
20466
|
+
resolve21({ answer, entry });
|
|
20467
20467
|
};
|
|
20468
20468
|
child.on("error", (err2) => {
|
|
20469
20469
|
stderr += String(err2);
|
|
@@ -21761,8 +21761,8 @@ var AgentLimiter = class {
|
|
|
21761
21761
|
this.running.set(k, this.runningFor(owner) + 1);
|
|
21762
21762
|
return Promise.resolve();
|
|
21763
21763
|
}
|
|
21764
|
-
return new Promise((
|
|
21765
|
-
const waiter = { resolve:
|
|
21764
|
+
return new Promise((resolve21, reject) => {
|
|
21765
|
+
const waiter = { resolve: resolve21, reject };
|
|
21766
21766
|
const queue = this.queues.get(k) ?? [];
|
|
21767
21767
|
queue.push(waiter);
|
|
21768
21768
|
this.queues.set(k, queue);
|
|
@@ -22298,14 +22298,14 @@ var WorktreeManager = class {
|
|
|
22298
22298
|
root2
|
|
22299
22299
|
);
|
|
22300
22300
|
if (untracked.code === 0) {
|
|
22301
|
-
for (const
|
|
22302
|
-
if (files.some((f) => f.path ===
|
|
22301
|
+
for (const path54 of untracked.out.split("\n").map((l) => l.trim()).filter(Boolean)) {
|
|
22302
|
+
if (files.some((f) => f.path === path54)) continue;
|
|
22303
22303
|
const counted = await this.git(
|
|
22304
|
-
["diff", "--numstat", "--no-index", "/dev/null",
|
|
22304
|
+
["diff", "--numstat", "--no-index", "/dev/null", path54],
|
|
22305
22305
|
root2
|
|
22306
22306
|
);
|
|
22307
22307
|
const parsed = parseNumstat(counted.out);
|
|
22308
|
-
files.push({ path:
|
|
22308
|
+
files.push({ path: path54, added: parsed[0]?.added ?? 0, removed: 0 });
|
|
22309
22309
|
}
|
|
22310
22310
|
}
|
|
22311
22311
|
return files;
|
|
@@ -22341,10 +22341,10 @@ function parseNumstat(out2) {
|
|
|
22341
22341
|
const parts2 = line.split(" ");
|
|
22342
22342
|
if (parts2.length < 3) continue;
|
|
22343
22343
|
const [addedRaw, removedRaw] = parts2;
|
|
22344
|
-
const
|
|
22345
|
-
if (!
|
|
22344
|
+
const path54 = parts2[parts2.length - 1].trim();
|
|
22345
|
+
if (!path54) continue;
|
|
22346
22346
|
files.push({
|
|
22347
|
-
path:
|
|
22347
|
+
path: path54,
|
|
22348
22348
|
added: addedRaw === "-" ? 0 : Number.parseInt(addedRaw, 10) || 0,
|
|
22349
22349
|
removed: removedRaw === "-" ? 0 : Number.parseInt(removedRaw, 10) || 0
|
|
22350
22350
|
});
|
|
@@ -22353,10 +22353,10 @@ function parseNumstat(out2) {
|
|
|
22353
22353
|
}
|
|
22354
22354
|
|
|
22355
22355
|
// ../editor/src/agent/tasks/worktree.ts
|
|
22356
|
-
var execGit = (args2, cwd) => new Promise((
|
|
22356
|
+
var execGit = (args2, cwd) => new Promise((resolve21) => {
|
|
22357
22357
|
(0, import_node_child_process.execFile)("git", args2, { cwd, maxBuffer: 8 * 1024 * 1024 }, (err2, stdout, stderr) => {
|
|
22358
22358
|
const code = err2 ? err2.code ?? 1 : 0;
|
|
22359
|
-
|
|
22359
|
+
resolve21({ code: typeof code === "number" ? code : 1, out: (stdout ?? "") + (stderr ?? "") });
|
|
22360
22360
|
});
|
|
22361
22361
|
});
|
|
22362
22362
|
function slug(s) {
|
|
@@ -22793,7 +22793,7 @@ var WebSocketClient = class extends import_events.EventEmitter {
|
|
|
22793
22793
|
const secure = parsed.protocol === "wss:";
|
|
22794
22794
|
if (opts.maxMessageBytes !== void 0) this.maxMessageBytes = opts.maxMessageBytes;
|
|
22795
22795
|
const offered = (opts.protocols ?? []).filter((p) => typeof p === "string" && /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(p));
|
|
22796
|
-
return new Promise((
|
|
22796
|
+
return new Promise((resolve21, reject) => {
|
|
22797
22797
|
const key = crypto3.randomBytes(16).toString("base64");
|
|
22798
22798
|
const expected = crypto3.createHash("sha1").update(key + GUID).digest("base64");
|
|
22799
22799
|
const host2 = parsed.hostname.replace(/^\[|\]$/g, "");
|
|
@@ -22852,7 +22852,7 @@ Sec-WebSocket-Key: ${key}\r
|
|
|
22852
22852
|
});
|
|
22853
22853
|
this.open = true;
|
|
22854
22854
|
if (this.buffer.length) this.onData(Buffer.alloc(0));
|
|
22855
|
-
|
|
22855
|
+
resolve21();
|
|
22856
22856
|
};
|
|
22857
22857
|
socket.on("data", onHandshake);
|
|
22858
22858
|
});
|
|
@@ -23316,8 +23316,8 @@ function parseGitHubRemote(url2) {
|
|
|
23316
23316
|
}
|
|
23317
23317
|
function githubClient(token, fetchImpl = fetch, base = "https://api.github.com") {
|
|
23318
23318
|
return {
|
|
23319
|
-
async request(method,
|
|
23320
|
-
const res = await fetchImpl(`${base}${
|
|
23319
|
+
async request(method, path54, body2) {
|
|
23320
|
+
const res = await fetchImpl(`${base}${path54}`, {
|
|
23321
23321
|
method,
|
|
23322
23322
|
headers: {
|
|
23323
23323
|
accept: "application/vnd.github+json",
|
|
@@ -23362,7 +23362,7 @@ async function workflowPresent(gh, r, defaultBranch) {
|
|
|
23362
23362
|
return {
|
|
23363
23363
|
ok: false,
|
|
23364
23364
|
missing: true,
|
|
23365
|
-
message: `${r.owner}/${r.repo} is not set up for remote agents: ${WORKFLOW_PATH} is not on its default branch (${defaultBranch}). Run "AstraCode: Enable remote agents for this repository"
|
|
23365
|
+
message: `${r.owner}/${r.repo} is not set up for remote agents: ${WORKFLOW_PATH} is not on its default branch (${defaultBranch}). Run "AstraCode: Enable remote agents for this repository" and commit the workflow it writes to that branch.`
|
|
23366
23366
|
};
|
|
23367
23367
|
}
|
|
23368
23368
|
return { ok: false, missing: false, message: why(res) };
|
|
@@ -23508,10 +23508,19 @@ function gatewayRuns(gatewayUrl2, token, fetchImpl = fetch) {
|
|
|
23508
23508
|
const base = gatewayUrl2.replace(/\/+$/, "");
|
|
23509
23509
|
const headers = { authorization: `Bearer ${token}`, "content-type": "application/json" };
|
|
23510
23510
|
return {
|
|
23511
|
-
/**
|
|
23512
|
-
|
|
23511
|
+
/**
|
|
23512
|
+
* Claim the run before dispatching it, so only this person can read it.
|
|
23513
|
+
* With the repository, so the run can sign in with GitHub's identity token
|
|
23514
|
+
* for exactly that repository instead of needing an ASTRACODE_TOKEN secret.
|
|
23515
|
+
*/
|
|
23516
|
+
async claim(runId, repository) {
|
|
23513
23517
|
try {
|
|
23514
|
-
const res = await fetchImpl(`${base}/v1/runs/${runId}`, {
|
|
23518
|
+
const res = await fetchImpl(`${base}/v1/runs/${runId}`, {
|
|
23519
|
+
method: "PUT",
|
|
23520
|
+
headers,
|
|
23521
|
+
signal: AbortSignal.timeout(1e4),
|
|
23522
|
+
...repository ? { body: JSON.stringify({ repository }) } : {}
|
|
23523
|
+
});
|
|
23515
23524
|
return { ok: res.ok, status: res.status };
|
|
23516
23525
|
} catch {
|
|
23517
23526
|
return { ok: false, status: 0 };
|
|
@@ -23615,7 +23624,7 @@ async function spawnRemoteAgent(scope, def, input, toolCallId) {
|
|
|
23615
23624
|
});
|
|
23616
23625
|
if (!confirmed) return "DENIED: the person declined to start this agent in GitHub Actions. Do the work here, or ask them.";
|
|
23617
23626
|
const gateway = gatewayRuns(gatewayUrl2, ctx.astracodeToken, h.fetch ?? fetch);
|
|
23618
|
-
const claimed = await gateway.claim(runId);
|
|
23627
|
+
const claimed = await gateway.claim(runId, repoName);
|
|
23619
23628
|
if (!claimed.ok) scope.log(`remote ${runId}: the gateway did not take the claim (${claimed.status}); following GitHub only`);
|
|
23620
23629
|
const dispatched = await dispatchWorkflow(ctx.gh, ctx.repo, ctx.defaultBranch, inputs.inputs);
|
|
23621
23630
|
if (!dispatched.ok) return `ERROR: ${dispatched.message}`;
|
|
@@ -23671,11 +23680,11 @@ async function cancelRun(rt, scope) {
|
|
|
23671
23680
|
const res = await cancelWorkflowRun(rt.ctx.gh, rt.ctx.repo, id).catch((err2) => ({ ok: false, message: String(err2) }));
|
|
23672
23681
|
scope.log(`remote ${rt.id}: cancel ${res.ok ? "requested" : `failed: ${res.message}`}`);
|
|
23673
23682
|
}
|
|
23674
|
-
var defaultSleep = (ms, signal) => new Promise((
|
|
23675
|
-
const t2 = setTimeout(
|
|
23683
|
+
var defaultSleep = (ms, signal) => new Promise((resolve21) => {
|
|
23684
|
+
const t2 = setTimeout(resolve21, ms);
|
|
23676
23685
|
signal.addEventListener("abort", () => {
|
|
23677
23686
|
clearTimeout(t2);
|
|
23678
|
-
|
|
23687
|
+
resolve21();
|
|
23679
23688
|
}, { once: true });
|
|
23680
23689
|
});
|
|
23681
23690
|
async function follow(rt, scope, h, gateway) {
|
|
@@ -23805,6 +23814,9 @@ function logLine(line) {
|
|
|
23805
23814
|
}
|
|
23806
23815
|
}
|
|
23807
23816
|
var mcpProvider = { start: async () => void 0 };
|
|
23817
|
+
function setAgentMcpProvider(p) {
|
|
23818
|
+
mcpProvider = p;
|
|
23819
|
+
}
|
|
23808
23820
|
var runtimes = /* @__PURE__ */ new Map();
|
|
23809
23821
|
var limiter = new AgentLimiter(() => maxConcurrentAgents());
|
|
23810
23822
|
var REPORT_CAP = 2e4;
|
|
@@ -23958,8 +23970,8 @@ ${plan.note}` : "";
|
|
|
23958
23970
|
const queued = limiter.queuedFor(scope.owner) > 0 && registry4.get(id)?.state === "queued" ? ` It is queued behind ${maxConcurrentAgents()} running agent(s) and starts when one finishes.` : "";
|
|
23959
23971
|
return `Agent ${id} ("${description}") started in the background.${queued} You will be notified when it completes; do not poll or guess its result.${notes}`;
|
|
23960
23972
|
}
|
|
23961
|
-
const moved = new Promise((
|
|
23962
|
-
rt.detach = () =>
|
|
23973
|
+
const moved = new Promise((resolve21) => {
|
|
23974
|
+
rt.detach = () => resolve21("moved");
|
|
23963
23975
|
});
|
|
23964
23976
|
const lent = scope.callerId !== void 0;
|
|
23965
23977
|
if (lent) limiter.lend(scope.owner);
|
|
@@ -24050,7 +24062,8 @@ async function execute(rt, prompt, history, isolate) {
|
|
|
24050
24062
|
escalated: rt.plan.escalated,
|
|
24051
24063
|
memory: memoryDir ? { dir: memoryDir, writeOnly: memoryWrites } : void 0,
|
|
24052
24064
|
extra: mcp2,
|
|
24053
|
-
disallowed: def.disallowedTools
|
|
24065
|
+
disallowed: def.disallowedTools,
|
|
24066
|
+
...def.spawnable ? { spawnable: def.spawnable } : {}
|
|
24054
24067
|
};
|
|
24055
24068
|
const approval = subagent.approval;
|
|
24056
24069
|
const onEvent2 = (ev) => {
|
|
@@ -24826,6 +24839,10 @@ var SharedTaskList = class {
|
|
|
24826
24839
|
var lists = /* @__PURE__ */ new Map();
|
|
24827
24840
|
var persistence;
|
|
24828
24841
|
var watchers = /* @__PURE__ */ new Set();
|
|
24842
|
+
function setTaskListPersistence(p) {
|
|
24843
|
+
persistence = p;
|
|
24844
|
+
lists.clear();
|
|
24845
|
+
}
|
|
24829
24846
|
var NO_CHAT = "";
|
|
24830
24847
|
function taskListFor(owner) {
|
|
24831
24848
|
const key = owner ?? NO_CHAT;
|
|
@@ -25956,6 +25973,14 @@ function negotiatedVersion(result) {
|
|
|
25956
25973
|
return typeof v === "string" && v ? v : PROTOCOL_VERSION;
|
|
25957
25974
|
}
|
|
25958
25975
|
var McpError = class extends Error {
|
|
25976
|
+
code;
|
|
25977
|
+
data;
|
|
25978
|
+
status;
|
|
25979
|
+
timedOut;
|
|
25980
|
+
constructor(message, detail = {}) {
|
|
25981
|
+
super(message);
|
|
25982
|
+
Object.assign(this, detail);
|
|
25983
|
+
}
|
|
25959
25984
|
};
|
|
25960
25985
|
function contentImages(result) {
|
|
25961
25986
|
const content = result?.content;
|
|
@@ -25963,6 +25988,145 @@ function contentImages(result) {
|
|
|
25963
25988
|
return content.filter((p) => p?.type === "image" && typeof p.data === "string").map((p) => ({ mime: String(p.mimeType ?? "image/png"), data: String(p.data) }));
|
|
25964
25989
|
}
|
|
25965
25990
|
var PROTOCOL_VERSION = "2025-06-18";
|
|
25991
|
+
var MODERN_PROTOCOL_VERSION = "2026-07-28";
|
|
25992
|
+
var MODERN_VERSIONS = [MODERN_PROTOCOL_VERSION];
|
|
25993
|
+
var LEGACY_VERSIONS = ["2025-11-25", "2025-06-18", "2025-03-26"];
|
|
25994
|
+
var CLIENT_INFO = { name: "AstraCode", version: "1.0.0" };
|
|
25995
|
+
var PROBE_TIMEOUT_MS = 5e3;
|
|
25996
|
+
var MODERN_ERRORS = {
|
|
25997
|
+
headerMismatch: -32020,
|
|
25998
|
+
missingRequiredClientCapability: -32021,
|
|
25999
|
+
unsupportedProtocolVersion: -32022
|
|
26000
|
+
};
|
|
26001
|
+
function isModernError(code) {
|
|
26002
|
+
return code === MODERN_ERRORS.headerMismatch || code === MODERN_ERRORS.missingRequiredClientCapability || code === MODERN_ERRORS.unsupportedProtocolVersion;
|
|
26003
|
+
}
|
|
26004
|
+
var META = "io.modelcontextprotocol/";
|
|
26005
|
+
function withMeta(params, version3) {
|
|
26006
|
+
const p = params && typeof params === "object" ? params : {};
|
|
26007
|
+
const meta3 = p._meta && typeof p._meta === "object" ? p._meta : {};
|
|
26008
|
+
return {
|
|
26009
|
+
...p,
|
|
26010
|
+
_meta: {
|
|
26011
|
+
...meta3,
|
|
26012
|
+
[`${META}protocolVersion`]: version3,
|
|
26013
|
+
[`${META}clientInfo`]: CLIENT_INFO,
|
|
26014
|
+
// Declared honestly, as in `initialize`: no sampling, roots or
|
|
26015
|
+
// elicitation, so a server should not send an input request for them.
|
|
26016
|
+
[`${META}clientCapabilities`]: {}
|
|
26017
|
+
}
|
|
26018
|
+
};
|
|
26019
|
+
}
|
|
26020
|
+
function serverInfoName(result) {
|
|
26021
|
+
const meta3 = result?._meta;
|
|
26022
|
+
const info2 = meta3?.[`${META}serverInfo`];
|
|
26023
|
+
return typeof info2?.name === "string" && info2.name ? info2.name : void 0;
|
|
26024
|
+
}
|
|
26025
|
+
function choose(supported) {
|
|
26026
|
+
if (!Array.isArray(supported)) return null;
|
|
26027
|
+
const listed = supported.filter((v) => typeof v === "string");
|
|
26028
|
+
const modern = MODERN_VERSIONS.find((v) => listed.includes(v));
|
|
26029
|
+
if (modern) return modern;
|
|
26030
|
+
return listed.some((v) => LEGACY_VERSIONS.includes(v)) ? "legacy" : null;
|
|
26031
|
+
}
|
|
26032
|
+
function eraFromDiscover(outcome) {
|
|
26033
|
+
if ("error" in outcome) {
|
|
26034
|
+
const { code, data } = outcome.error;
|
|
26035
|
+
if (!isModernError(code)) return { era: "legacy" };
|
|
26036
|
+
if (code === MODERN_ERRORS.unsupportedProtocolVersion) {
|
|
26037
|
+
const supported = data?.supported;
|
|
26038
|
+
const picked2 = choose(supported);
|
|
26039
|
+
if (picked2 === "legacy") return { era: "legacy" };
|
|
26040
|
+
if (picked2) return { era: "modern", version: picked2, listChanged: false };
|
|
26041
|
+
throw new McpError(`the server speaks MCP ${JSON.stringify(supported ?? [])}, and AstraCode speaks ${[...MODERN_VERSIONS, ...LEGACY_VERSIONS].join(", ")}`, { code });
|
|
26042
|
+
}
|
|
26043
|
+
throw new McpError(`the server refused AstraCode: ${outcome.error.message}`, { code });
|
|
26044
|
+
}
|
|
26045
|
+
const r = outcome.result;
|
|
26046
|
+
if (!r || !Array.isArray(r.supportedVersions)) return { era: "legacy" };
|
|
26047
|
+
const picked = choose(r.supportedVersions);
|
|
26048
|
+
if (picked === "legacy") return { era: "legacy" };
|
|
26049
|
+
if (!picked) {
|
|
26050
|
+
throw new McpError(`the server speaks MCP ${JSON.stringify(r.supportedVersions)}, and AstraCode speaks ${[...MODERN_VERSIONS, ...LEGACY_VERSIONS].join(", ")}`);
|
|
26051
|
+
}
|
|
26052
|
+
return {
|
|
26053
|
+
era: "modern",
|
|
26054
|
+
version: picked,
|
|
26055
|
+
serverName: serverInfoName(r),
|
|
26056
|
+
listChanged: r.capabilities?.tools?.listChanged === true
|
|
26057
|
+
};
|
|
26058
|
+
}
|
|
26059
|
+
function inputRequired(result) {
|
|
26060
|
+
const r = result;
|
|
26061
|
+
if (r?.resultType !== "input_required") return null;
|
|
26062
|
+
const asked = r.inputRequests && typeof r.inputRequests === "object" ? Object.values(r.inputRequests).map((q) => typeof q?.method === "string" ? q.method : "input") : [];
|
|
26063
|
+
return `the server asked for ${asked.length ? asked.join(", ") : "input"}, which AstraCode does not provide`;
|
|
26064
|
+
}
|
|
26065
|
+
var TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
26066
|
+
function headerValue(value) {
|
|
26067
|
+
const plain = /^[\x21-\x7E]([\x20-\x7E\t]*[\x21-\x7E])?$/.test(value) || value === "";
|
|
26068
|
+
const sentinel2 = value.startsWith("=?base64?") && value.endsWith("?=");
|
|
26069
|
+
return plain && !sentinel2 ? value : `=?base64?${Buffer.from(value, "utf8").toString("base64")}?=`;
|
|
26070
|
+
}
|
|
26071
|
+
function headerParams(tool) {
|
|
26072
|
+
const params = [];
|
|
26073
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26074
|
+
let reason = "";
|
|
26075
|
+
const walk5 = (node, path54, reachable) => {
|
|
26076
|
+
if (reason || !node || typeof node !== "object") return;
|
|
26077
|
+
if (Array.isArray(node)) {
|
|
26078
|
+
node.forEach((n) => walk5(n, path54, false));
|
|
26079
|
+
return;
|
|
26080
|
+
}
|
|
26081
|
+
const obj = node;
|
|
26082
|
+
if ("x-mcp-header" in obj) {
|
|
26083
|
+
const name3 = obj["x-mcp-header"];
|
|
26084
|
+
const type = obj.type;
|
|
26085
|
+
if (!reachable || path54.length === 0) {
|
|
26086
|
+
reason = "x-mcp-header on a property not reached through properties alone";
|
|
26087
|
+
return;
|
|
26088
|
+
}
|
|
26089
|
+
if (typeof name3 !== "string" || !TOKEN.test(name3)) {
|
|
26090
|
+
reason = `x-mcp-header ${JSON.stringify(name3)} is not a header name`;
|
|
26091
|
+
return;
|
|
26092
|
+
}
|
|
26093
|
+
if (seen.has(name3.toLowerCase())) {
|
|
26094
|
+
reason = `x-mcp-header ${name3} is used twice`;
|
|
26095
|
+
return;
|
|
26096
|
+
}
|
|
26097
|
+
if (type !== "string" && type !== "integer" && type !== "boolean") {
|
|
26098
|
+
reason = `x-mcp-header ${name3} is on a ${String(type)}, not a string, integer or boolean`;
|
|
26099
|
+
return;
|
|
26100
|
+
}
|
|
26101
|
+
seen.add(name3.toLowerCase());
|
|
26102
|
+
params.push({ path: path54, header: `mcp-param-${name3}` });
|
|
26103
|
+
}
|
|
26104
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
26105
|
+
if (key === "properties" && value && typeof value === "object" && !Array.isArray(value) && reachable) {
|
|
26106
|
+
for (const [prop, schema] of Object.entries(value)) walk5(schema, [...path54, prop], true);
|
|
26107
|
+
} else if (key !== "x-mcp-header") {
|
|
26108
|
+
walk5(value, path54, false);
|
|
26109
|
+
}
|
|
26110
|
+
}
|
|
26111
|
+
};
|
|
26112
|
+
walk5(tool.inputSchema, [], true);
|
|
26113
|
+
return reason ? { ok: false, reason } : { ok: true, params };
|
|
26114
|
+
}
|
|
26115
|
+
function paramHeaders(tool, args2) {
|
|
26116
|
+
if (!tool) return {};
|
|
26117
|
+
const declared2 = headerParams(tool);
|
|
26118
|
+
if (!declared2.ok) return {};
|
|
26119
|
+
const out2 = {};
|
|
26120
|
+
for (const { path: path54, header: header2 } of declared2.params) {
|
|
26121
|
+
let value = args2;
|
|
26122
|
+
for (const key of path54) value = value && typeof value === "object" ? value[key] : void 0;
|
|
26123
|
+
if (value === void 0 || value === null) continue;
|
|
26124
|
+
if (typeof value === "boolean") out2[header2] = String(value);
|
|
26125
|
+
else if (typeof value === "number" && Number.isSafeInteger(value)) out2[header2] = String(value);
|
|
26126
|
+
else if (typeof value === "string") out2[header2] = headerValue(value);
|
|
26127
|
+
}
|
|
26128
|
+
return out2;
|
|
26129
|
+
}
|
|
25966
26130
|
var CALL_TIMEOUT_MS = 3e4;
|
|
25967
26131
|
var HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
25968
26132
|
var FIRST_RUN_HANDSHAKE_TIMEOUT_MS = 12e4;
|
|
@@ -26013,6 +26177,16 @@ var McpClient = class {
|
|
|
26013
26177
|
serverName = "";
|
|
26014
26178
|
/** What the server agreed to in initialize. Stdio sends no header; kept for the log. */
|
|
26015
26179
|
protocolVersion = PROTOCOL_VERSION;
|
|
26180
|
+
/**
|
|
26181
|
+
* Set when the server speaks 2026-07-28 or later: every request then
|
|
26182
|
+
* carries the version in `_meta`, and there was no handshake. See
|
|
26183
|
+
* transport.ts for how it is decided.
|
|
26184
|
+
*/
|
|
26185
|
+
modern = null;
|
|
26186
|
+
/** How long the server/discover probe waits; a test shortens it. */
|
|
26187
|
+
probeTimeoutMs = PROBE_TIMEOUT_MS;
|
|
26188
|
+
/** The id of our subscriptions/listen, whose notifications are the only list_changed a modern server sends. */
|
|
26189
|
+
listenId = null;
|
|
26016
26190
|
onExit;
|
|
26017
26191
|
onToolsChanged;
|
|
26018
26192
|
get running() {
|
|
@@ -26057,28 +26231,89 @@ var McpClient = class {
|
|
|
26057
26231
|
this.failAllPending(new McpError(`server "${this.spec.id}" could not start: ${err2.message}`));
|
|
26058
26232
|
if (this.child === child) this.child = null;
|
|
26059
26233
|
});
|
|
26060
|
-
|
|
26061
|
-
|
|
26062
|
-
|
|
26063
|
-
|
|
26064
|
-
|
|
26065
|
-
|
|
26066
|
-
|
|
26067
|
-
|
|
26068
|
-
|
|
26069
|
-
|
|
26070
|
-
|
|
26071
|
-
);
|
|
26234
|
+
this.modern = null;
|
|
26235
|
+
this.listenId = null;
|
|
26236
|
+
const era = await this.handshake();
|
|
26237
|
+
if (era.era === "modern") {
|
|
26238
|
+
this.modern = era.version;
|
|
26239
|
+
this.protocolVersion = era.version;
|
|
26240
|
+
this.serverName = era.serverName ?? this.spec.id;
|
|
26241
|
+
}
|
|
26242
|
+
this.tools = await listAllTools((params) => this.request("tools/list", params));
|
|
26243
|
+
this.ready = true;
|
|
26244
|
+
if (era.era === "modern" && era.listChanged) this.listen();
|
|
26245
|
+
this.log(`mcp: "${this.spec.id}" ready, ${this.tools.length} tool(s)${this.modern ? `, MCP ${this.modern}` : ""}`);
|
|
26246
|
+
}
|
|
26247
|
+
/**
|
|
26248
|
+
* Which protocol this server speaks, and the handshake if it is the old one.
|
|
26249
|
+
*
|
|
26250
|
+
* `server/discover` first, carrying 2026-07-28, as the stdio binding says a
|
|
26251
|
+
* dual-era client SHOULD; `initialize` when the answer is anything but a
|
|
26252
|
+
* modern one. A probe that only timed out is asked once more if the
|
|
26253
|
+
* `initialize` after it is refused, because a modern server still being
|
|
26254
|
+
* downloaded by npx looks exactly like a silent legacy one.
|
|
26255
|
+
*/
|
|
26256
|
+
async handshake() {
|
|
26257
|
+
const startTimeout = downloadsOnStart(this.spec.command) ? FIRST_RUN_HANDSHAKE_TIMEOUT_MS : HANDSHAKE_TIMEOUT_MS;
|
|
26258
|
+
const probe = async (timeout) => {
|
|
26259
|
+
let result2;
|
|
26260
|
+
try {
|
|
26261
|
+
result2 = await this.request("server/discover", withMeta({}, MODERN_PROTOCOL_VERSION), timeout);
|
|
26262
|
+
} catch (err2) {
|
|
26263
|
+
if (!(err2 instanceof McpError) || this.child === null) throw err2;
|
|
26264
|
+
if (err2.timedOut) return "silent";
|
|
26265
|
+
return eraFromDiscover({ error: err2 });
|
|
26266
|
+
}
|
|
26267
|
+
return eraFromDiscover({ result: result2 });
|
|
26268
|
+
};
|
|
26269
|
+
const first = await probe(this.probeTimeoutMs);
|
|
26270
|
+
if (first !== "silent" && first.era === "modern") return first;
|
|
26271
|
+
let result;
|
|
26272
|
+
try {
|
|
26273
|
+
result = await this.request(
|
|
26274
|
+
"initialize",
|
|
26275
|
+
{
|
|
26276
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
26277
|
+
// Declared honestly. We do not implement sampling, so we do not claim
|
|
26278
|
+
// it; a server that needs it should fail loudly here rather than at the
|
|
26279
|
+
// moment somebody depends on it.
|
|
26280
|
+
capabilities: {},
|
|
26281
|
+
clientInfo: CLIENT_INFO
|
|
26282
|
+
},
|
|
26283
|
+
startTimeout
|
|
26284
|
+
);
|
|
26285
|
+
} catch (err2) {
|
|
26286
|
+
if (first === "silent" && err2 instanceof McpError && !err2.timedOut && this.child !== null) {
|
|
26287
|
+
const again = await probe(startTimeout);
|
|
26288
|
+
if (again !== "silent" && again.era === "modern") return again;
|
|
26289
|
+
}
|
|
26290
|
+
throw err2;
|
|
26291
|
+
}
|
|
26072
26292
|
this.serverName = result?.serverInfo?.name ?? this.spec.id;
|
|
26073
26293
|
this.protocolVersion = negotiatedVersion(result);
|
|
26074
26294
|
this.notify("notifications/initialized");
|
|
26075
|
-
|
|
26076
|
-
|
|
26077
|
-
|
|
26295
|
+
return { era: "legacy" };
|
|
26296
|
+
}
|
|
26297
|
+
/**
|
|
26298
|
+
* Ask a modern server for tool-list changes (subscriptions/listen). It
|
|
26299
|
+
* replaced the unsolicited list_changed of the old protocol; the request
|
|
26300
|
+
* stays open, so it has no timeout and nothing waits on it.
|
|
26301
|
+
*/
|
|
26302
|
+
listen() {
|
|
26303
|
+
const id = this.nextId++;
|
|
26304
|
+
this.listenId = id;
|
|
26305
|
+
this.write(JSON.stringify({
|
|
26306
|
+
jsonrpc: "2.0",
|
|
26307
|
+
id,
|
|
26308
|
+
method: "subscriptions/listen",
|
|
26309
|
+
params: withMeta({ notifications: { toolsListChanged: true } }, this.modern)
|
|
26310
|
+
}));
|
|
26078
26311
|
}
|
|
26079
26312
|
/** Run one tool. The RESULT IS UNTRUSTED; the caller fences it. */
|
|
26080
26313
|
async callTool(name3, args2, signal) {
|
|
26081
26314
|
const result = await this.request("tools/call", { name: name3, arguments: args2 }, CALL_TIMEOUT_MS, signal);
|
|
26315
|
+
const asked = inputRequired(result);
|
|
26316
|
+
if (asked) return { text: `ERROR from ${this.spec.id}: ${asked}`, images: [] };
|
|
26082
26317
|
const text2 = (result?.content ?? []).map((part) => part.type === "text" ? part.text ?? "" : `[${part.type}]`).join("\n").trim();
|
|
26083
26318
|
if (result?.isError) return { text: `ERROR from ${this.spec.id}: ${text2 || "no detail given"}`, images: [] };
|
|
26084
26319
|
return { text: text2 || "(the tool returned nothing)", images: contentImages(result) };
|
|
@@ -26126,7 +26361,7 @@ var McpClient = class {
|
|
|
26126
26361
|
this.write(replyToServer(message));
|
|
26127
26362
|
return;
|
|
26128
26363
|
case "notification":
|
|
26129
|
-
if (message.method === "notifications/tools/list_changed") void this.relist();
|
|
26364
|
+
if (message.method === "notifications/tools/list_changed" && this.fromOurSubscription(message)) void this.relist();
|
|
26130
26365
|
return;
|
|
26131
26366
|
case "reply":
|
|
26132
26367
|
break;
|
|
@@ -26137,8 +26372,24 @@ var McpClient = class {
|
|
|
26137
26372
|
this.pending.delete(message.id);
|
|
26138
26373
|
clearTimeout(waiting.timer);
|
|
26139
26374
|
waiting.done();
|
|
26140
|
-
if (message.error)
|
|
26141
|
-
|
|
26375
|
+
if (message.error) {
|
|
26376
|
+
waiting.reject(new McpError(message.error.message ?? "unknown error", {
|
|
26377
|
+
code: message.error.code,
|
|
26378
|
+
data: message.error.data
|
|
26379
|
+
}));
|
|
26380
|
+
} else {
|
|
26381
|
+
waiting.resolve(message.result);
|
|
26382
|
+
}
|
|
26383
|
+
}
|
|
26384
|
+
/**
|
|
26385
|
+
* A modern server's notifications arrive tagged with the subscription they
|
|
26386
|
+
* belong to, and the binding says to correlate by it; an old server's are
|
|
26387
|
+
* untagged and always ours.
|
|
26388
|
+
*/
|
|
26389
|
+
fromOurSubscription(message) {
|
|
26390
|
+
if (!this.modern) return true;
|
|
26391
|
+
const meta3 = message.params?._meta;
|
|
26392
|
+
return this.listenId !== null && meta3?.["io.modelcontextprotocol/subscriptionId"] === this.listenId;
|
|
26142
26393
|
}
|
|
26143
26394
|
/** The server said its tools changed: read them again, and tell the registry. */
|
|
26144
26395
|
async relist() {
|
|
@@ -26156,23 +26407,26 @@ var McpClient = class {
|
|
|
26156
26407
|
if (!child) return Promise.reject(new McpError(`server "${this.spec.id}" is not running`));
|
|
26157
26408
|
if (signal?.aborted) return Promise.reject(new McpError("the run was stopped"));
|
|
26158
26409
|
const id = this.nextId++;
|
|
26159
|
-
return new Promise((
|
|
26410
|
+
return new Promise((resolve21, reject) => {
|
|
26160
26411
|
const giveUp = (why2, error51) => {
|
|
26161
26412
|
if (!this.pending.has(id)) return;
|
|
26162
26413
|
this.pending.delete(id);
|
|
26163
26414
|
clearTimeout(timer);
|
|
26164
26415
|
signal?.removeEventListener("abort", onAbort);
|
|
26165
|
-
if (method !== "initialize"
|
|
26416
|
+
if (method !== "initialize" && method !== "server/discover") {
|
|
26417
|
+
this.notify("notifications/cancelled", { requestId: id, reason: why2 });
|
|
26418
|
+
}
|
|
26166
26419
|
reject(error51);
|
|
26167
26420
|
};
|
|
26168
26421
|
const onAbort = () => giveUp("the run was stopped", new McpError("the run was stopped"));
|
|
26169
26422
|
const timer = setTimeout(
|
|
26170
|
-
() => giveUp("timed out", new McpError(`server "${this.spec.id}" did not answer ${method} in time
|
|
26423
|
+
() => giveUp("timed out", new McpError(`server "${this.spec.id}" did not answer ${method} in time`, { timedOut: true })),
|
|
26171
26424
|
timeout
|
|
26172
26425
|
);
|
|
26173
26426
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
26174
|
-
this.pending.set(id, { resolve:
|
|
26175
|
-
this.
|
|
26427
|
+
this.pending.set(id, { resolve: resolve21, reject, timer, done: () => signal?.removeEventListener("abort", onAbort) });
|
|
26428
|
+
const sent = this.modern && method !== "server/discover" ? withMeta(params, this.modern) : params;
|
|
26429
|
+
this.write(JSON.stringify({ jsonrpc: "2.0", id, method, params: sent }));
|
|
26176
26430
|
});
|
|
26177
26431
|
}
|
|
26178
26432
|
notify(method, params = {}) {
|
|
@@ -26246,6 +26500,12 @@ init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
|
26246
26500
|
var import_crypto = require("crypto");
|
|
26247
26501
|
var HTTP_TIMEOUT_MS = 15e3;
|
|
26248
26502
|
var REFRESH_MARGIN_MS = 6e4;
|
|
26503
|
+
function issuerMismatch(iss, check2) {
|
|
26504
|
+
if (iss === null) {
|
|
26505
|
+
return check2.required ? `the sign-in answer carried no iss, which ${check2.expected} says it always sends` : null;
|
|
26506
|
+
}
|
|
26507
|
+
return iss === check2.expected ? null : `the sign-in answer came from ${iss}, not ${check2.expected}, the server AstraCode asked`;
|
|
26508
|
+
}
|
|
26249
26509
|
var OAuthError = class extends Error {
|
|
26250
26510
|
};
|
|
26251
26511
|
async function getJson(url2, init2) {
|
|
@@ -26336,8 +26596,8 @@ async function discover(serverUrl, wwwAuthenticate) {
|
|
|
26336
26596
|
if (typeof auth.issuer !== "string" || !sameIssuer(auth.issuer, issuer)) {
|
|
26337
26597
|
throw new OAuthError(`the authorization server at ${issuer} identifies itself as ${String(auth.issuer)}`);
|
|
26338
26598
|
}
|
|
26339
|
-
if (auth.code_challenge_methods_supported
|
|
26340
|
-
throw new OAuthError("the authorization server does not
|
|
26599
|
+
if (!Array.isArray(auth.code_challenge_methods_supported) || !auth.code_challenge_methods_supported.includes("S256")) {
|
|
26600
|
+
throw new OAuthError("the authorization server does not say it supports PKCE S256");
|
|
26341
26601
|
}
|
|
26342
26602
|
return { resource: resourceMeta.resource || serverUrl, auth, scope: scopeFor(wwwAuthenticate, resourceMeta) };
|
|
26343
26603
|
}
|
|
@@ -26368,6 +26628,9 @@ async function register(endpoint, redirectUri, auth, scope) {
|
|
|
26368
26628
|
grant_types: ["authorization_code", "refresh_token"],
|
|
26369
26629
|
response_types: ["code"],
|
|
26370
26630
|
token_endpoint_auth_method: method,
|
|
26631
|
+
// MUST be given (2026-07-28, SEP-837): omitted, an OpenID Connect
|
|
26632
|
+
// server assumes "web" and refuses a loopback redirect URI.
|
|
26633
|
+
application_type: "native",
|
|
26371
26634
|
...scope ? { scope } : {}
|
|
26372
26635
|
}),
|
|
26373
26636
|
signal: controller.signal
|
|
@@ -26422,6 +26685,26 @@ function authorize(serverUrl, wwwAuthenticate, deps, options = {}) {
|
|
|
26422
26685
|
return started;
|
|
26423
26686
|
}
|
|
26424
26687
|
var inFlight = /* @__PURE__ */ new Map();
|
|
26688
|
+
var CLIENT_METADATA_URL = "https://astracode.io/oauth/mcp-client.json";
|
|
26689
|
+
var cimdFailed = /* @__PURE__ */ new Set();
|
|
26690
|
+
async function clientMetadata(url2) {
|
|
26691
|
+
try {
|
|
26692
|
+
const doc = await getJson(url2, { headers: { accept: "application/json" } });
|
|
26693
|
+
if (doc.client_id !== url2 || !Array.isArray(doc.redirect_uris)) return null;
|
|
26694
|
+
if (doc.token_endpoint_auth_method !== void 0 && doc.token_endpoint_auth_method !== "none") return null;
|
|
26695
|
+
return { clientId: url2, redirectUris: doc.redirect_uris.filter((u) => typeof u === "string") };
|
|
26696
|
+
} catch {
|
|
26697
|
+
return null;
|
|
26698
|
+
}
|
|
26699
|
+
}
|
|
26700
|
+
function loopbackPorts(uris) {
|
|
26701
|
+
const ports = [];
|
|
26702
|
+
for (const u of uris) {
|
|
26703
|
+
const m = /^http:\/\/127\.0\.0\.1:(\d+)\/callback$/.exec(u);
|
|
26704
|
+
if (m) ports.push(Number(m[1]));
|
|
26705
|
+
}
|
|
26706
|
+
return ports;
|
|
26707
|
+
}
|
|
26425
26708
|
async function authorizeOnce(serverUrl, wwwAuthenticate, deps, rejected) {
|
|
26426
26709
|
const { resource, auth, scope } = await discover(serverUrl, wwwAuthenticate);
|
|
26427
26710
|
const key = tokenKey(serverUrl, resource);
|
|
@@ -26429,7 +26712,8 @@ async function authorizeOnce(serverUrl, wwwAuthenticate, deps, rejected) {
|
|
|
26429
26712
|
const refused = !!stored && !!rejected && stored.accessToken === rejected;
|
|
26430
26713
|
if (stored && !refused && !expired(stored)) return stored;
|
|
26431
26714
|
if (refused) deps.log(`mcp: ${serverUrl} refused its stored token; renewing it`);
|
|
26432
|
-
|
|
26715
|
+
const sameServer = !stored?.issuer || stored.issuer === auth.issuer;
|
|
26716
|
+
if (stored?.refreshToken && sameServer) {
|
|
26433
26717
|
try {
|
|
26434
26718
|
const refreshed = await exchange(auth.token_endpoint, {
|
|
26435
26719
|
grant_type: "refresh_token",
|
|
@@ -26442,7 +26726,8 @@ async function authorizeOnce(serverUrl, wwwAuthenticate, deps, rejected) {
|
|
|
26442
26726
|
...refreshed,
|
|
26443
26727
|
refreshToken: refreshed.refreshToken ?? stored.refreshToken,
|
|
26444
26728
|
clientId: stored.clientId,
|
|
26445
|
-
clientSecret: stored.clientSecret
|
|
26729
|
+
clientSecret: stored.clientSecret,
|
|
26730
|
+
issuer: stored.issuer ?? auth.issuer
|
|
26446
26731
|
};
|
|
26447
26732
|
await deps.store.write(key, kept);
|
|
26448
26733
|
return kept;
|
|
@@ -26450,9 +26735,13 @@ async function authorizeOnce(serverUrl, wwwAuthenticate, deps, rejected) {
|
|
|
26450
26735
|
deps.log(`mcp: refresh failed for ${resource}, signing in again (${err2})`);
|
|
26451
26736
|
}
|
|
26452
26737
|
}
|
|
26453
|
-
const client = stored?.clientId ? { clientId: stored.clientId, clientSecret: stored.clientSecret } : void 0;
|
|
26738
|
+
const client = stored?.clientId && stored.issuer === auth.issuer ? { clientId: stored.clientId, clientSecret: stored.clientSecret } : void 0;
|
|
26454
26739
|
if (stored) await deps.store.clear(key);
|
|
26455
|
-
const
|
|
26740
|
+
const metadataUrl = deps.clientMetadataUrl === void 0 ? CLIENT_METADATA_URL : deps.clientMetadataUrl;
|
|
26741
|
+
const document2 = !deps.clientId && metadataUrl && auth.client_id_metadata_document_supported === true && !cimdFailed.has(auth.issuer) ? await clientMetadata(metadataUrl) : null;
|
|
26742
|
+
const redirect = await deps.redirect(document2 ? { ports: loopbackPorts(document2.redirectUris) } : void 0);
|
|
26743
|
+
const cimd = document2 && document2.redirectUris.includes(redirect.uri) ? document2.clientId : void 0;
|
|
26744
|
+
if (document2 && !cimd) deps.log(`mcp: no listed port was free for ${auth.issuer}; registering instead`);
|
|
26456
26745
|
let host2 = resource;
|
|
26457
26746
|
try {
|
|
26458
26747
|
host2 = new URL(auth.authorization_endpoint).host;
|
|
@@ -26460,10 +26749,14 @@ async function authorizeOnce(serverUrl, wwwAuthenticate, deps, rejected) {
|
|
|
26460
26749
|
}
|
|
26461
26750
|
const finish = deps.signingIn?.(host2, () => redirect.close());
|
|
26462
26751
|
try {
|
|
26463
|
-
const tokens = await browserFlow(auth, resource, key, scope, redirect, deps, client);
|
|
26752
|
+
const tokens = await browserFlow(auth, resource, key, scope, redirect, deps, cimd ? { clientId: cimd } : client);
|
|
26464
26753
|
finish?.({ ok: true });
|
|
26465
26754
|
return tokens;
|
|
26466
26755
|
} catch (err2) {
|
|
26756
|
+
if (cimd) {
|
|
26757
|
+
cimdFailed.add(auth.issuer);
|
|
26758
|
+
deps.log(`mcp: signing in to ${auth.issuer} as ${cimd} failed; the next attempt registers instead`);
|
|
26759
|
+
}
|
|
26467
26760
|
finish?.({ ok: false, reason: err2 instanceof Error ? err2.message : String(err2) });
|
|
26468
26761
|
throw err2;
|
|
26469
26762
|
} finally {
|
|
@@ -26499,9 +26792,16 @@ async function browserFlow(auth, resource, key, scope, redirect, deps, registere
|
|
|
26499
26792
|
})) {
|
|
26500
26793
|
authUrl.searchParams.set(key2, value);
|
|
26501
26794
|
}
|
|
26502
|
-
const
|
|
26795
|
+
const check2 = {
|
|
26796
|
+
expected: auth.issuer,
|
|
26797
|
+
required: auth.authorization_response_iss_parameter_supported === true
|
|
26798
|
+
};
|
|
26799
|
+
const waiting = redirect.waitResponse ? redirect.waitResponse(state, check2) : redirect.wait(state).then((c) => ({ code: c, iss: null }));
|
|
26800
|
+
waiting.catch(() => void 0);
|
|
26503
26801
|
await deps.browser(authUrl.toString());
|
|
26504
|
-
const code = await waiting;
|
|
26802
|
+
const { code, iss } = await waiting;
|
|
26803
|
+
const mismatch = issuerMismatch(iss, check2);
|
|
26804
|
+
if (mismatch) throw new OAuthError(mismatch);
|
|
26505
26805
|
const issued = await exchange(auth.token_endpoint, {
|
|
26506
26806
|
grant_type: "authorization_code",
|
|
26507
26807
|
code,
|
|
@@ -26511,7 +26811,7 @@ async function browserFlow(auth, resource, key, scope, redirect, deps, registere
|
|
|
26511
26811
|
code_verifier: verifier,
|
|
26512
26812
|
resource
|
|
26513
26813
|
});
|
|
26514
|
-
const tokens = { ...issued, clientId, clientSecret };
|
|
26814
|
+
const tokens = { ...issued, clientId, clientSecret, issuer: auth.issuer };
|
|
26515
26815
|
await deps.store.write(key, tokens);
|
|
26516
26816
|
return tokens;
|
|
26517
26817
|
}
|
|
@@ -26538,6 +26838,14 @@ var McpHttpClient = class {
|
|
|
26538
26838
|
* that we were speaking the newer one.
|
|
26539
26839
|
*/
|
|
26540
26840
|
protocolVersion = PROTOCOL_VERSION;
|
|
26841
|
+
/**
|
|
26842
|
+
* The 2026-07-28-or-later version this server is spoken to in, or null for
|
|
26843
|
+
* a 2025 server reached through initialize. Set to the newest while the
|
|
26844
|
+
* server/discover probe is in flight, so the probe is a modern request.
|
|
26845
|
+
* See transport.ts for how it is decided.
|
|
26846
|
+
*/
|
|
26847
|
+
modern = null;
|
|
26848
|
+
probing = false;
|
|
26541
26849
|
tools = [];
|
|
26542
26850
|
serverName = "";
|
|
26543
26851
|
onExit;
|
|
@@ -26548,7 +26856,7 @@ var McpHttpClient = class {
|
|
|
26548
26856
|
get diagnostics() {
|
|
26549
26857
|
return this.lastError;
|
|
26550
26858
|
}
|
|
26551
|
-
headers() {
|
|
26859
|
+
headers(body2) {
|
|
26552
26860
|
return {
|
|
26553
26861
|
"content-type": "application/json",
|
|
26554
26862
|
// BOTH, always. The server chooses which to send and a client that
|
|
@@ -26556,11 +26864,47 @@ var McpHttpClient = class {
|
|
|
26556
26864
|
// other.
|
|
26557
26865
|
accept: "application/json, text/event-stream",
|
|
26558
26866
|
...this.spec.headers ?? {},
|
|
26559
|
-
...this.
|
|
26560
|
-
|
|
26561
|
-
|
|
26867
|
+
...this.modern ? this.modernHeaders(this.modern, body2) : {
|
|
26868
|
+
...this.sessionId ? { "mcp-session-id": this.sessionId } : {},
|
|
26869
|
+
...this.started ? { "mcp-protocol-version": this.protocolVersion } : {}
|
|
26870
|
+
},
|
|
26871
|
+
...this.bearer() ? { authorization: `Bearer ${this.bearer()}` } : {}
|
|
26562
26872
|
};
|
|
26563
26873
|
}
|
|
26874
|
+
/**
|
|
26875
|
+
* What a 2026-07-28 POST carries besides the body: the version (which must
|
|
26876
|
+
* match the body's _meta), the method, the tool for a tools/call, and any
|
|
26877
|
+
* argument the tool's schema marks with x-mcp-header. A server MUST reject a
|
|
26878
|
+
* request missing them with 400 HeaderMismatch. No session: there is none.
|
|
26879
|
+
*/
|
|
26880
|
+
modernHeaders(version3, body2) {
|
|
26881
|
+
const out2 = { "mcp-protocol-version": version3 };
|
|
26882
|
+
let message = {};
|
|
26883
|
+
try {
|
|
26884
|
+
message = body2 ? JSON.parse(body2) : {};
|
|
26885
|
+
} catch {
|
|
26886
|
+
}
|
|
26887
|
+
if (typeof message.method !== "string") return out2;
|
|
26888
|
+
out2["mcp-method"] = message.method;
|
|
26889
|
+
const named = message.method === "resources/read" ? message.params?.uri : message.method === "tools/call" || message.method === "prompts/get" ? message.params?.name : void 0;
|
|
26890
|
+
if (typeof named === "string") out2["mcp-name"] = headerValue(named);
|
|
26891
|
+
if (message.method === "tools/call" && typeof named === "string") {
|
|
26892
|
+
const args2 = message.params?.arguments;
|
|
26893
|
+
Object.assign(out2, paramHeaders(
|
|
26894
|
+
this.tools.find((t2) => t2.name === named),
|
|
26895
|
+
args2 && typeof args2 === "object" ? args2 : {}
|
|
26896
|
+
));
|
|
26897
|
+
}
|
|
26898
|
+
return out2;
|
|
26899
|
+
}
|
|
26900
|
+
/** A request in whichever protocol this server speaks. */
|
|
26901
|
+
request(id, method, params) {
|
|
26902
|
+
return rpc(id, method, this.modern ? withMeta(params ?? {}, this.modern) : params);
|
|
26903
|
+
}
|
|
26904
|
+
/** The OAuth token this client obtained, or the keychain one a catalogue entry gave it. */
|
|
26905
|
+
bearer() {
|
|
26906
|
+
return this.token || this.spec.bearer?.token || "";
|
|
26907
|
+
}
|
|
26564
26908
|
/**
|
|
26565
26909
|
* POST one message and return the reply, whichever way it arrives.
|
|
26566
26910
|
*
|
|
@@ -26586,7 +26930,7 @@ var McpHttpClient = class {
|
|
|
26586
26930
|
try {
|
|
26587
26931
|
res = await fetch(this.spec.url, {
|
|
26588
26932
|
method: "POST",
|
|
26589
|
-
headers: this.headers(),
|
|
26933
|
+
headers: this.headers(body2),
|
|
26590
26934
|
body: body2,
|
|
26591
26935
|
signal: controller.signal
|
|
26592
26936
|
});
|
|
@@ -26603,6 +26947,12 @@ var McpHttpClient = class {
|
|
|
26603
26947
|
clearTimeout(timer);
|
|
26604
26948
|
signal?.removeEventListener("abort", onAbort);
|
|
26605
26949
|
};
|
|
26950
|
+
if (res.status === 401 && this.spec.bearer) {
|
|
26951
|
+
settle3();
|
|
26952
|
+
const { variable, token } = this.spec.bearer;
|
|
26953
|
+
this.lastError = token ? `the server refused the ${variable} stored in your keychain (401); it may have expired or been revoked. Remove "${this.spec.id}" from your connectors and add it again with a new token` : `no ${variable} is stored for "${this.spec.id}". Remove it from your connectors and add it again to paste one`;
|
|
26954
|
+
throw new McpError(this.lastError);
|
|
26955
|
+
}
|
|
26606
26956
|
if (res.status === 401 && signIns < 2) {
|
|
26607
26957
|
settle3();
|
|
26608
26958
|
if (!this.auth) throw new McpError("server requires authorization");
|
|
@@ -26626,19 +26976,22 @@ var McpHttpClient = class {
|
|
|
26626
26976
|
if (!res.ok) {
|
|
26627
26977
|
const text3 = (await res.text().catch(() => "")).slice(0, 2e3);
|
|
26628
26978
|
settle3();
|
|
26629
|
-
this.log(`mcp: "${this.spec.id}" answered ${res.status}: ${text3.slice(0, 300)}`);
|
|
26979
|
+
if (!this.probing) this.log(`mcp: "${this.spec.id}" answered ${res.status}: ${text3.slice(0, 300)}`);
|
|
26630
26980
|
let said;
|
|
26981
|
+
let rpcError = {};
|
|
26631
26982
|
try {
|
|
26632
26983
|
const j = JSON.parse(text3);
|
|
26633
|
-
const
|
|
26984
|
+
const e = j.error;
|
|
26985
|
+
const m = e?.message ?? j.message ?? j.error;
|
|
26634
26986
|
if (typeof m === "string" && m.length < 200 && !/[<{]/.test(m)) said = m;
|
|
26987
|
+
if (e && typeof e === "object" && typeof e.code === "number") rpcError = { code: e.code, data: e.data };
|
|
26635
26988
|
} catch {
|
|
26636
26989
|
}
|
|
26637
26990
|
this.lastError = `the server answered ${res.status}${said ? `: ${said}` : ""}`;
|
|
26638
|
-
throw new McpError(this.lastError);
|
|
26991
|
+
throw new McpError(this.lastError, { status: res.status, ...rpcError });
|
|
26639
26992
|
}
|
|
26640
26993
|
const session3 = res.headers.get("mcp-session-id");
|
|
26641
|
-
if (session3) this.sessionId = session3;
|
|
26994
|
+
if (session3 && !this.modern) this.sessionId = session3;
|
|
26642
26995
|
if (res.status === 202) {
|
|
26643
26996
|
settle3();
|
|
26644
26997
|
return null;
|
|
@@ -26670,7 +27023,7 @@ var McpHttpClient = class {
|
|
|
26670
27023
|
throw new McpError("the server answered with a message of its own instead of a reply");
|
|
26671
27024
|
}
|
|
26672
27025
|
if (expect !== void 0 && parsed.id !== expect) throw new McpError("the server answered a different request");
|
|
26673
|
-
if (parsed.error) throw
|
|
27026
|
+
if (parsed.error) throw rpcFailure(parsed.error);
|
|
26674
27027
|
return parsed.result;
|
|
26675
27028
|
}
|
|
26676
27029
|
/**
|
|
@@ -26702,10 +27055,10 @@ var McpHttpClient = class {
|
|
|
26702
27055
|
}
|
|
26703
27056
|
if (parsed.id === void 0 || expect !== void 0 && parsed.id !== expect) continue;
|
|
26704
27057
|
found = true;
|
|
26705
|
-
if (parsed.error) error51 = parsed.error
|
|
27058
|
+
if (parsed.error) error51 = rpcFailure(parsed.error);
|
|
26706
27059
|
else result = parsed.result;
|
|
26707
27060
|
}
|
|
26708
|
-
if (error51) throw
|
|
27061
|
+
if (error51) throw error51;
|
|
26709
27062
|
if (!found) throw new McpError("the event stream carried no reply");
|
|
26710
27063
|
return result;
|
|
26711
27064
|
}
|
|
@@ -26720,12 +27073,18 @@ var McpHttpClient = class {
|
|
|
26720
27073
|
/** A message whose answer nobody waits for: a reply to the server, a cancellation. */
|
|
26721
27074
|
async post(body2) {
|
|
26722
27075
|
try {
|
|
26723
|
-
await fetch(this.spec.url, { method: "POST", headers: this.headers(), body: body2, signal: AbortSignal.timeout(5e3) });
|
|
27076
|
+
await fetch(this.spec.url, { method: "POST", headers: this.headers(body2), body: body2, signal: AbortSignal.timeout(5e3) });
|
|
26724
27077
|
} catch {
|
|
26725
27078
|
}
|
|
26726
27079
|
}
|
|
26727
|
-
listTools() {
|
|
26728
|
-
|
|
27080
|
+
async listTools() {
|
|
27081
|
+
const tools = await listAllTools((params) => this.send(this.request(this.nextId++, "tools/list", params), HANDSHAKE_TIMEOUT_MS));
|
|
27082
|
+
if (!this.modern) return tools;
|
|
27083
|
+
return tools.filter((tool) => {
|
|
27084
|
+
const declared2 = headerParams(tool);
|
|
27085
|
+
if (!declared2.ok) this.log(`mcp: "${this.spec.id}" tool "${tool.name}" left out: ${declared2.reason}`);
|
|
27086
|
+
return declared2.ok;
|
|
27087
|
+
});
|
|
26729
27088
|
}
|
|
26730
27089
|
relisting = false;
|
|
26731
27090
|
async relist() {
|
|
@@ -26741,12 +27100,60 @@ var McpHttpClient = class {
|
|
|
26741
27100
|
this.relisting = false;
|
|
26742
27101
|
}
|
|
26743
27102
|
}
|
|
27103
|
+
/**
|
|
27104
|
+
* Which protocol this server speaks, and the old handshake if it is a 2025
|
|
27105
|
+
* one.
|
|
27106
|
+
*
|
|
27107
|
+
* A modern request first: server/discover, which every 2026-07-28 server
|
|
27108
|
+
* MUST answer. The Streamable HTTP binding says to fall back only when the
|
|
27109
|
+
* answer is not a recognised modern error, so a 400 carrying
|
|
27110
|
+
* UnsupportedProtocolVersion is read for its versions, while a 400 from a
|
|
27111
|
+
* server that wanted a session, a 404 or 405, or a JSON-RPC "method not
|
|
27112
|
+
* found" means a 2025 server, which is initialized as before. A failure
|
|
27113
|
+
* with no answer at all (refused, timed out) is not a verdict and fails the
|
|
27114
|
+
* start, as it did.
|
|
27115
|
+
*/
|
|
26744
27116
|
async handshake() {
|
|
27117
|
+
this.modern = MODERN_PROTOCOL_VERSION;
|
|
27118
|
+
let era;
|
|
27119
|
+
let discovered;
|
|
27120
|
+
let refusal = null;
|
|
27121
|
+
this.probing = true;
|
|
27122
|
+
try {
|
|
27123
|
+
discovered = await this.send(this.request(this.nextId++, "server/discover"), HANDSHAKE_TIMEOUT_MS);
|
|
27124
|
+
} catch (err2) {
|
|
27125
|
+
const answered = err2 instanceof McpError && (err2.status !== void 0 || err2.code !== void 0);
|
|
27126
|
+
if (!answered) {
|
|
27127
|
+
this.modern = null;
|
|
27128
|
+
throw err2;
|
|
27129
|
+
}
|
|
27130
|
+
refusal = err2;
|
|
27131
|
+
} finally {
|
|
27132
|
+
this.probing = false;
|
|
27133
|
+
}
|
|
27134
|
+
try {
|
|
27135
|
+
era = refusal ? eraFromDiscover({ error: refusal }) : eraFromDiscover({ result: discovered });
|
|
27136
|
+
} catch (err2) {
|
|
27137
|
+
this.modern = null;
|
|
27138
|
+
this.lastError = err2 instanceof Error ? err2.message : String(err2);
|
|
27139
|
+
throw err2;
|
|
27140
|
+
}
|
|
27141
|
+
if (era.era === "modern") {
|
|
27142
|
+
this.modern = era.version;
|
|
27143
|
+
this.protocolVersion = era.version;
|
|
27144
|
+
this.serverName = era.serverName ?? serverInfoName(discovered) ?? this.spec.id;
|
|
27145
|
+
this.started = true;
|
|
27146
|
+
return;
|
|
27147
|
+
}
|
|
27148
|
+
this.modern = null;
|
|
27149
|
+
this.sessionId = "";
|
|
27150
|
+
this.lastError = "";
|
|
27151
|
+
if (refusal) this.log(`mcp: "${this.spec.id}" speaks an earlier MCP (${refusal.message}); initializing it`);
|
|
26745
27152
|
const result = await this.send(
|
|
26746
27153
|
rpc(this.nextId++, "initialize", {
|
|
26747
27154
|
protocolVersion: PROTOCOL_VERSION,
|
|
26748
27155
|
capabilities: {},
|
|
26749
|
-
clientInfo:
|
|
27156
|
+
clientInfo: CLIENT_INFO
|
|
26750
27157
|
}),
|
|
26751
27158
|
HANDSHAKE_TIMEOUT_MS
|
|
26752
27159
|
);
|
|
@@ -26758,16 +27165,16 @@ var McpHttpClient = class {
|
|
|
26758
27165
|
async start() {
|
|
26759
27166
|
await this.handshake();
|
|
26760
27167
|
this.tools = await this.listTools();
|
|
26761
|
-
this.log(`mcp: "${this.spec.id}" offered ${this.tools.length} tool(s) over http`);
|
|
27168
|
+
this.log(`mcp: "${this.spec.id}" offered ${this.tools.length} tool(s) over http${this.modern ? `, MCP ${this.modern}` : ""}`);
|
|
26762
27169
|
}
|
|
26763
27170
|
async callTool(name3, args2, signal) {
|
|
26764
27171
|
const id = this.nextId++;
|
|
26765
27172
|
let result;
|
|
26766
27173
|
try {
|
|
26767
|
-
result = await this.send(
|
|
27174
|
+
result = await this.send(this.request(id, "tools/call", { name: name3, arguments: args2 }), CALL_TIMEOUT_MS, true, 0, signal);
|
|
26768
27175
|
} catch (err2) {
|
|
26769
27176
|
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
26770
|
-
if (signal?.aborted || /^no (complete )?answer within/.test(message)) {
|
|
27177
|
+
if (!this.modern && (signal?.aborted || /^no (complete )?answer within/.test(message))) {
|
|
26771
27178
|
void this.post(notification("notifications/cancelled", {
|
|
26772
27179
|
requestId: id,
|
|
26773
27180
|
reason: signal?.aborted ? "the run was stopped" : "timed out"
|
|
@@ -26775,6 +27182,9 @@ var McpHttpClient = class {
|
|
|
26775
27182
|
}
|
|
26776
27183
|
throw err2;
|
|
26777
27184
|
}
|
|
27185
|
+
const asked = inputRequired(result);
|
|
27186
|
+
if (asked) return { text: `The tool reported an error:
|
|
27187
|
+
${asked}`, images: [] };
|
|
26778
27188
|
if (result?.isError) {
|
|
26779
27189
|
return { text: `The tool reported an error:
|
|
26780
27190
|
${contentToText(result)}`, images: [] };
|
|
@@ -26791,6 +27201,9 @@ ${contentToText(result)}`, images: [] };
|
|
|
26791
27201
|
this.tools = [];
|
|
26792
27202
|
}
|
|
26793
27203
|
};
|
|
27204
|
+
function rpcFailure(error51) {
|
|
27205
|
+
return new McpError(error51.message ?? "server returned an error", { code: error51.code, data: error51.data });
|
|
27206
|
+
}
|
|
26794
27207
|
function idOf(body2) {
|
|
26795
27208
|
try {
|
|
26796
27209
|
return JSON.parse(body2).id;
|
|
@@ -26879,6 +27292,22 @@ async function pin(store2, server, tools) {
|
|
|
26879
27292
|
}
|
|
26880
27293
|
await store2.update(PINS_KEY, { ...allPins(store2), [server]: pinned });
|
|
26881
27294
|
}
|
|
27295
|
+
function describeChange(server, change) {
|
|
27296
|
+
const lines2 = [];
|
|
27297
|
+
for (const tool of change.added) {
|
|
27298
|
+
const d = describeTool(tool);
|
|
27299
|
+
lines2.push(`New: ${d.name}${d.description ? ` -- ${d.description.slice(0, 300)}` : ""}` + (d.signals.length ? ` [${d.signals.join("; ")}]` : ""));
|
|
27300
|
+
}
|
|
27301
|
+
for (const { tool, before } of change.changed) {
|
|
27302
|
+
const d = describeTool(tool);
|
|
27303
|
+
lines2.push(d.description === before ? `Changed: ${d.name} (its input schema)` : `Changed: ${d.name}
|
|
27304
|
+
was: ${before || "(no description)"}
|
|
27305
|
+
now: ${d.description.slice(0, 300) || "(no description)"}` + (d.signals.length ? ` [${d.signals.join("; ")}]` : ""));
|
|
27306
|
+
}
|
|
27307
|
+
return `The MCP server "${server}" changed its tools since you last used it. Until you agree, the new and changed ones are not offered to the agent.
|
|
27308
|
+
|
|
27309
|
+
` + lines2.join("\n");
|
|
27310
|
+
}
|
|
26882
27311
|
|
|
26883
27312
|
// ../editor/src/mcp/registry.ts
|
|
26884
27313
|
var TOOL_PREFIX = "mcp__";
|
|
@@ -27164,6 +27593,107 @@ function normaliseSchema(schema) {
|
|
|
27164
27593
|
return { ...schema, properties: schema.properties ?? {} };
|
|
27165
27594
|
}
|
|
27166
27595
|
|
|
27596
|
+
// ../editor/src/mcp/catalogue.ts
|
|
27597
|
+
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
27598
|
+
var CATALOGUE = [
|
|
27599
|
+
/*
|
|
27600
|
+
GITHUB'S OWN SERVER, REMOTE, WITH A TOKEN FROM THE KEYCHAIN. 2026-10-05.
|
|
27601
|
+
|
|
27602
|
+
This was `npx -y @modelcontextprotocol/server-github@2025.4.8`, which npm
|
|
27603
|
+
now marks "Package no longer supported": GitHub took the server over and
|
|
27604
|
+
publishes it as github/github-mcp-server, run by GitHub at
|
|
27605
|
+
https://api.githubcopilot.com/mcp/ (its README; the endpoint answers 401
|
|
27606
|
+
with resource_metadata naming exactly that resource).
|
|
27607
|
+
|
|
27608
|
+
NOT OAuth, although the server advertises it. Its authorization server,
|
|
27609
|
+
https://github.com/login/oauth, publishes no registration_endpoint and no
|
|
27610
|
+
client_id_metadata_document_supported (checked against
|
|
27611
|
+
/.well-known/oauth-authorization-server/login/oauth, 2026-10-05), so a
|
|
27612
|
+
client has to be an OAuth app GitHub already knows; this editor is not one.
|
|
27613
|
+
GitHub's own install guides for clients in the same position send a
|
|
27614
|
+
personal access token as `Authorization: Bearer`, so that is what this
|
|
27615
|
+
does, from the keychain only: see keychainBearerFor and index.ts.
|
|
27616
|
+
|
|
27617
|
+
Remote rather than GitHub's local alternatives (the
|
|
27618
|
+
ghcr.io/github/github-mcp-server image, or its binary): both need Docker
|
|
27619
|
+
or a download before anything works, and the remote one needs neither.
|
|
27620
|
+
*/
|
|
27621
|
+
{
|
|
27622
|
+
id: "github",
|
|
27623
|
+
title: "GitHub",
|
|
27624
|
+
description: "Read issues and pull requests, and search code across your repositories.",
|
|
27625
|
+
url: "https://api.githubcopilot.com/mcp/",
|
|
27626
|
+
bearer: "GITHUB_PERSONAL_ACCESS_TOKEN",
|
|
27627
|
+
needs: ["GITHUB_PERSONAL_ACCESS_TOKEN"],
|
|
27628
|
+
// The scopes GitHub's README recommends as the minimum for a classic token.
|
|
27629
|
+
tokenHelp: "Create one at https://github.com/settings/tokens with the repo, read:org and read:packages scopes, or a fine-grained token limited to the repositories you choose.",
|
|
27630
|
+
docs: "https://github.com/github/github-mcp-server"
|
|
27631
|
+
},
|
|
27632
|
+
/*
|
|
27633
|
+
PostgreSQL was here, as @modelcontextprotocol/server-postgres with
|
|
27634
|
+
POSTGRES_CONNECTION_STRING. It never started: the package is deprecated
|
|
27635
|
+
("no longer supported" on npm) and reads the database URL from its command
|
|
27636
|
+
line, not that variable, so it exited with "Please provide a database URL"
|
|
27637
|
+
every time. Removed rather than kept as a row that cannot work.
|
|
27638
|
+
*/
|
|
27639
|
+
{
|
|
27640
|
+
id: "filesystem",
|
|
27641
|
+
title: "Filesystem",
|
|
27642
|
+
// NOT read-only, which this said: the server's tools include write_file,
|
|
27643
|
+
// edit_file, move_file and create_directory.
|
|
27644
|
+
description: "Let the agent read and write files in a directory outside the workspace.",
|
|
27645
|
+
command: "npx",
|
|
27646
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem@2026.8.31"],
|
|
27647
|
+
// It had no directory, and the server is given its folders on its command
|
|
27648
|
+
// line (or by MCP roots, which this client does not offer), so it started
|
|
27649
|
+
// with access to nothing and every call failed.
|
|
27650
|
+
directoryArg: true,
|
|
27651
|
+
docs: "https://github.com/modelcontextprotocol/servers"
|
|
27652
|
+
},
|
|
27653
|
+
{
|
|
27654
|
+
id: "sentry",
|
|
27655
|
+
title: "Sentry",
|
|
27656
|
+
description: "Pull an issue and its stack trace, so a fix starts from the real error.",
|
|
27657
|
+
// Sentry's own remote server, signed in through the browser. The local
|
|
27658
|
+
// package asked for SENTRY_AUTH_TOKEN here, which it does not read (it
|
|
27659
|
+
// wants SENTRY_ACCESS_TOKEN), so it exited "No access token was provided"
|
|
27660
|
+
// for everybody who followed the instruction.
|
|
27661
|
+
url: "https://mcp.sentry.dev/mcp",
|
|
27662
|
+
docs: "https://docs.sentry.io/product/sentry-mcp/"
|
|
27663
|
+
},
|
|
27664
|
+
/*
|
|
27665
|
+
FIGMA'S DESKTOP SERVER, not its remote one. 2026-09-29.
|
|
27666
|
+
|
|
27667
|
+
Users asked for UIs built from their Figma frames; a screenshot loses the
|
|
27668
|
+
exact values, the auto-layout and the variables that the Figma MCP server
|
|
27669
|
+
returns. Figma's remote server (mcp.figma.com) accepts only clients in its
|
|
27670
|
+
MCP Catalog, which this editor is not in yet. The desktop server is the
|
|
27671
|
+
Figma app itself, on this machine, enabled from Dev Mode, with no such
|
|
27672
|
+
list. Loopback, so plain http never leaves the machine.
|
|
27673
|
+
*/
|
|
27674
|
+
{
|
|
27675
|
+
id: "figma",
|
|
27676
|
+
// The name the docs and refusedRegistration (oauth.ts) tell people to look for.
|
|
27677
|
+
title: "Figma (desktop app)",
|
|
27678
|
+
description: 'Build from a Figma frame: exact values, layout, variables and a screenshot to compare against. In the Figma desktop app, open Dev Mode (Shift+D) and choose "Enable desktop MCP server" first.',
|
|
27679
|
+
url: "http://127.0.0.1:3845/mcp",
|
|
27680
|
+
docs: "https://developers.figma.com/docs/figma-mcp-server/local-server-installation/"
|
|
27681
|
+
},
|
|
27682
|
+
{
|
|
27683
|
+
id: "linear",
|
|
27684
|
+
title: "Linear",
|
|
27685
|
+
description: "Read and update issues without leaving the editor.",
|
|
27686
|
+
// /mcp, not /sse. /sse is the older transport, which this client does not
|
|
27687
|
+
// speak: it answered 404 to every request, so the entry never connected.
|
|
27688
|
+
url: "https://mcp.linear.app/mcp",
|
|
27689
|
+
docs: "https://linear.app/docs/mcp"
|
|
27690
|
+
}
|
|
27691
|
+
];
|
|
27692
|
+
function keychainBearerFor(spec) {
|
|
27693
|
+
const entry = CATALOGUE.find((e) => e.id === spec.id && e.url !== void 0 && e.url === spec.url);
|
|
27694
|
+
return entry?.bearer;
|
|
27695
|
+
}
|
|
27696
|
+
|
|
27167
27697
|
// ../editor/src/mcp/config.ts
|
|
27168
27698
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
27169
27699
|
var vscode7 = __toESM(require_shim_vscode());
|
|
@@ -27512,6 +28042,7 @@ async function loopbackRedirect(options = {}) {
|
|
|
27512
28042
|
let resolveCode = null;
|
|
27513
28043
|
let rejectCode = null;
|
|
27514
28044
|
let expectedState = "";
|
|
28045
|
+
let issuer = null;
|
|
27515
28046
|
const server = (0, import_http.createServer)((req, res) => {
|
|
27516
28047
|
const url2 = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
27517
28048
|
const code = url2.searchParams.get("code");
|
|
@@ -27534,6 +28065,12 @@ async function loopbackRedirect(options = {}) {
|
|
|
27534
28065
|
done2("That link did not come from AstraCode.");
|
|
27535
28066
|
return;
|
|
27536
28067
|
}
|
|
28068
|
+
const mismatch = issuer ? issuerMismatch(url2.searchParams.get("iss"), issuer) : null;
|
|
28069
|
+
if (mismatch) {
|
|
28070
|
+
done2("That sign-in answer came from a different server than the one AstraCode asked, so it was not used.");
|
|
28071
|
+
rejectCode?.(new Error(mismatch));
|
|
28072
|
+
return;
|
|
28073
|
+
}
|
|
27537
28074
|
if (error51) {
|
|
27538
28075
|
done2("Sign-in was refused. You can close this tab.");
|
|
27539
28076
|
rejectCode?.(new Error(`authorization failed: ${error51}`));
|
|
@@ -27547,31 +28084,34 @@ async function loopbackRedirect(options = {}) {
|
|
|
27547
28084
|
toTerminal ? "All set! Return to your terminal. Feel free to close this tab." : "All set! Returning you to AstraCode. Feel free to close this tab.",
|
|
27548
28085
|
true
|
|
27549
28086
|
);
|
|
27550
|
-
resolveCode?.(code);
|
|
28087
|
+
resolveCode?.({ code, iss: url2.searchParams.get("iss") });
|
|
27551
28088
|
});
|
|
27552
|
-
await
|
|
28089
|
+
await listenOn(server, options.ports ?? []);
|
|
27553
28090
|
const { port } = server.address();
|
|
28091
|
+
const waitResponse = (state, check2) => {
|
|
28092
|
+
expectedState = state;
|
|
28093
|
+
issuer = check2 ?? null;
|
|
28094
|
+
return new Promise((resolve21, reject) => {
|
|
28095
|
+
const timer = setTimeout(() => {
|
|
28096
|
+
reject(new Error(TIMED_OUT));
|
|
28097
|
+
server.close();
|
|
28098
|
+
}, options.waitMs ?? WAIT_MS);
|
|
28099
|
+
resolveCode = (response) => {
|
|
28100
|
+
clearTimeout(timer);
|
|
28101
|
+
server.close();
|
|
28102
|
+
resolve21(response);
|
|
28103
|
+
};
|
|
28104
|
+
rejectCode = (err2) => {
|
|
28105
|
+
clearTimeout(timer);
|
|
28106
|
+
server.close();
|
|
28107
|
+
reject(err2);
|
|
28108
|
+
};
|
|
28109
|
+
});
|
|
28110
|
+
};
|
|
27554
28111
|
return {
|
|
27555
28112
|
uri: `http://127.0.0.1:${port}/callback`,
|
|
27556
|
-
wait(state)
|
|
27557
|
-
|
|
27558
|
-
return new Promise((resolve20, reject) => {
|
|
27559
|
-
const timer = setTimeout(() => {
|
|
27560
|
-
reject(new Error(TIMED_OUT));
|
|
27561
|
-
server.close();
|
|
27562
|
-
}, options.waitMs ?? WAIT_MS);
|
|
27563
|
-
resolveCode = (code) => {
|
|
27564
|
-
clearTimeout(timer);
|
|
27565
|
-
server.close();
|
|
27566
|
-
resolve20(code);
|
|
27567
|
-
};
|
|
27568
|
-
rejectCode = (err2) => {
|
|
27569
|
-
clearTimeout(timer);
|
|
27570
|
-
server.close();
|
|
27571
|
-
reject(err2);
|
|
27572
|
-
};
|
|
27573
|
-
});
|
|
27574
|
-
},
|
|
28113
|
+
wait: (state) => waitResponse(state).then((r) => r.code),
|
|
28114
|
+
waitResponse,
|
|
27575
28115
|
/*
|
|
27576
28116
|
Ends a wait in flight, not only the listener. Closing the server alone
|
|
27577
28117
|
left the promise pending, so Cancel on "Signing in to AstraCode in your
|
|
@@ -27584,6 +28124,20 @@ async function loopbackRedirect(options = {}) {
|
|
|
27584
28124
|
}
|
|
27585
28125
|
};
|
|
27586
28126
|
}
|
|
28127
|
+
async function listenOn(server, ports) {
|
|
28128
|
+
for (const port of [...ports, 0]) {
|
|
28129
|
+
const ok = await new Promise((resolve21) => {
|
|
28130
|
+
const failed = () => resolve21(false);
|
|
28131
|
+
server.once("error", failed);
|
|
28132
|
+
server.listen(port, "127.0.0.1", () => {
|
|
28133
|
+
server.off("error", failed);
|
|
28134
|
+
resolve21(true);
|
|
28135
|
+
});
|
|
28136
|
+
});
|
|
28137
|
+
if (ok) return;
|
|
28138
|
+
}
|
|
28139
|
+
throw new Error("could not listen on a loopback port for the sign-in");
|
|
28140
|
+
}
|
|
27587
28141
|
|
|
27588
28142
|
// ../editor/src/providers/anthropicProvider.ts
|
|
27589
28143
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
@@ -28250,6 +28804,7 @@ async function startMcp(log2, org, auth = null, envFor, review3 = null) {
|
|
|
28250
28804
|
if (!mcpEnabled()) return;
|
|
28251
28805
|
const mine = configuredServers(log2);
|
|
28252
28806
|
if (envFor) {
|
|
28807
|
+
await attachKeychainBearers(mine, envFor);
|
|
28253
28808
|
for (const spec of mine) {
|
|
28254
28809
|
if (isHttpSpec(spec)) continue;
|
|
28255
28810
|
if ((spec.origin ?? "user") !== "user") continue;
|
|
@@ -28263,6 +28818,15 @@ async function startMcp(log2, org, auth = null, envFor, review3 = null) {
|
|
|
28263
28818
|
registry2 = new McpRegistry(log2, auth, review3);
|
|
28264
28819
|
await registry2.start(specs);
|
|
28265
28820
|
}
|
|
28821
|
+
async function attachKeychainBearers(specs, envFor) {
|
|
28822
|
+
for (const spec of specs) {
|
|
28823
|
+
if (!isHttpSpec(spec) || (spec.origin ?? "user") !== "user") continue;
|
|
28824
|
+
const variable = keychainBearerFor(spec);
|
|
28825
|
+
if (!variable) continue;
|
|
28826
|
+
const token = (await envFor(spec.id))[variable];
|
|
28827
|
+
spec.bearer = { variable, ...token ? { token } : {} };
|
|
28828
|
+
}
|
|
28829
|
+
}
|
|
28266
28830
|
function mcpToolReadOnly(name3) {
|
|
28267
28831
|
return registry2?.readOnly(name3) ?? false;
|
|
28268
28832
|
}
|
|
@@ -28314,13 +28878,13 @@ var CdpSession = class extends import_events4.EventEmitter {
|
|
|
28314
28878
|
}
|
|
28315
28879
|
send(method, params = {}, timeoutMs = 15e3) {
|
|
28316
28880
|
const id = this.nextId++;
|
|
28317
|
-
return new Promise((
|
|
28881
|
+
return new Promise((resolve21, reject) => {
|
|
28318
28882
|
const timer = setTimeout(() => {
|
|
28319
28883
|
this.pending.delete(id);
|
|
28320
28884
|
reject(new Error(`Browser command "${method}" timed out after ${timeoutMs}ms.`));
|
|
28321
28885
|
}, timeoutMs);
|
|
28322
28886
|
this.pending.set(id, {
|
|
28323
|
-
resolve:
|
|
28887
|
+
resolve: resolve21,
|
|
28324
28888
|
reject,
|
|
28325
28889
|
timer
|
|
28326
28890
|
});
|
|
@@ -31154,13 +31718,13 @@ function setFrontMatter(markdown, key, value) {
|
|
|
31154
31718
|
|
|
31155
31719
|
// ../editor/src/agent/planStore.ts
|
|
31156
31720
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
31157
|
-
function slugFromPath(
|
|
31158
|
-
const m = /([A-Za-z0-9_-]+)\.plan\.md$/.exec(
|
|
31721
|
+
function slugFromPath(path54) {
|
|
31722
|
+
const m = /([A-Za-z0-9_-]+)\.plan\.md$/.exec(path54);
|
|
31159
31723
|
return m ? m[1] : void 0;
|
|
31160
31724
|
}
|
|
31161
31725
|
var PlanStore = class {
|
|
31162
|
-
constructor(
|
|
31163
|
-
this.fs =
|
|
31726
|
+
constructor(fs46, newId) {
|
|
31727
|
+
this.fs = fs46;
|
|
31164
31728
|
this.newId = newId;
|
|
31165
31729
|
}
|
|
31166
31730
|
fs;
|
|
@@ -31176,8 +31740,8 @@ var PlanStore = class {
|
|
|
31176
31740
|
async create(input, now = /* @__PURE__ */ new Date()) {
|
|
31177
31741
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
31178
31742
|
const slug3 = planSlug(input.task, this.newId());
|
|
31179
|
-
const
|
|
31180
|
-
if (await this.fs.read(
|
|
31743
|
+
const path54 = planPath(slug3);
|
|
31744
|
+
if (await this.fs.read(path54) !== void 0) continue;
|
|
31181
31745
|
const raw = renderPlanFile(
|
|
31182
31746
|
{
|
|
31183
31747
|
task: oneLine3(input.task),
|
|
@@ -31189,16 +31753,16 @@ var PlanStore = class {
|
|
|
31189
31753
|
},
|
|
31190
31754
|
input.body
|
|
31191
31755
|
);
|
|
31192
|
-
await this.fs.write(
|
|
31193
|
-
return { ...parsePlan(raw), slug: slug3, path:
|
|
31756
|
+
await this.fs.write(path54, raw);
|
|
31757
|
+
return { ...parsePlan(raw), slug: slug3, path: path54 };
|
|
31194
31758
|
}
|
|
31195
31759
|
throw new Error("could not find a free plan filename after 5 attempts");
|
|
31196
31760
|
}
|
|
31197
31761
|
async read(slug3) {
|
|
31198
|
-
const
|
|
31199
|
-
const raw = await this.fs.read(
|
|
31762
|
+
const path54 = planPath(slug3);
|
|
31763
|
+
const raw = await this.fs.read(path54);
|
|
31200
31764
|
if (raw === void 0) return void 0;
|
|
31201
|
-
return { ...parsePlan(raw), slug: slugFromPath(
|
|
31765
|
+
return { ...parsePlan(raw), slug: slugFromPath(path54) ?? slug3, path: path54 };
|
|
31202
31766
|
}
|
|
31203
31767
|
markStep(slug3, line, status3) {
|
|
31204
31768
|
return this.modify(slug3, (raw) => markStep(raw, line, status3));
|
|
@@ -31279,12 +31843,12 @@ ${line}
|
|
|
31279
31843
|
*/
|
|
31280
31844
|
modify(slug3, fn) {
|
|
31281
31845
|
return this.serialised(slug3, async () => {
|
|
31282
|
-
const
|
|
31283
|
-
const before = await this.fs.read(
|
|
31846
|
+
const path54 = planPath(slug3);
|
|
31847
|
+
const before = await this.fs.read(path54);
|
|
31284
31848
|
if (before === void 0) return void 0;
|
|
31285
31849
|
const after = fn(before);
|
|
31286
|
-
if (after !== before) await this.fs.write(
|
|
31287
|
-
return { ...parsePlan(after), slug: slugFromPath(
|
|
31850
|
+
if (after !== before) await this.fs.write(path54, after);
|
|
31851
|
+
return { ...parsePlan(after), slug: slugFromPath(path54) ?? slug3, path: path54 };
|
|
31288
31852
|
});
|
|
31289
31853
|
}
|
|
31290
31854
|
serialised(slug3, fn) {
|
|
@@ -31470,7 +32034,7 @@ var BackgroundTasks = class {
|
|
|
31470
32034
|
whenEnded(id) {
|
|
31471
32035
|
const entry = this.entries.get(id);
|
|
31472
32036
|
if (!entry || entry.task.state !== "running") return Promise.resolve();
|
|
31473
|
-
return new Promise((
|
|
32037
|
+
return new Promise((resolve21) => entry.waiters.push(resolve21));
|
|
31474
32038
|
}
|
|
31475
32039
|
/** A foreground command, handed to the background: it shows in the list from now on. */
|
|
31476
32040
|
release(id) {
|
|
@@ -31858,7 +32422,7 @@ function severityLabel(s) {
|
|
|
31858
32422
|
}
|
|
31859
32423
|
}
|
|
31860
32424
|
async function newDiagnosticsSince(uri, before, settleDelayMs = SETTLE_DELAY_MS) {
|
|
31861
|
-
await new Promise((
|
|
32425
|
+
await new Promise((resolve21) => setTimeout(resolve21, settleDelayMs));
|
|
31862
32426
|
const after = vscode19.languages.getDiagnostics(uri);
|
|
31863
32427
|
const fresh = after.filter((d) => !before.has(fingerprint3(d)));
|
|
31864
32428
|
const actionable = fresh.filter(
|
|
@@ -32034,16 +32598,16 @@ var Diff = class {
|
|
|
32034
32598
|
}
|
|
32035
32599
|
}
|
|
32036
32600
|
}
|
|
32037
|
-
addToPath(
|
|
32038
|
-
const last =
|
|
32601
|
+
addToPath(path54, added, removed, oldPosInc, options) {
|
|
32602
|
+
const last = path54.lastComponent;
|
|
32039
32603
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
32040
32604
|
return {
|
|
32041
|
-
oldPos:
|
|
32605
|
+
oldPos: path54.oldPos + oldPosInc,
|
|
32042
32606
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
32043
32607
|
};
|
|
32044
32608
|
} else {
|
|
32045
32609
|
return {
|
|
32046
|
-
oldPos:
|
|
32610
|
+
oldPos: path54.oldPos + oldPosInc,
|
|
32047
32611
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
32048
32612
|
};
|
|
32049
32613
|
}
|
|
@@ -32728,12 +33292,12 @@ function displayPath(absolute) {
|
|
|
32728
33292
|
return toolPath(absolute);
|
|
32729
33293
|
}
|
|
32730
33294
|
function runRg(rg, args2, cwd, maxBuffer) {
|
|
32731
|
-
return new Promise((
|
|
33295
|
+
return new Promise((resolve21) => {
|
|
32732
33296
|
(0, import_child_process4.execFile)(rg, [...args2, "."], { cwd, timeout: deadlineMs, maxBuffer }, (error51, stdout, stderr) => {
|
|
32733
33297
|
const e = error51;
|
|
32734
33298
|
const cut = !!e && (e.killed === true || !!e.signal || e.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER");
|
|
32735
33299
|
const code = !e ? 0 : Number(e.code) === 1 ? 1 : 2;
|
|
32736
|
-
|
|
33300
|
+
resolve21({ stdout: String(stdout ?? ""), code, stderr: String(stderr ?? ""), cut });
|
|
32737
33301
|
});
|
|
32738
33302
|
});
|
|
32739
33303
|
}
|
|
@@ -32987,14 +33551,14 @@ function parsePatch(raw) {
|
|
|
32987
33551
|
return { kind: "error", message: "apply_patch does not rename files here. Move it with run_terminal_command, then patch it." };
|
|
32988
33552
|
}
|
|
32989
33553
|
if (header2.startsWith(ADD)) {
|
|
32990
|
-
const
|
|
33554
|
+
const path55 = header2.slice(ADD.length).trim();
|
|
32991
33555
|
const bad = body2.find((l) => !l.startsWith("+"));
|
|
32992
33556
|
if (bad !== void 0) {
|
|
32993
33557
|
return { kind: "error", message: `every line of an added file starts with "+"; this one does not: ${JSON.stringify(bad)}` };
|
|
32994
33558
|
}
|
|
32995
|
-
return { kind: "add", path:
|
|
33559
|
+
return { kind: "add", path: path55, content: body2.length ? body2.map((l) => l.slice(1)).join("\n") + "\n" : "" };
|
|
32996
33560
|
}
|
|
32997
|
-
const
|
|
33561
|
+
const path54 = header2.slice(UPDATE.length).trim();
|
|
32998
33562
|
const hunks = [];
|
|
32999
33563
|
let current4;
|
|
33000
33564
|
const start2 = (anchor) => {
|
|
@@ -33029,8 +33593,8 @@ function parsePatch(raw) {
|
|
|
33029
33593
|
}
|
|
33030
33594
|
}
|
|
33031
33595
|
const real = hunks.filter((h) => h.oldLines.length || h.newLines.length);
|
|
33032
|
-
if (real.length === 0) return { kind: "error", message: `the patch for ${
|
|
33033
|
-
return { kind: "update", path:
|
|
33596
|
+
if (real.length === 0) return { kind: "error", message: `the patch for ${path54} has no changes in it.` };
|
|
33597
|
+
return { kind: "update", path: path54, hunks: real };
|
|
33034
33598
|
}
|
|
33035
33599
|
function lineEndAfter(text2, index) {
|
|
33036
33600
|
const nl = text2.indexOf("\n", index);
|
|
@@ -33571,16 +34135,16 @@ function stripAnsi(s) {
|
|
|
33571
34135
|
}
|
|
33572
34136
|
async function waitForShellIntegration(t2) {
|
|
33573
34137
|
if (t2.shellIntegration) return t2.shellIntegration;
|
|
33574
|
-
return new Promise((
|
|
34138
|
+
return new Promise((resolve21) => {
|
|
33575
34139
|
const timer = setTimeout(() => {
|
|
33576
34140
|
sub.dispose();
|
|
33577
|
-
|
|
34141
|
+
resolve21(void 0);
|
|
33578
34142
|
}, INTEGRATION_WAIT_MS);
|
|
33579
34143
|
const sub = vscode22.window.onDidChangeTerminalShellIntegration((e) => {
|
|
33580
34144
|
if (e.terminal === t2) {
|
|
33581
34145
|
clearTimeout(timer);
|
|
33582
34146
|
sub.dispose();
|
|
33583
|
-
|
|
34147
|
+
resolve21(e.shellIntegration);
|
|
33584
34148
|
}
|
|
33585
34149
|
});
|
|
33586
34150
|
});
|
|
@@ -33598,15 +34162,15 @@ async function runInTerminal(command2, cwd, timeoutMs, maxChars, opts = {}) {
|
|
|
33598
34162
|
let output = "";
|
|
33599
34163
|
let truncated = false;
|
|
33600
34164
|
let sink;
|
|
33601
|
-
const ended = new Promise((
|
|
34165
|
+
const ended = new Promise((resolve21) => {
|
|
33602
34166
|
const sub = vscode22.window.onDidEndTerminalShellExecution((e) => {
|
|
33603
34167
|
if (e.execution === execution) {
|
|
33604
34168
|
sub.dispose();
|
|
33605
|
-
|
|
34169
|
+
resolve21(e.exitCode);
|
|
33606
34170
|
}
|
|
33607
34171
|
});
|
|
33608
34172
|
});
|
|
33609
|
-
const timedOut = new Promise((
|
|
34173
|
+
const timedOut = new Promise((resolve21) => setTimeout(() => resolve21("timeout"), timeoutMs));
|
|
33610
34174
|
const reader = (async () => {
|
|
33611
34175
|
for await (const chunk2 of execution.read()) {
|
|
33612
34176
|
if (sink) {
|
|
@@ -33734,8 +34298,8 @@ async function runCommandWhereConfigured(command2, cwd, raw, toolCallId, timeout
|
|
|
33734
34298
|
if (needsKeyboard) return `ERROR: ${needsKeyboard}`;
|
|
33735
34299
|
let detach = () => {
|
|
33736
34300
|
};
|
|
33737
|
-
const detached = new Promise((
|
|
33738
|
-
detach =
|
|
34301
|
+
const detached = new Promise((resolve21) => {
|
|
34302
|
+
detach = resolve21;
|
|
33739
34303
|
});
|
|
33740
34304
|
if (toolCallId) detachers.set(toolCallId, detach);
|
|
33741
34305
|
try {
|
|
@@ -33792,7 +34356,7 @@ ${out2}`;
|
|
|
33792
34356
|
}
|
|
33793
34357
|
const win = process.platform === "win32";
|
|
33794
34358
|
let winTimedOut = false;
|
|
33795
|
-
return new Promise((
|
|
34359
|
+
return new Promise((resolve21) => {
|
|
33796
34360
|
const child = (0, import_child_process5.exec)(
|
|
33797
34361
|
plan.command,
|
|
33798
34362
|
{ cwd, timeout: win ? 0 : timeoutMs, maxBuffer: 1024 * 1024, env: { ...process.env, ...AGENT_ENV } },
|
|
@@ -33803,7 +34367,7 @@ ${out2}`;
|
|
|
33803
34367
|
const body2 = killed ? `Command stopped after ${Math.round(timeoutMs / 1e3)}s, the time limit for one command here. That is the limit, not the command failing. What it printed before it was stopped:
|
|
33804
34368
|
${combined.trim() || "(nothing: some commands, terraform init among them, print only when done)"}` : error51 ? `Command failed (${error51.message}):
|
|
33805
34369
|
${combined}` : combined || "(no output)";
|
|
33806
|
-
|
|
34370
|
+
resolve21(plan.compressed ? body2 + COMPRESSION_NOTE : body2);
|
|
33807
34371
|
}
|
|
33808
34372
|
);
|
|
33809
34373
|
const timer = win && timeoutMs > 0 && child.pid ? setTimeout(() => {
|
|
@@ -33824,10 +34388,10 @@ async function undoFileChanges(changes) {
|
|
|
33824
34388
|
if (change.after !== void 0) latestAfterPerPath.set(change.path, change.after);
|
|
33825
34389
|
}
|
|
33826
34390
|
const changedSince = [];
|
|
33827
|
-
for (const [
|
|
34391
|
+
for (const [path54, change] of earliestPerPath) {
|
|
33828
34392
|
try {
|
|
33829
|
-
const uri = resolveWorkspacePath(
|
|
33830
|
-
const expected = latestAfterPerPath.get(
|
|
34393
|
+
const uri = resolveWorkspacePath(path54);
|
|
34394
|
+
const expected = latestAfterPerPath.get(path54);
|
|
33831
34395
|
if (expected !== void 0) {
|
|
33832
34396
|
let current4;
|
|
33833
34397
|
try {
|
|
@@ -33836,7 +34400,7 @@ async function undoFileChanges(changes) {
|
|
|
33836
34400
|
current4 = void 0;
|
|
33837
34401
|
}
|
|
33838
34402
|
if (current4 !== expected) {
|
|
33839
|
-
changedSince.push(
|
|
34403
|
+
changedSince.push(path54);
|
|
33840
34404
|
continue;
|
|
33841
34405
|
}
|
|
33842
34406
|
}
|
|
@@ -34533,8 +35097,8 @@ function readTokens(files) {
|
|
|
34533
35097
|
const colours = [];
|
|
34534
35098
|
const numbers = [];
|
|
34535
35099
|
const texts = [];
|
|
34536
|
-
for (const { path:
|
|
34537
|
-
if (/\.dart$/.test(
|
|
35100
|
+
for (const { path: path54, text: text2 } of files) {
|
|
35101
|
+
if (/\.dart$/.test(path54)) {
|
|
34538
35102
|
for (const cls of text2.matchAll(/class\s+(\w+)\s*\{([^]*?)\n\}/g)) {
|
|
34539
35103
|
const [, owner, body2] = cls;
|
|
34540
35104
|
for (const m of body2.matchAll(/static\s+const\s+(\w+)\s*=\s*Color\(0x([0-9a-fA-F]{8})\)/g)) {
|
|
@@ -34550,7 +35114,7 @@ function readTokens(files) {
|
|
|
34550
35114
|
texts.push({ name: `${owner}.${m[1]}`, size: Number(size2), weight, colour: /color:\s*([\w.]+)/.exec(m[2])?.[1] });
|
|
34551
35115
|
}
|
|
34552
35116
|
}
|
|
34553
|
-
} else if (/\.(css|scss|less)$/.test(
|
|
35117
|
+
} else if (/\.(css|scss|less)$/.test(path54)) {
|
|
34554
35118
|
for (const m of text2.matchAll(/(--[\w-]+)\s*:\s*#([0-9a-fA-F]{6})\b/g)) colours.push({ name: `var(${m[1]})`, rgb: rgbOf(m[2]) });
|
|
34555
35119
|
for (const m of text2.matchAll(/(--[\w-]+)\s*:\s*(\d+(?:\.\d+)?)px\b/g)) numbers.push({ name: `var(${m[1]})`, value: Number(m[2]), kind: kindOf(m[1]) });
|
|
34556
35120
|
}
|
|
@@ -35665,8 +36229,8 @@ ${context}` : task
|
|
|
35665
36229
|
if (TASK_TOOL_NAMES.has(call.name)) {
|
|
35666
36230
|
const owner = ctx.tasks?.owner ?? currentRunOwner();
|
|
35667
36231
|
const by = ctx.tasks?.callerId ?? "main";
|
|
35668
|
-
const
|
|
35669
|
-
return { output: runTaskTool(call.name, call.input, owner, by,
|
|
36232
|
+
const resolve21 = (o) => o === "main" ? o : taskRegistry().list(owner).find((t2) => t2.kind === "agent" && (t2.id === o || t2.name === o))?.id ?? o;
|
|
36233
|
+
return { output: runTaskTool(call.name, call.input, owner, by, resolve21) };
|
|
35670
36234
|
}
|
|
35671
36235
|
if (call.name === "update_todos") {
|
|
35672
36236
|
return await handleUpdateTodos(call, ctx);
|
|
@@ -36143,14 +36707,14 @@ function tail(text2, max) {
|
|
|
36143
36707
|
` + text2.slice(-max);
|
|
36144
36708
|
}
|
|
36145
36709
|
function runVerification(command2, cwd, timeoutMs = VERIFY_TIMEOUT_MS) {
|
|
36146
|
-
return new Promise((
|
|
36710
|
+
return new Promise((resolve21) => {
|
|
36147
36711
|
(0, import_node_child_process9.exec)(
|
|
36148
36712
|
command2,
|
|
36149
36713
|
{ cwd, timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 },
|
|
36150
36714
|
(error51, stdout, stderr) => {
|
|
36151
36715
|
const combined = tail(`${stdout}${stderr}`, MAX_VERIFY_OUTPUT_CHARS);
|
|
36152
36716
|
const timedOut = !!error51 && error51.killed === true;
|
|
36153
|
-
|
|
36717
|
+
resolve21({
|
|
36154
36718
|
command: command2,
|
|
36155
36719
|
ok: !error51,
|
|
36156
36720
|
timedOut,
|
|
@@ -36304,8 +36868,8 @@ Latest message: ${own}` : capMiddle(own, MAX_TASK_CHARS);
|
|
|
36304
36868
|
verify: "not run"
|
|
36305
36869
|
};
|
|
36306
36870
|
}
|
|
36307
|
-
function noteFileChanged(brief,
|
|
36308
|
-
if (!brief.filesChanged.includes(
|
|
36871
|
+
function noteFileChanged(brief, path54) {
|
|
36872
|
+
if (!brief.filesChanged.includes(path54)) brief.filesChanged.push(path54);
|
|
36309
36873
|
}
|
|
36310
36874
|
var BRIEF_HEADING = "WHERE YOU ARE (the editor's notes on this run, not a new message from the user)";
|
|
36311
36875
|
function formatRunBrief(brief, todos) {
|
|
@@ -36526,16 +37090,16 @@ function outline(root2) {
|
|
|
36526
37090
|
return lines2.join("\n");
|
|
36527
37091
|
}
|
|
36528
37092
|
function git(root2, args2) {
|
|
36529
|
-
return new Promise((
|
|
37093
|
+
return new Promise((resolve21) => {
|
|
36530
37094
|
try {
|
|
36531
37095
|
(0, import_node_child_process10.execFile)(
|
|
36532
37096
|
"git",
|
|
36533
37097
|
args2,
|
|
36534
37098
|
{ cwd: root2, timeout: GIT_TIMEOUT_MS, maxBuffer: 256 * 1024 },
|
|
36535
|
-
(err2, stdout) =>
|
|
37099
|
+
(err2, stdout) => resolve21(err2 ? void 0 : stdout.toString())
|
|
36536
37100
|
);
|
|
36537
37101
|
} catch {
|
|
36538
|
-
|
|
37102
|
+
resolve21(void 0);
|
|
36539
37103
|
}
|
|
36540
37104
|
});
|
|
36541
37105
|
}
|
|
@@ -36726,13 +37290,13 @@ function streamErrorType(e) {
|
|
|
36726
37290
|
return type && TRANSIENT_STREAM_ERRORS.has(type) ? type : void 0;
|
|
36727
37291
|
}
|
|
36728
37292
|
function sleepFor(ms, signal) {
|
|
36729
|
-
return new Promise((
|
|
36730
|
-
if (signal?.aborted) return
|
|
37293
|
+
return new Promise((resolve21) => {
|
|
37294
|
+
if (signal?.aborted) return resolve21();
|
|
36731
37295
|
const timer = setTimeout(done2, ms);
|
|
36732
37296
|
function done2() {
|
|
36733
37297
|
clearTimeout(timer);
|
|
36734
37298
|
signal?.removeEventListener("abort", done2);
|
|
36735
|
-
|
|
37299
|
+
resolve21();
|
|
36736
37300
|
}
|
|
36737
37301
|
signal?.addEventListener("abort", done2, { once: true });
|
|
36738
37302
|
});
|
|
@@ -37687,8 +38251,9 @@ async function runAgentTaskOnce(provider, userText, mode, priorHistory, onEvent2
|
|
|
37687
38251
|
log2(`agents: could not read the definitions -- ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
37688
38252
|
}
|
|
37689
38253
|
}
|
|
37690
|
-
const
|
|
37691
|
-
|
|
38254
|
+
const spawnable = guidance?.subagent ? guidance.subagent.spawnable : guidance?.spawnable;
|
|
38255
|
+
const agentDefs = allAgentDefs.filter((a) => !planGate || isReadOnlyAgent(a)).filter((a) => !spawnable || spawnable.includes(a.name));
|
|
38256
|
+
if ((planGate || spawnable) && agentDefs.length === 0) canSpawn = false;
|
|
37692
38257
|
const everyTool = allTools.filter((t2) => canSpawn || t2.name !== "agent" && t2.name !== "send_message").map((t2) => t2.name === "agent" ? { ...t2, description: agentToolDescription(agentDefs, describeAgents) } : t2);
|
|
37693
38258
|
const filtered = guidance?.subagent ? guidance.subagent.toolFilter ? guidance.subagent.toolFilter(everyTool) : subagentTools(guidance.subagent.kind ?? "build", everyTool) : guidance?.toolFilter ? guidance.toolFilter(everyTool) : everyTool;
|
|
37694
38259
|
const extraTools = (guidance?.subagent?.extra?.tools ?? []).filter((t2) => !filtered.some((f) => f.name === t2.name) && !disallowed(t2.name, guidance?.subagent?.disallowed ?? []));
|
|
@@ -37779,6 +38344,7 @@ ${guidance.subagent.role}` : systemPrompt;
|
|
|
37779
38344
|
root: runRootPath(),
|
|
37780
38345
|
signal,
|
|
37781
38346
|
callerTools: tools.map((t2) => t2.name),
|
|
38347
|
+
...spawnable ? { spawnable } : {},
|
|
37782
38348
|
canSpawn,
|
|
37783
38349
|
approval: callerApproval,
|
|
37784
38350
|
byok: guidance?.byok === true,
|
|
@@ -38794,7 +39360,7 @@ var USAGE = `Usage: astracode-agent ["<first request>"] a conversation in t
|
|
|
38794
39360
|
astracode-agent status
|
|
38795
39361
|
astracode-agent update
|
|
38796
39362
|
astracode-agent review [--base <ref>] [--output-format text|json]
|
|
38797
|
-
astracode-agent acp
|
|
39363
|
+
astracode-agent acp [--agents <json|file>] [--agent <name>] [--allow-agent-mcp]
|
|
38798
39364
|
|
|
38799
39365
|
On its own, opens a conversation with the agent: type requests, approve its
|
|
38800
39366
|
edits and commands as it asks, /clear to start over, Ctrl-D to leave. With -p,
|
|
@@ -38833,6 +39399,11 @@ Options:
|
|
|
38833
39399
|
Delivery is retried briefly and never fails or
|
|
38834
39400
|
slows the run. Used by remote agents in GitHub
|
|
38835
39401
|
Actions (<gateway>/v1/runs/<id>).
|
|
39402
|
+
--allow-agent-mcp Let the project's agent files (.astracode/agents,
|
|
39403
|
+
.claude/agents) start the MCP servers they
|
|
39404
|
+
declare, for this run only. Without it, -p and
|
|
39405
|
+
acp start only those in your own agent files.
|
|
39406
|
+
A conversation asks you instead.
|
|
38836
39407
|
-v, --verbose The agent's own log, on stderr.
|
|
38837
39408
|
-h, --help This text.
|
|
38838
39409
|
--version The CLI version.
|
|
@@ -38915,11 +39486,32 @@ function parseReview(argv, cwd) {
|
|
|
38915
39486
|
}
|
|
38916
39487
|
};
|
|
38917
39488
|
}
|
|
39489
|
+
function parseAcp(argv) {
|
|
39490
|
+
let values;
|
|
39491
|
+
try {
|
|
39492
|
+
({ values } = (0, import_node_util6.parseArgs)({
|
|
39493
|
+
args: argv,
|
|
39494
|
+
allowPositionals: false,
|
|
39495
|
+
strict: true,
|
|
39496
|
+
options: { agents: { type: "string" }, agent: { type: "string" }, "allow-agent-mcp": { type: "boolean" } }
|
|
39497
|
+
}));
|
|
39498
|
+
} catch (err2) {
|
|
39499
|
+
return { kind: "error", message: `acp: ${err2.message}` };
|
|
39500
|
+
}
|
|
39501
|
+
const flags2 = {};
|
|
39502
|
+
if (typeof values.agents === "string") {
|
|
39503
|
+
if (!values.agents.trim()) return { kind: "error", message: "--agents is empty" };
|
|
39504
|
+
flags2.agents = values.agents;
|
|
39505
|
+
}
|
|
39506
|
+
if (typeof values.agent === "string") {
|
|
39507
|
+
if (!values.agent.trim()) return { kind: "error", message: "--agent needs a name" };
|
|
39508
|
+
flags2.agent = values.agent.trim();
|
|
39509
|
+
}
|
|
39510
|
+
return { kind: "acp", ...flags2, ...values["allow-agent-mcp"] === true ? { allowAgentMcp: true } : {} };
|
|
39511
|
+
}
|
|
38918
39512
|
function parseCli(argv, cwd) {
|
|
38919
39513
|
if (argv[0] === "review") return parseReview(argv.slice(1), cwd);
|
|
38920
|
-
if (argv[0] === "acp")
|
|
38921
|
-
return argv.length === 1 ? { kind: "acp" } : { kind: "error", message: `unexpected argument "${argv[1]}" after acp` };
|
|
38922
|
-
}
|
|
39514
|
+
if (argv[0] === "acp") return parseAcp(argv.slice(1));
|
|
38923
39515
|
if (argv[0] === "status") {
|
|
38924
39516
|
return argv.length === 1 ? { kind: "status" } : { kind: "error", message: `unexpected argument "${argv[1]}" after status` };
|
|
38925
39517
|
}
|
|
@@ -38953,7 +39545,8 @@ function parseCli(argv, cwd) {
|
|
|
38953
39545
|
resume: { type: "boolean", short: "r" },
|
|
38954
39546
|
agents: { type: "string" },
|
|
38955
39547
|
agent: { type: "string" },
|
|
38956
|
-
"report-to": { type: "string" }
|
|
39548
|
+
"report-to": { type: "string" },
|
|
39549
|
+
"allow-agent-mcp": { type: "boolean" }
|
|
38957
39550
|
}
|
|
38958
39551
|
}));
|
|
38959
39552
|
} catch (err2) {
|
|
@@ -38972,7 +39565,7 @@ function parseCli(argv, cwd) {
|
|
|
38972
39565
|
flags2.agent = values.agent.trim();
|
|
38973
39566
|
}
|
|
38974
39567
|
if (prompt === void 0) {
|
|
38975
|
-
const oneShotOnly = ["mode", "output-format", "permissions", "max-steps", "report-to"].find(
|
|
39568
|
+
const oneShotOnly = ["mode", "output-format", "permissions", "max-steps", "report-to", "allow-agent-mcp"].find(
|
|
38976
39569
|
(k) => values[k] !== void 0
|
|
38977
39570
|
);
|
|
38978
39571
|
if (oneShotOnly) return { kind: "error", message: `--${oneShotOnly} applies to -p runs` };
|
|
@@ -39026,6 +39619,7 @@ function parseCli(argv, cwd) {
|
|
|
39026
39619
|
cwd: typeof values.cwd === "string" ? values.cwd : cwd,
|
|
39027
39620
|
verbose: values.verbose === true,
|
|
39028
39621
|
...reportTo ? { reportTo } : {},
|
|
39622
|
+
...values["allow-agent-mcp"] === true ? { allowAgentMcp: true } : {},
|
|
39029
39623
|
...flags2
|
|
39030
39624
|
}
|
|
39031
39625
|
};
|
|
@@ -39202,12 +39796,20 @@ function sessionAgent(def, auto) {
|
|
|
39202
39796
|
|
|
39203
39797
|
${def.prompt}`,
|
|
39204
39798
|
toolFilter: sessionToolFilter(def),
|
|
39799
|
+
...def.spawnable ? { spawnable: def.spawnable } : {},
|
|
39205
39800
|
auto: routed,
|
|
39206
39801
|
plan: def.permissionMode === "plan",
|
|
39207
39802
|
...def.maxTurns ? { maxSteps: def.maxTurns } : {},
|
|
39208
39803
|
...plan.note && def.model ? { note: plan.note } : {}
|
|
39209
39804
|
};
|
|
39210
39805
|
}
|
|
39806
|
+
function sessionGuidance(session3, customize) {
|
|
39807
|
+
return {
|
|
39808
|
+
customize: [customize, session3.role].filter(Boolean).join("\n\n"),
|
|
39809
|
+
toolFilter: session3.toolFilter,
|
|
39810
|
+
...session3.spawnable ? { spawnable: session3.spawnable } : {}
|
|
39811
|
+
};
|
|
39812
|
+
}
|
|
39211
39813
|
function pickSessionAgent(agents2, name3) {
|
|
39212
39814
|
const def = findAgent(agents2, name3);
|
|
39213
39815
|
return def ?? `--agent: there is no agent called "${name3}". The agents: ${agents2.map((a) => a.name).join(", ")}.`;
|
|
@@ -39309,10 +39911,10 @@ var FileStore2 = class {
|
|
|
39309
39911
|
}
|
|
39310
39912
|
};
|
|
39311
39913
|
function security(args2) {
|
|
39312
|
-
return new Promise((
|
|
39914
|
+
return new Promise((resolve21) => {
|
|
39313
39915
|
(0, import_node_child_process12.execFile)("/usr/bin/security", args2, (err2, stdout) => {
|
|
39314
39916
|
const code = err2 ? typeof err2.code === "number" ? err2.code : 1 : 0;
|
|
39315
|
-
|
|
39917
|
+
resolve21({ code, stdout: String(stdout) });
|
|
39316
39918
|
});
|
|
39317
39919
|
});
|
|
39318
39920
|
}
|
|
@@ -39327,14 +39929,14 @@ var KeychainStore = class {
|
|
|
39327
39929
|
if (!/^[A-Za-z0-9._~+/=-]+$/.test(token)) {
|
|
39328
39930
|
throw new Error("the gateway returned a token this CLI cannot store safely");
|
|
39329
39931
|
}
|
|
39330
|
-
await new Promise((
|
|
39932
|
+
await new Promise((resolve21, reject) => {
|
|
39331
39933
|
const child = (0, import_node_child_process12.spawn)("/usr/bin/security", ["-i"], { stdio: ["pipe", "ignore", "pipe"] });
|
|
39332
39934
|
let stderr = "";
|
|
39333
39935
|
child.stderr.on("data", (c) => stderr += c);
|
|
39334
39936
|
child.on("error", reject);
|
|
39335
39937
|
child.on(
|
|
39336
39938
|
"close",
|
|
39337
|
-
(code) => code === 0 && !stderr.trim() ?
|
|
39939
|
+
(code) => code === 0 && !stderr.trim() ? resolve21() : reject(new Error(`could not save to the Keychain: ${stderr.trim() || `exit ${code}`}`))
|
|
39338
39940
|
);
|
|
39339
39941
|
child.stdin.end(`add-generic-password -U -s "${SERVICE}" -a ${ACCOUNT} -l "${SERVICE}" -w ${token}
|
|
39340
39942
|
`);
|
|
@@ -39378,7 +39980,7 @@ async function awaitAgents(owner, signal) {
|
|
|
39378
39980
|
if (!live.length) return;
|
|
39379
39981
|
await Promise.race([
|
|
39380
39982
|
Promise.all(live.map((t2) => whenAgentDone(t2.id))),
|
|
39381
|
-
new Promise((
|
|
39983
|
+
new Promise((resolve21) => signal?.addEventListener("abort", () => resolve21(), { once: true }))
|
|
39382
39984
|
]);
|
|
39383
39985
|
await new Promise((r) => setTimeout(r, 10));
|
|
39384
39986
|
}
|
|
@@ -40586,10 +41188,10 @@ function mergeDefs(...defs) {
|
|
|
40586
41188
|
function cloneDef(schema) {
|
|
40587
41189
|
return mergeDefs(schema._zod.def);
|
|
40588
41190
|
}
|
|
40589
|
-
function getElementAtPath(obj,
|
|
40590
|
-
if (!
|
|
41191
|
+
function getElementAtPath(obj, path54) {
|
|
41192
|
+
if (!path54)
|
|
40591
41193
|
return obj;
|
|
40592
|
-
return
|
|
41194
|
+
return path54.reduce((acc, key) => acc?.[key], obj);
|
|
40593
41195
|
}
|
|
40594
41196
|
function promiseAllObject(promisesObj) {
|
|
40595
41197
|
const keys = Object.keys(promisesObj);
|
|
@@ -40998,11 +41600,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
40998
41600
|
}
|
|
40999
41601
|
return false;
|
|
41000
41602
|
}
|
|
41001
|
-
function prefixIssues(
|
|
41603
|
+
function prefixIssues(path54, issues) {
|
|
41002
41604
|
return issues.map((iss) => {
|
|
41003
41605
|
var _a4;
|
|
41004
41606
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
41005
|
-
iss.path.unshift(
|
|
41607
|
+
iss.path.unshift(path54);
|
|
41006
41608
|
return iss;
|
|
41007
41609
|
});
|
|
41008
41610
|
}
|
|
@@ -41149,16 +41751,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
41149
41751
|
}
|
|
41150
41752
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
41151
41753
|
const fieldErrors = { _errors: [] };
|
|
41152
|
-
const processError = (error52,
|
|
41754
|
+
const processError = (error52, path54 = []) => {
|
|
41153
41755
|
for (const issue2 of error52.issues) {
|
|
41154
41756
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
41155
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
41757
|
+
issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
|
|
41156
41758
|
} else if (issue2.code === "invalid_key") {
|
|
41157
|
-
processError({ issues: issue2.issues }, [...
|
|
41759
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
41158
41760
|
} else if (issue2.code === "invalid_element") {
|
|
41159
|
-
processError({ issues: issue2.issues }, [...
|
|
41761
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
41160
41762
|
} else {
|
|
41161
|
-
const fullpath = [...
|
|
41763
|
+
const fullpath = [...path54, ...issue2.path];
|
|
41162
41764
|
if (fullpath.length === 0) {
|
|
41163
41765
|
fieldErrors._errors.push(mapper(issue2));
|
|
41164
41766
|
} else {
|
|
@@ -41185,17 +41787,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
41185
41787
|
}
|
|
41186
41788
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
41187
41789
|
const result = { errors: [] };
|
|
41188
|
-
const processError = (error52,
|
|
41790
|
+
const processError = (error52, path54 = []) => {
|
|
41189
41791
|
var _a4, _b;
|
|
41190
41792
|
for (const issue2 of error52.issues) {
|
|
41191
41793
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
41192
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
41794
|
+
issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
|
|
41193
41795
|
} else if (issue2.code === "invalid_key") {
|
|
41194
|
-
processError({ issues: issue2.issues }, [...
|
|
41796
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
41195
41797
|
} else if (issue2.code === "invalid_element") {
|
|
41196
|
-
processError({ issues: issue2.issues }, [...
|
|
41798
|
+
processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
|
|
41197
41799
|
} else {
|
|
41198
|
-
const fullpath = [...
|
|
41800
|
+
const fullpath = [...path54, ...issue2.path];
|
|
41199
41801
|
if (fullpath.length === 0) {
|
|
41200
41802
|
result.errors.push(mapper(issue2));
|
|
41201
41803
|
continue;
|
|
@@ -41227,8 +41829,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
41227
41829
|
}
|
|
41228
41830
|
function toDotPath(_path) {
|
|
41229
41831
|
const segs = [];
|
|
41230
|
-
const
|
|
41231
|
-
for (const seg of
|
|
41832
|
+
const path54 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
41833
|
+
for (const seg of path54) {
|
|
41232
41834
|
if (typeof seg === "number")
|
|
41233
41835
|
segs.push(`[${seg}]`);
|
|
41234
41836
|
else if (typeof seg === "symbol")
|
|
@@ -54001,13 +54603,13 @@ function resolveRef(ref, ctx) {
|
|
|
54001
54603
|
if (!ref.startsWith("#")) {
|
|
54002
54604
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
54003
54605
|
}
|
|
54004
|
-
const
|
|
54005
|
-
if (
|
|
54606
|
+
const path54 = ref.slice(1).split("/").filter(Boolean);
|
|
54607
|
+
if (path54.length === 0) {
|
|
54006
54608
|
return ctx.rootSchema;
|
|
54007
54609
|
}
|
|
54008
54610
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
54009
|
-
if (
|
|
54010
|
-
const key =
|
|
54611
|
+
if (path54[0] === defsKey) {
|
|
54612
|
+
const key = path54[1];
|
|
54011
54613
|
if (!key || !ctx.defs[key]) {
|
|
54012
54614
|
throw new Error(`Reference not found: ${ref}`);
|
|
54013
54615
|
}
|
|
@@ -56544,11 +57146,11 @@ var Connection = class {
|
|
|
56544
57146
|
const id = this.nextRequestId++;
|
|
56545
57147
|
let cancel = () => {
|
|
56546
57148
|
};
|
|
56547
|
-
const response = new Promise((
|
|
57149
|
+
const response = new Promise((resolve21, reject) => {
|
|
56548
57150
|
const pendingResponse = {
|
|
56549
57151
|
resolve: (value) => {
|
|
56550
57152
|
try {
|
|
56551
|
-
|
|
57153
|
+
resolve21(mapResponse ? mapResponse(value) : value);
|
|
56552
57154
|
} catch (error51) {
|
|
56553
57155
|
reject(error51);
|
|
56554
57156
|
}
|
|
@@ -56605,8 +57207,8 @@ var Connection = class {
|
|
|
56605
57207
|
this.stream = stream;
|
|
56606
57208
|
this.staticHandlers = handlers;
|
|
56607
57209
|
this.allowBatches = options?.allowBatches ?? true;
|
|
56608
|
-
this.closedPromise = new Promise((
|
|
56609
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
57210
|
+
this.closedPromise = new Promise((resolve21) => {
|
|
57211
|
+
this.abortController.signal.addEventListener("abort", () => resolve21());
|
|
56610
57212
|
});
|
|
56611
57213
|
void this.receive();
|
|
56612
57214
|
}
|
|
@@ -57502,8 +58104,8 @@ var AsyncQueue2 = class {
|
|
|
57502
58104
|
if (this.failed) {
|
|
57503
58105
|
return Promise.reject(this.failure);
|
|
57504
58106
|
}
|
|
57505
|
-
return new Promise((
|
|
57506
|
-
this.waiters.push({ resolve:
|
|
58107
|
+
return new Promise((resolve21, reject) => {
|
|
58108
|
+
this.waiters.push({ resolve: resolve21, reject });
|
|
57507
58109
|
});
|
|
57508
58110
|
}
|
|
57509
58111
|
};
|
|
@@ -58108,7 +58710,7 @@ var legacyClientNotificationMethods = /* @__PURE__ */ new Set([
|
|
|
58108
58710
|
]);
|
|
58109
58711
|
|
|
58110
58712
|
// ../editor/src/cli/acp.ts
|
|
58111
|
-
var
|
|
58713
|
+
var path45 = __toESM(require("node:path"));
|
|
58112
58714
|
var import_node_stream2 = require("node:stream");
|
|
58113
58715
|
|
|
58114
58716
|
// ../editor/src/cli/auth.ts
|
|
@@ -58503,17 +59105,182 @@ function toolLabel(name3, input) {
|
|
|
58503
59105
|
}
|
|
58504
59106
|
}
|
|
58505
59107
|
|
|
59108
|
+
// ../editor/src/cli/agentMcp.ts
|
|
59109
|
+
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
59110
|
+
var fs40 = __toESM(require("node:fs"));
|
|
59111
|
+
var path44 = __toESM(require("node:path"));
|
|
59112
|
+
|
|
59113
|
+
// ../editor/src/agent/tasks/agentMcp.ts
|
|
59114
|
+
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
59115
|
+
var path43 = __toESM(require("path"));
|
|
59116
|
+
function projectOf(def) {
|
|
59117
|
+
return def.source === "project" && def.path ? path43.dirname(path43.dirname(path43.dirname(def.path))) : void 0;
|
|
59118
|
+
}
|
|
59119
|
+
async function allowedInlineServers(def, deps) {
|
|
59120
|
+
const { servers, problems } = inlineServerSpecs(def, projectOf(def));
|
|
59121
|
+
for (const p of problems) deps.log(`agents: ${p}`);
|
|
59122
|
+
const refused = [];
|
|
59123
|
+
if (servers.length === 0) return { allowed: [], refused };
|
|
59124
|
+
if (def.source === "user") return { allowed: servers, refused };
|
|
59125
|
+
if (def.source !== "project") {
|
|
59126
|
+
for (const s of servers) refused.push(`${s.name} (not from an agent file)`);
|
|
59127
|
+
return { allowed: [], refused };
|
|
59128
|
+
}
|
|
59129
|
+
if (!deps.trusted()) {
|
|
59130
|
+
for (const s of servers) refused.push(`${s.name} (this workspace is not trusted)`);
|
|
59131
|
+
return { allowed: [], refused };
|
|
59132
|
+
}
|
|
59133
|
+
const allowed = [];
|
|
59134
|
+
for (const server of servers) {
|
|
59135
|
+
if (isApproved(deps.store, server.offer)) {
|
|
59136
|
+
allowed.push(server);
|
|
59137
|
+
continue;
|
|
59138
|
+
}
|
|
59139
|
+
let yes = false;
|
|
59140
|
+
try {
|
|
59141
|
+
yes = await deps.ask(def, server, describe(server.offer));
|
|
59142
|
+
} catch {
|
|
59143
|
+
yes = false;
|
|
59144
|
+
}
|
|
59145
|
+
if (yes) {
|
|
59146
|
+
await approve(deps.store, server.offer);
|
|
59147
|
+
deps.log(`agents: approved inline MCP server "${server.name}" of agent "${def.name}" (${def.path})`);
|
|
59148
|
+
allowed.push(server);
|
|
59149
|
+
} else {
|
|
59150
|
+
refused.push(`${server.name} (not approved)`);
|
|
59151
|
+
}
|
|
59152
|
+
}
|
|
59153
|
+
return { allowed, refused };
|
|
59154
|
+
}
|
|
59155
|
+
function inlineMcpProvider(deps) {
|
|
59156
|
+
return {
|
|
59157
|
+
async start(def, agentId) {
|
|
59158
|
+
if (!def.inlineMcpServers || Object.keys(def.inlineMcpServers).length === 0) return void 0;
|
|
59159
|
+
if (deps.enabled && !deps.enabled()) {
|
|
59160
|
+
deps.log(`agents: ${agentId} (${def.name}): MCP is switched off, so its inline servers do not start`);
|
|
59161
|
+
return void 0;
|
|
59162
|
+
}
|
|
59163
|
+
const { allowed, refused } = await allowedInlineServers(def, deps);
|
|
59164
|
+
for (const r of refused) deps.log(`agents: ${agentId} (${def.name}): inline MCP server ${r}; not started`);
|
|
59165
|
+
if (allowed.length === 0) return void 0;
|
|
59166
|
+
const log2 = (line) => deps.log(`agents: ${agentId} (${def.name}): ${line}`);
|
|
59167
|
+
const registry4 = deps.registry ? deps.registry(log2, deps.auth ?? null, deps.review) : new McpRegistry(log2, deps.auth ?? null, deps.review);
|
|
59168
|
+
await registry4.start(allowed.map((s) => s.spec));
|
|
59169
|
+
const tools = registry4.toolDefs();
|
|
59170
|
+
log2(`started ${allowed.length} inline MCP server(s): ${registry4.summary().map((x) => `${x.id} (${x.failed ? `failed: ${x.failed}` : `${x.tools} tools`})`).join(", ")}`);
|
|
59171
|
+
return {
|
|
59172
|
+
tools,
|
|
59173
|
+
call: (name3, input, signal) => registry4.call(name3, input, signal),
|
|
59174
|
+
readOnly: (name3) => registry4.readOnly(name3),
|
|
59175
|
+
label: (name3) => registry4.serverFor(name3) ?? name3,
|
|
59176
|
+
stop: () => registry4.stop()
|
|
59177
|
+
};
|
|
59178
|
+
}
|
|
59179
|
+
};
|
|
59180
|
+
}
|
|
59181
|
+
|
|
59182
|
+
// ../editor/src/cli/agentMcp.ts
|
|
59183
|
+
function fileApprovalStore(file2 = path44.join(configDir(), "agent-mcp.json")) {
|
|
59184
|
+
const read = () => {
|
|
59185
|
+
try {
|
|
59186
|
+
const raw = JSON.parse(fs40.readFileSync(file2, "utf8"));
|
|
59187
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
59188
|
+
} catch {
|
|
59189
|
+
return {};
|
|
59190
|
+
}
|
|
59191
|
+
};
|
|
59192
|
+
return {
|
|
59193
|
+
get(key, fallback) {
|
|
59194
|
+
const all = read();
|
|
59195
|
+
return key in all ? all[key] : fallback;
|
|
59196
|
+
},
|
|
59197
|
+
async update(key, value) {
|
|
59198
|
+
const all = read();
|
|
59199
|
+
all[key] = value;
|
|
59200
|
+
fs40.mkdirSync(path44.dirname(file2), { recursive: true, mode: 448 });
|
|
59201
|
+
const tmp = `${file2}.${process.pid}.tmp`;
|
|
59202
|
+
fs40.writeFileSync(tmp, JSON.stringify(all, null, 2) + "\n", { mode: 384 });
|
|
59203
|
+
fs40.renameSync(tmp, file2);
|
|
59204
|
+
}
|
|
59205
|
+
};
|
|
59206
|
+
}
|
|
59207
|
+
function readOnlyOverlay(base) {
|
|
59208
|
+
const mine = /* @__PURE__ */ new Map();
|
|
59209
|
+
return {
|
|
59210
|
+
get: (key, fallback) => mine.has(key) ? mine.get(key) : base.get(key, fallback),
|
|
59211
|
+
update: async (key, value) => {
|
|
59212
|
+
mine.set(key, value);
|
|
59213
|
+
}
|
|
59214
|
+
};
|
|
59215
|
+
}
|
|
59216
|
+
function folderTrusted(cwd) {
|
|
59217
|
+
const list2 = userSettings().trustedFolders;
|
|
59218
|
+
return Array.isArray(list2) && list2.includes(path44.resolve(cwd));
|
|
59219
|
+
}
|
|
59220
|
+
function installAgentMcp(opts) {
|
|
59221
|
+
const file2 = opts.store ?? fileApprovalStore();
|
|
59222
|
+
const store2 = opts.allowedByFlag ? readOnlyOverlay(file2) : file2;
|
|
59223
|
+
const ask = opts.allowedByFlag ? async (agent2, server, what) => {
|
|
59224
|
+
opts.log(`starting inline MCP server "${server.name}" of agent "${agent2.name}" (${agent2.path ?? ""}) under --allow-agent-mcp: ${what}`);
|
|
59225
|
+
return true;
|
|
59226
|
+
} : opts.ask ?? (async () => false);
|
|
59227
|
+
setAgentMcpProvider(
|
|
59228
|
+
inlineMcpProvider({
|
|
59229
|
+
store: store2,
|
|
59230
|
+
review: { store: store2, ask: opts.askToolChange ?? (async () => false) },
|
|
59231
|
+
trusted: () => opts.allowedByFlag === true || opts.trusted(),
|
|
59232
|
+
enabled: () => mcpEnabled(),
|
|
59233
|
+
auth: null,
|
|
59234
|
+
log: opts.log,
|
|
59235
|
+
ask
|
|
59236
|
+
})
|
|
59237
|
+
);
|
|
59238
|
+
}
|
|
59239
|
+
var ALLOW_HINT = "a project's agent files start their own MCP servers only when you pass --allow-agent-mcp";
|
|
59240
|
+
function agentMcpLog(log2) {
|
|
59241
|
+
let hinted = false;
|
|
59242
|
+
return (line) => {
|
|
59243
|
+
if (!/not started|under --allow-agent-mcp/.test(line)) return log2(line);
|
|
59244
|
+
process.stderr.write(`astracode-agent: ${line}
|
|
59245
|
+
`);
|
|
59246
|
+
if (!hinted && /not trusted|not approved/.test(line)) {
|
|
59247
|
+
hinted = true;
|
|
59248
|
+
process.stderr.write(`astracode-agent: ${ALLOW_HINT}
|
|
59249
|
+
`);
|
|
59250
|
+
}
|
|
59251
|
+
};
|
|
59252
|
+
}
|
|
59253
|
+
|
|
58506
59254
|
// ../editor/src/cli/acp.ts
|
|
58507
59255
|
var TERMINAL_AUTH = "astracode-login-terminal";
|
|
58508
59256
|
var BROWSER_AUTH = "astracode-login";
|
|
58509
59257
|
var MAX_RESULT_CHARS = 4e3;
|
|
59258
|
+
var AGENT_OPTION = "agent";
|
|
59259
|
+
var DEFAULT_AGENT = "(default)";
|
|
59260
|
+
function agentConfigOption(agents2, current4) {
|
|
59261
|
+
return {
|
|
59262
|
+
id: AGENT_OPTION,
|
|
59263
|
+
name: "Agent",
|
|
59264
|
+
description: "Run this session as one of your agents: its prompt, its tools and its model tier.",
|
|
59265
|
+
type: "select",
|
|
59266
|
+
currentValue: current4 ?? DEFAULT_AGENT,
|
|
59267
|
+
options: [
|
|
59268
|
+
{ value: DEFAULT_AGENT, name: "AstraCode", description: "The agent with every tool." },
|
|
59269
|
+
...agents2.map((a) => ({
|
|
59270
|
+
value: a.name,
|
|
59271
|
+
name: a.name,
|
|
59272
|
+
description: a.description.replace(/\s+/g, " ").trim().slice(0, 200)
|
|
59273
|
+
}))
|
|
59274
|
+
]
|
|
59275
|
+
};
|
|
59276
|
+
}
|
|
58510
59277
|
function promptText(blocks, cwd) {
|
|
58511
59278
|
const parts2 = [];
|
|
58512
59279
|
for (const b of blocks) {
|
|
58513
59280
|
if (b.type === "text") parts2.push(b.text);
|
|
58514
59281
|
else if (b.type === "resource_link") {
|
|
58515
59282
|
const p = b.uri.startsWith("file://") ? decodeURIComponent(b.uri.slice(7)) : b.uri;
|
|
58516
|
-
parts2.push(`@${
|
|
59283
|
+
parts2.push(`@${path45.isAbsolute(p) ? path45.relative(cwd, p) || p : p}`);
|
|
58517
59284
|
} else if (b.type === "resource" && "text" in b.resource) {
|
|
58518
59285
|
parts2.push(`Contents of ${b.resource.uri}:
|
|
58519
59286
|
\`\`\`
|
|
@@ -58526,10 +59293,16 @@ ${b.resource.text}
|
|
|
58526
59293
|
function status2(output) {
|
|
58527
59294
|
return /^(ERROR|DENIED)\b/.test(output) ? "failed" : "completed";
|
|
58528
59295
|
}
|
|
58529
|
-
async function serveAcp(version3) {
|
|
59296
|
+
async function serveAcp(version3, options = {}) {
|
|
58530
59297
|
console.log = (...args2) => console.error(...args2);
|
|
58531
59298
|
const sessions = /* @__PURE__ */ new Map();
|
|
58532
59299
|
openTasks();
|
|
59300
|
+
installAgentMcp({
|
|
59301
|
+
trusted: () => false,
|
|
59302
|
+
allowedByFlag: options.allowAgentMcp === true,
|
|
59303
|
+
log: agentMcpLog(() => {
|
|
59304
|
+
})
|
|
59305
|
+
});
|
|
58533
59306
|
let queue = Promise.resolve();
|
|
58534
59307
|
let terminalAuth = false;
|
|
58535
59308
|
const app = agent({ name: "astracode-agent" }).onRequest("initialize", async (ctx) => {
|
|
@@ -58576,6 +59349,13 @@ async function serveAcp(version3) {
|
|
|
58576
59349
|
const opened = await openHost({ cwd, approvals: "reads", log: () => {
|
|
58577
59350
|
} });
|
|
58578
59351
|
if (!opened.ok) throw RequestError.invalidParams(void 0, opened.message);
|
|
59352
|
+
const agents2 = agentCatalogue();
|
|
59353
|
+
let agent2;
|
|
59354
|
+
if (options.agent) {
|
|
59355
|
+
const pick2 = pickSessionAgent(agents2, options.agent);
|
|
59356
|
+
if (typeof pick2 === "string") throw RequestError.invalidParams(void 0, pick2);
|
|
59357
|
+
agent2 = sessionAgent(pick2, opened.host.auto);
|
|
59358
|
+
}
|
|
58579
59359
|
const id = crypto.randomUUID();
|
|
58580
59360
|
sessions.set(id, {
|
|
58581
59361
|
id,
|
|
@@ -58584,9 +59364,31 @@ async function serveAcp(version3) {
|
|
|
58584
59364
|
history: [],
|
|
58585
59365
|
seenPaths: /* @__PURE__ */ new Set(),
|
|
58586
59366
|
alwaysAllowed: /* @__PURE__ */ new Set(),
|
|
58587
|
-
toolNames: /* @__PURE__ */ new Map()
|
|
59367
|
+
toolNames: /* @__PURE__ */ new Map(),
|
|
59368
|
+
...agent2 ? { agent: agent2 } : {}
|
|
58588
59369
|
});
|
|
58589
|
-
return { sessionId: id };
|
|
59370
|
+
return { sessionId: id, configOptions: [agentConfigOption(agents2, agent2?.def.name)] };
|
|
59371
|
+
}).onRequest("session/set_config_option", async (ctx) => {
|
|
59372
|
+
const session3 = sessions.get(ctx.params.sessionId);
|
|
59373
|
+
if (!session3) throw RequestError.invalidParams(void 0, `no session ${ctx.params.sessionId}`);
|
|
59374
|
+
if (ctx.params.configId !== AGENT_OPTION) {
|
|
59375
|
+
throw RequestError.invalidParams(void 0, `unknown config option ${ctx.params.configId}`);
|
|
59376
|
+
}
|
|
59377
|
+
const value = "type" in ctx.params && ctx.params.type === "boolean" ? void 0 : ctx.params.value;
|
|
59378
|
+
if (typeof value !== "string") throw RequestError.invalidParams(void 0, "agent takes an agent name");
|
|
59379
|
+
const change = queue.then(() => {
|
|
59380
|
+
configureShim(session3.host.gateway, { cwd: session3.cwd, approvals: "reads" });
|
|
59381
|
+
const agents2 = agentCatalogue();
|
|
59382
|
+
if (value === DEFAULT_AGENT) session3.agent = void 0;
|
|
59383
|
+
else {
|
|
59384
|
+
const pick2 = pickSessionAgent(agents2, value);
|
|
59385
|
+
if (typeof pick2 === "string") throw RequestError.invalidParams(void 0, pick2);
|
|
59386
|
+
session3.agent = sessionAgent(pick2, session3.host.auto);
|
|
59387
|
+
}
|
|
59388
|
+
return { configOptions: [agentConfigOption(agents2, session3.agent?.def.name)] };
|
|
59389
|
+
});
|
|
59390
|
+
queue = change.catch(() => void 0);
|
|
59391
|
+
return change;
|
|
58590
59392
|
}).onNotification("session/cancel", async (ctx) => {
|
|
58591
59393
|
sessions.get(ctx.params.sessionId)?.controller?.abort();
|
|
58592
59394
|
}).onRequest("session/prompt", async (ctx) => {
|
|
@@ -58648,7 +59450,7 @@ ${chunk2}` : chunk2;
|
|
|
58648
59450
|
kind: toolKind(event.call.name),
|
|
58649
59451
|
status: "in_progress",
|
|
58650
59452
|
rawInput: input,
|
|
58651
|
-
...target ? { locations: [{ path:
|
|
59453
|
+
...target ? { locations: [{ path: path45.resolve(session3.cwd, target) }] } : {}
|
|
58652
59454
|
});
|
|
58653
59455
|
break;
|
|
58654
59456
|
}
|
|
@@ -58661,7 +59463,7 @@ ${chunk2}` : chunk2;
|
|
|
58661
59463
|
content: change ? [
|
|
58662
59464
|
{
|
|
58663
59465
|
type: "diff",
|
|
58664
|
-
path:
|
|
59466
|
+
path: path45.resolve(session3.cwd, change.path),
|
|
58665
59467
|
oldText: change.existed ? change.before : null,
|
|
58666
59468
|
newText: change.after
|
|
58667
59469
|
}
|
|
@@ -58697,7 +59499,7 @@ ${chunk2}` : chunk2;
|
|
|
58697
59499
|
toolCall: {
|
|
58698
59500
|
toolCallId: req.toolCallId,
|
|
58699
59501
|
title: (req.agentLabel ? `${req.agentLabel}: ` : "") + (req.warning ? `${req.description} -- ${req.warning}` : req.description),
|
|
58700
|
-
...req.path ? { locations: [{ path:
|
|
59502
|
+
...req.path ? { locations: [{ path: path45.resolve(session3.cwd, req.path) }] } : {}
|
|
58701
59503
|
},
|
|
58702
59504
|
options: [
|
|
58703
59505
|
{ optionId: "allow", name: "Allow", kind: "allow_once" },
|
|
@@ -58712,6 +59514,7 @@ ${chunk2}` : chunk2;
|
|
|
58712
59514
|
configureShim(session3.host.gateway, { cwd: session3.cwd, approvals: "reads" });
|
|
58713
59515
|
const controller = new AbortController();
|
|
58714
59516
|
session3.controller = controller;
|
|
59517
|
+
const agent2 = session3.agent;
|
|
58715
59518
|
const runOnce = (input) => (
|
|
58716
59519
|
// Everything the run starts is this session's, so its notes are told to this session.
|
|
58717
59520
|
withRunOwner(
|
|
@@ -58719,7 +59522,7 @@ ${chunk2}` : chunk2;
|
|
|
58719
59522
|
() => runAgentTask(
|
|
58720
59523
|
session3.host.provider(),
|
|
58721
59524
|
input,
|
|
58722
|
-
"agent",
|
|
59525
|
+
agent2?.plan ? "plan" : "agent",
|
|
58723
59526
|
session3.history,
|
|
58724
59527
|
onEvent2,
|
|
58725
59528
|
requestApproval,
|
|
@@ -58728,12 +59531,13 @@ ${chunk2}` : chunk2;
|
|
|
58728
59531
|
controller.signal,
|
|
58729
59532
|
() => {
|
|
58730
59533
|
},
|
|
58731
|
-
150,
|
|
58732
|
-
session3.host.auto,
|
|
59534
|
+
agent2?.maxSteps ?? 150,
|
|
59535
|
+
agent2 ? agent2.auto : session3.host.auto,
|
|
58733
59536
|
{
|
|
58734
59537
|
principles: BUNDLED_PRINCIPLES,
|
|
58735
59538
|
projectRules: session3.host.projectRules,
|
|
58736
|
-
seenPaths: session3.seenPaths
|
|
59539
|
+
seenPaths: session3.seenPaths,
|
|
59540
|
+
...agent2 ? sessionGuidance(agent2) : {}
|
|
58737
59541
|
}
|
|
58738
59542
|
)
|
|
58739
59543
|
)
|
|
@@ -58776,7 +59580,7 @@ ${chunk2}` : chunk2;
|
|
|
58776
59580
|
import_node_stream2.Readable.toWeb(process.stdin)
|
|
58777
59581
|
);
|
|
58778
59582
|
await app.connect(stream);
|
|
58779
|
-
await new Promise((
|
|
59583
|
+
await new Promise((resolve21) => process.stdin.once("close", resolve21));
|
|
58780
59584
|
return 0;
|
|
58781
59585
|
}
|
|
58782
59586
|
|
|
@@ -58827,7 +59631,7 @@ function isNewer(a, b) {
|
|
|
58827
59631
|
// ../editor/src/cli/interactive.ts
|
|
58828
59632
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
58829
59633
|
var import_node_crypto12 = require("node:crypto");
|
|
58830
|
-
var
|
|
59634
|
+
var path50 = __toESM(require("node:path"));
|
|
58831
59635
|
var readline4 = __toESM(require("node:readline"));
|
|
58832
59636
|
|
|
58833
59637
|
// ../editor/src/cli/tui/onboard.ts
|
|
@@ -59312,8 +60116,8 @@ init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
|
59312
60116
|
|
|
59313
60117
|
// ../editor/src/cli/tui/app.ts
|
|
59314
60118
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
59315
|
-
var
|
|
59316
|
-
var
|
|
60119
|
+
var fs43 = __toESM(require("node:fs"));
|
|
60120
|
+
var path48 = __toESM(require("node:path"));
|
|
59317
60121
|
var readline2 = __toESM(require("node:readline"));
|
|
59318
60122
|
|
|
59319
60123
|
// ../editor/src/cli/tui/agents.ts
|
|
@@ -59863,25 +60667,25 @@ function wordStart(s, pos) {
|
|
|
59863
60667
|
// ../editor/src/cli/tui/store.ts
|
|
59864
60668
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
59865
60669
|
var import_node_crypto11 = require("node:crypto");
|
|
59866
|
-
var
|
|
59867
|
-
var
|
|
60670
|
+
var fs41 = __toESM(require("node:fs"));
|
|
60671
|
+
var path46 = __toESM(require("node:path"));
|
|
59868
60672
|
function projectKey2(cwd) {
|
|
59869
|
-
return (0, import_node_crypto11.createHash)("sha256").update(
|
|
60673
|
+
return (0, import_node_crypto11.createHash)("sha256").update(path46.resolve(cwd)).digest("hex").slice(0, 16);
|
|
59870
60674
|
}
|
|
59871
60675
|
function writePrivate(file2, body2) {
|
|
59872
|
-
|
|
60676
|
+
fs41.mkdirSync(path46.dirname(file2), { recursive: true, mode: 448 });
|
|
59873
60677
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
59874
|
-
|
|
59875
|
-
|
|
60678
|
+
fs41.writeFileSync(tmp, body2, { mode: 384 });
|
|
60679
|
+
fs41.renameSync(tmp, file2);
|
|
59876
60680
|
}
|
|
59877
60681
|
var MAX_HISTORY = 500;
|
|
59878
60682
|
var PromptHistory = class {
|
|
59879
60683
|
file;
|
|
59880
60684
|
entries = [];
|
|
59881
60685
|
constructor(cwd) {
|
|
59882
|
-
this.file =
|
|
60686
|
+
this.file = path46.join(configDir(), "history", `${projectKey2(cwd)}.json`);
|
|
59883
60687
|
try {
|
|
59884
|
-
const raw = JSON.parse(
|
|
60688
|
+
const raw = JSON.parse(fs41.readFileSync(this.file, "utf8"));
|
|
59885
60689
|
if (Array.isArray(raw)) this.entries = raw.filter((e) => typeof e === "string");
|
|
59886
60690
|
} catch {
|
|
59887
60691
|
}
|
|
@@ -59907,13 +60711,13 @@ var MAX_TURNS = 50;
|
|
|
59907
60711
|
var SessionStore = class {
|
|
59908
60712
|
dir;
|
|
59909
60713
|
constructor(cwd) {
|
|
59910
|
-
this.dir =
|
|
60714
|
+
this.dir = path46.join(configDir(), "sessions", projectKey2(cwd));
|
|
59911
60715
|
}
|
|
59912
60716
|
fresh(cwd) {
|
|
59913
60717
|
const now = Date.now();
|
|
59914
60718
|
return {
|
|
59915
60719
|
id: (0, import_node_crypto11.randomUUID)(),
|
|
59916
|
-
cwd:
|
|
60720
|
+
cwd: path46.resolve(cwd),
|
|
59917
60721
|
title: "New conversation",
|
|
59918
60722
|
createdAt: now,
|
|
59919
60723
|
updatedAt: now,
|
|
@@ -59930,7 +60734,7 @@ var SessionStore = class {
|
|
|
59930
60734
|
}
|
|
59931
60735
|
if (session3.turns.length > MAX_TURNS) session3.turns.splice(0, session3.turns.length - MAX_TURNS);
|
|
59932
60736
|
try {
|
|
59933
|
-
writePrivate(
|
|
60737
|
+
writePrivate(path46.join(this.dir, `${session3.id}.json`), JSON.stringify(session3));
|
|
59934
60738
|
} catch {
|
|
59935
60739
|
}
|
|
59936
60740
|
}
|
|
@@ -59938,14 +60742,14 @@ var SessionStore = class {
|
|
|
59938
60742
|
list() {
|
|
59939
60743
|
let names = [];
|
|
59940
60744
|
try {
|
|
59941
|
-
names =
|
|
60745
|
+
names = fs41.readdirSync(this.dir).filter((n) => n.endsWith(".json"));
|
|
59942
60746
|
} catch {
|
|
59943
60747
|
return [];
|
|
59944
60748
|
}
|
|
59945
60749
|
const out2 = [];
|
|
59946
60750
|
for (const n of names) {
|
|
59947
60751
|
try {
|
|
59948
|
-
const s = JSON.parse(
|
|
60752
|
+
const s = JSON.parse(fs41.readFileSync(path46.join(this.dir, n), "utf8"));
|
|
59949
60753
|
if (s && s.id && Array.isArray(s.history)) out2.push(s);
|
|
59950
60754
|
} catch {
|
|
59951
60755
|
}
|
|
@@ -59961,6 +60765,22 @@ var SessionStore = class {
|
|
|
59961
60765
|
);
|
|
59962
60766
|
}
|
|
59963
60767
|
};
|
|
60768
|
+
function taskListPersistence(store2, current4) {
|
|
60769
|
+
const other = (owner) => store2.list().find((s) => s.id === owner);
|
|
60770
|
+
return {
|
|
60771
|
+
load(owner) {
|
|
60772
|
+
const now = current4();
|
|
60773
|
+
return owner === now.id ? now.taskList : other(owner)?.taskList;
|
|
60774
|
+
},
|
|
60775
|
+
save(owner, tasks2) {
|
|
60776
|
+
const now = current4();
|
|
60777
|
+
const session3 = owner === now.id ? now : other(owner);
|
|
60778
|
+
if (!session3) return;
|
|
60779
|
+
session3.taskList = tasks2;
|
|
60780
|
+
store2.save(session3);
|
|
60781
|
+
}
|
|
60782
|
+
};
|
|
60783
|
+
}
|
|
59964
60784
|
|
|
59965
60785
|
// ../editor/src/cli/tui/events.ts
|
|
59966
60786
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
@@ -60132,9 +60952,9 @@ function toolResult(app, e, turn) {
|
|
|
60132
60952
|
// ../editor/src/cli/tui/commands.ts
|
|
60133
60953
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
60134
60954
|
var import_node_child_process14 = require("node:child_process");
|
|
60135
|
-
var
|
|
60955
|
+
var fs42 = __toESM(require("node:fs"));
|
|
60136
60956
|
var os15 = __toESM(require("node:os"));
|
|
60137
|
-
var
|
|
60957
|
+
var path47 = __toESM(require("node:path"));
|
|
60138
60958
|
|
|
60139
60959
|
// ../editor/src/branchReview.ts
|
|
60140
60960
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
@@ -60259,14 +61079,14 @@ function truncateDiff(diff2, max = MAX_DIFF_CHARS2) {
|
|
|
60259
61079
|
async function shell(app, command2) {
|
|
60260
61080
|
if (!command2) return;
|
|
60261
61081
|
app.print("\n" + yellow("! ") + command2);
|
|
60262
|
-
const output = await new Promise((
|
|
61082
|
+
const output = await new Promise((resolve21) => {
|
|
60263
61083
|
(0, import_node_child_process14.execFile)(
|
|
60264
61084
|
process.env.SHELL || "/bin/sh",
|
|
60265
61085
|
["-c", command2],
|
|
60266
61086
|
{ cwd: app.host.cwd, maxBuffer: 16 * 1024 * 1024, timeout: 12e4 },
|
|
60267
61087
|
(err2, stdout, stderr) => {
|
|
60268
61088
|
const text2 = `${stdout}${stderr}`.trimEnd();
|
|
60269
|
-
|
|
61089
|
+
resolve21(err2 && typeof err2.code === "number" ? `${text2}
|
|
60270
61090
|
(exit ${err2.code})` : text2);
|
|
60271
61091
|
}
|
|
60272
61092
|
);
|
|
@@ -60294,15 +61114,15 @@ async function rememberNote(app, note) {
|
|
|
60294
61114
|
}
|
|
60295
61115
|
function externalEditor(app) {
|
|
60296
61116
|
const editor = process.env.VISUAL || process.env.EDITOR || "vi";
|
|
60297
|
-
const file2 =
|
|
60298
|
-
|
|
61117
|
+
const file2 = path47.join(os15.tmpdir(), `astracode-${process.pid}.md`);
|
|
61118
|
+
fs42.writeFileSync(file2, app.editor.text);
|
|
60299
61119
|
app.screen.suspend();
|
|
60300
61120
|
app.input.setRawMode?.(false);
|
|
60301
61121
|
(0, import_node_child_process14.spawnSync)(editor, [file2], { stdio: "inherit", shell: true });
|
|
60302
61122
|
app.input.setRawMode?.(true);
|
|
60303
61123
|
try {
|
|
60304
|
-
app.editor.set(
|
|
60305
|
-
|
|
61124
|
+
app.editor.set(fs42.readFileSync(file2, "utf8").replace(/\n$/, ""));
|
|
61125
|
+
fs42.rmSync(file2, { force: true });
|
|
60306
61126
|
} catch {
|
|
60307
61127
|
}
|
|
60308
61128
|
app.screen.resume();
|
|
@@ -60312,7 +61132,7 @@ async function pasteImage(app) {
|
|
|
60312
61132
|
app.notice = "Ctrl-V pastes images on macOS; elsewhere, mention the file with @";
|
|
60313
61133
|
return;
|
|
60314
61134
|
}
|
|
60315
|
-
const file2 =
|
|
61135
|
+
const file2 = path47.join(os15.tmpdir(), `astracode-paste-${Date.now()}.png`);
|
|
60316
61136
|
const script = [
|
|
60317
61137
|
`set f to POSIX file ${JSON.stringify(file2)}`,
|
|
60318
61138
|
"set d to (the clipboard as \xABclass PNGf\xBB)",
|
|
@@ -60325,13 +61145,13 @@ async function pasteImage(app) {
|
|
|
60325
61145
|
script.flatMap((l) => ["-e", l]),
|
|
60326
61146
|
{ stdio: "ignore" }
|
|
60327
61147
|
);
|
|
60328
|
-
if (r.status !== 0 || !
|
|
61148
|
+
if (r.status !== 0 || !fs42.existsSync(file2)) {
|
|
60329
61149
|
app.notice = "No image on the clipboard";
|
|
60330
61150
|
app.redraw();
|
|
60331
61151
|
return;
|
|
60332
61152
|
}
|
|
60333
|
-
app.images.push({ mime: "image/png", data:
|
|
60334
|
-
|
|
61153
|
+
app.images.push({ mime: "image/png", data: fs42.readFileSync(file2).toString("base64") });
|
|
61154
|
+
fs42.rmSync(file2, { force: true });
|
|
60335
61155
|
app.editor.insert(`[Image #${app.images.length}] `);
|
|
60336
61156
|
app.redraw();
|
|
60337
61157
|
}
|
|
@@ -60410,11 +61230,11 @@ ${t.bold("Your commands and skills")}
|
|
|
60410
61230
|
return;
|
|
60411
61231
|
}
|
|
60412
61232
|
case "export": {
|
|
60413
|
-
const file2 =
|
|
61233
|
+
const file2 = path47.resolve(
|
|
60414
61234
|
app.host.cwd,
|
|
60415
61235
|
args2 || `astracode-conversation-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.md`
|
|
60416
61236
|
);
|
|
60417
|
-
|
|
61237
|
+
fs42.writeFileSync(file2, stripAnsi2(app.session.transcript.join("\n")) + "\n");
|
|
60418
61238
|
app.block(dim(` Saved to ${file2}`));
|
|
60419
61239
|
return;
|
|
60420
61240
|
}
|
|
@@ -60639,11 +61459,11 @@ async function memory(app, args2) {
|
|
|
60639
61459
|
}
|
|
60640
61460
|
async function review(app, base) {
|
|
60641
61461
|
const git3 = (a) => new Promise(
|
|
60642
|
-
(
|
|
61462
|
+
(resolve21) => (0, import_node_child_process14.execFile)(
|
|
60643
61463
|
"git",
|
|
60644
61464
|
a,
|
|
60645
61465
|
{ cwd: app.host.cwd, maxBuffer: 64 * 1024 * 1024 },
|
|
60646
|
-
(err2, out2) =>
|
|
61466
|
+
(err2, out2) => resolve21({ code: err2 ? 1 : 0, out: String(out2) })
|
|
60647
61467
|
)
|
|
60648
61468
|
);
|
|
60649
61469
|
const found = base ? await git3(["merge-base", "HEAD", base]).then(
|
|
@@ -60689,11 +61509,11 @@ async function review(app, base) {
|
|
|
60689
61509
|
}
|
|
60690
61510
|
async function diff(app) {
|
|
60691
61511
|
const out2 = await new Promise(
|
|
60692
|
-
(
|
|
61512
|
+
(resolve21) => (0, import_node_child_process14.execFile)(
|
|
60693
61513
|
"git",
|
|
60694
61514
|
["-c", "color.ui=always", "diff", "--stat", "--patch", "HEAD"],
|
|
60695
61515
|
{ cwd: app.host.cwd, maxBuffer: 64 * 1024 * 1024 },
|
|
60696
|
-
(err2, stdout) =>
|
|
61516
|
+
(err2, stdout) => resolve21(err2 ? "" : String(stdout))
|
|
60697
61517
|
)
|
|
60698
61518
|
);
|
|
60699
61519
|
if (!out2.trim()) {
|
|
@@ -61032,7 +61852,7 @@ var App = class {
|
|
|
61032
61852
|
}
|
|
61033
61853
|
opts;
|
|
61034
61854
|
async start() {
|
|
61035
|
-
const done2 = new Promise((
|
|
61855
|
+
const done2 = new Promise((resolve21) => this.finished = resolve21);
|
|
61036
61856
|
readline2.emitKeypressEvents(this.input);
|
|
61037
61857
|
this.input.setRawMode?.(true);
|
|
61038
61858
|
this.input.resume();
|
|
@@ -61053,8 +61873,35 @@ var App = class {
|
|
|
61053
61873
|
this.animTimer.unref?.();
|
|
61054
61874
|
}
|
|
61055
61875
|
openTasks({ onMainNote: (owner) => this.onMainNote(owner) });
|
|
61876
|
+
setTaskListPersistence(taskListPersistence(this.store, () => this.session));
|
|
61056
61877
|
setBackgroundTasks(new BackgroundTasks(() => this.onShellsChanged()));
|
|
61057
61878
|
if (this.sessionAgent?.note) this.notice = this.sessionAgent.note;
|
|
61879
|
+
installAgentMcp({
|
|
61880
|
+
trusted: () => folderTrusted(this.host.cwd),
|
|
61881
|
+
ask: async (agent2, server, what) => {
|
|
61882
|
+
const choice = await this.ask(
|
|
61883
|
+
`Agent "${agent2.name}" wants to start its MCP server "${server.name}". Run it?`,
|
|
61884
|
+
[{ label: "Yes, run it", hint: "remembered on this machine" }, { label: "No", hint: "esc" }],
|
|
61885
|
+
`From ${agent2.path ?? "a project agent file"}
|
|
61886
|
+
It runs: ${what}`
|
|
61887
|
+
);
|
|
61888
|
+
return choice === 0;
|
|
61889
|
+
},
|
|
61890
|
+
askToolChange: async (server, change) => {
|
|
61891
|
+
const choice = await this.ask(
|
|
61892
|
+
`The tools of MCP server "${server}" changed since you last used them. Offer the changed ones to the agent?`,
|
|
61893
|
+
[{ label: "Yes" }, { label: "No, keep them out", hint: "esc" }],
|
|
61894
|
+
describeChange(server, change)
|
|
61895
|
+
);
|
|
61896
|
+
return choice === 0;
|
|
61897
|
+
},
|
|
61898
|
+
log: (line) => {
|
|
61899
|
+
if (/not started/.test(line)) {
|
|
61900
|
+
this.notice = line.replace(/^agents: /, "");
|
|
61901
|
+
this.redraw();
|
|
61902
|
+
}
|
|
61903
|
+
}
|
|
61904
|
+
});
|
|
61058
61905
|
const settings = userSettings();
|
|
61059
61906
|
if (settings["mcp.servers"] && typeof settings["mcp.servers"] === "object") {
|
|
61060
61907
|
void startMcp(() => {
|
|
@@ -61358,13 +62205,13 @@ var App = class {
|
|
|
61358
62205
|
}
|
|
61359
62206
|
ask(title, items, note, extra = {}) {
|
|
61360
62207
|
const asked = this.modalChain.then(
|
|
61361
|
-
() => new Promise((
|
|
62208
|
+
() => new Promise((resolve21) => {
|
|
61362
62209
|
this.modal = {
|
|
61363
62210
|
title,
|
|
61364
62211
|
items,
|
|
61365
62212
|
index: extra.start ?? 0,
|
|
61366
62213
|
note,
|
|
61367
|
-
resolve:
|
|
62214
|
+
resolve: resolve21,
|
|
61368
62215
|
onMove: extra.onMove,
|
|
61369
62216
|
preview: extra.preview
|
|
61370
62217
|
};
|
|
@@ -61440,10 +62287,10 @@ var App = class {
|
|
|
61440
62287
|
this.images = [];
|
|
61441
62288
|
for (const m of body2.matchAll(/@(\S+)/g)) {
|
|
61442
62289
|
if (!IMAGE_EXT.test(m[1])) continue;
|
|
61443
|
-
const file2 =
|
|
62290
|
+
const file2 = path48.resolve(this.host.cwd, m[1]);
|
|
61444
62291
|
try {
|
|
61445
62292
|
const ext = m[1].split(".").pop().toLowerCase();
|
|
61446
|
-
images.push({ mime: MIME[ext], data:
|
|
62293
|
+
images.push({ mime: MIME[ext], data: fs43.readFileSync(file2).toString("base64") });
|
|
61447
62294
|
} catch {
|
|
61448
62295
|
}
|
|
61449
62296
|
}
|
|
@@ -61525,10 +62372,7 @@ var App = class {
|
|
|
61525
62372
|
seenPaths: seen,
|
|
61526
62373
|
memories,
|
|
61527
62374
|
...base,
|
|
61528
|
-
...agent2 ? {
|
|
61529
|
-
customize: [base.customize, agent2.role].filter(Boolean).join("\n\n"),
|
|
61530
|
-
toolFilter: agent2.toolFilter
|
|
61531
|
-
} : {},
|
|
62375
|
+
...agent2 ? sessionGuidance(agent2, base.customize) : {},
|
|
61532
62376
|
...images.length ? { images } : {},
|
|
61533
62377
|
...planSlug2 ? { planSlug: planSlug2 } : {},
|
|
61534
62378
|
...review3 ? { reviewing: true, onFindings: review3 } : {},
|
|
@@ -61632,8 +62476,8 @@ function ago(t2) {
|
|
|
61632
62476
|
// ../editor/src/cli/tui/complete.ts
|
|
61633
62477
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
61634
62478
|
var import_node_child_process16 = require("node:child_process");
|
|
61635
|
-
var
|
|
61636
|
-
var
|
|
62479
|
+
var fs44 = __toESM(require("node:fs"));
|
|
62480
|
+
var path49 = __toESM(require("node:path"));
|
|
61637
62481
|
function fuzzyScore(query, candidate) {
|
|
61638
62482
|
if (!query) return 0;
|
|
61639
62483
|
const q = query.toLowerCase();
|
|
@@ -61683,15 +62527,15 @@ function listFiles2(root2) {
|
|
|
61683
62527
|
if (files.length >= MAX_FILES2) return;
|
|
61684
62528
|
let entries = [];
|
|
61685
62529
|
try {
|
|
61686
|
-
entries =
|
|
62530
|
+
entries = fs44.readdirSync(dir, { withFileTypes: true });
|
|
61687
62531
|
} catch {
|
|
61688
62532
|
return;
|
|
61689
62533
|
}
|
|
61690
62534
|
for (const e of entries) {
|
|
61691
62535
|
if (SKIP3.has(e.name) || e.name.startsWith(".")) continue;
|
|
61692
|
-
const full =
|
|
62536
|
+
const full = path49.join(dir, e.name);
|
|
61693
62537
|
if (e.isDirectory()) walk5(full);
|
|
61694
|
-
else files.push(
|
|
62538
|
+
else files.push(path49.relative(root2, full));
|
|
61695
62539
|
if (files.length >= MAX_FILES2) return;
|
|
61696
62540
|
}
|
|
61697
62541
|
};
|
|
@@ -61861,7 +62705,10 @@ function compose(app) {
|
|
|
61861
62705
|
if (app.modal) {
|
|
61862
62706
|
const m = app.modal;
|
|
61863
62707
|
const body3 = [];
|
|
61864
|
-
if (m.note)
|
|
62708
|
+
if (m.note) {
|
|
62709
|
+
const [first, ...rest] = m.note.split("\n");
|
|
62710
|
+
body3.push(t.warning("\u26A0 " + first), ...rest.map((l) => t.warning(" " + l)), "");
|
|
62711
|
+
}
|
|
61865
62712
|
m.items.forEach((item, i2) => {
|
|
61866
62713
|
const sel = i2 === m.index;
|
|
61867
62714
|
const label = `${i2 + 1}. ${item.label}`;
|
|
@@ -62130,7 +62977,7 @@ async function onboard(plan, io) {
|
|
|
62130
62977
|
result.ok = ok;
|
|
62131
62978
|
resolveDone();
|
|
62132
62979
|
};
|
|
62133
|
-
const
|
|
62980
|
+
const choose2 = (render, items, start2 = 0) => new Promise((resolve21) => {
|
|
62134
62981
|
let sel = start2;
|
|
62135
62982
|
const list2 = () => items.map((c, i2) => {
|
|
62136
62983
|
const label = `${i2 + 1}. ${c.label}`;
|
|
@@ -62140,16 +62987,16 @@ async function onboard(plan, io) {
|
|
|
62140
62987
|
onKey = (str3, k) => {
|
|
62141
62988
|
if (k.name === "up") sel = (sel - 1 + items.length) % items.length;
|
|
62142
62989
|
else if (k.name === "down" || k.name === "tab") sel = (sel + 1) % items.length;
|
|
62143
|
-
else if (k.name === "return")
|
|
62144
|
-
else if (k.name === "escape")
|
|
62145
|
-
else if (str3 && /^[1-9]$/.test(str3) && Number(str3) <= items.length)
|
|
62990
|
+
else if (k.name === "return") resolve21(sel);
|
|
62991
|
+
else if (k.name === "escape") resolve21(void 0);
|
|
62992
|
+
else if (str3 && /^[1-9]$/.test(str3) && Number(str3) <= items.length) resolve21(Number(str3) - 1);
|
|
62146
62993
|
};
|
|
62147
62994
|
draw();
|
|
62148
62995
|
});
|
|
62149
|
-
const pressEnter = (lines2) => new Promise((
|
|
62996
|
+
const pressEnter = (lines2) => new Promise((resolve21) => {
|
|
62150
62997
|
body2 = () => [...lines2, "", t.muted(" Press ") + t.bold("Enter") + t.muted(" to continue\u2026")];
|
|
62151
62998
|
onKey = (_s, k) => {
|
|
62152
|
-
if (k.name === "return")
|
|
62999
|
+
if (k.name === "return") resolve21();
|
|
62153
63000
|
};
|
|
62154
63001
|
draw();
|
|
62155
63002
|
});
|
|
@@ -62169,7 +63016,7 @@ async function onboard(plan, io) {
|
|
|
62169
63016
|
}
|
|
62170
63017
|
if (plan.theme) {
|
|
62171
63018
|
const current4 = THEMES.findIndex((x) => x.name === themeName());
|
|
62172
|
-
const pick2 = await
|
|
63019
|
+
const pick2 = await choose2(
|
|
62173
63020
|
(sel) => {
|
|
62174
63021
|
setTheme(THEMES[sel].name);
|
|
62175
63022
|
return [
|
|
@@ -62191,7 +63038,7 @@ async function onboard(plan, io) {
|
|
|
62191
63038
|
}
|
|
62192
63039
|
if (plan.apiKey) {
|
|
62193
63040
|
const masked = plan.apiKey.slice(0, 8) + "\u2026" + plan.apiKey.slice(-4);
|
|
62194
|
-
const pick2 = await
|
|
63041
|
+
const pick2 = await choose2(
|
|
62195
63042
|
() => [
|
|
62196
63043
|
...box(
|
|
62197
63044
|
[
|
|
@@ -62214,7 +63061,7 @@ async function onboard(plan, io) {
|
|
|
62214
63061
|
if (!result.useApiKey) plan.signIn = true;
|
|
62215
63062
|
}
|
|
62216
63063
|
while (plan.signIn && !result.useApiKey) {
|
|
62217
|
-
const how = await
|
|
63064
|
+
const how = await choose2(
|
|
62218
63065
|
() => [
|
|
62219
63066
|
"AstraCode is used with your AstraCode plan, or with an API key for scripts and CI.",
|
|
62220
63067
|
"",
|
|
@@ -62255,7 +63102,7 @@ async function onboard(plan, io) {
|
|
|
62255
63102
|
]);
|
|
62256
63103
|
}
|
|
62257
63104
|
if (plan.trust) {
|
|
62258
|
-
const pick2 = await
|
|
63105
|
+
const pick2 = await choose2(
|
|
62259
63106
|
() => [
|
|
62260
63107
|
...box(
|
|
62261
63108
|
[
|
|
@@ -62303,11 +63150,11 @@ async function onboard(plan, io) {
|
|
|
62303
63150
|
t.muted(copied ? " \u2713 Copied to the clipboard" : " c to copy the link \xB7 esc to go back"),
|
|
62304
63151
|
t.muted(" Over SSH? The link only works on this machine; use an API key instead.")
|
|
62305
63152
|
];
|
|
62306
|
-
const cancelled = new Promise((
|
|
63153
|
+
const cancelled = new Promise((resolve21) => {
|
|
62307
63154
|
onKey = (str3, k) => {
|
|
62308
63155
|
if (k.name === "escape") {
|
|
62309
63156
|
pending2.cancel();
|
|
62310
|
-
|
|
63157
|
+
resolve21("cancel");
|
|
62311
63158
|
} else if (str3 === "c") {
|
|
62312
63159
|
copyToClipboard(pending2.url);
|
|
62313
63160
|
copied = true;
|
|
@@ -62450,6 +63297,25 @@ async function interactive(opts) {
|
|
|
62450
63297
|
return r.done ? void 0 : r.value;
|
|
62451
63298
|
};
|
|
62452
63299
|
let wakes = 0;
|
|
63300
|
+
installAgentMcp({
|
|
63301
|
+
trusted: () => folderTrusted(host2.cwd),
|
|
63302
|
+
ask: async (agent3, server, what) => {
|
|
63303
|
+
out2(
|
|
63304
|
+
`
|
|
63305
|
+
Agent ${bold2(agent3.name)} (${agent3.path ?? "a project agent file"}) wants to start its MCP server ${bold2(server.name)}:
|
|
63306
|
+
${what}
|
|
63307
|
+
Run it? ${dim2("[y]es / [n]o")} `
|
|
63308
|
+
);
|
|
63309
|
+
const answer = (await nextLine())?.trim().toLowerCase();
|
|
63310
|
+
if (!process.stdin.isTTY) out2(`${answer ?? ""}
|
|
63311
|
+
`);
|
|
63312
|
+
return answer === "y" || answer === "yes";
|
|
63313
|
+
},
|
|
63314
|
+
log: (line) => {
|
|
63315
|
+
if (/not started/.test(line)) out2(dim2(` ${line.replace(/^agents: /, "")}
|
|
63316
|
+
`));
|
|
63317
|
+
}
|
|
63318
|
+
});
|
|
62453
63319
|
let history = [];
|
|
62454
63320
|
let seenPaths = /* @__PURE__ */ new Set();
|
|
62455
63321
|
const always = /* @__PURE__ */ new Set();
|
|
@@ -62491,7 +63357,7 @@ ${dim2("/help for commands, Ctrl-D to leave")}
|
|
|
62491
63357
|
if (!closed) rl.prompt();
|
|
62492
63358
|
const raced = await Promise.race([
|
|
62493
63359
|
readOne().then((r) => ({ line: r })),
|
|
62494
|
-
new Promise((
|
|
63360
|
+
new Promise((resolve21) => wakeSignal = () => resolve21({}))
|
|
62495
63361
|
]);
|
|
62496
63362
|
wakeSignal = void 0;
|
|
62497
63363
|
if (!raced.line) {
|
|
@@ -62601,7 +63467,7 @@ ${dim2("/help for commands, Ctrl-D to leave")}
|
|
|
62601
63467
|
principles: BUNDLED_PRINCIPLES,
|
|
62602
63468
|
projectRules: host2.projectRules,
|
|
62603
63469
|
seenPaths,
|
|
62604
|
-
...agent2 ?
|
|
63470
|
+
...agent2 ? sessionGuidance(agent2) : {}
|
|
62605
63471
|
}
|
|
62606
63472
|
)
|
|
62607
63473
|
);
|
|
@@ -62626,7 +63492,7 @@ ${dim2("/help for commands, Ctrl-D to leave")}
|
|
|
62626
63492
|
return 0;
|
|
62627
63493
|
}
|
|
62628
63494
|
async function firstRun(opts, settings) {
|
|
62629
|
-
const cwd =
|
|
63495
|
+
const cwd = path50.resolve(opts.cwd);
|
|
62630
63496
|
const key = process.env.ASTRACODE_API_KEY?.trim();
|
|
62631
63497
|
const fp = key ? keyFingerprint(key) : void 0;
|
|
62632
63498
|
const choices = settings.apiKeyChoice && typeof settings.apiKeyChoice === "object" ? settings.apiKeyChoice : {};
|
|
@@ -62663,9 +63529,9 @@ init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
|
62663
63529
|
var import_node_child_process19 = require("node:child_process");
|
|
62664
63530
|
var MAX_DIFF_CHARS3 = 12e4;
|
|
62665
63531
|
function git2(args2, cwd) {
|
|
62666
|
-
return new Promise((
|
|
63532
|
+
return new Promise((resolve21) => {
|
|
62667
63533
|
(0, import_node_child_process19.execFile)("git", args2, { cwd, maxBuffer: 64 * 1024 * 1024 }, (err2, stdout) => {
|
|
62668
|
-
|
|
63534
|
+
resolve21({ code: err2 ? typeof err2.code === "number" ? err2.code : 1 : 0, out: String(stdout) });
|
|
62669
63535
|
});
|
|
62670
63536
|
});
|
|
62671
63537
|
}
|
|
@@ -62809,7 +63675,7 @@ ${lines2.join("\n\n")}
|
|
|
62809
63675
|
// ../editor/src/cli/update.ts
|
|
62810
63676
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
62811
63677
|
var import_node_child_process20 = require("node:child_process");
|
|
62812
|
-
var
|
|
63678
|
+
var path51 = __toESM(require("node:path"));
|
|
62813
63679
|
var DEFAULT_INSTALLER = "https://astracode.io/install";
|
|
62814
63680
|
function cliReason(err2) {
|
|
62815
63681
|
const status3 = err2.status;
|
|
@@ -62865,26 +63731,26 @@ async function update(current4) {
|
|
|
62865
63731
|
process.stderr.write(`Updating astracode-agent ${current4} -> ${latest}
|
|
62866
63732
|
`);
|
|
62867
63733
|
const env5 = { ...process.env, ASTRACODE_VERSION: latest };
|
|
62868
|
-
const versionDir =
|
|
62869
|
-
if (VERSION_RE.test(
|
|
62870
|
-
env5.ASTRACODE_DATA_DIR =
|
|
63734
|
+
const versionDir = path51.dirname(process.execPath);
|
|
63735
|
+
if (VERSION_RE.test(path51.basename(versionDir)) && !process.env.ASTRACODE_DATA_DIR) {
|
|
63736
|
+
env5.ASTRACODE_DATA_DIR = path51.dirname(versionDir);
|
|
62871
63737
|
}
|
|
62872
|
-
return new Promise((
|
|
63738
|
+
return new Promise((resolve21) => {
|
|
62873
63739
|
const child = (0, import_node_child_process20.spawn)("sh", ["-s"], { env: env5, stdio: ["pipe", "inherit", "inherit"] });
|
|
62874
63740
|
child.on("error", (err2) => {
|
|
62875
63741
|
process.stderr.write(`astracode-agent: could not run the installer (${err2.message})
|
|
62876
63742
|
`);
|
|
62877
|
-
|
|
63743
|
+
resolve21(1);
|
|
62878
63744
|
});
|
|
62879
|
-
child.on("close", (code) =>
|
|
63745
|
+
child.on("close", (code) => resolve21(code ?? 1));
|
|
62880
63746
|
child.stdin.end(script);
|
|
62881
63747
|
});
|
|
62882
63748
|
}
|
|
62883
63749
|
|
|
62884
63750
|
// ../editor/src/cli/update-check.ts
|
|
62885
63751
|
init_define_ASTRACODE_BUNDLED_SKILLS();
|
|
62886
|
-
var
|
|
62887
|
-
var
|
|
63752
|
+
var fs45 = __toESM(require("node:fs"));
|
|
63753
|
+
var path52 = __toESM(require("node:path"));
|
|
62888
63754
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
62889
63755
|
var FETCH_TIMEOUT_MS = 3e3;
|
|
62890
63756
|
var GRACE_MS = 1500;
|
|
@@ -62911,10 +63777,10 @@ async function fetchLatest(kind) {
|
|
|
62911
63777
|
return typeof latest === "string" && VERSION_RE.test(latest) ? latest : void 0;
|
|
62912
63778
|
}
|
|
62913
63779
|
function startUpdateCheck(current4, kind) {
|
|
62914
|
-
const file2 =
|
|
63780
|
+
const file2 = path52.join(configDir(), "update-check.json");
|
|
62915
63781
|
let cached4;
|
|
62916
63782
|
try {
|
|
62917
|
-
cached4 = JSON.parse(
|
|
63783
|
+
cached4 = JSON.parse(fs45.readFileSync(file2, "utf8"));
|
|
62918
63784
|
} catch {
|
|
62919
63785
|
}
|
|
62920
63786
|
const fresh = cached4 && cached4.kind === kind && Date.now() - cached4.checkedAt < DAY_MS && VERSION_RE.test(cached4.latest);
|
|
@@ -62922,8 +63788,8 @@ function startUpdateCheck(current4, kind) {
|
|
|
62922
63788
|
(latest) => {
|
|
62923
63789
|
if (latest) {
|
|
62924
63790
|
try {
|
|
62925
|
-
|
|
62926
|
-
|
|
63791
|
+
fs45.mkdirSync(path52.dirname(file2), { recursive: true, mode: 448 });
|
|
63792
|
+
fs45.writeFileSync(file2, JSON.stringify({ checkedAt: Date.now(), latest, kind }));
|
|
62927
63793
|
} catch {
|
|
62928
63794
|
}
|
|
62929
63795
|
}
|
|
@@ -62935,7 +63801,7 @@ function startUpdateCheck(current4, kind) {
|
|
|
62935
63801
|
async notice() {
|
|
62936
63802
|
const latest = await Promise.race([
|
|
62937
63803
|
pending2,
|
|
62938
|
-
new Promise((
|
|
63804
|
+
new Promise((resolve21) => setTimeout(() => resolve21(void 0), GRACE_MS).unref())
|
|
62939
63805
|
]);
|
|
62940
63806
|
if (!latest || !isNewer(latest, current4)) return void 0;
|
|
62941
63807
|
return `astracode-agent ${latest} is available (you have ${current4}). Update with: ${updateCommand(kind)}`;
|
|
@@ -63059,12 +63925,12 @@ var RunReporter = class {
|
|
|
63059
63925
|
};
|
|
63060
63926
|
|
|
63061
63927
|
// ../editor/src/cli/main.ts
|
|
63062
|
-
var VERSION2 = true ? "0.4.
|
|
63928
|
+
var VERSION2 = true ? "0.4.1" : "dev";
|
|
63063
63929
|
function readStdin() {
|
|
63064
|
-
return new Promise((
|
|
63930
|
+
return new Promise((resolve21, reject) => {
|
|
63065
63931
|
const chunks = [];
|
|
63066
63932
|
process.stdin.on("data", (c) => chunks.push(c));
|
|
63067
|
-
process.stdin.on("end", () =>
|
|
63933
|
+
process.stdin.on("end", () => resolve21(Buffer.concat(chunks).toString("utf8")));
|
|
63068
63934
|
process.stdin.on("error", reject);
|
|
63069
63935
|
});
|
|
63070
63936
|
}
|
|
@@ -63090,7 +63956,15 @@ ${USAGE}
|
|
|
63090
63956
|
if (parsed.kind === "update") return update(VERSION2);
|
|
63091
63957
|
setClient(cliKind(parsed.kind, process.env), VERSION2);
|
|
63092
63958
|
if (typeof define_ASTRACODE_BUNDLED_SKILLS_default === "object") setBundledSkillFiles(define_ASTRACODE_BUNDLED_SKILLS_default);
|
|
63093
|
-
if (parsed.kind === "acp")
|
|
63959
|
+
if (parsed.kind === "acp") {
|
|
63960
|
+
const problem = loadSessionAgents(parsed, process.cwd());
|
|
63961
|
+
if (problem) {
|
|
63962
|
+
process.stderr.write(`astracode-agent: ${problem}
|
|
63963
|
+
`);
|
|
63964
|
+
return 2;
|
|
63965
|
+
}
|
|
63966
|
+
return serveAcp(VERSION2, { agent: parsed.agent, allowAgentMcp: parsed.allowAgentMcp === true });
|
|
63967
|
+
}
|
|
63094
63968
|
if (parsed.kind === "status") {
|
|
63095
63969
|
configureShim(gatewayUrl());
|
|
63096
63970
|
const credential = await credentialForRun(() => {
|
|
@@ -63142,7 +64016,7 @@ ${notice}
|
|
|
63142
64016
|
}
|
|
63143
64017
|
function loadSessionAgents(flags2, cwd) {
|
|
63144
64018
|
if (!flags2.agents) return void 0;
|
|
63145
|
-
const parsed = parseAgentsFlag(flags2.agents,
|
|
64019
|
+
const parsed = parseAgentsFlag(flags2.agents, path53.resolve(cwd));
|
|
63146
64020
|
if (!parsed.ok) return parsed.message;
|
|
63147
64021
|
for (const p of parsed.problems) process.stderr.write(`astracode-agent: warning: ${p}
|
|
63148
64022
|
`);
|
|
@@ -63172,6 +64046,11 @@ async function runTask(options) {
|
|
|
63172
64046
|
}
|
|
63173
64047
|
const host2 = opened.host;
|
|
63174
64048
|
openTasks({ log: log2 });
|
|
64049
|
+
installAgentMcp({
|
|
64050
|
+
trusted: () => false,
|
|
64051
|
+
allowedByFlag: options.allowAgentMcp === true,
|
|
64052
|
+
log: agentMcpLog(log2)
|
|
64053
|
+
});
|
|
63175
64054
|
const session3 = resolveSessionAgent(options.agent, host2.auto);
|
|
63176
64055
|
if (typeof session3 === "string") {
|
|
63177
64056
|
process.stderr.write(`astracode-agent: ${session3}
|
|
@@ -63225,7 +64104,7 @@ async function runTask(options) {
|
|
|
63225
64104
|
principles: BUNDLED_PRINCIPLES,
|
|
63226
64105
|
projectRules: host2.projectRules,
|
|
63227
64106
|
seenPaths: /* @__PURE__ */ new Set(),
|
|
63228
|
-
...session3 ?
|
|
64107
|
+
...session3 ? sessionGuidance(session3) : {}
|
|
63229
64108
|
}
|
|
63230
64109
|
);
|
|
63231
64110
|
} catch (err2) {
|