replicas-engine 0.1.1587 → 0.1.1588
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-47LQ5HGG.js → asp-host-AGBWUQMD.js} +5 -5
- package/dist/src/{chunk-EPXKLPHV.js → chunk-3BFBWNAQ.js} +2 -2
- package/dist/src/{chunk-S4HGSY5Z.js → chunk-7MJCUMQR.js} +2 -2
- package/dist/src/{chunk-DGDRZKY6.js → chunk-CBTYCMFF.js} +573 -448
- package/dist/src/{chunk-7HOFVL7D.js → chunk-OZH37ZP5.js} +1 -1
- package/dist/src/{chunk-XRXQ7NIX.js → chunk-T6OPQGDD.js} +6 -6
- package/dist/src/{chunk-5HCIPJAY.js → chunk-TKVNHQ6W.js} +2 -2
- package/dist/src/{chunk-AXGVGBIT.js → chunk-TWV26MTQ.js} +1 -1
- package/dist/src/{chunk-XMXK5XQD.js → chunk-TZN36XJ4.js} +3 -3
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +4 -4
- package/dist/src/index.js +800 -443
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/subagent-mcp.js +1 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
evaluateCommandProtection,
|
|
28
28
|
extractToolCommand,
|
|
29
29
|
reportCommandProtectionBlock
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-3BFBWNAQ.js";
|
|
31
31
|
import {
|
|
32
32
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
33
33
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -65,10 +65,10 @@ import {
|
|
|
65
65
|
spawnMuseMsp,
|
|
66
66
|
startMuseSession,
|
|
67
67
|
uuidV7
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-7MJCUMQR.js";
|
|
69
69
|
import {
|
|
70
70
|
publishedPullRequestUrls
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-OZH37ZP5.js";
|
|
72
72
|
import {
|
|
73
73
|
ACCOUNT_RATE_LIMITS_READ_METHOD,
|
|
74
74
|
AsyncLock,
|
|
@@ -147,7 +147,7 @@ import {
|
|
|
147
147
|
transcriptSecrets,
|
|
148
148
|
upsertCredentialFileLines,
|
|
149
149
|
writeSecureCredentialFile
|
|
150
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-T6OPQGDD.js";
|
|
151
151
|
import {
|
|
152
152
|
ENGINE_ENV,
|
|
153
153
|
UNQUOTED_PATHS_CONFIG,
|
|
@@ -158,15 +158,16 @@ import {
|
|
|
158
158
|
resolveDiffBase,
|
|
159
159
|
setAgentCredentialSnapshot,
|
|
160
160
|
setLinearSessionId
|
|
161
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-TKVNHQ6W.js";
|
|
162
162
|
import {
|
|
163
|
+
buildCodexAgentEnv,
|
|
163
164
|
getCodexModelProvider
|
|
164
|
-
} from "./chunk-
|
|
165
|
+
} from "./chunk-TZN36XJ4.js";
|
|
165
166
|
import {
|
|
166
167
|
SUBPROCESS_MAX_BUFFER,
|
|
167
168
|
execAsync,
|
|
168
169
|
execFileAsync
|
|
169
|
-
} from "./chunk-
|
|
170
|
+
} from "./chunk-TWV26MTQ.js";
|
|
170
171
|
import {
|
|
171
172
|
isRecord as isRecord2
|
|
172
173
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -228,6 +229,16 @@ import {
|
|
|
228
229
|
ENGINE_SLEEP_PATH,
|
|
229
230
|
ENGINE_STREAM_LAST_EVENT_ID_HEADER,
|
|
230
231
|
ENVIRONMENT_HOOK_RUN_LOG_LIMIT,
|
|
232
|
+
EXEC_DEFAULT_IDLE_TTL_MS,
|
|
233
|
+
EXEC_DEFAULT_READ_BYTES,
|
|
234
|
+
EXEC_ERROR_CODES,
|
|
235
|
+
EXEC_FRAME,
|
|
236
|
+
EXEC_MAX_FRAME_BYTES,
|
|
237
|
+
EXEC_PING_INTERVAL_MS,
|
|
238
|
+
EXEC_PROCESS_BUFFER_BYTES,
|
|
239
|
+
EXEC_PROTOCOL_VERSION,
|
|
240
|
+
EXEC_SILENCE_TIMEOUT_MS,
|
|
241
|
+
EXEC_SOCKET_PATH,
|
|
231
242
|
GITHUB_CREDENTIAL_REFRESH_PATH,
|
|
232
243
|
GITLAB_CREDENTIAL_REFRESH_PATH,
|
|
233
244
|
HISTORY_INDEX_FILENAME,
|
|
@@ -311,6 +322,7 @@ import {
|
|
|
311
322
|
createSuccessResult,
|
|
312
323
|
createUuidFromHex,
|
|
313
324
|
currentStepLabel,
|
|
325
|
+
decodeExecFrame,
|
|
314
326
|
defaultForkChatTitle,
|
|
315
327
|
describeAuthFallback,
|
|
316
328
|
describeCredential,
|
|
@@ -318,9 +330,11 @@ import {
|
|
|
318
330
|
detectAgentQuotaLimit,
|
|
319
331
|
detectEnvironmentAuthMethod,
|
|
320
332
|
detectLanguageByPath,
|
|
333
|
+
encodeExecFrame,
|
|
321
334
|
engineCredentialRefreshFailureSchema,
|
|
322
335
|
engineMcpOAuthTokenResponseSchema,
|
|
323
336
|
excludeQueuedAcceptedEvents,
|
|
337
|
+
execRequestSchema,
|
|
324
338
|
extractErrorText,
|
|
325
339
|
extractFinalResponse,
|
|
326
340
|
extractJsonObject,
|
|
@@ -449,7 +463,7 @@ import {
|
|
|
449
463
|
workspaceTokenRequestSchema,
|
|
450
464
|
workspaceTokenResponseSchema,
|
|
451
465
|
wrapInTag
|
|
452
|
-
} from "./chunk-
|
|
466
|
+
} from "./chunk-CBTYCMFF.js";
|
|
453
467
|
import {
|
|
454
468
|
cloneMcpConfig,
|
|
455
469
|
ensureCompatibilityImports,
|
|
@@ -650,7 +664,7 @@ var require_lib = __commonJS({
|
|
|
650
664
|
"../node_modules/.bun/which@5.0.0/node_modules/which/lib/index.js"(exports, module) {
|
|
651
665
|
"use strict";
|
|
652
666
|
var { isexe, sync: isexeSync } = require_index_min();
|
|
653
|
-
var { join:
|
|
667
|
+
var { join: join38, delimiter: delimiter3, sep: sep2, posix } = __require("path");
|
|
654
668
|
var isWindows = process.platform === "win32";
|
|
655
669
|
var rSlash = new RegExp(`[${posix.sep}${sep2 === posix.sep ? "" : sep2}]`.replace(/(\\)/g, "\\$1"));
|
|
656
670
|
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
@@ -679,7 +693,7 @@ var require_lib = __commonJS({
|
|
|
679
693
|
var getPathPart = (raw, cmd) => {
|
|
680
694
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
681
695
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
682
|
-
return prefix +
|
|
696
|
+
return prefix + join38(pathPart, cmd);
|
|
683
697
|
};
|
|
684
698
|
var which = async (cmd, opt = {}) => {
|
|
685
699
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -740,8 +754,8 @@ var require_path_key = __commonJS({
|
|
|
740
754
|
"use strict";
|
|
741
755
|
var pathKey = (options = {}) => {
|
|
742
756
|
const environment = options.env || process.env;
|
|
743
|
-
const
|
|
744
|
-
if (
|
|
757
|
+
const platform4 = options.platform || process.platform;
|
|
758
|
+
if (platform4 !== "win32") {
|
|
745
759
|
return "PATH";
|
|
746
760
|
}
|
|
747
761
|
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
@@ -755,7 +769,7 @@ var require_path_key = __commonJS({
|
|
|
755
769
|
var require_resolveCommand = __commonJS({
|
|
756
770
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
757
771
|
"use strict";
|
|
758
|
-
var
|
|
772
|
+
var path8 = __require("path");
|
|
759
773
|
var which = require_lib();
|
|
760
774
|
var getPathKey = require_path_key();
|
|
761
775
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -773,7 +787,7 @@ var require_resolveCommand = __commonJS({
|
|
|
773
787
|
try {
|
|
774
788
|
resolved = which.sync(parsed.command, {
|
|
775
789
|
path: env[getPathKey({ env })],
|
|
776
|
-
pathExt: withoutPathExt ?
|
|
790
|
+
pathExt: withoutPathExt ? path8.delimiter : void 0
|
|
777
791
|
});
|
|
778
792
|
} catch (e) {
|
|
779
793
|
} finally {
|
|
@@ -782,7 +796,7 @@ var require_resolveCommand = __commonJS({
|
|
|
782
796
|
}
|
|
783
797
|
}
|
|
784
798
|
if (resolved) {
|
|
785
|
-
resolved =
|
|
799
|
+
resolved = path8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
786
800
|
}
|
|
787
801
|
return resolved;
|
|
788
802
|
}
|
|
@@ -836,8 +850,8 @@ var require_shebang_command = __commonJS({
|
|
|
836
850
|
if (!match) {
|
|
837
851
|
return null;
|
|
838
852
|
}
|
|
839
|
-
const [
|
|
840
|
-
const binary =
|
|
853
|
+
const [path8, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
854
|
+
const binary = path8.split("/").pop();
|
|
841
855
|
if (binary === "env") {
|
|
842
856
|
return argument;
|
|
843
857
|
}
|
|
@@ -872,7 +886,7 @@ var require_readShebang = __commonJS({
|
|
|
872
886
|
var require_parse = __commonJS({
|
|
873
887
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
874
888
|
"use strict";
|
|
875
|
-
var
|
|
889
|
+
var path8 = __require("path");
|
|
876
890
|
var resolveCommand = require_resolveCommand();
|
|
877
891
|
var escape2 = require_escape();
|
|
878
892
|
var readShebang = require_readShebang();
|
|
@@ -897,7 +911,7 @@ var require_parse = __commonJS({
|
|
|
897
911
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
898
912
|
if (parsed.options.forceShell || needsShell) {
|
|
899
913
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
900
|
-
parsed.command =
|
|
914
|
+
parsed.command = path8.normalize(parsed.command);
|
|
901
915
|
parsed.command = escape2.command(parsed.command);
|
|
902
916
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
903
917
|
const shellCommand2 = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -907,7 +921,7 @@ var require_parse = __commonJS({
|
|
|
907
921
|
}
|
|
908
922
|
return parsed;
|
|
909
923
|
}
|
|
910
|
-
function
|
|
924
|
+
function parse3(command, args, options) {
|
|
911
925
|
if (args && !Array.isArray(args)) {
|
|
912
926
|
options = args;
|
|
913
927
|
args = null;
|
|
@@ -926,7 +940,7 @@ var require_parse = __commonJS({
|
|
|
926
940
|
};
|
|
927
941
|
return options.shell ? parsed : parseNonShell(parsed);
|
|
928
942
|
}
|
|
929
|
-
module.exports =
|
|
943
|
+
module.exports = parse3;
|
|
930
944
|
}
|
|
931
945
|
});
|
|
932
946
|
|
|
@@ -985,24 +999,24 @@ var require_cross_spawn = __commonJS({
|
|
|
985
999
|
"../node_modules/.bun/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
|
|
986
1000
|
"use strict";
|
|
987
1001
|
var cp2 = __require("child_process");
|
|
988
|
-
var
|
|
1002
|
+
var parse3 = require_parse();
|
|
989
1003
|
var enoent = require_enoent();
|
|
990
|
-
function
|
|
991
|
-
const parsed =
|
|
1004
|
+
function spawn8(command, args, options) {
|
|
1005
|
+
const parsed = parse3(command, args, options);
|
|
992
1006
|
const spawned = cp2.spawn(parsed.command, parsed.args, parsed.options);
|
|
993
1007
|
enoent.hookChildProcess(spawned, parsed);
|
|
994
1008
|
return spawned;
|
|
995
1009
|
}
|
|
996
1010
|
function spawnSync3(command, args, options) {
|
|
997
|
-
const parsed =
|
|
1011
|
+
const parsed = parse3(command, args, options);
|
|
998
1012
|
const result = cp2.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
999
1013
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
1000
1014
|
return result;
|
|
1001
1015
|
}
|
|
1002
|
-
module.exports =
|
|
1003
|
-
module.exports.spawn =
|
|
1016
|
+
module.exports = spawn8;
|
|
1017
|
+
module.exports.spawn = spawn8;
|
|
1004
1018
|
module.exports.sync = spawnSync3;
|
|
1005
|
-
module.exports._parse =
|
|
1019
|
+
module.exports._parse = parse3;
|
|
1006
1020
|
module.exports._enoent = enoent;
|
|
1007
1021
|
}
|
|
1008
1022
|
});
|
|
@@ -1384,11 +1398,11 @@ var require_codegen2 = __commonJS({
|
|
|
1384
1398
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
1385
1399
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
1386
1400
|
}
|
|
1387
|
-
optimizeNames(names,
|
|
1401
|
+
optimizeNames(names, constants3) {
|
|
1388
1402
|
if (!names[this.name.str])
|
|
1389
1403
|
return;
|
|
1390
1404
|
if (this.rhs)
|
|
1391
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
1405
|
+
this.rhs = optimizeExpr(this.rhs, names, constants3);
|
|
1392
1406
|
return this;
|
|
1393
1407
|
}
|
|
1394
1408
|
get names() {
|
|
@@ -1405,10 +1419,10 @@ var require_codegen2 = __commonJS({
|
|
|
1405
1419
|
render({ _n }) {
|
|
1406
1420
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
1407
1421
|
}
|
|
1408
|
-
optimizeNames(names,
|
|
1422
|
+
optimizeNames(names, constants3) {
|
|
1409
1423
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
1410
1424
|
return;
|
|
1411
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
1425
|
+
this.rhs = optimizeExpr(this.rhs, names, constants3);
|
|
1412
1426
|
return this;
|
|
1413
1427
|
}
|
|
1414
1428
|
get names() {
|
|
@@ -1469,8 +1483,8 @@ var require_codegen2 = __commonJS({
|
|
|
1469
1483
|
optimizeNodes() {
|
|
1470
1484
|
return `${this.code}` ? this : void 0;
|
|
1471
1485
|
}
|
|
1472
|
-
optimizeNames(names,
|
|
1473
|
-
this.code = optimizeExpr(this.code, names,
|
|
1486
|
+
optimizeNames(names, constants3) {
|
|
1487
|
+
this.code = optimizeExpr(this.code, names, constants3);
|
|
1474
1488
|
return this;
|
|
1475
1489
|
}
|
|
1476
1490
|
get names() {
|
|
@@ -1499,12 +1513,12 @@ var require_codegen2 = __commonJS({
|
|
|
1499
1513
|
}
|
|
1500
1514
|
return nodes.length > 0 ? this : void 0;
|
|
1501
1515
|
}
|
|
1502
|
-
optimizeNames(names,
|
|
1516
|
+
optimizeNames(names, constants3) {
|
|
1503
1517
|
const { nodes } = this;
|
|
1504
1518
|
let i = nodes.length;
|
|
1505
1519
|
while (i--) {
|
|
1506
1520
|
const n = nodes[i];
|
|
1507
|
-
if (n.optimizeNames(names,
|
|
1521
|
+
if (n.optimizeNames(names, constants3))
|
|
1508
1522
|
continue;
|
|
1509
1523
|
subtractNames(names, n.names);
|
|
1510
1524
|
nodes.splice(i, 1);
|
|
@@ -1557,12 +1571,12 @@ var require_codegen2 = __commonJS({
|
|
|
1557
1571
|
return void 0;
|
|
1558
1572
|
return this;
|
|
1559
1573
|
}
|
|
1560
|
-
optimizeNames(names,
|
|
1574
|
+
optimizeNames(names, constants3) {
|
|
1561
1575
|
var _a;
|
|
1562
|
-
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names,
|
|
1563
|
-
if (!(super.optimizeNames(names,
|
|
1576
|
+
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants3);
|
|
1577
|
+
if (!(super.optimizeNames(names, constants3) || this.else))
|
|
1564
1578
|
return;
|
|
1565
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
1579
|
+
this.condition = optimizeExpr(this.condition, names, constants3);
|
|
1566
1580
|
return this;
|
|
1567
1581
|
}
|
|
1568
1582
|
get names() {
|
|
@@ -1585,10 +1599,10 @@ var require_codegen2 = __commonJS({
|
|
|
1585
1599
|
render(opts) {
|
|
1586
1600
|
return `for(${this.iteration})` + super.render(opts);
|
|
1587
1601
|
}
|
|
1588
|
-
optimizeNames(names,
|
|
1589
|
-
if (!super.optimizeNames(names,
|
|
1602
|
+
optimizeNames(names, constants3) {
|
|
1603
|
+
if (!super.optimizeNames(names, constants3))
|
|
1590
1604
|
return;
|
|
1591
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
1605
|
+
this.iteration = optimizeExpr(this.iteration, names, constants3);
|
|
1592
1606
|
return this;
|
|
1593
1607
|
}
|
|
1594
1608
|
get names() {
|
|
@@ -1624,10 +1638,10 @@ var require_codegen2 = __commonJS({
|
|
|
1624
1638
|
render(opts) {
|
|
1625
1639
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
1626
1640
|
}
|
|
1627
|
-
optimizeNames(names,
|
|
1628
|
-
if (!super.optimizeNames(names,
|
|
1641
|
+
optimizeNames(names, constants3) {
|
|
1642
|
+
if (!super.optimizeNames(names, constants3))
|
|
1629
1643
|
return;
|
|
1630
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
1644
|
+
this.iterable = optimizeExpr(this.iterable, names, constants3);
|
|
1631
1645
|
return this;
|
|
1632
1646
|
}
|
|
1633
1647
|
get names() {
|
|
@@ -1669,11 +1683,11 @@ var require_codegen2 = __commonJS({
|
|
|
1669
1683
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
1670
1684
|
return this;
|
|
1671
1685
|
}
|
|
1672
|
-
optimizeNames(names,
|
|
1686
|
+
optimizeNames(names, constants3) {
|
|
1673
1687
|
var _a, _b;
|
|
1674
|
-
super.optimizeNames(names,
|
|
1675
|
-
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names,
|
|
1676
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names,
|
|
1688
|
+
super.optimizeNames(names, constants3);
|
|
1689
|
+
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants3);
|
|
1690
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants3);
|
|
1677
1691
|
return this;
|
|
1678
1692
|
}
|
|
1679
1693
|
get names() {
|
|
@@ -1974,7 +1988,7 @@ var require_codegen2 = __commonJS({
|
|
|
1974
1988
|
function addExprNames(names, from) {
|
|
1975
1989
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
1976
1990
|
}
|
|
1977
|
-
function optimizeExpr(expr, names,
|
|
1991
|
+
function optimizeExpr(expr, names, constants3) {
|
|
1978
1992
|
if (expr instanceof code_1.Name)
|
|
1979
1993
|
return replaceName(expr);
|
|
1980
1994
|
if (!canOptimize(expr))
|
|
@@ -1989,14 +2003,14 @@ var require_codegen2 = __commonJS({
|
|
|
1989
2003
|
return items;
|
|
1990
2004
|
}, []));
|
|
1991
2005
|
function replaceName(n) {
|
|
1992
|
-
const c =
|
|
2006
|
+
const c = constants3[n.str];
|
|
1993
2007
|
if (c === void 0 || names[n.str] !== 1)
|
|
1994
2008
|
return n;
|
|
1995
2009
|
delete names[n.str];
|
|
1996
2010
|
return c;
|
|
1997
2011
|
}
|
|
1998
2012
|
function canOptimize(e) {
|
|
1999
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
2013
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants3[c.str] !== void 0);
|
|
2000
2014
|
}
|
|
2001
2015
|
}
|
|
2002
2016
|
function subtractNames(names, from) {
|
|
@@ -3958,7 +3972,7 @@ var require_compile2 = __commonJS({
|
|
|
3958
3972
|
const schOrFunc = root.refs[ref];
|
|
3959
3973
|
if (schOrFunc)
|
|
3960
3974
|
return schOrFunc;
|
|
3961
|
-
let _sch =
|
|
3975
|
+
let _sch = resolve8.call(this, root, ref);
|
|
3962
3976
|
if (_sch === void 0) {
|
|
3963
3977
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
3964
3978
|
const { schemaId } = this.opts;
|
|
@@ -3985,7 +3999,7 @@ var require_compile2 = __commonJS({
|
|
|
3985
3999
|
function sameSchemaEnv(s1, s2) {
|
|
3986
4000
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3987
4001
|
}
|
|
3988
|
-
function
|
|
4002
|
+
function resolve8(root, ref) {
|
|
3989
4003
|
let sch;
|
|
3990
4004
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3991
4005
|
ref = sch;
|
|
@@ -4236,8 +4250,8 @@ var require_utils2 = __commonJS({
|
|
|
4236
4250
|
}
|
|
4237
4251
|
return ind;
|
|
4238
4252
|
}
|
|
4239
|
-
function removeDotSegments(
|
|
4240
|
-
let input =
|
|
4253
|
+
function removeDotSegments(path8) {
|
|
4254
|
+
let input = path8;
|
|
4241
4255
|
const output = [];
|
|
4242
4256
|
let nextSlash = -1;
|
|
4243
4257
|
let len = 0;
|
|
@@ -4311,11 +4325,11 @@ var require_utils2 = __commonJS({
|
|
|
4311
4325
|
}
|
|
4312
4326
|
return output.join("");
|
|
4313
4327
|
}
|
|
4314
|
-
function removeDotSegmentsRelative(
|
|
4315
|
-
if (
|
|
4316
|
-
return removeDotSegments(
|
|
4328
|
+
function removeDotSegmentsRelative(path8) {
|
|
4329
|
+
if (path8 === "" || path8[0] === "/") {
|
|
4330
|
+
return removeDotSegments(path8);
|
|
4317
4331
|
}
|
|
4318
|
-
const segments =
|
|
4332
|
+
const segments = path8.split("/");
|
|
4319
4333
|
const last = segments.length - 1;
|
|
4320
4334
|
const output = [];
|
|
4321
4335
|
let trailingDirectory = false;
|
|
@@ -4678,8 +4692,8 @@ var require_schemes2 = __commonJS({
|
|
|
4678
4692
|
}
|
|
4679
4693
|
if (wsComponent.resourceName) {
|
|
4680
4694
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
4681
|
-
const
|
|
4682
|
-
wsComponent.path =
|
|
4695
|
+
const path8 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
4696
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
4683
4697
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
4684
4698
|
wsComponent.resourceName = void 0;
|
|
4685
4699
|
}
|
|
@@ -4845,11 +4859,11 @@ var require_fast_uri2 = __commonJS({
|
|
|
4845
4859
|
normalizeString(uri, options);
|
|
4846
4860
|
} else if (typeof uri === "object") {
|
|
4847
4861
|
uri = /** @type {T} */
|
|
4848
|
-
|
|
4862
|
+
parse3(serialize(uri, options), options);
|
|
4849
4863
|
}
|
|
4850
4864
|
return uri;
|
|
4851
4865
|
}
|
|
4852
|
-
function
|
|
4866
|
+
function resolve8(baseURI, relativeURI, options) {
|
|
4853
4867
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
4854
4868
|
const {
|
|
4855
4869
|
parsed: baseParsed,
|
|
@@ -4888,8 +4902,8 @@ var require_fast_uri2 = __commonJS({
|
|
|
4888
4902
|
function resolveComponent(base, relative3, options, skipNormalization) {
|
|
4889
4903
|
const target = {};
|
|
4890
4904
|
if (!skipNormalization) {
|
|
4891
|
-
base =
|
|
4892
|
-
relative3 =
|
|
4905
|
+
base = parse3(serialize(base, options), options);
|
|
4906
|
+
relative3 = parse3(serialize(relative3, options), options);
|
|
4893
4907
|
}
|
|
4894
4908
|
options = options || {};
|
|
4895
4909
|
if (!options.tolerant && relative3.scheme) {
|
|
@@ -5207,7 +5221,7 @@ var require_fast_uri2 = __commonJS({
|
|
|
5207
5221
|
}
|
|
5208
5222
|
return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
|
|
5209
5223
|
}
|
|
5210
|
-
function
|
|
5224
|
+
function parse3(uri, opts) {
|
|
5211
5225
|
return parseWithStatus(uri, opts).parsed;
|
|
5212
5226
|
}
|
|
5213
5227
|
function normalizeString(uri, opts) {
|
|
@@ -5240,11 +5254,11 @@ var require_fast_uri2 = __commonJS({
|
|
|
5240
5254
|
var fastUri = {
|
|
5241
5255
|
SCHEMES,
|
|
5242
5256
|
normalize,
|
|
5243
|
-
resolve:
|
|
5257
|
+
resolve: resolve8,
|
|
5244
5258
|
resolveComponent,
|
|
5245
5259
|
equal,
|
|
5246
5260
|
serialize,
|
|
5247
|
-
parse:
|
|
5261
|
+
parse: parse3
|
|
5248
5262
|
};
|
|
5249
5263
|
module.exports = fastUri;
|
|
5250
5264
|
module.exports.default = fastUri;
|
|
@@ -5677,15 +5691,15 @@ var require_core2 = __commonJS({
|
|
|
5677
5691
|
}
|
|
5678
5692
|
return metaSchema;
|
|
5679
5693
|
}
|
|
5680
|
-
_removeAllSchemas(
|
|
5681
|
-
for (const keyRef in
|
|
5682
|
-
const sch =
|
|
5694
|
+
_removeAllSchemas(schemas2, regex) {
|
|
5695
|
+
for (const keyRef in schemas2) {
|
|
5696
|
+
const sch = schemas2[keyRef];
|
|
5683
5697
|
if (!regex || regex.test(keyRef)) {
|
|
5684
5698
|
if (typeof sch == "string") {
|
|
5685
|
-
delete
|
|
5699
|
+
delete schemas2[keyRef];
|
|
5686
5700
|
} else if (sch && !sch.meta) {
|
|
5687
5701
|
this._cache.delete(sch.schema);
|
|
5688
|
-
delete
|
|
5702
|
+
delete schemas2[keyRef];
|
|
5689
5703
|
}
|
|
5690
5704
|
}
|
|
5691
5705
|
}
|
|
@@ -9056,7 +9070,7 @@ var require_dist2 = __commonJS({
|
|
|
9056
9070
|
// src/index.ts
|
|
9057
9071
|
import { serve } from "@hono/node-server";
|
|
9058
9072
|
import { Hono as Hono2 } from "hono";
|
|
9059
|
-
import { randomUUID as
|
|
9073
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
9060
9074
|
import { connect } from "net";
|
|
9061
9075
|
import { Agent as Agent2, getGlobalDispatcher, setGlobalDispatcher } from "undici";
|
|
9062
9076
|
import { WebSocketServer } from "ws";
|
|
@@ -9461,9 +9475,9 @@ var TokenCache = class {
|
|
|
9461
9475
|
return pending;
|
|
9462
9476
|
}
|
|
9463
9477
|
};
|
|
9464
|
-
async function requestToken(request,
|
|
9478
|
+
async function requestToken(request, path8, body, failureMessage) {
|
|
9465
9479
|
try {
|
|
9466
|
-
return createSuccessResult(await request(
|
|
9480
|
+
return createSuccessResult(await request(path8, { body }));
|
|
9467
9481
|
} catch (error) {
|
|
9468
9482
|
return createErrorResult({ message: error instanceof Error ? error.message : failureMessage, code: 503 });
|
|
9469
9483
|
}
|
|
@@ -9555,16 +9569,16 @@ function resolveMcpOAuthRoute(requestUrl) {
|
|
|
9555
9569
|
}
|
|
9556
9570
|
var MAX_MCP_OAUTH_BODY_BYTES = 10 * 1024 * 1024;
|
|
9557
9571
|
function readBody(request, maxBytes) {
|
|
9558
|
-
return new Promise((
|
|
9572
|
+
return new Promise((resolve8) => {
|
|
9559
9573
|
const chunks = [];
|
|
9560
9574
|
let size = 0;
|
|
9561
9575
|
request.on("data", (chunk) => {
|
|
9562
9576
|
size += chunk.length;
|
|
9563
|
-
if (size > maxBytes)
|
|
9577
|
+
if (size > maxBytes) resolve8("too_large");
|
|
9564
9578
|
else chunks.push(chunk);
|
|
9565
9579
|
});
|
|
9566
|
-
request.on("end", () =>
|
|
9567
|
-
request.on("error", () =>
|
|
9580
|
+
request.on("end", () => resolve8(Buffer.concat(chunks)));
|
|
9581
|
+
request.on("error", () => resolve8(null));
|
|
9568
9582
|
});
|
|
9569
9583
|
}
|
|
9570
9584
|
function forward(request, response, target, token, onResponse = (incoming) => pipeResponse(incoming, response)) {
|
|
@@ -9734,11 +9748,11 @@ var EngineLifecycle = class {
|
|
|
9734
9748
|
}
|
|
9735
9749
|
waitForActive(timeoutMs) {
|
|
9736
9750
|
if (this.active) return Promise.resolve();
|
|
9737
|
-
return new Promise((
|
|
9738
|
-
const timer = setTimeout(
|
|
9751
|
+
return new Promise((resolve8) => {
|
|
9752
|
+
const timer = setTimeout(resolve8, timeoutMs);
|
|
9739
9753
|
this.activeWaiters.push(() => {
|
|
9740
9754
|
clearTimeout(timer);
|
|
9741
|
-
|
|
9755
|
+
resolve8();
|
|
9742
9756
|
});
|
|
9743
9757
|
});
|
|
9744
9758
|
}
|
|
@@ -9766,8 +9780,8 @@ var StreamWriter = class {
|
|
|
9766
9780
|
backpressured = false;
|
|
9767
9781
|
droppedCount = 0;
|
|
9768
9782
|
flushTimer = null;
|
|
9769
|
-
open(
|
|
9770
|
-
this.stream = createWriteStream(
|
|
9783
|
+
open(path8, highWaterMark = DEFAULT_HIGH_WATER) {
|
|
9784
|
+
this.stream = createWriteStream(path8, { flags: "a", highWaterMark });
|
|
9771
9785
|
this.stream.on("error", () => {
|
|
9772
9786
|
this.stream = null;
|
|
9773
9787
|
});
|
|
@@ -9789,9 +9803,9 @@ var StreamWriter = class {
|
|
|
9789
9803
|
return true;
|
|
9790
9804
|
}
|
|
9791
9805
|
flush(signal) {
|
|
9792
|
-
return new Promise((
|
|
9806
|
+
return new Promise((resolve8, reject) => {
|
|
9793
9807
|
if (!this.stream) {
|
|
9794
|
-
|
|
9808
|
+
resolve8();
|
|
9795
9809
|
return;
|
|
9796
9810
|
}
|
|
9797
9811
|
if (this.flushTimer) {
|
|
@@ -9808,7 +9822,7 @@ var StreamWriter = class {
|
|
|
9808
9822
|
s.write("", (error) => {
|
|
9809
9823
|
signal?.removeEventListener("abort", onAbort);
|
|
9810
9824
|
if (error) reject(error);
|
|
9811
|
-
else
|
|
9825
|
+
else resolve8();
|
|
9812
9826
|
});
|
|
9813
9827
|
});
|
|
9814
9828
|
}
|
|
@@ -10370,7 +10384,7 @@ var ReplicasConfigService = class {
|
|
|
10370
10384
|
});
|
|
10371
10385
|
if (signal("SIGTERM").length === 0) return;
|
|
10372
10386
|
const deadline = Date.now() + 5e3;
|
|
10373
|
-
while (signal(0).length > 0 && Date.now() < deadline) await new Promise((
|
|
10387
|
+
while (signal(0).length > 0 && Date.now() < deadline) await new Promise((resolve8) => setTimeout(resolve8, 25));
|
|
10374
10388
|
signal("SIGKILL");
|
|
10375
10389
|
}
|
|
10376
10390
|
/**
|
|
@@ -10446,7 +10460,7 @@ var ReplicasConfigService = class {
|
|
|
10446
10460
|
await this.logToFile(`[${params.repoName}] --- Running: ${params.label} ---`);
|
|
10447
10461
|
emit(`$ ${params.label}
|
|
10448
10462
|
`);
|
|
10449
|
-
return new Promise((
|
|
10463
|
+
return new Promise((resolve8) => {
|
|
10450
10464
|
const proc = spawn("bash", ["-lc", params.command], {
|
|
10451
10465
|
cwd: params.cwd,
|
|
10452
10466
|
env: process.env,
|
|
@@ -10459,7 +10473,7 @@ var ReplicasConfigService = class {
|
|
|
10459
10473
|
const finish = (result) => {
|
|
10460
10474
|
if (settled) return;
|
|
10461
10475
|
settled = true;
|
|
10462
|
-
|
|
10476
|
+
resolve8(result);
|
|
10463
10477
|
};
|
|
10464
10478
|
const timer = setTimeout(() => {
|
|
10465
10479
|
timedOut = true;
|
|
@@ -11025,7 +11039,7 @@ async function startDeviceRelays(names, paths, signal) {
|
|
|
11025
11039
|
await rm2(paths.socket(name), { force: true });
|
|
11026
11040
|
const relay = { server: createServer((local) => attach(relay, local)), knownHostsPath: paths.knownHosts(name), waiting: [], pending: [] };
|
|
11027
11041
|
relays.set(name, relay);
|
|
11028
|
-
await new Promise((
|
|
11042
|
+
await new Promise((resolve8, reject) => relay.server.once("error", reject).listen(paths.socket(name), resolve8));
|
|
11029
11043
|
}));
|
|
11030
11044
|
}
|
|
11031
11045
|
|
|
@@ -12989,7 +13003,7 @@ async function getSkillRegistryInventory(homeDir) {
|
|
|
12989
13003
|
async function buildClaudeRegistryConfig(homeDir) {
|
|
12990
13004
|
const inventory = await getSkillRegistryInventory(homeDir);
|
|
12991
13005
|
return {
|
|
12992
|
-
plugins: inventory.claudePluginRoots.map((
|
|
13006
|
+
plugins: inventory.claudePluginRoots.map((path8) => ({ type: "local", path: path8 })),
|
|
12993
13007
|
enableAllSkills: inventory.claudePluginRoots.length > 0 || inventory.standaloneSkills.length > 0
|
|
12994
13008
|
};
|
|
12995
13009
|
}
|
|
@@ -13147,31 +13161,31 @@ function uniqueStandaloneSkills(skills) {
|
|
|
13147
13161
|
}
|
|
13148
13162
|
return unique;
|
|
13149
13163
|
}
|
|
13150
|
-
async function safeReadDir(
|
|
13164
|
+
async function safeReadDir(path8) {
|
|
13151
13165
|
try {
|
|
13152
|
-
return await readdir3(
|
|
13166
|
+
return await readdir3(path8, { withFileTypes: true });
|
|
13153
13167
|
} catch (error) {
|
|
13154
13168
|
if (isNotFoundError(error)) return [];
|
|
13155
13169
|
throw error;
|
|
13156
13170
|
}
|
|
13157
13171
|
}
|
|
13158
|
-
async function isDirectoryDirent(dirent,
|
|
13172
|
+
async function isDirectoryDirent(dirent, path8) {
|
|
13159
13173
|
if (dirent.isDirectory()) return true;
|
|
13160
13174
|
if (!dirent.isSymbolicLink()) return false;
|
|
13161
|
-
return directoryExists(
|
|
13175
|
+
return directoryExists(path8);
|
|
13162
13176
|
}
|
|
13163
|
-
async function directoryExists(
|
|
13177
|
+
async function directoryExists(path8) {
|
|
13164
13178
|
try {
|
|
13165
|
-
const pathStat = await stat(
|
|
13179
|
+
const pathStat = await stat(path8);
|
|
13166
13180
|
return pathStat.isDirectory();
|
|
13167
13181
|
} catch (error) {
|
|
13168
13182
|
if (isNotFoundError(error)) return false;
|
|
13169
13183
|
throw error;
|
|
13170
13184
|
}
|
|
13171
13185
|
}
|
|
13172
|
-
async function fileExists(
|
|
13186
|
+
async function fileExists(path8) {
|
|
13173
13187
|
try {
|
|
13174
|
-
const pathStat = await stat(
|
|
13188
|
+
const pathStat = await stat(path8);
|
|
13175
13189
|
return pathStat.isFile();
|
|
13176
13190
|
} catch (error) {
|
|
13177
13191
|
if (isNotFoundError(error)) return false;
|
|
@@ -13286,8 +13300,8 @@ var PromptStream = class {
|
|
|
13286
13300
|
if (this.closed) {
|
|
13287
13301
|
return Promise.resolve({ value: void 0, done: true });
|
|
13288
13302
|
}
|
|
13289
|
-
return new Promise((
|
|
13290
|
-
this.waiters.push(
|
|
13303
|
+
return new Promise((resolve8) => {
|
|
13304
|
+
this.waiters.push(resolve8);
|
|
13291
13305
|
});
|
|
13292
13306
|
}
|
|
13293
13307
|
};
|
|
@@ -13658,7 +13672,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13658
13672
|
// Claude Code starts a command for another chat's SendMessage without streaming its text, and can start it a moment before writing it.
|
|
13659
13673
|
async recordPeerMessage(uuid, query2) {
|
|
13660
13674
|
for (const delayMs of [0, 100, 300, 600, 1e3]) {
|
|
13661
|
-
if (delayMs) await new Promise((
|
|
13675
|
+
if (delayMs) await new Promise((resolve8) => setTimeout(resolve8, delayMs));
|
|
13662
13676
|
if (this.activeQuery !== query2 || !this.sessionId) return;
|
|
13663
13677
|
const entry = (await getSessionMessages(this.sessionId, { dir: this.workingDirectory })).findLast((message) => message.uuid === uuid);
|
|
13664
13678
|
if (!entry) continue;
|
|
@@ -13843,14 +13857,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13843
13857
|
const requestId = randomUUID3();
|
|
13844
13858
|
const toolUseId = options.toolUseID;
|
|
13845
13859
|
const { options: requestOptions, questions: requestQuestions } = handler.getRequest(input);
|
|
13846
|
-
const result = await new Promise((
|
|
13860
|
+
const result = await new Promise((resolve8) => {
|
|
13847
13861
|
this.pendingToolInputs.set(requestId, {
|
|
13848
13862
|
requestId,
|
|
13849
13863
|
toolUseId,
|
|
13850
13864
|
toolName,
|
|
13851
13865
|
input,
|
|
13852
13866
|
handler,
|
|
13853
|
-
resolve:
|
|
13867
|
+
resolve: resolve8
|
|
13854
13868
|
});
|
|
13855
13869
|
const onAbort = () => {
|
|
13856
13870
|
const pending = this.pendingToolInputs.get(requestId);
|
|
@@ -14105,7 +14119,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14105
14119
|
error
|
|
14106
14120
|
);
|
|
14107
14121
|
await this.tearDownSession();
|
|
14108
|
-
await new Promise((
|
|
14122
|
+
await new Promise((resolve8) => setTimeout(resolve8, delayMs));
|
|
14109
14123
|
currentRequest = { ...request, message: CLAUDE_MIDTURN_CONTINUE_PROMPT, images: [], goalMode: false };
|
|
14110
14124
|
attempt++;
|
|
14111
14125
|
continue;
|
|
@@ -14118,7 +14132,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14118
14132
|
error
|
|
14119
14133
|
);
|
|
14120
14134
|
await this.tearDownSession();
|
|
14121
|
-
await new Promise((
|
|
14135
|
+
await new Promise((resolve8) => setTimeout(resolve8, delayMs));
|
|
14122
14136
|
attempt++;
|
|
14123
14137
|
continue;
|
|
14124
14138
|
}
|
|
@@ -14269,10 +14283,10 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14269
14283
|
this.endedReplies.clear();
|
|
14270
14284
|
this.cutSentAt = null;
|
|
14271
14285
|
try {
|
|
14272
|
-
await new Promise((
|
|
14286
|
+
await new Promise((resolve8, reject) => {
|
|
14273
14287
|
const steers = options.steers ?? /* @__PURE__ */ new Map();
|
|
14274
14288
|
this.pendingTurn = {
|
|
14275
|
-
resolve:
|
|
14289
|
+
resolve: resolve8,
|
|
14276
14290
|
reject,
|
|
14277
14291
|
sawActivity: false,
|
|
14278
14292
|
steers,
|
|
@@ -15911,8 +15925,8 @@ ${text.slice(-24e3)}`
|
|
|
15911
15925
|
});
|
|
15912
15926
|
};
|
|
15913
15927
|
let resolveCompleted;
|
|
15914
|
-
const completed = new Promise((
|
|
15915
|
-
resolveCompleted =
|
|
15928
|
+
const completed = new Promise((resolve8) => {
|
|
15929
|
+
resolveCompleted = resolve8;
|
|
15916
15930
|
});
|
|
15917
15931
|
let rejectDisposed = () => {
|
|
15918
15932
|
};
|
|
@@ -16466,10 +16480,10 @@ var STREAM_SYNC_DELAY_MS = 50;
|
|
|
16466
16480
|
function isMissingFile(error) {
|
|
16467
16481
|
return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
|
|
16468
16482
|
}
|
|
16469
|
-
async function openWholeLog(
|
|
16483
|
+
async function openWholeLog(path8) {
|
|
16470
16484
|
let file;
|
|
16471
16485
|
try {
|
|
16472
|
-
file = await open(
|
|
16486
|
+
file = await open(path8, "r");
|
|
16473
16487
|
} catch (error) {
|
|
16474
16488
|
if (isMissingFile(error)) return null;
|
|
16475
16489
|
throw error;
|
|
@@ -16543,8 +16557,8 @@ var CodexHistoryFile = class {
|
|
|
16543
16557
|
this.nextOffset += bytes.length;
|
|
16544
16558
|
const synced = Promise.withResolvers();
|
|
16545
16559
|
this.taken = synced.promise;
|
|
16546
|
-
const written = new Promise((
|
|
16547
|
-
this.queued.push({ bytes, stream: this.isStream(event), resolve:
|
|
16560
|
+
const written = new Promise((resolve8, reject) => {
|
|
16561
|
+
this.queued.push({ bytes, stream: this.isStream(event), resolve: resolve8, reject, synced: synced.resolve });
|
|
16548
16562
|
});
|
|
16549
16563
|
written.catch(() => {
|
|
16550
16564
|
});
|
|
@@ -16626,7 +16640,7 @@ var CodexHistoryFile = class {
|
|
|
16626
16640
|
} catch (error) {
|
|
16627
16641
|
const delay2 = WRITE_RETRY_DELAYS_MS[attempt];
|
|
16628
16642
|
if (delay2 === void 0) throw error;
|
|
16629
|
-
await new Promise((
|
|
16643
|
+
await new Promise((resolve8) => setTimeout(resolve8, delay2));
|
|
16630
16644
|
}
|
|
16631
16645
|
}
|
|
16632
16646
|
}
|
|
@@ -16868,12 +16882,12 @@ var postToolHookPath = [
|
|
|
16868
16882
|
join13(moduleDirectory, "post-tool-pr-hook.js"),
|
|
16869
16883
|
join13(moduleDirectory, "..", "post-tool-pr-hook.ts")
|
|
16870
16884
|
].find(existsSync7);
|
|
16871
|
-
function shellCommand(
|
|
16872
|
-
if (!
|
|
16885
|
+
function shellCommand(path8, provider) {
|
|
16886
|
+
if (!path8) throw new Error("Replicas hook executable is missing.");
|
|
16873
16887
|
const args = [
|
|
16874
16888
|
process.execPath,
|
|
16875
|
-
...
|
|
16876
|
-
|
|
16889
|
+
...path8.endsWith(".ts") && basename(process.execPath) !== "bun" ? ["--import", "tsx"] : [],
|
|
16890
|
+
path8,
|
|
16877
16891
|
...provider ? [provider] : []
|
|
16878
16892
|
];
|
|
16879
16893
|
return args.map((value) => `'${value.replaceAll("'", "'\\''")}'`).join(" ");
|
|
@@ -16887,10 +16901,10 @@ function getPostToolPrHookPath() {
|
|
|
16887
16901
|
return postToolHookPath;
|
|
16888
16902
|
}
|
|
16889
16903
|
async function ensureCursorCommandProtectionHook() {
|
|
16890
|
-
const
|
|
16904
|
+
const path8 = join13(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
|
|
16891
16905
|
let config = {};
|
|
16892
16906
|
try {
|
|
16893
|
-
const content = await readFile8(
|
|
16907
|
+
const content = await readFile8(path8, "utf8");
|
|
16894
16908
|
const parsed = content.trim() ? JSON.parse(content) : {};
|
|
16895
16909
|
if (!isRecord2(parsed)) throw new Error("Invalid Cursor hooks configuration.");
|
|
16896
16910
|
config = parsed;
|
|
@@ -16908,8 +16922,8 @@ async function ensureCursorCommandProtectionHook() {
|
|
|
16908
16922
|
...existingPost.filter((entry) => !isRecord2(entry) || typeof entry.command !== "string" || !entry.command.includes("post-tool-pr-hook")),
|
|
16909
16923
|
{ command: shellCommand(postToolHookPath) }
|
|
16910
16924
|
];
|
|
16911
|
-
await mkdir9(dirname4(
|
|
16912
|
-
await atomicWriteFile(
|
|
16925
|
+
await mkdir9(dirname4(path8), { recursive: true });
|
|
16926
|
+
await atomicWriteFile(path8, `${JSON.stringify({ ...config, version: 1, hooks }, null, 2)}
|
|
16913
16927
|
`);
|
|
16914
16928
|
}
|
|
16915
16929
|
|
|
@@ -17143,8 +17157,8 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
17143
17157
|
let agent = null;
|
|
17144
17158
|
let sawCursorActivity = false;
|
|
17145
17159
|
let reconnectNoticeTimer = null;
|
|
17146
|
-
const aborted = new Promise((
|
|
17147
|
-
this.abortActiveTurn = () =>
|
|
17160
|
+
const aborted = new Promise((resolve8) => {
|
|
17161
|
+
this.abortActiveTurn = () => resolve8(TURN_ABORTED);
|
|
17148
17162
|
});
|
|
17149
17163
|
const linearForwarder = new LinearEventForwarder(() => this.linearSessionId);
|
|
17150
17164
|
const clearReconnectNoticeTimer = () => {
|
|
@@ -17636,8 +17650,8 @@ ${typeof pending.subject.command === "string" ? pending.subject.command : JSON.s
|
|
|
17636
17650
|
userMessageRecorded = true;
|
|
17637
17651
|
}
|
|
17638
17652
|
if (/^\/compact$/i.test(request.message.trim())) {
|
|
17639
|
-
const completed2 = new Promise((
|
|
17640
|
-
this.compactionComplete = { resolve:
|
|
17653
|
+
const completed2 = new Promise((resolve8) => {
|
|
17654
|
+
this.compactionComplete = { resolve: resolve8 };
|
|
17641
17655
|
});
|
|
17642
17656
|
const result2 = await this.request("session/compact", {
|
|
17643
17657
|
commandId: uuidV7(),
|
|
@@ -17669,8 +17683,8 @@ ${pending}
|
|
|
17669
17683
|
` : ""}${request.planMode ? "Plan the requested work without modifying files or running mutating commands.\n\n" : ""}${request.message}`;
|
|
17670
17684
|
if (signal.aborted) return;
|
|
17671
17685
|
this.turnError = null;
|
|
17672
|
-
const completed = new Promise((
|
|
17673
|
-
this.turnComplete = { resolve:
|
|
17686
|
+
const completed = new Promise((resolve8) => {
|
|
17687
|
+
this.turnComplete = { resolve: resolve8 };
|
|
17674
17688
|
});
|
|
17675
17689
|
const result = await this.request("turn/start", {
|
|
17676
17690
|
...museTurnStartParams(this.sessionId, this.createTurnInput(text, request.images), request.thinkingLevel),
|
|
@@ -18094,8 +18108,8 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18094
18108
|
const previousUpdate = this.clientUpdate;
|
|
18095
18109
|
let finishUpdate = () => {
|
|
18096
18110
|
};
|
|
18097
|
-
this.clientUpdate = new Promise((
|
|
18098
|
-
finishUpdate =
|
|
18111
|
+
this.clientUpdate = new Promise((resolve8) => {
|
|
18112
|
+
finishUpdate = resolve8;
|
|
18099
18113
|
});
|
|
18100
18114
|
await previousUpdate;
|
|
18101
18115
|
try {
|
|
@@ -18176,8 +18190,8 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18176
18190
|
this.configuredModels = new Set(providerModels);
|
|
18177
18191
|
const eventController = new AbortController();
|
|
18178
18192
|
this.eventAbortController = eventController;
|
|
18179
|
-
this.eventSubscriptionReady = new Promise((
|
|
18180
|
-
this.resolveEventSubscriptionReady =
|
|
18193
|
+
this.eventSubscriptionReady = new Promise((resolve8) => {
|
|
18194
|
+
this.resolveEventSubscriptionReady = resolve8;
|
|
18181
18195
|
});
|
|
18182
18196
|
this.subscribeToEvents(client, eventController).catch((error) => {
|
|
18183
18197
|
this.resolveEventSubscriptionReady?.();
|
|
@@ -18187,7 +18201,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18187
18201
|
});
|
|
18188
18202
|
await Promise.race([
|
|
18189
18203
|
this.eventSubscriptionReady,
|
|
18190
|
-
new Promise((
|
|
18204
|
+
new Promise((resolve8) => setTimeout(resolve8, 2e3))
|
|
18191
18205
|
]);
|
|
18192
18206
|
return client;
|
|
18193
18207
|
} finally {
|
|
@@ -27095,9 +27109,9 @@ var rev2026Codec = {
|
|
|
27095
27109
|
});
|
|
27096
27110
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta);
|
|
27097
27111
|
if (!parsed.success) for (const issue of parsed.error.issues) {
|
|
27098
|
-
const
|
|
27099
|
-
const key =
|
|
27100
|
-
if (
|
|
27112
|
+
const path8 = issue.path.map(String);
|
|
27113
|
+
const key = path8.length > 0 ? path8.join(".") : "_meta";
|
|
27114
|
+
if (path8.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing")) continue;
|
|
27101
27115
|
issues.push({
|
|
27102
27116
|
key,
|
|
27103
27117
|
problem: issue.message
|
|
@@ -27402,29 +27416,29 @@ var PERMITTED_X_MCP_HEADER_TYPES = /* @__PURE__ */ new Set([
|
|
|
27402
27416
|
function scanXMcpHeaderDeclarations(inputSchema) {
|
|
27403
27417
|
const declarations = [];
|
|
27404
27418
|
const seenLower = /* @__PURE__ */ new Map();
|
|
27405
|
-
const visit = (node,
|
|
27419
|
+
const visit = (node, path8, reachable) => {
|
|
27406
27420
|
if (node === null || typeof node !== "object") return void 0;
|
|
27407
27421
|
const schema = node;
|
|
27408
27422
|
if (X_MCP_HEADER_KEY in schema) {
|
|
27409
|
-
if (!reachable ||
|
|
27423
|
+
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)`;
|
|
27410
27424
|
const raw = schema[X_MCP_HEADER_KEY];
|
|
27411
|
-
if (typeof raw !== "string" || raw.length === 0) return `${pathName(
|
|
27412
|
-
if (!RFC9110_TOKEN.test(raw)) return `${pathName(
|
|
27425
|
+
if (typeof raw !== "string" || raw.length === 0) return `${pathName(path8)}: x-mcp-header MUST be a non-empty string`;
|
|
27426
|
+
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)`;
|
|
27413
27427
|
const type = typeof schema.type === "string" ? schema.type : void 0;
|
|
27414
|
-
if (type === void 0 || !PERMITTED_X_MCP_HEADER_TYPES.has(type)) return `${pathName(
|
|
27428
|
+
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>"}`;
|
|
27415
27429
|
const lower = raw.toLowerCase();
|
|
27416
27430
|
const prior = seenLower.get(lower);
|
|
27417
27431
|
if (prior !== void 0) return `x-mcp-header '${raw}' is not case-insensitively unique (also declared as '${prior}')`;
|
|
27418
27432
|
seenLower.set(lower, raw);
|
|
27419
27433
|
declarations.push({
|
|
27420
|
-
path:
|
|
27434
|
+
path: path8,
|
|
27421
27435
|
headerName: raw,
|
|
27422
27436
|
type
|
|
27423
27437
|
});
|
|
27424
27438
|
}
|
|
27425
27439
|
const properties = schema.properties;
|
|
27426
27440
|
if (properties !== null && typeof properties === "object") for (const [key, child] of Object.entries(properties)) {
|
|
27427
|
-
const fault$1 = visit(child, [...
|
|
27441
|
+
const fault$1 = visit(child, [...path8, key], reachable);
|
|
27428
27442
|
if (fault$1 !== void 0) return fault$1;
|
|
27429
27443
|
}
|
|
27430
27444
|
for (const k of NON_REACHABLE_SUBSCHEMA_KEYWORDS) {
|
|
@@ -27432,7 +27446,7 @@ function scanXMcpHeaderDeclarations(inputSchema) {
|
|
|
27432
27446
|
if (sub === void 0) continue;
|
|
27433
27447
|
const branches = Array.isArray(sub) ? sub : sub !== null && typeof sub === "object" && OBJECT_VALUED_SUBSCHEMA_KEYWORDS.has(k) ? Object.values(sub) : [sub];
|
|
27434
27448
|
for (const branch of branches) {
|
|
27435
|
-
const fault$1 = visit(branch, [...
|
|
27449
|
+
const fault$1 = visit(branch, [...path8, `<${k}>`], false);
|
|
27436
27450
|
if (fault$1 !== void 0) return fault$1;
|
|
27437
27451
|
}
|
|
27438
27452
|
}
|
|
@@ -27472,8 +27486,8 @@ var OBJECT_VALUED_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
27472
27486
|
"$defs",
|
|
27473
27487
|
"definitions"
|
|
27474
27488
|
]);
|
|
27475
|
-
function pathName(
|
|
27476
|
-
return
|
|
27489
|
+
function pathName(path8) {
|
|
27490
|
+
return path8.length === 0 ? "<root>" : path8.join(".");
|
|
27477
27491
|
}
|
|
27478
27492
|
var BASE64_SENTINEL_PREFIX = "=?base64?";
|
|
27479
27493
|
var BASE64_SENTINEL_SUFFIX = "?=";
|
|
@@ -27506,9 +27520,9 @@ function utf8ToBase64(s) {
|
|
|
27506
27520
|
function encodeMcpParamValue(value) {
|
|
27507
27521
|
return needsBase64(value) ? `${BASE64_SENTINEL_PREFIX}${utf8ToBase64(value)}${BASE64_SENTINEL_SUFFIX}` : value;
|
|
27508
27522
|
}
|
|
27509
|
-
function valueAtPath(root,
|
|
27523
|
+
function valueAtPath(root, path8) {
|
|
27510
27524
|
let node = root;
|
|
27511
|
-
for (const key of
|
|
27525
|
+
for (const key of path8) {
|
|
27512
27526
|
if (node === null || typeof node !== "object") return void 0;
|
|
27513
27527
|
node = node[key];
|
|
27514
27528
|
}
|
|
@@ -27635,8 +27649,8 @@ function isPlainObject$2(value) {
|
|
|
27635
27649
|
function parseSchema(schema, data) {
|
|
27636
27650
|
return z2.safeParse(schema, data);
|
|
27637
27651
|
}
|
|
27638
|
-
function shapeKeys(
|
|
27639
|
-
return new Set(
|
|
27652
|
+
function shapeKeys(schemas2) {
|
|
27653
|
+
return new Set(schemas2.flatMap((schema) => Object.keys(schema.shape)));
|
|
27640
27654
|
}
|
|
27641
27655
|
function isStandardSchema(schema) {
|
|
27642
27656
|
if (schema == null) return false;
|
|
@@ -27783,7 +27797,7 @@ var PROPERTY_KEYS_BY_TYPE = {
|
|
|
27783
27797
|
array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
|
|
27784
27798
|
};
|
|
27785
27799
|
var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
|
|
27786
|
-
function walkProperty(node,
|
|
27800
|
+
function walkProperty(node, path8, vendor, unsupported) {
|
|
27787
27801
|
if (!isJsonObject(node)) return node;
|
|
27788
27802
|
const allowedKeys = typeof node.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node.type) ? PROPERTY_KEYS_BY_TYPE[node.type] : void 0;
|
|
27789
27803
|
if (allowedKeys === void 0) return node;
|
|
@@ -27791,8 +27805,8 @@ function walkProperty(node, path7, vendor, unsupported) {
|
|
|
27791
27805
|
for (const [key, value] of Object.entries(node)) if (allowedKeys.has(key) || isAnnotationOnlyJsonSchemaKeyword(key)) pruned[key] = value;
|
|
27792
27806
|
else if (key === "pattern" && node.type === "string" && typeof node.format === "string") {
|
|
27793
27807
|
if (!SUPPORTED_STRING_FORMATS.has(node.format)) pruned[key] = value;
|
|
27794
|
-
else if (typeof value !== "string" || !isLibraryFormatPattern(node.format, value, vendor)) unsupported.push(`${
|
|
27795
|
-
} else unsupported.push(`${
|
|
27808
|
+
else if (typeof value !== "string" || !isLibraryFormatPattern(node.format, value, vendor)) unsupported.push(`${path8}.${key}`);
|
|
27809
|
+
} else unsupported.push(`${path8}.${key}`);
|
|
27796
27810
|
return pruned;
|
|
27797
27811
|
}
|
|
27798
27812
|
function walkRequestedSchema(converted, vendor) {
|
|
@@ -27809,11 +27823,11 @@ function describeUnsupportedProperties(pruned, fallback) {
|
|
|
27809
27823
|
const offenders = Object.entries(pruned.properties).filter(([, node]) => !parseSchema(PrimitiveSchemaDefinitionSchema, node).success).map(([name]) => `properties.${name}`);
|
|
27810
27824
|
return offenders.length > 0 ? offenders.join(", ") : fallback;
|
|
27811
27825
|
}
|
|
27812
|
-
function findDroppedConstraintPaths(original, parsed,
|
|
27813
|
-
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${
|
|
27826
|
+
function findDroppedConstraintPaths(original, parsed, path8 = "") {
|
|
27827
|
+
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path8}[${index}]`));
|
|
27814
27828
|
if (!isJsonObject(original) || !isJsonObject(parsed)) return [];
|
|
27815
27829
|
return Object.entries(original).flatMap(([key, value]) => {
|
|
27816
|
-
const childPath =
|
|
27830
|
+
const childPath = path8 ? `${path8}.${key}` : key;
|
|
27817
27831
|
if (!Object.prototype.hasOwnProperty.call(parsed, key)) return isAnnotationOnlyJsonSchemaKeyword(key) ? [] : [childPath];
|
|
27818
27832
|
return findDroppedConstraintPaths(value, parsed[key], childPath);
|
|
27819
27833
|
});
|
|
@@ -27900,14 +27914,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
|
27900
27914
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
27901
27915
|
}
|
|
27902
27916
|
function sleep2(ms, signal) {
|
|
27903
|
-
return new Promise((
|
|
27917
|
+
return new Promise((resolve8, reject) => {
|
|
27904
27918
|
if (signal?.aborted) {
|
|
27905
27919
|
reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
27906
27920
|
return;
|
|
27907
27921
|
}
|
|
27908
27922
|
const timer = setTimeout(() => {
|
|
27909
27923
|
signal?.removeEventListener("abort", onAbort);
|
|
27910
|
-
|
|
27924
|
+
resolve8();
|
|
27911
27925
|
}, ms);
|
|
27912
27926
|
const onAbort = () => {
|
|
27913
27927
|
clearTimeout(timer);
|
|
@@ -28751,7 +28765,7 @@ var Protocol = class {
|
|
|
28751
28765
|
const flowStartedAt = Date.now();
|
|
28752
28766
|
let onAbort;
|
|
28753
28767
|
let cleanupMessageId;
|
|
28754
|
-
return new Promise((
|
|
28768
|
+
return new Promise((resolve8, reject) => {
|
|
28755
28769
|
const earlyReject = (error) => {
|
|
28756
28770
|
reject(error);
|
|
28757
28771
|
};
|
|
@@ -28820,7 +28834,7 @@ var Protocol = class {
|
|
|
28820
28834
|
}
|
|
28821
28835
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
28822
28836
|
if (decoded.kind === "input_required") {
|
|
28823
|
-
if (options?.allowInputRequired === true) return
|
|
28837
|
+
if (options?.allowInputRequired === true) return resolve8(manualInputRequiredValue(decoded));
|
|
28824
28838
|
const flow = {
|
|
28825
28839
|
codec,
|
|
28826
28840
|
request,
|
|
@@ -28832,11 +28846,11 @@ var Protocol = class {
|
|
|
28832
28846
|
params
|
|
28833
28847
|
}, resultSchema, legOptions)
|
|
28834
28848
|
};
|
|
28835
|
-
return
|
|
28849
|
+
return resolve8(this._resolveNonCompleteResult(decoded, flow));
|
|
28836
28850
|
}
|
|
28837
28851
|
const result = decoded.result;
|
|
28838
28852
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
28839
|
-
if (parseResult.success)
|
|
28853
|
+
if (parseResult.success) resolve8(parseResult.data);
|
|
28840
28854
|
else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
|
|
28841
28855
|
}, reject);
|
|
28842
28856
|
});
|
|
@@ -29108,8 +29122,8 @@ var require_content_type = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29108
29122
|
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
29109
29123
|
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
29110
29124
|
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
29111
|
-
exports.parse =
|
|
29112
|
-
function
|
|
29125
|
+
exports.parse = parse3;
|
|
29126
|
+
function parse3(string3) {
|
|
29113
29127
|
if (!string3) throw new TypeError("argument string is required");
|
|
29114
29128
|
var header = typeof string3 === "object" ? getcontenttype(string3) : string3;
|
|
29115
29129
|
if (typeof header !== "string") throw new TypeError("argument string is required to be a string");
|
|
@@ -29661,9 +29675,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29661
29675
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
29662
29676
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
29663
29677
|
}
|
|
29664
|
-
optimizeNames(names,
|
|
29678
|
+
optimizeNames(names, constants3) {
|
|
29665
29679
|
if (!names[this.name.str]) return;
|
|
29666
|
-
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names,
|
|
29680
|
+
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names, constants3);
|
|
29667
29681
|
return this;
|
|
29668
29682
|
}
|
|
29669
29683
|
get names() {
|
|
@@ -29680,9 +29694,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29680
29694
|
render({ _n }) {
|
|
29681
29695
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
29682
29696
|
}
|
|
29683
|
-
optimizeNames(names,
|
|
29697
|
+
optimizeNames(names, constants3) {
|
|
29684
29698
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) return;
|
|
29685
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
29699
|
+
this.rhs = optimizeExpr(this.rhs, names, constants3);
|
|
29686
29700
|
return this;
|
|
29687
29701
|
}
|
|
29688
29702
|
get names() {
|
|
@@ -29741,8 +29755,8 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29741
29755
|
optimizeNodes() {
|
|
29742
29756
|
return `${this.code}` ? this : void 0;
|
|
29743
29757
|
}
|
|
29744
|
-
optimizeNames(names,
|
|
29745
|
-
this.code = optimizeExpr(this.code, names,
|
|
29758
|
+
optimizeNames(names, constants3) {
|
|
29759
|
+
this.code = optimizeExpr(this.code, names, constants3);
|
|
29746
29760
|
return this;
|
|
29747
29761
|
}
|
|
29748
29762
|
get names() {
|
|
@@ -29768,12 +29782,12 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29768
29782
|
}
|
|
29769
29783
|
return nodes.length > 0 ? this : void 0;
|
|
29770
29784
|
}
|
|
29771
|
-
optimizeNames(names,
|
|
29785
|
+
optimizeNames(names, constants3) {
|
|
29772
29786
|
const { nodes } = this;
|
|
29773
29787
|
let i = nodes.length;
|
|
29774
29788
|
while (i--) {
|
|
29775
29789
|
const n = nodes[i];
|
|
29776
|
-
if (n.optimizeNames(names,
|
|
29790
|
+
if (n.optimizeNames(names, constants3)) continue;
|
|
29777
29791
|
subtractNames(names, n.names);
|
|
29778
29792
|
nodes.splice(i, 1);
|
|
29779
29793
|
}
|
|
@@ -29820,11 +29834,11 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29820
29834
|
if (cond === false || !this.nodes.length) return void 0;
|
|
29821
29835
|
return this;
|
|
29822
29836
|
}
|
|
29823
|
-
optimizeNames(names,
|
|
29837
|
+
optimizeNames(names, constants3) {
|
|
29824
29838
|
var _a;
|
|
29825
|
-
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names,
|
|
29826
|
-
if (!(super.optimizeNames(names,
|
|
29827
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
29839
|
+
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants3);
|
|
29840
|
+
if (!(super.optimizeNames(names, constants3) || this.else)) return;
|
|
29841
|
+
this.condition = optimizeExpr(this.condition, names, constants3);
|
|
29828
29842
|
return this;
|
|
29829
29843
|
}
|
|
29830
29844
|
get names() {
|
|
@@ -29846,9 +29860,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29846
29860
|
render(opts) {
|
|
29847
29861
|
return `for(${this.iteration})` + super.render(opts);
|
|
29848
29862
|
}
|
|
29849
|
-
optimizeNames(names,
|
|
29850
|
-
if (!super.optimizeNames(names,
|
|
29851
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
29863
|
+
optimizeNames(names, constants3) {
|
|
29864
|
+
if (!super.optimizeNames(names, constants3)) return;
|
|
29865
|
+
this.iteration = optimizeExpr(this.iteration, names, constants3);
|
|
29852
29866
|
return this;
|
|
29853
29867
|
}
|
|
29854
29868
|
get names() {
|
|
@@ -29883,9 +29897,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29883
29897
|
render(opts) {
|
|
29884
29898
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
29885
29899
|
}
|
|
29886
|
-
optimizeNames(names,
|
|
29887
|
-
if (!super.optimizeNames(names,
|
|
29888
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
29900
|
+
optimizeNames(names, constants3) {
|
|
29901
|
+
if (!super.optimizeNames(names, constants3)) return;
|
|
29902
|
+
this.iterable = optimizeExpr(this.iterable, names, constants3);
|
|
29889
29903
|
return this;
|
|
29890
29904
|
}
|
|
29891
29905
|
get names() {
|
|
@@ -29924,11 +29938,11 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29924
29938
|
(_b = this.finally) === null || _b === void 0 || _b.optimizeNodes();
|
|
29925
29939
|
return this;
|
|
29926
29940
|
}
|
|
29927
|
-
optimizeNames(names,
|
|
29941
|
+
optimizeNames(names, constants3) {
|
|
29928
29942
|
var _a, _b;
|
|
29929
|
-
super.optimizeNames(names,
|
|
29930
|
-
(_a = this.catch) === null || _a === void 0 || _a.optimizeNames(names,
|
|
29931
|
-
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names,
|
|
29943
|
+
super.optimizeNames(names, constants3);
|
|
29944
|
+
(_a = this.catch) === null || _a === void 0 || _a.optimizeNames(names, constants3);
|
|
29945
|
+
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names, constants3);
|
|
29932
29946
|
return this;
|
|
29933
29947
|
}
|
|
29934
29948
|
get names() {
|
|
@@ -30177,7 +30191,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
30177
30191
|
function addExprNames(names, from) {
|
|
30178
30192
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
30179
30193
|
}
|
|
30180
|
-
function optimizeExpr(expr, names,
|
|
30194
|
+
function optimizeExpr(expr, names, constants3) {
|
|
30181
30195
|
if (expr instanceof code_1.Name) return replaceName(expr);
|
|
30182
30196
|
if (!canOptimize(expr)) return expr;
|
|
30183
30197
|
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
@@ -30187,13 +30201,13 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
30187
30201
|
return items;
|
|
30188
30202
|
}, []));
|
|
30189
30203
|
function replaceName(n) {
|
|
30190
|
-
const c =
|
|
30204
|
+
const c = constants3[n.str];
|
|
30191
30205
|
if (c === void 0 || names[n.str] !== 1) return n;
|
|
30192
30206
|
delete names[n.str];
|
|
30193
30207
|
return c;
|
|
30194
30208
|
}
|
|
30195
30209
|
function canOptimize(e) {
|
|
30196
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
30210
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants3[c.str] !== void 0);
|
|
30197
30211
|
}
|
|
30198
30212
|
}
|
|
30199
30213
|
function subtractNames(names, from) {
|
|
@@ -31853,7 +31867,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31853
31867
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
31854
31868
|
const schOrFunc = root.refs[ref];
|
|
31855
31869
|
if (schOrFunc) return schOrFunc;
|
|
31856
|
-
let _sch =
|
|
31870
|
+
let _sch = resolve8.call(this, root, ref);
|
|
31857
31871
|
if (_sch === void 0) {
|
|
31858
31872
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
31859
31873
|
const { schemaId } = this.opts;
|
|
@@ -31879,7 +31893,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31879
31893
|
function sameSchemaEnv(s1, s2) {
|
|
31880
31894
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
31881
31895
|
}
|
|
31882
|
-
function
|
|
31896
|
+
function resolve8(root, ref) {
|
|
31883
31897
|
let sch;
|
|
31884
31898
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
31885
31899
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -32064,8 +32078,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32064
32078
|
for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
|
|
32065
32079
|
return ind;
|
|
32066
32080
|
}
|
|
32067
|
-
function removeDotSegments(
|
|
32068
|
-
let input =
|
|
32081
|
+
function removeDotSegments(path8) {
|
|
32082
|
+
let input = path8;
|
|
32069
32083
|
const output = [];
|
|
32070
32084
|
let nextSlash = -1;
|
|
32071
32085
|
let len = 0;
|
|
@@ -32218,8 +32232,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32218
32232
|
wsComponent.secure = void 0;
|
|
32219
32233
|
}
|
|
32220
32234
|
if (wsComponent.resourceName) {
|
|
32221
|
-
const [
|
|
32222
|
-
wsComponent.path =
|
|
32235
|
+
const [path8, query2] = wsComponent.resourceName.split("?");
|
|
32236
|
+
wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
|
|
32223
32237
|
wsComponent.query = query2;
|
|
32224
32238
|
wsComponent.resourceName = void 0;
|
|
32225
32239
|
}
|
|
@@ -32325,21 +32339,21 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32325
32339
|
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
|
|
32326
32340
|
const { SCHEMES, getSchemeHandler } = require_schemes();
|
|
32327
32341
|
function normalize(uri, options) {
|
|
32328
|
-
if (typeof uri === "string") uri = serialize(
|
|
32329
|
-
else if (typeof uri === "object") uri =
|
|
32342
|
+
if (typeof uri === "string") uri = serialize(parse3(uri, options), options);
|
|
32343
|
+
else if (typeof uri === "object") uri = parse3(serialize(uri, options), options);
|
|
32330
32344
|
return uri;
|
|
32331
32345
|
}
|
|
32332
|
-
function
|
|
32346
|
+
function resolve8(baseURI, relativeURI, options) {
|
|
32333
32347
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
32334
|
-
const resolved = resolveComponent(
|
|
32348
|
+
const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
32335
32349
|
schemelessOptions.skipEscape = true;
|
|
32336
32350
|
return serialize(resolved, schemelessOptions);
|
|
32337
32351
|
}
|
|
32338
32352
|
function resolveComponent(base, relative3, options, skipNormalization) {
|
|
32339
32353
|
const target = {};
|
|
32340
32354
|
if (!skipNormalization) {
|
|
32341
|
-
base =
|
|
32342
|
-
relative3 =
|
|
32355
|
+
base = parse3(serialize(base, options), options);
|
|
32356
|
+
relative3 = parse3(serialize(relative3, options), options);
|
|
32343
32357
|
}
|
|
32344
32358
|
options = options || {};
|
|
32345
32359
|
if (!options.tolerant && relative3.scheme) {
|
|
@@ -32383,7 +32397,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32383
32397
|
function equal(uriA, uriB, options) {
|
|
32384
32398
|
if (typeof uriA === "string") {
|
|
32385
32399
|
uriA = unescape(uriA);
|
|
32386
|
-
uriA = serialize(normalizeComponentEncoding(
|
|
32400
|
+
uriA = serialize(normalizeComponentEncoding(parse3(uriA, options), true), {
|
|
32387
32401
|
...options,
|
|
32388
32402
|
skipEscape: true
|
|
32389
32403
|
});
|
|
@@ -32393,7 +32407,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32393
32407
|
});
|
|
32394
32408
|
if (typeof uriB === "string") {
|
|
32395
32409
|
uriB = unescape(uriB);
|
|
32396
|
-
uriB = serialize(normalizeComponentEncoding(
|
|
32410
|
+
uriB = serialize(normalizeComponentEncoding(parse3(uriB, options), true), {
|
|
32397
32411
|
...options,
|
|
32398
32412
|
skipEscape: true
|
|
32399
32413
|
});
|
|
@@ -32446,7 +32460,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32446
32460
|
return uriTokens.join("");
|
|
32447
32461
|
}
|
|
32448
32462
|
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
32449
|
-
function
|
|
32463
|
+
function parse3(uri, opts) {
|
|
32450
32464
|
const options = Object.assign({}, opts);
|
|
32451
32465
|
const parsed = {
|
|
32452
32466
|
scheme: void 0,
|
|
@@ -32503,11 +32517,11 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
32503
32517
|
const fastUri = {
|
|
32504
32518
|
SCHEMES,
|
|
32505
32519
|
normalize,
|
|
32506
|
-
resolve:
|
|
32520
|
+
resolve: resolve8,
|
|
32507
32521
|
resolveComponent,
|
|
32508
32522
|
equal,
|
|
32509
32523
|
serialize,
|
|
32510
|
-
parse:
|
|
32524
|
+
parse: parse3
|
|
32511
32525
|
};
|
|
32512
32526
|
module.exports = fastUri;
|
|
32513
32527
|
module.exports.default = fastUri;
|
|
@@ -32920,14 +32934,14 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
32920
32934
|
}
|
|
32921
32935
|
return metaSchema;
|
|
32922
32936
|
}
|
|
32923
|
-
_removeAllSchemas(
|
|
32924
|
-
for (const keyRef in
|
|
32925
|
-
const sch =
|
|
32937
|
+
_removeAllSchemas(schemas2, regex) {
|
|
32938
|
+
for (const keyRef in schemas2) {
|
|
32939
|
+
const sch = schemas2[keyRef];
|
|
32926
32940
|
if (!regex || regex.test(keyRef)) {
|
|
32927
|
-
if (typeof sch == "string") delete
|
|
32941
|
+
if (typeof sch == "string") delete schemas2[keyRef];
|
|
32928
32942
|
else if (sch && !sch.meta) {
|
|
32929
32943
|
this._cache.delete(sch.schema);
|
|
32930
|
-
delete
|
|
32944
|
+
delete schemas2[keyRef];
|
|
32931
32945
|
}
|
|
32932
32946
|
}
|
|
32933
32947
|
}
|
|
@@ -36631,11 +36645,11 @@ var EventSource = class extends EventTarget {
|
|
|
36631
36645
|
return;
|
|
36632
36646
|
}
|
|
36633
36647
|
const decoder = new TextDecoder(), reader = body.getReader();
|
|
36634
|
-
let
|
|
36648
|
+
let open4 = true;
|
|
36635
36649
|
do {
|
|
36636
36650
|
const { done, value } = await reader.read();
|
|
36637
|
-
value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (
|
|
36638
|
-
} while (
|
|
36651
|
+
value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open4 = false, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
|
|
36652
|
+
} while (open4);
|
|
36639
36653
|
}), __privateAdd(this, _onFetchError, (err) => {
|
|
36640
36654
|
__privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));
|
|
36641
36655
|
}), __privateAdd(this, _onEvent, (event) => {
|
|
@@ -38368,14 +38382,14 @@ var ProbeWindow = class ProbeWindow2 {
|
|
|
38368
38382
|
*/
|
|
38369
38383
|
async exchange(buildRequest, timeoutMs) {
|
|
38370
38384
|
const id = `server-discover-probe-${++this._probeCounter}`;
|
|
38371
|
-
return new Promise((
|
|
38385
|
+
return new Promise((resolve8) => {
|
|
38372
38386
|
let settled = false;
|
|
38373
38387
|
const settle = (reply) => {
|
|
38374
38388
|
if (settled) return;
|
|
38375
38389
|
settled = true;
|
|
38376
38390
|
clearTimeout(timer);
|
|
38377
38391
|
if (this._pending?.id === id) this._pending = void 0;
|
|
38378
|
-
|
|
38392
|
+
resolve8(reply);
|
|
38379
38393
|
};
|
|
38380
38394
|
const timer = setTimeout(() => settle({ kind: "timeout" }), timeoutMs);
|
|
38381
38395
|
this._pending = {
|
|
@@ -39589,13 +39603,13 @@ var Client = class extends Protocol {
|
|
|
39589
39603
|
let onCallerAbort;
|
|
39590
39604
|
let resolveOpening;
|
|
39591
39605
|
let rejectOpening;
|
|
39592
|
-
const opening = new Promise((
|
|
39593
|
-
resolveOpening =
|
|
39606
|
+
const opening = new Promise((resolve8, reject) => {
|
|
39607
|
+
resolveOpening = resolve8;
|
|
39594
39608
|
rejectOpening = reject;
|
|
39595
39609
|
});
|
|
39596
39610
|
let resolveClosed;
|
|
39597
|
-
const closed = new Promise((
|
|
39598
|
-
resolveClosed =
|
|
39611
|
+
const closed = new Promise((resolve8) => {
|
|
39612
|
+
resolveClosed = resolve8;
|
|
39599
39613
|
});
|
|
39600
39614
|
const settle = (outcome) => {
|
|
39601
39615
|
if (state === "closed") return;
|
|
@@ -40151,7 +40165,7 @@ var SSEClientTransport = class {
|
|
|
40151
40165
|
const eventSourceFetch = this._eventSourceInit?.fetch;
|
|
40152
40166
|
const fetchImpl = this._redirects(eventSourceFetch ? this._dpop?.(eventSourceFetch) ?? eventSourceFetch : this._fetch ?? fetch);
|
|
40153
40167
|
let redirect;
|
|
40154
|
-
return new Promise((
|
|
40168
|
+
return new Promise((resolve8, reject) => {
|
|
40155
40169
|
this._eventSource = new EventSource(this._url.href, {
|
|
40156
40170
|
...this._eventSourceInit,
|
|
40157
40171
|
fetch: async (url3, init) => {
|
|
@@ -40185,7 +40199,7 @@ var SSEClientTransport = class {
|
|
|
40185
40199
|
response,
|
|
40186
40200
|
serverUrl: this._url,
|
|
40187
40201
|
fetchFn: this._fetchWithInit
|
|
40188
|
-
}).then(() => this._startOrAuth().then(
|
|
40202
|
+
}).then(() => this._startOrAuth().then(resolve8, reject), (error$2) => {
|
|
40189
40203
|
this._connectAuthRetried = false;
|
|
40190
40204
|
markAuthSeamEscape(error$2);
|
|
40191
40205
|
this.onerror?.(error$2);
|
|
@@ -40223,7 +40237,7 @@ var SSEClientTransport = class {
|
|
|
40223
40237
|
this.close();
|
|
40224
40238
|
return;
|
|
40225
40239
|
}
|
|
40226
|
-
|
|
40240
|
+
resolve8();
|
|
40227
40241
|
});
|
|
40228
40242
|
this._eventSource.onmessage = (event) => {
|
|
40229
40243
|
const messageEvent = event;
|
|
@@ -40972,7 +40986,7 @@ var StdioClientTransport = class {
|
|
|
40972
40986
|
*/
|
|
40973
40987
|
async start() {
|
|
40974
40988
|
if (this._process) throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
40975
|
-
return new Promise((
|
|
40989
|
+
return new Promise((resolve8, reject) => {
|
|
40976
40990
|
this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
|
|
40977
40991
|
env: {
|
|
40978
40992
|
...getDefaultEnvironment(),
|
|
@@ -40992,7 +41006,7 @@ var StdioClientTransport = class {
|
|
|
40992
41006
|
this.onerror?.(error);
|
|
40993
41007
|
});
|
|
40994
41008
|
this._process.on("spawn", () => {
|
|
40995
|
-
|
|
41009
|
+
resolve8();
|
|
40996
41010
|
});
|
|
40997
41011
|
this._process.on("close", (_code) => {
|
|
40998
41012
|
this._process = void 0;
|
|
@@ -41057,7 +41071,7 @@ var StdioClientTransport = class {
|
|
|
41057
41071
|
const proc = this._process;
|
|
41058
41072
|
this._process = void 0;
|
|
41059
41073
|
if (proc && proc.exitCode === null && proc.signalCode === null) {
|
|
41060
|
-
const exited = new Promise((
|
|
41074
|
+
const exited = new Promise((resolve8) => proc.once("exit", () => resolve8()));
|
|
41061
41075
|
try {
|
|
41062
41076
|
proc.stdin?.end();
|
|
41063
41077
|
} catch {
|
|
@@ -41066,7 +41080,7 @@ var StdioClientTransport = class {
|
|
|
41066
41080
|
proc.kill("SIGTERM");
|
|
41067
41081
|
} catch {
|
|
41068
41082
|
}
|
|
41069
|
-
await Promise.race([exited, new Promise((
|
|
41083
|
+
await Promise.race([exited, new Promise((resolve8) => setTimeout(resolve8, 1e3).unref())]);
|
|
41070
41084
|
if (proc.exitCode === null && proc.signalCode === null) try {
|
|
41071
41085
|
proc.kill("SIGKILL");
|
|
41072
41086
|
} catch {
|
|
@@ -41091,22 +41105,22 @@ var StdioClientTransport = class {
|
|
|
41091
41105
|
if (this._process) {
|
|
41092
41106
|
const processToClose = this._process;
|
|
41093
41107
|
this._process = void 0;
|
|
41094
|
-
const closePromise = new Promise((
|
|
41108
|
+
const closePromise = new Promise((resolve8) => {
|
|
41095
41109
|
processToClose.once("close", () => {
|
|
41096
|
-
|
|
41110
|
+
resolve8();
|
|
41097
41111
|
});
|
|
41098
41112
|
});
|
|
41099
41113
|
try {
|
|
41100
41114
|
processToClose.stdin?.end();
|
|
41101
41115
|
} catch {
|
|
41102
41116
|
}
|
|
41103
|
-
await Promise.race([closePromise, new Promise((
|
|
41117
|
+
await Promise.race([closePromise, new Promise((resolve8) => setTimeout(resolve8, 2e3).unref())]);
|
|
41104
41118
|
if (processToClose.exitCode === null) {
|
|
41105
41119
|
try {
|
|
41106
41120
|
processToClose.kill("SIGTERM");
|
|
41107
41121
|
} catch {
|
|
41108
41122
|
}
|
|
41109
|
-
await Promise.race([closePromise, new Promise((
|
|
41123
|
+
await Promise.race([closePromise, new Promise((resolve8) => setTimeout(resolve8, 2e3).unref())]);
|
|
41110
41124
|
}
|
|
41111
41125
|
if (processToClose.exitCode === null) try {
|
|
41112
41126
|
processToClose.kill("SIGKILL");
|
|
@@ -41116,11 +41130,11 @@ var StdioClientTransport = class {
|
|
|
41116
41130
|
this._readBuffer.clear();
|
|
41117
41131
|
}
|
|
41118
41132
|
send(message) {
|
|
41119
|
-
return new Promise((
|
|
41133
|
+
return new Promise((resolve8) => {
|
|
41120
41134
|
if (!this._process?.stdin) throw new SdkError(SdkErrorCode.NotConnected, "Not connected");
|
|
41121
41135
|
const json = serializeMessage(message);
|
|
41122
|
-
if (this._process.stdin.write(json))
|
|
41123
|
-
else this._process.stdin.once("drain",
|
|
41136
|
+
if (this._process.stdin.write(json)) resolve8();
|
|
41137
|
+
else this._process.stdin.once("drain", resolve8);
|
|
41124
41138
|
});
|
|
41125
41139
|
}
|
|
41126
41140
|
};
|
|
@@ -41141,13 +41155,13 @@ var UnixSocketClientTransport = class {
|
|
|
41141
41155
|
if (this.socket) {
|
|
41142
41156
|
throw new Error("UnixSocketClientTransport already started");
|
|
41143
41157
|
}
|
|
41144
|
-
await new Promise((
|
|
41158
|
+
await new Promise((resolve8, reject) => {
|
|
41145
41159
|
const socket = createConnection(this.socketPath);
|
|
41146
41160
|
this.socket = socket;
|
|
41147
41161
|
let connected = false;
|
|
41148
41162
|
socket.once("connect", () => {
|
|
41149
41163
|
connected = true;
|
|
41150
|
-
|
|
41164
|
+
resolve8();
|
|
41151
41165
|
});
|
|
41152
41166
|
socket.on("data", (chunk) => {
|
|
41153
41167
|
try {
|
|
@@ -41179,12 +41193,12 @@ var UnixSocketClientTransport = class {
|
|
|
41179
41193
|
this.socket = void 0;
|
|
41180
41194
|
this.readBuffer.clear();
|
|
41181
41195
|
if (!socket || socket.destroyed) return;
|
|
41182
|
-
await new Promise((
|
|
41196
|
+
await new Promise((resolve8) => {
|
|
41183
41197
|
const timeout = setTimeout(() => socket.destroy(), 2e3);
|
|
41184
41198
|
timeout.unref();
|
|
41185
41199
|
socket.once("close", () => {
|
|
41186
41200
|
clearTimeout(timeout);
|
|
41187
|
-
|
|
41201
|
+
resolve8();
|
|
41188
41202
|
});
|
|
41189
41203
|
socket.end();
|
|
41190
41204
|
});
|
|
@@ -41192,10 +41206,10 @@ var UnixSocketClientTransport = class {
|
|
|
41192
41206
|
async send(message) {
|
|
41193
41207
|
const socket = this.socket;
|
|
41194
41208
|
if (!socket || socket.destroyed) throw new Error("Unix socket is not connected");
|
|
41195
|
-
await new Promise((
|
|
41209
|
+
await new Promise((resolve8, reject) => {
|
|
41196
41210
|
socket.write(serializeMessage(message), (error) => {
|
|
41197
41211
|
if (error) reject(error);
|
|
41198
|
-
else
|
|
41212
|
+
else resolve8();
|
|
41199
41213
|
});
|
|
41200
41214
|
});
|
|
41201
41215
|
}
|
|
@@ -41360,7 +41374,7 @@ function throwIfAborted(signal) {
|
|
|
41360
41374
|
async function abortable(promise, signal) {
|
|
41361
41375
|
if (!signal) return promise;
|
|
41362
41376
|
throwIfAborted(signal);
|
|
41363
|
-
return await new Promise((
|
|
41377
|
+
return await new Promise((resolve8, reject) => {
|
|
41364
41378
|
let settled = false;
|
|
41365
41379
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
41366
41380
|
const onAbort = () => {
|
|
@@ -41375,7 +41389,7 @@ async function abortable(promise, signal) {
|
|
|
41375
41389
|
if (settled) return;
|
|
41376
41390
|
settled = true;
|
|
41377
41391
|
cleanup();
|
|
41378
|
-
|
|
41392
|
+
resolve8(value);
|
|
41379
41393
|
},
|
|
41380
41394
|
(error) => {
|
|
41381
41395
|
if (settled) return;
|
|
@@ -41559,7 +41573,7 @@ var FORCE_CACHE_TIMEOUT_MS = 3e4;
|
|
|
41559
41573
|
async function forceNpxCache(packageSpec, signal) {
|
|
41560
41574
|
throwIfAborted(signal);
|
|
41561
41575
|
try {
|
|
41562
|
-
await new Promise((
|
|
41576
|
+
await new Promise((resolve8, reject) => {
|
|
41563
41577
|
const proc = (0, import_cross_spawn2.default)(
|
|
41564
41578
|
"npm",
|
|
41565
41579
|
["exec", "--yes", "--package", packageSpec, "--", "node", "-e", "1"],
|
|
@@ -41578,7 +41592,7 @@ async function forceNpxCache(packageSpec, signal) {
|
|
|
41578
41592
|
proc.on("close", () => {
|
|
41579
41593
|
clearTimeout(timer);
|
|
41580
41594
|
signal?.removeEventListener("abort", abort);
|
|
41581
|
-
|
|
41595
|
+
resolve8();
|
|
41582
41596
|
});
|
|
41583
41597
|
proc.on("error", (err) => {
|
|
41584
41598
|
clearTimeout(timer);
|
|
@@ -41702,8 +41716,8 @@ function getNpmCacheDir() {
|
|
|
41702
41716
|
try {
|
|
41703
41717
|
const result = import_cross_spawn2.default.sync("npm", ["config", "get", "cache"], { encoding: "utf-8" });
|
|
41704
41718
|
if (result.status === 0) {
|
|
41705
|
-
const
|
|
41706
|
-
npmCacheDirCached =
|
|
41719
|
+
const path8 = String(result.stdout).trim();
|
|
41720
|
+
npmCacheDirCached = path8 || null;
|
|
41707
41721
|
return npmCacheDirCached;
|
|
41708
41722
|
}
|
|
41709
41723
|
} catch {
|
|
@@ -41791,16 +41805,16 @@ function saveCacheEntry(key, entry) {
|
|
|
41791
41805
|
} catch {
|
|
41792
41806
|
}
|
|
41793
41807
|
}
|
|
41794
|
-
function safeRealpath(
|
|
41808
|
+
function safeRealpath(path8) {
|
|
41795
41809
|
try {
|
|
41796
|
-
return realpathSync(
|
|
41810
|
+
return realpathSync(path8);
|
|
41797
41811
|
} catch {
|
|
41798
41812
|
return "";
|
|
41799
41813
|
}
|
|
41800
41814
|
}
|
|
41801
|
-
function safeStatMtime(
|
|
41815
|
+
function safeStatMtime(path8) {
|
|
41802
41816
|
try {
|
|
41803
|
-
return statSync(
|
|
41817
|
+
return statSync(path8).mtimeMs;
|
|
41804
41818
|
} catch {
|
|
41805
41819
|
return 0;
|
|
41806
41820
|
}
|
|
@@ -41999,12 +42013,12 @@ function getKeyringEntry(account) {
|
|
|
41999
42013
|
throw new Error("OAuth secure credential storage is unavailable. Configure the OS credential store and retry authentication.", { cause: error });
|
|
42000
42014
|
}
|
|
42001
42015
|
}
|
|
42002
|
-
function loadKeyringEntryClass(keyringRequire = require2,
|
|
42016
|
+
function loadKeyringEntryClass(keyringRequire = require2, platform4 = process.platform, arch3 = process.arch) {
|
|
42003
42017
|
try {
|
|
42004
42018
|
return keyringRequire("@napi-rs/keyring").Entry;
|
|
42005
42019
|
} catch (loaderError) {
|
|
42006
42020
|
try {
|
|
42007
|
-
return loadKeyringNativeBindingFallback(keyringRequire,
|
|
42021
|
+
return loadKeyringNativeBindingFallback(keyringRequire, platform4, arch3).Entry;
|
|
42008
42022
|
} catch (fallbackError) {
|
|
42009
42023
|
throw new Error(`Failed to load @napi-rs/keyring; absolute-path native binding fallback also failed: ${formatErrorMessage(fallbackError)}`, {
|
|
42010
42024
|
cause: loaderError
|
|
@@ -42012,10 +42026,10 @@ function loadKeyringEntryClass(keyringRequire = require2, platform3 = process.pl
|
|
|
42012
42026
|
}
|
|
42013
42027
|
}
|
|
42014
42028
|
}
|
|
42015
|
-
function loadKeyringNativeBindingFallback(keyringRequire,
|
|
42016
|
-
const targets = getKeyringNativeBindingTargets(
|
|
42029
|
+
function loadKeyringNativeBindingFallback(keyringRequire, platform4, arch3) {
|
|
42030
|
+
const targets = getKeyringNativeBindingTargets(platform4, arch3);
|
|
42017
42031
|
if (targets.length === 0) {
|
|
42018
|
-
throw new Error(`Unsupported @napi-rs/keyring native binding target: ${
|
|
42032
|
+
throw new Error(`Unsupported @napi-rs/keyring native binding target: ${platform4}-${arch3}`);
|
|
42019
42033
|
}
|
|
42020
42034
|
let lastError;
|
|
42021
42035
|
for (const target of targets) {
|
|
@@ -42028,29 +42042,29 @@ function loadKeyringNativeBindingFallback(keyringRequire, platform3, arch2) {
|
|
|
42028
42042
|
}
|
|
42029
42043
|
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
42030
42044
|
}
|
|
42031
|
-
function getKeyringNativeBindingTargets(
|
|
42032
|
-
return getKeyringNativeBindingSuffixes(
|
|
42045
|
+
function getKeyringNativeBindingTargets(platform4, arch3) {
|
|
42046
|
+
return getKeyringNativeBindingSuffixes(platform4, arch3).map((suffix) => ({
|
|
42033
42047
|
packageName: `@napi-rs/keyring-${suffix}`,
|
|
42034
42048
|
bindingFile: `keyring.${suffix}.node`
|
|
42035
42049
|
}));
|
|
42036
42050
|
}
|
|
42037
|
-
function getKeyringNativeBindingSuffixes(
|
|
42038
|
-
if (
|
|
42039
|
-
if (
|
|
42040
|
-
if (
|
|
42051
|
+
function getKeyringNativeBindingSuffixes(platform4, arch3) {
|
|
42052
|
+
if (platform4 === "darwin") {
|
|
42053
|
+
if (arch3 === "arm64") return ["darwin-arm64"];
|
|
42054
|
+
if (arch3 === "x64") return ["darwin-x64"];
|
|
42041
42055
|
}
|
|
42042
|
-
if (
|
|
42043
|
-
if (
|
|
42044
|
-
if (
|
|
42045
|
-
if (
|
|
42056
|
+
if (platform4 === "win32") {
|
|
42057
|
+
if (arch3 === "arm64") return ["win32-arm64-msvc"];
|
|
42058
|
+
if (arch3 === "x64") return ["win32-x64-msvc"];
|
|
42059
|
+
if (arch3 === "ia32") return ["win32-ia32-msvc"];
|
|
42046
42060
|
}
|
|
42047
|
-
if (
|
|
42048
|
-
if (
|
|
42049
|
-
if (
|
|
42050
|
-
if (
|
|
42051
|
-
if (
|
|
42061
|
+
if (platform4 === "linux") {
|
|
42062
|
+
if (arch3 === "arm64") return ["linux-arm64-gnu", "linux-arm64-musl"];
|
|
42063
|
+
if (arch3 === "arm") return ["linux-arm-gnueabihf"];
|
|
42064
|
+
if (arch3 === "riscv64") return ["linux-riscv64-gnu"];
|
|
42065
|
+
if (arch3 === "x64") return ["linux-x64-gnu", "linux-x64-musl"];
|
|
42052
42066
|
}
|
|
42053
|
-
if (
|
|
42067
|
+
if (platform4 === "freebsd" && arch3 === "x64") return ["freebsd-x64"];
|
|
42054
42068
|
return [];
|
|
42055
42069
|
}
|
|
42056
42070
|
function formatErrorMessage(error) {
|
|
@@ -42545,8 +42559,8 @@ function setOAuthCallbackPort(port2) {
|
|
|
42545
42559
|
function getOAuthCallbackPath() {
|
|
42546
42560
|
return oauthCallbackPath;
|
|
42547
42561
|
}
|
|
42548
|
-
function setOAuthCallbackPath(
|
|
42549
|
-
oauthCallbackPath =
|
|
42562
|
+
function setOAuthCallbackPath(path8) {
|
|
42563
|
+
oauthCallbackPath = path8.startsWith("/") ? path8 : `/${path8}`;
|
|
42550
42564
|
}
|
|
42551
42565
|
var reservedAuthorizationParams = /* @__PURE__ */ new Set([
|
|
42552
42566
|
"client_id",
|
|
@@ -43491,14 +43505,14 @@ var baseOpen = async (options) => {
|
|
|
43491
43505
|
}
|
|
43492
43506
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
43493
43507
|
if (options.wait) {
|
|
43494
|
-
return new Promise((
|
|
43508
|
+
return new Promise((resolve8, reject) => {
|
|
43495
43509
|
subprocess.once("error", reject);
|
|
43496
43510
|
subprocess.once("close", (exitCode) => {
|
|
43497
43511
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
43498
43512
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
43499
43513
|
return;
|
|
43500
43514
|
}
|
|
43501
|
-
|
|
43515
|
+
resolve8(subprocess);
|
|
43502
43516
|
});
|
|
43503
43517
|
});
|
|
43504
43518
|
}
|
|
@@ -43826,12 +43840,12 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43826
43840
|
const candidateServer = createServer2(handleRequest);
|
|
43827
43841
|
const listenPort = strictPort ? requiredPort : 0;
|
|
43828
43842
|
try {
|
|
43829
|
-
await new Promise((
|
|
43843
|
+
await new Promise((resolve8, reject) => {
|
|
43830
43844
|
candidateServer.once("error", (err) => {
|
|
43831
43845
|
reject(err);
|
|
43832
43846
|
});
|
|
43833
43847
|
candidateServer.listen(listenPort, requestedHost, () => {
|
|
43834
|
-
|
|
43848
|
+
resolve8();
|
|
43835
43849
|
});
|
|
43836
43850
|
});
|
|
43837
43851
|
if (strictPort) {
|
|
@@ -43844,8 +43858,8 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43844
43858
|
setOAuthCallbackPort(address.port);
|
|
43845
43859
|
}
|
|
43846
43860
|
if (previousServer && (needsStrictRebind || needsHostSwitch)) {
|
|
43847
|
-
await new Promise((
|
|
43848
|
-
previousServer.close(() =>
|
|
43861
|
+
await new Promise((resolve8) => {
|
|
43862
|
+
previousServer.close(() => resolve8());
|
|
43849
43863
|
});
|
|
43850
43864
|
}
|
|
43851
43865
|
callbackServerHost = requestedHost;
|
|
@@ -43861,8 +43875,8 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43861
43875
|
reservedAuthStates.delete(reservedState);
|
|
43862
43876
|
}
|
|
43863
43877
|
const nodeError = error;
|
|
43864
|
-
await new Promise((
|
|
43865
|
-
candidateServer.close(() =>
|
|
43878
|
+
await new Promise((resolve8) => {
|
|
43879
|
+
candidateServer.close(() => resolve8());
|
|
43866
43880
|
});
|
|
43867
43881
|
if (strictPort && nodeError.code === "EADDRINUSE") {
|
|
43868
43882
|
throw new Error(
|
|
@@ -43878,14 +43892,14 @@ function releaseCallbackServer(oauthState) {
|
|
|
43878
43892
|
}
|
|
43879
43893
|
function waitForCallback(oauthState) {
|
|
43880
43894
|
reservedAuthStates.delete(oauthState);
|
|
43881
|
-
return new Promise((
|
|
43895
|
+
return new Promise((resolve8, reject) => {
|
|
43882
43896
|
const timeout = setTimeout(() => {
|
|
43883
43897
|
if (pendingAuths.has(oauthState)) {
|
|
43884
43898
|
pendingAuths.delete(oauthState);
|
|
43885
43899
|
reject(new Error("OAuth callback timeout - authorization took too long"));
|
|
43886
43900
|
}
|
|
43887
43901
|
}, CALLBACK_TIMEOUT_MS);
|
|
43888
|
-
pendingAuths.set(oauthState, { resolve:
|
|
43902
|
+
pendingAuths.set(oauthState, { resolve: resolve8, reject, timeout });
|
|
43889
43903
|
});
|
|
43890
43904
|
}
|
|
43891
43905
|
function cancelPendingCallback(oauthState) {
|
|
@@ -43910,9 +43924,9 @@ function stopCallbackServer() {
|
|
|
43910
43924
|
});
|
|
43911
43925
|
}
|
|
43912
43926
|
if (server) {
|
|
43913
|
-
await new Promise((
|
|
43927
|
+
await new Promise((resolve8) => {
|
|
43914
43928
|
server.close(() => {
|
|
43915
|
-
|
|
43929
|
+
resolve8();
|
|
43916
43930
|
});
|
|
43917
43931
|
});
|
|
43918
43932
|
server = void 0;
|
|
@@ -44819,20 +44833,20 @@ function getKeyringEntry2(account) {
|
|
|
44819
44833
|
throw new Error("Bearer token secure credential storage is unavailable. Configure the OS credential store and retry.", { cause: error });
|
|
44820
44834
|
}
|
|
44821
44835
|
}
|
|
44822
|
-
function loadKeyringEntryClass2(keyringRequire = require3,
|
|
44836
|
+
function loadKeyringEntryClass2(keyringRequire = require3, platform4 = process.platform, arch3 = process.arch) {
|
|
44823
44837
|
try {
|
|
44824
44838
|
return keyringRequire("@napi-rs/keyring").Entry;
|
|
44825
44839
|
} catch (loaderError) {
|
|
44826
44840
|
try {
|
|
44827
|
-
return loadKeyringNativeBindingFallback2(keyringRequire,
|
|
44841
|
+
return loadKeyringNativeBindingFallback2(keyringRequire, platform4, arch3).Entry;
|
|
44828
44842
|
} catch (fallbackError) {
|
|
44829
44843
|
const message = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
44830
44844
|
throw new Error(`Failed to load @napi-rs/keyring; absolute-path native binding fallback also failed: ${message}`, { cause: loaderError });
|
|
44831
44845
|
}
|
|
44832
44846
|
}
|
|
44833
44847
|
}
|
|
44834
|
-
function loadKeyringNativeBindingFallback2(keyringRequire,
|
|
44835
|
-
const targets = getKeyringNativeBindingSuffixes2(
|
|
44848
|
+
function loadKeyringNativeBindingFallback2(keyringRequire, platform4, arch3) {
|
|
44849
|
+
const targets = getKeyringNativeBindingSuffixes2(platform4, arch3).map((suffix) => ({
|
|
44836
44850
|
packageName: `@napi-rs/keyring-${suffix}`,
|
|
44837
44851
|
bindingFile: `keyring.${suffix}.node`
|
|
44838
44852
|
}));
|
|
@@ -44847,23 +44861,23 @@ function loadKeyringNativeBindingFallback2(keyringRequire, platform3, arch2) {
|
|
|
44847
44861
|
}
|
|
44848
44862
|
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
44849
44863
|
}
|
|
44850
|
-
function getKeyringNativeBindingSuffixes2(
|
|
44851
|
-
if (
|
|
44852
|
-
if (
|
|
44853
|
-
if (
|
|
44864
|
+
function getKeyringNativeBindingSuffixes2(platform4, arch3) {
|
|
44865
|
+
if (platform4 === "darwin") {
|
|
44866
|
+
if (arch3 === "arm64") return ["darwin-arm64"];
|
|
44867
|
+
if (arch3 === "x64") return ["darwin-x64"];
|
|
44854
44868
|
}
|
|
44855
|
-
if (
|
|
44856
|
-
if (
|
|
44857
|
-
if (
|
|
44858
|
-
if (
|
|
44869
|
+
if (platform4 === "win32") {
|
|
44870
|
+
if (arch3 === "arm64") return ["win32-arm64-msvc"];
|
|
44871
|
+
if (arch3 === "x64") return ["win32-x64-msvc"];
|
|
44872
|
+
if (arch3 === "ia32") return ["win32-ia32-msvc"];
|
|
44859
44873
|
}
|
|
44860
|
-
if (
|
|
44861
|
-
if (
|
|
44862
|
-
if (
|
|
44863
|
-
if (
|
|
44864
|
-
if (
|
|
44874
|
+
if (platform4 === "linux") {
|
|
44875
|
+
if (arch3 === "arm64") return ["linux-arm64-gnu", "linux-arm64-musl"];
|
|
44876
|
+
if (arch3 === "arm") return ["linux-arm-gnueabihf"];
|
|
44877
|
+
if (arch3 === "riscv64") return ["linux-riscv64-gnu"];
|
|
44878
|
+
if (arch3 === "x64") return ["linux-x64-gnu", "linux-x64-musl"];
|
|
44865
44879
|
}
|
|
44866
|
-
if (
|
|
44880
|
+
if (platform4 === "freebsd" && arch3 === "x64") return ["freebsd-x64"];
|
|
44867
44881
|
return [];
|
|
44868
44882
|
}
|
|
44869
44883
|
function getBearerAccount(serverName) {
|
|
@@ -45517,14 +45531,14 @@ var McpTraceWriter = class {
|
|
|
45517
45531
|
this.options = options;
|
|
45518
45532
|
this.maxBytes = boundedPositiveInteger(options.maxBytes, DEFAULT_MCP_TRACE_MAX_BYTES);
|
|
45519
45533
|
this.maxEvents = boundedPositiveInteger(options.maxEvents, DEFAULT_MCP_TRACE_MAX_EVENTS);
|
|
45520
|
-
this.append = options.appendFile ?? (async (
|
|
45521
|
-
await appendFile2(
|
|
45534
|
+
this.append = options.appendFile ?? (async (path8, data, appendOptions) => {
|
|
45535
|
+
await appendFile2(path8, data, appendOptions);
|
|
45522
45536
|
});
|
|
45523
|
-
this.resetFile = options.writeFile ?? (async (
|
|
45524
|
-
await writeFile6(
|
|
45537
|
+
this.resetFile = options.writeFile ?? (async (path8, data, writeOptions) => {
|
|
45538
|
+
await writeFile6(path8, data, writeOptions);
|
|
45525
45539
|
});
|
|
45526
|
-
this.makeDirectory = options.mkdir ?? (async (
|
|
45527
|
-
await mkdir11(
|
|
45540
|
+
this.makeDirectory = options.mkdir ?? (async (path8) => {
|
|
45541
|
+
await mkdir11(path8, { recursive: true });
|
|
45528
45542
|
return void 0;
|
|
45529
45543
|
});
|
|
45530
45544
|
this.fileReady = this.makeDirectory(dirname9(this.options.filePath), { recursive: true }).then(() => this.resetFile(this.options.filePath, "", { encoding: "utf8" })).catch(() => {
|
|
@@ -45801,7 +45815,7 @@ function resolvedCommand(config) {
|
|
|
45801
45815
|
async function invokeRequestHeadersCommand(config, envelope, signal) {
|
|
45802
45816
|
const resolved = resolvedCommand(config);
|
|
45803
45817
|
if (USE_PROCESS_GROUP) assertPosixProcessDiscoveryAvailable();
|
|
45804
|
-
return new Promise((
|
|
45818
|
+
return new Promise((resolve8, reject) => {
|
|
45805
45819
|
let stdout = Buffer.alloc(0);
|
|
45806
45820
|
let settled = false;
|
|
45807
45821
|
const cleanupToken = randomUUID4();
|
|
@@ -45830,7 +45844,7 @@ async function invokeRequestHeadersCommand(config, envelope, signal) {
|
|
|
45830
45844
|
if (descendantTracker) clearInterval(descendantTracker);
|
|
45831
45845
|
signal.removeEventListener("abort", abort);
|
|
45832
45846
|
if (result.status === "error") reject(result.error);
|
|
45833
|
-
else
|
|
45847
|
+
else resolve8(result.headers);
|
|
45834
45848
|
};
|
|
45835
45849
|
const finishAfterKill = (result) => {
|
|
45836
45850
|
try {
|
|
@@ -48663,10 +48677,10 @@ function getOnboardingStatePath() {
|
|
|
48663
48677
|
return getAgentPath("mcp-onboarding.json");
|
|
48664
48678
|
}
|
|
48665
48679
|
function loadOnboardingState() {
|
|
48666
|
-
const
|
|
48667
|
-
if (!existsSync12(
|
|
48680
|
+
const path8 = getOnboardingStatePath();
|
|
48681
|
+
if (!existsSync12(path8)) return { ...DEFAULT_STATE };
|
|
48668
48682
|
try {
|
|
48669
|
-
const raw = JSON.parse(readFileSync4(
|
|
48683
|
+
const raw = JSON.parse(readFileSync4(path8, "utf-8"));
|
|
48670
48684
|
if (!raw || typeof raw !== "object") return { ...DEFAULT_STATE };
|
|
48671
48685
|
return {
|
|
48672
48686
|
version: 1,
|
|
@@ -48679,12 +48693,12 @@ function loadOnboardingState() {
|
|
|
48679
48693
|
}
|
|
48680
48694
|
}
|
|
48681
48695
|
function saveOnboardingState(state) {
|
|
48682
|
-
const
|
|
48683
|
-
mkdirSync5(dirname10(
|
|
48684
|
-
const tmpPath = `${
|
|
48696
|
+
const path8 = getOnboardingStatePath();
|
|
48697
|
+
mkdirSync5(dirname10(path8), { recursive: true });
|
|
48698
|
+
const tmpPath = `${path8}.${process.pid}.tmp`;
|
|
48685
48699
|
writeFileSync4(tmpPath, `${JSON.stringify(state, null, 2)}
|
|
48686
48700
|
`, "utf-8");
|
|
48687
|
-
renameSync2(tmpPath,
|
|
48701
|
+
renameSync2(tmpPath, path8);
|
|
48688
48702
|
}
|
|
48689
48703
|
function updateOnboardingState(updater) {
|
|
48690
48704
|
const next = updater(loadOnboardingState());
|
|
@@ -49097,23 +49111,23 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
|
|
|
49097
49111
|
return result;
|
|
49098
49112
|
},
|
|
49099
49113
|
scaffoldConfig: async (target) => {
|
|
49100
|
-
const
|
|
49114
|
+
const path8 = writeStarterSharedConfig(target, ctx.cwd);
|
|
49101
49115
|
configChanged = true;
|
|
49102
|
-
return { path:
|
|
49116
|
+
return { path: path8 };
|
|
49103
49117
|
},
|
|
49104
49118
|
addRepoPrompt: async (target) => {
|
|
49105
49119
|
const repoPrompt = getMcpDiscoverySummary(configOverridePath, ctx.cwd, options).repoPrompt;
|
|
49106
49120
|
if (!repoPrompt.entry || !repoPrompt.targetPath || !repoPrompt.serverName) {
|
|
49107
49121
|
throw new Error("RepoPrompt is not available to add from this setup screen.");
|
|
49108
49122
|
}
|
|
49109
|
-
const
|
|
49123
|
+
const path8 = writeSharedServerEntry(getSharedConfigPath(target, ctx.cwd), repoPrompt.serverName, repoPrompt.entry);
|
|
49110
49124
|
configChanged = true;
|
|
49111
|
-
return { path:
|
|
49125
|
+
return { path: path8, serverName: repoPrompt.serverName };
|
|
49112
49126
|
},
|
|
49113
49127
|
addKnownServer: async (preset, target) => {
|
|
49114
|
-
const
|
|
49128
|
+
const path8 = writeSharedServerEntry(getSharedConfigPath(target, ctx.cwd), preset.id, preset.entry);
|
|
49115
49129
|
configChanged = true;
|
|
49116
|
-
return { path:
|
|
49130
|
+
return { path: path8, serverName: preset.name };
|
|
49117
49131
|
},
|
|
49118
49132
|
openPath: async (targetPath) => {
|
|
49119
49133
|
await openPath(pi, targetPath);
|
|
@@ -49122,12 +49136,12 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
|
|
|
49122
49136
|
markSetupCompleted(discovery.fingerprint);
|
|
49123
49137
|
}
|
|
49124
49138
|
};
|
|
49125
|
-
return new Promise((
|
|
49139
|
+
return new Promise((resolve8) => {
|
|
49126
49140
|
ctx.ui.custom(
|
|
49127
49141
|
(tui, _theme, keybindings, done) => {
|
|
49128
49142
|
return createMcpSetupPanel(discovery, callbacks, { mode, onboardingState, keybindings }, tui, () => {
|
|
49129
49143
|
done(void 0);
|
|
49130
|
-
|
|
49144
|
+
resolve8({ configChanged });
|
|
49131
49145
|
});
|
|
49132
49146
|
},
|
|
49133
49147
|
{ overlay: true, overlayOptions: { anchor: "center", width: 92 } }
|
|
@@ -49209,7 +49223,7 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
|
|
|
49209
49223
|
const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
|
|
49210
49224
|
const { createMcpPanel } = await import("./mcp-panel-H3TDJYHQ.js");
|
|
49211
49225
|
let configChanged = false;
|
|
49212
|
-
await new Promise((
|
|
49226
|
+
await new Promise((resolve8) => {
|
|
49213
49227
|
ctx.ui.custom(
|
|
49214
49228
|
(tui, _theme, keybindings, done) => {
|
|
49215
49229
|
return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, (result) => {
|
|
@@ -49232,13 +49246,13 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
|
|
|
49232
49246
|
ctx.ui.notify("Direct tools updated for this session.", "info");
|
|
49233
49247
|
}
|
|
49234
49248
|
done(void 0);
|
|
49235
|
-
|
|
49249
|
+
resolve8();
|
|
49236
49250
|
})().catch((error) => {
|
|
49237
49251
|
const message = error instanceof Error ? error.message : String(error);
|
|
49238
49252
|
ctx.ui.notify(`Direct tools updated, but live refresh failed: ${message}`, "error");
|
|
49239
49253
|
configChanged = true;
|
|
49240
49254
|
done(void 0);
|
|
49241
|
-
|
|
49255
|
+
resolve8();
|
|
49242
49256
|
});
|
|
49243
49257
|
}, { noticeLines, keybindings });
|
|
49244
49258
|
},
|
|
@@ -49280,12 +49294,12 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
|
|
|
49280
49294
|
let overlayHandle;
|
|
49281
49295
|
const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
|
|
49282
49296
|
const { createMcpPanel } = await import("./mcp-panel-H3TDJYHQ.js");
|
|
49283
|
-
await new Promise((
|
|
49297
|
+
await new Promise((resolve8) => {
|
|
49284
49298
|
ctx.ui.custom(
|
|
49285
49299
|
(tui, _theme, keybindings, done) => {
|
|
49286
49300
|
return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, () => {
|
|
49287
49301
|
done(void 0);
|
|
49288
|
-
|
|
49302
|
+
resolve8();
|
|
49289
49303
|
}, {
|
|
49290
49304
|
authOnly: true,
|
|
49291
49305
|
keybindings,
|
|
@@ -49820,16 +49834,16 @@ function serializedObjectEntryBytes(key, value, hasPrevious) {
|
|
|
49820
49834
|
async function saveArtifact(kind, text) {
|
|
49821
49835
|
try {
|
|
49822
49836
|
const dir = await mkdtemp(join20(tmpdir2(), "pi-mcp-output-"));
|
|
49823
|
-
const
|
|
49824
|
-
await writeFile7(
|
|
49825
|
-
return { path:
|
|
49837
|
+
const path8 = join20(dir, `${kind}-${randomBytes3(4).toString("hex")}.txt`);
|
|
49838
|
+
await writeFile7(path8, text, { encoding: "utf8", mode: 384 });
|
|
49839
|
+
return { path: path8 };
|
|
49826
49840
|
} catch (error) {
|
|
49827
49841
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
49828
49842
|
}
|
|
49829
49843
|
}
|
|
49830
|
-
async function discardArtifact(
|
|
49844
|
+
async function discardArtifact(path8) {
|
|
49831
49845
|
try {
|
|
49832
|
-
await rm5(dirname11(
|
|
49846
|
+
await rm5(dirname11(path8), { recursive: true, force: true });
|
|
49833
49847
|
} catch {
|
|
49834
49848
|
}
|
|
49835
49849
|
}
|
|
@@ -51232,7 +51246,7 @@ data: ${JSON.stringify(payload)}
|
|
|
51232
51246
|
markCompleted("stale");
|
|
51233
51247
|
}, WATCHDOG_INTERVAL_MS);
|
|
51234
51248
|
watchdog.unref();
|
|
51235
|
-
return new Promise((
|
|
51249
|
+
return new Promise((resolve8, reject) => {
|
|
51236
51250
|
const candidates = resolvePortCandidates(options.port);
|
|
51237
51251
|
let candidateIndex = 0;
|
|
51238
51252
|
const startSandboxProxy = (parentOrigin) => {
|
|
@@ -51369,7 +51383,7 @@ data: ${JSON.stringify(payload)}
|
|
|
51369
51383
|
getSessionMessages: () => ({ ...sessionMessages }),
|
|
51370
51384
|
getStreamSummary: () => streamSummary ? { ...streamSummary, phases: [...streamSummary.phases] } : void 0
|
|
51371
51385
|
};
|
|
51372
|
-
|
|
51386
|
+
resolve8(handle);
|
|
51373
51387
|
}).catch((error) => {
|
|
51374
51388
|
log.error("Failed to start sandbox proxy", error instanceof Error ? error : void 0);
|
|
51375
51389
|
closeListeners();
|
|
@@ -51394,7 +51408,7 @@ async function parseBody(req, res) {
|
|
|
51394
51408
|
}
|
|
51395
51409
|
}
|
|
51396
51410
|
function readBody2(req) {
|
|
51397
|
-
return new Promise((
|
|
51411
|
+
return new Promise((resolve8, reject) => {
|
|
51398
51412
|
let size = 0;
|
|
51399
51413
|
const chunks = [];
|
|
51400
51414
|
req.on("data", (chunk) => {
|
|
@@ -51408,7 +51422,7 @@ function readBody2(req) {
|
|
|
51408
51422
|
});
|
|
51409
51423
|
req.on("end", () => {
|
|
51410
51424
|
try {
|
|
51411
|
-
|
|
51425
|
+
resolve8(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
51412
51426
|
} catch (error) {
|
|
51413
51427
|
reject(error);
|
|
51414
51428
|
}
|
|
@@ -51589,22 +51603,22 @@ function isRemoteSession() {
|
|
|
51589
51603
|
return Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY);
|
|
51590
51604
|
}
|
|
51591
51605
|
function hasActiveRemoteLogin() {
|
|
51592
|
-
return new Promise((
|
|
51606
|
+
return new Promise((resolve8) => {
|
|
51593
51607
|
execFile6("who", { encoding: "utf8", timeout: 2e3 }, (error, out) => {
|
|
51594
51608
|
if (error) {
|
|
51595
|
-
|
|
51609
|
+
resolve8(false);
|
|
51596
51610
|
return;
|
|
51597
51611
|
}
|
|
51598
|
-
|
|
51612
|
+
resolve8(/\(.+\)\s*$/m.test(out));
|
|
51599
51613
|
});
|
|
51600
51614
|
});
|
|
51601
51615
|
}
|
|
51602
51616
|
function probeMoshiGateway() {
|
|
51603
|
-
return new Promise((
|
|
51617
|
+
return new Promise((resolve8) => {
|
|
51604
51618
|
const socket = net.connect({ host: "127.0.0.1", port: 24543 });
|
|
51605
51619
|
const done = (ok) => {
|
|
51606
51620
|
socket.destroy();
|
|
51607
|
-
|
|
51621
|
+
resolve8(ok);
|
|
51608
51622
|
};
|
|
51609
51623
|
socket.setTimeout(300);
|
|
51610
51624
|
socket.once("connect", () => done(true));
|
|
@@ -57920,22 +57934,22 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57920
57934
|
durationMs: "error" in operation && operation.error === "incomplete" ? Math.max(0, Date.now() - startedAt) : operation.durationMs
|
|
57921
57935
|
}));
|
|
57922
57936
|
let callsSnapshot;
|
|
57923
|
-
const callTool = async (
|
|
57937
|
+
const callTool = async (path8, args) => {
|
|
57924
57938
|
const startedAt = Date.now();
|
|
57925
|
-
const index = calls.push({ operation: "call", path:
|
|
57926
|
-
const result = await executeCall(state,
|
|
57939
|
+
const index = calls.push({ operation: "call", path: path8, ok: false, error: "incomplete", durationMs: 0, startedAt }) - 1;
|
|
57940
|
+
const result = await executeCall(state, path8, args, void 0, getPiTools, callSignal, "script");
|
|
57927
57941
|
const details = result.details;
|
|
57928
57942
|
if (details.error !== void 0) {
|
|
57929
57943
|
const errorCode2 = String(details.error);
|
|
57930
57944
|
const suggestions = Array.isArray(details.suggestions) ? details.suggestions.filter((suggestion) => typeof suggestion === "string") : [];
|
|
57931
|
-
const message = errorCode2 === "tool_not_found" ? `Tool "${
|
|
57932
|
-
calls[index] = { operation: "call", path:
|
|
57945
|
+
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);
|
|
57946
|
+
calls[index] = { operation: "call", path: path8, ok: false, error: errorCode2, durationMs: Date.now() - startedAt, startedAt };
|
|
57933
57947
|
return {
|
|
57934
57948
|
ok: false,
|
|
57935
57949
|
error: { code: errorCode2, message }
|
|
57936
57950
|
};
|
|
57937
57951
|
}
|
|
57938
|
-
calls[index] = { operation: "call", path:
|
|
57952
|
+
calls[index] = { operation: "call", path: path8, ok: true, durationMs: Date.now() - startedAt, startedAt };
|
|
57939
57953
|
return {
|
|
57940
57954
|
ok: true,
|
|
57941
57955
|
data: details.mcpResult !== void 0 ? details.mcpResult : textFromContent(result.content)
|
|
@@ -57972,12 +57986,12 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57972
57986
|
};
|
|
57973
57987
|
const describeTool = (input) => {
|
|
57974
57988
|
const startedAt = Date.now();
|
|
57975
|
-
const
|
|
57989
|
+
const path8 = typeof input?.path === "string" ? input.path : "";
|
|
57976
57990
|
let error;
|
|
57977
57991
|
try {
|
|
57978
57992
|
for (const [server3, metadata] of state.toolMetadata) {
|
|
57979
57993
|
if (isServerInActiveFailureBackoff(state, server3)) continue;
|
|
57980
|
-
const tool = findToolByName(metadata,
|
|
57994
|
+
const tool = findToolByName(metadata, path8);
|
|
57981
57995
|
if (!tool) continue;
|
|
57982
57996
|
const inputTypeScript = tool.inputSchema ? renderTsShape(tool.inputSchema) ?? formatSchema(tool.inputSchema) : null;
|
|
57983
57997
|
return {
|
|
@@ -57988,13 +58002,13 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57988
58002
|
...inputTypeScript ? { inputTypeScript } : {}
|
|
57989
58003
|
};
|
|
57990
58004
|
}
|
|
57991
|
-
const suggestions =
|
|
58005
|
+
const suggestions = path8 ? rankSuggestions(state, path8, 5) : [];
|
|
57992
58006
|
error = "tool_not_found";
|
|
57993
58007
|
return {
|
|
57994
|
-
path:
|
|
58008
|
+
path: path8,
|
|
57995
58009
|
error: {
|
|
57996
58010
|
code: "tool_not_found",
|
|
57997
|
-
message: `Tool not found: ${
|
|
58011
|
+
message: `Tool not found: ${path8}`,
|
|
57998
58012
|
suggestions
|
|
57999
58013
|
}
|
|
58000
58014
|
};
|
|
@@ -58002,7 +58016,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
58002
58016
|
error = caught;
|
|
58003
58017
|
throw caught;
|
|
58004
58018
|
} finally {
|
|
58005
|
-
calls.push(error === void 0 ? { operation: "describe", path:
|
|
58019
|
+
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 });
|
|
58006
58020
|
}
|
|
58007
58021
|
};
|
|
58008
58022
|
let worker;
|
|
@@ -58024,7 +58038,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
58024
58038
|
trackUnmanagedFds: false
|
|
58025
58039
|
});
|
|
58026
58040
|
const activeWorker = worker;
|
|
58027
|
-
const execution = new Promise((
|
|
58041
|
+
const execution = new Promise((resolve8, reject) => {
|
|
58028
58042
|
let completed = false;
|
|
58029
58043
|
activeWorker.on("message", (value) => {
|
|
58030
58044
|
const message = parseWorkerMessage(value);
|
|
@@ -58036,7 +58050,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
58036
58050
|
if (message.type === "done") {
|
|
58037
58051
|
completed = true;
|
|
58038
58052
|
if ("returnBlock" in message) output.push(toContentBlock(message.returnBlock));
|
|
58039
|
-
|
|
58053
|
+
resolve8();
|
|
58040
58054
|
return;
|
|
58041
58055
|
}
|
|
58042
58056
|
if (message.type === "error") {
|
|
@@ -58315,8 +58329,8 @@ async function awaitWithTimeout(promise, timeoutMs) {
|
|
|
58315
58329
|
try {
|
|
58316
58330
|
return await Promise.race([
|
|
58317
58331
|
promise,
|
|
58318
|
-
new Promise((
|
|
58319
|
-
timer = setTimeout(() =>
|
|
58332
|
+
new Promise((resolve8) => {
|
|
58333
|
+
timer = setTimeout(() => resolve8(INIT_WAIT_TIMED_OUT), timeoutMs);
|
|
58320
58334
|
timer.unref?.();
|
|
58321
58335
|
})
|
|
58322
58336
|
]);
|
|
@@ -60115,9 +60129,9 @@ function calculateCumulativeTokenUsageDelta(current, previous) {
|
|
|
60115
60129
|
cacheWriteInputTokens: current.cacheWriteInputTokens - previous.cacheWriteInputTokens
|
|
60116
60130
|
};
|
|
60117
60131
|
}
|
|
60118
|
-
function recordParsedTokenUsage(event, harness,
|
|
60132
|
+
function recordParsedTokenUsage(event, harness, parse3) {
|
|
60119
60133
|
if (event.type !== "usage-updated") return void 0;
|
|
60120
|
-
const usage =
|
|
60134
|
+
const usage = parse3(event.payload);
|
|
60121
60135
|
if (!usage) return void 0;
|
|
60122
60136
|
return {
|
|
60123
60137
|
records: [{
|
|
@@ -60776,12 +60790,12 @@ var CanvasService = class {
|
|
|
60776
60790
|
const safe = sanitizeCanvasFilename(filename);
|
|
60777
60791
|
if (!safe) return null;
|
|
60778
60792
|
for (const directory of await this.directories()) {
|
|
60779
|
-
const
|
|
60780
|
-
const stats = await stat3(
|
|
60793
|
+
const path8 = join25(directory, safe);
|
|
60794
|
+
const stats = await stat3(path8).catch(() => null);
|
|
60781
60795
|
if (stats?.isFile()) {
|
|
60782
60796
|
return {
|
|
60783
60797
|
filename: safe,
|
|
60784
|
-
path:
|
|
60798
|
+
path: path8,
|
|
60785
60799
|
sizeBytes: stats.size,
|
|
60786
60800
|
updatedAt: stats.mtime.toISOString(),
|
|
60787
60801
|
...classifyCanvasFilename(safe)
|
|
@@ -60793,9 +60807,9 @@ var CanvasService = class {
|
|
|
60793
60807
|
async getItemFile(filename, maxBytes = MAX_CANVAS_FILE_BYTES) {
|
|
60794
60808
|
const item = await this.locateItem(filename);
|
|
60795
60809
|
if (!item) return null;
|
|
60796
|
-
const { path:
|
|
60810
|
+
const { path: path8, ...file } = item;
|
|
60797
60811
|
if (file.sizeBytes > maxBytes) return { ...file, tooLarge: true };
|
|
60798
|
-
const bytes = await readFile15(
|
|
60812
|
+
const bytes = await readFile15(path8).catch(() => null);
|
|
60799
60813
|
return bytes ? { ...file, bytes } : null;
|
|
60800
60814
|
}
|
|
60801
60815
|
async getItem(filename) {
|
|
@@ -60961,7 +60975,7 @@ function parseChatMessageSendersJsonl(content) {
|
|
|
60961
60975
|
import { request as httpRequest } from "http";
|
|
60962
60976
|
import { request as httpsRequest } from "https";
|
|
60963
60977
|
async function putPresignedFile(urlValue, body, size, contentType) {
|
|
60964
|
-
await new Promise((
|
|
60978
|
+
await new Promise((resolve8, reject) => {
|
|
60965
60979
|
const url3 = new URL(urlValue);
|
|
60966
60980
|
const request = (url3.protocol === "https:" ? httpsRequest : httpRequest)(url3, {
|
|
60967
60981
|
method: "PUT",
|
|
@@ -60977,7 +60991,7 @@ async function putPresignedFile(urlValue, body, size, contentType) {
|
|
|
60977
60991
|
});
|
|
60978
60992
|
response.on("end", () => {
|
|
60979
60993
|
const status = response.statusCode ?? 0;
|
|
60980
|
-
if (status >= 200 && status < 300)
|
|
60994
|
+
if (status >= 200 && status < 300) resolve8();
|
|
60981
60995
|
else reject(new Error(`upload failed: ${status} ${body2}`));
|
|
60982
60996
|
});
|
|
60983
60997
|
response.on("error", reject);
|
|
@@ -61282,13 +61296,13 @@ function runBeforeDeadline(operation, deadline) {
|
|
|
61282
61296
|
const timeoutMs = deadline - Date.now();
|
|
61283
61297
|
if (timeoutMs <= 0) return Promise.reject(new DOMException("engine log flush deadline exceeded", "TimeoutError"));
|
|
61284
61298
|
const signal = AbortSignal.timeout(timeoutMs);
|
|
61285
|
-
return new Promise((
|
|
61299
|
+
return new Promise((resolve8, reject) => {
|
|
61286
61300
|
const onAbort = () => reject(signal.reason);
|
|
61287
61301
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
61288
61302
|
operation(signal).then(
|
|
61289
61303
|
(value) => {
|
|
61290
61304
|
signal.removeEventListener("abort", onAbort);
|
|
61291
|
-
|
|
61305
|
+
resolve8(value);
|
|
61292
61306
|
},
|
|
61293
61307
|
(error) => {
|
|
61294
61308
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -61327,7 +61341,7 @@ function unansweredRequest(blocks) {
|
|
|
61327
61341
|
const answered = blocks.slice(lastUser + 1).some((block) => block.startsWith("## Agent"));
|
|
61328
61342
|
return answered ? null : lastUserBlockText(blocks);
|
|
61329
61343
|
}
|
|
61330
|
-
async function readHistoryTail(
|
|
61344
|
+
async function readHistoryTail(path8, maxBytes, openHistory = () => openWholeLog(path8)) {
|
|
61331
61345
|
const opened = await openHistory();
|
|
61332
61346
|
if (!opened) return { content: "", truncated: false };
|
|
61333
61347
|
const { file: handle, size } = opened;
|
|
@@ -61900,8 +61914,8 @@ var ChatService = class {
|
|
|
61900
61914
|
}
|
|
61901
61915
|
const remainingMs = timeoutMs === null ? null : timeoutMs - (Date.now() - startedAt);
|
|
61902
61916
|
if (remainingMs !== null && remainingMs <= 0) return { ...result, timedOut: true };
|
|
61903
|
-
await new Promise((
|
|
61904
|
-
|
|
61917
|
+
await new Promise((resolve8) => setTimeout(
|
|
61918
|
+
resolve8,
|
|
61905
61919
|
remainingMs === null ? SUBAGENT_POLL_INTERVAL_MS : Math.min(SUBAGENT_POLL_INTERVAL_MS, remainingMs)
|
|
61906
61920
|
));
|
|
61907
61921
|
}
|
|
@@ -62533,7 +62547,7 @@ ${decisions}` };
|
|
|
62533
62547
|
historyPath,
|
|
62534
62548
|
`${historyPath}.pages.jsonl`,
|
|
62535
62549
|
`${historyPath}.pages.index.json`
|
|
62536
|
-
].map((
|
|
62550
|
+
].map((path8) => rm7(path8, { force: true })));
|
|
62537
62551
|
await rm7(chatMessageSendersFilePath(persisted.id), { force: true });
|
|
62538
62552
|
await rm7(join30(FORKS_DIR, persisted.id), { recursive: true, force: true });
|
|
62539
62553
|
}
|
|
@@ -63776,10 +63790,10 @@ var LanguageServerService = class {
|
|
|
63776
63790
|
const uri = "targetUri" in location ? location.targetUri : location.uri;
|
|
63777
63791
|
const range = "targetSelectionRange" in location ? location.targetSelectionRange : location.range;
|
|
63778
63792
|
const absolutePath = fileURLToPath5(uri);
|
|
63779
|
-
const
|
|
63780
|
-
if (
|
|
63793
|
+
const path8 = relative2(repoPath, absolutePath);
|
|
63794
|
+
if (path8.startsWith("..")) return [];
|
|
63781
63795
|
const preview = readFileSync6(absolutePath, "utf8").split("\n")[range.start.line]?.trim() ?? "";
|
|
63782
|
-
return [{ repoName, path:
|
|
63796
|
+
return [{ repoName, path: path8, line: range.start.line + 1, character: range.start.character, endCharacter: range.end.character, preview }];
|
|
63783
63797
|
});
|
|
63784
63798
|
return { symbol: "", detail: null, documentation: null, locations, provider: "language-server" };
|
|
63785
63799
|
} catch {
|
|
@@ -63831,7 +63845,7 @@ function isBinaryExtension(filePath) {
|
|
|
63831
63845
|
return classifyCanvasFilename(filePath).kind === "image" || binaryExts.has(ext);
|
|
63832
63846
|
}
|
|
63833
63847
|
function execGitAsync(args, cwd, timeoutMs) {
|
|
63834
|
-
return new Promise((
|
|
63848
|
+
return new Promise((resolve8, reject) => {
|
|
63835
63849
|
const child = execFile7("git", [...UNQUOTED_PATHS_CONFIG, ...args], {
|
|
63836
63850
|
cwd,
|
|
63837
63851
|
encoding: "utf-8",
|
|
@@ -63841,7 +63855,7 @@ function execGitAsync(args, cwd, timeoutMs) {
|
|
|
63841
63855
|
if (error) {
|
|
63842
63856
|
reject(error);
|
|
63843
63857
|
} else {
|
|
63844
|
-
|
|
63858
|
+
resolve8(stdout);
|
|
63845
63859
|
}
|
|
63846
63860
|
});
|
|
63847
63861
|
child.stdin?.end();
|
|
@@ -64281,7 +64295,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
64281
64295
|
let bufferExceeded = false;
|
|
64282
64296
|
params.onChunk(`$ ${params.label}
|
|
64283
64297
|
`);
|
|
64284
|
-
return new Promise((
|
|
64298
|
+
return new Promise((resolve8) => {
|
|
64285
64299
|
const proc = spawn5("bash", ["-lc", params.content], {
|
|
64286
64300
|
cwd: params.cwd,
|
|
64287
64301
|
env: process.env,
|
|
@@ -64314,7 +64328,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
64314
64328
|
proc.on("close", (code) => {
|
|
64315
64329
|
clearTimeout(timer);
|
|
64316
64330
|
const output = [`$ ${params.label}`, ...outputParts].join("");
|
|
64317
|
-
|
|
64331
|
+
resolve8({
|
|
64318
64332
|
exitCode: bufferExceeded ? 1 : code ?? 1,
|
|
64319
64333
|
output,
|
|
64320
64334
|
timedOut: killed && !bufferExceeded
|
|
@@ -64324,7 +64338,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
64324
64338
|
clearTimeout(timer);
|
|
64325
64339
|
const output = [`$ ${params.label}
|
|
64326
64340
|
`, ...outputParts, err.message].join("");
|
|
64327
|
-
|
|
64341
|
+
resolve8({
|
|
64328
64342
|
exitCode: 1,
|
|
64329
64343
|
output,
|
|
64330
64344
|
timedOut: false
|
|
@@ -65165,44 +65179,44 @@ function createV1Routes(deps) {
|
|
|
65165
65179
|
});
|
|
65166
65180
|
app2.get("/repo-files/content", async (c) => {
|
|
65167
65181
|
const repoName = c.req.query("repoName");
|
|
65168
|
-
const
|
|
65169
|
-
if (!repoName || !
|
|
65182
|
+
const path8 = c.req.query("path");
|
|
65183
|
+
if (!repoName || !path8) {
|
|
65170
65184
|
return c.json(jsonError("repoName and path are required"), 400);
|
|
65171
65185
|
}
|
|
65172
|
-
const result = await deps.repoFileService.readFile(repoName,
|
|
65186
|
+
const result = await deps.repoFileService.readFile(repoName, path8);
|
|
65173
65187
|
if (!result) {
|
|
65174
65188
|
return c.json(jsonError("File not found"), 404);
|
|
65175
65189
|
}
|
|
65176
65190
|
return c.json(result);
|
|
65177
65191
|
});
|
|
65178
65192
|
app2.get("/skill-files/content", async (c) => {
|
|
65179
|
-
const
|
|
65180
|
-
if (!
|
|
65181
|
-
const result = await deps.repoFileService.readSkillFile(
|
|
65193
|
+
const path8 = c.req.query("path");
|
|
65194
|
+
if (!path8) return c.json(jsonError("path is required"), 400);
|
|
65195
|
+
const result = await deps.repoFileService.readSkillFile(path8);
|
|
65182
65196
|
if (!result) return c.json(jsonError("File not found"), 404);
|
|
65183
65197
|
return c.json(result);
|
|
65184
65198
|
});
|
|
65185
65199
|
app2.put("/repo-files/content", async (c) => {
|
|
65186
65200
|
const repoName = c.req.query("repoName");
|
|
65187
|
-
const
|
|
65188
|
-
if (!repoName || !
|
|
65201
|
+
const path8 = c.req.query("path");
|
|
65202
|
+
if (!repoName || !path8) {
|
|
65189
65203
|
return c.json(jsonError("repoName and path are required"), 400);
|
|
65190
65204
|
}
|
|
65191
65205
|
const body = updateTextFileSchema(MAX_REPO_FILE_CONTENT_BYTES).parse(await c.req.json());
|
|
65192
|
-
const result = await deps.repoFileService.updateFile(repoName,
|
|
65206
|
+
const result = await deps.repoFileService.updateFile(repoName, path8, body.content, body.expectedRevision);
|
|
65193
65207
|
if (!result) return c.json(jsonError("File is not editable"), 400);
|
|
65194
65208
|
return c.json(result);
|
|
65195
65209
|
});
|
|
65196
65210
|
app2.get("/repo-files/symbol", async (c) => {
|
|
65197
65211
|
const repoName = c.req.query("repoName");
|
|
65198
|
-
const
|
|
65212
|
+
const path8 = c.req.query("path");
|
|
65199
65213
|
const action = c.req.query("action");
|
|
65200
65214
|
const line = Number(c.req.query("line"));
|
|
65201
65215
|
const character = Number(c.req.query("character"));
|
|
65202
|
-
if (!repoName || !
|
|
65216
|
+
if (!repoName || !path8 || action !== "hover" && action !== "definition" && action !== "references" || !Number.isInteger(line) || !Number.isInteger(character)) {
|
|
65203
65217
|
return c.json(jsonError("Invalid symbol request"), 400);
|
|
65204
65218
|
}
|
|
65205
|
-
const result = await deps.repoFileService.inspectSymbol(repoName,
|
|
65219
|
+
const result = await deps.repoFileService.inspectSymbol(repoName, path8, line, character, action);
|
|
65206
65220
|
if (!result) return c.json(jsonError("Symbol not found"), 404);
|
|
65207
65221
|
return c.json(result);
|
|
65208
65222
|
});
|
|
@@ -65660,20 +65674,361 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
65660
65674
|
return app2;
|
|
65661
65675
|
}
|
|
65662
65676
|
|
|
65663
|
-
// src/services/
|
|
65677
|
+
// src/services/exec/exec-socket.ts
|
|
65678
|
+
import { randomUUID as randomUUID12 } from "crypto";
|
|
65679
|
+
import { mkdir as mkdir17, open as open3, stat as stat6, writeFile as writeFile10 } from "fs/promises";
|
|
65680
|
+
import { arch as arch2, platform as platform3 } from "os";
|
|
65681
|
+
import { dirname as dirname14, join as join36, resolve as resolve6 } from "path";
|
|
65664
65682
|
import { z as z7 } from "zod";
|
|
65683
|
+
|
|
65684
|
+
// src/services/exec/process-registry.ts
|
|
65685
|
+
import { spawn as spawn7 } from "child_process";
|
|
65686
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
65687
|
+
import { constants as constants2 } from "os";
|
|
65688
|
+
var KILL_GRACE_MS = 2e3;
|
|
65689
|
+
var EXIT_DRAIN_MS = 100;
|
|
65690
|
+
var EXITED_RETENTION_MS = 10 * 6e4;
|
|
65691
|
+
var ManagedProcess = class {
|
|
65692
|
+
constructor(options, child, onForget) {
|
|
65693
|
+
this.options = options;
|
|
65694
|
+
this.child = child;
|
|
65695
|
+
this.onForget = onForget;
|
|
65696
|
+
if (options.timeoutMs) this.timeoutTimer = setTimeout(() => this.kill("timeout"), options.timeoutMs);
|
|
65697
|
+
this.armIdleTimer();
|
|
65698
|
+
}
|
|
65699
|
+
options;
|
|
65700
|
+
child;
|
|
65701
|
+
onForget;
|
|
65702
|
+
id = randomUUID11();
|
|
65703
|
+
startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
65704
|
+
chunks = [];
|
|
65705
|
+
bufferedBytes = 0;
|
|
65706
|
+
outputBytes = 0;
|
|
65707
|
+
exit = null;
|
|
65708
|
+
killReason = null;
|
|
65709
|
+
listeners = /* @__PURE__ */ new Set();
|
|
65710
|
+
idleTimer;
|
|
65711
|
+
timeoutTimer;
|
|
65712
|
+
get pid() {
|
|
65713
|
+
return this.child.pid ?? 0;
|
|
65714
|
+
}
|
|
65715
|
+
get bufferStart() {
|
|
65716
|
+
return this.outputBytes - this.bufferedBytes;
|
|
65717
|
+
}
|
|
65718
|
+
info() {
|
|
65719
|
+
return {
|
|
65720
|
+
processId: this.id,
|
|
65721
|
+
pid: this.pid,
|
|
65722
|
+
threadId: this.options.threadId,
|
|
65723
|
+
label: this.options.label ?? null,
|
|
65724
|
+
command: this.options.command,
|
|
65725
|
+
startedAt: this.startedAt,
|
|
65726
|
+
outputBytes: this.outputBytes,
|
|
65727
|
+
bufferStart: this.bufferStart,
|
|
65728
|
+
exit: this.exit
|
|
65729
|
+
};
|
|
65730
|
+
}
|
|
65731
|
+
append(stream, data) {
|
|
65732
|
+
const chunk = { stream, offset: this.outputBytes, data };
|
|
65733
|
+
this.outputBytes += data.length;
|
|
65734
|
+
this.chunks.push(chunk);
|
|
65735
|
+
this.bufferedBytes += data.length;
|
|
65736
|
+
while (this.bufferedBytes > EXEC_PROCESS_BUFFER_BYTES && this.chunks.length > 1) {
|
|
65737
|
+
this.bufferedBytes -= this.chunks[0].data.length;
|
|
65738
|
+
this.chunks.shift();
|
|
65739
|
+
}
|
|
65740
|
+
for (const listener of this.listeners) listener.output(chunk);
|
|
65741
|
+
}
|
|
65742
|
+
finish(exitCode, signal) {
|
|
65743
|
+
if (this.exit) return;
|
|
65744
|
+
clearTimeout(this.timeoutTimer);
|
|
65745
|
+
this.exit = {
|
|
65746
|
+
exitCode: exitCode ?? 128 + (signal ? constants2.signals[signal] : 0),
|
|
65747
|
+
signal,
|
|
65748
|
+
reason: this.killReason ?? "exit"
|
|
65749
|
+
};
|
|
65750
|
+
for (const listener of this.listeners) listener.exit(this.exit);
|
|
65751
|
+
this.armIdleTimer();
|
|
65752
|
+
}
|
|
65753
|
+
attach(offset, listener) {
|
|
65754
|
+
for (const chunk of this.chunks) {
|
|
65755
|
+
if (chunk.offset + chunk.data.length <= offset) continue;
|
|
65756
|
+
const data = chunk.offset < offset ? chunk.data.subarray(offset - chunk.offset) : chunk.data;
|
|
65757
|
+
listener.output({ ...chunk, offset: Math.max(chunk.offset, offset), data });
|
|
65758
|
+
}
|
|
65759
|
+
if (this.exit) {
|
|
65760
|
+
listener.exit(this.exit);
|
|
65761
|
+
return () => {
|
|
65762
|
+
};
|
|
65763
|
+
}
|
|
65764
|
+
this.listeners.add(listener);
|
|
65765
|
+
clearTimeout(this.idleTimer);
|
|
65766
|
+
return () => {
|
|
65767
|
+
if (this.listeners.delete(listener) && this.listeners.size === 0) this.armIdleTimer();
|
|
65768
|
+
};
|
|
65769
|
+
}
|
|
65770
|
+
kill(reason) {
|
|
65771
|
+
if (this.exit) return;
|
|
65772
|
+
this.killReason ??= reason;
|
|
65773
|
+
const signalGroup = (signal) => {
|
|
65774
|
+
try {
|
|
65775
|
+
process.kill(-this.pid, signal);
|
|
65776
|
+
} catch {
|
|
65777
|
+
}
|
|
65778
|
+
};
|
|
65779
|
+
signalGroup("SIGTERM");
|
|
65780
|
+
setTimeout(() => signalGroup("SIGKILL"), KILL_GRACE_MS).unref();
|
|
65781
|
+
}
|
|
65782
|
+
armIdleTimer() {
|
|
65783
|
+
clearTimeout(this.idleTimer);
|
|
65784
|
+
if (this.listeners.size > 0) return;
|
|
65785
|
+
this.idleTimer = this.exit ? setTimeout(this.onForget, EXITED_RETENTION_MS) : setTimeout(() => this.kill("idle"), this.options.idleTtlMs ?? EXEC_DEFAULT_IDLE_TTL_MS);
|
|
65786
|
+
this.idleTimer.unref();
|
|
65787
|
+
}
|
|
65788
|
+
};
|
|
65789
|
+
var ProcessRegistry = class {
|
|
65790
|
+
processes = /* @__PURE__ */ new Map();
|
|
65791
|
+
spawn(options) {
|
|
65792
|
+
const child = spawn7(options.file, options.args, {
|
|
65793
|
+
cwd: options.cwd,
|
|
65794
|
+
env: { ...buildCodexAgentEnv(), ...options.env },
|
|
65795
|
+
detached: true,
|
|
65796
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
65797
|
+
});
|
|
65798
|
+
return new Promise((resolve8) => {
|
|
65799
|
+
child.once("error", (error) => resolve8(createErrorResult({ code: "spawn_error", message: error.message })));
|
|
65800
|
+
child.once("spawn", () => {
|
|
65801
|
+
const managed = new ManagedProcess(options, child, () => this.processes.delete(managed.id));
|
|
65802
|
+
this.processes.set(managed.id, managed);
|
|
65803
|
+
child.stdout.on("data", (data) => managed.append("stdout", data));
|
|
65804
|
+
child.stderr.on("data", (data) => managed.append("stderr", data));
|
|
65805
|
+
let drain;
|
|
65806
|
+
const settle = () => {
|
|
65807
|
+
clearTimeout(drain);
|
|
65808
|
+
managed.finish(child.exitCode, child.signalCode);
|
|
65809
|
+
child.stdout.destroy();
|
|
65810
|
+
child.stderr.destroy();
|
|
65811
|
+
};
|
|
65812
|
+
child.once("exit", () => {
|
|
65813
|
+
drain = setTimeout(settle, EXIT_DRAIN_MS);
|
|
65814
|
+
});
|
|
65815
|
+
child.once("close", settle);
|
|
65816
|
+
resolve8(createSuccessResult(managed));
|
|
65817
|
+
});
|
|
65818
|
+
});
|
|
65819
|
+
}
|
|
65820
|
+
get(processId) {
|
|
65821
|
+
return this.processes.get(processId);
|
|
65822
|
+
}
|
|
65823
|
+
list(threadId) {
|
|
65824
|
+
return [...this.processes.values()].filter((managed) => !threadId || managed.options.threadId === threadId).map((managed) => managed.info());
|
|
65825
|
+
}
|
|
65826
|
+
killThread(threadId) {
|
|
65827
|
+
const running = [...this.processes.values()].filter((managed) => managed.options.threadId === threadId && !managed.exit);
|
|
65828
|
+
for (const managed of running) managed.kill("killed");
|
|
65829
|
+
return running.length;
|
|
65830
|
+
}
|
|
65831
|
+
};
|
|
65832
|
+
var processRegistry = new ProcessRegistry();
|
|
65833
|
+
|
|
65834
|
+
// src/services/exec/exec-socket.ts
|
|
65835
|
+
var BOOT_ID = randomUUID12();
|
|
65836
|
+
var MAX_SOCKET_BUFFERED_BYTES = 4 * 1024 * 1024;
|
|
65837
|
+
var DRAIN_POLL_MS = 100;
|
|
65838
|
+
var path7 = z7.string().min(1);
|
|
65839
|
+
var schemas = {
|
|
65840
|
+
hello: z7.object({ protocol: z7.number().int() }),
|
|
65841
|
+
stat: z7.object({ path: path7 }),
|
|
65842
|
+
read: z7.object({ path: path7, offset: z7.number().int().nonnegative().optional(), length: z7.number().int().positive().max(EXEC_MAX_FRAME_BYTES / 2).optional() }),
|
|
65843
|
+
write: z7.object({ path: path7, append: z7.boolean().optional() }),
|
|
65844
|
+
exec: execRequestSchema,
|
|
65845
|
+
attach: z7.object({ processId: z7.string(), offset: z7.number().int().nonnegative().optional() }),
|
|
65846
|
+
kill: z7.object({ processId: z7.string() }),
|
|
65847
|
+
killThread: z7.object({ threadId: z7.string().min(1) }),
|
|
65848
|
+
list: z7.object({ threadId: z7.string().optional() })
|
|
65849
|
+
};
|
|
65850
|
+
var ExecError = class extends Error {
|
|
65851
|
+
constructor(code, message, path8) {
|
|
65852
|
+
super(message);
|
|
65853
|
+
this.code = code;
|
|
65854
|
+
this.path = path8;
|
|
65855
|
+
}
|
|
65856
|
+
code;
|
|
65857
|
+
path;
|
|
65858
|
+
};
|
|
65859
|
+
function parse(schema, json) {
|
|
65860
|
+
const parsed = schema.safeParse(json);
|
|
65861
|
+
if (!parsed.success) throw new ExecError("EINVAL", z7.prettifyError(parsed.error));
|
|
65862
|
+
return parsed.data;
|
|
65863
|
+
}
|
|
65864
|
+
function resolvePath(target) {
|
|
65865
|
+
if (target === "~" || target.startsWith("~/")) return join36(ENGINE_ENV.HOME_DIR, target.slice(1));
|
|
65866
|
+
return resolve6(ENGINE_ENV.WORKSPACE_ROOT, target);
|
|
65867
|
+
}
|
|
65868
|
+
function toErrorBody(error) {
|
|
65869
|
+
if (error instanceof ExecError) return { code: error.code, message: error.message, path: error.path };
|
|
65870
|
+
if (!(error instanceof Error)) return { code: "unknown", message: String(error) };
|
|
65871
|
+
const code = "code" in error ? EXEC_ERROR_CODES.find((candidate) => candidate === error.code) : void 0;
|
|
65872
|
+
const path8 = "path" in error && typeof error.path === "string" ? error.path : void 0;
|
|
65873
|
+
return { code: code ?? "unknown", message: error.message, path: path8 };
|
|
65874
|
+
}
|
|
65875
|
+
function attachExecSocket(socket) {
|
|
65876
|
+
const streams = /* @__PURE__ */ new Map();
|
|
65877
|
+
let lastHeard = Date.now();
|
|
65878
|
+
const send = (type, id, json, payload) => {
|
|
65879
|
+
if (socket.readyState === socket.OPEN) socket.send(encodeExecFrame(type, id, json, payload));
|
|
65880
|
+
};
|
|
65881
|
+
const sendEvent = (id, event, payload) => send(EXEC_FRAME.event, id, event, payload);
|
|
65882
|
+
const liveness = setInterval(() => {
|
|
65883
|
+
if (Date.now() - lastHeard > EXEC_SILENCE_TIMEOUT_MS) socket.terminate();
|
|
65884
|
+
else send(EXEC_FRAME.ping, 0);
|
|
65885
|
+
}, EXEC_PING_INTERVAL_MS);
|
|
65886
|
+
const follow = (id, processId, offset, onCancel) => {
|
|
65887
|
+
const managed = processRegistry.get(processId);
|
|
65888
|
+
if (!managed) throw new ExecError("ESRCH", `No process ${processId}. The engine forgets processes when it restarts.`);
|
|
65889
|
+
let next = offset;
|
|
65890
|
+
let paused;
|
|
65891
|
+
let detach = () => {
|
|
65892
|
+
};
|
|
65893
|
+
const listener = {
|
|
65894
|
+
output: (chunk) => {
|
|
65895
|
+
if (paused || chunk.offset + chunk.data.length <= next) return;
|
|
65896
|
+
if (socket.bufferedAmount > MAX_SOCKET_BUFFERED_BYTES) {
|
|
65897
|
+
detach();
|
|
65898
|
+
paused = setInterval(() => {
|
|
65899
|
+
if (socket.bufferedAmount > MAX_SOCKET_BUFFERED_BYTES) return;
|
|
65900
|
+
clearInterval(paused);
|
|
65901
|
+
paused = void 0;
|
|
65902
|
+
start();
|
|
65903
|
+
}, DRAIN_POLL_MS);
|
|
65904
|
+
return;
|
|
65905
|
+
}
|
|
65906
|
+
const data = chunk.offset < next ? chunk.data.subarray(next - chunk.offset) : chunk.data;
|
|
65907
|
+
sendEvent(id, { kind: "output", stream: chunk.stream, offset: next }, data);
|
|
65908
|
+
next += data.length;
|
|
65909
|
+
},
|
|
65910
|
+
exit: (exit) => {
|
|
65911
|
+
stop();
|
|
65912
|
+
send(EXEC_FRAME.result, id, exit);
|
|
65913
|
+
}
|
|
65914
|
+
};
|
|
65915
|
+
const stop = () => {
|
|
65916
|
+
clearInterval(paused);
|
|
65917
|
+
paused = void 0;
|
|
65918
|
+
detach();
|
|
65919
|
+
streams.delete(id);
|
|
65920
|
+
};
|
|
65921
|
+
const start = () => {
|
|
65922
|
+
const skipped = Math.max(0, managed.bufferStart - next);
|
|
65923
|
+
if (skipped > 0) {
|
|
65924
|
+
sendEvent(id, { kind: "skipped", offset: next, bytes: skipped });
|
|
65925
|
+
next += skipped;
|
|
65926
|
+
}
|
|
65927
|
+
detach = managed.attach(next, listener);
|
|
65928
|
+
};
|
|
65929
|
+
streams.set(id, { cancel: () => onCancel(stop), stop });
|
|
65930
|
+
start();
|
|
65931
|
+
};
|
|
65932
|
+
const handlers = {
|
|
65933
|
+
hello: async (_id, json) => {
|
|
65934
|
+
parse(schemas.hello, json);
|
|
65935
|
+
return {
|
|
65936
|
+
protocol: EXEC_PROTOCOL_VERSION,
|
|
65937
|
+
version: ENGINE_ENV.REPLICAS_SANDBOX_IMAGE_VERSION,
|
|
65938
|
+
os: platform3(),
|
|
65939
|
+
arch: arch2(),
|
|
65940
|
+
home: ENGINE_ENV.HOME_DIR,
|
|
65941
|
+
root: ENGINE_ENV.WORKSPACE_ROOT,
|
|
65942
|
+
bootId: BOOT_ID,
|
|
65943
|
+
features: Object.keys(schemas)
|
|
65944
|
+
};
|
|
65945
|
+
},
|
|
65946
|
+
stat: async (_id, json) => {
|
|
65947
|
+
const info = await stat6(resolvePath(parse(schemas.stat, json).path));
|
|
65948
|
+
const kind = info.isFile() ? "file" : info.isDirectory() ? "directory" : "other";
|
|
65949
|
+
return { kind, size: info.size, mtimeMs: info.mtimeMs };
|
|
65950
|
+
},
|
|
65951
|
+
read: async (id, json) => {
|
|
65952
|
+
const { path: target, offset = 0, length = EXEC_DEFAULT_READ_BYTES } = parse(schemas.read, json);
|
|
65953
|
+
const file = await open3(resolvePath(target), "r");
|
|
65954
|
+
try {
|
|
65955
|
+
const { size } = await file.stat();
|
|
65956
|
+
const buffer = Buffer.alloc(Math.max(0, Math.min(length, size - offset)));
|
|
65957
|
+
const { bytesRead } = await file.read(buffer, 0, buffer.length, offset);
|
|
65958
|
+
send(EXEC_FRAME.result, id, { size }, buffer.subarray(0, bytesRead));
|
|
65959
|
+
return void 0;
|
|
65960
|
+
} finally {
|
|
65961
|
+
await file.close();
|
|
65962
|
+
}
|
|
65963
|
+
},
|
|
65964
|
+
write: async (_id, json, payload) => {
|
|
65965
|
+
const { path: target, append } = parse(schemas.write, json);
|
|
65966
|
+
const resolved = resolvePath(target);
|
|
65967
|
+
await mkdir17(dirname14(resolved), { recursive: true });
|
|
65968
|
+
await writeFile10(resolved, payload, { flag: append ? "a" : "w" });
|
|
65969
|
+
return { bytes: payload.length };
|
|
65970
|
+
},
|
|
65971
|
+
exec: async (id, json) => {
|
|
65972
|
+
const request = parse(schemas.exec, json);
|
|
65973
|
+
const cwd = resolvePath(request.cwd ?? ".");
|
|
65974
|
+
if (!(await stat6(cwd).catch(() => null))?.isDirectory()) throw new ExecError("ENOENT", `Working directory not found: ${cwd}`, cwd);
|
|
65975
|
+
const [file, ...args] = request.argv ?? ["/bin/bash", request.login === false ? "-c" : "-lc", request.command ?? ""];
|
|
65976
|
+
const spawned = await processRegistry.spawn({ ...request, file, args, command: request.command ?? args.join(" "), cwd });
|
|
65977
|
+
if (!spawned.ok) throw new ExecError("spawn_error", spawned.error.message);
|
|
65978
|
+
sendEvent(id, { kind: "started", processId: spawned.data.id, pid: spawned.data.pid });
|
|
65979
|
+
follow(id, spawned.data.id, 0, () => spawned.data.kill("killed"));
|
|
65980
|
+
return void 0;
|
|
65981
|
+
},
|
|
65982
|
+
attach: async (id, json) => {
|
|
65983
|
+
const { processId, offset = 0 } = parse(schemas.attach, json);
|
|
65984
|
+
follow(id, processId, offset, (stop) => {
|
|
65985
|
+
stop();
|
|
65986
|
+
send(EXEC_FRAME.error, id, { code: "aborted", message: "Detached" });
|
|
65987
|
+
});
|
|
65988
|
+
return void 0;
|
|
65989
|
+
},
|
|
65990
|
+
kill: async (_id, json) => {
|
|
65991
|
+
const { processId } = parse(schemas.kill, json);
|
|
65992
|
+
const managed = processRegistry.get(processId);
|
|
65993
|
+
if (!managed) throw new ExecError("ESRCH", `No process ${processId}`);
|
|
65994
|
+
managed.kill("killed");
|
|
65995
|
+
return {};
|
|
65996
|
+
},
|
|
65997
|
+
killThread: async (_id, json) => ({ killed: processRegistry.killThread(parse(schemas.killThread, json).threadId) }),
|
|
65998
|
+
list: async (_id, json) => ({ processes: processRegistry.list(parse(schemas.list, json).threadId) })
|
|
65999
|
+
};
|
|
66000
|
+
socket.on("message", (raw, isBinary) => {
|
|
66001
|
+
lastHeard = Date.now();
|
|
66002
|
+
const frame = isBinary && Buffer.isBuffer(raw) ? decodeExecFrame(raw) : null;
|
|
66003
|
+
if (!frame) {
|
|
66004
|
+
socket.close(1003, "Expected binary exec frames");
|
|
66005
|
+
return;
|
|
66006
|
+
}
|
|
66007
|
+
if (frame.type === EXEC_FRAME.cancel) streams.get(frame.id)?.cancel();
|
|
66008
|
+
if (frame.type !== EXEC_FRAME.request) return;
|
|
66009
|
+
const handler = typeof frame.json.op === "string" ? handlers[frame.json.op] : void 0;
|
|
66010
|
+
(handler ? handler(frame.id, frame.json, frame.payload) : Promise.reject(new ExecError("ENOTSUP", `Unknown op ${String(frame.json.op)}`))).then((result) => result && send(EXEC_FRAME.result, frame.id, result)).catch((error) => send(EXEC_FRAME.error, frame.id, toErrorBody(error)));
|
|
66011
|
+
});
|
|
66012
|
+
socket.on("close", () => {
|
|
66013
|
+
clearInterval(liveness);
|
|
66014
|
+
for (const { stop } of streams.values()) stop();
|
|
66015
|
+
});
|
|
66016
|
+
}
|
|
66017
|
+
|
|
66018
|
+
// src/services/terminal-socket.ts
|
|
66019
|
+
import { z as z8 } from "zod";
|
|
65665
66020
|
var ndcModule;
|
|
65666
66021
|
var loadNdc = () => ndcModule ??= import("node-datachannel").then((module) => module.default, () => null);
|
|
65667
66022
|
var CHANNEL_CHUNK_CHARS = 16384;
|
|
65668
66023
|
var MAX_QUEUED_CANDIDATES = 32;
|
|
65669
66024
|
var MAX_BUFFERED_BYTES = 8 * 1024 * 1024;
|
|
65670
|
-
var socketMessageSchema =
|
|
66025
|
+
var socketMessageSchema = z8.union([
|
|
65671
66026
|
terminalCommandSchema,
|
|
65672
|
-
|
|
65673
|
-
|
|
65674
|
-
|
|
66027
|
+
z8.object({ type: z8.literal("rtc-offer"), sdp: z8.string().max(64 * 1024) }),
|
|
66028
|
+
z8.object({ type: z8.literal("rtc-candidate"), candidate: z8.string().max(1024), mid: z8.string().max(64) }),
|
|
66029
|
+
z8.object({ type: z8.literal("rtc-switch") })
|
|
65675
66030
|
]);
|
|
65676
|
-
function
|
|
66031
|
+
function parse2(schema, raw) {
|
|
65677
66032
|
try {
|
|
65678
66033
|
const result = schema.safeParse(JSON.parse(raw));
|
|
65679
66034
|
return result.success ? result.data : null;
|
|
@@ -65717,7 +66072,7 @@ function attachTerminalSocket(id, socket) {
|
|
|
65717
66072
|
connection.onLocalCandidate((candidate, mid) => send({ type: "rtc-candidate", candidate, mid }));
|
|
65718
66073
|
connection.onDataChannel((dc) => {
|
|
65719
66074
|
dc.onMessage((raw) => {
|
|
65720
|
-
const command = typeof raw === "string" ?
|
|
66075
|
+
const command = typeof raw === "string" ? parse2(terminalCommandSchema, raw) : null;
|
|
65721
66076
|
if (!command) return;
|
|
65722
66077
|
if (early) early.push(command);
|
|
65723
66078
|
else terminalService.command(id, command);
|
|
@@ -65736,7 +66091,7 @@ function attachTerminalSocket(id, socket) {
|
|
|
65736
66091
|
for (const { candidate, mid } of candidates.splice(0)) connection.addRemoteCandidate(candidate, mid);
|
|
65737
66092
|
};
|
|
65738
66093
|
socket.on("message", (raw) => {
|
|
65739
|
-
const message =
|
|
66094
|
+
const message = parse2(socketMessageSchema, raw.toString());
|
|
65740
66095
|
if (!message) return;
|
|
65741
66096
|
if (message.type === "rtc-offer") {
|
|
65742
66097
|
negotiate(message.sdp).catch(() => {
|
|
@@ -65764,13 +66119,13 @@ var SAMPLE_INTERVAL_MS = 5e3;
|
|
|
65764
66119
|
var READ_TIMEOUT_MS = 2e3;
|
|
65765
66120
|
var pendingReads = new InFlightMap();
|
|
65766
66121
|
var boundedReads = /* @__PURE__ */ new WeakMap();
|
|
65767
|
-
function readWithin(
|
|
65768
|
-
const read = pendingReads.run(
|
|
65769
|
-
const bounded = boundedReads.get(read) ?? withTimeout(read, READ_TIMEOUT_MS, `Timed out reading ${
|
|
66122
|
+
function readWithin(path8) {
|
|
66123
|
+
const read = pendingReads.run(path8, () => readFile23(path8, "utf8"));
|
|
66124
|
+
const bounded = boundedReads.get(read) ?? withTimeout(read, READ_TIMEOUT_MS, `Timed out reading ${path8}`);
|
|
65770
66125
|
boundedReads.set(read, bounded);
|
|
65771
66126
|
return bounded;
|
|
65772
66127
|
}
|
|
65773
|
-
var readOptional = (
|
|
66128
|
+
var readOptional = (path8) => readWithin(path8).catch(() => null);
|
|
65774
66129
|
function parseCounters(text) {
|
|
65775
66130
|
const counters = {};
|
|
65776
66131
|
for (const line of text?.split("\n") ?? []) {
|
|
@@ -65797,7 +66152,7 @@ var ResourceMonitor = class {
|
|
|
65797
66152
|
minute = null;
|
|
65798
66153
|
pending = [];
|
|
65799
66154
|
onMemorySample = null;
|
|
65800
|
-
cgroupEventsPath = readOptional("/proc/self/cgroup").then((text) => text?.match(/^0::(.*)$/m)?.[1]).then((
|
|
66155
|
+
cgroupEventsPath = readOptional("/proc/self/cgroup").then((text) => text?.match(/^0::(.*)$/m)?.[1]).then((path8) => path8 ? `/sys/fs/cgroup${path8.replace(/\/$/, "")}/memory.events` : null);
|
|
65801
66156
|
start() {
|
|
65802
66157
|
if (this.timer) return;
|
|
65803
66158
|
this.oomBaseline = this.readOomCounters();
|
|
@@ -65831,7 +66186,7 @@ var ResourceMonitor = class {
|
|
|
65831
66186
|
if (this.sampling) return;
|
|
65832
66187
|
this.sampling = true;
|
|
65833
66188
|
try {
|
|
65834
|
-
const [
|
|
66189
|
+
const [stat7, meminfo, cpuPressure, memoryPressure, ioPressure] = await Promise.all([
|
|
65835
66190
|
readWithin("/proc/stat"),
|
|
65836
66191
|
readWithin("/proc/meminfo"),
|
|
65837
66192
|
readOptional("/proc/pressure/cpu"),
|
|
@@ -65839,7 +66194,7 @@ var ResourceMonitor = class {
|
|
|
65839
66194
|
readOptional("/proc/pressure/io")
|
|
65840
66195
|
]);
|
|
65841
66196
|
if (!this.timer) return;
|
|
65842
|
-
const lines =
|
|
66197
|
+
const lines = stat7.split("\n");
|
|
65843
66198
|
const jiffies = lines[0].trim().split(/\s+/).slice(1, 9).map(Number);
|
|
65844
66199
|
const total = jiffies.reduce((sum, value) => sum + value, 0);
|
|
65845
66200
|
const cpu = { busy: total - jiffies[3] - jiffies[4], total };
|
|
@@ -65997,26 +66352,26 @@ var HeartbeatService = class _HeartbeatService {
|
|
|
65997
66352
|
var heartbeatService = new HeartbeatService();
|
|
65998
66353
|
|
|
65999
66354
|
// src/services/workspace-sdk-service.ts
|
|
66000
|
-
import { cp, mkdir as
|
|
66001
|
-
import { dirname as
|
|
66355
|
+
import { cp, mkdir as mkdir18 } from "fs/promises";
|
|
66356
|
+
import { dirname as dirname15, resolve as resolve7 } from "path";
|
|
66002
66357
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
66003
66358
|
async function installWorkspaceSdk() {
|
|
66004
|
-
const source =
|
|
66359
|
+
const source = resolve7(dirname15(fileURLToPath6(import.meta.url)), "../../workspace-sdk");
|
|
66005
66360
|
const targets = [
|
|
66006
|
-
|
|
66361
|
+
resolve7(ENGINE_ENV.HOME_DIR, "node_modules/@replicas/sdk"),
|
|
66007
66362
|
"/tmp/node_modules/@replicas/sdk"
|
|
66008
66363
|
];
|
|
66009
66364
|
await Promise.all(targets.map(async (target) => {
|
|
66010
|
-
await
|
|
66365
|
+
await mkdir18(target, { recursive: true });
|
|
66011
66366
|
await cp(source, target, { recursive: true, force: true });
|
|
66012
66367
|
}));
|
|
66013
66368
|
}
|
|
66014
66369
|
|
|
66015
66370
|
// src/services/git-push-tracker.ts
|
|
66016
|
-
import { mkdir as
|
|
66371
|
+
import { mkdir as mkdir19, rm as rm8 } from "fs/promises";
|
|
66017
66372
|
import { createServer as createServer3 } from "net";
|
|
66018
|
-
import { join as
|
|
66019
|
-
var SOCKET_PATH =
|
|
66373
|
+
import { join as join37 } from "path";
|
|
66374
|
+
var SOCKET_PATH = join37(ENGINE_DIR, "git-trace2.sock");
|
|
66020
66375
|
var MAX_LINE_LENGTH = 1024 * 1024;
|
|
66021
66376
|
var listening = null;
|
|
66022
66377
|
function startGitPushTracker() {
|
|
@@ -66026,7 +66381,7 @@ function startGitPushTracker() {
|
|
|
66026
66381
|
});
|
|
66027
66382
|
}
|
|
66028
66383
|
async function listen() {
|
|
66029
|
-
await
|
|
66384
|
+
await mkdir19(ENGINE_DIR, { recursive: true });
|
|
66030
66385
|
await rm8(SOCKET_PATH, { force: true });
|
|
66031
66386
|
const server3 = createServer3((socket) => {
|
|
66032
66387
|
let buffered = "";
|
|
@@ -66069,12 +66424,12 @@ async function listen() {
|
|
|
66069
66424
|
}).catch((error) => console.error("[GitPushTracker] Failed to track pushed repository:", error));
|
|
66070
66425
|
});
|
|
66071
66426
|
});
|
|
66072
|
-
await new Promise((
|
|
66427
|
+
await new Promise((resolve8, reject) => {
|
|
66073
66428
|
server3.once("error", reject);
|
|
66074
66429
|
server3.listen(SOCKET_PATH, () => {
|
|
66075
66430
|
server3.off("error", reject);
|
|
66076
66431
|
server3.on("error", (error) => console.error("[GitPushTracker] Socket error:", error));
|
|
66077
|
-
|
|
66432
|
+
resolve8();
|
|
66078
66433
|
});
|
|
66079
66434
|
});
|
|
66080
66435
|
process.env.GIT_TRACE2_EVENT = `af_unix:stream:${SOCKET_PATH}`;
|
|
@@ -66125,11 +66480,11 @@ async function checkActiveSSHSessions() {
|
|
|
66125
66480
|
}
|
|
66126
66481
|
}
|
|
66127
66482
|
function checkDesktopReady() {
|
|
66128
|
-
return new Promise((
|
|
66483
|
+
return new Promise((resolve8) => {
|
|
66129
66484
|
const socket = connect({ host: "127.0.0.1", port: DESKTOP_STREAM_PORT });
|
|
66130
66485
|
const done = (ready) => {
|
|
66131
66486
|
socket.destroy();
|
|
66132
|
-
|
|
66487
|
+
resolve8(ready);
|
|
66133
66488
|
};
|
|
66134
66489
|
socket.once("connect", () => done(true));
|
|
66135
66490
|
socket.once("error", () => done(false));
|
|
@@ -66273,7 +66628,7 @@ function startStatusBroadcaster() {
|
|
|
66273
66628
|
if (serialized !== previousRepoStatus) {
|
|
66274
66629
|
previousRepoStatus = serialized;
|
|
66275
66630
|
eventService.publish({
|
|
66276
|
-
id:
|
|
66631
|
+
id: randomUUID13(),
|
|
66277
66632
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66278
66633
|
type: "repo.status.changed",
|
|
66279
66634
|
payload: { repos }
|
|
@@ -66294,7 +66649,7 @@ function startStatusBroadcaster() {
|
|
|
66294
66649
|
if (engineStatusJson !== previousEngineStatus) {
|
|
66295
66650
|
previousEngineStatus = engineStatusJson;
|
|
66296
66651
|
eventService.publish({
|
|
66297
|
-
id:
|
|
66652
|
+
id: randomUUID13(),
|
|
66298
66653
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66299
66654
|
type: "engine.status.changed",
|
|
66300
66655
|
payload: { status: engineStatus }
|
|
@@ -66313,7 +66668,7 @@ function startStatusBroadcaster() {
|
|
|
66313
66668
|
previousHookStatus = hookSnapshot;
|
|
66314
66669
|
if (!lastHooksRunning && hooksRunning) {
|
|
66315
66670
|
eventService.publish({
|
|
66316
|
-
id:
|
|
66671
|
+
id: randomUUID13(),
|
|
66317
66672
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66318
66673
|
type: "hooks.started",
|
|
66319
66674
|
payload: { running: true, completed: false }
|
|
@@ -66322,7 +66677,7 @@ function startStatusBroadcaster() {
|
|
|
66322
66677
|
}
|
|
66323
66678
|
if (hooksRunning) {
|
|
66324
66679
|
eventService.publish({
|
|
66325
|
-
id:
|
|
66680
|
+
id: randomUUID13(),
|
|
66326
66681
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66327
66682
|
type: "hooks.progress",
|
|
66328
66683
|
payload: { running: true, completed: false }
|
|
@@ -66331,7 +66686,7 @@ function startStatusBroadcaster() {
|
|
|
66331
66686
|
}
|
|
66332
66687
|
if (lastHooksRunning && !hooksRunning && hooksCompleted && !hooksFailed) {
|
|
66333
66688
|
eventService.publish({
|
|
66334
|
-
id:
|
|
66689
|
+
id: randomUUID13(),
|
|
66335
66690
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66336
66691
|
type: "hooks.completed",
|
|
66337
66692
|
payload: { running: false, completed: true }
|
|
@@ -66340,7 +66695,7 @@ function startStatusBroadcaster() {
|
|
|
66340
66695
|
}
|
|
66341
66696
|
if (lastHooksRunning && !hooksRunning && hooksFailed) {
|
|
66342
66697
|
eventService.publish({
|
|
66343
|
-
id:
|
|
66698
|
+
id: randomUUID13(),
|
|
66344
66699
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66345
66700
|
type: "hooks.failed",
|
|
66346
66701
|
payload: { running: false, completed: hooksCompleted }
|
|
@@ -66348,7 +66703,7 @@ function startStatusBroadcaster() {
|
|
|
66348
66703
|
});
|
|
66349
66704
|
}
|
|
66350
66705
|
eventService.publish({
|
|
66351
|
-
id:
|
|
66706
|
+
id: randomUUID13(),
|
|
66352
66707
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66353
66708
|
type: "hooks.status",
|
|
66354
66709
|
payload: {
|
|
@@ -66451,7 +66806,7 @@ async function startBackgroundServices(signal) {
|
|
|
66451
66806
|
{ type: "engine.ready", payload: { version: "v1" } }
|
|
66452
66807
|
]) {
|
|
66453
66808
|
if (signal.aborted) return;
|
|
66454
|
-
await eventService.publish({ id:
|
|
66809
|
+
await eventService.publish({ id: randomUUID13(), ts: (/* @__PURE__ */ new Date()).toISOString(), ...event });
|
|
66455
66810
|
}
|
|
66456
66811
|
if (!signal.aborted) startStatusBroadcaster();
|
|
66457
66812
|
}
|
|
@@ -66489,18 +66844,20 @@ var server2 = serve(
|
|
|
66489
66844
|
);
|
|
66490
66845
|
server2.on("connection", recordProxyConnection);
|
|
66491
66846
|
server2.on("upgrade", (req, socket, head) => {
|
|
66492
|
-
const
|
|
66493
|
-
const sessionId = TERMINAL_SOCKET_PATH.exec(
|
|
66494
|
-
const device = DEVICE_SOCKET_PATH.exec(
|
|
66495
|
-
|
|
66496
|
-
|
|
66847
|
+
const path8 = new URL(req.url ?? "/", "http://engine").pathname;
|
|
66848
|
+
const sessionId = TERMINAL_SOCKET_PATH.exec(path8)?.[1];
|
|
66849
|
+
const device = DEVICE_SOCKET_PATH.exec(path8)?.[1];
|
|
66850
|
+
const exec = path8 === EXEC_SOCKET_PATH;
|
|
66851
|
+
if (!(sessionId || device || exec) || req.headers["x-replicas-engine-secret"] !== ENGINE_ENV.REPLICAS_ENGINE_SECRET || !lifecycle.active) {
|
|
66852
|
+
socket.end(`HTTP/1.1 ${sessionId || device || exec ? "401 Unauthorized" : "404 Not Found"}\r
|
|
66497
66853
|
Connection: close\r
|
|
66498
66854
|
\r
|
|
66499
66855
|
`);
|
|
66500
66856
|
return;
|
|
66501
66857
|
}
|
|
66502
66858
|
webSockets.handleUpgrade(req, socket, head, (ws) => {
|
|
66503
|
-
if (
|
|
66859
|
+
if (exec) attachExecSocket(ws);
|
|
66860
|
+
else if (sessionId) attachTerminalSocket(decodeURIComponent(sessionId), ws);
|
|
66504
66861
|
else if (device) acceptDeviceConnection(decodeURIComponent(device), ws, String(req.headers[DEVICE_HOST_KEYS_HEADER] ?? "").split(",").filter(Boolean));
|
|
66505
66862
|
});
|
|
66506
66863
|
});
|