replicas-engine 0.1.888 → 0.1.891
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-BGOXGPHG.js → asp-host-RKLHLTPR.js} +4 -4
- package/dist/src/{chunk-P7AHODJ6.js → chunk-4NFLZXZX.js} +2 -2
- package/dist/src/{chunk-N2DC3SCQ.js → chunk-DG4VIQXA.js} +1 -1
- package/dist/src/{chunk-ADX5FHF6.js → chunk-EDLDRUYW.js} +2 -2
- package/dist/src/{chunk-4DGHCMBQ.js → chunk-IB2SHITZ.js} +9 -4
- package/dist/src/{chunk-5RULOJKJ.js → chunk-OBAGPETY.js} +236 -123
- package/dist/src/{chunk-2JFHMLKJ.js → chunk-TDLEF5FU.js} +10 -5
- package/dist/src/chunk-U2T2QCYP.js +54 -0
- package/dist/src/command-protection-hook.js +3 -3
- package/dist/src/deepseek-command-protection-plugin.js +5 -4
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +605 -392
- package/dist/src/post-tool-pr-hook.js +4 -3
- package/dist/src/relay-mcp.js +1 -1
- package/package.json +1 -1
- package/scripts/opencode-command-protection-plugin.ts +10 -9
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-4NFLZXZX.js";
|
|
95
95
|
import {
|
|
96
96
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
97
97
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -114,6 +114,9 @@ import {
|
|
|
114
114
|
putPresignedFile,
|
|
115
115
|
recoverCompletedTurn
|
|
116
116
|
} from "./chunk-FLDA7BX3.js";
|
|
117
|
+
import {
|
|
118
|
+
publishedPullRequestUrls
|
|
119
|
+
} from "./chunk-U2T2QCYP.js";
|
|
117
120
|
import {
|
|
118
121
|
RELAY_MCP_TOOLS,
|
|
119
122
|
RELAY_MCP_TOOL_NAMES,
|
|
@@ -131,23 +134,24 @@ import {
|
|
|
131
134
|
listCredentialFallbacks,
|
|
132
135
|
recordCredentialFallback,
|
|
133
136
|
recordExhaustedCredential,
|
|
137
|
+
refreshDelayMs,
|
|
134
138
|
restartCodexAspHost,
|
|
135
139
|
routineRefreshExclusions
|
|
136
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-TDLEF5FU.js";
|
|
137
141
|
import {
|
|
138
142
|
ENGINE_ENV,
|
|
139
143
|
IS_WARMING_MODE,
|
|
140
144
|
monolithRequest,
|
|
141
145
|
monolithService,
|
|
142
146
|
setAgentCredentialSnapshot
|
|
143
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-DG4VIQXA.js";
|
|
144
148
|
import {
|
|
145
149
|
AspClient,
|
|
146
150
|
SUBPROCESS_MAX_BUFFER,
|
|
147
151
|
execAsync,
|
|
148
152
|
execFileAsync,
|
|
149
153
|
getCodexModelProvider
|
|
150
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-EDLDRUYW.js";
|
|
151
155
|
import {
|
|
152
156
|
isRecord as isRecord2
|
|
153
157
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -214,6 +218,7 @@ import {
|
|
|
214
218
|
GITLAB_CREDENTIAL_REFRESH_PATH,
|
|
215
219
|
GIT_CREDENTIAL_HELPER_FILENAME,
|
|
216
220
|
HOOK_EXEC_MAX_BUFFER_BYTES,
|
|
221
|
+
IDENTITY_PROXY_PORT,
|
|
217
222
|
IMAGE_MEDIA_TYPES,
|
|
218
223
|
InFlightMap,
|
|
219
224
|
MAX_CANVAS_FILE_BYTES,
|
|
@@ -237,10 +242,12 @@ import {
|
|
|
237
242
|
TaskAccumulator,
|
|
238
243
|
USER_MESSAGE_ID_PAYLOAD_KEY,
|
|
239
244
|
VALID_AGENT_PROVIDERS,
|
|
245
|
+
WORKSPACE_TOKEN_ENV,
|
|
240
246
|
agentQuotaExhaustedPayloadSchema,
|
|
241
247
|
areSameUserMessageEvents,
|
|
242
248
|
areUserMessagesWithinMatchWindow,
|
|
243
249
|
autoCompactThresholdField,
|
|
250
|
+
buildCodeHostPrUrl,
|
|
244
251
|
buildCodexTokenUsageContextUsagePayload,
|
|
245
252
|
buildGitCredentialHelperScript,
|
|
246
253
|
buildHookOutputPreview,
|
|
@@ -269,6 +276,7 @@ import {
|
|
|
269
276
|
createProviderSlashCommand,
|
|
270
277
|
createSuccessResult,
|
|
271
278
|
createUuidFromHex,
|
|
279
|
+
currentWorkspaceToken,
|
|
272
280
|
decodePathSegments,
|
|
273
281
|
defaultForkChatTitle,
|
|
274
282
|
describeQuotaLimit,
|
|
@@ -339,6 +347,7 @@ import {
|
|
|
339
347
|
parseAgentEvents,
|
|
340
348
|
parseChatHistoryCursor,
|
|
341
349
|
parseChatTranscriptArtifact,
|
|
350
|
+
parseCodeHostPrUrl,
|
|
342
351
|
parseDisplayMessages,
|
|
343
352
|
parseFrontmatter,
|
|
344
353
|
parseGitRemote,
|
|
@@ -363,7 +372,7 @@ import {
|
|
|
363
372
|
waitRelaySubagentRequestSchema,
|
|
364
373
|
withTimeout,
|
|
365
374
|
workspaceCredentialProviderSchema
|
|
366
|
-
} from "./chunk-
|
|
375
|
+
} from "./chunk-OBAGPETY.js";
|
|
367
376
|
import {
|
|
368
377
|
__commonJS,
|
|
369
378
|
__export,
|
|
@@ -378,7 +387,7 @@ var require_windows = __commonJS({
|
|
|
378
387
|
module.exports = isexe;
|
|
379
388
|
isexe.sync = sync;
|
|
380
389
|
var fs8 = __require("fs");
|
|
381
|
-
function checkPathExt(
|
|
390
|
+
function checkPathExt(path8, options) {
|
|
382
391
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
383
392
|
if (!pathext) {
|
|
384
393
|
return true;
|
|
@@ -389,25 +398,25 @@ var require_windows = __commonJS({
|
|
|
389
398
|
}
|
|
390
399
|
for (var i = 0; i < pathext.length; i++) {
|
|
391
400
|
var p = pathext[i].toLowerCase();
|
|
392
|
-
if (p &&
|
|
401
|
+
if (p && path8.substr(-p.length).toLowerCase() === p) {
|
|
393
402
|
return true;
|
|
394
403
|
}
|
|
395
404
|
}
|
|
396
405
|
return false;
|
|
397
406
|
}
|
|
398
|
-
function checkStat(stat8,
|
|
407
|
+
function checkStat(stat8, path8, options) {
|
|
399
408
|
if (!stat8.isSymbolicLink() && !stat8.isFile()) {
|
|
400
409
|
return false;
|
|
401
410
|
}
|
|
402
|
-
return checkPathExt(
|
|
411
|
+
return checkPathExt(path8, options);
|
|
403
412
|
}
|
|
404
|
-
function isexe(
|
|
405
|
-
fs8.stat(
|
|
406
|
-
cb(er, er ? false : checkStat(stat8,
|
|
413
|
+
function isexe(path8, options, cb) {
|
|
414
|
+
fs8.stat(path8, function(er, stat8) {
|
|
415
|
+
cb(er, er ? false : checkStat(stat8, path8, options));
|
|
407
416
|
});
|
|
408
417
|
}
|
|
409
|
-
function sync(
|
|
410
|
-
return checkStat(fs8.statSync(
|
|
418
|
+
function sync(path8, options) {
|
|
419
|
+
return checkStat(fs8.statSync(path8), path8, options);
|
|
411
420
|
}
|
|
412
421
|
}
|
|
413
422
|
});
|
|
@@ -419,13 +428,13 @@ var require_mode = __commonJS({
|
|
|
419
428
|
module.exports = isexe;
|
|
420
429
|
isexe.sync = sync;
|
|
421
430
|
var fs8 = __require("fs");
|
|
422
|
-
function isexe(
|
|
423
|
-
fs8.stat(
|
|
431
|
+
function isexe(path8, options, cb) {
|
|
432
|
+
fs8.stat(path8, function(er, stat8) {
|
|
424
433
|
cb(er, er ? false : checkStat(stat8, options));
|
|
425
434
|
});
|
|
426
435
|
}
|
|
427
|
-
function sync(
|
|
428
|
-
return checkStat(fs8.statSync(
|
|
436
|
+
function sync(path8, options) {
|
|
437
|
+
return checkStat(fs8.statSync(path8), options);
|
|
429
438
|
}
|
|
430
439
|
function checkStat(stat8, options) {
|
|
431
440
|
return stat8.isFile() && checkMode(stat8, options);
|
|
@@ -459,7 +468,7 @@ var require_isexe = __commonJS({
|
|
|
459
468
|
}
|
|
460
469
|
module.exports = isexe;
|
|
461
470
|
isexe.sync = sync;
|
|
462
|
-
function isexe(
|
|
471
|
+
function isexe(path8, options, cb) {
|
|
463
472
|
if (typeof options === "function") {
|
|
464
473
|
cb = options;
|
|
465
474
|
options = {};
|
|
@@ -468,17 +477,17 @@ var require_isexe = __commonJS({
|
|
|
468
477
|
if (typeof Promise !== "function") {
|
|
469
478
|
throw new TypeError("callback not provided");
|
|
470
479
|
}
|
|
471
|
-
return new Promise(function(
|
|
472
|
-
isexe(
|
|
480
|
+
return new Promise(function(resolve8, reject) {
|
|
481
|
+
isexe(path8, options || {}, function(er, is) {
|
|
473
482
|
if (er) {
|
|
474
483
|
reject(er);
|
|
475
484
|
} else {
|
|
476
|
-
|
|
485
|
+
resolve8(is);
|
|
477
486
|
}
|
|
478
487
|
});
|
|
479
488
|
});
|
|
480
489
|
}
|
|
481
|
-
core(
|
|
490
|
+
core(path8, options || {}, function(er, is) {
|
|
482
491
|
if (er) {
|
|
483
492
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
484
493
|
er = null;
|
|
@@ -488,9 +497,9 @@ var require_isexe = __commonJS({
|
|
|
488
497
|
cb(er, is);
|
|
489
498
|
});
|
|
490
499
|
}
|
|
491
|
-
function sync(
|
|
500
|
+
function sync(path8, options) {
|
|
492
501
|
try {
|
|
493
|
-
return core.sync(
|
|
502
|
+
return core.sync(path8, options || {});
|
|
494
503
|
} catch (er) {
|
|
495
504
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
496
505
|
return false;
|
|
@@ -507,7 +516,7 @@ var require_which = __commonJS({
|
|
|
507
516
|
"../node_modules/.bun/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
508
517
|
"use strict";
|
|
509
518
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
510
|
-
var
|
|
519
|
+
var path8 = __require("path");
|
|
511
520
|
var COLON = isWindows ? ";" : ":";
|
|
512
521
|
var isexe = require_isexe();
|
|
513
522
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -540,27 +549,27 @@ var require_which = __commonJS({
|
|
|
540
549
|
opt = {};
|
|
541
550
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
542
551
|
const found = [];
|
|
543
|
-
const step = (i) => new Promise((
|
|
552
|
+
const step = (i) => new Promise((resolve8, reject) => {
|
|
544
553
|
if (i === pathEnv.length)
|
|
545
|
-
return opt.all && found.length ?
|
|
554
|
+
return opt.all && found.length ? resolve8(found) : reject(getNotFoundError(cmd));
|
|
546
555
|
const ppRaw = pathEnv[i];
|
|
547
556
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
548
|
-
const pCmd =
|
|
557
|
+
const pCmd = path8.join(pathPart, cmd);
|
|
549
558
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
550
|
-
|
|
559
|
+
resolve8(subStep(p, i, 0));
|
|
551
560
|
});
|
|
552
|
-
const subStep = (p, i, ii) => new Promise((
|
|
561
|
+
const subStep = (p, i, ii) => new Promise((resolve8, reject) => {
|
|
553
562
|
if (ii === pathExt.length)
|
|
554
|
-
return
|
|
563
|
+
return resolve8(step(i + 1));
|
|
555
564
|
const ext = pathExt[ii];
|
|
556
565
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
557
566
|
if (!er && is) {
|
|
558
567
|
if (opt.all)
|
|
559
568
|
found.push(p + ext);
|
|
560
569
|
else
|
|
561
|
-
return
|
|
570
|
+
return resolve8(p + ext);
|
|
562
571
|
}
|
|
563
|
-
return
|
|
572
|
+
return resolve8(subStep(p, i, ii + 1));
|
|
564
573
|
});
|
|
565
574
|
});
|
|
566
575
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -572,7 +581,7 @@ var require_which = __commonJS({
|
|
|
572
581
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
573
582
|
const ppRaw = pathEnv[i];
|
|
574
583
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
575
|
-
const pCmd =
|
|
584
|
+
const pCmd = path8.join(pathPart, cmd);
|
|
576
585
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
577
586
|
for (let j = 0; j < pathExt.length; j++) {
|
|
578
587
|
const cur = p + pathExt[j];
|
|
@@ -620,7 +629,7 @@ var require_path_key = __commonJS({
|
|
|
620
629
|
var require_resolveCommand = __commonJS({
|
|
621
630
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
622
631
|
"use strict";
|
|
623
|
-
var
|
|
632
|
+
var path8 = __require("path");
|
|
624
633
|
var which = require_which();
|
|
625
634
|
var getPathKey = require_path_key();
|
|
626
635
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -638,7 +647,7 @@ var require_resolveCommand = __commonJS({
|
|
|
638
647
|
try {
|
|
639
648
|
resolved = which.sync(parsed.command, {
|
|
640
649
|
path: env[getPathKey({ env })],
|
|
641
|
-
pathExt: withoutPathExt ?
|
|
650
|
+
pathExt: withoutPathExt ? path8.delimiter : void 0
|
|
642
651
|
});
|
|
643
652
|
} catch (e) {
|
|
644
653
|
} finally {
|
|
@@ -647,7 +656,7 @@ var require_resolveCommand = __commonJS({
|
|
|
647
656
|
}
|
|
648
657
|
}
|
|
649
658
|
if (resolved) {
|
|
650
|
-
resolved =
|
|
659
|
+
resolved = path8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
651
660
|
}
|
|
652
661
|
return resolved;
|
|
653
662
|
}
|
|
@@ -701,8 +710,8 @@ var require_shebang_command = __commonJS({
|
|
|
701
710
|
if (!match) {
|
|
702
711
|
return null;
|
|
703
712
|
}
|
|
704
|
-
const [
|
|
705
|
-
const binary =
|
|
713
|
+
const [path8, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
714
|
+
const binary = path8.split("/").pop();
|
|
706
715
|
if (binary === "env") {
|
|
707
716
|
return argument;
|
|
708
717
|
}
|
|
@@ -737,7 +746,7 @@ var require_readShebang = __commonJS({
|
|
|
737
746
|
var require_parse = __commonJS({
|
|
738
747
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
739
748
|
"use strict";
|
|
740
|
-
var
|
|
749
|
+
var path8 = __require("path");
|
|
741
750
|
var resolveCommand = require_resolveCommand();
|
|
742
751
|
var escape2 = require_escape();
|
|
743
752
|
var readShebang = require_readShebang();
|
|
@@ -762,7 +771,7 @@ var require_parse = __commonJS({
|
|
|
762
771
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
763
772
|
if (parsed.options.forceShell || needsShell) {
|
|
764
773
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
765
|
-
parsed.command =
|
|
774
|
+
parsed.command = path8.normalize(parsed.command);
|
|
766
775
|
parsed.command = escape2.command(parsed.command);
|
|
767
776
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
768
777
|
const shellCommand2 = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -3823,7 +3832,7 @@ var require_compile2 = __commonJS({
|
|
|
3823
3832
|
const schOrFunc = root.refs[ref];
|
|
3824
3833
|
if (schOrFunc)
|
|
3825
3834
|
return schOrFunc;
|
|
3826
|
-
let _sch =
|
|
3835
|
+
let _sch = resolve8.call(this, root, ref);
|
|
3827
3836
|
if (_sch === void 0) {
|
|
3828
3837
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
3829
3838
|
const { schemaId } = this.opts;
|
|
@@ -3850,7 +3859,7 @@ var require_compile2 = __commonJS({
|
|
|
3850
3859
|
function sameSchemaEnv(s1, s2) {
|
|
3851
3860
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3852
3861
|
}
|
|
3853
|
-
function
|
|
3862
|
+
function resolve8(root, ref) {
|
|
3854
3863
|
let sch;
|
|
3855
3864
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3856
3865
|
ref = sch;
|
|
@@ -4068,8 +4077,8 @@ var require_utils2 = __commonJS({
|
|
|
4068
4077
|
}
|
|
4069
4078
|
return ind;
|
|
4070
4079
|
}
|
|
4071
|
-
function removeDotSegments(
|
|
4072
|
-
let input =
|
|
4080
|
+
function removeDotSegments(path8) {
|
|
4081
|
+
let input = path8;
|
|
4073
4082
|
const output = [];
|
|
4074
4083
|
let nextSlash = -1;
|
|
4075
4084
|
let len = 0;
|
|
@@ -4321,8 +4330,8 @@ var require_schemes2 = __commonJS({
|
|
|
4321
4330
|
wsComponent.secure = void 0;
|
|
4322
4331
|
}
|
|
4323
4332
|
if (wsComponent.resourceName) {
|
|
4324
|
-
const [
|
|
4325
|
-
wsComponent.path =
|
|
4333
|
+
const [path8, query2] = wsComponent.resourceName.split("?");
|
|
4334
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
4326
4335
|
wsComponent.query = query2;
|
|
4327
4336
|
wsComponent.resourceName = void 0;
|
|
4328
4337
|
}
|
|
@@ -4381,7 +4390,7 @@ var require_schemes2 = __commonJS({
|
|
|
4381
4390
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
4382
4391
|
return urnComponent;
|
|
4383
4392
|
}
|
|
4384
|
-
var
|
|
4393
|
+
var http3 = (
|
|
4385
4394
|
/** @type {SchemeHandler} */
|
|
4386
4395
|
{
|
|
4387
4396
|
scheme: "http",
|
|
@@ -4390,11 +4399,11 @@ var require_schemes2 = __commonJS({
|
|
|
4390
4399
|
serialize: httpSerialize
|
|
4391
4400
|
}
|
|
4392
4401
|
);
|
|
4393
|
-
var
|
|
4402
|
+
var https2 = (
|
|
4394
4403
|
/** @type {SchemeHandler} */
|
|
4395
4404
|
{
|
|
4396
4405
|
scheme: "https",
|
|
4397
|
-
domainHost:
|
|
4406
|
+
domainHost: http3.domainHost,
|
|
4398
4407
|
parse: httpParse,
|
|
4399
4408
|
serialize: httpSerialize
|
|
4400
4409
|
}
|
|
@@ -4438,8 +4447,8 @@ var require_schemes2 = __commonJS({
|
|
|
4438
4447
|
var SCHEMES = (
|
|
4439
4448
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
4440
4449
|
{
|
|
4441
|
-
http:
|
|
4442
|
-
https,
|
|
4450
|
+
http: http3,
|
|
4451
|
+
https: https2,
|
|
4443
4452
|
ws,
|
|
4444
4453
|
wss,
|
|
4445
4454
|
urn,
|
|
@@ -4481,7 +4490,7 @@ var require_fast_uri2 = __commonJS({
|
|
|
4481
4490
|
}
|
|
4482
4491
|
return uri;
|
|
4483
4492
|
}
|
|
4484
|
-
function
|
|
4493
|
+
function resolve8(baseURI, relativeURI, options) {
|
|
4485
4494
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
4486
4495
|
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
4487
4496
|
schemelessOptions.skipEscape = true;
|
|
@@ -4739,7 +4748,7 @@ var require_fast_uri2 = __commonJS({
|
|
|
4739
4748
|
var fastUri = {
|
|
4740
4749
|
SCHEMES,
|
|
4741
4750
|
normalize,
|
|
4742
|
-
resolve:
|
|
4751
|
+
resolve: resolve8,
|
|
4743
4752
|
resolveComponent,
|
|
4744
4753
|
equal,
|
|
4745
4754
|
serialize,
|
|
@@ -8581,11 +8590,11 @@ var AsyncLock = class {
|
|
|
8581
8590
|
};
|
|
8582
8591
|
|
|
8583
8592
|
// src/utils/file.ts
|
|
8584
|
-
async function atomicWriteFile(
|
|
8585
|
-
const tmpFile = `${
|
|
8593
|
+
async function atomicWriteFile(path8, data, options) {
|
|
8594
|
+
const tmpFile = `${path8}.${process.pid}.${randomUUID()}.tmp`;
|
|
8586
8595
|
try {
|
|
8587
8596
|
await writeFile(tmpFile, data, { encoding: "utf-8", mode: options?.mode });
|
|
8588
|
-
await rename(tmpFile,
|
|
8597
|
+
await rename(tmpFile, path8);
|
|
8589
8598
|
} catch (error) {
|
|
8590
8599
|
await unlink(tmpFile).catch(() => void 0);
|
|
8591
8600
|
throw error;
|
|
@@ -8651,11 +8660,12 @@ var DEFAULT_STATE = {
|
|
|
8651
8660
|
};
|
|
8652
8661
|
var stateWriteLock = new AsyncLock();
|
|
8653
8662
|
async function updateEngineState(updater) {
|
|
8654
|
-
|
|
8663
|
+
return stateWriteLock.run(async () => {
|
|
8655
8664
|
await mkdir2(STATE_DIR, { recursive: true });
|
|
8656
8665
|
const currentState = await loadEngineState();
|
|
8657
8666
|
const nextState = updater(currentState);
|
|
8658
8667
|
await atomicWriteFile(STATE_FILE, JSON.stringify(nextState, null, 2));
|
|
8668
|
+
return nextState;
|
|
8659
8669
|
});
|
|
8660
8670
|
}
|
|
8661
8671
|
function isEngineRepoDiff(value) {
|
|
@@ -8726,7 +8736,7 @@ async function loadRepoState(repoName) {
|
|
|
8726
8736
|
return state.repos[repoName] ?? null;
|
|
8727
8737
|
}
|
|
8728
8738
|
async function saveRepoState(repoName, state, fallbackState) {
|
|
8729
|
-
await updateEngineState((currentState) => {
|
|
8739
|
+
const updated = await updateEngineState((currentState) => {
|
|
8730
8740
|
const currentRepoState = currentState.repos[repoName] ?? fallbackState;
|
|
8731
8741
|
return {
|
|
8732
8742
|
...currentState,
|
|
@@ -8734,16 +8744,19 @@ async function saveRepoState(repoName, state, fallbackState) {
|
|
|
8734
8744
|
...currentState.repos,
|
|
8735
8745
|
[repoName]: {
|
|
8736
8746
|
...currentRepoState,
|
|
8737
|
-
...state
|
|
8747
|
+
...state,
|
|
8748
|
+
// Publication events and repository refreshes can finish in either order.
|
|
8749
|
+
prUrls: [.../* @__PURE__ */ new Set([...currentRepoState.prUrls, ...state.prUrls ?? []])]
|
|
8738
8750
|
}
|
|
8739
8751
|
}
|
|
8740
8752
|
};
|
|
8741
8753
|
});
|
|
8754
|
+
return updated.repos[repoName];
|
|
8742
8755
|
}
|
|
8743
8756
|
|
|
8744
8757
|
// src/git/commands.ts
|
|
8745
|
-
import { readFileSync } from "fs";
|
|
8746
|
-
import { join as join3 } from "path";
|
|
8758
|
+
import { readdirSync, readFileSync, statSync } from "fs";
|
|
8759
|
+
import { join as join3, resolve } from "path";
|
|
8747
8760
|
async function runGitCommand(args, cwd, options = {}) {
|
|
8748
8761
|
const { stdout } = await execFileAsync("git", args, {
|
|
8749
8762
|
cwd,
|
|
@@ -8752,14 +8765,37 @@ async function runGitCommand(args, cwd, options = {}) {
|
|
|
8752
8765
|
});
|
|
8753
8766
|
return stdout.trim();
|
|
8754
8767
|
}
|
|
8755
|
-
function
|
|
8768
|
+
function readRepoHeadBranches(repoPath) {
|
|
8769
|
+
const branches = /* @__PURE__ */ new Set();
|
|
8756
8770
|
try {
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8771
|
+
let gitDir = join3(repoPath, ".git");
|
|
8772
|
+
if (statSync(gitDir).isFile()) {
|
|
8773
|
+
const target = readFileSync(gitDir, "utf8").trim().match(/^gitdir: (.+)$/)?.[1];
|
|
8774
|
+
if (!target) return branches;
|
|
8775
|
+
gitDir = resolve(repoPath, target);
|
|
8776
|
+
}
|
|
8777
|
+
let commonDir = gitDir;
|
|
8778
|
+
try {
|
|
8779
|
+
commonDir = resolve(gitDir, readFileSync(join3(gitDir, "commondir"), "utf8").trim());
|
|
8780
|
+
} catch {
|
|
8781
|
+
}
|
|
8782
|
+
const headDirs = /* @__PURE__ */ new Set([gitDir, commonDir]);
|
|
8783
|
+
try {
|
|
8784
|
+
for (const entry of readdirSync(join3(commonDir, "worktrees"))) {
|
|
8785
|
+
headDirs.add(join3(commonDir, "worktrees", entry));
|
|
8786
|
+
}
|
|
8787
|
+
} catch {
|
|
8788
|
+
}
|
|
8789
|
+
for (const dir of headDirs) {
|
|
8790
|
+
try {
|
|
8791
|
+
const branch = readFileSync(join3(dir, "HEAD"), "utf8").trim().match(/^ref:\s+refs\/heads\/(.+)$/)?.[1];
|
|
8792
|
+
if (branch) branches.add(branch);
|
|
8793
|
+
} catch {
|
|
8794
|
+
}
|
|
8795
|
+
}
|
|
8760
8796
|
} catch {
|
|
8761
|
-
return null;
|
|
8762
8797
|
}
|
|
8798
|
+
return branches;
|
|
8763
8799
|
}
|
|
8764
8800
|
async function branchExists(branchName, cwd) {
|
|
8765
8801
|
try {
|
|
@@ -8889,7 +8925,10 @@ var GitService = class {
|
|
|
8889
8925
|
const persistedState = await loadRepoState(repo.name);
|
|
8890
8926
|
const currentBranch = await getCurrentBranch(repo.path) ?? repo.defaultBranch;
|
|
8891
8927
|
const startHooksCompleted = persistedState?.startHooksCompleted ?? false;
|
|
8892
|
-
const observed =
|
|
8928
|
+
const observed = /* @__PURE__ */ new Set([
|
|
8929
|
+
...readRepoHeadBranches(repo.path),
|
|
8930
|
+
...observedBranchesByRepo?.get(repo.name) ?? []
|
|
8931
|
+
]);
|
|
8893
8932
|
const state = await this.refreshRepoMetadata(
|
|
8894
8933
|
repo,
|
|
8895
8934
|
currentBranch,
|
|
@@ -8908,19 +8947,33 @@ var GitService = class {
|
|
|
8908
8947
|
}
|
|
8909
8948
|
return { repos: states, complete: complete2 };
|
|
8910
8949
|
}
|
|
8911
|
-
// Fast branch snapshot for per-event observation during a turn. Reads
|
|
8912
|
-
// .git/HEAD directly for each repo (no subprocess) so callers can safely
|
|
8913
|
-
// invoke this on every agent event without measurable overhead.
|
|
8914
8950
|
async snapshotCurrentBranches() {
|
|
8915
8951
|
const repos = await this.listRepositories();
|
|
8916
|
-
|
|
8952
|
+
return new Map(repos.map((repo) => [repo.name, readRepoHeadBranches(repo.path)]));
|
|
8953
|
+
}
|
|
8954
|
+
async recordPublishedPullRequest(prUrl) {
|
|
8955
|
+
if (!URL.canParse(prUrl)) return false;
|
|
8956
|
+
const parsed = parseCodeHostPrUrl(prUrl);
|
|
8957
|
+
if (!parsed || !Number.isSafeInteger(parsed.number) || parsed.number <= 0) return false;
|
|
8958
|
+
const url3 = new URL(prUrl);
|
|
8959
|
+
if (url3.host.toLowerCase() !== parsed.host || !["https:", "http:"].includes(url3.protocol)) return false;
|
|
8960
|
+
const canonicalUrl = buildCodeHostPrUrl(parsed.repoUrl, parsed.provider, parsed.number);
|
|
8961
|
+
const repos = await this.listRepositories();
|
|
8917
8962
|
for (const repo of repos) {
|
|
8918
|
-
const
|
|
8919
|
-
if (
|
|
8920
|
-
|
|
8921
|
-
|
|
8963
|
+
const remote = parseGitRemote(await runGitCommand(["remote", "get-url", "origin"], repo.path).catch(() => ""));
|
|
8964
|
+
if (!remote || remote.host !== parsed.host) continue;
|
|
8965
|
+
const sameRepository = parsed.provider === "github" ? remote.path.toLowerCase() === parsed.repositoryPath.toLowerCase() : remote.path === parsed.repositoryPath;
|
|
8966
|
+
if (!sameRepository) continue;
|
|
8967
|
+
await saveRepoState(repo.name, { prUrls: [canonicalUrl] }, {
|
|
8968
|
+
...repo,
|
|
8969
|
+
currentBranch: await getCurrentBranch(repo.path) ?? repo.defaultBranch,
|
|
8970
|
+
prUrls: [],
|
|
8971
|
+
gitDiff: null,
|
|
8972
|
+
startHooksCompleted: false
|
|
8973
|
+
});
|
|
8974
|
+
return true;
|
|
8922
8975
|
}
|
|
8923
|
-
return
|
|
8976
|
+
return false;
|
|
8924
8977
|
}
|
|
8925
8978
|
getGitDiffStats(repoPath, defaultBranch) {
|
|
8926
8979
|
return this.diffStatsInFlight.run(repoPath, async () => {
|
|
@@ -8976,7 +9029,7 @@ var GitService = class {
|
|
|
8976
9029
|
}
|
|
8977
9030
|
}
|
|
8978
9031
|
readUntrackedDiff(repoPath, paths) {
|
|
8979
|
-
return new Promise((
|
|
9032
|
+
return new Promise((resolve8) => {
|
|
8980
9033
|
const child = spawn("git", ["diff", "--", ...paths], {
|
|
8981
9034
|
cwd: repoPath,
|
|
8982
9035
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -8997,12 +9050,12 @@ var GitService = class {
|
|
|
8997
9050
|
});
|
|
8998
9051
|
child.stderr.on("data", () => {
|
|
8999
9052
|
});
|
|
9000
|
-
child.on("error", () =>
|
|
9053
|
+
child.on("error", () => resolve8(""));
|
|
9001
9054
|
child.on("close", (code) => {
|
|
9002
9055
|
if (code === 0 || code === 1 || truncated) {
|
|
9003
|
-
|
|
9056
|
+
resolve8(Buffer.concat(chunks).toString("utf-8"));
|
|
9004
9057
|
} else {
|
|
9005
|
-
|
|
9058
|
+
resolve8("");
|
|
9006
9059
|
}
|
|
9007
9060
|
});
|
|
9008
9061
|
});
|
|
@@ -9011,9 +9064,9 @@ var GitService = class {
|
|
|
9011
9064
|
try {
|
|
9012
9065
|
const paths = await this.listUntrackedPaths(repoPath);
|
|
9013
9066
|
let total = 0;
|
|
9014
|
-
for (const
|
|
9067
|
+
for (const path8 of paths) {
|
|
9015
9068
|
try {
|
|
9016
|
-
const contents = await readFile3(join4(repoPath,
|
|
9069
|
+
const contents = await readFile3(join4(repoPath, path8));
|
|
9017
9070
|
if (contents.length === 0 || contents.includes(0)) {
|
|
9018
9071
|
continue;
|
|
9019
9072
|
}
|
|
@@ -9266,12 +9319,11 @@ var GitService = class {
|
|
|
9266
9319
|
startHooksCompleted,
|
|
9267
9320
|
...await this.resolveCodeHost(repo.path)
|
|
9268
9321
|
};
|
|
9269
|
-
|
|
9270
|
-
return state;
|
|
9322
|
+
return saveRepoState(repo.name, state, state);
|
|
9271
9323
|
}
|
|
9272
|
-
async safeStat(
|
|
9324
|
+
async safeStat(path8) {
|
|
9273
9325
|
try {
|
|
9274
|
-
return await stat(
|
|
9326
|
+
return await stat(path8);
|
|
9275
9327
|
} catch {
|
|
9276
9328
|
return null;
|
|
9277
9329
|
}
|
|
@@ -9550,8 +9602,7 @@ var InfisicalTokenManager = class extends BaseRefreshManager {
|
|
|
9550
9602
|
if (!response.ok) throw new Error(`Token refresh failed: ${response.status} ${await response.text()}`);
|
|
9551
9603
|
const data = await response.json();
|
|
9552
9604
|
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;
|
|
9605
|
+
this.nextRefreshDelayMs = refreshDelayMs(data.configured ? Date.parse(data.expiresAt) : Number.NaN);
|
|
9555
9606
|
}
|
|
9556
9607
|
getNextRefreshDelayMs() {
|
|
9557
9608
|
return this.nextRefreshDelayMs;
|
|
@@ -9586,6 +9637,131 @@ async function applyInfisicalCredentials(data, paths) {
|
|
|
9586
9637
|
}
|
|
9587
9638
|
var infisicalTokenManager = new InfisicalTokenManager();
|
|
9588
9639
|
|
|
9640
|
+
// src/managers/workspace-identity-token-manager.ts
|
|
9641
|
+
import { rm as rm2 } from "fs/promises";
|
|
9642
|
+
import path5 from "path";
|
|
9643
|
+
var MAX_REFRESH_MS = 5 * 60 * 1e3;
|
|
9644
|
+
var WorkspaceIdentityTokenManager = class extends BaseRefreshManager {
|
|
9645
|
+
constructor(request = monolithRequest, homeDir = ENGINE_ENV.HOME_DIR) {
|
|
9646
|
+
super("WorkspaceIdentityTokenManager", MAX_REFRESH_MS);
|
|
9647
|
+
this.request = request;
|
|
9648
|
+
this.homeDir = homeDir;
|
|
9649
|
+
}
|
|
9650
|
+
request;
|
|
9651
|
+
homeDir;
|
|
9652
|
+
nextRefreshDelayMs = MAX_REFRESH_MS;
|
|
9653
|
+
bundle = null;
|
|
9654
|
+
async doRefresh() {
|
|
9655
|
+
const response = await this.request("/v1/engine/workspace-identity/token");
|
|
9656
|
+
if (!response.ok) throw new Error(`Workspace identity refresh failed: ${response.status} ${await response.text()}`);
|
|
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;
|
|
9666
|
+
}
|
|
9667
|
+
const { configured: _configured, ...bundle } = data;
|
|
9668
|
+
this.bundle = bundle;
|
|
9669
|
+
const env = {
|
|
9670
|
+
[WORKSPACE_TOKEN_ENV.TOKEN]: currentWorkspaceToken(bundle) ?? "",
|
|
9671
|
+
[WORKSPACE_TOKEN_ENV.TOKEN_FILE]: bundleFile,
|
|
9672
|
+
[WORKSPACE_TOKEN_ENV.AUDIENCE]: bundle.default_audience,
|
|
9673
|
+
[WORKSPACE_TOKEN_ENV.ISSUER]: bundle.issuer
|
|
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
|
+
);
|
|
9690
|
+
}
|
|
9691
|
+
getNextRefreshDelayMs() {
|
|
9692
|
+
return this.nextRefreshDelayMs;
|
|
9693
|
+
}
|
|
9694
|
+
};
|
|
9695
|
+
var workspaceIdentityTokenManager = new WorkspaceIdentityTokenManager();
|
|
9696
|
+
|
|
9697
|
+
// src/identity-proxy.ts
|
|
9698
|
+
import http from "http";
|
|
9699
|
+
import https from "https";
|
|
9700
|
+
var STRIPPED_HEADERS = /* @__PURE__ */ new Set([
|
|
9701
|
+
"authorization",
|
|
9702
|
+
"proxy-authorization",
|
|
9703
|
+
"cookie",
|
|
9704
|
+
"host",
|
|
9705
|
+
"connection",
|
|
9706
|
+
"keep-alive",
|
|
9707
|
+
"proxy-connection",
|
|
9708
|
+
"te",
|
|
9709
|
+
"trailer",
|
|
9710
|
+
"upgrade"
|
|
9711
|
+
]);
|
|
9712
|
+
var decode = (segment) => Buffer.from(segment, "base64url").toString("utf8");
|
|
9713
|
+
function resolveIdentityRoute(requestUrl) {
|
|
9714
|
+
const url3 = new URL(requestUrl, "http://127.0.0.1");
|
|
9715
|
+
const [, kind, encodedAudience, encodedTarget, ...rest] = url3.pathname.split("/");
|
|
9716
|
+
if (kind !== "identity" || !encodedAudience || !encodedTarget) return null;
|
|
9717
|
+
let target;
|
|
9718
|
+
try {
|
|
9719
|
+
target = new URL(decode(encodedTarget));
|
|
9720
|
+
} catch {
|
|
9721
|
+
return null;
|
|
9722
|
+
}
|
|
9723
|
+
const loopback = target.hostname === "localhost" || target.hostname === "127.0.0.1";
|
|
9724
|
+
if (target.protocol !== "https:" && !(target.protocol === "http:" && loopback)) return null;
|
|
9725
|
+
target.pathname = [target.pathname.replace(/\/$/, ""), ...rest].join("/") || "/";
|
|
9726
|
+
target.search = url3.search;
|
|
9727
|
+
return { target, audience: decode(encodedAudience) };
|
|
9728
|
+
}
|
|
9729
|
+
function createIdentityProxy(getBundle) {
|
|
9730
|
+
return http.createServer((request, response) => {
|
|
9731
|
+
const route = resolveIdentityRoute(request.url ?? "/");
|
|
9732
|
+
if (!route) {
|
|
9733
|
+
response.writeHead(404).end("Unknown identity route");
|
|
9734
|
+
return;
|
|
9735
|
+
}
|
|
9736
|
+
const bundle = getBundle();
|
|
9737
|
+
const token = bundle && currentWorkspaceToken(bundle, route.audience);
|
|
9738
|
+
if (!token) {
|
|
9739
|
+
response.writeHead(503).end("Workspace token unavailable; waiting for renewal");
|
|
9740
|
+
return;
|
|
9741
|
+
}
|
|
9742
|
+
const headers = { host: route.target.host };
|
|
9743
|
+
for (const [name, value] of Object.entries(request.headers)) {
|
|
9744
|
+
if (!STRIPPED_HEADERS.has(name) && !name.startsWith("x-replicas-") && value !== void 0) headers[name] = value;
|
|
9745
|
+
}
|
|
9746
|
+
headers.authorization = `Bearer ${token}`;
|
|
9747
|
+
const upstream = (route.target.protocol === "https:" ? https : http).request(
|
|
9748
|
+
route.target,
|
|
9749
|
+
{ method: request.method, headers },
|
|
9750
|
+
(incoming) => {
|
|
9751
|
+
response.writeHead(incoming.statusCode ?? 502, incoming.headers);
|
|
9752
|
+
incoming.pipe(response);
|
|
9753
|
+
response.on("close", () => incoming.destroy());
|
|
9754
|
+
}
|
|
9755
|
+
);
|
|
9756
|
+
upstream.on("error", () => {
|
|
9757
|
+
if (!response.headersSent) response.writeHead(502);
|
|
9758
|
+
response.end();
|
|
9759
|
+
});
|
|
9760
|
+
response.on("close", () => upstream.destroy());
|
|
9761
|
+
request.pipe(upstream);
|
|
9762
|
+
});
|
|
9763
|
+
}
|
|
9764
|
+
|
|
9589
9765
|
// src/utils/logger.ts
|
|
9590
9766
|
import { mkdir as mkdir3, writeFile as writeFile2 } from "fs/promises";
|
|
9591
9767
|
import { homedir as homedir2 } from "os";
|
|
@@ -9601,8 +9777,8 @@ var StreamWriter = class {
|
|
|
9601
9777
|
backpressured = false;
|
|
9602
9778
|
droppedCount = 0;
|
|
9603
9779
|
flushTimer = null;
|
|
9604
|
-
open(
|
|
9605
|
-
this.stream = createWriteStream(
|
|
9780
|
+
open(path8, highWaterMark = DEFAULT_HIGH_WATER) {
|
|
9781
|
+
this.stream = createWriteStream(path8, { flags: "a", highWaterMark });
|
|
9606
9782
|
this.stream.on("error", () => {
|
|
9607
9783
|
this.stream = null;
|
|
9608
9784
|
});
|
|
@@ -9624,9 +9800,9 @@ var StreamWriter = class {
|
|
|
9624
9800
|
return true;
|
|
9625
9801
|
}
|
|
9626
9802
|
flush(signal) {
|
|
9627
|
-
return new Promise((
|
|
9803
|
+
return new Promise((resolve8, reject) => {
|
|
9628
9804
|
if (!this.stream) {
|
|
9629
|
-
|
|
9805
|
+
resolve8();
|
|
9630
9806
|
return;
|
|
9631
9807
|
}
|
|
9632
9808
|
if (this.flushTimer) {
|
|
@@ -9643,7 +9819,7 @@ var StreamWriter = class {
|
|
|
9643
9819
|
s.write("", (error) => {
|
|
9644
9820
|
signal?.removeEventListener("abort", onAbort);
|
|
9645
9821
|
if (error) reject(error);
|
|
9646
|
-
else
|
|
9822
|
+
else resolve8();
|
|
9647
9823
|
});
|
|
9648
9824
|
});
|
|
9649
9825
|
}
|
|
@@ -10267,7 +10443,7 @@ var ReplicasConfigService = class {
|
|
|
10267
10443
|
await this.logToFile(`[${params.repoName}] --- Running: ${params.label} ---`);
|
|
10268
10444
|
emit(`$ ${params.label}
|
|
10269
10445
|
`);
|
|
10270
|
-
return new Promise((
|
|
10446
|
+
return new Promise((resolve8) => {
|
|
10271
10447
|
const proc = spawn2("bash", ["-lc", params.command], {
|
|
10272
10448
|
cwd: params.cwd,
|
|
10273
10449
|
env: process.env,
|
|
@@ -10278,7 +10454,7 @@ var ReplicasConfigService = class {
|
|
|
10278
10454
|
const finish = (result) => {
|
|
10279
10455
|
if (settled) return;
|
|
10280
10456
|
settled = true;
|
|
10281
|
-
|
|
10457
|
+
resolve8(result);
|
|
10282
10458
|
};
|
|
10283
10459
|
const timer = setTimeout(() => {
|
|
10284
10460
|
timedOut = true;
|
|
@@ -10704,7 +10880,7 @@ async function registerDesktopPreview() {
|
|
|
10704
10880
|
if (await attemptRegistration()) {
|
|
10705
10881
|
return;
|
|
10706
10882
|
}
|
|
10707
|
-
await new Promise((
|
|
10883
|
+
await new Promise((resolve8) => setTimeout(resolve8, RETRY_DELAY_MS));
|
|
10708
10884
|
}
|
|
10709
10885
|
console.error(
|
|
10710
10886
|
`[DesktopPreview] Gave up registering port ${DESKTOP_STREAM_PORT} after ${REGISTRATION_TIMEOUT_MS}ms`
|
|
@@ -10712,7 +10888,7 @@ async function registerDesktopPreview() {
|
|
|
10712
10888
|
}
|
|
10713
10889
|
|
|
10714
10890
|
// 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
|
|
10891
|
+
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir22, readFile as readFile22, rename as rename5, rm as rm5 } from "fs/promises";
|
|
10716
10892
|
import { join as join37 } from "path";
|
|
10717
10893
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
10718
10894
|
|
|
@@ -11361,7 +11537,7 @@ async function saveNormalizedImagesToTempFiles(images, tempImageDir = join13(hom
|
|
|
11361
11537
|
return tempPaths;
|
|
11362
11538
|
}
|
|
11363
11539
|
async function removeTempImageFiles(paths) {
|
|
11364
|
-
await Promise.allSettled(paths.map((
|
|
11540
|
+
await Promise.allSettled(paths.map((path8) => unlink2(path8)));
|
|
11365
11541
|
}
|
|
11366
11542
|
|
|
11367
11543
|
// src/managers/coding-agent-manager.ts
|
|
@@ -12194,6 +12370,22 @@ var CHECK_TIMEOUT_MS = 3e4;
|
|
|
12194
12370
|
var PullRequestCheckService = class {
|
|
12195
12371
|
running = null;
|
|
12196
12372
|
trailing = null;
|
|
12373
|
+
async recordPublishedPullRequest(url3) {
|
|
12374
|
+
if (await gitService.recordPublishedPullRequest(url3)) {
|
|
12375
|
+
this.check().catch((error) => console.error("[PullRequestCheck] Failed to report published PR:", error));
|
|
12376
|
+
}
|
|
12377
|
+
}
|
|
12378
|
+
async onToolResult(result) {
|
|
12379
|
+
if (!result.success) return;
|
|
12380
|
+
const urls = publishedPullRequestUrls(result);
|
|
12381
|
+
try {
|
|
12382
|
+
for (const url3 of urls) await gitService.recordPublishedPullRequest(url3);
|
|
12383
|
+
} finally {
|
|
12384
|
+
if (urls.length > 0 || shouldRefreshPullRequests(result.toolName, result.toolInput)) {
|
|
12385
|
+
this.check().catch((error) => console.error("[PullRequestCheck] Failed to report tool result:", error));
|
|
12386
|
+
}
|
|
12387
|
+
}
|
|
12388
|
+
}
|
|
12197
12389
|
// Plain single-flight would hand a caller a result gathered before its PR
|
|
12198
12390
|
// existed, so callers arriving mid-run instead share one trailing run that
|
|
12199
12391
|
// starts after the current one settles.
|
|
@@ -12223,7 +12415,7 @@ var pullRequestCheckService = new PullRequestCheckService();
|
|
|
12223
12415
|
|
|
12224
12416
|
// src/services/skill-registry-service.ts
|
|
12225
12417
|
import { readFile as readFile9, readdir as readdir3, stat as stat2 } from "fs/promises";
|
|
12226
|
-
import { dirname as dirname3, isAbsolute, join as join15, relative, resolve } from "path";
|
|
12418
|
+
import { dirname as dirname3, isAbsolute, join as join15, relative, resolve as resolve2 } from "path";
|
|
12227
12419
|
var REGISTRY_ROOT_DIR = ".replicas/skill-registries";
|
|
12228
12420
|
var REGISTRY_MANIFEST = "manifest.json";
|
|
12229
12421
|
async function getSkillRegistryInventory(homeDir) {
|
|
@@ -12256,7 +12448,7 @@ async function getSkillRegistryInventory(homeDir) {
|
|
|
12256
12448
|
async function buildClaudeRegistryConfig(homeDir) {
|
|
12257
12449
|
const inventory = await getSkillRegistryInventory(homeDir);
|
|
12258
12450
|
return {
|
|
12259
|
-
plugins: inventory.claudePluginRoots.map((
|
|
12451
|
+
plugins: inventory.claudePluginRoots.map((path8) => ({ type: "local", path: path8 })),
|
|
12260
12452
|
enableAllSkills: inventory.claudePluginRoots.length > 0 || inventory.standaloneSkills.length > 0
|
|
12261
12453
|
};
|
|
12262
12454
|
}
|
|
@@ -12414,31 +12606,31 @@ function uniqueStandaloneSkills(skills) {
|
|
|
12414
12606
|
}
|
|
12415
12607
|
return unique;
|
|
12416
12608
|
}
|
|
12417
|
-
async function safeReadDir(
|
|
12609
|
+
async function safeReadDir(path8) {
|
|
12418
12610
|
try {
|
|
12419
|
-
return await readdir3(
|
|
12611
|
+
return await readdir3(path8, { withFileTypes: true });
|
|
12420
12612
|
} catch (error) {
|
|
12421
12613
|
if (isNotFoundError(error)) return [];
|
|
12422
12614
|
throw error;
|
|
12423
12615
|
}
|
|
12424
12616
|
}
|
|
12425
|
-
async function isDirectoryDirent(dirent,
|
|
12617
|
+
async function isDirectoryDirent(dirent, path8) {
|
|
12426
12618
|
if (dirent.isDirectory()) return true;
|
|
12427
12619
|
if (!dirent.isSymbolicLink()) return false;
|
|
12428
|
-
return directoryExists(
|
|
12620
|
+
return directoryExists(path8);
|
|
12429
12621
|
}
|
|
12430
|
-
async function directoryExists(
|
|
12622
|
+
async function directoryExists(path8) {
|
|
12431
12623
|
try {
|
|
12432
|
-
const pathStat = await stat2(
|
|
12624
|
+
const pathStat = await stat2(path8);
|
|
12433
12625
|
return pathStat.isDirectory();
|
|
12434
12626
|
} catch (error) {
|
|
12435
12627
|
if (isNotFoundError(error)) return false;
|
|
12436
12628
|
throw error;
|
|
12437
12629
|
}
|
|
12438
12630
|
}
|
|
12439
|
-
async function fileExists(
|
|
12631
|
+
async function fileExists(path8) {
|
|
12440
12632
|
try {
|
|
12441
|
-
const pathStat = await stat2(
|
|
12633
|
+
const pathStat = await stat2(path8);
|
|
12442
12634
|
return pathStat.isFile();
|
|
12443
12635
|
} catch (error) {
|
|
12444
12636
|
if (isNotFoundError(error)) return false;
|
|
@@ -12446,8 +12638,8 @@ async function fileExists(path7) {
|
|
|
12446
12638
|
}
|
|
12447
12639
|
}
|
|
12448
12640
|
function isPathInside(parentPath, childPath) {
|
|
12449
|
-
const parent =
|
|
12450
|
-
const child =
|
|
12641
|
+
const parent = resolve2(parentPath);
|
|
12642
|
+
const child = resolve2(childPath);
|
|
12451
12643
|
const childRelativePath = relative(parent, child);
|
|
12452
12644
|
return childRelativePath === "" || !childRelativePath.startsWith("..") && !isAbsolute(childRelativePath);
|
|
12453
12645
|
}
|
|
@@ -12714,8 +12906,8 @@ var PromptStream = class {
|
|
|
12714
12906
|
if (this.closed) {
|
|
12715
12907
|
return Promise.resolve({ value: void 0, done: true });
|
|
12716
12908
|
}
|
|
12717
|
-
return new Promise((
|
|
12718
|
-
this.waiters.push(
|
|
12909
|
+
return new Promise((resolve8) => {
|
|
12910
|
+
this.waiters.push(resolve8);
|
|
12719
12911
|
});
|
|
12720
12912
|
}
|
|
12721
12913
|
};
|
|
@@ -13102,14 +13294,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13102
13294
|
const requestId = randomUUID5();
|
|
13103
13295
|
const toolUseId = options.toolUseID;
|
|
13104
13296
|
const { options: requestOptions, questions: requestQuestions } = handler.getRequest(input);
|
|
13105
|
-
const result = await new Promise((
|
|
13297
|
+
const result = await new Promise((resolve8) => {
|
|
13106
13298
|
this.pendingToolInputs.set(requestId, {
|
|
13107
13299
|
requestId,
|
|
13108
13300
|
toolUseId,
|
|
13109
13301
|
toolName,
|
|
13110
13302
|
input,
|
|
13111
13303
|
handler,
|
|
13112
|
-
resolve:
|
|
13304
|
+
resolve: resolve8
|
|
13113
13305
|
});
|
|
13114
13306
|
const onAbort = () => {
|
|
13115
13307
|
const pending = this.pendingToolInputs.get(requestId);
|
|
@@ -13260,7 +13452,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13260
13452
|
error
|
|
13261
13453
|
);
|
|
13262
13454
|
await this.tearDownSession();
|
|
13263
|
-
await new Promise((
|
|
13455
|
+
await new Promise((resolve8) => setTimeout(resolve8, delayMs));
|
|
13264
13456
|
currentRequest = { ...request, message: CLAUDE_MIDTURN_CONTINUE_PROMPT, images: [] };
|
|
13265
13457
|
attempt++;
|
|
13266
13458
|
continue;
|
|
@@ -13273,7 +13465,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13273
13465
|
error
|
|
13274
13466
|
);
|
|
13275
13467
|
await this.tearDownSession();
|
|
13276
|
-
await new Promise((
|
|
13468
|
+
await new Promise((resolve8) => setTimeout(resolve8, delayMs));
|
|
13277
13469
|
attempt++;
|
|
13278
13470
|
continue;
|
|
13279
13471
|
}
|
|
@@ -13434,8 +13626,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13434
13626
|
this.pendingInterrupt = false;
|
|
13435
13627
|
return;
|
|
13436
13628
|
}
|
|
13437
|
-
await new Promise((
|
|
13438
|
-
this.pendingTurn = { resolve:
|
|
13629
|
+
await new Promise((resolve8, reject) => {
|
|
13630
|
+
this.pendingTurn = { resolve: resolve8, reject, sawActivity: false, userMessageUuid };
|
|
13439
13631
|
promptStream.push(userMessage);
|
|
13440
13632
|
});
|
|
13441
13633
|
}
|
|
@@ -14120,6 +14312,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14120
14312
|
this.supportedSlashCommands = normalizeClaudeSlashCommands(message.commands);
|
|
14121
14313
|
this.slashCommandsDiscoveredAt = Date.now();
|
|
14122
14314
|
}
|
|
14315
|
+
if (message.type === "system" && String(message.subtype) === "code_change_published" && "url" in message && typeof message.url === "string") {
|
|
14316
|
+
await pullRequestCheckService.recordPublishedPullRequest(message.url).catch((error) => {
|
|
14317
|
+
console.error("[ClaudeManager] Failed to record published PR:", error);
|
|
14318
|
+
});
|
|
14319
|
+
}
|
|
14123
14320
|
this.trackNativeCompaction(message);
|
|
14124
14321
|
if (message.type === "system" && message.subtype === "task_started" && message.ambient) {
|
|
14125
14322
|
this.ambientTaskIds.add(message.task_id);
|
|
@@ -14344,16 +14541,16 @@ function transcriptItemsForTurn(turn) {
|
|
|
14344
14541
|
const otherItems = turn.items.filter((item) => item.type !== "userMessage");
|
|
14345
14542
|
return [...userItems, ...otherItems];
|
|
14346
14543
|
}
|
|
14347
|
-
function userImageForLocalPath(
|
|
14348
|
-
const cached = localImageCache.get(
|
|
14544
|
+
function userImageForLocalPath(path8) {
|
|
14545
|
+
const cached = localImageCache.get(path8);
|
|
14349
14546
|
if (cached) return cached;
|
|
14350
|
-
if (!existsSync7(
|
|
14547
|
+
if (!existsSync7(path8)) return null;
|
|
14351
14548
|
const image = {
|
|
14352
14549
|
type: "image",
|
|
14353
|
-
mediaType: inferMediaType(
|
|
14354
|
-
data: readFileSync3(
|
|
14550
|
+
mediaType: inferMediaType(path8),
|
|
14551
|
+
data: readFileSync3(path8).toString("base64")
|
|
14355
14552
|
};
|
|
14356
|
-
if (image.data.length > 0) localImageCache.set(
|
|
14553
|
+
if (image.data.length > 0) localImageCache.set(path8, image);
|
|
14357
14554
|
return image;
|
|
14358
14555
|
}
|
|
14359
14556
|
function userImagesForInput(input) {
|
|
@@ -14644,9 +14841,9 @@ async function buildTurnInput(request) {
|
|
|
14644
14841
|
}
|
|
14645
14842
|
const normalizedImages = await normalizeImages(request.images);
|
|
14646
14843
|
const tempImagePaths = await saveNormalizedImagesToTempFiles(normalizedImages);
|
|
14647
|
-
input.push(...tempImagePaths.map((
|
|
14844
|
+
input.push(...tempImagePaths.map((path8) => ({
|
|
14648
14845
|
type: "localImage",
|
|
14649
|
-
path:
|
|
14846
|
+
path: path8
|
|
14650
14847
|
})));
|
|
14651
14848
|
return { input, tempImagePaths };
|
|
14652
14849
|
}
|
|
@@ -15301,8 +15498,8 @@ ${text.slice(-24e3)}`
|
|
|
15301
15498
|
}
|
|
15302
15499
|
async observeTurn(host, threadId, request, startTurn) {
|
|
15303
15500
|
let resolveCompleted;
|
|
15304
|
-
const completed = new Promise((
|
|
15305
|
-
resolveCompleted =
|
|
15501
|
+
const completed = new Promise((resolve8) => {
|
|
15502
|
+
resolveCompleted = resolve8;
|
|
15306
15503
|
});
|
|
15307
15504
|
let rejectDisposed = () => {
|
|
15308
15505
|
};
|
|
@@ -15399,8 +15596,10 @@ ${text.slice(-24e3)}`
|
|
|
15399
15596
|
);
|
|
15400
15597
|
linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
|
|
15401
15598
|
const completedItem = notification.params.item;
|
|
15402
|
-
|
|
15403
|
-
|
|
15599
|
+
const toolResult = completedItem.type === "commandExecution" ? { toolName: "commandExecution", toolInput: { command: completedItem.command }, output: completedItem.aggregatedOutput, success: completedItem.exitCode === 0 } : completedItem.type === "mcpToolCall" ? { toolName: completedItem.tool, toolInput: completedItem.arguments, output: completedItem.result, success: completedItem.status === "completed" && !completedItem.error } : completedItem.type === "dynamicToolCall" ? { toolName: completedItem.tool, toolInput: completedItem.arguments, output: completedItem.contentItems, success: completedItem.success === true } : null;
|
|
15600
|
+
if (toolResult) {
|
|
15601
|
+
pullRequestCheckService.onToolResult(toolResult).catch((error) => {
|
|
15602
|
+
console.error("[CodexAspManager] Failed to capture published PR:", error);
|
|
15404
15603
|
});
|
|
15405
15604
|
}
|
|
15406
15605
|
},
|
|
@@ -15847,12 +16046,12 @@ var postToolHookPath = [
|
|
|
15847
16046
|
join18(moduleDirectory, "post-tool-pr-hook.js"),
|
|
15848
16047
|
join18(moduleDirectory, "..", "post-tool-pr-hook.ts")
|
|
15849
16048
|
].find(existsSync8);
|
|
15850
|
-
function shellCommand(
|
|
15851
|
-
if (!
|
|
16049
|
+
function shellCommand(path8, provider) {
|
|
16050
|
+
if (!path8) throw new Error("Replicas hook executable is missing.");
|
|
15852
16051
|
const args = [
|
|
15853
16052
|
process.execPath,
|
|
15854
|
-
...
|
|
15855
|
-
|
|
16053
|
+
...path8.endsWith(".ts") && basename(process.execPath) !== "bun" ? ["--import", "tsx"] : [],
|
|
16054
|
+
path8,
|
|
15856
16055
|
...provider ? [provider] : []
|
|
15857
16056
|
];
|
|
15858
16057
|
return args.map((value) => `'${value.replaceAll("'", "'\\''")}'`).join(" ");
|
|
@@ -15866,10 +16065,10 @@ function getPostToolPrHookPath() {
|
|
|
15866
16065
|
return postToolHookPath;
|
|
15867
16066
|
}
|
|
15868
16067
|
async function ensureCursorCommandProtectionHook() {
|
|
15869
|
-
const
|
|
16068
|
+
const path8 = join18(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
|
|
15870
16069
|
let config = {};
|
|
15871
16070
|
try {
|
|
15872
|
-
const parsed = JSON.parse(await readFile11(
|
|
16071
|
+
const parsed = JSON.parse(await readFile11(path8, "utf8"));
|
|
15873
16072
|
if (!isRecord2(parsed)) throw new Error("Invalid Cursor hooks configuration.");
|
|
15874
16073
|
config = parsed;
|
|
15875
16074
|
} catch (error) {
|
|
@@ -15886,15 +16085,15 @@ async function ensureCursorCommandProtectionHook() {
|
|
|
15886
16085
|
...existingPost.filter((entry) => !isRecord2(entry) || typeof entry.command !== "string" || !entry.command.includes("post-tool-pr-hook")),
|
|
15887
16086
|
{ command: shellCommand(postToolHookPath) }
|
|
15888
16087
|
];
|
|
15889
|
-
await mkdir12(dirname5(
|
|
15890
|
-
await writeFile7(
|
|
16088
|
+
await mkdir12(dirname5(path8), { recursive: true });
|
|
16089
|
+
await writeFile7(path8, `${JSON.stringify({ ...config, version: 1, hooks }, null, 2)}
|
|
15891
16090
|
`, "utf8");
|
|
15892
16091
|
}
|
|
15893
16092
|
async function ensureGeminiCommandProtectionHook() {
|
|
15894
|
-
const
|
|
16093
|
+
const path8 = join18(ENGINE_ENV.HOME_DIR, ".gemini", "settings.json");
|
|
15895
16094
|
let config = {};
|
|
15896
16095
|
try {
|
|
15897
|
-
const parsed = JSON.parse(await readFile11(
|
|
16096
|
+
const parsed = JSON.parse(await readFile11(path8, "utf8"));
|
|
15898
16097
|
if (!isRecord2(parsed)) throw new Error("Invalid Gemini hooks configuration.");
|
|
15899
16098
|
config = parsed;
|
|
15900
16099
|
} catch (error) {
|
|
@@ -15914,17 +16113,17 @@ async function ensureGeminiCommandProtectionHook() {
|
|
|
15914
16113
|
...without(hooks.AfterTool, "replicas-post-tool-pr-check"),
|
|
15915
16114
|
hook("replicas-post-tool-pr-check", shellCommand(postToolHookPath))
|
|
15916
16115
|
];
|
|
15917
|
-
await mkdir12(dirname5(
|
|
15918
|
-
await writeFile7(
|
|
16116
|
+
await mkdir12(dirname5(path8), { recursive: true });
|
|
16117
|
+
await writeFile7(path8, `${JSON.stringify({ ...config, hooks }, null, 2)}
|
|
15919
16118
|
`, "utf8");
|
|
15920
16119
|
}
|
|
15921
16120
|
async function ensureKimiCommandProtectionHook() {
|
|
15922
|
-
const
|
|
16121
|
+
const path8 = join18(ENGINE_ENV.HOME_DIR, ".kimi-code", "config.toml");
|
|
15923
16122
|
const start = "# Replicas command protection hook";
|
|
15924
16123
|
const end = "# End Replicas command protection hook";
|
|
15925
16124
|
let config = "";
|
|
15926
16125
|
try {
|
|
15927
|
-
config = await readFile11(
|
|
16126
|
+
config = await readFile11(path8, "utf8");
|
|
15928
16127
|
} catch (error) {
|
|
15929
16128
|
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
|
|
15930
16129
|
}
|
|
@@ -15943,8 +16142,8 @@ ${end}`;
|
|
|
15943
16142
|
const markerEnd = config.indexOf(end, markerStart + start.length);
|
|
15944
16143
|
config = markerStart >= 0 && markerEnd >= 0 ? `${config.slice(0, markerStart)}${block}${config.slice(markerEnd + end.length)}` : `${config.trimEnd()}${config.trim() ? "\n\n" : ""}${block}
|
|
15945
16144
|
`;
|
|
15946
|
-
await mkdir12(dirname5(
|
|
15947
|
-
await writeFile7(
|
|
16145
|
+
await mkdir12(dirname5(path8), { recursive: true });
|
|
16146
|
+
await writeFile7(path8, config, "utf8");
|
|
15948
16147
|
}
|
|
15949
16148
|
|
|
15950
16149
|
// src/managers/cursor-run-recovery.ts
|
|
@@ -16157,8 +16356,8 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
16157
16356
|
let agent = null;
|
|
16158
16357
|
let sawCursorActivity = false;
|
|
16159
16358
|
let reconnectNoticeTimer = null;
|
|
16160
|
-
const aborted = new Promise((
|
|
16161
|
-
this.abortActiveTurn = () =>
|
|
16359
|
+
const aborted = new Promise((resolve8) => {
|
|
16360
|
+
this.abortActiveTurn = () => resolve8(TURN_ABORTED);
|
|
16162
16361
|
});
|
|
16163
16362
|
const linearSessionId = this.linearSessionId;
|
|
16164
16363
|
const linearForwarder = new LinearEventForwarder(linearSessionId);
|
|
@@ -16513,8 +16712,8 @@ var DeepseekApiClient = class extends AbstractApiClient {
|
|
|
16513
16712
|
if (!execution.success) throw new Error(`DeepSeek Harness did not recognize ${line}.`);
|
|
16514
16713
|
if (execution.data.result.kind === "error") throw new Error(execution.data.result.text ?? `DeepSeek Harness rejected ${line}.`);
|
|
16515
16714
|
}
|
|
16516
|
-
async *readWebSocket(
|
|
16517
|
-
const url3 = new URL(
|
|
16715
|
+
async *readWebSocket(path8, signal, schema, onOpen) {
|
|
16716
|
+
const url3 = new URL(path8, this.baseUrl);
|
|
16518
16717
|
url3.protocol = url3.protocol === "https:" ? "wss:" : "ws:";
|
|
16519
16718
|
const socket = new WebSocket(url3);
|
|
16520
16719
|
const inbox = [];
|
|
@@ -16544,8 +16743,8 @@ var DeepseekApiClient = class extends AbstractApiClient {
|
|
|
16544
16743
|
if (item === null) return;
|
|
16545
16744
|
if (item) yield item;
|
|
16546
16745
|
}
|
|
16547
|
-
await new Promise((
|
|
16548
|
-
wake =
|
|
16746
|
+
await new Promise((resolve8) => {
|
|
16747
|
+
wake = resolve8;
|
|
16549
16748
|
});
|
|
16550
16749
|
}
|
|
16551
16750
|
} finally {
|
|
@@ -16704,7 +16903,7 @@ var DeepseekManager = class extends CodingAgentManager {
|
|
|
16704
16903
|
stdio: ["ignore", "pipe", "pipe"]
|
|
16705
16904
|
});
|
|
16706
16905
|
this.process = child;
|
|
16707
|
-
const baseUrl = await new Promise((
|
|
16906
|
+
const baseUrl = await new Promise((resolve8, reject) => {
|
|
16708
16907
|
let stdout = "";
|
|
16709
16908
|
let stderr = "";
|
|
16710
16909
|
const timeout = setTimeout(() => {
|
|
@@ -16716,7 +16915,7 @@ var DeepseekManager = class extends CodingAgentManager {
|
|
|
16716
16915
|
const match = stdout.match(/dsh web:\s+(http:\/\/[^\s]+)/);
|
|
16717
16916
|
if (!match?.[1]) return;
|
|
16718
16917
|
clearTimeout(timeout);
|
|
16719
|
-
|
|
16918
|
+
resolve8(match[1]);
|
|
16720
16919
|
});
|
|
16721
16920
|
child.stderr?.on("data", (chunk) => {
|
|
16722
16921
|
stderr = (stderr + chunk.toString()).slice(-8e3);
|
|
@@ -16890,8 +17089,8 @@ var DeepseekManager = class extends CodingAgentManager {
|
|
|
16890
17089
|
}));
|
|
16891
17090
|
}
|
|
16892
17091
|
this.recordUserMessageHistoryEvent(request, this.historyFile);
|
|
16893
|
-
this.turnCompletion = new Promise((
|
|
16894
|
-
this.resolveTurnCompletion =
|
|
17092
|
+
this.turnCompletion = new Promise((resolve8) => {
|
|
17093
|
+
this.resolveTurnCompletion = resolve8;
|
|
16895
17094
|
});
|
|
16896
17095
|
const images = await normalizeImages(request.images ?? []);
|
|
16897
17096
|
const combinedInstructions = this.activeAgentPreset ? "" : this.buildCombinedInstructions(request.customInstructions);
|
|
@@ -17166,8 +17365,8 @@ var AcpManager = class extends CodingAgentManager {
|
|
|
17166
17365
|
outputByteLimit,
|
|
17167
17366
|
truncated: false,
|
|
17168
17367
|
exitStatus: null,
|
|
17169
|
-
exited: new Promise((
|
|
17170
|
-
resolveExit =
|
|
17368
|
+
exited: new Promise((resolve8) => {
|
|
17369
|
+
resolveExit = resolve8;
|
|
17171
17370
|
})
|
|
17172
17371
|
};
|
|
17173
17372
|
const append = (chunk) => {
|
|
@@ -17283,8 +17482,8 @@ var AcpManager = class extends CodingAgentManager {
|
|
|
17283
17482
|
if (!this.interactiveTools) return { outcome: { outcome: "cancelled" } };
|
|
17284
17483
|
const requestId = randomUUID7();
|
|
17285
17484
|
const toolCallId = params.toolCall.toolCallId;
|
|
17286
|
-
return new Promise((
|
|
17287
|
-
this.pendingPermissions.set(requestId, { toolCallId, options: params.options, resolve:
|
|
17485
|
+
return new Promise((resolve8) => {
|
|
17486
|
+
this.pendingPermissions.set(requestId, { toolCallId, options: params.options, resolve: resolve8 });
|
|
17288
17487
|
this.recordHistoryEvent("acp-session-update", {
|
|
17289
17488
|
provider: this.acp.provider,
|
|
17290
17489
|
update: { ...params.toolCall, sessionUpdate: "tool_call", status: "pending" }
|
|
@@ -17437,14 +17636,14 @@ ${request.message}` : request.message
|
|
|
17437
17636
|
async function ensureResolvableDnsConfig() {
|
|
17438
17637
|
const contents = await readFile15("/etc/resolv.conf");
|
|
17439
17638
|
if (contents.length === 0 || contents.at(-1) === 10) return;
|
|
17440
|
-
await new Promise((
|
|
17639
|
+
await new Promise((resolve8, reject) => {
|
|
17441
17640
|
const child = spawn5("sudo", ["tee", "-a", "/etc/resolv.conf"], { stdio: ["pipe", "ignore", "pipe"] });
|
|
17442
17641
|
let stderr = "";
|
|
17443
17642
|
child.stderr.on("data", (chunk) => {
|
|
17444
17643
|
stderr += chunk;
|
|
17445
17644
|
});
|
|
17446
17645
|
child.on("error", reject);
|
|
17447
|
-
child.on("exit", (code) => code === 0 ?
|
|
17646
|
+
child.on("exit", (code) => code === 0 ? resolve8() : reject(new Error(`Failed to normalize /etc/resolv.conf: ${stderr.trim()}`)));
|
|
17448
17647
|
child.stdin.end("\n");
|
|
17449
17648
|
});
|
|
17450
17649
|
}
|
|
@@ -17842,8 +18041,8 @@ ${typeof pending.subject.command === "string" ? pending.subject.command : JSON.s
|
|
|
17842
18041
|
userMessageRecorded = true;
|
|
17843
18042
|
}
|
|
17844
18043
|
if (/^\/compact$/i.test(request.message.trim())) {
|
|
17845
|
-
const completed2 = new Promise((
|
|
17846
|
-
this.compactionComplete = { resolve:
|
|
18044
|
+
const completed2 = new Promise((resolve8) => {
|
|
18045
|
+
this.compactionComplete = { resolve: resolve8 };
|
|
17847
18046
|
});
|
|
17848
18047
|
const result2 = await this.request("session/compact", {
|
|
17849
18048
|
commandId: uuidV7(),
|
|
@@ -17875,8 +18074,8 @@ ${pending}
|
|
|
17875
18074
|
|
|
17876
18075
|
` : ""}${request.planMode ? "Plan the requested work without modifying files or running mutating commands.\n\n" : ""}${request.message}`;
|
|
17877
18076
|
this.turnError = null;
|
|
17878
|
-
const completed = new Promise((
|
|
17879
|
-
this.turnComplete = { resolve:
|
|
18077
|
+
const completed = new Promise((resolve8) => {
|
|
18078
|
+
this.turnComplete = { resolve: resolve8 };
|
|
17880
18079
|
});
|
|
17881
18080
|
const result = await this.request("turn/start", {
|
|
17882
18081
|
commandId: uuidV7(),
|
|
@@ -18059,7 +18258,7 @@ ${pending}
|
|
|
18059
18258
|
|
|
18060
18259
|
// src/managers/opencode-manager.ts
|
|
18061
18260
|
import { existsSync as existsSync10 } from "fs";
|
|
18062
|
-
import { copyFile, mkdir as mkdir17, readFile as readFile16, rm as
|
|
18261
|
+
import { copyFile, mkdir as mkdir17, readFile as readFile16, rm as rm3 } from "fs/promises";
|
|
18063
18262
|
import { delimiter, dirname as dirname10, join as join22 } from "path";
|
|
18064
18263
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
18065
18264
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -18390,8 +18589,8 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18390
18589
|
const previousUpdate = this.clientUpdate;
|
|
18391
18590
|
let finishUpdate = () => {
|
|
18392
18591
|
};
|
|
18393
|
-
this.clientUpdate = new Promise((
|
|
18394
|
-
finishUpdate =
|
|
18592
|
+
this.clientUpdate = new Promise((resolve8) => {
|
|
18593
|
+
finishUpdate = resolve8;
|
|
18395
18594
|
});
|
|
18396
18595
|
await previousUpdate;
|
|
18397
18596
|
try {
|
|
@@ -18421,7 +18620,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18421
18620
|
}
|
|
18422
18621
|
await mkdir17(dirname10(OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH), { recursive: true });
|
|
18423
18622
|
await copyFile(OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE, OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH);
|
|
18424
|
-
await
|
|
18623
|
+
await rm3(OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH, { force: true });
|
|
18425
18624
|
process.env.REPLICAS_COMMAND_PROTECTION_HOOK_PATH = getCommandProtectionHookPath();
|
|
18426
18625
|
process.env.REPLICAS_POST_TOOL_PR_HOOK_PATH = getPostToolPrHookPath();
|
|
18427
18626
|
process.env.REPLICAS_COMMAND_PROTECTION_RUNTIME_PATH = process.execPath;
|
|
@@ -18465,8 +18664,8 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18465
18664
|
this.configuredModels = new Set(providerModels);
|
|
18466
18665
|
const eventController = new AbortController();
|
|
18467
18666
|
this.eventAbortController = eventController;
|
|
18468
|
-
this.eventSubscriptionReady = new Promise((
|
|
18469
|
-
this.resolveEventSubscriptionReady =
|
|
18667
|
+
this.eventSubscriptionReady = new Promise((resolve8) => {
|
|
18668
|
+
this.resolveEventSubscriptionReady = resolve8;
|
|
18470
18669
|
});
|
|
18471
18670
|
this.subscribeToEvents(client2, eventController).catch((error) => {
|
|
18472
18671
|
this.resolveEventSubscriptionReady?.();
|
|
@@ -18476,7 +18675,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18476
18675
|
});
|
|
18477
18676
|
await Promise.race([
|
|
18478
18677
|
this.eventSubscriptionReady,
|
|
18479
|
-
new Promise((
|
|
18678
|
+
new Promise((resolve8) => setTimeout(resolve8, 2e3))
|
|
18480
18679
|
]);
|
|
18481
18680
|
return client2;
|
|
18482
18681
|
} finally {
|
|
@@ -19803,15 +20002,15 @@ function Get2() {
|
|
|
19803
20002
|
|
|
19804
20003
|
// ../node_modules/.bun/typebox@1.3.7/node_modules/typebox/build/type/types/_codec.mjs
|
|
19805
20004
|
var EncodeBuilder = class {
|
|
19806
|
-
constructor(type,
|
|
20005
|
+
constructor(type, decode2) {
|
|
19807
20006
|
this.type = type;
|
|
19808
|
-
this.decode =
|
|
20007
|
+
this.decode = decode2;
|
|
19809
20008
|
}
|
|
19810
20009
|
Encode(callback) {
|
|
19811
20010
|
const type = this.type;
|
|
19812
|
-
const
|
|
20011
|
+
const decode2 = IsCodec(type) ? (value) => this.decode(type["~codec"].decode(value)) : this.decode;
|
|
19813
20012
|
const encode = IsCodec(type) ? (value) => type["~codec"].encode(callback(value)) : callback;
|
|
19814
|
-
const codec = { decode, encode };
|
|
20013
|
+
const codec = { decode: decode2, encode };
|
|
19815
20014
|
return memory_exports.Update(this.type, { "~codec": codec }, {});
|
|
19816
20015
|
}
|
|
19817
20016
|
};
|
|
@@ -27311,9 +27510,9 @@ var rev2026Codec = {
|
|
|
27311
27510
|
});
|
|
27312
27511
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta);
|
|
27313
27512
|
if (!parsed.success) for (const issue of parsed.error.issues) {
|
|
27314
|
-
const
|
|
27315
|
-
const key =
|
|
27316
|
-
if (
|
|
27513
|
+
const path8 = issue.path.map(String);
|
|
27514
|
+
const key = path8.length > 0 ? path8.join(".") : "_meta";
|
|
27515
|
+
if (path8.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing")) continue;
|
|
27317
27516
|
issues.push({
|
|
27318
27517
|
key,
|
|
27319
27518
|
problem: issue.message
|
|
@@ -27612,29 +27811,29 @@ var PERMITTED_X_MCP_HEADER_TYPES = /* @__PURE__ */ new Set([
|
|
|
27612
27811
|
function scanXMcpHeaderDeclarations(inputSchema) {
|
|
27613
27812
|
const declarations = [];
|
|
27614
27813
|
const seenLower = /* @__PURE__ */ new Map();
|
|
27615
|
-
const visit = (node,
|
|
27814
|
+
const visit = (node, path8, reachable) => {
|
|
27616
27815
|
if (node === null || typeof node !== "object") return void 0;
|
|
27617
27816
|
const schema = node;
|
|
27618
27817
|
if (X_MCP_HEADER_KEY in schema) {
|
|
27619
|
-
if (!reachable ||
|
|
27818
|
+
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
27819
|
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(
|
|
27820
|
+
if (typeof raw !== "string" || raw.length === 0) return `${pathName(path8)}: x-mcp-header MUST be a non-empty string`;
|
|
27821
|
+
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
27822
|
const type = typeof schema.type === "string" ? schema.type : void 0;
|
|
27624
|
-
if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(
|
|
27823
|
+
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
27824
|
const lower = raw.toLowerCase();
|
|
27626
27825
|
const prior = seenLower.get(lower);
|
|
27627
27826
|
if (prior !== void 0) return `x-mcp-header '${raw}' is not case-insensitively unique (also declared as '${prior}')`;
|
|
27628
27827
|
seenLower.set(lower, raw);
|
|
27629
27828
|
declarations.push({
|
|
27630
|
-
path:
|
|
27829
|
+
path: path8,
|
|
27631
27830
|
headerName: raw,
|
|
27632
27831
|
type
|
|
27633
27832
|
});
|
|
27634
27833
|
}
|
|
27635
27834
|
const properties = schema.properties;
|
|
27636
27835
|
if (properties !== null && typeof properties === "object") for (const [key, child] of Object.entries(properties)) {
|
|
27637
|
-
const fault$1 = visit(child, [...
|
|
27836
|
+
const fault$1 = visit(child, [...path8, key], reachable);
|
|
27638
27837
|
if (fault$1 !== void 0) return fault$1;
|
|
27639
27838
|
}
|
|
27640
27839
|
for (const k of NON_REACHABLE_SUBSCHEMA_KEYWORDS) {
|
|
@@ -27642,7 +27841,7 @@ function scanXMcpHeaderDeclarations(inputSchema) {
|
|
|
27642
27841
|
if (sub === void 0) continue;
|
|
27643
27842
|
const branches = Array.isArray(sub) ? sub : sub !== null && typeof sub === "object" && OBJECT_VALUED_SUBSCHEMA_KEYWORDS.has(k) ? Object.values(sub) : [sub];
|
|
27644
27843
|
for (const branch of branches) {
|
|
27645
|
-
const fault$1 = visit(branch, [...
|
|
27844
|
+
const fault$1 = visit(branch, [...path8, `<${k}>`], false);
|
|
27646
27845
|
if (fault$1 !== void 0) return fault$1;
|
|
27647
27846
|
}
|
|
27648
27847
|
}
|
|
@@ -27682,8 +27881,8 @@ var OBJECT_VALUED_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
27682
27881
|
"$defs",
|
|
27683
27882
|
"definitions"
|
|
27684
27883
|
]);
|
|
27685
|
-
function pathName(
|
|
27686
|
-
return
|
|
27884
|
+
function pathName(path8) {
|
|
27885
|
+
return path8.length === 0 ? "<root>" : path8.join(".");
|
|
27687
27886
|
}
|
|
27688
27887
|
var BASE64_SENTINEL_PREFIX = "=?base64?";
|
|
27689
27888
|
var BASE64_SENTINEL_SUFFIX = "?=";
|
|
@@ -27716,9 +27915,9 @@ function utf8ToBase64(s) {
|
|
|
27716
27915
|
function encodeMcpParamValue(value) {
|
|
27717
27916
|
return needsBase64(value) ? `${BASE64_SENTINEL_PREFIX}${utf8ToBase64(value)}${BASE64_SENTINEL_SUFFIX}` : value;
|
|
27718
27917
|
}
|
|
27719
|
-
function valueAtPath(root,
|
|
27918
|
+
function valueAtPath(root, path8) {
|
|
27720
27919
|
let node = root;
|
|
27721
|
-
for (const key of
|
|
27920
|
+
for (const key of path8) {
|
|
27722
27921
|
if (node === null || typeof node !== "object") return void 0;
|
|
27723
27922
|
node = node[key];
|
|
27724
27923
|
}
|
|
@@ -27973,7 +28172,7 @@ var PROPERTY_KEYS_BY_TYPE = {
|
|
|
27973
28172
|
array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
|
|
27974
28173
|
};
|
|
27975
28174
|
var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
|
|
27976
|
-
function walkProperty(node,
|
|
28175
|
+
function walkProperty(node, path8, vendor, unsupported) {
|
|
27977
28176
|
if (!isJsonObject(node)) return node;
|
|
27978
28177
|
const allowedKeys = typeof node.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node.type) ? PROPERTY_KEYS_BY_TYPE[node.type] : void 0;
|
|
27979
28178
|
if (allowedKeys === void 0) return node;
|
|
@@ -27981,8 +28180,8 @@ function walkProperty(node, path7, vendor, unsupported) {
|
|
|
27981
28180
|
for (const [key, value] of Object.entries(node)) if (allowedKeys.has(key) || isAnnotationOnlyJsonSchemaKeyword(key)) pruned[key] = value;
|
|
27982
28181
|
else if (key === "pattern" && node.type === "string" && typeof node.format === "string") {
|
|
27983
28182
|
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(`${
|
|
28183
|
+
else if (typeof value !== "string" || !isLibraryFormatPattern(node.format, value, vendor)) unsupported.push(`${path8}.${key}`);
|
|
28184
|
+
} else unsupported.push(`${path8}.${key}`);
|
|
27986
28185
|
return pruned;
|
|
27987
28186
|
}
|
|
27988
28187
|
function walkRequestedSchema(converted, vendor) {
|
|
@@ -27999,11 +28198,11 @@ function describeUnsupportedProperties(pruned, fallback) {
|
|
|
27999
28198
|
const offenders = Object.entries(pruned.properties).filter(([, node]) => !parseSchema(PrimitiveSchemaDefinitionSchema, node).success).map(([name]) => `properties.${name}`);
|
|
28000
28199
|
return offenders.length > 0 ? offenders.join(", ") : fallback;
|
|
28001
28200
|
}
|
|
28002
|
-
function findDroppedConstraintPaths(original, parsed,
|
|
28003
|
-
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${
|
|
28201
|
+
function findDroppedConstraintPaths(original, parsed, path8 = "") {
|
|
28202
|
+
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path8}[${index}]`));
|
|
28004
28203
|
if (!isJsonObject(original) || !isJsonObject(parsed)) return [];
|
|
28005
28204
|
return Object.entries(original).flatMap(([key, value]) => {
|
|
28006
|
-
const childPath =
|
|
28205
|
+
const childPath = path8 ? `${path8}.${key}` : key;
|
|
28007
28206
|
if (!Object.prototype.hasOwnProperty.call(parsed, key)) return isAnnotationOnlyJsonSchemaKeyword(key) ? [] : [childPath];
|
|
28008
28207
|
return findDroppedConstraintPaths(value, parsed[key], childPath);
|
|
28009
28208
|
});
|
|
@@ -28090,14 +28289,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
|
28090
28289
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
28091
28290
|
}
|
|
28092
28291
|
function sleep(ms, signal) {
|
|
28093
|
-
return new Promise((
|
|
28292
|
+
return new Promise((resolve8, reject) => {
|
|
28094
28293
|
if (signal?.aborted) {
|
|
28095
28294
|
reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
28096
28295
|
return;
|
|
28097
28296
|
}
|
|
28098
28297
|
const timer = setTimeout(() => {
|
|
28099
28298
|
signal?.removeEventListener("abort", onAbort);
|
|
28100
|
-
|
|
28299
|
+
resolve8();
|
|
28101
28300
|
}, ms);
|
|
28102
28301
|
const onAbort = () => {
|
|
28103
28302
|
clearTimeout(timer);
|
|
@@ -28936,7 +29135,7 @@ var Protocol = class {
|
|
|
28936
29135
|
const flowStartedAt = Date.now();
|
|
28937
29136
|
let onAbort;
|
|
28938
29137
|
let cleanupMessageId;
|
|
28939
|
-
return new Promise((
|
|
29138
|
+
return new Promise((resolve8, reject) => {
|
|
28940
29139
|
const earlyReject = (error) => {
|
|
28941
29140
|
reject(error);
|
|
28942
29141
|
};
|
|
@@ -29004,7 +29203,7 @@ var Protocol = class {
|
|
|
29004
29203
|
}
|
|
29005
29204
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
29006
29205
|
if (decoded.kind === "input_required") {
|
|
29007
|
-
if (options?.allowInputRequired === true) return
|
|
29206
|
+
if (options?.allowInputRequired === true) return resolve8(manualInputRequiredValue(decoded));
|
|
29008
29207
|
const flow = {
|
|
29009
29208
|
codec,
|
|
29010
29209
|
request,
|
|
@@ -29016,11 +29215,11 @@ var Protocol = class {
|
|
|
29016
29215
|
params
|
|
29017
29216
|
}, resultSchema, legOptions)
|
|
29018
29217
|
};
|
|
29019
|
-
return
|
|
29218
|
+
return resolve8(this._resolveNonCompleteResult(decoded, flow));
|
|
29020
29219
|
}
|
|
29021
29220
|
const result = decoded.result;
|
|
29022
29221
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
29023
|
-
if (parseResult.success)
|
|
29222
|
+
if (parseResult.success) resolve8(parseResult.data);
|
|
29024
29223
|
else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
|
|
29025
29224
|
}, reject);
|
|
29026
29225
|
});
|
|
@@ -31972,7 +32171,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31972
32171
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
31973
32172
|
const schOrFunc = root.refs[ref];
|
|
31974
32173
|
if (schOrFunc) return schOrFunc;
|
|
31975
|
-
let _sch =
|
|
32174
|
+
let _sch = resolve8.call(this, root, ref);
|
|
31976
32175
|
if (_sch === void 0) {
|
|
31977
32176
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
31978
32177
|
const { schemaId } = this.opts;
|
|
@@ -31998,7 +32197,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31998
32197
|
function sameSchemaEnv(s1, s2) {
|
|
31999
32198
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
32000
32199
|
}
|
|
32001
|
-
function
|
|
32200
|
+
function resolve8(root, ref) {
|
|
32002
32201
|
let sch;
|
|
32003
32202
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
32004
32203
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -32183,8 +32382,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32183
32382
|
for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
|
|
32184
32383
|
return ind;
|
|
32185
32384
|
}
|
|
32186
|
-
function removeDotSegments(
|
|
32187
|
-
let input =
|
|
32385
|
+
function removeDotSegments(path8) {
|
|
32386
|
+
let input = path8;
|
|
32188
32387
|
const output = [];
|
|
32189
32388
|
let nextSlash = -1;
|
|
32190
32389
|
let len = 0;
|
|
@@ -32337,8 +32536,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32337
32536
|
wsComponent.secure = void 0;
|
|
32338
32537
|
}
|
|
32339
32538
|
if (wsComponent.resourceName) {
|
|
32340
|
-
const [
|
|
32341
|
-
wsComponent.path =
|
|
32539
|
+
const [path8, query2] = wsComponent.resourceName.split("?");
|
|
32540
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
32342
32541
|
wsComponent.query = query2;
|
|
32343
32542
|
wsComponent.resourceName = void 0;
|
|
32344
32543
|
}
|
|
@@ -32385,15 +32584,15 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32385
32584
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
32386
32585
|
return urnComponent;
|
|
32387
32586
|
}
|
|
32388
|
-
const
|
|
32587
|
+
const http3 = {
|
|
32389
32588
|
scheme: "http",
|
|
32390
32589
|
domainHost: true,
|
|
32391
32590
|
parse: httpParse,
|
|
32392
32591
|
serialize: httpSerialize
|
|
32393
32592
|
};
|
|
32394
|
-
const
|
|
32593
|
+
const https2 = {
|
|
32395
32594
|
scheme: "https",
|
|
32396
|
-
domainHost:
|
|
32595
|
+
domainHost: http3.domainHost,
|
|
32397
32596
|
parse: httpParse,
|
|
32398
32597
|
serialize: httpSerialize
|
|
32399
32598
|
};
|
|
@@ -32422,8 +32621,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32422
32621
|
skipNormalize: true
|
|
32423
32622
|
};
|
|
32424
32623
|
const SCHEMES = {
|
|
32425
|
-
http:
|
|
32426
|
-
https,
|
|
32624
|
+
http: http3,
|
|
32625
|
+
https: https2,
|
|
32427
32626
|
ws,
|
|
32428
32627
|
wss,
|
|
32429
32628
|
urn,
|
|
@@ -32448,7 +32647,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32448
32647
|
else if (typeof uri === "object") uri = parse(serialize(uri, options), options);
|
|
32449
32648
|
return uri;
|
|
32450
32649
|
}
|
|
32451
|
-
function
|
|
32650
|
+
function resolve8(baseURI, relativeURI, options) {
|
|
32452
32651
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
32453
32652
|
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
32454
32653
|
schemelessOptions.skipEscape = true;
|
|
@@ -32622,7 +32821,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32622
32821
|
const fastUri = {
|
|
32623
32822
|
SCHEMES,
|
|
32624
32823
|
normalize,
|
|
32625
|
-
resolve:
|
|
32824
|
+
resolve: resolve8,
|
|
32626
32825
|
resolveComponent,
|
|
32627
32826
|
equal,
|
|
32628
32827
|
serialize,
|
|
@@ -38435,14 +38634,14 @@ var ProbeWindow = class ProbeWindow2 {
|
|
|
38435
38634
|
*/
|
|
38436
38635
|
async exchange(buildRequest, timeoutMs) {
|
|
38437
38636
|
const id = `server-discover-probe-${++this._probeCounter}`;
|
|
38438
|
-
return new Promise((
|
|
38637
|
+
return new Promise((resolve8) => {
|
|
38439
38638
|
let settled = false;
|
|
38440
38639
|
const settle = (reply) => {
|
|
38441
38640
|
if (settled) return;
|
|
38442
38641
|
settled = true;
|
|
38443
38642
|
clearTimeout(timer);
|
|
38444
38643
|
if (this._pending?.id === id) this._pending = void 0;
|
|
38445
|
-
|
|
38644
|
+
resolve8(reply);
|
|
38446
38645
|
};
|
|
38447
38646
|
const timer = setTimeout(() => settle({ kind: "timeout" }), timeoutMs);
|
|
38448
38647
|
this._pending = {
|
|
@@ -39648,13 +39847,13 @@ var Client = class extends Protocol {
|
|
|
39648
39847
|
let onCallerAbort;
|
|
39649
39848
|
let resolveOpening;
|
|
39650
39849
|
let rejectOpening;
|
|
39651
|
-
const opening = new Promise((
|
|
39652
|
-
resolveOpening =
|
|
39850
|
+
const opening = new Promise((resolve8, reject) => {
|
|
39851
|
+
resolveOpening = resolve8;
|
|
39653
39852
|
rejectOpening = reject;
|
|
39654
39853
|
});
|
|
39655
39854
|
let resolveClosed;
|
|
39656
|
-
const closed = new Promise((
|
|
39657
|
-
resolveClosed =
|
|
39855
|
+
const closed = new Promise((resolve8) => {
|
|
39856
|
+
resolveClosed = resolve8;
|
|
39658
39857
|
});
|
|
39659
39858
|
const settle = (outcome) => {
|
|
39660
39859
|
if (state === "closed") return;
|
|
@@ -40134,7 +40333,7 @@ var SSEClientTransport = class {
|
|
|
40134
40333
|
}
|
|
40135
40334
|
_startOrAuth() {
|
|
40136
40335
|
const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
|
|
40137
|
-
return new Promise((
|
|
40336
|
+
return new Promise((resolve8, reject) => {
|
|
40138
40337
|
this._eventSource = new EventSource(this._url.href, {
|
|
40139
40338
|
...this._eventSourceInit,
|
|
40140
40339
|
fetch: async (url3, init) => {
|
|
@@ -40166,7 +40365,7 @@ var SSEClientTransport = class {
|
|
|
40166
40365
|
response,
|
|
40167
40366
|
serverUrl: this._url,
|
|
40168
40367
|
fetchFn: this._fetchWithInit
|
|
40169
|
-
}).then(() => this._startOrAuth().then(
|
|
40368
|
+
}).then(() => this._startOrAuth().then(resolve8, reject), (error$2) => {
|
|
40170
40369
|
markAuthSeamEscape(error$2);
|
|
40171
40370
|
this.onerror?.(error$2);
|
|
40172
40371
|
reject(error$2);
|
|
@@ -40195,7 +40394,7 @@ var SSEClientTransport = class {
|
|
|
40195
40394
|
this.close();
|
|
40196
40395
|
return;
|
|
40197
40396
|
}
|
|
40198
|
-
|
|
40397
|
+
resolve8();
|
|
40199
40398
|
});
|
|
40200
40399
|
this._eventSource.onmessage = (event) => {
|
|
40201
40400
|
const messageEvent = event;
|
|
@@ -40871,7 +41070,7 @@ var StreamableHTTPClientTransport = class {
|
|
|
40871
41070
|
};
|
|
40872
41071
|
|
|
40873
41072
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/server-manager.ts
|
|
40874
|
-
import { mkdirSync as mkdirSync2, statSync as
|
|
41073
|
+
import { mkdirSync as mkdirSync2, statSync as statSync3 } from "fs";
|
|
40875
41074
|
import { isDeepStrictEqual } from "util";
|
|
40876
41075
|
|
|
40877
41076
|
// ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/stdio.mjs
|
|
@@ -40927,7 +41126,7 @@ var StdioClientTransport = class {
|
|
|
40927
41126
|
*/
|
|
40928
41127
|
async start() {
|
|
40929
41128
|
if (this._process) throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
40930
|
-
return new Promise((
|
|
41129
|
+
return new Promise((resolve8, reject) => {
|
|
40931
41130
|
this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
|
|
40932
41131
|
env: {
|
|
40933
41132
|
...getDefaultEnvironment(),
|
|
@@ -40947,7 +41146,7 @@ var StdioClientTransport = class {
|
|
|
40947
41146
|
this.onerror?.(error);
|
|
40948
41147
|
});
|
|
40949
41148
|
this._process.on("spawn", () => {
|
|
40950
|
-
|
|
41149
|
+
resolve8();
|
|
40951
41150
|
});
|
|
40952
41151
|
this._process.on("close", (_code) => {
|
|
40953
41152
|
this._process = void 0;
|
|
@@ -41012,7 +41211,7 @@ var StdioClientTransport = class {
|
|
|
41012
41211
|
const proc = this._process;
|
|
41013
41212
|
this._process = void 0;
|
|
41014
41213
|
if (proc && proc.exitCode === null && proc.signalCode === null) {
|
|
41015
|
-
const exited = new Promise((
|
|
41214
|
+
const exited = new Promise((resolve8) => proc.once("exit", () => resolve8()));
|
|
41016
41215
|
try {
|
|
41017
41216
|
proc.stdin?.end();
|
|
41018
41217
|
} catch {
|
|
@@ -41021,7 +41220,7 @@ var StdioClientTransport = class {
|
|
|
41021
41220
|
proc.kill("SIGTERM");
|
|
41022
41221
|
} catch {
|
|
41023
41222
|
}
|
|
41024
|
-
await Promise.race([exited, new Promise((
|
|
41223
|
+
await Promise.race([exited, new Promise((resolve8) => setTimeout(resolve8, 1e3).unref())]);
|
|
41025
41224
|
if (proc.exitCode === null && proc.signalCode === null) try {
|
|
41026
41225
|
proc.kill("SIGKILL");
|
|
41027
41226
|
} catch {
|
|
@@ -41046,22 +41245,22 @@ var StdioClientTransport = class {
|
|
|
41046
41245
|
if (this._process) {
|
|
41047
41246
|
const processToClose = this._process;
|
|
41048
41247
|
this._process = void 0;
|
|
41049
|
-
const closePromise = new Promise((
|
|
41248
|
+
const closePromise = new Promise((resolve8) => {
|
|
41050
41249
|
processToClose.once("close", () => {
|
|
41051
|
-
|
|
41250
|
+
resolve8();
|
|
41052
41251
|
});
|
|
41053
41252
|
});
|
|
41054
41253
|
try {
|
|
41055
41254
|
processToClose.stdin?.end();
|
|
41056
41255
|
} catch {
|
|
41057
41256
|
}
|
|
41058
|
-
await Promise.race([closePromise, new Promise((
|
|
41257
|
+
await Promise.race([closePromise, new Promise((resolve8) => setTimeout(resolve8, 2e3).unref())]);
|
|
41059
41258
|
if (processToClose.exitCode === null) {
|
|
41060
41259
|
try {
|
|
41061
41260
|
processToClose.kill("SIGTERM");
|
|
41062
41261
|
} catch {
|
|
41063
41262
|
}
|
|
41064
|
-
await Promise.race([closePromise, new Promise((
|
|
41263
|
+
await Promise.race([closePromise, new Promise((resolve8) => setTimeout(resolve8, 2e3).unref())]);
|
|
41065
41264
|
}
|
|
41066
41265
|
if (processToClose.exitCode === null) try {
|
|
41067
41266
|
processToClose.kill("SIGKILL");
|
|
@@ -41071,11 +41270,11 @@ var StdioClientTransport = class {
|
|
|
41071
41270
|
this._readBuffer.clear();
|
|
41072
41271
|
}
|
|
41073
41272
|
send(message) {
|
|
41074
|
-
return new Promise((
|
|
41273
|
+
return new Promise((resolve8) => {
|
|
41075
41274
|
if (!this._process?.stdin) throw new SdkError(SdkErrorCode.NotConnected, "Not connected");
|
|
41076
41275
|
const json = serializeMessage(message);
|
|
41077
|
-
if (this._process.stdin.write(json))
|
|
41078
|
-
else this._process.stdin.once("drain",
|
|
41276
|
+
if (this._process.stdin.write(json)) resolve8();
|
|
41277
|
+
else this._process.stdin.once("drain", resolve8);
|
|
41079
41278
|
});
|
|
41080
41279
|
}
|
|
41081
41280
|
};
|
|
@@ -41096,13 +41295,13 @@ var UnixSocketClientTransport = class {
|
|
|
41096
41295
|
if (this.socket) {
|
|
41097
41296
|
throw new Error("UnixSocketClientTransport already started");
|
|
41098
41297
|
}
|
|
41099
|
-
await new Promise((
|
|
41298
|
+
await new Promise((resolve8, reject) => {
|
|
41100
41299
|
const socket = createConnection(this.socketPath);
|
|
41101
41300
|
this.socket = socket;
|
|
41102
41301
|
let connected = false;
|
|
41103
41302
|
socket.once("connect", () => {
|
|
41104
41303
|
connected = true;
|
|
41105
|
-
|
|
41304
|
+
resolve8();
|
|
41106
41305
|
});
|
|
41107
41306
|
socket.on("data", (chunk) => {
|
|
41108
41307
|
try {
|
|
@@ -41134,12 +41333,12 @@ var UnixSocketClientTransport = class {
|
|
|
41134
41333
|
this.socket = void 0;
|
|
41135
41334
|
this.readBuffer.clear();
|
|
41136
41335
|
if (!socket || socket.destroyed) return;
|
|
41137
|
-
await new Promise((
|
|
41336
|
+
await new Promise((resolve8) => {
|
|
41138
41337
|
const timeout = setTimeout(() => socket.destroy(), 2e3);
|
|
41139
41338
|
timeout.unref();
|
|
41140
41339
|
socket.once("close", () => {
|
|
41141
41340
|
clearTimeout(timeout);
|
|
41142
|
-
|
|
41341
|
+
resolve8();
|
|
41143
41342
|
});
|
|
41144
41343
|
socket.end();
|
|
41145
41344
|
});
|
|
@@ -41147,10 +41346,10 @@ var UnixSocketClientTransport = class {
|
|
|
41147
41346
|
async send(message) {
|
|
41148
41347
|
const socket = this.socket;
|
|
41149
41348
|
if (!socket || socket.destroyed) throw new Error("Unix socket is not connected");
|
|
41150
|
-
await new Promise((
|
|
41349
|
+
await new Promise((resolve8, reject) => {
|
|
41151
41350
|
socket.write(serializeMessage(message), (error) => {
|
|
41152
41351
|
if (error) reject(error);
|
|
41153
|
-
else
|
|
41352
|
+
else resolve8();
|
|
41154
41353
|
});
|
|
41155
41354
|
});
|
|
41156
41355
|
}
|
|
@@ -41304,8 +41503,8 @@ async function probeMcpEndpoint(url3) {
|
|
|
41304
41503
|
}
|
|
41305
41504
|
|
|
41306
41505
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
|
|
41307
|
-
import { existsSync as existsSync11, readFileSync as readFileSync4, realpathSync, readdirSync, statSync, writeFileSync, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
|
|
41308
|
-
import { join as join24, dirname as dirname11, extname as extname2, resolve as
|
|
41506
|
+
import { existsSync as existsSync11, readFileSync as readFileSync4, realpathSync, readdirSync as readdirSync2, statSync as statSync2, writeFileSync, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
|
|
41507
|
+
import { join as join24, dirname as dirname11, extname as extname2, resolve as resolve3, sep } from "path";
|
|
41309
41508
|
|
|
41310
41509
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/abort.ts
|
|
41311
41510
|
function throwIfAborted(signal) {
|
|
@@ -41315,7 +41514,7 @@ function throwIfAborted(signal) {
|
|
|
41315
41514
|
async function abortable(promise, signal) {
|
|
41316
41515
|
if (!signal) return promise;
|
|
41317
41516
|
throwIfAborted(signal);
|
|
41318
|
-
return await new Promise((
|
|
41517
|
+
return await new Promise((resolve8, reject) => {
|
|
41319
41518
|
let settled = false;
|
|
41320
41519
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
41321
41520
|
const onAbort = () => {
|
|
@@ -41330,7 +41529,7 @@ async function abortable(promise, signal) {
|
|
|
41330
41529
|
if (settled) return;
|
|
41331
41530
|
settled = true;
|
|
41332
41531
|
cleanup();
|
|
41333
|
-
|
|
41532
|
+
resolve8(value);
|
|
41334
41533
|
},
|
|
41335
41534
|
(error) => {
|
|
41336
41535
|
if (settled) return;
|
|
@@ -41499,7 +41698,7 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
41499
41698
|
const binLink = chosenBinName ? join24(nodeModulesDir, ".bin", chosenBinName) : null;
|
|
41500
41699
|
let resolvedBin = binLink && existsSync11(binLink) ? safeRealpath(binLink) : "";
|
|
41501
41700
|
if (!resolvedBin) {
|
|
41502
|
-
resolvedBin =
|
|
41701
|
+
resolvedBin = resolve3(packageDir, binRel);
|
|
41503
41702
|
if (!existsSync11(resolvedBin)) return null;
|
|
41504
41703
|
}
|
|
41505
41704
|
const isJs = detectJsBinary(resolvedBin);
|
|
@@ -41514,7 +41713,7 @@ var FORCE_CACHE_TIMEOUT_MS = 3e4;
|
|
|
41514
41713
|
async function forceNpxCache(packageSpec, signal) {
|
|
41515
41714
|
throwIfAborted(signal);
|
|
41516
41715
|
try {
|
|
41517
|
-
await new Promise((
|
|
41716
|
+
await new Promise((resolve8, reject) => {
|
|
41518
41717
|
const proc = (0, import_cross_spawn2.default)(
|
|
41519
41718
|
"npm",
|
|
41520
41719
|
["exec", "--yes", "--package", packageSpec, "--", "node", "-e", "1"],
|
|
@@ -41533,7 +41732,7 @@ async function forceNpxCache(packageSpec, signal) {
|
|
|
41533
41732
|
proc.on("close", () => {
|
|
41534
41733
|
clearTimeout(timer);
|
|
41535
41734
|
signal?.removeEventListener("abort", abort);
|
|
41536
|
-
|
|
41735
|
+
resolve8();
|
|
41537
41736
|
});
|
|
41538
41737
|
proc.on("error", (err) => {
|
|
41539
41738
|
clearTimeout(timer);
|
|
@@ -41601,7 +41800,7 @@ function findCachedPackageDir(cacheDir, packageName, exactVersion) {
|
|
|
41601
41800
|
const npxDir = join24(cacheDir, "_npx");
|
|
41602
41801
|
if (!existsSync11(npxDir)) return null;
|
|
41603
41802
|
const packagePathParts = packageName.startsWith("@") ? packageName.split("/") : [packageName];
|
|
41604
|
-
const candidates =
|
|
41803
|
+
const candidates = readdirSync2(npxDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
|
|
41605
41804
|
const full = join24(npxDir, entry.name);
|
|
41606
41805
|
const mtime = safeStatMtime(full);
|
|
41607
41806
|
return { name: entry.name, mtime };
|
|
@@ -41657,8 +41856,8 @@ function getNpmCacheDir() {
|
|
|
41657
41856
|
try {
|
|
41658
41857
|
const result = import_cross_spawn2.default.sync("npm", ["config", "get", "cache"], { encoding: "utf-8" });
|
|
41659
41858
|
if (result.status === 0) {
|
|
41660
|
-
const
|
|
41661
|
-
npmCacheDirCached =
|
|
41859
|
+
const path8 = String(result.stdout).trim();
|
|
41860
|
+
npmCacheDirCached = path8 || null;
|
|
41662
41861
|
return npmCacheDirCached;
|
|
41663
41862
|
}
|
|
41664
41863
|
} catch {
|
|
@@ -41746,16 +41945,16 @@ function saveCacheEntry(key, entry) {
|
|
|
41746
41945
|
} catch {
|
|
41747
41946
|
}
|
|
41748
41947
|
}
|
|
41749
|
-
function safeRealpath(
|
|
41948
|
+
function safeRealpath(path8) {
|
|
41750
41949
|
try {
|
|
41751
|
-
return realpathSync(
|
|
41950
|
+
return realpathSync(path8);
|
|
41752
41951
|
} catch {
|
|
41753
41952
|
return "";
|
|
41754
41953
|
}
|
|
41755
41954
|
}
|
|
41756
|
-
function safeStatMtime(
|
|
41955
|
+
function safeStatMtime(path8) {
|
|
41757
41956
|
try {
|
|
41758
|
-
return
|
|
41957
|
+
return statSync2(path8).mtimeMs;
|
|
41759
41958
|
} catch {
|
|
41760
41959
|
return 0;
|
|
41761
41960
|
}
|
|
@@ -42500,8 +42699,8 @@ function setOAuthCallbackPort(port2) {
|
|
|
42500
42699
|
function getOAuthCallbackPath() {
|
|
42501
42700
|
return oauthCallbackPath;
|
|
42502
42701
|
}
|
|
42503
|
-
function setOAuthCallbackPath(
|
|
42504
|
-
oauthCallbackPath =
|
|
42702
|
+
function setOAuthCallbackPath(path8) {
|
|
42703
|
+
oauthCallbackPath = path8.startsWith("/") ? path8 : `/${path8}`;
|
|
42505
42704
|
}
|
|
42506
42705
|
var reservedAuthorizationParams = /* @__PURE__ */ new Set([
|
|
42507
42706
|
"client_id",
|
|
@@ -43014,7 +43213,7 @@ var McpOAuthProvider = class {
|
|
|
43014
43213
|
// ../node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
43015
43214
|
import process9 from "process";
|
|
43016
43215
|
import { Buffer as Buffer2 } from "buffer";
|
|
43017
|
-
import
|
|
43216
|
+
import path6 from "path";
|
|
43018
43217
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
43019
43218
|
import { promisify as promisify5 } from "util";
|
|
43020
43219
|
import childProcess from "child_process";
|
|
@@ -43272,8 +43471,8 @@ async function defaultBrowser2() {
|
|
|
43272
43471
|
|
|
43273
43472
|
// ../node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
43274
43473
|
var execFile5 = promisify5(childProcess.execFile);
|
|
43275
|
-
var __dirname =
|
|
43276
|
-
var localXdgOpenPath =
|
|
43474
|
+
var __dirname = path6.dirname(fileURLToPath5(import.meta.url));
|
|
43475
|
+
var localXdgOpenPath = path6.join(__dirname, "xdg-open");
|
|
43277
43476
|
var { platform, arch } = process9;
|
|
43278
43477
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
43279
43478
|
const powershellPath = await powerShellPath();
|
|
@@ -43446,14 +43645,14 @@ var baseOpen = async (options) => {
|
|
|
43446
43645
|
}
|
|
43447
43646
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
43448
43647
|
if (options.wait) {
|
|
43449
|
-
return new Promise((
|
|
43648
|
+
return new Promise((resolve8, reject) => {
|
|
43450
43649
|
subprocess.once("error", reject);
|
|
43451
43650
|
subprocess.once("close", (exitCode) => {
|
|
43452
43651
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
43453
43652
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
43454
43653
|
return;
|
|
43455
43654
|
}
|
|
43456
|
-
|
|
43655
|
+
resolve8(subprocess);
|
|
43457
43656
|
});
|
|
43458
43657
|
});
|
|
43459
43658
|
}
|
|
@@ -43781,12 +43980,12 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43781
43980
|
const candidateServer = createServer(handleRequest);
|
|
43782
43981
|
const listenPort = strictPort ? requiredPort : 0;
|
|
43783
43982
|
try {
|
|
43784
|
-
await new Promise((
|
|
43983
|
+
await new Promise((resolve8, reject) => {
|
|
43785
43984
|
candidateServer.once("error", (err) => {
|
|
43786
43985
|
reject(err);
|
|
43787
43986
|
});
|
|
43788
43987
|
candidateServer.listen(listenPort, requestedHost, () => {
|
|
43789
|
-
|
|
43988
|
+
resolve8();
|
|
43790
43989
|
});
|
|
43791
43990
|
});
|
|
43792
43991
|
if (strictPort) {
|
|
@@ -43799,8 +43998,8 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43799
43998
|
setOAuthCallbackPort(address.port);
|
|
43800
43999
|
}
|
|
43801
44000
|
if (previousServer && (needsStrictRebind || needsHostSwitch)) {
|
|
43802
|
-
await new Promise((
|
|
43803
|
-
previousServer.close(() =>
|
|
44001
|
+
await new Promise((resolve8) => {
|
|
44002
|
+
previousServer.close(() => resolve8());
|
|
43804
44003
|
});
|
|
43805
44004
|
}
|
|
43806
44005
|
callbackServerHost = requestedHost;
|
|
@@ -43816,8 +44015,8 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43816
44015
|
reservedAuthStates.delete(reservedState);
|
|
43817
44016
|
}
|
|
43818
44017
|
const nodeError = error;
|
|
43819
|
-
await new Promise((
|
|
43820
|
-
candidateServer.close(() =>
|
|
44018
|
+
await new Promise((resolve8) => {
|
|
44019
|
+
candidateServer.close(() => resolve8());
|
|
43821
44020
|
});
|
|
43822
44021
|
if (strictPort && nodeError.code === "EADDRINUSE") {
|
|
43823
44022
|
throw new Error(
|
|
@@ -43833,14 +44032,14 @@ function releaseCallbackServer(oauthState) {
|
|
|
43833
44032
|
}
|
|
43834
44033
|
function waitForCallback(oauthState) {
|
|
43835
44034
|
reservedAuthStates.delete(oauthState);
|
|
43836
|
-
return new Promise((
|
|
44035
|
+
return new Promise((resolve8, reject) => {
|
|
43837
44036
|
const timeout = setTimeout(() => {
|
|
43838
44037
|
if (pendingAuths.has(oauthState)) {
|
|
43839
44038
|
pendingAuths.delete(oauthState);
|
|
43840
44039
|
reject(new Error("OAuth callback timeout - authorization took too long"));
|
|
43841
44040
|
}
|
|
43842
44041
|
}, CALLBACK_TIMEOUT_MS);
|
|
43843
|
-
pendingAuths.set(oauthState, { resolve:
|
|
44042
|
+
pendingAuths.set(oauthState, { resolve: resolve8, reject, timeout });
|
|
43844
44043
|
});
|
|
43845
44044
|
}
|
|
43846
44045
|
function cancelPendingCallback(oauthState) {
|
|
@@ -43865,9 +44064,9 @@ function stopCallbackServer() {
|
|
|
43865
44064
|
});
|
|
43866
44065
|
}
|
|
43867
44066
|
if (server) {
|
|
43868
|
-
await new Promise((
|
|
44067
|
+
await new Promise((resolve8) => {
|
|
43869
44068
|
server.close(() => {
|
|
43870
|
-
|
|
44069
|
+
resolve8();
|
|
43871
44070
|
});
|
|
43872
44071
|
});
|
|
43873
44072
|
server = void 0;
|
|
@@ -45409,7 +45608,7 @@ function humanizeName(name) {
|
|
|
45409
45608
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-trace.ts
|
|
45410
45609
|
import { appendFile as appendFile3, mkdir as mkdir18, writeFile as writeFile10 } from "fs/promises";
|
|
45411
45610
|
import { Buffer as Buffer3 } from "buffer";
|
|
45412
|
-
import { dirname as dirname14, isAbsolute as isAbsolute2, resolve as
|
|
45611
|
+
import { dirname as dirname14, isAbsolute as isAbsolute2, resolve as resolve4 } from "path";
|
|
45413
45612
|
var MCP_TRACE_SCHEMA_VERSION = 1;
|
|
45414
45613
|
var DEFAULT_MCP_TRACE_MAX_BYTES = 256 * 1024;
|
|
45415
45614
|
var DEFAULT_MCP_TRACE_MAX_EVENTS = 1e4;
|
|
@@ -45472,14 +45671,14 @@ var McpTraceWriter = class {
|
|
|
45472
45671
|
this.options = options;
|
|
45473
45672
|
this.maxBytes = boundedPositiveInteger(options.maxBytes, DEFAULT_MCP_TRACE_MAX_BYTES);
|
|
45474
45673
|
this.maxEvents = boundedPositiveInteger(options.maxEvents, DEFAULT_MCP_TRACE_MAX_EVENTS);
|
|
45475
|
-
this.append = options.appendFile ?? (async (
|
|
45476
|
-
await appendFile3(
|
|
45674
|
+
this.append = options.appendFile ?? (async (path8, data, appendOptions) => {
|
|
45675
|
+
await appendFile3(path8, data, appendOptions);
|
|
45477
45676
|
});
|
|
45478
|
-
this.resetFile = options.writeFile ?? (async (
|
|
45479
|
-
await writeFile10(
|
|
45677
|
+
this.resetFile = options.writeFile ?? (async (path8, data, writeOptions) => {
|
|
45678
|
+
await writeFile10(path8, data, writeOptions);
|
|
45480
45679
|
});
|
|
45481
|
-
this.makeDirectory = options.mkdir ?? (async (
|
|
45482
|
-
await mkdir18(
|
|
45680
|
+
this.makeDirectory = options.mkdir ?? (async (path8) => {
|
|
45681
|
+
await mkdir18(path8, { recursive: true });
|
|
45483
45682
|
return void 0;
|
|
45484
45683
|
});
|
|
45485
45684
|
this.fileReady = this.makeDirectory(dirname14(this.options.filePath), { recursive: true }).then(() => this.resetFile(this.options.filePath, "", { encoding: "utf8" })).catch(() => {
|
|
@@ -45541,7 +45740,7 @@ var McpTraceWriter = class {
|
|
|
45541
45740
|
function createMcpTraceWriter(sessionCwd, settings2 = {}, randomSuffix = Math.random().toString(36).slice(2, 10)) {
|
|
45542
45741
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
45543
45742
|
const configuredPath = settings2.file;
|
|
45544
|
-
const filePath = configuredPath ? isAbsolute2(configuredPath) ? configuredPath :
|
|
45743
|
+
const filePath = configuredPath ? isAbsolute2(configuredPath) ? configuredPath : resolve4(sessionCwd ?? process.cwd(), configuredPath) : resolve4(sessionCwd ?? process.cwd(), ".pi", "mcp-traces", `mcp-${timestamp}-${randomSuffix}.jsonl`);
|
|
45545
45744
|
return new McpTraceWriter({
|
|
45546
45745
|
filePath,
|
|
45547
45746
|
...settings2.maxBytes !== void 0 ? { maxBytes: settings2.maxBytes } : {},
|
|
@@ -45756,7 +45955,7 @@ function resolvedCommand(config) {
|
|
|
45756
45955
|
async function invokeRequestHeadersCommand(config, envelope, signal) {
|
|
45757
45956
|
const resolved = resolvedCommand(config);
|
|
45758
45957
|
if (USE_PROCESS_GROUP) assertPosixProcessDiscoveryAvailable();
|
|
45759
|
-
return new Promise((
|
|
45958
|
+
return new Promise((resolve8, reject) => {
|
|
45760
45959
|
let stdout = Buffer.alloc(0);
|
|
45761
45960
|
let settled = false;
|
|
45762
45961
|
const cleanupToken = randomUUID8();
|
|
@@ -45785,7 +45984,7 @@ async function invokeRequestHeadersCommand(config, envelope, signal) {
|
|
|
45785
45984
|
if (descendantTracker) clearInterval(descendantTracker);
|
|
45786
45985
|
signal.removeEventListener("abort", abort);
|
|
45787
45986
|
if (result.status === "error") reject(result.error);
|
|
45788
|
-
else
|
|
45987
|
+
else resolve8(result.headers);
|
|
45789
45988
|
};
|
|
45790
45989
|
const finishAfterKill = (result) => {
|
|
45791
45990
|
try {
|
|
@@ -46407,7 +46606,7 @@ var McpServerManager = class {
|
|
|
46407
46606
|
let args = (definition.args ?? []).map((argument) => interpolateEnvVars(argument));
|
|
46408
46607
|
const cwd = resolveConfigPath(definition.cwd) ?? this.defaultCwd;
|
|
46409
46608
|
if (cwd !== void 0) {
|
|
46410
|
-
const cwdStats =
|
|
46609
|
+
const cwdStats = statSync3(cwd, { throwIfNoEntry: false });
|
|
46411
46610
|
if (!cwdStats) throw new Error(`MCP server "${name}" configured cwd does not exist: "${cwd}"`);
|
|
46412
46611
|
if (!cwdStats.isDirectory()) throw new Error(`MCP server "${name}" configured cwd is not a directory: "${cwd}"`);
|
|
46413
46612
|
}
|
|
@@ -48618,10 +48817,10 @@ function getOnboardingStatePath() {
|
|
|
48618
48817
|
return getAgentPath("mcp-onboarding.json");
|
|
48619
48818
|
}
|
|
48620
48819
|
function loadOnboardingState() {
|
|
48621
|
-
const
|
|
48622
|
-
if (!existsSync14(
|
|
48820
|
+
const path8 = getOnboardingStatePath();
|
|
48821
|
+
if (!existsSync14(path8)) return { ...DEFAULT_STATE2 };
|
|
48623
48822
|
try {
|
|
48624
|
-
const raw = JSON.parse(readFileSync6(
|
|
48823
|
+
const raw = JSON.parse(readFileSync6(path8, "utf-8"));
|
|
48625
48824
|
if (!raw || typeof raw !== "object") return { ...DEFAULT_STATE2 };
|
|
48626
48825
|
return {
|
|
48627
48826
|
version: 1,
|
|
@@ -48634,12 +48833,12 @@ function loadOnboardingState() {
|
|
|
48634
48833
|
}
|
|
48635
48834
|
}
|
|
48636
48835
|
function saveOnboardingState(state) {
|
|
48637
|
-
const
|
|
48638
|
-
mkdirSync3(dirname15(
|
|
48639
|
-
const tmpPath = `${
|
|
48836
|
+
const path8 = getOnboardingStatePath();
|
|
48837
|
+
mkdirSync3(dirname15(path8), { recursive: true });
|
|
48838
|
+
const tmpPath = `${path8}.${process.pid}.tmp`;
|
|
48640
48839
|
writeFileSync2(tmpPath, `${JSON.stringify(state, null, 2)}
|
|
48641
48840
|
`, "utf-8");
|
|
48642
|
-
renameSync2(tmpPath,
|
|
48841
|
+
renameSync2(tmpPath, path8);
|
|
48643
48842
|
}
|
|
48644
48843
|
function updateOnboardingState(updater) {
|
|
48645
48844
|
const next = updater(loadOnboardingState());
|
|
@@ -49052,23 +49251,23 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
|
|
|
49052
49251
|
return result;
|
|
49053
49252
|
},
|
|
49054
49253
|
scaffoldConfig: async (target) => {
|
|
49055
|
-
const
|
|
49254
|
+
const path8 = writeStarterSharedConfig(target, ctx.cwd);
|
|
49056
49255
|
configChanged = true;
|
|
49057
|
-
return { path:
|
|
49256
|
+
return { path: path8 };
|
|
49058
49257
|
},
|
|
49059
49258
|
addRepoPrompt: async (target) => {
|
|
49060
49259
|
const repoPrompt = getMcpDiscoverySummary(configOverridePath, ctx.cwd, options).repoPrompt;
|
|
49061
49260
|
if (!repoPrompt.entry || !repoPrompt.targetPath || !repoPrompt.serverName) {
|
|
49062
49261
|
throw new Error("RepoPrompt is not available to add from this setup screen.");
|
|
49063
49262
|
}
|
|
49064
|
-
const
|
|
49263
|
+
const path8 = writeSharedServerEntry(getSharedConfigPath(target, ctx.cwd), repoPrompt.serverName, repoPrompt.entry);
|
|
49065
49264
|
configChanged = true;
|
|
49066
|
-
return { path:
|
|
49265
|
+
return { path: path8, serverName: repoPrompt.serverName };
|
|
49067
49266
|
},
|
|
49068
49267
|
addKnownServer: async (preset, target) => {
|
|
49069
|
-
const
|
|
49268
|
+
const path8 = writeSharedServerEntry(getSharedConfigPath(target, ctx.cwd), preset.id, preset.entry);
|
|
49070
49269
|
configChanged = true;
|
|
49071
|
-
return { path:
|
|
49270
|
+
return { path: path8, serverName: preset.name };
|
|
49072
49271
|
},
|
|
49073
49272
|
openPath: async (targetPath) => {
|
|
49074
49273
|
await openPath(pi, targetPath);
|
|
@@ -49077,12 +49276,12 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
|
|
|
49077
49276
|
markSetupCompleted(discovery.fingerprint);
|
|
49078
49277
|
}
|
|
49079
49278
|
};
|
|
49080
|
-
return new Promise((
|
|
49279
|
+
return new Promise((resolve8) => {
|
|
49081
49280
|
ctx.ui.custom(
|
|
49082
49281
|
(tui, _theme, keybindings, done) => {
|
|
49083
49282
|
return createMcpSetupPanel(discovery, callbacks, { mode, onboardingState, keybindings }, tui, () => {
|
|
49084
49283
|
done(void 0);
|
|
49085
|
-
|
|
49284
|
+
resolve8({ configChanged });
|
|
49086
49285
|
});
|
|
49087
49286
|
},
|
|
49088
49287
|
{ overlay: true, overlayOptions: { anchor: "center", width: 92 } }
|
|
@@ -49164,7 +49363,7 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
|
|
|
49164
49363
|
const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
|
|
49165
49364
|
const { createMcpPanel } = await import("./mcp-panel-IBIVWX27.js");
|
|
49166
49365
|
let configChanged = false;
|
|
49167
|
-
await new Promise((
|
|
49366
|
+
await new Promise((resolve8) => {
|
|
49168
49367
|
ctx.ui.custom(
|
|
49169
49368
|
(tui, _theme, keybindings, done) => {
|
|
49170
49369
|
return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, (result) => {
|
|
@@ -49187,13 +49386,13 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
|
|
|
49187
49386
|
ctx.ui.notify("Direct tools updated for this session.", "info");
|
|
49188
49387
|
}
|
|
49189
49388
|
done(void 0);
|
|
49190
|
-
|
|
49389
|
+
resolve8();
|
|
49191
49390
|
})().catch((error) => {
|
|
49192
49391
|
const message = error instanceof Error ? error.message : String(error);
|
|
49193
49392
|
ctx.ui.notify(`Direct tools updated, but live refresh failed: ${message}`, "error");
|
|
49194
49393
|
configChanged = true;
|
|
49195
49394
|
done(void 0);
|
|
49196
|
-
|
|
49395
|
+
resolve8();
|
|
49197
49396
|
});
|
|
49198
49397
|
}, { noticeLines, keybindings });
|
|
49199
49398
|
},
|
|
@@ -49235,12 +49434,12 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
|
|
|
49235
49434
|
let overlayHandle;
|
|
49236
49435
|
const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
|
|
49237
49436
|
const { createMcpPanel } = await import("./mcp-panel-IBIVWX27.js");
|
|
49238
|
-
await new Promise((
|
|
49437
|
+
await new Promise((resolve8) => {
|
|
49239
49438
|
ctx.ui.custom(
|
|
49240
49439
|
(tui, _theme, keybindings, done) => {
|
|
49241
49440
|
return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, () => {
|
|
49242
49441
|
done(void 0);
|
|
49243
|
-
|
|
49442
|
+
resolve8();
|
|
49244
49443
|
}, {
|
|
49245
49444
|
authOnly: true,
|
|
49246
49445
|
keybindings,
|
|
@@ -49464,7 +49663,7 @@ function stringifyStructuredContent(value) {
|
|
|
49464
49663
|
|
|
49465
49664
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-output-guard.ts
|
|
49466
49665
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
49467
|
-
import { mkdtemp, rm as
|
|
49666
|
+
import { mkdtemp, rm as rm4, writeFile as writeFile11 } from "fs/promises";
|
|
49468
49667
|
import { tmpdir as tmpdir2 } from "os";
|
|
49469
49668
|
import { dirname as dirname16, join as join28 } from "path";
|
|
49470
49669
|
var DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
|
|
@@ -49775,16 +49974,16 @@ function serializedObjectEntryBytes(key, value, hasPrevious) {
|
|
|
49775
49974
|
async function saveArtifact(kind, text) {
|
|
49776
49975
|
try {
|
|
49777
49976
|
const dir = await mkdtemp(join28(tmpdir2(), "pi-mcp-output-"));
|
|
49778
|
-
const
|
|
49779
|
-
await writeFile11(
|
|
49780
|
-
return { path:
|
|
49977
|
+
const path8 = join28(dir, `${kind}-${randomBytes4(4).toString("hex")}.txt`);
|
|
49978
|
+
await writeFile11(path8, text, { encoding: "utf8", mode: 384 });
|
|
49979
|
+
return { path: path8 };
|
|
49781
49980
|
} catch (error) {
|
|
49782
49981
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
49783
49982
|
}
|
|
49784
49983
|
}
|
|
49785
|
-
async function discardArtifact(
|
|
49984
|
+
async function discardArtifact(path8) {
|
|
49786
49985
|
try {
|
|
49787
|
-
await
|
|
49986
|
+
await rm4(dirname16(path8), { recursive: true, force: true });
|
|
49788
49987
|
} catch {
|
|
49789
49988
|
}
|
|
49790
49989
|
}
|
|
@@ -49828,9 +50027,9 @@ import { randomUUID as randomUUID11 } from "crypto";
|
|
|
49828
50027
|
import net from "net";
|
|
49829
50028
|
|
|
49830
50029
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ui-server.ts
|
|
49831
|
-
import
|
|
50030
|
+
import http2 from "http";
|
|
49832
50031
|
import fs7 from "fs/promises";
|
|
49833
|
-
import
|
|
50032
|
+
import path7 from "path";
|
|
49834
50033
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
49835
50034
|
|
|
49836
50035
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/host-html-template.ts
|
|
@@ -50843,7 +51042,7 @@ data: ${JSON.stringify(payload)}
|
|
|
50843
51042
|
options.onComplete?.(reason);
|
|
50844
51043
|
scheduleListenerClose();
|
|
50845
51044
|
};
|
|
50846
|
-
const hostServer =
|
|
51045
|
+
const hostServer = http2.createServer(async (req, res) => {
|
|
50847
51046
|
try {
|
|
50848
51047
|
const method = req.method || "GET";
|
|
50849
51048
|
const hostHeader = req.headers.host;
|
|
@@ -50927,7 +51126,7 @@ data: ${JSON.stringify(payload)}
|
|
|
50927
51126
|
return;
|
|
50928
51127
|
}
|
|
50929
51128
|
if (method === "GET" && url3.pathname === "/app-bridge.bundle.js") {
|
|
50930
|
-
const bundlePath =
|
|
51129
|
+
const bundlePath = path7.join(import.meta.dirname, "app-bridge.bundle.js");
|
|
50931
51130
|
try {
|
|
50932
51131
|
const content = await fs7.readFile(bundlePath, "utf-8");
|
|
50933
51132
|
res.writeHead(200, {
|
|
@@ -51187,11 +51386,11 @@ data: ${JSON.stringify(payload)}
|
|
|
51187
51386
|
markCompleted("stale");
|
|
51188
51387
|
}, WATCHDOG_INTERVAL_MS);
|
|
51189
51388
|
watchdog.unref();
|
|
51190
|
-
return new Promise((
|
|
51389
|
+
return new Promise((resolve8, reject) => {
|
|
51191
51390
|
const candidates = resolvePortCandidates(options.port);
|
|
51192
51391
|
let candidateIndex = 0;
|
|
51193
51392
|
const startSandboxProxy = (parentOrigin) => {
|
|
51194
|
-
const proxy =
|
|
51393
|
+
const proxy = http2.createServer((req, res) => {
|
|
51195
51394
|
try {
|
|
51196
51395
|
const method = req.method || "GET";
|
|
51197
51396
|
const hostHeader = req.headers.host;
|
|
@@ -51324,7 +51523,7 @@ data: ${JSON.stringify(payload)}
|
|
|
51324
51523
|
getSessionMessages: () => ({ ...sessionMessages }),
|
|
51325
51524
|
getStreamSummary: () => streamSummary ? { ...streamSummary, phases: [...streamSummary.phases] } : void 0
|
|
51326
51525
|
};
|
|
51327
|
-
|
|
51526
|
+
resolve8(handle);
|
|
51328
51527
|
}).catch((error) => {
|
|
51329
51528
|
log.error("Failed to start sandbox proxy", error instanceof Error ? error : void 0);
|
|
51330
51529
|
closeListeners();
|
|
@@ -51349,7 +51548,7 @@ async function parseBody(req, res) {
|
|
|
51349
51548
|
}
|
|
51350
51549
|
}
|
|
51351
51550
|
function readBody(req) {
|
|
51352
|
-
return new Promise((
|
|
51551
|
+
return new Promise((resolve8, reject) => {
|
|
51353
51552
|
let size = 0;
|
|
51354
51553
|
const chunks = [];
|
|
51355
51554
|
req.on("data", (chunk) => {
|
|
@@ -51363,7 +51562,7 @@ function readBody(req) {
|
|
|
51363
51562
|
});
|
|
51364
51563
|
req.on("end", () => {
|
|
51365
51564
|
try {
|
|
51366
|
-
|
|
51565
|
+
resolve8(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
51367
51566
|
} catch (error) {
|
|
51368
51567
|
reject(error);
|
|
51369
51568
|
}
|
|
@@ -51544,22 +51743,22 @@ function isRemoteSession() {
|
|
|
51544
51743
|
return Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY);
|
|
51545
51744
|
}
|
|
51546
51745
|
function hasActiveRemoteLogin() {
|
|
51547
|
-
return new Promise((
|
|
51746
|
+
return new Promise((resolve8) => {
|
|
51548
51747
|
execFile6("who", { encoding: "utf8", timeout: 2e3 }, (error, out) => {
|
|
51549
51748
|
if (error) {
|
|
51550
|
-
|
|
51749
|
+
resolve8(false);
|
|
51551
51750
|
return;
|
|
51552
51751
|
}
|
|
51553
|
-
|
|
51752
|
+
resolve8(/\(.+\)\s*$/m.test(out));
|
|
51554
51753
|
});
|
|
51555
51754
|
});
|
|
51556
51755
|
}
|
|
51557
51756
|
function probeMoshiGateway() {
|
|
51558
|
-
return new Promise((
|
|
51757
|
+
return new Promise((resolve8) => {
|
|
51559
51758
|
const socket = net.connect({ host: "127.0.0.1", port: 24543 });
|
|
51560
51759
|
const done = (ok) => {
|
|
51561
51760
|
socket.destroy();
|
|
51562
|
-
|
|
51761
|
+
resolve8(ok);
|
|
51563
51762
|
};
|
|
51564
51763
|
socket.setTimeout(300);
|
|
51565
51764
|
socket.once("connect", () => done(true));
|
|
@@ -57875,22 +58074,22 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57875
58074
|
durationMs: "error" in operation && operation.error === "incomplete" ? Math.max(0, Date.now() - startedAt) : operation.durationMs
|
|
57876
58075
|
}));
|
|
57877
58076
|
let callsSnapshot;
|
|
57878
|
-
const callTool = async (
|
|
58077
|
+
const callTool = async (path8, args) => {
|
|
57879
58078
|
const startedAt = Date.now();
|
|
57880
|
-
const index = calls.push({ operation: "call", path:
|
|
57881
|
-
const result = await executeCall(state,
|
|
58079
|
+
const index = calls.push({ operation: "call", path: path8, ok: false, error: "incomplete", durationMs: 0, startedAt }) - 1;
|
|
58080
|
+
const result = await executeCall(state, path8, args, void 0, getPiTools, callSignal, "script");
|
|
57882
58081
|
const details = result.details;
|
|
57883
58082
|
if (details.error !== void 0) {
|
|
57884
58083
|
const errorCode2 = String(details.error);
|
|
57885
58084
|
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:
|
|
58085
|
+
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);
|
|
58086
|
+
calls[index] = { operation: "call", path: path8, ok: false, error: errorCode2, durationMs: Date.now() - startedAt, startedAt };
|
|
57888
58087
|
return {
|
|
57889
58088
|
ok: false,
|
|
57890
58089
|
error: { code: errorCode2, message }
|
|
57891
58090
|
};
|
|
57892
58091
|
}
|
|
57893
|
-
calls[index] = { operation: "call", path:
|
|
58092
|
+
calls[index] = { operation: "call", path: path8, ok: true, durationMs: Date.now() - startedAt, startedAt };
|
|
57894
58093
|
return {
|
|
57895
58094
|
ok: true,
|
|
57896
58095
|
data: details.mcpResult !== void 0 ? details.mcpResult : textFromContent(result.content)
|
|
@@ -57927,12 +58126,12 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57927
58126
|
};
|
|
57928
58127
|
const describeTool = (input) => {
|
|
57929
58128
|
const startedAt = Date.now();
|
|
57930
|
-
const
|
|
58129
|
+
const path8 = typeof input?.path === "string" ? input.path : "";
|
|
57931
58130
|
let error;
|
|
57932
58131
|
try {
|
|
57933
58132
|
for (const [server2, metadata] of state.toolMetadata) {
|
|
57934
58133
|
if (isServerInActiveFailureBackoff(state, server2)) continue;
|
|
57935
|
-
const tool = findToolByName(metadata,
|
|
58134
|
+
const tool = findToolByName(metadata, path8);
|
|
57936
58135
|
if (!tool) continue;
|
|
57937
58136
|
const inputTypeScript = tool.inputSchema ? renderTsShape(tool.inputSchema) ?? formatSchema(tool.inputSchema) : null;
|
|
57938
58137
|
return {
|
|
@@ -57943,13 +58142,13 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57943
58142
|
...inputTypeScript ? { inputTypeScript } : {}
|
|
57944
58143
|
};
|
|
57945
58144
|
}
|
|
57946
|
-
const suggestions =
|
|
58145
|
+
const suggestions = path8 ? rankSuggestions(state, path8, 5) : [];
|
|
57947
58146
|
error = "tool_not_found";
|
|
57948
58147
|
return {
|
|
57949
|
-
path:
|
|
58148
|
+
path: path8,
|
|
57950
58149
|
error: {
|
|
57951
58150
|
code: "tool_not_found",
|
|
57952
|
-
message: `Tool not found: ${
|
|
58151
|
+
message: `Tool not found: ${path8}`,
|
|
57953
58152
|
suggestions
|
|
57954
58153
|
}
|
|
57955
58154
|
};
|
|
@@ -57957,7 +58156,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57957
58156
|
error = caught;
|
|
57958
58157
|
throw caught;
|
|
57959
58158
|
} finally {
|
|
57960
|
-
calls.push(error === void 0 ? { operation: "describe", path:
|
|
58159
|
+
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
58160
|
}
|
|
57962
58161
|
};
|
|
57963
58162
|
let worker;
|
|
@@ -57979,7 +58178,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57979
58178
|
trackUnmanagedFds: false
|
|
57980
58179
|
});
|
|
57981
58180
|
const activeWorker = worker;
|
|
57982
|
-
const execution = new Promise((
|
|
58181
|
+
const execution = new Promise((resolve8, reject) => {
|
|
57983
58182
|
let completed = false;
|
|
57984
58183
|
activeWorker.on("message", (value) => {
|
|
57985
58184
|
const message = parseWorkerMessage(value);
|
|
@@ -57991,7 +58190,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57991
58190
|
if (message.type === "done") {
|
|
57992
58191
|
completed = true;
|
|
57993
58192
|
if ("returnBlock" in message) output.push(toContentBlock(message.returnBlock));
|
|
57994
|
-
|
|
58193
|
+
resolve8();
|
|
57995
58194
|
return;
|
|
57996
58195
|
}
|
|
57997
58196
|
if (message.type === "error") {
|
|
@@ -58270,8 +58469,8 @@ async function awaitWithTimeout(promise, timeoutMs) {
|
|
|
58270
58469
|
try {
|
|
58271
58470
|
return await Promise.race([
|
|
58272
58471
|
promise,
|
|
58273
|
-
new Promise((
|
|
58274
|
-
timer = setTimeout(() =>
|
|
58472
|
+
new Promise((resolve8) => {
|
|
58473
|
+
timer = setTimeout(() => resolve8(INIT_WAIT_TIMED_OUT), timeoutMs);
|
|
58275
58474
|
timer.unref?.();
|
|
58276
58475
|
})
|
|
58277
58476
|
]);
|
|
@@ -59649,7 +59848,7 @@ import {
|
|
|
59649
59848
|
rename as rename4,
|
|
59650
59849
|
unlink as unlink3
|
|
59651
59850
|
} from "fs/promises";
|
|
59652
|
-
import { existsSync as existsSync16, readFileSync as readFileSync7, readdirSync as
|
|
59851
|
+
import { existsSync as existsSync16, readFileSync as readFileSync7, readdirSync as readdirSync3 } from "fs";
|
|
59653
59852
|
import { join as join31 } from "path";
|
|
59654
59853
|
var MAX_FAILED_RECORDS = 500;
|
|
59655
59854
|
var FLUSH_DEBOUNCE_MS = 15e3;
|
|
@@ -59698,7 +59897,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
59698
59897
|
}
|
|
59699
59898
|
readStoredRecords() {
|
|
59700
59899
|
if (!existsSync16(ENGINE_DIR2)) return [];
|
|
59701
|
-
return
|
|
59900
|
+
return readdirSync3(ENGINE_DIR2, { withFileTypes: true }).filter((entry) => entry.isFile() && this.storageNames.some(
|
|
59702
59901
|
(storageName) => entry.name === `${storageName}.jsonl` || entry.name.startsWith(`${storageName}.`) && (entry.name.endsWith(".jsonl") || entry.name.endsWith(`.jsonl${UPLOADED_SUFFIX}`))
|
|
59703
59902
|
)).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync7(join31(ENGINE_DIR2, name), "utf-8"))).map((record3) => {
|
|
59704
59903
|
const recordId = this.options.getRecordId?.(record3);
|
|
@@ -60630,11 +60829,11 @@ import { join as join32 } from "path";
|
|
|
60630
60829
|
|
|
60631
60830
|
// src/utils/contained-file.ts
|
|
60632
60831
|
import { realpath, stat as stat3 } from "fs/promises";
|
|
60633
|
-
import { resolve as
|
|
60832
|
+
import { resolve as resolve5 } from "path";
|
|
60634
60833
|
async function resolveContainedFile(root, relativePath) {
|
|
60635
60834
|
try {
|
|
60636
60835
|
const [fullPath, resolvedRoot] = await Promise.all([
|
|
60637
|
-
realpath(
|
|
60836
|
+
realpath(resolve5(root, relativePath)),
|
|
60638
60837
|
realpath(root)
|
|
60639
60838
|
]);
|
|
60640
60839
|
const fileStat = await stat3(fullPath);
|
|
@@ -60803,7 +61002,7 @@ function isReconcileCanvasItemsResponse(value) {
|
|
|
60803
61002
|
}
|
|
60804
61003
|
async function withCanvasUploadSlot(operation) {
|
|
60805
61004
|
if (activeCanvasUploads >= MAX_CONCURRENT_CANVAS_UPLOADS) {
|
|
60806
|
-
await new Promise((
|
|
61005
|
+
await new Promise((resolve8) => pendingCanvasUploads.push(resolve8));
|
|
60807
61006
|
} else {
|
|
60808
61007
|
activeCanvasUploads++;
|
|
60809
61008
|
}
|
|
@@ -61129,13 +61328,13 @@ function runBeforeDeadline(operation, deadline) {
|
|
|
61129
61328
|
const timeoutMs = deadline - Date.now();
|
|
61130
61329
|
if (timeoutMs <= 0) return Promise.reject(new DOMException("engine log flush deadline exceeded", "TimeoutError"));
|
|
61131
61330
|
const signal = AbortSignal.timeout(timeoutMs);
|
|
61132
|
-
return new Promise((
|
|
61331
|
+
return new Promise((resolve8, reject) => {
|
|
61133
61332
|
const onAbort = () => reject(signal.reason);
|
|
61134
61333
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
61135
61334
|
operation(signal).then(
|
|
61136
61335
|
(value) => {
|
|
61137
61336
|
signal.removeEventListener("abort", onAbort);
|
|
61138
|
-
|
|
61337
|
+
resolve8(value);
|
|
61139
61338
|
},
|
|
61140
61339
|
(error) => {
|
|
61141
61340
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -61170,10 +61369,10 @@ function unansweredRequest(blocks) {
|
|
|
61170
61369
|
const answered = blocks.slice(lastUser + 1).some((block) => block.startsWith("## Agent"));
|
|
61171
61370
|
return answered ? null : lastUserBlockText(blocks);
|
|
61172
61371
|
}
|
|
61173
|
-
async function readHistoryTail(
|
|
61372
|
+
async function readHistoryTail(path8, maxBytes) {
|
|
61174
61373
|
let handle;
|
|
61175
61374
|
try {
|
|
61176
|
-
handle = await open3(
|
|
61375
|
+
handle = await open3(path8, "r");
|
|
61177
61376
|
} catch (error) {
|
|
61178
61377
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return { content: "", truncated: false };
|
|
61179
61378
|
throw error;
|
|
@@ -61546,8 +61745,8 @@ var ChatService = class {
|
|
|
61546
61745
|
if (result.status === "completed") return result;
|
|
61547
61746
|
const remainingMs = timeoutMs === null ? null : timeoutMs - (Date.now() - startedAt);
|
|
61548
61747
|
if (remainingMs !== null && remainingMs <= 0) return { ...result, timedOut: true };
|
|
61549
|
-
await new Promise((
|
|
61550
|
-
|
|
61748
|
+
await new Promise((resolve8) => setTimeout(
|
|
61749
|
+
resolve8,
|
|
61551
61750
|
remainingMs === null ? RELAY_SUBAGENT_POLL_INTERVAL_MS : Math.min(RELAY_SUBAGENT_POLL_INTERVAL_MS, remainingMs)
|
|
61552
61751
|
));
|
|
61553
61752
|
}
|
|
@@ -61964,9 +62163,9 @@ var ChatService = class {
|
|
|
61964
62163
|
historyPath,
|
|
61965
62164
|
`${historyPath}.pages.jsonl`,
|
|
61966
62165
|
`${historyPath}.pages.index.json`
|
|
61967
|
-
].map((
|
|
61968
|
-
await
|
|
61969
|
-
await
|
|
62166
|
+
].map((path8) => rm5(path8, { force: true })));
|
|
62167
|
+
await rm5(chatMessageSendersFilePath(persisted.id), { force: true });
|
|
62168
|
+
await rm5(join37(FORKS_DIR, persisted.id), { recursive: true, force: true });
|
|
61970
62169
|
}
|
|
61971
62170
|
/** Resolves once the target chat exists; the handoff and its first turn run in the background. */
|
|
61972
62171
|
async forkChat(sourceChatId, request, trigger = "manual", reason) {
|
|
@@ -62601,13 +62800,13 @@ var ChatService = class {
|
|
|
62601
62800
|
async observeCurrentBranches(chat) {
|
|
62602
62801
|
try {
|
|
62603
62802
|
const snapshot = await gitService.snapshotCurrentBranches();
|
|
62604
|
-
for (const [repoName,
|
|
62803
|
+
for (const [repoName, branches] of snapshot) {
|
|
62605
62804
|
let observed = chat.observedBranchesByRepo.get(repoName);
|
|
62606
62805
|
if (!observed) {
|
|
62607
62806
|
observed = /* @__PURE__ */ new Set();
|
|
62608
62807
|
chat.observedBranchesByRepo.set(repoName, observed);
|
|
62609
62808
|
}
|
|
62610
|
-
observed.add(branch);
|
|
62809
|
+
for (const branch of branches) observed.add(branch);
|
|
62611
62810
|
}
|
|
62612
62811
|
} catch {
|
|
62613
62812
|
}
|
|
@@ -62797,10 +62996,10 @@ var LanguageServerService = class {
|
|
|
62797
62996
|
const uri = "targetUri" in location ? location.targetUri : location.uri;
|
|
62798
62997
|
const range = "targetSelectionRange" in location ? location.targetSelectionRange : location.range;
|
|
62799
62998
|
const absolutePath = fileURLToPath6(uri);
|
|
62800
|
-
const
|
|
62801
|
-
if (
|
|
62999
|
+
const path8 = relative2(repoPath, absolutePath);
|
|
63000
|
+
if (path8.startsWith("..")) return [];
|
|
62802
63001
|
const preview = readFileSync8(absolutePath, "utf8").split("\n")[range.start.line]?.trim() ?? "";
|
|
62803
|
-
return [{ repoName, path:
|
|
63002
|
+
return [{ repoName, path: path8, line: range.start.line + 1, character: range.start.character, endCharacter: range.end.character, preview }];
|
|
62804
63003
|
});
|
|
62805
63004
|
return { symbol: "", detail: null, documentation: null, locations, provider: "language-server" };
|
|
62806
63005
|
} catch {
|
|
@@ -62852,7 +63051,7 @@ function isBinaryExtension(filePath) {
|
|
|
62852
63051
|
return classifyCanvasFilename(filePath).kind === "image" || binaryExts.has(ext);
|
|
62853
63052
|
}
|
|
62854
63053
|
function execGitAsync(args, cwd, timeoutMs) {
|
|
62855
|
-
return new Promise((
|
|
63054
|
+
return new Promise((resolve8, reject) => {
|
|
62856
63055
|
const child = execFile7("git", args, {
|
|
62857
63056
|
cwd,
|
|
62858
63057
|
encoding: "utf-8",
|
|
@@ -62862,7 +63061,7 @@ function execGitAsync(args, cwd, timeoutMs) {
|
|
|
62862
63061
|
if (error) {
|
|
62863
63062
|
reject(error);
|
|
62864
63063
|
} else {
|
|
62865
|
-
|
|
63064
|
+
resolve8(stdout);
|
|
62866
63065
|
}
|
|
62867
63066
|
});
|
|
62868
63067
|
child.stdin?.end();
|
|
@@ -63118,7 +63317,7 @@ var RepoFileService = class {
|
|
|
63118
63317
|
import { Hono } from "hono";
|
|
63119
63318
|
import { z as z6 } from "zod";
|
|
63120
63319
|
import { readdir as readdir12, stat as stat7, readFile as readFile26 } from "fs/promises";
|
|
63121
|
-
import { join as join41, resolve as
|
|
63320
|
+
import { join as join41, resolve as resolve6 } from "path";
|
|
63122
63321
|
|
|
63123
63322
|
// src/services/warm-hooks-service.ts
|
|
63124
63323
|
import { spawn as spawn10 } from "child_process";
|
|
@@ -63295,7 +63494,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
63295
63494
|
let bufferExceeded = false;
|
|
63296
63495
|
params.onChunk(`$ ${params.label}
|
|
63297
63496
|
`);
|
|
63298
|
-
return new Promise((
|
|
63497
|
+
return new Promise((resolve8) => {
|
|
63299
63498
|
const proc = spawn10("bash", ["-lc", params.content], {
|
|
63300
63499
|
cwd: params.cwd,
|
|
63301
63500
|
env: process.env,
|
|
@@ -63328,7 +63527,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
63328
63527
|
proc.on("close", (code) => {
|
|
63329
63528
|
clearTimeout(timer);
|
|
63330
63529
|
const output = [`$ ${params.label}`, ...outputParts].join("");
|
|
63331
|
-
|
|
63530
|
+
resolve8({
|
|
63332
63531
|
exitCode: bufferExceeded ? 1 : code ?? 1,
|
|
63333
63532
|
output,
|
|
63334
63533
|
timedOut: killed && !bufferExceeded
|
|
@@ -63338,7 +63537,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
63338
63537
|
clearTimeout(timer);
|
|
63339
63538
|
const output = [`$ ${params.label}
|
|
63340
63539
|
`, ...outputParts, err.message].join("");
|
|
63341
|
-
|
|
63540
|
+
resolve8({
|
|
63342
63541
|
exitCode: 1,
|
|
63343
63542
|
output,
|
|
63344
63543
|
timedOut: false
|
|
@@ -63698,8 +63897,19 @@ function createJsonEventStream(run, onError) {
|
|
|
63698
63897
|
function createV1Routes(deps) {
|
|
63699
63898
|
const app2 = new Hono();
|
|
63700
63899
|
app2.post("/pull-requests/check", async (c) => {
|
|
63701
|
-
|
|
63702
|
-
|
|
63900
|
+
if (c.req.header("content-type")?.includes("application/json")) {
|
|
63901
|
+
const result = z6.object({
|
|
63902
|
+
toolName: z6.string(),
|
|
63903
|
+
toolInput: z6.unknown(),
|
|
63904
|
+
output: z6.unknown(),
|
|
63905
|
+
success: z6.boolean()
|
|
63906
|
+
}).safeParse(await c.req.json().catch(() => null));
|
|
63907
|
+
if (!result.success) return c.json({ error: "Invalid PR tool result" }, 400);
|
|
63908
|
+
await pullRequestCheckService.onToolResult(result.data);
|
|
63909
|
+
} else {
|
|
63910
|
+
pullRequestCheckService.check().catch(() => {
|
|
63911
|
+
});
|
|
63912
|
+
}
|
|
63703
63913
|
return c.json({ accepted: true }, 202);
|
|
63704
63914
|
});
|
|
63705
63915
|
const loadChatHistory = async (c, chatId, page2, failureMessage, unexpectedStatus, legacy = false) => {
|
|
@@ -64182,11 +64392,11 @@ function createV1Routes(deps) {
|
|
|
64182
64392
|
});
|
|
64183
64393
|
app2.get("/repo-files/content", async (c) => {
|
|
64184
64394
|
const repoName = c.req.query("repoName");
|
|
64185
|
-
const
|
|
64186
|
-
if (!repoName || !
|
|
64395
|
+
const path8 = c.req.query("path");
|
|
64396
|
+
if (!repoName || !path8) {
|
|
64187
64397
|
return c.json(jsonError("repoName and path are required"), 400);
|
|
64188
64398
|
}
|
|
64189
|
-
const result = await deps.repoFileService.readFile(repoName,
|
|
64399
|
+
const result = await deps.repoFileService.readFile(repoName, path8);
|
|
64190
64400
|
if (!result) {
|
|
64191
64401
|
return c.json(jsonError("File not found"), 404);
|
|
64192
64402
|
}
|
|
@@ -64194,25 +64404,25 @@ function createV1Routes(deps) {
|
|
|
64194
64404
|
});
|
|
64195
64405
|
app2.put("/repo-files/content", async (c) => {
|
|
64196
64406
|
const repoName = c.req.query("repoName");
|
|
64197
|
-
const
|
|
64198
|
-
if (!repoName || !
|
|
64407
|
+
const path8 = c.req.query("path");
|
|
64408
|
+
if (!repoName || !path8) {
|
|
64199
64409
|
return c.json(jsonError("repoName and path are required"), 400);
|
|
64200
64410
|
}
|
|
64201
64411
|
const body = updateTextFileSchema(MAX_REPO_FILE_CONTENT_BYTES).parse(await c.req.json());
|
|
64202
|
-
const result = await deps.repoFileService.updateFile(repoName,
|
|
64412
|
+
const result = await deps.repoFileService.updateFile(repoName, path8, body.content, body.expectedRevision);
|
|
64203
64413
|
if (!result) return c.json(jsonError("File is not editable"), 400);
|
|
64204
64414
|
return c.json(result);
|
|
64205
64415
|
});
|
|
64206
64416
|
app2.get("/repo-files/symbol", async (c) => {
|
|
64207
64417
|
const repoName = c.req.query("repoName");
|
|
64208
|
-
const
|
|
64418
|
+
const path8 = c.req.query("path");
|
|
64209
64419
|
const action = c.req.query("action");
|
|
64210
64420
|
const line = Number(c.req.query("line"));
|
|
64211
64421
|
const character = Number(c.req.query("character"));
|
|
64212
|
-
if (!repoName || !
|
|
64422
|
+
if (!repoName || !path8 || action !== "hover" && action !== "definition" && action !== "references" || !Number.isInteger(line) || !Number.isInteger(character)) {
|
|
64213
64423
|
return c.json(jsonError("Invalid symbol request"), 400);
|
|
64214
64424
|
}
|
|
64215
|
-
const result = await deps.repoFileService.inspectSymbol(repoName,
|
|
64425
|
+
const result = await deps.repoFileService.inspectSymbol(repoName, path8, line, character, action);
|
|
64216
64426
|
if (!result) return c.json(jsonError("Symbol not found"), 404);
|
|
64217
64427
|
return c.json(result);
|
|
64218
64428
|
});
|
|
@@ -64622,8 +64832,8 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
64622
64832
|
if (!isValidEngineLogSessionId(sessionId)) {
|
|
64623
64833
|
return c.json(jsonError("Invalid session ID"), 400);
|
|
64624
64834
|
}
|
|
64625
|
-
const filePath =
|
|
64626
|
-
if (!filePath.startsWith(
|
|
64835
|
+
const filePath = resolve6(LOG_DIR, `${sessionId}.log`);
|
|
64836
|
+
if (!filePath.startsWith(resolve6(LOG_DIR))) {
|
|
64627
64837
|
return c.json(jsonError("Invalid session ID"), 400);
|
|
64628
64838
|
}
|
|
64629
64839
|
let content;
|
|
@@ -64700,12 +64910,12 @@ var heartbeatService = new HeartbeatService();
|
|
|
64700
64910
|
|
|
64701
64911
|
// src/services/workspace-sdk-service.ts
|
|
64702
64912
|
import { cp, mkdir as mkdir24 } from "fs/promises";
|
|
64703
|
-
import { dirname as dirname20, resolve as
|
|
64913
|
+
import { dirname as dirname20, resolve as resolve7 } from "path";
|
|
64704
64914
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
64705
64915
|
async function installWorkspaceSdk() {
|
|
64706
|
-
const source =
|
|
64916
|
+
const source = resolve7(dirname20(fileURLToPath7(import.meta.url)), "../../workspace-sdk");
|
|
64707
64917
|
const targets = [
|
|
64708
|
-
|
|
64918
|
+
resolve7(ENGINE_ENV.HOME_DIR, "node_modules/@replicas/sdk"),
|
|
64709
64919
|
"/tmp/node_modules/@replicas/sdk"
|
|
64710
64920
|
];
|
|
64711
64921
|
await Promise.all(targets.map(async (target) => {
|
|
@@ -64720,8 +64930,8 @@ var startupTimings = {};
|
|
|
64720
64930
|
var ENGINE_INIT_GATE_TIMEOUT_MS = 35 * 60 * 1e3;
|
|
64721
64931
|
var resolveEngineReady = () => {
|
|
64722
64932
|
};
|
|
64723
|
-
var engineReadyPromise = new Promise((
|
|
64724
|
-
resolveEngineReady =
|
|
64933
|
+
var engineReadyPromise = new Promise((resolve8) => {
|
|
64934
|
+
resolveEngineReady = resolve8;
|
|
64725
64935
|
});
|
|
64726
64936
|
async function timeStartupStep(name, fn) {
|
|
64727
64937
|
const startedAt = performance.now();
|
|
@@ -64741,7 +64951,7 @@ async function waitForInitializationGate() {
|
|
|
64741
64951
|
if (Date.now() >= deadline) {
|
|
64742
64952
|
throw new Error("Timed out waiting for deferred engine initialization gate");
|
|
64743
64953
|
}
|
|
64744
|
-
await new Promise((
|
|
64954
|
+
await new Promise((resolve8) => setTimeout(resolve8, 25));
|
|
64745
64955
|
}
|
|
64746
64956
|
}
|
|
64747
64957
|
await timeStartupStep("engine_logger_initialize", () => engineLogger.initialize());
|
|
@@ -64773,11 +64983,11 @@ async function checkActiveSSHSessions() {
|
|
|
64773
64983
|
}
|
|
64774
64984
|
}
|
|
64775
64985
|
function checkDesktopReady() {
|
|
64776
|
-
return new Promise((
|
|
64986
|
+
return new Promise((resolve8) => {
|
|
64777
64987
|
const socket = connect({ host: "127.0.0.1", port: DESKTOP_STREAM_PORT });
|
|
64778
64988
|
const done = (ready) => {
|
|
64779
64989
|
socket.destroy();
|
|
64780
|
-
|
|
64990
|
+
resolve8(ready);
|
|
64781
64991
|
};
|
|
64782
64992
|
socket.once("connect", () => done(true));
|
|
64783
64993
|
socket.once("error", () => done(false));
|
|
@@ -64814,7 +65024,7 @@ app.get("/health", async (c) => {
|
|
|
64814
65024
|
if (!engineReady && waitMs > 0) {
|
|
64815
65025
|
await Promise.race([
|
|
64816
65026
|
engineReadyPromise,
|
|
64817
|
-
new Promise((
|
|
65027
|
+
new Promise((resolve8) => setTimeout(resolve8, waitMs))
|
|
64818
65028
|
]);
|
|
64819
65029
|
}
|
|
64820
65030
|
c.header(ENGINE_HEALTH_WAIT_HEADER, "1");
|
|
@@ -64863,7 +65073,8 @@ app.get("/token-refresh/health", async (c) => {
|
|
|
64863
65073
|
gitlab: gitlabTokenManager.getHealthStatus(),
|
|
64864
65074
|
claude: claudeTokenManager.getHealthStatus(),
|
|
64865
65075
|
codex: codexTokenManager.getHealthStatus(),
|
|
64866
|
-
infisical: infisicalTokenManager.getHealthStatus()
|
|
65076
|
+
infisical: infisicalTokenManager.getHealthStatus(),
|
|
65077
|
+
workspaceIdentity: workspaceIdentityTokenManager.getHealthStatus()
|
|
64867
65078
|
});
|
|
64868
65079
|
});
|
|
64869
65080
|
app.post(GITHUB_CREDENTIAL_REFRESH_PATH, async (c) => {
|
|
@@ -65036,6 +65247,8 @@ serve(
|
|
|
65036
65247
|
await claudeTokenManager.start();
|
|
65037
65248
|
await codexTokenManager.start();
|
|
65038
65249
|
await infisicalTokenManager.start();
|
|
65250
|
+
await workspaceIdentityTokenManager.start();
|
|
65251
|
+
createIdentityProxy(() => workspaceIdentityTokenManager.bundle).on("error", (error) => console.error("[identity-proxy] failed to listen:", error)).listen(IDENTITY_PROXY_PORT, "127.0.0.1");
|
|
65039
65252
|
}
|
|
65040
65253
|
const repos = await gitService.listRepos();
|
|
65041
65254
|
await eventService.publish({
|