replicas-engine 0.1.887 → 0.1.889
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/{asp-host-BMYDTN33.js → asp-host-7TTLBO5M.js} +4 -4
- package/dist/src/{chunk-5RULOJKJ.js → chunk-45I2CJU6.js} +180 -123
- package/dist/src/{chunk-B7FBFPKL.js → chunk-F33TXACU.js} +2 -2
- package/dist/src/{chunk-4DGHCMBQ.js → chunk-ISNWC7OA.js} +1 -1
- package/dist/src/{chunk-UZC3FR6R.js → chunk-N7JSMN3R.js} +10 -5
- package/dist/src/{chunk-N2DC3SCQ.js → chunk-RG6ZP2EU.js} +1 -1
- package/dist/src/{chunk-P7AHODJ6.js → chunk-WMRZEQIH.js} +2 -2
- package/dist/src/command-protection-hook.js +3 -3
- package/dist/src/deepseek-command-protection-plugin.js +4 -4
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +328 -197
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/relay-mcp.js +1 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
evaluateCommandProtection,
|
|
92
92
|
extractToolCommand,
|
|
93
93
|
reportCommandProtectionBlock
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-WMRZEQIH.js";
|
|
95
95
|
import {
|
|
96
96
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
97
97
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -131,23 +131,24 @@ import {
|
|
|
131
131
|
listCredentialFallbacks,
|
|
132
132
|
recordCredentialFallback,
|
|
133
133
|
recordExhaustedCredential,
|
|
134
|
+
refreshDelayMs,
|
|
134
135
|
restartCodexAspHost,
|
|
135
136
|
routineRefreshExclusions
|
|
136
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-N7JSMN3R.js";
|
|
137
138
|
import {
|
|
138
139
|
ENGINE_ENV,
|
|
139
140
|
IS_WARMING_MODE,
|
|
140
141
|
monolithRequest,
|
|
141
142
|
monolithService,
|
|
142
143
|
setAgentCredentialSnapshot
|
|
143
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-RG6ZP2EU.js";
|
|
144
145
|
import {
|
|
145
146
|
AspClient,
|
|
146
147
|
SUBPROCESS_MAX_BUFFER,
|
|
147
148
|
execAsync,
|
|
148
149
|
execFileAsync,
|
|
149
150
|
getCodexModelProvider
|
|
150
|
-
} from "./chunk-
|
|
151
|
+
} from "./chunk-F33TXACU.js";
|
|
151
152
|
import {
|
|
152
153
|
isRecord as isRecord2
|
|
153
154
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -214,6 +215,7 @@ import {
|
|
|
214
215
|
GITLAB_CREDENTIAL_REFRESH_PATH,
|
|
215
216
|
GIT_CREDENTIAL_HELPER_FILENAME,
|
|
216
217
|
HOOK_EXEC_MAX_BUFFER_BYTES,
|
|
218
|
+
IDENTITY_PROXY_PORT,
|
|
217
219
|
IMAGE_MEDIA_TYPES,
|
|
218
220
|
InFlightMap,
|
|
219
221
|
MAX_CANVAS_FILE_BYTES,
|
|
@@ -237,6 +239,7 @@ import {
|
|
|
237
239
|
TaskAccumulator,
|
|
238
240
|
USER_MESSAGE_ID_PAYLOAD_KEY,
|
|
239
241
|
VALID_AGENT_PROVIDERS,
|
|
242
|
+
WORKSPACE_TOKEN_ENV,
|
|
240
243
|
agentQuotaExhaustedPayloadSchema,
|
|
241
244
|
areSameUserMessageEvents,
|
|
242
245
|
areUserMessagesWithinMatchWindow,
|
|
@@ -269,6 +272,7 @@ import {
|
|
|
269
272
|
createProviderSlashCommand,
|
|
270
273
|
createSuccessResult,
|
|
271
274
|
createUuidFromHex,
|
|
275
|
+
currentWorkspaceToken,
|
|
272
276
|
decodePathSegments,
|
|
273
277
|
defaultForkChatTitle,
|
|
274
278
|
describeQuotaLimit,
|
|
@@ -363,7 +367,7 @@ import {
|
|
|
363
367
|
waitRelaySubagentRequestSchema,
|
|
364
368
|
withTimeout,
|
|
365
369
|
workspaceCredentialProviderSchema
|
|
366
|
-
} from "./chunk-
|
|
370
|
+
} from "./chunk-45I2CJU6.js";
|
|
367
371
|
import {
|
|
368
372
|
__commonJS,
|
|
369
373
|
__export,
|
|
@@ -378,7 +382,7 @@ var require_windows = __commonJS({
|
|
|
378
382
|
module.exports = isexe;
|
|
379
383
|
isexe.sync = sync;
|
|
380
384
|
var fs8 = __require("fs");
|
|
381
|
-
function checkPathExt(
|
|
385
|
+
function checkPathExt(path8, options) {
|
|
382
386
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
383
387
|
if (!pathext) {
|
|
384
388
|
return true;
|
|
@@ -389,25 +393,25 @@ var require_windows = __commonJS({
|
|
|
389
393
|
}
|
|
390
394
|
for (var i = 0; i < pathext.length; i++) {
|
|
391
395
|
var p = pathext[i].toLowerCase();
|
|
392
|
-
if (p &&
|
|
396
|
+
if (p && path8.substr(-p.length).toLowerCase() === p) {
|
|
393
397
|
return true;
|
|
394
398
|
}
|
|
395
399
|
}
|
|
396
400
|
return false;
|
|
397
401
|
}
|
|
398
|
-
function checkStat(stat8,
|
|
402
|
+
function checkStat(stat8, path8, options) {
|
|
399
403
|
if (!stat8.isSymbolicLink() && !stat8.isFile()) {
|
|
400
404
|
return false;
|
|
401
405
|
}
|
|
402
|
-
return checkPathExt(
|
|
406
|
+
return checkPathExt(path8, options);
|
|
403
407
|
}
|
|
404
|
-
function isexe(
|
|
405
|
-
fs8.stat(
|
|
406
|
-
cb(er, er ? false : checkStat(stat8,
|
|
408
|
+
function isexe(path8, options, cb) {
|
|
409
|
+
fs8.stat(path8, function(er, stat8) {
|
|
410
|
+
cb(er, er ? false : checkStat(stat8, path8, options));
|
|
407
411
|
});
|
|
408
412
|
}
|
|
409
|
-
function sync(
|
|
410
|
-
return checkStat(fs8.statSync(
|
|
413
|
+
function sync(path8, options) {
|
|
414
|
+
return checkStat(fs8.statSync(path8), path8, options);
|
|
411
415
|
}
|
|
412
416
|
}
|
|
413
417
|
});
|
|
@@ -419,13 +423,13 @@ var require_mode = __commonJS({
|
|
|
419
423
|
module.exports = isexe;
|
|
420
424
|
isexe.sync = sync;
|
|
421
425
|
var fs8 = __require("fs");
|
|
422
|
-
function isexe(
|
|
423
|
-
fs8.stat(
|
|
426
|
+
function isexe(path8, options, cb) {
|
|
427
|
+
fs8.stat(path8, function(er, stat8) {
|
|
424
428
|
cb(er, er ? false : checkStat(stat8, options));
|
|
425
429
|
});
|
|
426
430
|
}
|
|
427
|
-
function sync(
|
|
428
|
-
return checkStat(fs8.statSync(
|
|
431
|
+
function sync(path8, options) {
|
|
432
|
+
return checkStat(fs8.statSync(path8), options);
|
|
429
433
|
}
|
|
430
434
|
function checkStat(stat8, options) {
|
|
431
435
|
return stat8.isFile() && checkMode(stat8, options);
|
|
@@ -459,7 +463,7 @@ var require_isexe = __commonJS({
|
|
|
459
463
|
}
|
|
460
464
|
module.exports = isexe;
|
|
461
465
|
isexe.sync = sync;
|
|
462
|
-
function isexe(
|
|
466
|
+
function isexe(path8, options, cb) {
|
|
463
467
|
if (typeof options === "function") {
|
|
464
468
|
cb = options;
|
|
465
469
|
options = {};
|
|
@@ -469,7 +473,7 @@ var require_isexe = __commonJS({
|
|
|
469
473
|
throw new TypeError("callback not provided");
|
|
470
474
|
}
|
|
471
475
|
return new Promise(function(resolve7, reject) {
|
|
472
|
-
isexe(
|
|
476
|
+
isexe(path8, options || {}, function(er, is) {
|
|
473
477
|
if (er) {
|
|
474
478
|
reject(er);
|
|
475
479
|
} else {
|
|
@@ -478,7 +482,7 @@ var require_isexe = __commonJS({
|
|
|
478
482
|
});
|
|
479
483
|
});
|
|
480
484
|
}
|
|
481
|
-
core(
|
|
485
|
+
core(path8, options || {}, function(er, is) {
|
|
482
486
|
if (er) {
|
|
483
487
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
484
488
|
er = null;
|
|
@@ -488,9 +492,9 @@ var require_isexe = __commonJS({
|
|
|
488
492
|
cb(er, is);
|
|
489
493
|
});
|
|
490
494
|
}
|
|
491
|
-
function sync(
|
|
495
|
+
function sync(path8, options) {
|
|
492
496
|
try {
|
|
493
|
-
return core.sync(
|
|
497
|
+
return core.sync(path8, options || {});
|
|
494
498
|
} catch (er) {
|
|
495
499
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
496
500
|
return false;
|
|
@@ -507,7 +511,7 @@ var require_which = __commonJS({
|
|
|
507
511
|
"../node_modules/.bun/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
508
512
|
"use strict";
|
|
509
513
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
510
|
-
var
|
|
514
|
+
var path8 = __require("path");
|
|
511
515
|
var COLON = isWindows ? ";" : ":";
|
|
512
516
|
var isexe = require_isexe();
|
|
513
517
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -545,7 +549,7 @@ var require_which = __commonJS({
|
|
|
545
549
|
return opt.all && found.length ? resolve7(found) : reject(getNotFoundError(cmd));
|
|
546
550
|
const ppRaw = pathEnv[i];
|
|
547
551
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
548
|
-
const pCmd =
|
|
552
|
+
const pCmd = path8.join(pathPart, cmd);
|
|
549
553
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
550
554
|
resolve7(subStep(p, i, 0));
|
|
551
555
|
});
|
|
@@ -572,7 +576,7 @@ var require_which = __commonJS({
|
|
|
572
576
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
573
577
|
const ppRaw = pathEnv[i];
|
|
574
578
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
575
|
-
const pCmd =
|
|
579
|
+
const pCmd = path8.join(pathPart, cmd);
|
|
576
580
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
577
581
|
for (let j = 0; j < pathExt.length; j++) {
|
|
578
582
|
const cur = p + pathExt[j];
|
|
@@ -620,7 +624,7 @@ var require_path_key = __commonJS({
|
|
|
620
624
|
var require_resolveCommand = __commonJS({
|
|
621
625
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
622
626
|
"use strict";
|
|
623
|
-
var
|
|
627
|
+
var path8 = __require("path");
|
|
624
628
|
var which = require_which();
|
|
625
629
|
var getPathKey = require_path_key();
|
|
626
630
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -638,7 +642,7 @@ var require_resolveCommand = __commonJS({
|
|
|
638
642
|
try {
|
|
639
643
|
resolved = which.sync(parsed.command, {
|
|
640
644
|
path: env[getPathKey({ env })],
|
|
641
|
-
pathExt: withoutPathExt ?
|
|
645
|
+
pathExt: withoutPathExt ? path8.delimiter : void 0
|
|
642
646
|
});
|
|
643
647
|
} catch (e) {
|
|
644
648
|
} finally {
|
|
@@ -647,7 +651,7 @@ var require_resolveCommand = __commonJS({
|
|
|
647
651
|
}
|
|
648
652
|
}
|
|
649
653
|
if (resolved) {
|
|
650
|
-
resolved =
|
|
654
|
+
resolved = path8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
651
655
|
}
|
|
652
656
|
return resolved;
|
|
653
657
|
}
|
|
@@ -701,8 +705,8 @@ var require_shebang_command = __commonJS({
|
|
|
701
705
|
if (!match) {
|
|
702
706
|
return null;
|
|
703
707
|
}
|
|
704
|
-
const [
|
|
705
|
-
const binary =
|
|
708
|
+
const [path8, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
709
|
+
const binary = path8.split("/").pop();
|
|
706
710
|
if (binary === "env") {
|
|
707
711
|
return argument;
|
|
708
712
|
}
|
|
@@ -737,7 +741,7 @@ var require_readShebang = __commonJS({
|
|
|
737
741
|
var require_parse = __commonJS({
|
|
738
742
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
739
743
|
"use strict";
|
|
740
|
-
var
|
|
744
|
+
var path8 = __require("path");
|
|
741
745
|
var resolveCommand = require_resolveCommand();
|
|
742
746
|
var escape2 = require_escape();
|
|
743
747
|
var readShebang = require_readShebang();
|
|
@@ -762,7 +766,7 @@ var require_parse = __commonJS({
|
|
|
762
766
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
763
767
|
if (parsed.options.forceShell || needsShell) {
|
|
764
768
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
765
|
-
parsed.command =
|
|
769
|
+
parsed.command = path8.normalize(parsed.command);
|
|
766
770
|
parsed.command = escape2.command(parsed.command);
|
|
767
771
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
768
772
|
const shellCommand2 = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -4068,8 +4072,8 @@ var require_utils2 = __commonJS({
|
|
|
4068
4072
|
}
|
|
4069
4073
|
return ind;
|
|
4070
4074
|
}
|
|
4071
|
-
function removeDotSegments(
|
|
4072
|
-
let input =
|
|
4075
|
+
function removeDotSegments(path8) {
|
|
4076
|
+
let input = path8;
|
|
4073
4077
|
const output = [];
|
|
4074
4078
|
let nextSlash = -1;
|
|
4075
4079
|
let len = 0;
|
|
@@ -4321,8 +4325,8 @@ var require_schemes2 = __commonJS({
|
|
|
4321
4325
|
wsComponent.secure = void 0;
|
|
4322
4326
|
}
|
|
4323
4327
|
if (wsComponent.resourceName) {
|
|
4324
|
-
const [
|
|
4325
|
-
wsComponent.path =
|
|
4328
|
+
const [path8, query2] = wsComponent.resourceName.split("?");
|
|
4329
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
4326
4330
|
wsComponent.query = query2;
|
|
4327
4331
|
wsComponent.resourceName = void 0;
|
|
4328
4332
|
}
|
|
@@ -4381,7 +4385,7 @@ var require_schemes2 = __commonJS({
|
|
|
4381
4385
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
4382
4386
|
return urnComponent;
|
|
4383
4387
|
}
|
|
4384
|
-
var
|
|
4388
|
+
var http3 = (
|
|
4385
4389
|
/** @type {SchemeHandler} */
|
|
4386
4390
|
{
|
|
4387
4391
|
scheme: "http",
|
|
@@ -4390,11 +4394,11 @@ var require_schemes2 = __commonJS({
|
|
|
4390
4394
|
serialize: httpSerialize
|
|
4391
4395
|
}
|
|
4392
4396
|
);
|
|
4393
|
-
var
|
|
4397
|
+
var https2 = (
|
|
4394
4398
|
/** @type {SchemeHandler} */
|
|
4395
4399
|
{
|
|
4396
4400
|
scheme: "https",
|
|
4397
|
-
domainHost:
|
|
4401
|
+
domainHost: http3.domainHost,
|
|
4398
4402
|
parse: httpParse,
|
|
4399
4403
|
serialize: httpSerialize
|
|
4400
4404
|
}
|
|
@@ -4438,8 +4442,8 @@ var require_schemes2 = __commonJS({
|
|
|
4438
4442
|
var SCHEMES = (
|
|
4439
4443
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
4440
4444
|
{
|
|
4441
|
-
http:
|
|
4442
|
-
https,
|
|
4445
|
+
http: http3,
|
|
4446
|
+
https: https2,
|
|
4443
4447
|
ws,
|
|
4444
4448
|
wss,
|
|
4445
4449
|
urn,
|
|
@@ -8581,11 +8585,11 @@ var AsyncLock = class {
|
|
|
8581
8585
|
};
|
|
8582
8586
|
|
|
8583
8587
|
// src/utils/file.ts
|
|
8584
|
-
async function atomicWriteFile(
|
|
8585
|
-
const tmpFile = `${
|
|
8588
|
+
async function atomicWriteFile(path8, data, options) {
|
|
8589
|
+
const tmpFile = `${path8}.${process.pid}.${randomUUID()}.tmp`;
|
|
8586
8590
|
try {
|
|
8587
8591
|
await writeFile(tmpFile, data, { encoding: "utf-8", mode: options?.mode });
|
|
8588
|
-
await rename(tmpFile,
|
|
8592
|
+
await rename(tmpFile, path8);
|
|
8589
8593
|
} catch (error) {
|
|
8590
8594
|
await unlink(tmpFile).catch(() => void 0);
|
|
8591
8595
|
throw error;
|
|
@@ -9011,9 +9015,9 @@ var GitService = class {
|
|
|
9011
9015
|
try {
|
|
9012
9016
|
const paths = await this.listUntrackedPaths(repoPath);
|
|
9013
9017
|
let total = 0;
|
|
9014
|
-
for (const
|
|
9018
|
+
for (const path8 of paths) {
|
|
9015
9019
|
try {
|
|
9016
|
-
const contents = await readFile3(join4(repoPath,
|
|
9020
|
+
const contents = await readFile3(join4(repoPath, path8));
|
|
9017
9021
|
if (contents.length === 0 || contents.includes(0)) {
|
|
9018
9022
|
continue;
|
|
9019
9023
|
}
|
|
@@ -9269,9 +9273,9 @@ var GitService = class {
|
|
|
9269
9273
|
await saveRepoState(repo.name, state, state);
|
|
9270
9274
|
return state;
|
|
9271
9275
|
}
|
|
9272
|
-
async safeStat(
|
|
9276
|
+
async safeStat(path8) {
|
|
9273
9277
|
try {
|
|
9274
|
-
return await stat(
|
|
9278
|
+
return await stat(path8);
|
|
9275
9279
|
} catch {
|
|
9276
9280
|
return null;
|
|
9277
9281
|
}
|
|
@@ -9550,8 +9554,7 @@ var InfisicalTokenManager = class extends BaseRefreshManager {
|
|
|
9550
9554
|
if (!response.ok) throw new Error(`Token refresh failed: ${response.status} ${await response.text()}`);
|
|
9551
9555
|
const data = await response.json();
|
|
9552
9556
|
await this.applyCredentials(data, this.paths);
|
|
9553
|
-
|
|
9554
|
-
this.nextRefreshDelayMs = Number.isFinite(ttlMs) ? Math.max(1e3, Math.min(5 * 60 * 1e3, Math.floor(ttlMs * 0.8))) : 5 * 60 * 1e3;
|
|
9557
|
+
this.nextRefreshDelayMs = refreshDelayMs(data.configured ? Date.parse(data.expiresAt) : Number.NaN);
|
|
9555
9558
|
}
|
|
9556
9559
|
getNextRefreshDelayMs() {
|
|
9557
9560
|
return this.nextRefreshDelayMs;
|
|
@@ -9586,6 +9589,131 @@ async function applyInfisicalCredentials(data, paths) {
|
|
|
9586
9589
|
}
|
|
9587
9590
|
var infisicalTokenManager = new InfisicalTokenManager();
|
|
9588
9591
|
|
|
9592
|
+
// src/managers/workspace-identity-token-manager.ts
|
|
9593
|
+
import { rm as rm2 } from "fs/promises";
|
|
9594
|
+
import path5 from "path";
|
|
9595
|
+
var MAX_REFRESH_MS = 5 * 60 * 1e3;
|
|
9596
|
+
var WorkspaceIdentityTokenManager = class extends BaseRefreshManager {
|
|
9597
|
+
constructor(request = monolithRequest, homeDir = ENGINE_ENV.HOME_DIR) {
|
|
9598
|
+
super("WorkspaceIdentityTokenManager", MAX_REFRESH_MS);
|
|
9599
|
+
this.request = request;
|
|
9600
|
+
this.homeDir = homeDir;
|
|
9601
|
+
}
|
|
9602
|
+
request;
|
|
9603
|
+
homeDir;
|
|
9604
|
+
nextRefreshDelayMs = MAX_REFRESH_MS;
|
|
9605
|
+
bundle = null;
|
|
9606
|
+
async doRefresh() {
|
|
9607
|
+
const response = await this.request("/v1/engine/workspace-identity/token");
|
|
9608
|
+
if (!response.ok) throw new Error(`Workspace identity refresh failed: ${response.status} ${await response.text()}`);
|
|
9609
|
+
const data = await response.json();
|
|
9610
|
+
const bundleFile = path5.join(this.homeDir, ".replicas", "credentials", "tokens.json");
|
|
9611
|
+
const envFile = path5.join(this.homeDir, ".replicas", "workspace-identity-env.sh");
|
|
9612
|
+
if (!data.configured) {
|
|
9613
|
+
this.bundle = null;
|
|
9614
|
+
for (const key of Object.values(WORKSPACE_TOKEN_ENV)) delete process.env[key];
|
|
9615
|
+
await Promise.all([rm2(bundleFile, { force: true }), rm2(envFile, { force: true })]);
|
|
9616
|
+
this.nextRefreshDelayMs = MAX_REFRESH_MS;
|
|
9617
|
+
return;
|
|
9618
|
+
}
|
|
9619
|
+
const { configured: _configured, ...bundle } = data;
|
|
9620
|
+
this.bundle = bundle;
|
|
9621
|
+
const env = {
|
|
9622
|
+
[WORKSPACE_TOKEN_ENV.TOKEN]: currentWorkspaceToken(bundle) ?? "",
|
|
9623
|
+
[WORKSPACE_TOKEN_ENV.TOKEN_FILE]: bundleFile,
|
|
9624
|
+
[WORKSPACE_TOKEN_ENV.AUDIENCE]: bundle.default_audience,
|
|
9625
|
+
[WORKSPACE_TOKEN_ENV.ISSUER]: bundle.issuer
|
|
9626
|
+
};
|
|
9627
|
+
Object.assign(process.env, env);
|
|
9628
|
+
await Promise.all([
|
|
9629
|
+
writeSecureCredentialFile(bundleFile, `${JSON.stringify(bundle)}
|
|
9630
|
+
`, { ensureParentDir: true }),
|
|
9631
|
+
writeSecureCredentialFile(
|
|
9632
|
+
envFile,
|
|
9633
|
+
`${Object.entries(env).map(([key, value]) => `export ${key}=${shellQuotePosix(value)}`).join("\n")}
|
|
9634
|
+
`,
|
|
9635
|
+
{ ensureParentDir: true }
|
|
9636
|
+
)
|
|
9637
|
+
]);
|
|
9638
|
+
this.nextRefreshDelayMs = refreshDelayMs(
|
|
9639
|
+
Math.min(...Object.values(bundle.tokens).map((entry) => Date.parse(entry.expires_at))),
|
|
9640
|
+
MAX_REFRESH_MS
|
|
9641
|
+
);
|
|
9642
|
+
}
|
|
9643
|
+
getNextRefreshDelayMs() {
|
|
9644
|
+
return this.nextRefreshDelayMs;
|
|
9645
|
+
}
|
|
9646
|
+
};
|
|
9647
|
+
var workspaceIdentityTokenManager = new WorkspaceIdentityTokenManager();
|
|
9648
|
+
|
|
9649
|
+
// src/identity-proxy.ts
|
|
9650
|
+
import http from "http";
|
|
9651
|
+
import https from "https";
|
|
9652
|
+
var STRIPPED_HEADERS = /* @__PURE__ */ new Set([
|
|
9653
|
+
"authorization",
|
|
9654
|
+
"proxy-authorization",
|
|
9655
|
+
"cookie",
|
|
9656
|
+
"host",
|
|
9657
|
+
"connection",
|
|
9658
|
+
"keep-alive",
|
|
9659
|
+
"proxy-connection",
|
|
9660
|
+
"te",
|
|
9661
|
+
"trailer",
|
|
9662
|
+
"upgrade"
|
|
9663
|
+
]);
|
|
9664
|
+
var decode = (segment) => Buffer.from(segment, "base64url").toString("utf8");
|
|
9665
|
+
function resolveIdentityRoute(requestUrl) {
|
|
9666
|
+
const url3 = new URL(requestUrl, "http://127.0.0.1");
|
|
9667
|
+
const [, kind, encodedAudience, encodedTarget, ...rest] = url3.pathname.split("/");
|
|
9668
|
+
if (kind !== "identity" || !encodedAudience || !encodedTarget) return null;
|
|
9669
|
+
let target;
|
|
9670
|
+
try {
|
|
9671
|
+
target = new URL(decode(encodedTarget));
|
|
9672
|
+
} catch {
|
|
9673
|
+
return null;
|
|
9674
|
+
}
|
|
9675
|
+
const loopback = target.hostname === "localhost" || target.hostname === "127.0.0.1";
|
|
9676
|
+
if (target.protocol !== "https:" && !(target.protocol === "http:" && loopback)) return null;
|
|
9677
|
+
target.pathname = [target.pathname.replace(/\/$/, ""), ...rest].join("/") || "/";
|
|
9678
|
+
target.search = url3.search;
|
|
9679
|
+
return { target, audience: decode(encodedAudience) };
|
|
9680
|
+
}
|
|
9681
|
+
function createIdentityProxy(getBundle) {
|
|
9682
|
+
return http.createServer((request, response) => {
|
|
9683
|
+
const route = resolveIdentityRoute(request.url ?? "/");
|
|
9684
|
+
if (!route) {
|
|
9685
|
+
response.writeHead(404).end("Unknown identity route");
|
|
9686
|
+
return;
|
|
9687
|
+
}
|
|
9688
|
+
const bundle = getBundle();
|
|
9689
|
+
const token = bundle && currentWorkspaceToken(bundle, route.audience);
|
|
9690
|
+
if (!token) {
|
|
9691
|
+
response.writeHead(503).end("Workspace token unavailable; waiting for renewal");
|
|
9692
|
+
return;
|
|
9693
|
+
}
|
|
9694
|
+
const headers = { host: route.target.host };
|
|
9695
|
+
for (const [name, value] of Object.entries(request.headers)) {
|
|
9696
|
+
if (!STRIPPED_HEADERS.has(name) && !name.startsWith("x-replicas-") && value !== void 0) headers[name] = value;
|
|
9697
|
+
}
|
|
9698
|
+
headers.authorization = `Bearer ${token}`;
|
|
9699
|
+
const upstream = (route.target.protocol === "https:" ? https : http).request(
|
|
9700
|
+
route.target,
|
|
9701
|
+
{ method: request.method, headers },
|
|
9702
|
+
(incoming) => {
|
|
9703
|
+
response.writeHead(incoming.statusCode ?? 502, incoming.headers);
|
|
9704
|
+
incoming.pipe(response);
|
|
9705
|
+
response.on("close", () => incoming.destroy());
|
|
9706
|
+
}
|
|
9707
|
+
);
|
|
9708
|
+
upstream.on("error", () => {
|
|
9709
|
+
if (!response.headersSent) response.writeHead(502);
|
|
9710
|
+
response.end();
|
|
9711
|
+
});
|
|
9712
|
+
response.on("close", () => upstream.destroy());
|
|
9713
|
+
request.pipe(upstream);
|
|
9714
|
+
});
|
|
9715
|
+
}
|
|
9716
|
+
|
|
9589
9717
|
// src/utils/logger.ts
|
|
9590
9718
|
import { mkdir as mkdir3, writeFile as writeFile2 } from "fs/promises";
|
|
9591
9719
|
import { homedir as homedir2 } from "os";
|
|
@@ -9601,8 +9729,8 @@ var StreamWriter = class {
|
|
|
9601
9729
|
backpressured = false;
|
|
9602
9730
|
droppedCount = 0;
|
|
9603
9731
|
flushTimer = null;
|
|
9604
|
-
open(
|
|
9605
|
-
this.stream = createWriteStream(
|
|
9732
|
+
open(path8, highWaterMark = DEFAULT_HIGH_WATER) {
|
|
9733
|
+
this.stream = createWriteStream(path8, { flags: "a", highWaterMark });
|
|
9606
9734
|
this.stream.on("error", () => {
|
|
9607
9735
|
this.stream = null;
|
|
9608
9736
|
});
|
|
@@ -10712,7 +10840,7 @@ async function registerDesktopPreview() {
|
|
|
10712
10840
|
}
|
|
10713
10841
|
|
|
10714
10842
|
// src/services/chat/chat-service.ts
|
|
10715
|
-
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir22, readFile as readFile22, rename as rename5, rm as
|
|
10843
|
+
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir22, readFile as readFile22, rename as rename5, rm as rm5 } from "fs/promises";
|
|
10716
10844
|
import { join as join37 } from "path";
|
|
10717
10845
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
10718
10846
|
|
|
@@ -11361,7 +11489,7 @@ async function saveNormalizedImagesToTempFiles(images, tempImageDir = join13(hom
|
|
|
11361
11489
|
return tempPaths;
|
|
11362
11490
|
}
|
|
11363
11491
|
async function removeTempImageFiles(paths) {
|
|
11364
|
-
await Promise.allSettled(paths.map((
|
|
11492
|
+
await Promise.allSettled(paths.map((path8) => unlink2(path8)));
|
|
11365
11493
|
}
|
|
11366
11494
|
|
|
11367
11495
|
// src/managers/coding-agent-manager.ts
|
|
@@ -12256,7 +12384,7 @@ async function getSkillRegistryInventory(homeDir) {
|
|
|
12256
12384
|
async function buildClaudeRegistryConfig(homeDir) {
|
|
12257
12385
|
const inventory = await getSkillRegistryInventory(homeDir);
|
|
12258
12386
|
return {
|
|
12259
|
-
plugins: inventory.claudePluginRoots.map((
|
|
12387
|
+
plugins: inventory.claudePluginRoots.map((path8) => ({ type: "local", path: path8 })),
|
|
12260
12388
|
enableAllSkills: inventory.claudePluginRoots.length > 0 || inventory.standaloneSkills.length > 0
|
|
12261
12389
|
};
|
|
12262
12390
|
}
|
|
@@ -12414,31 +12542,31 @@ function uniqueStandaloneSkills(skills) {
|
|
|
12414
12542
|
}
|
|
12415
12543
|
return unique;
|
|
12416
12544
|
}
|
|
12417
|
-
async function safeReadDir(
|
|
12545
|
+
async function safeReadDir(path8) {
|
|
12418
12546
|
try {
|
|
12419
|
-
return await readdir3(
|
|
12547
|
+
return await readdir3(path8, { withFileTypes: true });
|
|
12420
12548
|
} catch (error) {
|
|
12421
12549
|
if (isNotFoundError(error)) return [];
|
|
12422
12550
|
throw error;
|
|
12423
12551
|
}
|
|
12424
12552
|
}
|
|
12425
|
-
async function isDirectoryDirent(dirent,
|
|
12553
|
+
async function isDirectoryDirent(dirent, path8) {
|
|
12426
12554
|
if (dirent.isDirectory()) return true;
|
|
12427
12555
|
if (!dirent.isSymbolicLink()) return false;
|
|
12428
|
-
return directoryExists(
|
|
12556
|
+
return directoryExists(path8);
|
|
12429
12557
|
}
|
|
12430
|
-
async function directoryExists(
|
|
12558
|
+
async function directoryExists(path8) {
|
|
12431
12559
|
try {
|
|
12432
|
-
const pathStat = await stat2(
|
|
12560
|
+
const pathStat = await stat2(path8);
|
|
12433
12561
|
return pathStat.isDirectory();
|
|
12434
12562
|
} catch (error) {
|
|
12435
12563
|
if (isNotFoundError(error)) return false;
|
|
12436
12564
|
throw error;
|
|
12437
12565
|
}
|
|
12438
12566
|
}
|
|
12439
|
-
async function fileExists(
|
|
12567
|
+
async function fileExists(path8) {
|
|
12440
12568
|
try {
|
|
12441
|
-
const pathStat = await stat2(
|
|
12569
|
+
const pathStat = await stat2(path8);
|
|
12442
12570
|
return pathStat.isFile();
|
|
12443
12571
|
} catch (error) {
|
|
12444
12572
|
if (isNotFoundError(error)) return false;
|
|
@@ -14344,16 +14472,16 @@ function transcriptItemsForTurn(turn) {
|
|
|
14344
14472
|
const otherItems = turn.items.filter((item) => item.type !== "userMessage");
|
|
14345
14473
|
return [...userItems, ...otherItems];
|
|
14346
14474
|
}
|
|
14347
|
-
function userImageForLocalPath(
|
|
14348
|
-
const cached = localImageCache.get(
|
|
14475
|
+
function userImageForLocalPath(path8) {
|
|
14476
|
+
const cached = localImageCache.get(path8);
|
|
14349
14477
|
if (cached) return cached;
|
|
14350
|
-
if (!existsSync7(
|
|
14478
|
+
if (!existsSync7(path8)) return null;
|
|
14351
14479
|
const image = {
|
|
14352
14480
|
type: "image",
|
|
14353
|
-
mediaType: inferMediaType(
|
|
14354
|
-
data: readFileSync3(
|
|
14481
|
+
mediaType: inferMediaType(path8),
|
|
14482
|
+
data: readFileSync3(path8).toString("base64")
|
|
14355
14483
|
};
|
|
14356
|
-
if (image.data.length > 0) localImageCache.set(
|
|
14484
|
+
if (image.data.length > 0) localImageCache.set(path8, image);
|
|
14357
14485
|
return image;
|
|
14358
14486
|
}
|
|
14359
14487
|
function userImagesForInput(input) {
|
|
@@ -14644,9 +14772,9 @@ async function buildTurnInput(request) {
|
|
|
14644
14772
|
}
|
|
14645
14773
|
const normalizedImages = await normalizeImages(request.images);
|
|
14646
14774
|
const tempImagePaths = await saveNormalizedImagesToTempFiles(normalizedImages);
|
|
14647
|
-
input.push(...tempImagePaths.map((
|
|
14775
|
+
input.push(...tempImagePaths.map((path8) => ({
|
|
14648
14776
|
type: "localImage",
|
|
14649
|
-
path:
|
|
14777
|
+
path: path8
|
|
14650
14778
|
})));
|
|
14651
14779
|
return { input, tempImagePaths };
|
|
14652
14780
|
}
|
|
@@ -15847,12 +15975,12 @@ var postToolHookPath = [
|
|
|
15847
15975
|
join18(moduleDirectory, "post-tool-pr-hook.js"),
|
|
15848
15976
|
join18(moduleDirectory, "..", "post-tool-pr-hook.ts")
|
|
15849
15977
|
].find(existsSync8);
|
|
15850
|
-
function shellCommand(
|
|
15851
|
-
if (!
|
|
15978
|
+
function shellCommand(path8, provider) {
|
|
15979
|
+
if (!path8) throw new Error("Replicas hook executable is missing.");
|
|
15852
15980
|
const args = [
|
|
15853
15981
|
process.execPath,
|
|
15854
|
-
...
|
|
15855
|
-
|
|
15982
|
+
...path8.endsWith(".ts") && basename(process.execPath) !== "bun" ? ["--import", "tsx"] : [],
|
|
15983
|
+
path8,
|
|
15856
15984
|
...provider ? [provider] : []
|
|
15857
15985
|
];
|
|
15858
15986
|
return args.map((value) => `'${value.replaceAll("'", "'\\''")}'`).join(" ");
|
|
@@ -15866,10 +15994,10 @@ function getPostToolPrHookPath() {
|
|
|
15866
15994
|
return postToolHookPath;
|
|
15867
15995
|
}
|
|
15868
15996
|
async function ensureCursorCommandProtectionHook() {
|
|
15869
|
-
const
|
|
15997
|
+
const path8 = join18(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
|
|
15870
15998
|
let config = {};
|
|
15871
15999
|
try {
|
|
15872
|
-
const parsed = JSON.parse(await readFile11(
|
|
16000
|
+
const parsed = JSON.parse(await readFile11(path8, "utf8"));
|
|
15873
16001
|
if (!isRecord2(parsed)) throw new Error("Invalid Cursor hooks configuration.");
|
|
15874
16002
|
config = parsed;
|
|
15875
16003
|
} catch (error) {
|
|
@@ -15886,15 +16014,15 @@ async function ensureCursorCommandProtectionHook() {
|
|
|
15886
16014
|
...existingPost.filter((entry) => !isRecord2(entry) || typeof entry.command !== "string" || !entry.command.includes("post-tool-pr-hook")),
|
|
15887
16015
|
{ command: shellCommand(postToolHookPath) }
|
|
15888
16016
|
];
|
|
15889
|
-
await mkdir12(dirname5(
|
|
15890
|
-
await writeFile7(
|
|
16017
|
+
await mkdir12(dirname5(path8), { recursive: true });
|
|
16018
|
+
await writeFile7(path8, `${JSON.stringify({ ...config, version: 1, hooks }, null, 2)}
|
|
15891
16019
|
`, "utf8");
|
|
15892
16020
|
}
|
|
15893
16021
|
async function ensureGeminiCommandProtectionHook() {
|
|
15894
|
-
const
|
|
16022
|
+
const path8 = join18(ENGINE_ENV.HOME_DIR, ".gemini", "settings.json");
|
|
15895
16023
|
let config = {};
|
|
15896
16024
|
try {
|
|
15897
|
-
const parsed = JSON.parse(await readFile11(
|
|
16025
|
+
const parsed = JSON.parse(await readFile11(path8, "utf8"));
|
|
15898
16026
|
if (!isRecord2(parsed)) throw new Error("Invalid Gemini hooks configuration.");
|
|
15899
16027
|
config = parsed;
|
|
15900
16028
|
} catch (error) {
|
|
@@ -15914,17 +16042,17 @@ async function ensureGeminiCommandProtectionHook() {
|
|
|
15914
16042
|
...without(hooks.AfterTool, "replicas-post-tool-pr-check"),
|
|
15915
16043
|
hook("replicas-post-tool-pr-check", shellCommand(postToolHookPath))
|
|
15916
16044
|
];
|
|
15917
|
-
await mkdir12(dirname5(
|
|
15918
|
-
await writeFile7(
|
|
16045
|
+
await mkdir12(dirname5(path8), { recursive: true });
|
|
16046
|
+
await writeFile7(path8, `${JSON.stringify({ ...config, hooks }, null, 2)}
|
|
15919
16047
|
`, "utf8");
|
|
15920
16048
|
}
|
|
15921
16049
|
async function ensureKimiCommandProtectionHook() {
|
|
15922
|
-
const
|
|
16050
|
+
const path8 = join18(ENGINE_ENV.HOME_DIR, ".kimi-code", "config.toml");
|
|
15923
16051
|
const start = "# Replicas command protection hook";
|
|
15924
16052
|
const end = "# End Replicas command protection hook";
|
|
15925
16053
|
let config = "";
|
|
15926
16054
|
try {
|
|
15927
|
-
config = await readFile11(
|
|
16055
|
+
config = await readFile11(path8, "utf8");
|
|
15928
16056
|
} catch (error) {
|
|
15929
16057
|
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
|
|
15930
16058
|
}
|
|
@@ -15943,8 +16071,8 @@ ${end}`;
|
|
|
15943
16071
|
const markerEnd = config.indexOf(end, markerStart + start.length);
|
|
15944
16072
|
config = markerStart >= 0 && markerEnd >= 0 ? `${config.slice(0, markerStart)}${block}${config.slice(markerEnd + end.length)}` : `${config.trimEnd()}${config.trim() ? "\n\n" : ""}${block}
|
|
15945
16073
|
`;
|
|
15946
|
-
await mkdir12(dirname5(
|
|
15947
|
-
await writeFile7(
|
|
16074
|
+
await mkdir12(dirname5(path8), { recursive: true });
|
|
16075
|
+
await writeFile7(path8, config, "utf8");
|
|
15948
16076
|
}
|
|
15949
16077
|
|
|
15950
16078
|
// src/managers/cursor-run-recovery.ts
|
|
@@ -16513,8 +16641,8 @@ var DeepseekApiClient = class extends AbstractApiClient {
|
|
|
16513
16641
|
if (!execution.success) throw new Error(`DeepSeek Harness did not recognize ${line}.`);
|
|
16514
16642
|
if (execution.data.result.kind === "error") throw new Error(execution.data.result.text ?? `DeepSeek Harness rejected ${line}.`);
|
|
16515
16643
|
}
|
|
16516
|
-
async *readWebSocket(
|
|
16517
|
-
const url3 = new URL(
|
|
16644
|
+
async *readWebSocket(path8, signal, schema, onOpen) {
|
|
16645
|
+
const url3 = new URL(path8, this.baseUrl);
|
|
16518
16646
|
url3.protocol = url3.protocol === "https:" ? "wss:" : "ws:";
|
|
16519
16647
|
const socket = new WebSocket(url3);
|
|
16520
16648
|
const inbox = [];
|
|
@@ -18059,7 +18187,7 @@ ${pending}
|
|
|
18059
18187
|
|
|
18060
18188
|
// src/managers/opencode-manager.ts
|
|
18061
18189
|
import { existsSync as existsSync10 } from "fs";
|
|
18062
|
-
import { copyFile, mkdir as mkdir17, readFile as readFile16, rm as
|
|
18190
|
+
import { copyFile, mkdir as mkdir17, readFile as readFile16, rm as rm3 } from "fs/promises";
|
|
18063
18191
|
import { delimiter, dirname as dirname10, join as join22 } from "path";
|
|
18064
18192
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
18065
18193
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -18421,7 +18549,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18421
18549
|
}
|
|
18422
18550
|
await mkdir17(dirname10(OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH), { recursive: true });
|
|
18423
18551
|
await copyFile(OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE, OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH);
|
|
18424
|
-
await
|
|
18552
|
+
await rm3(OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH, { force: true });
|
|
18425
18553
|
process.env.REPLICAS_COMMAND_PROTECTION_HOOK_PATH = getCommandProtectionHookPath();
|
|
18426
18554
|
process.env.REPLICAS_POST_TOOL_PR_HOOK_PATH = getPostToolPrHookPath();
|
|
18427
18555
|
process.env.REPLICAS_COMMAND_PROTECTION_RUNTIME_PATH = process.execPath;
|
|
@@ -19803,15 +19931,15 @@ function Get2() {
|
|
|
19803
19931
|
|
|
19804
19932
|
// ../node_modules/.bun/typebox@1.3.7/node_modules/typebox/build/type/types/_codec.mjs
|
|
19805
19933
|
var EncodeBuilder = class {
|
|
19806
|
-
constructor(type,
|
|
19934
|
+
constructor(type, decode2) {
|
|
19807
19935
|
this.type = type;
|
|
19808
|
-
this.decode =
|
|
19936
|
+
this.decode = decode2;
|
|
19809
19937
|
}
|
|
19810
19938
|
Encode(callback) {
|
|
19811
19939
|
const type = this.type;
|
|
19812
|
-
const
|
|
19940
|
+
const decode2 = IsCodec(type) ? (value) => this.decode(type["~codec"].decode(value)) : this.decode;
|
|
19813
19941
|
const encode = IsCodec(type) ? (value) => type["~codec"].encode(callback(value)) : callback;
|
|
19814
|
-
const codec = { decode, encode };
|
|
19942
|
+
const codec = { decode: decode2, encode };
|
|
19815
19943
|
return memory_exports.Update(this.type, { "~codec": codec }, {});
|
|
19816
19944
|
}
|
|
19817
19945
|
};
|
|
@@ -27311,9 +27439,9 @@ var rev2026Codec = {
|
|
|
27311
27439
|
});
|
|
27312
27440
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta);
|
|
27313
27441
|
if (!parsed.success) for (const issue of parsed.error.issues) {
|
|
27314
|
-
const
|
|
27315
|
-
const key =
|
|
27316
|
-
if (
|
|
27442
|
+
const path8 = issue.path.map(String);
|
|
27443
|
+
const key = path8.length > 0 ? path8.join(".") : "_meta";
|
|
27444
|
+
if (path8.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing")) continue;
|
|
27317
27445
|
issues.push({
|
|
27318
27446
|
key,
|
|
27319
27447
|
problem: issue.message
|
|
@@ -27612,29 +27740,29 @@ var PERMITTED_X_MCP_HEADER_TYPES = /* @__PURE__ */ new Set([
|
|
|
27612
27740
|
function scanXMcpHeaderDeclarations(inputSchema) {
|
|
27613
27741
|
const declarations = [];
|
|
27614
27742
|
const seenLower = /* @__PURE__ */ new Map();
|
|
27615
|
-
const visit = (node,
|
|
27743
|
+
const visit = (node, path8, reachable) => {
|
|
27616
27744
|
if (node === null || typeof node !== "object") return void 0;
|
|
27617
27745
|
const schema = node;
|
|
27618
27746
|
if (X_MCP_HEADER_KEY in schema) {
|
|
27619
|
-
if (!reachable ||
|
|
27747
|
+
if (!reachable || path8.length === 0) return `${pathName(path8)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;
|
|
27620
27748
|
const raw = schema[X_MCP_HEADER_KEY];
|
|
27621
|
-
if (typeof raw !== "string" || raw.length === 0) return `${pathName(
|
|
27622
|
-
if (!RFC9110_TOKEN.test(raw)) return `${pathName(
|
|
27749
|
+
if (typeof raw !== "string" || raw.length === 0) return `${pathName(path8)}: x-mcp-header MUST be a non-empty string`;
|
|
27750
|
+
if (!RFC9110_TOKEN.test(raw)) return `${pathName(path8)}: x-mcp-header '${raw}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;
|
|
27623
27751
|
const type = typeof schema.type === "string" ? schema.type : void 0;
|
|
27624
|
-
if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(
|
|
27752
|
+
if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(path8)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${type ?? "<none>"}`;
|
|
27625
27753
|
const lower = raw.toLowerCase();
|
|
27626
27754
|
const prior = seenLower.get(lower);
|
|
27627
27755
|
if (prior !== void 0) return `x-mcp-header '${raw}' is not case-insensitively unique (also declared as '${prior}')`;
|
|
27628
27756
|
seenLower.set(lower, raw);
|
|
27629
27757
|
declarations.push({
|
|
27630
|
-
path:
|
|
27758
|
+
path: path8,
|
|
27631
27759
|
headerName: raw,
|
|
27632
27760
|
type
|
|
27633
27761
|
});
|
|
27634
27762
|
}
|
|
27635
27763
|
const properties = schema.properties;
|
|
27636
27764
|
if (properties !== null && typeof properties === "object") for (const [key, child] of Object.entries(properties)) {
|
|
27637
|
-
const fault$1 = visit(child, [...
|
|
27765
|
+
const fault$1 = visit(child, [...path8, key], reachable);
|
|
27638
27766
|
if (fault$1 !== void 0) return fault$1;
|
|
27639
27767
|
}
|
|
27640
27768
|
for (const k of NON_REACHABLE_SUBSCHEMA_KEYWORDS) {
|
|
@@ -27642,7 +27770,7 @@ function scanXMcpHeaderDeclarations(inputSchema) {
|
|
|
27642
27770
|
if (sub === void 0) continue;
|
|
27643
27771
|
const branches = Array.isArray(sub) ? sub : sub !== null && typeof sub === "object" && OBJECT_VALUED_SUBSCHEMA_KEYWORDS.has(k) ? Object.values(sub) : [sub];
|
|
27644
27772
|
for (const branch of branches) {
|
|
27645
|
-
const fault$1 = visit(branch, [...
|
|
27773
|
+
const fault$1 = visit(branch, [...path8, `<${k}>`], false);
|
|
27646
27774
|
if (fault$1 !== void 0) return fault$1;
|
|
27647
27775
|
}
|
|
27648
27776
|
}
|
|
@@ -27682,8 +27810,8 @@ var OBJECT_VALUED_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
27682
27810
|
"$defs",
|
|
27683
27811
|
"definitions"
|
|
27684
27812
|
]);
|
|
27685
|
-
function pathName(
|
|
27686
|
-
return
|
|
27813
|
+
function pathName(path8) {
|
|
27814
|
+
return path8.length === 0 ? "<root>" : path8.join(".");
|
|
27687
27815
|
}
|
|
27688
27816
|
var BASE64_SENTINEL_PREFIX = "=?base64?";
|
|
27689
27817
|
var BASE64_SENTINEL_SUFFIX = "?=";
|
|
@@ -27716,9 +27844,9 @@ function utf8ToBase64(s) {
|
|
|
27716
27844
|
function encodeMcpParamValue(value) {
|
|
27717
27845
|
return needsBase64(value) ? `${BASE64_SENTINEL_PREFIX}${utf8ToBase64(value)}${BASE64_SENTINEL_SUFFIX}` : value;
|
|
27718
27846
|
}
|
|
27719
|
-
function valueAtPath(root,
|
|
27847
|
+
function valueAtPath(root, path8) {
|
|
27720
27848
|
let node = root;
|
|
27721
|
-
for (const key of
|
|
27849
|
+
for (const key of path8) {
|
|
27722
27850
|
if (node === null || typeof node !== "object") return void 0;
|
|
27723
27851
|
node = node[key];
|
|
27724
27852
|
}
|
|
@@ -27973,7 +28101,7 @@ var PROPERTY_KEYS_BY_TYPE = {
|
|
|
27973
28101
|
array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
|
|
27974
28102
|
};
|
|
27975
28103
|
var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
|
|
27976
|
-
function walkProperty(node,
|
|
28104
|
+
function walkProperty(node, path8, vendor, unsupported) {
|
|
27977
28105
|
if (!isJsonObject(node)) return node;
|
|
27978
28106
|
const allowedKeys = typeof node.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node.type) ? PROPERTY_KEYS_BY_TYPE[node.type] : void 0;
|
|
27979
28107
|
if (allowedKeys === void 0) return node;
|
|
@@ -27981,8 +28109,8 @@ function walkProperty(node, path7, vendor, unsupported) {
|
|
|
27981
28109
|
for (const [key, value] of Object.entries(node)) if (allowedKeys.has(key) || isAnnotationOnlyJsonSchemaKeyword(key)) pruned[key] = value;
|
|
27982
28110
|
else if (key === "pattern" && node.type === "string" && typeof node.format === "string") {
|
|
27983
28111
|
if (!SUPPORTED_STRING_FORMATS.has(node.format)) pruned[key] = value;
|
|
27984
|
-
else if (typeof value !== "string" || !isLibraryFormatPattern(node.format, value, vendor)) unsupported.push(`${
|
|
27985
|
-
} else unsupported.push(`${
|
|
28112
|
+
else if (typeof value !== "string" || !isLibraryFormatPattern(node.format, value, vendor)) unsupported.push(`${path8}.${key}`);
|
|
28113
|
+
} else unsupported.push(`${path8}.${key}`);
|
|
27986
28114
|
return pruned;
|
|
27987
28115
|
}
|
|
27988
28116
|
function walkRequestedSchema(converted, vendor) {
|
|
@@ -27999,11 +28127,11 @@ function describeUnsupportedProperties(pruned, fallback) {
|
|
|
27999
28127
|
const offenders = Object.entries(pruned.properties).filter(([, node]) => !parseSchema(PrimitiveSchemaDefinitionSchema, node).success).map(([name]) => `properties.${name}`);
|
|
28000
28128
|
return offenders.length > 0 ? offenders.join(", ") : fallback;
|
|
28001
28129
|
}
|
|
28002
|
-
function findDroppedConstraintPaths(original, parsed,
|
|
28003
|
-
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${
|
|
28130
|
+
function findDroppedConstraintPaths(original, parsed, path8 = "") {
|
|
28131
|
+
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path8}[${index}]`));
|
|
28004
28132
|
if (!isJsonObject(original) || !isJsonObject(parsed)) return [];
|
|
28005
28133
|
return Object.entries(original).flatMap(([key, value]) => {
|
|
28006
|
-
const childPath =
|
|
28134
|
+
const childPath = path8 ? `${path8}.${key}` : key;
|
|
28007
28135
|
if (!Object.prototype.hasOwnProperty.call(parsed, key)) return isAnnotationOnlyJsonSchemaKeyword(key) ? [] : [childPath];
|
|
28008
28136
|
return findDroppedConstraintPaths(value, parsed[key], childPath);
|
|
28009
28137
|
});
|
|
@@ -32183,8 +32311,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32183
32311
|
for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
|
|
32184
32312
|
return ind;
|
|
32185
32313
|
}
|
|
32186
|
-
function removeDotSegments(
|
|
32187
|
-
let input =
|
|
32314
|
+
function removeDotSegments(path8) {
|
|
32315
|
+
let input = path8;
|
|
32188
32316
|
const output = [];
|
|
32189
32317
|
let nextSlash = -1;
|
|
32190
32318
|
let len = 0;
|
|
@@ -32337,8 +32465,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32337
32465
|
wsComponent.secure = void 0;
|
|
32338
32466
|
}
|
|
32339
32467
|
if (wsComponent.resourceName) {
|
|
32340
|
-
const [
|
|
32341
|
-
wsComponent.path =
|
|
32468
|
+
const [path8, query2] = wsComponent.resourceName.split("?");
|
|
32469
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
32342
32470
|
wsComponent.query = query2;
|
|
32343
32471
|
wsComponent.resourceName = void 0;
|
|
32344
32472
|
}
|
|
@@ -32385,15 +32513,15 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32385
32513
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
32386
32514
|
return urnComponent;
|
|
32387
32515
|
}
|
|
32388
|
-
const
|
|
32516
|
+
const http3 = {
|
|
32389
32517
|
scheme: "http",
|
|
32390
32518
|
domainHost: true,
|
|
32391
32519
|
parse: httpParse,
|
|
32392
32520
|
serialize: httpSerialize
|
|
32393
32521
|
};
|
|
32394
|
-
const
|
|
32522
|
+
const https2 = {
|
|
32395
32523
|
scheme: "https",
|
|
32396
|
-
domainHost:
|
|
32524
|
+
domainHost: http3.domainHost,
|
|
32397
32525
|
parse: httpParse,
|
|
32398
32526
|
serialize: httpSerialize
|
|
32399
32527
|
};
|
|
@@ -32422,8 +32550,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32422
32550
|
skipNormalize: true
|
|
32423
32551
|
};
|
|
32424
32552
|
const SCHEMES = {
|
|
32425
|
-
http:
|
|
32426
|
-
https,
|
|
32553
|
+
http: http3,
|
|
32554
|
+
https: https2,
|
|
32427
32555
|
ws,
|
|
32428
32556
|
wss,
|
|
32429
32557
|
urn,
|
|
@@ -41657,8 +41785,8 @@ function getNpmCacheDir() {
|
|
|
41657
41785
|
try {
|
|
41658
41786
|
const result = import_cross_spawn2.default.sync("npm", ["config", "get", "cache"], { encoding: "utf-8" });
|
|
41659
41787
|
if (result.status === 0) {
|
|
41660
|
-
const
|
|
41661
|
-
npmCacheDirCached =
|
|
41788
|
+
const path8 = String(result.stdout).trim();
|
|
41789
|
+
npmCacheDirCached = path8 || null;
|
|
41662
41790
|
return npmCacheDirCached;
|
|
41663
41791
|
}
|
|
41664
41792
|
} catch {
|
|
@@ -41746,16 +41874,16 @@ function saveCacheEntry(key, entry) {
|
|
|
41746
41874
|
} catch {
|
|
41747
41875
|
}
|
|
41748
41876
|
}
|
|
41749
|
-
function safeRealpath(
|
|
41877
|
+
function safeRealpath(path8) {
|
|
41750
41878
|
try {
|
|
41751
|
-
return realpathSync(
|
|
41879
|
+
return realpathSync(path8);
|
|
41752
41880
|
} catch {
|
|
41753
41881
|
return "";
|
|
41754
41882
|
}
|
|
41755
41883
|
}
|
|
41756
|
-
function safeStatMtime(
|
|
41884
|
+
function safeStatMtime(path8) {
|
|
41757
41885
|
try {
|
|
41758
|
-
return statSync(
|
|
41886
|
+
return statSync(path8).mtimeMs;
|
|
41759
41887
|
} catch {
|
|
41760
41888
|
return 0;
|
|
41761
41889
|
}
|
|
@@ -42500,8 +42628,8 @@ function setOAuthCallbackPort(port2) {
|
|
|
42500
42628
|
function getOAuthCallbackPath() {
|
|
42501
42629
|
return oauthCallbackPath;
|
|
42502
42630
|
}
|
|
42503
|
-
function setOAuthCallbackPath(
|
|
42504
|
-
oauthCallbackPath =
|
|
42631
|
+
function setOAuthCallbackPath(path8) {
|
|
42632
|
+
oauthCallbackPath = path8.startsWith("/") ? path8 : `/${path8}`;
|
|
42505
42633
|
}
|
|
42506
42634
|
var reservedAuthorizationParams = /* @__PURE__ */ new Set([
|
|
42507
42635
|
"client_id",
|
|
@@ -43014,7 +43142,7 @@ var McpOAuthProvider = class {
|
|
|
43014
43142
|
// ../node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
43015
43143
|
import process9 from "process";
|
|
43016
43144
|
import { Buffer as Buffer2 } from "buffer";
|
|
43017
|
-
import
|
|
43145
|
+
import path6 from "path";
|
|
43018
43146
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
43019
43147
|
import { promisify as promisify5 } from "util";
|
|
43020
43148
|
import childProcess from "child_process";
|
|
@@ -43272,8 +43400,8 @@ async function defaultBrowser2() {
|
|
|
43272
43400
|
|
|
43273
43401
|
// ../node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
43274
43402
|
var execFile5 = promisify5(childProcess.execFile);
|
|
43275
|
-
var __dirname =
|
|
43276
|
-
var localXdgOpenPath =
|
|
43403
|
+
var __dirname = path6.dirname(fileURLToPath5(import.meta.url));
|
|
43404
|
+
var localXdgOpenPath = path6.join(__dirname, "xdg-open");
|
|
43277
43405
|
var { platform, arch } = process9;
|
|
43278
43406
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
43279
43407
|
const powershellPath = await powerShellPath();
|
|
@@ -45472,14 +45600,14 @@ var McpTraceWriter = class {
|
|
|
45472
45600
|
this.options = options;
|
|
45473
45601
|
this.maxBytes = boundedPositiveInteger(options.maxBytes, DEFAULT_MCP_TRACE_MAX_BYTES);
|
|
45474
45602
|
this.maxEvents = boundedPositiveInteger(options.maxEvents, DEFAULT_MCP_TRACE_MAX_EVENTS);
|
|
45475
|
-
this.append = options.appendFile ?? (async (
|
|
45476
|
-
await appendFile3(
|
|
45603
|
+
this.append = options.appendFile ?? (async (path8, data, appendOptions) => {
|
|
45604
|
+
await appendFile3(path8, data, appendOptions);
|
|
45477
45605
|
});
|
|
45478
|
-
this.resetFile = options.writeFile ?? (async (
|
|
45479
|
-
await writeFile10(
|
|
45606
|
+
this.resetFile = options.writeFile ?? (async (path8, data, writeOptions) => {
|
|
45607
|
+
await writeFile10(path8, data, writeOptions);
|
|
45480
45608
|
});
|
|
45481
|
-
this.makeDirectory = options.mkdir ?? (async (
|
|
45482
|
-
await mkdir18(
|
|
45609
|
+
this.makeDirectory = options.mkdir ?? (async (path8) => {
|
|
45610
|
+
await mkdir18(path8, { recursive: true });
|
|
45483
45611
|
return void 0;
|
|
45484
45612
|
});
|
|
45485
45613
|
this.fileReady = this.makeDirectory(dirname14(this.options.filePath), { recursive: true }).then(() => this.resetFile(this.options.filePath, "", { encoding: "utf8" })).catch(() => {
|
|
@@ -48618,10 +48746,10 @@ function getOnboardingStatePath() {
|
|
|
48618
48746
|
return getAgentPath("mcp-onboarding.json");
|
|
48619
48747
|
}
|
|
48620
48748
|
function loadOnboardingState() {
|
|
48621
|
-
const
|
|
48622
|
-
if (!existsSync14(
|
|
48749
|
+
const path8 = getOnboardingStatePath();
|
|
48750
|
+
if (!existsSync14(path8)) return { ...DEFAULT_STATE2 };
|
|
48623
48751
|
try {
|
|
48624
|
-
const raw = JSON.parse(readFileSync6(
|
|
48752
|
+
const raw = JSON.parse(readFileSync6(path8, "utf-8"));
|
|
48625
48753
|
if (!raw || typeof raw !== "object") return { ...DEFAULT_STATE2 };
|
|
48626
48754
|
return {
|
|
48627
48755
|
version: 1,
|
|
@@ -48634,12 +48762,12 @@ function loadOnboardingState() {
|
|
|
48634
48762
|
}
|
|
48635
48763
|
}
|
|
48636
48764
|
function saveOnboardingState(state) {
|
|
48637
|
-
const
|
|
48638
|
-
mkdirSync3(dirname15(
|
|
48639
|
-
const tmpPath = `${
|
|
48765
|
+
const path8 = getOnboardingStatePath();
|
|
48766
|
+
mkdirSync3(dirname15(path8), { recursive: true });
|
|
48767
|
+
const tmpPath = `${path8}.${process.pid}.tmp`;
|
|
48640
48768
|
writeFileSync2(tmpPath, `${JSON.stringify(state, null, 2)}
|
|
48641
48769
|
`, "utf-8");
|
|
48642
|
-
renameSync2(tmpPath,
|
|
48770
|
+
renameSync2(tmpPath, path8);
|
|
48643
48771
|
}
|
|
48644
48772
|
function updateOnboardingState(updater) {
|
|
48645
48773
|
const next = updater(loadOnboardingState());
|
|
@@ -49052,23 +49180,23 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
|
|
|
49052
49180
|
return result;
|
|
49053
49181
|
},
|
|
49054
49182
|
scaffoldConfig: async (target) => {
|
|
49055
|
-
const
|
|
49183
|
+
const path8 = writeStarterSharedConfig(target, ctx.cwd);
|
|
49056
49184
|
configChanged = true;
|
|
49057
|
-
return { path:
|
|
49185
|
+
return { path: path8 };
|
|
49058
49186
|
},
|
|
49059
49187
|
addRepoPrompt: async (target) => {
|
|
49060
49188
|
const repoPrompt = getMcpDiscoverySummary(configOverridePath, ctx.cwd, options).repoPrompt;
|
|
49061
49189
|
if (!repoPrompt.entry || !repoPrompt.targetPath || !repoPrompt.serverName) {
|
|
49062
49190
|
throw new Error("RepoPrompt is not available to add from this setup screen.");
|
|
49063
49191
|
}
|
|
49064
|
-
const
|
|
49192
|
+
const path8 = writeSharedServerEntry(getSharedConfigPath(target, ctx.cwd), repoPrompt.serverName, repoPrompt.entry);
|
|
49065
49193
|
configChanged = true;
|
|
49066
|
-
return { path:
|
|
49194
|
+
return { path: path8, serverName: repoPrompt.serverName };
|
|
49067
49195
|
},
|
|
49068
49196
|
addKnownServer: async (preset, target) => {
|
|
49069
|
-
const
|
|
49197
|
+
const path8 = writeSharedServerEntry(getSharedConfigPath(target, ctx.cwd), preset.id, preset.entry);
|
|
49070
49198
|
configChanged = true;
|
|
49071
|
-
return { path:
|
|
49199
|
+
return { path: path8, serverName: preset.name };
|
|
49072
49200
|
},
|
|
49073
49201
|
openPath: async (targetPath) => {
|
|
49074
49202
|
await openPath(pi, targetPath);
|
|
@@ -49464,7 +49592,7 @@ function stringifyStructuredContent(value) {
|
|
|
49464
49592
|
|
|
49465
49593
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-output-guard.ts
|
|
49466
49594
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
49467
|
-
import { mkdtemp, rm as
|
|
49595
|
+
import { mkdtemp, rm as rm4, writeFile as writeFile11 } from "fs/promises";
|
|
49468
49596
|
import { tmpdir as tmpdir2 } from "os";
|
|
49469
49597
|
import { dirname as dirname16, join as join28 } from "path";
|
|
49470
49598
|
var DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
|
|
@@ -49775,16 +49903,16 @@ function serializedObjectEntryBytes(key, value, hasPrevious) {
|
|
|
49775
49903
|
async function saveArtifact(kind, text) {
|
|
49776
49904
|
try {
|
|
49777
49905
|
const dir = await mkdtemp(join28(tmpdir2(), "pi-mcp-output-"));
|
|
49778
|
-
const
|
|
49779
|
-
await writeFile11(
|
|
49780
|
-
return { path:
|
|
49906
|
+
const path8 = join28(dir, `${kind}-${randomBytes4(4).toString("hex")}.txt`);
|
|
49907
|
+
await writeFile11(path8, text, { encoding: "utf8", mode: 384 });
|
|
49908
|
+
return { path: path8 };
|
|
49781
49909
|
} catch (error) {
|
|
49782
49910
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
49783
49911
|
}
|
|
49784
49912
|
}
|
|
49785
|
-
async function discardArtifact(
|
|
49913
|
+
async function discardArtifact(path8) {
|
|
49786
49914
|
try {
|
|
49787
|
-
await
|
|
49915
|
+
await rm4(dirname16(path8), { recursive: true, force: true });
|
|
49788
49916
|
} catch {
|
|
49789
49917
|
}
|
|
49790
49918
|
}
|
|
@@ -49828,9 +49956,9 @@ import { randomUUID as randomUUID11 } from "crypto";
|
|
|
49828
49956
|
import net from "net";
|
|
49829
49957
|
|
|
49830
49958
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ui-server.ts
|
|
49831
|
-
import
|
|
49959
|
+
import http2 from "http";
|
|
49832
49960
|
import fs7 from "fs/promises";
|
|
49833
|
-
import
|
|
49961
|
+
import path7 from "path";
|
|
49834
49962
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
49835
49963
|
|
|
49836
49964
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/host-html-template.ts
|
|
@@ -50843,7 +50971,7 @@ data: ${JSON.stringify(payload)}
|
|
|
50843
50971
|
options.onComplete?.(reason);
|
|
50844
50972
|
scheduleListenerClose();
|
|
50845
50973
|
};
|
|
50846
|
-
const hostServer =
|
|
50974
|
+
const hostServer = http2.createServer(async (req, res) => {
|
|
50847
50975
|
try {
|
|
50848
50976
|
const method = req.method || "GET";
|
|
50849
50977
|
const hostHeader = req.headers.host;
|
|
@@ -50927,7 +51055,7 @@ data: ${JSON.stringify(payload)}
|
|
|
50927
51055
|
return;
|
|
50928
51056
|
}
|
|
50929
51057
|
if (method === "GET" && url3.pathname === "/app-bridge.bundle.js") {
|
|
50930
|
-
const bundlePath =
|
|
51058
|
+
const bundlePath = path7.join(import.meta.dirname, "app-bridge.bundle.js");
|
|
50931
51059
|
try {
|
|
50932
51060
|
const content = await fs7.readFile(bundlePath, "utf-8");
|
|
50933
51061
|
res.writeHead(200, {
|
|
@@ -51191,7 +51319,7 @@ data: ${JSON.stringify(payload)}
|
|
|
51191
51319
|
const candidates = resolvePortCandidates(options.port);
|
|
51192
51320
|
let candidateIndex = 0;
|
|
51193
51321
|
const startSandboxProxy = (parentOrigin) => {
|
|
51194
|
-
const proxy =
|
|
51322
|
+
const proxy = http2.createServer((req, res) => {
|
|
51195
51323
|
try {
|
|
51196
51324
|
const method = req.method || "GET";
|
|
51197
51325
|
const hostHeader = req.headers.host;
|
|
@@ -57875,22 +58003,22 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57875
58003
|
durationMs: "error" in operation && operation.error === "incomplete" ? Math.max(0, Date.now() - startedAt) : operation.durationMs
|
|
57876
58004
|
}));
|
|
57877
58005
|
let callsSnapshot;
|
|
57878
|
-
const callTool = async (
|
|
58006
|
+
const callTool = async (path8, args) => {
|
|
57879
58007
|
const startedAt = Date.now();
|
|
57880
|
-
const index = calls.push({ operation: "call", path:
|
|
57881
|
-
const result = await executeCall(state,
|
|
58008
|
+
const index = calls.push({ operation: "call", path: path8, ok: false, error: "incomplete", durationMs: 0, startedAt }) - 1;
|
|
58009
|
+
const result = await executeCall(state, path8, args, void 0, getPiTools, callSignal, "script");
|
|
57882
58010
|
const details = result.details;
|
|
57883
58011
|
if (details.error !== void 0) {
|
|
57884
58012
|
const errorCode2 = String(details.error);
|
|
57885
58013
|
const suggestions = Array.isArray(details.suggestions) ? details.suggestions.filter((suggestion) => typeof suggestion === "string") : [];
|
|
57886
|
-
const message = errorCode2 === "tool_not_found" ? `Tool "${
|
|
57887
|
-
calls[index] = { operation: "call", path:
|
|
58014
|
+
const message = errorCode2 === "tool_not_found" ? `Tool "${path8}" not found. Use await tools.search({ query: "..." }) inside mcpScript.${suggestions.length > 0 ? ` Did you mean: ${suggestions.join(", ")}` : ""}` : typeof details.message === "string" ? details.message : textFromContent(result.content);
|
|
58015
|
+
calls[index] = { operation: "call", path: path8, ok: false, error: errorCode2, durationMs: Date.now() - startedAt, startedAt };
|
|
57888
58016
|
return {
|
|
57889
58017
|
ok: false,
|
|
57890
58018
|
error: { code: errorCode2, message }
|
|
57891
58019
|
};
|
|
57892
58020
|
}
|
|
57893
|
-
calls[index] = { operation: "call", path:
|
|
58021
|
+
calls[index] = { operation: "call", path: path8, ok: true, durationMs: Date.now() - startedAt, startedAt };
|
|
57894
58022
|
return {
|
|
57895
58023
|
ok: true,
|
|
57896
58024
|
data: details.mcpResult !== void 0 ? details.mcpResult : textFromContent(result.content)
|
|
@@ -57927,12 +58055,12 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57927
58055
|
};
|
|
57928
58056
|
const describeTool = (input) => {
|
|
57929
58057
|
const startedAt = Date.now();
|
|
57930
|
-
const
|
|
58058
|
+
const path8 = typeof input?.path === "string" ? input.path : "";
|
|
57931
58059
|
let error;
|
|
57932
58060
|
try {
|
|
57933
58061
|
for (const [server2, metadata] of state.toolMetadata) {
|
|
57934
58062
|
if (isServerInActiveFailureBackoff(state, server2)) continue;
|
|
57935
|
-
const tool = findToolByName(metadata,
|
|
58063
|
+
const tool = findToolByName(metadata, path8);
|
|
57936
58064
|
if (!tool) continue;
|
|
57937
58065
|
const inputTypeScript = tool.inputSchema ? renderTsShape(tool.inputSchema) ?? formatSchema(tool.inputSchema) : null;
|
|
57938
58066
|
return {
|
|
@@ -57943,13 +58071,13 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57943
58071
|
...inputTypeScript ? { inputTypeScript } : {}
|
|
57944
58072
|
};
|
|
57945
58073
|
}
|
|
57946
|
-
const suggestions =
|
|
58074
|
+
const suggestions = path8 ? rankSuggestions(state, path8, 5) : [];
|
|
57947
58075
|
error = "tool_not_found";
|
|
57948
58076
|
return {
|
|
57949
|
-
path:
|
|
58077
|
+
path: path8,
|
|
57950
58078
|
error: {
|
|
57951
58079
|
code: "tool_not_found",
|
|
57952
|
-
message: `Tool not found: ${
|
|
58080
|
+
message: `Tool not found: ${path8}`,
|
|
57953
58081
|
suggestions
|
|
57954
58082
|
}
|
|
57955
58083
|
};
|
|
@@ -57957,7 +58085,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57957
58085
|
error = caught;
|
|
57958
58086
|
throw caught;
|
|
57959
58087
|
} finally {
|
|
57960
|
-
calls.push(error === void 0 ? { operation: "describe", path:
|
|
58088
|
+
calls.push(error === void 0 ? { operation: "describe", path: path8, ok: true, durationMs: Date.now() - startedAt, startedAt } : { operation: "describe", path: path8, ok: false, error: error instanceof Error ? error.message : String(error), durationMs: Date.now() - startedAt, startedAt });
|
|
57961
58089
|
}
|
|
57962
58090
|
};
|
|
57963
58091
|
let worker;
|
|
@@ -61170,10 +61298,10 @@ function unansweredRequest(blocks) {
|
|
|
61170
61298
|
const answered = blocks.slice(lastUser + 1).some((block) => block.startsWith("## Agent"));
|
|
61171
61299
|
return answered ? null : lastUserBlockText(blocks);
|
|
61172
61300
|
}
|
|
61173
|
-
async function readHistoryTail(
|
|
61301
|
+
async function readHistoryTail(path8, maxBytes) {
|
|
61174
61302
|
let handle;
|
|
61175
61303
|
try {
|
|
61176
|
-
handle = await open3(
|
|
61304
|
+
handle = await open3(path8, "r");
|
|
61177
61305
|
} catch (error) {
|
|
61178
61306
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return { content: "", truncated: false };
|
|
61179
61307
|
throw error;
|
|
@@ -61964,9 +62092,9 @@ var ChatService = class {
|
|
|
61964
62092
|
historyPath,
|
|
61965
62093
|
`${historyPath}.pages.jsonl`,
|
|
61966
62094
|
`${historyPath}.pages.index.json`
|
|
61967
|
-
].map((
|
|
61968
|
-
await
|
|
61969
|
-
await
|
|
62095
|
+
].map((path8) => rm5(path8, { force: true })));
|
|
62096
|
+
await rm5(chatMessageSendersFilePath(persisted.id), { force: true });
|
|
62097
|
+
await rm5(join37(FORKS_DIR, persisted.id), { recursive: true, force: true });
|
|
61970
62098
|
}
|
|
61971
62099
|
/** Resolves once the target chat exists; the handoff and its first turn run in the background. */
|
|
61972
62100
|
async forkChat(sourceChatId, request, trigger = "manual", reason) {
|
|
@@ -62797,10 +62925,10 @@ var LanguageServerService = class {
|
|
|
62797
62925
|
const uri = "targetUri" in location ? location.targetUri : location.uri;
|
|
62798
62926
|
const range = "targetSelectionRange" in location ? location.targetSelectionRange : location.range;
|
|
62799
62927
|
const absolutePath = fileURLToPath6(uri);
|
|
62800
|
-
const
|
|
62801
|
-
if (
|
|
62928
|
+
const path8 = relative2(repoPath, absolutePath);
|
|
62929
|
+
if (path8.startsWith("..")) return [];
|
|
62802
62930
|
const preview = readFileSync8(absolutePath, "utf8").split("\n")[range.start.line]?.trim() ?? "";
|
|
62803
|
-
return [{ repoName, path:
|
|
62931
|
+
return [{ repoName, path: path8, line: range.start.line + 1, character: range.start.character, endCharacter: range.end.character, preview }];
|
|
62804
62932
|
});
|
|
62805
62933
|
return { symbol: "", detail: null, documentation: null, locations, provider: "language-server" };
|
|
62806
62934
|
} catch {
|
|
@@ -64182,11 +64310,11 @@ function createV1Routes(deps) {
|
|
|
64182
64310
|
});
|
|
64183
64311
|
app2.get("/repo-files/content", async (c) => {
|
|
64184
64312
|
const repoName = c.req.query("repoName");
|
|
64185
|
-
const
|
|
64186
|
-
if (!repoName || !
|
|
64313
|
+
const path8 = c.req.query("path");
|
|
64314
|
+
if (!repoName || !path8) {
|
|
64187
64315
|
return c.json(jsonError("repoName and path are required"), 400);
|
|
64188
64316
|
}
|
|
64189
|
-
const result = await deps.repoFileService.readFile(repoName,
|
|
64317
|
+
const result = await deps.repoFileService.readFile(repoName, path8);
|
|
64190
64318
|
if (!result) {
|
|
64191
64319
|
return c.json(jsonError("File not found"), 404);
|
|
64192
64320
|
}
|
|
@@ -64194,25 +64322,25 @@ function createV1Routes(deps) {
|
|
|
64194
64322
|
});
|
|
64195
64323
|
app2.put("/repo-files/content", async (c) => {
|
|
64196
64324
|
const repoName = c.req.query("repoName");
|
|
64197
|
-
const
|
|
64198
|
-
if (!repoName || !
|
|
64325
|
+
const path8 = c.req.query("path");
|
|
64326
|
+
if (!repoName || !path8) {
|
|
64199
64327
|
return c.json(jsonError("repoName and path are required"), 400);
|
|
64200
64328
|
}
|
|
64201
64329
|
const body = updateTextFileSchema(MAX_REPO_FILE_CONTENT_BYTES).parse(await c.req.json());
|
|
64202
|
-
const result = await deps.repoFileService.updateFile(repoName,
|
|
64330
|
+
const result = await deps.repoFileService.updateFile(repoName, path8, body.content, body.expectedRevision);
|
|
64203
64331
|
if (!result) return c.json(jsonError("File is not editable"), 400);
|
|
64204
64332
|
return c.json(result);
|
|
64205
64333
|
});
|
|
64206
64334
|
app2.get("/repo-files/symbol", async (c) => {
|
|
64207
64335
|
const repoName = c.req.query("repoName");
|
|
64208
|
-
const
|
|
64336
|
+
const path8 = c.req.query("path");
|
|
64209
64337
|
const action = c.req.query("action");
|
|
64210
64338
|
const line = Number(c.req.query("line"));
|
|
64211
64339
|
const character = Number(c.req.query("character"));
|
|
64212
|
-
if (!repoName || !
|
|
64340
|
+
if (!repoName || !path8 || action !== "hover" && action !== "definition" && action !== "references" || !Number.isInteger(line) || !Number.isInteger(character)) {
|
|
64213
64341
|
return c.json(jsonError("Invalid symbol request"), 400);
|
|
64214
64342
|
}
|
|
64215
|
-
const result = await deps.repoFileService.inspectSymbol(repoName,
|
|
64343
|
+
const result = await deps.repoFileService.inspectSymbol(repoName, path8, line, character, action);
|
|
64216
64344
|
if (!result) return c.json(jsonError("Symbol not found"), 404);
|
|
64217
64345
|
return c.json(result);
|
|
64218
64346
|
});
|
|
@@ -64863,7 +64991,8 @@ app.get("/token-refresh/health", async (c) => {
|
|
|
64863
64991
|
gitlab: gitlabTokenManager.getHealthStatus(),
|
|
64864
64992
|
claude: claudeTokenManager.getHealthStatus(),
|
|
64865
64993
|
codex: codexTokenManager.getHealthStatus(),
|
|
64866
|
-
infisical: infisicalTokenManager.getHealthStatus()
|
|
64994
|
+
infisical: infisicalTokenManager.getHealthStatus(),
|
|
64995
|
+
workspaceIdentity: workspaceIdentityTokenManager.getHealthStatus()
|
|
64867
64996
|
});
|
|
64868
64997
|
});
|
|
64869
64998
|
app.post(GITHUB_CREDENTIAL_REFRESH_PATH, async (c) => {
|
|
@@ -65036,6 +65165,8 @@ serve(
|
|
|
65036
65165
|
await claudeTokenManager.start();
|
|
65037
65166
|
await codexTokenManager.start();
|
|
65038
65167
|
await infisicalTokenManager.start();
|
|
65168
|
+
await workspaceIdentityTokenManager.start();
|
|
65169
|
+
createIdentityProxy(() => workspaceIdentityTokenManager.bundle).on("error", (error) => console.error("[identity-proxy] failed to listen:", error)).listen(IDENTITY_PROXY_PORT, "127.0.0.1");
|
|
65039
65170
|
}
|
|
65040
65171
|
const repos = await gitService.listRepos();
|
|
65041
65172
|
await eventService.publish({
|