replicas-engine 0.1.891 → 0.1.893
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-RKLHLTPR.js → asp-host-X5TW6XEX.js} +4 -4
- package/dist/src/{chunk-IB2SHITZ.js → chunk-2ISAUV3V.js} +2 -2
- package/dist/src/{chunk-EDLDRUYW.js → chunk-HANGEXUO.js} +2 -2
- package/dist/src/{chunk-4NFLZXZX.js → chunk-IN4SUFZ2.js} +2 -2
- package/dist/src/{chunk-TDLEF5FU.js → chunk-PAELCM3S.js} +5 -5
- package/dist/src/{chunk-U2T2QCYP.js → chunk-UVFBGY57.js} +1 -1
- package/dist/src/{chunk-DG4VIQXA.js → chunk-V7P43L3L.js} +1 -1
- package/dist/src/{chunk-OBAGPETY.js → chunk-ZZ7YYXV5.js} +22 -27
- package/dist/src/command-protection-hook.js +3 -3
- package/dist/src/deepseek-command-protection-plugin.js +5 -5
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +275 -241
- package/dist/src/post-tool-pr-hook.js +3 -3
- 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-IN4SUFZ2.js";
|
|
95
95
|
import {
|
|
96
96
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
97
97
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -116,7 +116,7 @@ import {
|
|
|
116
116
|
} from "./chunk-FLDA7BX3.js";
|
|
117
117
|
import {
|
|
118
118
|
publishedPullRequestUrls
|
|
119
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-UVFBGY57.js";
|
|
120
120
|
import {
|
|
121
121
|
RELAY_MCP_TOOLS,
|
|
122
122
|
RELAY_MCP_TOOL_NAMES,
|
|
@@ -137,21 +137,21 @@ import {
|
|
|
137
137
|
refreshDelayMs,
|
|
138
138
|
restartCodexAspHost,
|
|
139
139
|
routineRefreshExclusions
|
|
140
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-PAELCM3S.js";
|
|
141
141
|
import {
|
|
142
142
|
ENGINE_ENV,
|
|
143
143
|
IS_WARMING_MODE,
|
|
144
144
|
monolithRequest,
|
|
145
145
|
monolithService,
|
|
146
146
|
setAgentCredentialSnapshot
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-V7P43L3L.js";
|
|
148
148
|
import {
|
|
149
149
|
AspClient,
|
|
150
150
|
SUBPROCESS_MAX_BUFFER,
|
|
151
151
|
execAsync,
|
|
152
152
|
execFileAsync,
|
|
153
153
|
getCodexModelProvider
|
|
154
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-HANGEXUO.js";
|
|
155
155
|
import {
|
|
156
156
|
isRecord as isRecord2
|
|
157
157
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -219,6 +219,7 @@ import {
|
|
|
219
219
|
GIT_CREDENTIAL_HELPER_FILENAME,
|
|
220
220
|
HOOK_EXEC_MAX_BUFFER_BYTES,
|
|
221
221
|
IDENTITY_PROXY_PORT,
|
|
222
|
+
IDENTITY_TOKEN_PATH,
|
|
222
223
|
IMAGE_MEDIA_TYPES,
|
|
223
224
|
InFlightMap,
|
|
224
225
|
MAX_CANVAS_FILE_BYTES,
|
|
@@ -242,7 +243,7 @@ import {
|
|
|
242
243
|
TaskAccumulator,
|
|
243
244
|
USER_MESSAGE_ID_PAYLOAD_KEY,
|
|
244
245
|
VALID_AGENT_PROVIDERS,
|
|
245
|
-
|
|
246
|
+
WORKSPACE_IDENTITY_AUDIENCE,
|
|
246
247
|
agentQuotaExhaustedPayloadSchema,
|
|
247
248
|
areSameUserMessageEvents,
|
|
248
249
|
areUserMessagesWithinMatchWindow,
|
|
@@ -276,7 +277,6 @@ import {
|
|
|
276
277
|
createProviderSlashCommand,
|
|
277
278
|
createSuccessResult,
|
|
278
279
|
createUuidFromHex,
|
|
279
|
-
currentWorkspaceToken,
|
|
280
280
|
decodePathSegments,
|
|
281
281
|
defaultForkChatTitle,
|
|
282
282
|
describeQuotaLimit,
|
|
@@ -334,6 +334,7 @@ import {
|
|
|
334
334
|
isValidEngineLogSessionId,
|
|
335
335
|
isValidRelayBaseProvider,
|
|
336
336
|
lastUserBlockText,
|
|
337
|
+
legacyWorkspaceTokenBundleSchema,
|
|
337
338
|
listOllamaModels,
|
|
338
339
|
mergeSlashCommands,
|
|
339
340
|
messageRelaySubagentRequestSchema,
|
|
@@ -371,8 +372,11 @@ import {
|
|
|
371
372
|
updateChatDisplayNameRequestSchema,
|
|
372
373
|
waitRelaySubagentRequestSchema,
|
|
373
374
|
withTimeout,
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
workspaceAudienceSchema,
|
|
376
|
+
workspaceCredentialProviderSchema,
|
|
377
|
+
workspaceTokenRequestSchema,
|
|
378
|
+
workspaceTokenResponseSchema
|
|
379
|
+
} from "./chunk-ZZ7YYXV5.js";
|
|
376
380
|
import {
|
|
377
381
|
__commonJS,
|
|
378
382
|
__export,
|
|
@@ -387,7 +391,7 @@ var require_windows = __commonJS({
|
|
|
387
391
|
module.exports = isexe;
|
|
388
392
|
isexe.sync = sync;
|
|
389
393
|
var fs8 = __require("fs");
|
|
390
|
-
function checkPathExt(
|
|
394
|
+
function checkPathExt(path7, options) {
|
|
391
395
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
392
396
|
if (!pathext) {
|
|
393
397
|
return true;
|
|
@@ -398,25 +402,25 @@ var require_windows = __commonJS({
|
|
|
398
402
|
}
|
|
399
403
|
for (var i = 0; i < pathext.length; i++) {
|
|
400
404
|
var p = pathext[i].toLowerCase();
|
|
401
|
-
if (p &&
|
|
405
|
+
if (p && path7.substr(-p.length).toLowerCase() === p) {
|
|
402
406
|
return true;
|
|
403
407
|
}
|
|
404
408
|
}
|
|
405
409
|
return false;
|
|
406
410
|
}
|
|
407
|
-
function checkStat(stat8,
|
|
411
|
+
function checkStat(stat8, path7, options) {
|
|
408
412
|
if (!stat8.isSymbolicLink() && !stat8.isFile()) {
|
|
409
413
|
return false;
|
|
410
414
|
}
|
|
411
|
-
return checkPathExt(
|
|
415
|
+
return checkPathExt(path7, options);
|
|
412
416
|
}
|
|
413
|
-
function isexe(
|
|
414
|
-
fs8.stat(
|
|
415
|
-
cb(er, er ? false : checkStat(stat8,
|
|
417
|
+
function isexe(path7, options, cb) {
|
|
418
|
+
fs8.stat(path7, function(er, stat8) {
|
|
419
|
+
cb(er, er ? false : checkStat(stat8, path7, options));
|
|
416
420
|
});
|
|
417
421
|
}
|
|
418
|
-
function sync(
|
|
419
|
-
return checkStat(fs8.statSync(
|
|
422
|
+
function sync(path7, options) {
|
|
423
|
+
return checkStat(fs8.statSync(path7), path7, options);
|
|
420
424
|
}
|
|
421
425
|
}
|
|
422
426
|
});
|
|
@@ -428,13 +432,13 @@ var require_mode = __commonJS({
|
|
|
428
432
|
module.exports = isexe;
|
|
429
433
|
isexe.sync = sync;
|
|
430
434
|
var fs8 = __require("fs");
|
|
431
|
-
function isexe(
|
|
432
|
-
fs8.stat(
|
|
435
|
+
function isexe(path7, options, cb) {
|
|
436
|
+
fs8.stat(path7, function(er, stat8) {
|
|
433
437
|
cb(er, er ? false : checkStat(stat8, options));
|
|
434
438
|
});
|
|
435
439
|
}
|
|
436
|
-
function sync(
|
|
437
|
-
return checkStat(fs8.statSync(
|
|
440
|
+
function sync(path7, options) {
|
|
441
|
+
return checkStat(fs8.statSync(path7), options);
|
|
438
442
|
}
|
|
439
443
|
function checkStat(stat8, options) {
|
|
440
444
|
return stat8.isFile() && checkMode(stat8, options);
|
|
@@ -468,7 +472,7 @@ var require_isexe = __commonJS({
|
|
|
468
472
|
}
|
|
469
473
|
module.exports = isexe;
|
|
470
474
|
isexe.sync = sync;
|
|
471
|
-
function isexe(
|
|
475
|
+
function isexe(path7, options, cb) {
|
|
472
476
|
if (typeof options === "function") {
|
|
473
477
|
cb = options;
|
|
474
478
|
options = {};
|
|
@@ -478,7 +482,7 @@ var require_isexe = __commonJS({
|
|
|
478
482
|
throw new TypeError("callback not provided");
|
|
479
483
|
}
|
|
480
484
|
return new Promise(function(resolve8, reject) {
|
|
481
|
-
isexe(
|
|
485
|
+
isexe(path7, options || {}, function(er, is) {
|
|
482
486
|
if (er) {
|
|
483
487
|
reject(er);
|
|
484
488
|
} else {
|
|
@@ -487,7 +491,7 @@ var require_isexe = __commonJS({
|
|
|
487
491
|
});
|
|
488
492
|
});
|
|
489
493
|
}
|
|
490
|
-
core(
|
|
494
|
+
core(path7, options || {}, function(er, is) {
|
|
491
495
|
if (er) {
|
|
492
496
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
493
497
|
er = null;
|
|
@@ -497,9 +501,9 @@ var require_isexe = __commonJS({
|
|
|
497
501
|
cb(er, is);
|
|
498
502
|
});
|
|
499
503
|
}
|
|
500
|
-
function sync(
|
|
504
|
+
function sync(path7, options) {
|
|
501
505
|
try {
|
|
502
|
-
return core.sync(
|
|
506
|
+
return core.sync(path7, options || {});
|
|
503
507
|
} catch (er) {
|
|
504
508
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
505
509
|
return false;
|
|
@@ -516,7 +520,7 @@ var require_which = __commonJS({
|
|
|
516
520
|
"../node_modules/.bun/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
517
521
|
"use strict";
|
|
518
522
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
519
|
-
var
|
|
523
|
+
var path7 = __require("path");
|
|
520
524
|
var COLON = isWindows ? ";" : ":";
|
|
521
525
|
var isexe = require_isexe();
|
|
522
526
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -554,7 +558,7 @@ var require_which = __commonJS({
|
|
|
554
558
|
return opt.all && found.length ? resolve8(found) : reject(getNotFoundError(cmd));
|
|
555
559
|
const ppRaw = pathEnv[i];
|
|
556
560
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
557
|
-
const pCmd =
|
|
561
|
+
const pCmd = path7.join(pathPart, cmd);
|
|
558
562
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
559
563
|
resolve8(subStep(p, i, 0));
|
|
560
564
|
});
|
|
@@ -581,7 +585,7 @@ var require_which = __commonJS({
|
|
|
581
585
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
582
586
|
const ppRaw = pathEnv[i];
|
|
583
587
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
584
|
-
const pCmd =
|
|
588
|
+
const pCmd = path7.join(pathPart, cmd);
|
|
585
589
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
586
590
|
for (let j = 0; j < pathExt.length; j++) {
|
|
587
591
|
const cur = p + pathExt[j];
|
|
@@ -629,7 +633,7 @@ var require_path_key = __commonJS({
|
|
|
629
633
|
var require_resolveCommand = __commonJS({
|
|
630
634
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
631
635
|
"use strict";
|
|
632
|
-
var
|
|
636
|
+
var path7 = __require("path");
|
|
633
637
|
var which = require_which();
|
|
634
638
|
var getPathKey = require_path_key();
|
|
635
639
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -647,7 +651,7 @@ var require_resolveCommand = __commonJS({
|
|
|
647
651
|
try {
|
|
648
652
|
resolved = which.sync(parsed.command, {
|
|
649
653
|
path: env[getPathKey({ env })],
|
|
650
|
-
pathExt: withoutPathExt ?
|
|
654
|
+
pathExt: withoutPathExt ? path7.delimiter : void 0
|
|
651
655
|
});
|
|
652
656
|
} catch (e) {
|
|
653
657
|
} finally {
|
|
@@ -656,7 +660,7 @@ var require_resolveCommand = __commonJS({
|
|
|
656
660
|
}
|
|
657
661
|
}
|
|
658
662
|
if (resolved) {
|
|
659
|
-
resolved =
|
|
663
|
+
resolved = path7.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
660
664
|
}
|
|
661
665
|
return resolved;
|
|
662
666
|
}
|
|
@@ -710,8 +714,8 @@ var require_shebang_command = __commonJS({
|
|
|
710
714
|
if (!match) {
|
|
711
715
|
return null;
|
|
712
716
|
}
|
|
713
|
-
const [
|
|
714
|
-
const binary =
|
|
717
|
+
const [path7, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
718
|
+
const binary = path7.split("/").pop();
|
|
715
719
|
if (binary === "env") {
|
|
716
720
|
return argument;
|
|
717
721
|
}
|
|
@@ -746,7 +750,7 @@ var require_readShebang = __commonJS({
|
|
|
746
750
|
var require_parse = __commonJS({
|
|
747
751
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
748
752
|
"use strict";
|
|
749
|
-
var
|
|
753
|
+
var path7 = __require("path");
|
|
750
754
|
var resolveCommand = require_resolveCommand();
|
|
751
755
|
var escape2 = require_escape();
|
|
752
756
|
var readShebang = require_readShebang();
|
|
@@ -771,7 +775,7 @@ var require_parse = __commonJS({
|
|
|
771
775
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
772
776
|
if (parsed.options.forceShell || needsShell) {
|
|
773
777
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
774
|
-
parsed.command =
|
|
778
|
+
parsed.command = path7.normalize(parsed.command);
|
|
775
779
|
parsed.command = escape2.command(parsed.command);
|
|
776
780
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
777
781
|
const shellCommand2 = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -4077,8 +4081,8 @@ var require_utils2 = __commonJS({
|
|
|
4077
4081
|
}
|
|
4078
4082
|
return ind;
|
|
4079
4083
|
}
|
|
4080
|
-
function removeDotSegments(
|
|
4081
|
-
let input =
|
|
4084
|
+
function removeDotSegments(path7) {
|
|
4085
|
+
let input = path7;
|
|
4082
4086
|
const output = [];
|
|
4083
4087
|
let nextSlash = -1;
|
|
4084
4088
|
let len = 0;
|
|
@@ -4330,8 +4334,8 @@ var require_schemes2 = __commonJS({
|
|
|
4330
4334
|
wsComponent.secure = void 0;
|
|
4331
4335
|
}
|
|
4332
4336
|
if (wsComponent.resourceName) {
|
|
4333
|
-
const [
|
|
4334
|
-
wsComponent.path =
|
|
4337
|
+
const [path7, query2] = wsComponent.resourceName.split("?");
|
|
4338
|
+
wsComponent.path = path7 && path7 !== "/" ? path7 : void 0;
|
|
4335
4339
|
wsComponent.query = query2;
|
|
4336
4340
|
wsComponent.resourceName = void 0;
|
|
4337
4341
|
}
|
|
@@ -8590,11 +8594,11 @@ var AsyncLock = class {
|
|
|
8590
8594
|
};
|
|
8591
8595
|
|
|
8592
8596
|
// src/utils/file.ts
|
|
8593
|
-
async function atomicWriteFile(
|
|
8594
|
-
const tmpFile = `${
|
|
8597
|
+
async function atomicWriteFile(path7, data, options) {
|
|
8598
|
+
const tmpFile = `${path7}.${process.pid}.${randomUUID()}.tmp`;
|
|
8595
8599
|
try {
|
|
8596
8600
|
await writeFile(tmpFile, data, { encoding: "utf-8", mode: options?.mode });
|
|
8597
|
-
await rename(tmpFile,
|
|
8601
|
+
await rename(tmpFile, path7);
|
|
8598
8602
|
} catch (error) {
|
|
8599
8603
|
await unlink(tmpFile).catch(() => void 0);
|
|
8600
8604
|
throw error;
|
|
@@ -9064,9 +9068,9 @@ var GitService = class {
|
|
|
9064
9068
|
try {
|
|
9065
9069
|
const paths = await this.listUntrackedPaths(repoPath);
|
|
9066
9070
|
let total = 0;
|
|
9067
|
-
for (const
|
|
9071
|
+
for (const path7 of paths) {
|
|
9068
9072
|
try {
|
|
9069
|
-
const contents = await readFile3(join4(repoPath,
|
|
9073
|
+
const contents = await readFile3(join4(repoPath, path7));
|
|
9070
9074
|
if (contents.length === 0 || contents.includes(0)) {
|
|
9071
9075
|
continue;
|
|
9072
9076
|
}
|
|
@@ -9321,9 +9325,9 @@ var GitService = class {
|
|
|
9321
9325
|
};
|
|
9322
9326
|
return saveRepoState(repo.name, state, state);
|
|
9323
9327
|
}
|
|
9324
|
-
async safeStat(
|
|
9328
|
+
async safeStat(path7) {
|
|
9325
9329
|
try {
|
|
9326
|
-
return await stat(
|
|
9330
|
+
return await stat(path7);
|
|
9327
9331
|
} catch {
|
|
9328
9332
|
return null;
|
|
9329
9333
|
}
|
|
@@ -9637,62 +9641,58 @@ async function applyInfisicalCredentials(data, paths) {
|
|
|
9637
9641
|
}
|
|
9638
9642
|
var infisicalTokenManager = new InfisicalTokenManager();
|
|
9639
9643
|
|
|
9640
|
-
// src/
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
var
|
|
9644
|
-
|
|
9645
|
-
constructor(request = monolithRequest, homeDir = ENGINE_ENV.HOME_DIR) {
|
|
9646
|
-
super("WorkspaceIdentityTokenManager", MAX_REFRESH_MS);
|
|
9644
|
+
// src/workspace-identity-tokens.ts
|
|
9645
|
+
var MIN_REMAINING_MS = 5 * 60 * 1e3;
|
|
9646
|
+
var MAX_CACHED_AUDIENCES = 32;
|
|
9647
|
+
var WorkspaceIdentityTokens = class {
|
|
9648
|
+
constructor(request = monolithRequest) {
|
|
9647
9649
|
this.request = request;
|
|
9648
|
-
this.homeDir = homeDir;
|
|
9649
9650
|
}
|
|
9650
9651
|
request;
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
const data = await response.json();
|
|
9658
|
-
const bundleFile = path5.join(this.homeDir, ".replicas", "credentials", "tokens.json");
|
|
9659
|
-
const envFile = path5.join(this.homeDir, ".replicas", "workspace-identity-env.sh");
|
|
9660
|
-
if (!data.configured) {
|
|
9661
|
-
this.bundle = null;
|
|
9662
|
-
for (const key of Object.values(WORKSPACE_TOKEN_ENV)) delete process.env[key];
|
|
9663
|
-
await Promise.all([rm2(bundleFile, { force: true }), rm2(envFile, { force: true })]);
|
|
9664
|
-
this.nextRefreshDelayMs = MAX_REFRESH_MS;
|
|
9665
|
-
return;
|
|
9652
|
+
cache = /* @__PURE__ */ new Map();
|
|
9653
|
+
inflight = /* @__PURE__ */ new Map();
|
|
9654
|
+
async get(audience = WORKSPACE_IDENTITY_AUDIENCE) {
|
|
9655
|
+
const parsed = workspaceAudienceSchema.safeParse(audience);
|
|
9656
|
+
if (!parsed.success) {
|
|
9657
|
+
return createErrorResult({ message: parsed.error.issues[0]?.message ?? "Invalid audience", code: 400 });
|
|
9666
9658
|
}
|
|
9667
|
-
const
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
Object.assign(process.env, env);
|
|
9676
|
-
await Promise.all([
|
|
9677
|
-
writeSecureCredentialFile(bundleFile, `${JSON.stringify(bundle)}
|
|
9678
|
-
`, { ensureParentDir: true }),
|
|
9679
|
-
writeSecureCredentialFile(
|
|
9680
|
-
envFile,
|
|
9681
|
-
`${Object.entries(env).map(([key, value]) => `export ${key}=${shellQuotePosix(value)}`).join("\n")}
|
|
9682
|
-
`,
|
|
9683
|
-
{ ensureParentDir: true }
|
|
9684
|
-
)
|
|
9685
|
-
]);
|
|
9686
|
-
this.nextRefreshDelayMs = refreshDelayMs(
|
|
9687
|
-
Math.min(...Object.values(bundle.tokens).map((entry) => Date.parse(entry.expires_at))),
|
|
9688
|
-
MAX_REFRESH_MS
|
|
9689
|
-
);
|
|
9659
|
+
const cached = this.cache.get(audience);
|
|
9660
|
+
if (cached && Date.parse(cached.expires_at) - Date.now() > MIN_REMAINING_MS) return createSuccessResult(cached);
|
|
9661
|
+
let pending = this.inflight.get(audience);
|
|
9662
|
+
if (!pending) {
|
|
9663
|
+
pending = this.mint(audience).finally(() => this.inflight.delete(audience));
|
|
9664
|
+
this.inflight.set(audience, pending);
|
|
9665
|
+
}
|
|
9666
|
+
return pending;
|
|
9690
9667
|
}
|
|
9691
|
-
|
|
9692
|
-
|
|
9668
|
+
async mint(audience) {
|
|
9669
|
+
let response;
|
|
9670
|
+
try {
|
|
9671
|
+
response = await this.request("/v1/engine/workspace-identity/token", { body: { audience } });
|
|
9672
|
+
} catch (error) {
|
|
9673
|
+
return createErrorResult({ message: error instanceof Error ? error.message : "Workspace identity request failed", code: 503 });
|
|
9674
|
+
}
|
|
9675
|
+
if (!response.ok) {
|
|
9676
|
+
return createErrorResult({ message: `Workspace identity request failed: ${response.status} ${await response.text()}`, code: response.status === 400 ? 400 : 503 });
|
|
9677
|
+
}
|
|
9678
|
+
const data = await response.json().catch(() => null);
|
|
9679
|
+
if (isRecord(data) && data.configured === false) {
|
|
9680
|
+
return createErrorResult({ message: "Workspace identity is not enabled for this workspace", code: 503 });
|
|
9681
|
+
}
|
|
9682
|
+
const parsed = workspaceTokenResponseSchema.safeParse(data);
|
|
9683
|
+
const legacy = parsed.success ? null : legacyWorkspaceTokenBundleSchema.safeParse(data);
|
|
9684
|
+
const token = parsed.success ? parsed.data : legacy?.success && legacy.data.tokens[audience] ? { issuer: legacy.data.issuer, audience, ...legacy.data.tokens[audience] } : null;
|
|
9685
|
+
if (!token) {
|
|
9686
|
+
return createErrorResult({ message: `Workspace identity token for ${audience} is unavailable from this Replicas version`, code: 503 });
|
|
9687
|
+
}
|
|
9688
|
+
this.cache.delete(audience);
|
|
9689
|
+
const oldest = this.cache.keys().next();
|
|
9690
|
+
if (this.cache.size >= MAX_CACHED_AUDIENCES && !oldest.done) this.cache.delete(oldest.value);
|
|
9691
|
+
this.cache.set(audience, token);
|
|
9692
|
+
return createSuccessResult(token);
|
|
9693
9693
|
}
|
|
9694
9694
|
};
|
|
9695
|
-
var
|
|
9695
|
+
var workspaceIdentityTokens = new WorkspaceIdentityTokens();
|
|
9696
9696
|
|
|
9697
9697
|
// src/identity-proxy.ts
|
|
9698
9698
|
import http from "http";
|
|
@@ -9709,6 +9709,7 @@ var STRIPPED_HEADERS = /* @__PURE__ */ new Set([
|
|
|
9709
9709
|
"trailer",
|
|
9710
9710
|
"upgrade"
|
|
9711
9711
|
]);
|
|
9712
|
+
var MAX_TOKEN_REQUEST_BYTES = 4096;
|
|
9712
9713
|
var decode = (segment) => Buffer.from(segment, "base64url").toString("utf8");
|
|
9713
9714
|
function resolveIdentityRoute(requestUrl) {
|
|
9714
9715
|
const url3 = new URL(requestUrl, "http://127.0.0.1");
|
|
@@ -9726,24 +9727,59 @@ function resolveIdentityRoute(requestUrl) {
|
|
|
9726
9727
|
target.search = url3.search;
|
|
9727
9728
|
return { target, audience: decode(encodedAudience) };
|
|
9728
9729
|
}
|
|
9729
|
-
function
|
|
9730
|
-
return
|
|
9730
|
+
function readJsonBody(request) {
|
|
9731
|
+
return new Promise((resolve8) => {
|
|
9732
|
+
const chunks = [];
|
|
9733
|
+
let size = 0;
|
|
9734
|
+
request.on("data", (chunk) => {
|
|
9735
|
+
size += chunk.length;
|
|
9736
|
+
if (size <= MAX_TOKEN_REQUEST_BYTES) chunks.push(chunk);
|
|
9737
|
+
});
|
|
9738
|
+
request.on("end", () => {
|
|
9739
|
+
if (size > MAX_TOKEN_REQUEST_BYTES) return resolve8(null);
|
|
9740
|
+
const text = Buffer.concat(chunks).toString("utf8").trim();
|
|
9741
|
+
try {
|
|
9742
|
+
resolve8(text ? JSON.parse(text) : {});
|
|
9743
|
+
} catch {
|
|
9744
|
+
resolve8(null);
|
|
9745
|
+
}
|
|
9746
|
+
});
|
|
9747
|
+
request.on("error", () => resolve8(null));
|
|
9748
|
+
});
|
|
9749
|
+
}
|
|
9750
|
+
function createIdentityProxy(tokens) {
|
|
9751
|
+
return http.createServer(async (request, response) => {
|
|
9752
|
+
const url3 = new URL(request.url ?? "/", "http://127.0.0.1");
|
|
9753
|
+
if (url3.pathname === IDENTITY_TOKEN_PATH) {
|
|
9754
|
+
if (request.method !== "POST") {
|
|
9755
|
+
response.writeHead(405, { allow: "POST" }).end();
|
|
9756
|
+
return;
|
|
9757
|
+
}
|
|
9758
|
+
const body = workspaceTokenRequestSchema.safeParse(await readJsonBody(request));
|
|
9759
|
+
if (!body.success) {
|
|
9760
|
+
response.writeHead(400, { "content-type": "application/json" }).end(JSON.stringify({ error: 'Body must be JSON with an optional printable "audience" string' }));
|
|
9761
|
+
return;
|
|
9762
|
+
}
|
|
9763
|
+
const result = await tokens.get(body.data.audience);
|
|
9764
|
+
response.writeHead(result.ok ? 200 : result.error.code ?? 503, { "content-type": "application/json", "cache-control": "no-store" });
|
|
9765
|
+
response.end(JSON.stringify(result.ok ? result.data : { error: result.error.message }));
|
|
9766
|
+
return;
|
|
9767
|
+
}
|
|
9731
9768
|
const route = resolveIdentityRoute(request.url ?? "/");
|
|
9732
9769
|
if (!route) {
|
|
9733
9770
|
response.writeHead(404).end("Unknown identity route");
|
|
9734
9771
|
return;
|
|
9735
9772
|
}
|
|
9736
|
-
const
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
response.writeHead(503).end("Workspace token unavailable; waiting for renewal");
|
|
9773
|
+
const token = await tokens.get(route.audience);
|
|
9774
|
+
if (!token.ok) {
|
|
9775
|
+
response.writeHead(token.error.code ?? 503).end(token.error.message);
|
|
9740
9776
|
return;
|
|
9741
9777
|
}
|
|
9742
9778
|
const headers = { host: route.target.host };
|
|
9743
9779
|
for (const [name, value] of Object.entries(request.headers)) {
|
|
9744
9780
|
if (!STRIPPED_HEADERS.has(name) && !name.startsWith("x-replicas-") && value !== void 0) headers[name] = value;
|
|
9745
9781
|
}
|
|
9746
|
-
headers.authorization = `Bearer ${token}`;
|
|
9782
|
+
headers.authorization = `Bearer ${token.data.token}`;
|
|
9747
9783
|
const upstream = (route.target.protocol === "https:" ? https : http).request(
|
|
9748
9784
|
route.target,
|
|
9749
9785
|
{ method: request.method, headers },
|
|
@@ -9777,8 +9813,8 @@ var StreamWriter = class {
|
|
|
9777
9813
|
backpressured = false;
|
|
9778
9814
|
droppedCount = 0;
|
|
9779
9815
|
flushTimer = null;
|
|
9780
|
-
open(
|
|
9781
|
-
this.stream = createWriteStream(
|
|
9816
|
+
open(path7, highWaterMark = DEFAULT_HIGH_WATER) {
|
|
9817
|
+
this.stream = createWriteStream(path7, { flags: "a", highWaterMark });
|
|
9782
9818
|
this.stream.on("error", () => {
|
|
9783
9819
|
this.stream = null;
|
|
9784
9820
|
});
|
|
@@ -10888,7 +10924,7 @@ async function registerDesktopPreview() {
|
|
|
10888
10924
|
}
|
|
10889
10925
|
|
|
10890
10926
|
// src/services/chat/chat-service.ts
|
|
10891
|
-
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir22, readFile as readFile22, rename as rename5, rm as
|
|
10927
|
+
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir22, readFile as readFile22, rename as rename5, rm as rm4 } from "fs/promises";
|
|
10892
10928
|
import { join as join37 } from "path";
|
|
10893
10929
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
10894
10930
|
|
|
@@ -11537,7 +11573,7 @@ async function saveNormalizedImagesToTempFiles(images, tempImageDir = join13(hom
|
|
|
11537
11573
|
return tempPaths;
|
|
11538
11574
|
}
|
|
11539
11575
|
async function removeTempImageFiles(paths) {
|
|
11540
|
-
await Promise.allSettled(paths.map((
|
|
11576
|
+
await Promise.allSettled(paths.map((path7) => unlink2(path7)));
|
|
11541
11577
|
}
|
|
11542
11578
|
|
|
11543
11579
|
// src/managers/coding-agent-manager.ts
|
|
@@ -12448,7 +12484,7 @@ async function getSkillRegistryInventory(homeDir) {
|
|
|
12448
12484
|
async function buildClaudeRegistryConfig(homeDir) {
|
|
12449
12485
|
const inventory = await getSkillRegistryInventory(homeDir);
|
|
12450
12486
|
return {
|
|
12451
|
-
plugins: inventory.claudePluginRoots.map((
|
|
12487
|
+
plugins: inventory.claudePluginRoots.map((path7) => ({ type: "local", path: path7 })),
|
|
12452
12488
|
enableAllSkills: inventory.claudePluginRoots.length > 0 || inventory.standaloneSkills.length > 0
|
|
12453
12489
|
};
|
|
12454
12490
|
}
|
|
@@ -12606,31 +12642,31 @@ function uniqueStandaloneSkills(skills) {
|
|
|
12606
12642
|
}
|
|
12607
12643
|
return unique;
|
|
12608
12644
|
}
|
|
12609
|
-
async function safeReadDir(
|
|
12645
|
+
async function safeReadDir(path7) {
|
|
12610
12646
|
try {
|
|
12611
|
-
return await readdir3(
|
|
12647
|
+
return await readdir3(path7, { withFileTypes: true });
|
|
12612
12648
|
} catch (error) {
|
|
12613
12649
|
if (isNotFoundError(error)) return [];
|
|
12614
12650
|
throw error;
|
|
12615
12651
|
}
|
|
12616
12652
|
}
|
|
12617
|
-
async function isDirectoryDirent(dirent,
|
|
12653
|
+
async function isDirectoryDirent(dirent, path7) {
|
|
12618
12654
|
if (dirent.isDirectory()) return true;
|
|
12619
12655
|
if (!dirent.isSymbolicLink()) return false;
|
|
12620
|
-
return directoryExists(
|
|
12656
|
+
return directoryExists(path7);
|
|
12621
12657
|
}
|
|
12622
|
-
async function directoryExists(
|
|
12658
|
+
async function directoryExists(path7) {
|
|
12623
12659
|
try {
|
|
12624
|
-
const pathStat = await stat2(
|
|
12660
|
+
const pathStat = await stat2(path7);
|
|
12625
12661
|
return pathStat.isDirectory();
|
|
12626
12662
|
} catch (error) {
|
|
12627
12663
|
if (isNotFoundError(error)) return false;
|
|
12628
12664
|
throw error;
|
|
12629
12665
|
}
|
|
12630
12666
|
}
|
|
12631
|
-
async function fileExists(
|
|
12667
|
+
async function fileExists(path7) {
|
|
12632
12668
|
try {
|
|
12633
|
-
const pathStat = await stat2(
|
|
12669
|
+
const pathStat = await stat2(path7);
|
|
12634
12670
|
return pathStat.isFile();
|
|
12635
12671
|
} catch (error) {
|
|
12636
12672
|
if (isNotFoundError(error)) return false;
|
|
@@ -14541,16 +14577,16 @@ function transcriptItemsForTurn(turn) {
|
|
|
14541
14577
|
const otherItems = turn.items.filter((item) => item.type !== "userMessage");
|
|
14542
14578
|
return [...userItems, ...otherItems];
|
|
14543
14579
|
}
|
|
14544
|
-
function userImageForLocalPath(
|
|
14545
|
-
const cached = localImageCache.get(
|
|
14580
|
+
function userImageForLocalPath(path7) {
|
|
14581
|
+
const cached = localImageCache.get(path7);
|
|
14546
14582
|
if (cached) return cached;
|
|
14547
|
-
if (!existsSync7(
|
|
14583
|
+
if (!existsSync7(path7)) return null;
|
|
14548
14584
|
const image = {
|
|
14549
14585
|
type: "image",
|
|
14550
|
-
mediaType: inferMediaType(
|
|
14551
|
-
data: readFileSync3(
|
|
14586
|
+
mediaType: inferMediaType(path7),
|
|
14587
|
+
data: readFileSync3(path7).toString("base64")
|
|
14552
14588
|
};
|
|
14553
|
-
if (image.data.length > 0) localImageCache.set(
|
|
14589
|
+
if (image.data.length > 0) localImageCache.set(path7, image);
|
|
14554
14590
|
return image;
|
|
14555
14591
|
}
|
|
14556
14592
|
function userImagesForInput(input) {
|
|
@@ -14841,9 +14877,9 @@ async function buildTurnInput(request) {
|
|
|
14841
14877
|
}
|
|
14842
14878
|
const normalizedImages = await normalizeImages(request.images);
|
|
14843
14879
|
const tempImagePaths = await saveNormalizedImagesToTempFiles(normalizedImages);
|
|
14844
|
-
input.push(...tempImagePaths.map((
|
|
14880
|
+
input.push(...tempImagePaths.map((path7) => ({
|
|
14845
14881
|
type: "localImage",
|
|
14846
|
-
path:
|
|
14882
|
+
path: path7
|
|
14847
14883
|
})));
|
|
14848
14884
|
return { input, tempImagePaths };
|
|
14849
14885
|
}
|
|
@@ -16046,12 +16082,12 @@ var postToolHookPath = [
|
|
|
16046
16082
|
join18(moduleDirectory, "post-tool-pr-hook.js"),
|
|
16047
16083
|
join18(moduleDirectory, "..", "post-tool-pr-hook.ts")
|
|
16048
16084
|
].find(existsSync8);
|
|
16049
|
-
function shellCommand(
|
|
16050
|
-
if (!
|
|
16085
|
+
function shellCommand(path7, provider) {
|
|
16086
|
+
if (!path7) throw new Error("Replicas hook executable is missing.");
|
|
16051
16087
|
const args = [
|
|
16052
16088
|
process.execPath,
|
|
16053
|
-
...
|
|
16054
|
-
|
|
16089
|
+
...path7.endsWith(".ts") && basename(process.execPath) !== "bun" ? ["--import", "tsx"] : [],
|
|
16090
|
+
path7,
|
|
16055
16091
|
...provider ? [provider] : []
|
|
16056
16092
|
];
|
|
16057
16093
|
return args.map((value) => `'${value.replaceAll("'", "'\\''")}'`).join(" ");
|
|
@@ -16065,10 +16101,10 @@ function getPostToolPrHookPath() {
|
|
|
16065
16101
|
return postToolHookPath;
|
|
16066
16102
|
}
|
|
16067
16103
|
async function ensureCursorCommandProtectionHook() {
|
|
16068
|
-
const
|
|
16104
|
+
const path7 = join18(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
|
|
16069
16105
|
let config = {};
|
|
16070
16106
|
try {
|
|
16071
|
-
const parsed = JSON.parse(await readFile11(
|
|
16107
|
+
const parsed = JSON.parse(await readFile11(path7, "utf8"));
|
|
16072
16108
|
if (!isRecord2(parsed)) throw new Error("Invalid Cursor hooks configuration.");
|
|
16073
16109
|
config = parsed;
|
|
16074
16110
|
} catch (error) {
|
|
@@ -16085,15 +16121,15 @@ async function ensureCursorCommandProtectionHook() {
|
|
|
16085
16121
|
...existingPost.filter((entry) => !isRecord2(entry) || typeof entry.command !== "string" || !entry.command.includes("post-tool-pr-hook")),
|
|
16086
16122
|
{ command: shellCommand(postToolHookPath) }
|
|
16087
16123
|
];
|
|
16088
|
-
await mkdir12(dirname5(
|
|
16089
|
-
await writeFile7(
|
|
16124
|
+
await mkdir12(dirname5(path7), { recursive: true });
|
|
16125
|
+
await writeFile7(path7, `${JSON.stringify({ ...config, version: 1, hooks }, null, 2)}
|
|
16090
16126
|
`, "utf8");
|
|
16091
16127
|
}
|
|
16092
16128
|
async function ensureGeminiCommandProtectionHook() {
|
|
16093
|
-
const
|
|
16129
|
+
const path7 = join18(ENGINE_ENV.HOME_DIR, ".gemini", "settings.json");
|
|
16094
16130
|
let config = {};
|
|
16095
16131
|
try {
|
|
16096
|
-
const parsed = JSON.parse(await readFile11(
|
|
16132
|
+
const parsed = JSON.parse(await readFile11(path7, "utf8"));
|
|
16097
16133
|
if (!isRecord2(parsed)) throw new Error("Invalid Gemini hooks configuration.");
|
|
16098
16134
|
config = parsed;
|
|
16099
16135
|
} catch (error) {
|
|
@@ -16113,17 +16149,17 @@ async function ensureGeminiCommandProtectionHook() {
|
|
|
16113
16149
|
...without(hooks.AfterTool, "replicas-post-tool-pr-check"),
|
|
16114
16150
|
hook("replicas-post-tool-pr-check", shellCommand(postToolHookPath))
|
|
16115
16151
|
];
|
|
16116
|
-
await mkdir12(dirname5(
|
|
16117
|
-
await writeFile7(
|
|
16152
|
+
await mkdir12(dirname5(path7), { recursive: true });
|
|
16153
|
+
await writeFile7(path7, `${JSON.stringify({ ...config, hooks }, null, 2)}
|
|
16118
16154
|
`, "utf8");
|
|
16119
16155
|
}
|
|
16120
16156
|
async function ensureKimiCommandProtectionHook() {
|
|
16121
|
-
const
|
|
16157
|
+
const path7 = join18(ENGINE_ENV.HOME_DIR, ".kimi-code", "config.toml");
|
|
16122
16158
|
const start = "# Replicas command protection hook";
|
|
16123
16159
|
const end = "# End Replicas command protection hook";
|
|
16124
16160
|
let config = "";
|
|
16125
16161
|
try {
|
|
16126
|
-
config = await readFile11(
|
|
16162
|
+
config = await readFile11(path7, "utf8");
|
|
16127
16163
|
} catch (error) {
|
|
16128
16164
|
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
|
|
16129
16165
|
}
|
|
@@ -16142,8 +16178,8 @@ ${end}`;
|
|
|
16142
16178
|
const markerEnd = config.indexOf(end, markerStart + start.length);
|
|
16143
16179
|
config = markerStart >= 0 && markerEnd >= 0 ? `${config.slice(0, markerStart)}${block}${config.slice(markerEnd + end.length)}` : `${config.trimEnd()}${config.trim() ? "\n\n" : ""}${block}
|
|
16144
16180
|
`;
|
|
16145
|
-
await mkdir12(dirname5(
|
|
16146
|
-
await writeFile7(
|
|
16181
|
+
await mkdir12(dirname5(path7), { recursive: true });
|
|
16182
|
+
await writeFile7(path7, config, "utf8");
|
|
16147
16183
|
}
|
|
16148
16184
|
|
|
16149
16185
|
// src/managers/cursor-run-recovery.ts
|
|
@@ -16712,8 +16748,8 @@ var DeepseekApiClient = class extends AbstractApiClient {
|
|
|
16712
16748
|
if (!execution.success) throw new Error(`DeepSeek Harness did not recognize ${line}.`);
|
|
16713
16749
|
if (execution.data.result.kind === "error") throw new Error(execution.data.result.text ?? `DeepSeek Harness rejected ${line}.`);
|
|
16714
16750
|
}
|
|
16715
|
-
async *readWebSocket(
|
|
16716
|
-
const url3 = new URL(
|
|
16751
|
+
async *readWebSocket(path7, signal, schema, onOpen) {
|
|
16752
|
+
const url3 = new URL(path7, this.baseUrl);
|
|
16717
16753
|
url3.protocol = url3.protocol === "https:" ? "wss:" : "ws:";
|
|
16718
16754
|
const socket = new WebSocket(url3);
|
|
16719
16755
|
const inbox = [];
|
|
@@ -18258,7 +18294,7 @@ ${pending}
|
|
|
18258
18294
|
|
|
18259
18295
|
// src/managers/opencode-manager.ts
|
|
18260
18296
|
import { existsSync as existsSync10 } from "fs";
|
|
18261
|
-
import { copyFile, mkdir as mkdir17, readFile as readFile16, rm as
|
|
18297
|
+
import { copyFile, mkdir as mkdir17, readFile as readFile16, rm as rm2 } from "fs/promises";
|
|
18262
18298
|
import { delimiter, dirname as dirname10, join as join22 } from "path";
|
|
18263
18299
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
18264
18300
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -18620,7 +18656,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18620
18656
|
}
|
|
18621
18657
|
await mkdir17(dirname10(OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH), { recursive: true });
|
|
18622
18658
|
await copyFile(OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE, OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH);
|
|
18623
|
-
await
|
|
18659
|
+
await rm2(OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH, { force: true });
|
|
18624
18660
|
process.env.REPLICAS_COMMAND_PROTECTION_HOOK_PATH = getCommandProtectionHookPath();
|
|
18625
18661
|
process.env.REPLICAS_POST_TOOL_PR_HOOK_PATH = getPostToolPrHookPath();
|
|
18626
18662
|
process.env.REPLICAS_COMMAND_PROTECTION_RUNTIME_PATH = process.execPath;
|
|
@@ -27510,9 +27546,9 @@ var rev2026Codec = {
|
|
|
27510
27546
|
});
|
|
27511
27547
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta);
|
|
27512
27548
|
if (!parsed.success) for (const issue of parsed.error.issues) {
|
|
27513
|
-
const
|
|
27514
|
-
const key =
|
|
27515
|
-
if (
|
|
27549
|
+
const path7 = issue.path.map(String);
|
|
27550
|
+
const key = path7.length > 0 ? path7.join(".") : "_meta";
|
|
27551
|
+
if (path7.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing")) continue;
|
|
27516
27552
|
issues.push({
|
|
27517
27553
|
key,
|
|
27518
27554
|
problem: issue.message
|
|
@@ -27811,29 +27847,29 @@ var PERMITTED_X_MCP_HEADER_TYPES = /* @__PURE__ */ new Set([
|
|
|
27811
27847
|
function scanXMcpHeaderDeclarations(inputSchema) {
|
|
27812
27848
|
const declarations = [];
|
|
27813
27849
|
const seenLower = /* @__PURE__ */ new Map();
|
|
27814
|
-
const visit = (node,
|
|
27850
|
+
const visit = (node, path7, reachable) => {
|
|
27815
27851
|
if (node === null || typeof node !== "object") return void 0;
|
|
27816
27852
|
const schema = node;
|
|
27817
27853
|
if (X_MCP_HEADER_KEY in schema) {
|
|
27818
|
-
if (!reachable ||
|
|
27854
|
+
if (!reachable || path7.length === 0) return `${pathName(path7)}: 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)`;
|
|
27819
27855
|
const raw = schema[X_MCP_HEADER_KEY];
|
|
27820
|
-
if (typeof raw !== "string" || raw.length === 0) return `${pathName(
|
|
27821
|
-
if (!RFC9110_TOKEN.test(raw)) return `${pathName(
|
|
27856
|
+
if (typeof raw !== "string" || raw.length === 0) return `${pathName(path7)}: x-mcp-header MUST be a non-empty string`;
|
|
27857
|
+
if (!RFC9110_TOKEN.test(raw)) return `${pathName(path7)}: x-mcp-header '${raw}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;
|
|
27822
27858
|
const type = typeof schema.type === "string" ? schema.type : void 0;
|
|
27823
|
-
if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(
|
|
27859
|
+
if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(path7)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${type ?? "<none>"}`;
|
|
27824
27860
|
const lower = raw.toLowerCase();
|
|
27825
27861
|
const prior = seenLower.get(lower);
|
|
27826
27862
|
if (prior !== void 0) return `x-mcp-header '${raw}' is not case-insensitively unique (also declared as '${prior}')`;
|
|
27827
27863
|
seenLower.set(lower, raw);
|
|
27828
27864
|
declarations.push({
|
|
27829
|
-
path:
|
|
27865
|
+
path: path7,
|
|
27830
27866
|
headerName: raw,
|
|
27831
27867
|
type
|
|
27832
27868
|
});
|
|
27833
27869
|
}
|
|
27834
27870
|
const properties = schema.properties;
|
|
27835
27871
|
if (properties !== null && typeof properties === "object") for (const [key, child] of Object.entries(properties)) {
|
|
27836
|
-
const fault$1 = visit(child, [...
|
|
27872
|
+
const fault$1 = visit(child, [...path7, key], reachable);
|
|
27837
27873
|
if (fault$1 !== void 0) return fault$1;
|
|
27838
27874
|
}
|
|
27839
27875
|
for (const k of NON_REACHABLE_SUBSCHEMA_KEYWORDS) {
|
|
@@ -27841,7 +27877,7 @@ function scanXMcpHeaderDeclarations(inputSchema) {
|
|
|
27841
27877
|
if (sub === void 0) continue;
|
|
27842
27878
|
const branches = Array.isArray(sub) ? sub : sub !== null && typeof sub === "object" && OBJECT_VALUED_SUBSCHEMA_KEYWORDS.has(k) ? Object.values(sub) : [sub];
|
|
27843
27879
|
for (const branch of branches) {
|
|
27844
|
-
const fault$1 = visit(branch, [...
|
|
27880
|
+
const fault$1 = visit(branch, [...path7, `<${k}>`], false);
|
|
27845
27881
|
if (fault$1 !== void 0) return fault$1;
|
|
27846
27882
|
}
|
|
27847
27883
|
}
|
|
@@ -27881,8 +27917,8 @@ var OBJECT_VALUED_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
27881
27917
|
"$defs",
|
|
27882
27918
|
"definitions"
|
|
27883
27919
|
]);
|
|
27884
|
-
function pathName(
|
|
27885
|
-
return
|
|
27920
|
+
function pathName(path7) {
|
|
27921
|
+
return path7.length === 0 ? "<root>" : path7.join(".");
|
|
27886
27922
|
}
|
|
27887
27923
|
var BASE64_SENTINEL_PREFIX = "=?base64?";
|
|
27888
27924
|
var BASE64_SENTINEL_SUFFIX = "?=";
|
|
@@ -27915,9 +27951,9 @@ function utf8ToBase64(s) {
|
|
|
27915
27951
|
function encodeMcpParamValue(value) {
|
|
27916
27952
|
return needsBase64(value) ? `${BASE64_SENTINEL_PREFIX}${utf8ToBase64(value)}${BASE64_SENTINEL_SUFFIX}` : value;
|
|
27917
27953
|
}
|
|
27918
|
-
function valueAtPath(root,
|
|
27954
|
+
function valueAtPath(root, path7) {
|
|
27919
27955
|
let node = root;
|
|
27920
|
-
for (const key of
|
|
27956
|
+
for (const key of path7) {
|
|
27921
27957
|
if (node === null || typeof node !== "object") return void 0;
|
|
27922
27958
|
node = node[key];
|
|
27923
27959
|
}
|
|
@@ -28172,7 +28208,7 @@ var PROPERTY_KEYS_BY_TYPE = {
|
|
|
28172
28208
|
array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
|
|
28173
28209
|
};
|
|
28174
28210
|
var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
|
|
28175
|
-
function walkProperty(node,
|
|
28211
|
+
function walkProperty(node, path7, vendor, unsupported) {
|
|
28176
28212
|
if (!isJsonObject(node)) return node;
|
|
28177
28213
|
const allowedKeys = typeof node.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node.type) ? PROPERTY_KEYS_BY_TYPE[node.type] : void 0;
|
|
28178
28214
|
if (allowedKeys === void 0) return node;
|
|
@@ -28180,8 +28216,8 @@ function walkProperty(node, path8, vendor, unsupported) {
|
|
|
28180
28216
|
for (const [key, value] of Object.entries(node)) if (allowedKeys.has(key) || isAnnotationOnlyJsonSchemaKeyword(key)) pruned[key] = value;
|
|
28181
28217
|
else if (key === "pattern" && node.type === "string" && typeof node.format === "string") {
|
|
28182
28218
|
if (!SUPPORTED_STRING_FORMATS.has(node.format)) pruned[key] = value;
|
|
28183
|
-
else if (typeof value !== "string" || !isLibraryFormatPattern(node.format, value, vendor)) unsupported.push(`${
|
|
28184
|
-
} else unsupported.push(`${
|
|
28219
|
+
else if (typeof value !== "string" || !isLibraryFormatPattern(node.format, value, vendor)) unsupported.push(`${path7}.${key}`);
|
|
28220
|
+
} else unsupported.push(`${path7}.${key}`);
|
|
28185
28221
|
return pruned;
|
|
28186
28222
|
}
|
|
28187
28223
|
function walkRequestedSchema(converted, vendor) {
|
|
@@ -28198,11 +28234,11 @@ function describeUnsupportedProperties(pruned, fallback) {
|
|
|
28198
28234
|
const offenders = Object.entries(pruned.properties).filter(([, node]) => !parseSchema(PrimitiveSchemaDefinitionSchema, node).success).map(([name]) => `properties.${name}`);
|
|
28199
28235
|
return offenders.length > 0 ? offenders.join(", ") : fallback;
|
|
28200
28236
|
}
|
|
28201
|
-
function findDroppedConstraintPaths(original, parsed,
|
|
28202
|
-
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${
|
|
28237
|
+
function findDroppedConstraintPaths(original, parsed, path7 = "") {
|
|
28238
|
+
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path7}[${index}]`));
|
|
28203
28239
|
if (!isJsonObject(original) || !isJsonObject(parsed)) return [];
|
|
28204
28240
|
return Object.entries(original).flatMap(([key, value]) => {
|
|
28205
|
-
const childPath =
|
|
28241
|
+
const childPath = path7 ? `${path7}.${key}` : key;
|
|
28206
28242
|
if (!Object.prototype.hasOwnProperty.call(parsed, key)) return isAnnotationOnlyJsonSchemaKeyword(key) ? [] : [childPath];
|
|
28207
28243
|
return findDroppedConstraintPaths(value, parsed[key], childPath);
|
|
28208
28244
|
});
|
|
@@ -32382,8 +32418,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32382
32418
|
for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
|
|
32383
32419
|
return ind;
|
|
32384
32420
|
}
|
|
32385
|
-
function removeDotSegments(
|
|
32386
|
-
let input =
|
|
32421
|
+
function removeDotSegments(path7) {
|
|
32422
|
+
let input = path7;
|
|
32387
32423
|
const output = [];
|
|
32388
32424
|
let nextSlash = -1;
|
|
32389
32425
|
let len = 0;
|
|
@@ -32536,8 +32572,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32536
32572
|
wsComponent.secure = void 0;
|
|
32537
32573
|
}
|
|
32538
32574
|
if (wsComponent.resourceName) {
|
|
32539
|
-
const [
|
|
32540
|
-
wsComponent.path =
|
|
32575
|
+
const [path7, query2] = wsComponent.resourceName.split("?");
|
|
32576
|
+
wsComponent.path = path7 && path7 !== "/" ? path7 : void 0;
|
|
32541
32577
|
wsComponent.query = query2;
|
|
32542
32578
|
wsComponent.resourceName = void 0;
|
|
32543
32579
|
}
|
|
@@ -41856,8 +41892,8 @@ function getNpmCacheDir() {
|
|
|
41856
41892
|
try {
|
|
41857
41893
|
const result = import_cross_spawn2.default.sync("npm", ["config", "get", "cache"], { encoding: "utf-8" });
|
|
41858
41894
|
if (result.status === 0) {
|
|
41859
|
-
const
|
|
41860
|
-
npmCacheDirCached =
|
|
41895
|
+
const path7 = String(result.stdout).trim();
|
|
41896
|
+
npmCacheDirCached = path7 || null;
|
|
41861
41897
|
return npmCacheDirCached;
|
|
41862
41898
|
}
|
|
41863
41899
|
} catch {
|
|
@@ -41945,16 +41981,16 @@ function saveCacheEntry(key, entry) {
|
|
|
41945
41981
|
} catch {
|
|
41946
41982
|
}
|
|
41947
41983
|
}
|
|
41948
|
-
function safeRealpath(
|
|
41984
|
+
function safeRealpath(path7) {
|
|
41949
41985
|
try {
|
|
41950
|
-
return realpathSync(
|
|
41986
|
+
return realpathSync(path7);
|
|
41951
41987
|
} catch {
|
|
41952
41988
|
return "";
|
|
41953
41989
|
}
|
|
41954
41990
|
}
|
|
41955
|
-
function safeStatMtime(
|
|
41991
|
+
function safeStatMtime(path7) {
|
|
41956
41992
|
try {
|
|
41957
|
-
return statSync2(
|
|
41993
|
+
return statSync2(path7).mtimeMs;
|
|
41958
41994
|
} catch {
|
|
41959
41995
|
return 0;
|
|
41960
41996
|
}
|
|
@@ -42699,8 +42735,8 @@ function setOAuthCallbackPort(port2) {
|
|
|
42699
42735
|
function getOAuthCallbackPath() {
|
|
42700
42736
|
return oauthCallbackPath;
|
|
42701
42737
|
}
|
|
42702
|
-
function setOAuthCallbackPath(
|
|
42703
|
-
oauthCallbackPath =
|
|
42738
|
+
function setOAuthCallbackPath(path7) {
|
|
42739
|
+
oauthCallbackPath = path7.startsWith("/") ? path7 : `/${path7}`;
|
|
42704
42740
|
}
|
|
42705
42741
|
var reservedAuthorizationParams = /* @__PURE__ */ new Set([
|
|
42706
42742
|
"client_id",
|
|
@@ -43213,7 +43249,7 @@ var McpOAuthProvider = class {
|
|
|
43213
43249
|
// ../node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
43214
43250
|
import process9 from "process";
|
|
43215
43251
|
import { Buffer as Buffer2 } from "buffer";
|
|
43216
|
-
import
|
|
43252
|
+
import path5 from "path";
|
|
43217
43253
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
43218
43254
|
import { promisify as promisify5 } from "util";
|
|
43219
43255
|
import childProcess from "child_process";
|
|
@@ -43471,8 +43507,8 @@ async function defaultBrowser2() {
|
|
|
43471
43507
|
|
|
43472
43508
|
// ../node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
43473
43509
|
var execFile5 = promisify5(childProcess.execFile);
|
|
43474
|
-
var __dirname =
|
|
43475
|
-
var localXdgOpenPath =
|
|
43510
|
+
var __dirname = path5.dirname(fileURLToPath5(import.meta.url));
|
|
43511
|
+
var localXdgOpenPath = path5.join(__dirname, "xdg-open");
|
|
43476
43512
|
var { platform, arch } = process9;
|
|
43477
43513
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
43478
43514
|
const powershellPath = await powerShellPath();
|
|
@@ -45671,14 +45707,14 @@ var McpTraceWriter = class {
|
|
|
45671
45707
|
this.options = options;
|
|
45672
45708
|
this.maxBytes = boundedPositiveInteger(options.maxBytes, DEFAULT_MCP_TRACE_MAX_BYTES);
|
|
45673
45709
|
this.maxEvents = boundedPositiveInteger(options.maxEvents, DEFAULT_MCP_TRACE_MAX_EVENTS);
|
|
45674
|
-
this.append = options.appendFile ?? (async (
|
|
45675
|
-
await appendFile3(
|
|
45710
|
+
this.append = options.appendFile ?? (async (path7, data, appendOptions) => {
|
|
45711
|
+
await appendFile3(path7, data, appendOptions);
|
|
45676
45712
|
});
|
|
45677
|
-
this.resetFile = options.writeFile ?? (async (
|
|
45678
|
-
await writeFile10(
|
|
45713
|
+
this.resetFile = options.writeFile ?? (async (path7, data, writeOptions) => {
|
|
45714
|
+
await writeFile10(path7, data, writeOptions);
|
|
45679
45715
|
});
|
|
45680
|
-
this.makeDirectory = options.mkdir ?? (async (
|
|
45681
|
-
await mkdir18(
|
|
45716
|
+
this.makeDirectory = options.mkdir ?? (async (path7) => {
|
|
45717
|
+
await mkdir18(path7, { recursive: true });
|
|
45682
45718
|
return void 0;
|
|
45683
45719
|
});
|
|
45684
45720
|
this.fileReady = this.makeDirectory(dirname14(this.options.filePath), { recursive: true }).then(() => this.resetFile(this.options.filePath, "", { encoding: "utf8" })).catch(() => {
|
|
@@ -48817,10 +48853,10 @@ function getOnboardingStatePath() {
|
|
|
48817
48853
|
return getAgentPath("mcp-onboarding.json");
|
|
48818
48854
|
}
|
|
48819
48855
|
function loadOnboardingState() {
|
|
48820
|
-
const
|
|
48821
|
-
if (!existsSync14(
|
|
48856
|
+
const path7 = getOnboardingStatePath();
|
|
48857
|
+
if (!existsSync14(path7)) return { ...DEFAULT_STATE2 };
|
|
48822
48858
|
try {
|
|
48823
|
-
const raw = JSON.parse(readFileSync6(
|
|
48859
|
+
const raw = JSON.parse(readFileSync6(path7, "utf-8"));
|
|
48824
48860
|
if (!raw || typeof raw !== "object") return { ...DEFAULT_STATE2 };
|
|
48825
48861
|
return {
|
|
48826
48862
|
version: 1,
|
|
@@ -48833,12 +48869,12 @@ function loadOnboardingState() {
|
|
|
48833
48869
|
}
|
|
48834
48870
|
}
|
|
48835
48871
|
function saveOnboardingState(state) {
|
|
48836
|
-
const
|
|
48837
|
-
mkdirSync3(dirname15(
|
|
48838
|
-
const tmpPath = `${
|
|
48872
|
+
const path7 = getOnboardingStatePath();
|
|
48873
|
+
mkdirSync3(dirname15(path7), { recursive: true });
|
|
48874
|
+
const tmpPath = `${path7}.${process.pid}.tmp`;
|
|
48839
48875
|
writeFileSync2(tmpPath, `${JSON.stringify(state, null, 2)}
|
|
48840
48876
|
`, "utf-8");
|
|
48841
|
-
renameSync2(tmpPath,
|
|
48877
|
+
renameSync2(tmpPath, path7);
|
|
48842
48878
|
}
|
|
48843
48879
|
function updateOnboardingState(updater) {
|
|
48844
48880
|
const next = updater(loadOnboardingState());
|
|
@@ -49251,23 +49287,23 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
|
|
|
49251
49287
|
return result;
|
|
49252
49288
|
},
|
|
49253
49289
|
scaffoldConfig: async (target) => {
|
|
49254
|
-
const
|
|
49290
|
+
const path7 = writeStarterSharedConfig(target, ctx.cwd);
|
|
49255
49291
|
configChanged = true;
|
|
49256
|
-
return { path:
|
|
49292
|
+
return { path: path7 };
|
|
49257
49293
|
},
|
|
49258
49294
|
addRepoPrompt: async (target) => {
|
|
49259
49295
|
const repoPrompt = getMcpDiscoverySummary(configOverridePath, ctx.cwd, options).repoPrompt;
|
|
49260
49296
|
if (!repoPrompt.entry || !repoPrompt.targetPath || !repoPrompt.serverName) {
|
|
49261
49297
|
throw new Error("RepoPrompt is not available to add from this setup screen.");
|
|
49262
49298
|
}
|
|
49263
|
-
const
|
|
49299
|
+
const path7 = writeSharedServerEntry(getSharedConfigPath(target, ctx.cwd), repoPrompt.serverName, repoPrompt.entry);
|
|
49264
49300
|
configChanged = true;
|
|
49265
|
-
return { path:
|
|
49301
|
+
return { path: path7, serverName: repoPrompt.serverName };
|
|
49266
49302
|
},
|
|
49267
49303
|
addKnownServer: async (preset, target) => {
|
|
49268
|
-
const
|
|
49304
|
+
const path7 = writeSharedServerEntry(getSharedConfigPath(target, ctx.cwd), preset.id, preset.entry);
|
|
49269
49305
|
configChanged = true;
|
|
49270
|
-
return { path:
|
|
49306
|
+
return { path: path7, serverName: preset.name };
|
|
49271
49307
|
},
|
|
49272
49308
|
openPath: async (targetPath) => {
|
|
49273
49309
|
await openPath(pi, targetPath);
|
|
@@ -49663,7 +49699,7 @@ function stringifyStructuredContent(value) {
|
|
|
49663
49699
|
|
|
49664
49700
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-output-guard.ts
|
|
49665
49701
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
49666
|
-
import { mkdtemp, rm as
|
|
49702
|
+
import { mkdtemp, rm as rm3, writeFile as writeFile11 } from "fs/promises";
|
|
49667
49703
|
import { tmpdir as tmpdir2 } from "os";
|
|
49668
49704
|
import { dirname as dirname16, join as join28 } from "path";
|
|
49669
49705
|
var DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
|
|
@@ -49974,16 +50010,16 @@ function serializedObjectEntryBytes(key, value, hasPrevious) {
|
|
|
49974
50010
|
async function saveArtifact(kind, text) {
|
|
49975
50011
|
try {
|
|
49976
50012
|
const dir = await mkdtemp(join28(tmpdir2(), "pi-mcp-output-"));
|
|
49977
|
-
const
|
|
49978
|
-
await writeFile11(
|
|
49979
|
-
return { path:
|
|
50013
|
+
const path7 = join28(dir, `${kind}-${randomBytes4(4).toString("hex")}.txt`);
|
|
50014
|
+
await writeFile11(path7, text, { encoding: "utf8", mode: 384 });
|
|
50015
|
+
return { path: path7 };
|
|
49980
50016
|
} catch (error) {
|
|
49981
50017
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
49982
50018
|
}
|
|
49983
50019
|
}
|
|
49984
|
-
async function discardArtifact(
|
|
50020
|
+
async function discardArtifact(path7) {
|
|
49985
50021
|
try {
|
|
49986
|
-
await
|
|
50022
|
+
await rm3(dirname16(path7), { recursive: true, force: true });
|
|
49987
50023
|
} catch {
|
|
49988
50024
|
}
|
|
49989
50025
|
}
|
|
@@ -50029,7 +50065,7 @@ import net from "net";
|
|
|
50029
50065
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ui-server.ts
|
|
50030
50066
|
import http2 from "http";
|
|
50031
50067
|
import fs7 from "fs/promises";
|
|
50032
|
-
import
|
|
50068
|
+
import path6 from "path";
|
|
50033
50069
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
50034
50070
|
|
|
50035
50071
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/host-html-template.ts
|
|
@@ -51126,7 +51162,7 @@ data: ${JSON.stringify(payload)}
|
|
|
51126
51162
|
return;
|
|
51127
51163
|
}
|
|
51128
51164
|
if (method === "GET" && url3.pathname === "/app-bridge.bundle.js") {
|
|
51129
|
-
const bundlePath =
|
|
51165
|
+
const bundlePath = path6.join(import.meta.dirname, "app-bridge.bundle.js");
|
|
51130
51166
|
try {
|
|
51131
51167
|
const content = await fs7.readFile(bundlePath, "utf-8");
|
|
51132
51168
|
res.writeHead(200, {
|
|
@@ -58074,22 +58110,22 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
58074
58110
|
durationMs: "error" in operation && operation.error === "incomplete" ? Math.max(0, Date.now() - startedAt) : operation.durationMs
|
|
58075
58111
|
}));
|
|
58076
58112
|
let callsSnapshot;
|
|
58077
|
-
const callTool = async (
|
|
58113
|
+
const callTool = async (path7, args) => {
|
|
58078
58114
|
const startedAt = Date.now();
|
|
58079
|
-
const index = calls.push({ operation: "call", path:
|
|
58080
|
-
const result = await executeCall(state,
|
|
58115
|
+
const index = calls.push({ operation: "call", path: path7, ok: false, error: "incomplete", durationMs: 0, startedAt }) - 1;
|
|
58116
|
+
const result = await executeCall(state, path7, args, void 0, getPiTools, callSignal, "script");
|
|
58081
58117
|
const details = result.details;
|
|
58082
58118
|
if (details.error !== void 0) {
|
|
58083
58119
|
const errorCode2 = String(details.error);
|
|
58084
58120
|
const suggestions = Array.isArray(details.suggestions) ? details.suggestions.filter((suggestion) => typeof suggestion === "string") : [];
|
|
58085
|
-
const message = errorCode2 === "tool_not_found" ? `Tool "${
|
|
58086
|
-
calls[index] = { operation: "call", path:
|
|
58121
|
+
const message = errorCode2 === "tool_not_found" ? `Tool "${path7}" 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);
|
|
58122
|
+
calls[index] = { operation: "call", path: path7, ok: false, error: errorCode2, durationMs: Date.now() - startedAt, startedAt };
|
|
58087
58123
|
return {
|
|
58088
58124
|
ok: false,
|
|
58089
58125
|
error: { code: errorCode2, message }
|
|
58090
58126
|
};
|
|
58091
58127
|
}
|
|
58092
|
-
calls[index] = { operation: "call", path:
|
|
58128
|
+
calls[index] = { operation: "call", path: path7, ok: true, durationMs: Date.now() - startedAt, startedAt };
|
|
58093
58129
|
return {
|
|
58094
58130
|
ok: true,
|
|
58095
58131
|
data: details.mcpResult !== void 0 ? details.mcpResult : textFromContent(result.content)
|
|
@@ -58126,12 +58162,12 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
58126
58162
|
};
|
|
58127
58163
|
const describeTool = (input) => {
|
|
58128
58164
|
const startedAt = Date.now();
|
|
58129
|
-
const
|
|
58165
|
+
const path7 = typeof input?.path === "string" ? input.path : "";
|
|
58130
58166
|
let error;
|
|
58131
58167
|
try {
|
|
58132
58168
|
for (const [server2, metadata] of state.toolMetadata) {
|
|
58133
58169
|
if (isServerInActiveFailureBackoff(state, server2)) continue;
|
|
58134
|
-
const tool = findToolByName(metadata,
|
|
58170
|
+
const tool = findToolByName(metadata, path7);
|
|
58135
58171
|
if (!tool) continue;
|
|
58136
58172
|
const inputTypeScript = tool.inputSchema ? renderTsShape(tool.inputSchema) ?? formatSchema(tool.inputSchema) : null;
|
|
58137
58173
|
return {
|
|
@@ -58142,13 +58178,13 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
58142
58178
|
...inputTypeScript ? { inputTypeScript } : {}
|
|
58143
58179
|
};
|
|
58144
58180
|
}
|
|
58145
|
-
const suggestions =
|
|
58181
|
+
const suggestions = path7 ? rankSuggestions(state, path7, 5) : [];
|
|
58146
58182
|
error = "tool_not_found";
|
|
58147
58183
|
return {
|
|
58148
|
-
path:
|
|
58184
|
+
path: path7,
|
|
58149
58185
|
error: {
|
|
58150
58186
|
code: "tool_not_found",
|
|
58151
|
-
message: `Tool not found: ${
|
|
58187
|
+
message: `Tool not found: ${path7}`,
|
|
58152
58188
|
suggestions
|
|
58153
58189
|
}
|
|
58154
58190
|
};
|
|
@@ -58156,7 +58192,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
58156
58192
|
error = caught;
|
|
58157
58193
|
throw caught;
|
|
58158
58194
|
} finally {
|
|
58159
|
-
calls.push(error === void 0 ? { operation: "describe", path:
|
|
58195
|
+
calls.push(error === void 0 ? { operation: "describe", path: path7, ok: true, durationMs: Date.now() - startedAt, startedAt } : { operation: "describe", path: path7, ok: false, error: error instanceof Error ? error.message : String(error), durationMs: Date.now() - startedAt, startedAt });
|
|
58160
58196
|
}
|
|
58161
58197
|
};
|
|
58162
58198
|
let worker;
|
|
@@ -61369,10 +61405,10 @@ function unansweredRequest(blocks) {
|
|
|
61369
61405
|
const answered = blocks.slice(lastUser + 1).some((block) => block.startsWith("## Agent"));
|
|
61370
61406
|
return answered ? null : lastUserBlockText(blocks);
|
|
61371
61407
|
}
|
|
61372
|
-
async function readHistoryTail(
|
|
61408
|
+
async function readHistoryTail(path7, maxBytes) {
|
|
61373
61409
|
let handle;
|
|
61374
61410
|
try {
|
|
61375
|
-
handle = await open3(
|
|
61411
|
+
handle = await open3(path7, "r");
|
|
61376
61412
|
} catch (error) {
|
|
61377
61413
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return { content: "", truncated: false };
|
|
61378
61414
|
throw error;
|
|
@@ -62163,9 +62199,9 @@ var ChatService = class {
|
|
|
62163
62199
|
historyPath,
|
|
62164
62200
|
`${historyPath}.pages.jsonl`,
|
|
62165
62201
|
`${historyPath}.pages.index.json`
|
|
62166
|
-
].map((
|
|
62167
|
-
await
|
|
62168
|
-
await
|
|
62202
|
+
].map((path7) => rm4(path7, { force: true })));
|
|
62203
|
+
await rm4(chatMessageSendersFilePath(persisted.id), { force: true });
|
|
62204
|
+
await rm4(join37(FORKS_DIR, persisted.id), { recursive: true, force: true });
|
|
62169
62205
|
}
|
|
62170
62206
|
/** Resolves once the target chat exists; the handoff and its first turn run in the background. */
|
|
62171
62207
|
async forkChat(sourceChatId, request, trigger = "manual", reason) {
|
|
@@ -62996,10 +63032,10 @@ var LanguageServerService = class {
|
|
|
62996
63032
|
const uri = "targetUri" in location ? location.targetUri : location.uri;
|
|
62997
63033
|
const range = "targetSelectionRange" in location ? location.targetSelectionRange : location.range;
|
|
62998
63034
|
const absolutePath = fileURLToPath6(uri);
|
|
62999
|
-
const
|
|
63000
|
-
if (
|
|
63035
|
+
const path7 = relative2(repoPath, absolutePath);
|
|
63036
|
+
if (path7.startsWith("..")) return [];
|
|
63001
63037
|
const preview = readFileSync8(absolutePath, "utf8").split("\n")[range.start.line]?.trim() ?? "";
|
|
63002
|
-
return [{ repoName, path:
|
|
63038
|
+
return [{ repoName, path: path7, line: range.start.line + 1, character: range.start.character, endCharacter: range.end.character, preview }];
|
|
63003
63039
|
});
|
|
63004
63040
|
return { symbol: "", detail: null, documentation: null, locations, provider: "language-server" };
|
|
63005
63041
|
} catch {
|
|
@@ -64392,11 +64428,11 @@ function createV1Routes(deps) {
|
|
|
64392
64428
|
});
|
|
64393
64429
|
app2.get("/repo-files/content", async (c) => {
|
|
64394
64430
|
const repoName = c.req.query("repoName");
|
|
64395
|
-
const
|
|
64396
|
-
if (!repoName || !
|
|
64431
|
+
const path7 = c.req.query("path");
|
|
64432
|
+
if (!repoName || !path7) {
|
|
64397
64433
|
return c.json(jsonError("repoName and path are required"), 400);
|
|
64398
64434
|
}
|
|
64399
|
-
const result = await deps.repoFileService.readFile(repoName,
|
|
64435
|
+
const result = await deps.repoFileService.readFile(repoName, path7);
|
|
64400
64436
|
if (!result) {
|
|
64401
64437
|
return c.json(jsonError("File not found"), 404);
|
|
64402
64438
|
}
|
|
@@ -64404,25 +64440,25 @@ function createV1Routes(deps) {
|
|
|
64404
64440
|
});
|
|
64405
64441
|
app2.put("/repo-files/content", async (c) => {
|
|
64406
64442
|
const repoName = c.req.query("repoName");
|
|
64407
|
-
const
|
|
64408
|
-
if (!repoName || !
|
|
64443
|
+
const path7 = c.req.query("path");
|
|
64444
|
+
if (!repoName || !path7) {
|
|
64409
64445
|
return c.json(jsonError("repoName and path are required"), 400);
|
|
64410
64446
|
}
|
|
64411
64447
|
const body = updateTextFileSchema(MAX_REPO_FILE_CONTENT_BYTES).parse(await c.req.json());
|
|
64412
|
-
const result = await deps.repoFileService.updateFile(repoName,
|
|
64448
|
+
const result = await deps.repoFileService.updateFile(repoName, path7, body.content, body.expectedRevision);
|
|
64413
64449
|
if (!result) return c.json(jsonError("File is not editable"), 400);
|
|
64414
64450
|
return c.json(result);
|
|
64415
64451
|
});
|
|
64416
64452
|
app2.get("/repo-files/symbol", async (c) => {
|
|
64417
64453
|
const repoName = c.req.query("repoName");
|
|
64418
|
-
const
|
|
64454
|
+
const path7 = c.req.query("path");
|
|
64419
64455
|
const action = c.req.query("action");
|
|
64420
64456
|
const line = Number(c.req.query("line"));
|
|
64421
64457
|
const character = Number(c.req.query("character"));
|
|
64422
|
-
if (!repoName || !
|
|
64458
|
+
if (!repoName || !path7 || action !== "hover" && action !== "definition" && action !== "references" || !Number.isInteger(line) || !Number.isInteger(character)) {
|
|
64423
64459
|
return c.json(jsonError("Invalid symbol request"), 400);
|
|
64424
64460
|
}
|
|
64425
|
-
const result = await deps.repoFileService.inspectSymbol(repoName,
|
|
64461
|
+
const result = await deps.repoFileService.inspectSymbol(repoName, path7, line, character, action);
|
|
64426
64462
|
if (!result) return c.json(jsonError("Symbol not found"), 404);
|
|
64427
64463
|
return c.json(result);
|
|
64428
64464
|
});
|
|
@@ -65073,8 +65109,7 @@ app.get("/token-refresh/health", async (c) => {
|
|
|
65073
65109
|
gitlab: gitlabTokenManager.getHealthStatus(),
|
|
65074
65110
|
claude: claudeTokenManager.getHealthStatus(),
|
|
65075
65111
|
codex: codexTokenManager.getHealthStatus(),
|
|
65076
|
-
infisical: infisicalTokenManager.getHealthStatus()
|
|
65077
|
-
workspaceIdentity: workspaceIdentityTokenManager.getHealthStatus()
|
|
65112
|
+
infisical: infisicalTokenManager.getHealthStatus()
|
|
65078
65113
|
});
|
|
65079
65114
|
});
|
|
65080
65115
|
app.post(GITHUB_CREDENTIAL_REFRESH_PATH, async (c) => {
|
|
@@ -65247,8 +65282,7 @@ serve(
|
|
|
65247
65282
|
await claudeTokenManager.start();
|
|
65248
65283
|
await codexTokenManager.start();
|
|
65249
65284
|
await infisicalTokenManager.start();
|
|
65250
|
-
|
|
65251
|
-
createIdentityProxy(() => workspaceIdentityTokenManager.bundle).on("error", (error) => console.error("[identity-proxy] failed to listen:", error)).listen(IDENTITY_PROXY_PORT, "127.0.0.1");
|
|
65285
|
+
createIdentityProxy(workspaceIdentityTokens).on("error", (error) => console.error("[identity-proxy] failed to listen:", error)).listen(IDENTITY_PROXY_PORT, "127.0.0.1");
|
|
65252
65286
|
}
|
|
65253
65287
|
const repos = await gitService.listRepos();
|
|
65254
65288
|
await eventService.publish({
|