mu-agent 0.2.9 → 0.2.11
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/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/judge/mu/index.js +329 -197
- package/package.json +3 -3
package/judge/mu/index.js
CHANGED
|
@@ -2687,9 +2687,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
2687
2687
|
}
|
|
2688
2688
|
close(callback) {
|
|
2689
2689
|
if (callback === void 0) {
|
|
2690
|
-
return new Promise((
|
|
2690
|
+
return new Promise((resolve16, reject) => {
|
|
2691
2691
|
this.close((err, data) => {
|
|
2692
|
-
return err ? reject(err) :
|
|
2692
|
+
return err ? reject(err) : resolve16(data);
|
|
2693
2693
|
});
|
|
2694
2694
|
});
|
|
2695
2695
|
}
|
|
@@ -2727,9 +2727,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
2727
2727
|
err = null;
|
|
2728
2728
|
}
|
|
2729
2729
|
if (callback === void 0) {
|
|
2730
|
-
return new Promise((
|
|
2730
|
+
return new Promise((resolve16, reject) => {
|
|
2731
2731
|
this.destroy(err, (err2, data) => {
|
|
2732
|
-
return err2 ? reject(err2) :
|
|
2732
|
+
return err2 ? reject(err2) : resolve16(data);
|
|
2733
2733
|
});
|
|
2734
2734
|
});
|
|
2735
2735
|
}
|
|
@@ -7686,12 +7686,12 @@ upgrade: ${upgrade}\r
|
|
|
7686
7686
|
cb();
|
|
7687
7687
|
}
|
|
7688
7688
|
}
|
|
7689
|
-
const waitForDrain = () => new Promise((
|
|
7689
|
+
const waitForDrain = () => new Promise((resolve16, reject) => {
|
|
7690
7690
|
assert(callback === null);
|
|
7691
7691
|
if (socket[kError]) {
|
|
7692
7692
|
reject(socket[kError]);
|
|
7693
7693
|
} else {
|
|
7694
|
-
callback =
|
|
7694
|
+
callback = resolve16;
|
|
7695
7695
|
}
|
|
7696
7696
|
});
|
|
7697
7697
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -9074,12 +9074,12 @@ var require_client_h2 = __commonJS({
|
|
|
9074
9074
|
cb();
|
|
9075
9075
|
}
|
|
9076
9076
|
}
|
|
9077
|
-
const waitForDrain = () => new Promise((
|
|
9077
|
+
const waitForDrain = () => new Promise((resolve16, reject) => {
|
|
9078
9078
|
assert(callback === null);
|
|
9079
9079
|
if (socket[kError]) {
|
|
9080
9080
|
reject(socket[kError]);
|
|
9081
9081
|
} else {
|
|
9082
|
-
callback =
|
|
9082
|
+
callback = resolve16;
|
|
9083
9083
|
}
|
|
9084
9084
|
});
|
|
9085
9085
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -9448,16 +9448,16 @@ var require_client = __commonJS({
|
|
|
9448
9448
|
return this[kNeedDrain] < 2;
|
|
9449
9449
|
}
|
|
9450
9450
|
[kClose]() {
|
|
9451
|
-
return new Promise((
|
|
9451
|
+
return new Promise((resolve16) => {
|
|
9452
9452
|
if (this[kSize]) {
|
|
9453
|
-
this[kClosedResolve] =
|
|
9453
|
+
this[kClosedResolve] = resolve16;
|
|
9454
9454
|
} else {
|
|
9455
|
-
|
|
9455
|
+
resolve16(null);
|
|
9456
9456
|
}
|
|
9457
9457
|
});
|
|
9458
9458
|
}
|
|
9459
9459
|
[kDestroy](err) {
|
|
9460
|
-
return new Promise((
|
|
9460
|
+
return new Promise((resolve16) => {
|
|
9461
9461
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
9462
9462
|
for (let i = 0; i < requests.length; i++) {
|
|
9463
9463
|
const request = requests[i];
|
|
@@ -9470,7 +9470,7 @@ var require_client = __commonJS({
|
|
|
9470
9470
|
this[kClosedResolve]();
|
|
9471
9471
|
this[kClosedResolve] = null;
|
|
9472
9472
|
}
|
|
9473
|
-
|
|
9473
|
+
resolve16(null);
|
|
9474
9474
|
};
|
|
9475
9475
|
if (this[kHTTPContext]) {
|
|
9476
9476
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -9883,8 +9883,8 @@ var require_pool_base = __commonJS({
|
|
|
9883
9883
|
}
|
|
9884
9884
|
return Promise.all(closeAll);
|
|
9885
9885
|
} else {
|
|
9886
|
-
return new Promise((
|
|
9887
|
-
this[kClosedResolve] =
|
|
9886
|
+
return new Promise((resolve16) => {
|
|
9887
|
+
this[kClosedResolve] = resolve16;
|
|
9888
9888
|
});
|
|
9889
9889
|
}
|
|
9890
9890
|
}
|
|
@@ -12547,7 +12547,7 @@ var require_readable = __commonJS({
|
|
|
12547
12547
|
if (this._readableState.closeEmitted) {
|
|
12548
12548
|
return Promise.resolve(null);
|
|
12549
12549
|
}
|
|
12550
|
-
return new Promise((
|
|
12550
|
+
return new Promise((resolve16, reject) => {
|
|
12551
12551
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
12552
12552
|
this.destroy(new AbortError());
|
|
12553
12553
|
}
|
|
@@ -12561,11 +12561,11 @@ var require_readable = __commonJS({
|
|
|
12561
12561
|
if (signal.aborted) {
|
|
12562
12562
|
reject(signal.reason ?? new AbortError());
|
|
12563
12563
|
} else {
|
|
12564
|
-
|
|
12564
|
+
resolve16(null);
|
|
12565
12565
|
}
|
|
12566
12566
|
});
|
|
12567
12567
|
} else {
|
|
12568
|
-
this.on("close",
|
|
12568
|
+
this.on("close", resolve16);
|
|
12569
12569
|
}
|
|
12570
12570
|
this.on("error", noop).on("data", () => {
|
|
12571
12571
|
if (this[kBytesRead] > limit) {
|
|
@@ -12593,7 +12593,7 @@ var require_readable = __commonJS({
|
|
|
12593
12593
|
}
|
|
12594
12594
|
function consume(stream, type) {
|
|
12595
12595
|
assert(!stream[kConsume]);
|
|
12596
|
-
return new Promise((
|
|
12596
|
+
return new Promise((resolve16, reject) => {
|
|
12597
12597
|
if (isUnusable(stream)) {
|
|
12598
12598
|
const rState = stream._readableState;
|
|
12599
12599
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -12608,7 +12608,7 @@ var require_readable = __commonJS({
|
|
|
12608
12608
|
stream[kConsume] = {
|
|
12609
12609
|
type,
|
|
12610
12610
|
stream,
|
|
12611
|
-
resolve:
|
|
12611
|
+
resolve: resolve16,
|
|
12612
12612
|
reject,
|
|
12613
12613
|
length: 0,
|
|
12614
12614
|
body: []
|
|
@@ -12686,18 +12686,18 @@ var require_readable = __commonJS({
|
|
|
12686
12686
|
return buffer;
|
|
12687
12687
|
}
|
|
12688
12688
|
function consumeEnd(consume2, encoding) {
|
|
12689
|
-
const { type, body, resolve:
|
|
12689
|
+
const { type, body, resolve: resolve16, stream, length } = consume2;
|
|
12690
12690
|
try {
|
|
12691
12691
|
if (type === "text") {
|
|
12692
|
-
|
|
12692
|
+
resolve16(chunksDecode(body, length, encoding));
|
|
12693
12693
|
} else if (type === "json") {
|
|
12694
|
-
|
|
12694
|
+
resolve16(JSON.parse(chunksDecode(body, length, encoding)));
|
|
12695
12695
|
} else if (type === "arrayBuffer") {
|
|
12696
|
-
|
|
12696
|
+
resolve16(chunksConcat(body, length).buffer);
|
|
12697
12697
|
} else if (type === "blob") {
|
|
12698
|
-
|
|
12698
|
+
resolve16(new Blob(body, { type: stream[kContentType] }));
|
|
12699
12699
|
} else if (type === "bytes") {
|
|
12700
|
-
|
|
12700
|
+
resolve16(chunksConcat(body, length));
|
|
12701
12701
|
}
|
|
12702
12702
|
consumeFinish(consume2);
|
|
12703
12703
|
} catch (err) {
|
|
@@ -12916,9 +12916,9 @@ var require_api_request = __commonJS({
|
|
|
12916
12916
|
};
|
|
12917
12917
|
function request(opts, callback) {
|
|
12918
12918
|
if (callback === void 0) {
|
|
12919
|
-
return new Promise((
|
|
12919
|
+
return new Promise((resolve16, reject) => {
|
|
12920
12920
|
request.call(this, opts, (err, data) => {
|
|
12921
|
-
return err ? reject(err) :
|
|
12921
|
+
return err ? reject(err) : resolve16(data);
|
|
12922
12922
|
});
|
|
12923
12923
|
});
|
|
12924
12924
|
}
|
|
@@ -13179,9 +13179,9 @@ var require_api_stream = __commonJS({
|
|
|
13179
13179
|
};
|
|
13180
13180
|
function stream(opts, factory, callback) {
|
|
13181
13181
|
if (callback === void 0) {
|
|
13182
|
-
return new Promise((
|
|
13182
|
+
return new Promise((resolve16, reject) => {
|
|
13183
13183
|
stream.call(this, opts, factory, (err, data) => {
|
|
13184
|
-
return err ? reject(err) :
|
|
13184
|
+
return err ? reject(err) : resolve16(data);
|
|
13185
13185
|
});
|
|
13186
13186
|
});
|
|
13187
13187
|
}
|
|
@@ -13481,9 +13481,9 @@ var require_api_upgrade = __commonJS({
|
|
|
13481
13481
|
};
|
|
13482
13482
|
function upgrade(opts, callback) {
|
|
13483
13483
|
if (callback === void 0) {
|
|
13484
|
-
return new Promise((
|
|
13484
|
+
return new Promise((resolve16, reject) => {
|
|
13485
13485
|
upgrade.call(this, opts, (err, data) => {
|
|
13486
|
-
return err ? reject(err) :
|
|
13486
|
+
return err ? reject(err) : resolve16(data);
|
|
13487
13487
|
});
|
|
13488
13488
|
});
|
|
13489
13489
|
}
|
|
@@ -13577,9 +13577,9 @@ var require_api_connect = __commonJS({
|
|
|
13577
13577
|
};
|
|
13578
13578
|
function connect2(opts, callback) {
|
|
13579
13579
|
if (callback === void 0) {
|
|
13580
|
-
return new Promise((
|
|
13580
|
+
return new Promise((resolve16, reject) => {
|
|
13581
13581
|
connect2.call(this, opts, (err, data) => {
|
|
13582
|
-
return err ? reject(err) :
|
|
13582
|
+
return err ? reject(err) : resolve16(data);
|
|
13583
13583
|
});
|
|
13584
13584
|
});
|
|
13585
13585
|
}
|
|
@@ -15046,7 +15046,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
15046
15046
|
"node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
15047
15047
|
"use strict";
|
|
15048
15048
|
var { writeFile: writeFile7, readFile: readFile8, mkdir: mkdir2 } = __require("node:fs/promises");
|
|
15049
|
-
var { dirname: dirname13, resolve:
|
|
15049
|
+
var { dirname: dirname13, resolve: resolve16 } = __require("node:path");
|
|
15050
15050
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
15051
15051
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
15052
15052
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -15262,7 +15262,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
15262
15262
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
15263
15263
|
}
|
|
15264
15264
|
try {
|
|
15265
|
-
const data = await readFile8(
|
|
15265
|
+
const data = await readFile8(resolve16(path), "utf8");
|
|
15266
15266
|
const parsed = JSON.parse(data);
|
|
15267
15267
|
if (Array.isArray(parsed)) {
|
|
15268
15268
|
this.#snapshots.clear();
|
|
@@ -15291,7 +15291,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
15291
15291
|
if (!path) {
|
|
15292
15292
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
15293
15293
|
}
|
|
15294
|
-
const resolvedPath =
|
|
15294
|
+
const resolvedPath = resolve16(path);
|
|
15295
15295
|
await mkdir2(dirname13(resolvedPath), { recursive: true });
|
|
15296
15296
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot2]) => ({
|
|
15297
15297
|
hash,
|
|
@@ -22955,7 +22955,7 @@ var require_fetch = __commonJS({
|
|
|
22955
22955
|
const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
|
|
22956
22956
|
return dispatchWithProtocolPreference(body);
|
|
22957
22957
|
function dispatchWithProtocolPreference(body2, allowH2) {
|
|
22958
|
-
return new Promise((
|
|
22958
|
+
return new Promise((resolve16, reject) => agent.dispatch(
|
|
22959
22959
|
{
|
|
22960
22960
|
path: hasTrailingQuestionMark ? `${path}?` : path,
|
|
22961
22961
|
origin: url.origin,
|
|
@@ -23038,7 +23038,7 @@ var require_fetch = __commonJS({
|
|
|
23038
23038
|
}
|
|
23039
23039
|
}
|
|
23040
23040
|
const onError = (err) => this.onResponseError(controller, err);
|
|
23041
|
-
|
|
23041
|
+
resolve16({
|
|
23042
23042
|
status,
|
|
23043
23043
|
statusText,
|
|
23044
23044
|
headersList,
|
|
@@ -23071,7 +23071,7 @@ var require_fetch = __commonJS({
|
|
|
23071
23071
|
fetchParams.controller.off("terminated", this.abort);
|
|
23072
23072
|
}
|
|
23073
23073
|
if (request.mode === "websocket" && allowH2 !== false && error?.code === "UND_ERR_INFO" && error?.message === "HTTP/2: Extended CONNECT protocol not supported by server") {
|
|
23074
|
-
|
|
23074
|
+
resolve16(dispatchWithProtocolPreference(body2, false));
|
|
23075
23075
|
return;
|
|
23076
23076
|
}
|
|
23077
23077
|
this.body?.destroy(error);
|
|
@@ -23088,7 +23088,7 @@ var require_fetch = __commonJS({
|
|
|
23088
23088
|
const rawHeaders = controller?.rawHeaders ?? [];
|
|
23089
23089
|
const headersList = new HeadersList();
|
|
23090
23090
|
appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders);
|
|
23091
|
-
|
|
23091
|
+
resolve16({
|
|
23092
23092
|
status,
|
|
23093
23093
|
statusText: STATUS_CODES[status],
|
|
23094
23094
|
headersList,
|
|
@@ -31157,8 +31157,8 @@ var KyrnRuntime = class {
|
|
|
31157
31157
|
let timer;
|
|
31158
31158
|
return Promise.race([
|
|
31159
31159
|
work,
|
|
31160
|
-
new Promise((
|
|
31161
|
-
timer = setTimeout(() =>
|
|
31160
|
+
new Promise((resolve16) => {
|
|
31161
|
+
timer = setTimeout(() => resolve16(void 0), left);
|
|
31162
31162
|
})
|
|
31163
31163
|
]).finally(() => {
|
|
31164
31164
|
if (timer) clearTimeout(timer);
|
|
@@ -31276,8 +31276,8 @@ function within(work, waitMs) {
|
|
|
31276
31276
|
let timer;
|
|
31277
31277
|
return Promise.race([
|
|
31278
31278
|
work,
|
|
31279
|
-
new Promise((
|
|
31280
|
-
timer = setTimeout(() =>
|
|
31279
|
+
new Promise((resolve16) => {
|
|
31280
|
+
timer = setTimeout(() => resolve16(void 0), waitMs);
|
|
31281
31281
|
})
|
|
31282
31282
|
]).finally(() => {
|
|
31283
31283
|
if (timer) clearTimeout(timer);
|
|
@@ -31924,14 +31924,14 @@ var JobManager = class {
|
|
|
31924
31924
|
scanFrom = offset;
|
|
31925
31925
|
return void 0;
|
|
31926
31926
|
};
|
|
31927
|
-
return new Promise((
|
|
31927
|
+
return new Promise((resolve16) => {
|
|
31928
31928
|
let timer;
|
|
31929
31929
|
const settle = (result) => {
|
|
31930
31930
|
if (timer) clearTimeout(timer);
|
|
31931
31931
|
job.listeners.delete(check);
|
|
31932
31932
|
request.signal?.removeEventListener("abort", onAbort);
|
|
31933
31933
|
job.waiting--;
|
|
31934
|
-
|
|
31934
|
+
resolve16(result);
|
|
31935
31935
|
};
|
|
31936
31936
|
const check = () => {
|
|
31937
31937
|
const line3 = scan2();
|
|
@@ -31969,13 +31969,13 @@ var JobManager = class {
|
|
|
31969
31969
|
}
|
|
31970
31970
|
/** Polls a condition that a job's end may change; resolves to whether it came true in time. */
|
|
31971
31971
|
until(job, condition, timeoutMs) {
|
|
31972
|
-
return new Promise((
|
|
31973
|
-
if (condition()) return
|
|
31972
|
+
return new Promise((resolve16) => {
|
|
31973
|
+
if (condition()) return resolve16(true);
|
|
31974
31974
|
const startedAt = Date.now();
|
|
31975
31975
|
const done = (result) => {
|
|
31976
31976
|
clearInterval(poll);
|
|
31977
31977
|
job.listeners.delete(check);
|
|
31978
|
-
|
|
31978
|
+
resolve16(result);
|
|
31979
31979
|
};
|
|
31980
31980
|
const check = () => {
|
|
31981
31981
|
if (condition()) done(true);
|
|
@@ -33000,6 +33000,10 @@ var BoardProjects = class {
|
|
|
33000
33000
|
}
|
|
33001
33001
|
};
|
|
33002
33002
|
|
|
33003
|
+
// packages/kyrn-judge/src/checkpoint/mutating.ts
|
|
33004
|
+
import { realpathSync } from "node:fs";
|
|
33005
|
+
import { isAbsolute as isAbsolute2, resolve as resolve3 } from "node:path";
|
|
33006
|
+
|
|
33003
33007
|
// packages/kyrn-judge/src/extension/shell-tools.ts
|
|
33004
33008
|
var SHELL_TOOLS = /* @__PURE__ */ new Set(["bash", "powershell"]);
|
|
33005
33009
|
function isShellTool(toolName) {
|
|
@@ -33023,7 +33027,7 @@ var READ_ONLY_TOOLS = /* @__PURE__ */ new Set([
|
|
|
33023
33027
|
]);
|
|
33024
33028
|
var SHELL_TRICKS = /[<>;&`\n\r]|\$\(|\$\{/;
|
|
33025
33029
|
var POWERSHELL_TRICKS = /[(){}]/;
|
|
33026
|
-
var READ_ONLY_PROGRAM = /^(?:ls|pwd|cat|head|tail|wc|which|file|stat|du|df|date|whoami|uname|echo|printf|rg|grep|sort|uniq|cut|nl|tree|git
|
|
33030
|
+
var READ_ONLY_PROGRAM = /^(?:ls|pwd|cat|head|tail|wc|which|file|stat|du|df|date|whoami|uname|echo|printf|rg|grep|sort|uniq|cut|nl|tree|git|Get-ChildItem|gci|dir|Get-Content|gc|type|Get-Location|Select-String|sls|Get-Item|gi|Get-Date|Write-Output|Write-Host)(?:\s|$)/i;
|
|
33027
33031
|
var WRITES_OR_RUNS = /* @__PURE__ */ new Map([
|
|
33028
33032
|
// ripgrep runs `--pre` on every file it searches, and `--hostname-bin` for its links.
|
|
33029
33033
|
["rg", /(?:^|\s)--(?:pre|hostname-bin)(?:[\s=]|$)/],
|
|
@@ -33048,21 +33052,145 @@ function longOption(words2, option, shortest = 1) {
|
|
|
33048
33052
|
return name.length >= shortest && option.startsWith(name);
|
|
33049
33053
|
});
|
|
33050
33054
|
}
|
|
33051
|
-
|
|
33055
|
+
var GIT_READS = /* @__PURE__ */ new Set([
|
|
33056
|
+
"status",
|
|
33057
|
+
"log",
|
|
33058
|
+
"diff",
|
|
33059
|
+
"show",
|
|
33060
|
+
"blame",
|
|
33061
|
+
"rev-parse",
|
|
33062
|
+
"ls-files",
|
|
33063
|
+
"describe",
|
|
33064
|
+
"shortlog",
|
|
33065
|
+
"rev-list",
|
|
33066
|
+
"ls-tree",
|
|
33067
|
+
"cat-file",
|
|
33068
|
+
"merge-base",
|
|
33069
|
+
"name-rev",
|
|
33070
|
+
"for-each-ref",
|
|
33071
|
+
"show-ref",
|
|
33072
|
+
"diff-tree",
|
|
33073
|
+
"diff-index",
|
|
33074
|
+
"diff-files",
|
|
33075
|
+
"grep",
|
|
33076
|
+
"version"
|
|
33077
|
+
]);
|
|
33078
|
+
var GIT_LISTS = /* @__PURE__ */ new Map([
|
|
33079
|
+
[
|
|
33080
|
+
"branch",
|
|
33081
|
+
{
|
|
33082
|
+
long: /* @__PURE__ */ new Set([
|
|
33083
|
+
"show-current",
|
|
33084
|
+
"list",
|
|
33085
|
+
"all",
|
|
33086
|
+
"remotes",
|
|
33087
|
+
"verbose",
|
|
33088
|
+
"contains",
|
|
33089
|
+
"no-contains",
|
|
33090
|
+
"merged",
|
|
33091
|
+
"no-merged",
|
|
33092
|
+
"points-at",
|
|
33093
|
+
"sort",
|
|
33094
|
+
"format",
|
|
33095
|
+
"color",
|
|
33096
|
+
"no-color",
|
|
33097
|
+
"column",
|
|
33098
|
+
"no-column",
|
|
33099
|
+
"abbrev",
|
|
33100
|
+
"no-abbrev",
|
|
33101
|
+
"ignore-case",
|
|
33102
|
+
"omit-empty"
|
|
33103
|
+
]),
|
|
33104
|
+
short: /^-[ailrv]+$/,
|
|
33105
|
+
listing: /^(?:--(?:list|contains|no-contains|merged|no-merged|points-at)(?:=|$)|-[ailrv]*l)/
|
|
33106
|
+
}
|
|
33107
|
+
],
|
|
33108
|
+
[
|
|
33109
|
+
"tag",
|
|
33110
|
+
{
|
|
33111
|
+
long: /* @__PURE__ */ new Set([
|
|
33112
|
+
"list",
|
|
33113
|
+
"contains",
|
|
33114
|
+
"no-contains",
|
|
33115
|
+
"merged",
|
|
33116
|
+
"no-merged",
|
|
33117
|
+
"points-at",
|
|
33118
|
+
"sort",
|
|
33119
|
+
"format",
|
|
33120
|
+
"color",
|
|
33121
|
+
"no-color",
|
|
33122
|
+
"column",
|
|
33123
|
+
"no-column",
|
|
33124
|
+
"ignore-case",
|
|
33125
|
+
"omit-empty"
|
|
33126
|
+
]),
|
|
33127
|
+
// `-v` is not here: it verifies a tag with the program the config names.
|
|
33128
|
+
short: /^-(?:[il]+|n\d*)$/,
|
|
33129
|
+
listing: /^(?:--(?:list|contains|no-contains|merged|no-merged|points-at)(?:=|$)|-i*l|-n)/
|
|
33130
|
+
}
|
|
33131
|
+
]
|
|
33132
|
+
]);
|
|
33133
|
+
var CONFIG_SHOWS = /^(?:--(?:global|system|local|worktree|file|blob|show-origin|show-scope|name-only|null|includes|no-includes|type|bool|int|bool-or-int|path|expiry-date|default)(?:=|$)|-z$)/;
|
|
33134
|
+
var CONFIG_GETS = /^(?:--(?:get|get-all|get-regexp|get-urlmatch|list)|-l)$/;
|
|
33135
|
+
function readOnlyGit(args) {
|
|
33136
|
+
let at = 0;
|
|
33137
|
+
while (/^(?:-P|--no-pager|--no-optional-locks)$/.test(args[at] ?? "")) at++;
|
|
33138
|
+
const [command, ...rest] = args.slice(at);
|
|
33139
|
+
if (command === "--version") return rest.length === 0;
|
|
33140
|
+
if (command === "grep") {
|
|
33141
|
+
return !rest.some((arg) => /^-[a-zA-Z]*O/.test(arg)) && !longOption(rest, "open-files-in-pager");
|
|
33142
|
+
}
|
|
33143
|
+
if (command !== void 0 && GIT_READS.has(command)) return true;
|
|
33144
|
+
const list4 = command === void 0 ? void 0 : GIT_LISTS.get(command);
|
|
33145
|
+
if (list4) {
|
|
33146
|
+
let named = false;
|
|
33147
|
+
for (const arg of rest) {
|
|
33148
|
+
if (arg.startsWith("--")) {
|
|
33149
|
+
if (!list4.long.has(arg.slice(2).split("=")[0])) return false;
|
|
33150
|
+
} else if (arg.startsWith("-")) {
|
|
33151
|
+
if (!list4.short.test(arg)) return false;
|
|
33152
|
+
} else named = true;
|
|
33153
|
+
}
|
|
33154
|
+
return !named || rest.some((arg) => list4.listing.test(arg));
|
|
33155
|
+
}
|
|
33156
|
+
if (command === "stash") return rest[0] === "list" || rest[0] === "show";
|
|
33157
|
+
if (command === "worktree") return rest[0] === "list";
|
|
33158
|
+
if (command === "remote") return rest[0] === "get-url" || rest.every((arg) => arg === "-v" || arg === "--verbose");
|
|
33159
|
+
if (command === "config") {
|
|
33160
|
+
if (rest[0] === "get" || rest[0] === "list") return true;
|
|
33161
|
+
const names = rest.filter((arg) => !arg.startsWith("-")).length;
|
|
33162
|
+
return rest.every((arg) => !arg.startsWith("-") || CONFIG_GETS.test(arg) || CONFIG_SHOWS.test(arg)) && (rest.some((arg) => CONFIG_GETS.test(arg)) || names === 1);
|
|
33163
|
+
}
|
|
33164
|
+
return false;
|
|
33165
|
+
}
|
|
33166
|
+
function readOnlyProgram(piece, elsewhere = false) {
|
|
33052
33167
|
if (!READ_ONLY_PROGRAM.test(piece)) return false;
|
|
33053
33168
|
const words2 = piece.split(/\s+/);
|
|
33054
33169
|
if (longOption(words2, "output")) return false;
|
|
33055
33170
|
const program = words2[0].toLowerCase();
|
|
33171
|
+
if (program === "git") return !elsewhere && readOnlyGit(words2.slice(1));
|
|
33056
33172
|
if (program === "uniq") return !uniqWrites(words2);
|
|
33057
33173
|
if (program === "sort" && longOption(words2, "compress-program", 2)) return false;
|
|
33058
33174
|
if (program === "file" && longOption(words2, "compile", 2)) return false;
|
|
33059
33175
|
return !WRITES_OR_RUNS.get(program)?.test(piece);
|
|
33060
33176
|
}
|
|
33061
|
-
function
|
|
33177
|
+
function samePlace(dir, cwd) {
|
|
33178
|
+
if (resolve3(dir) === resolve3(cwd)) return true;
|
|
33179
|
+
try {
|
|
33180
|
+
return realpathSync.native(dir) === realpathSync.native(cwd);
|
|
33181
|
+
} catch {
|
|
33182
|
+
return false;
|
|
33183
|
+
}
|
|
33184
|
+
}
|
|
33185
|
+
function startsElsewhere(cwd, start) {
|
|
33186
|
+
return cwd !== void 0 && start !== void 0 && !samePlace(start, cwd);
|
|
33187
|
+
}
|
|
33188
|
+
function isReadOnlyCommand(command, powershell = false, cwd, start = cwd) {
|
|
33062
33189
|
const text9 = command.trim();
|
|
33063
33190
|
if (!text9 || SHELL_TRICKS.test(text9) || /--output\b/.test(text9)) return false;
|
|
33064
33191
|
if (powershell && POWERSHELL_TRICKS.test(text9)) return false;
|
|
33065
|
-
|
|
33192
|
+
const elsewhere = startsElsewhere(cwd, start);
|
|
33193
|
+
return text9.split("|").every((part) => readOnlyProgram(part.trim(), elsewhere));
|
|
33066
33194
|
}
|
|
33067
33195
|
var FIND_ACTS = /^-(?:delete|exec|ok|fprint|fls)/;
|
|
33068
33196
|
function harmlessRedirect(text9, at, both) {
|
|
@@ -33158,28 +33286,31 @@ function simpleCommands(text9) {
|
|
|
33158
33286
|
endCommand();
|
|
33159
33287
|
return commands;
|
|
33160
33288
|
}
|
|
33161
|
-
function isReadOnlyChain(command, powershell = false) {
|
|
33162
|
-
if (powershell) return isReadOnlyCommand(command, true);
|
|
33289
|
+
function isReadOnlyChain(command, powershell = false, cwd, start = cwd) {
|
|
33290
|
+
if (powershell) return isReadOnlyCommand(command, true, cwd, start);
|
|
33163
33291
|
const commands = simpleCommands(command.trim());
|
|
33164
33292
|
if (!commands?.some((words2) => words2.length > 0)) return false;
|
|
33165
|
-
let
|
|
33293
|
+
let elsewhere = startsElsewhere(cwd, start);
|
|
33166
33294
|
return commands.every((words2) => {
|
|
33167
33295
|
const [program] = words2;
|
|
33168
33296
|
if (program === void 0 || program === "true" || program === "false" || program === ":") return true;
|
|
33169
33297
|
if (program === "cd") {
|
|
33170
|
-
|
|
33298
|
+
const [, to, ...more] = words2;
|
|
33299
|
+
elsewhere = cwd === void 0 || to === void 0 || more.length > 0 || !isAbsolute2(to) || /[$*?[~]/.test(to) || to.split(/[\\/]/).includes("..") || !samePlace(to, cwd);
|
|
33171
33300
|
return true;
|
|
33172
33301
|
}
|
|
33173
33302
|
if (program === "find") return !words2.some((word) => FIND_ACTS.test(word));
|
|
33174
|
-
|
|
33175
|
-
return readOnlyProgram(words2.join(" "));
|
|
33303
|
+
return readOnlyProgram(words2.join(" "), elsewhere);
|
|
33176
33304
|
});
|
|
33177
33305
|
}
|
|
33178
|
-
function isMutatingCall(toolName, input) {
|
|
33306
|
+
function isMutatingCall(toolName, input, cwd) {
|
|
33179
33307
|
if (READ_ONLY_TOOLS.has(toolName)) return false;
|
|
33180
|
-
if (isShellTool(toolName)) return !isReadOnlyChain(String(input.command ?? ""), toolName === "powershell");
|
|
33308
|
+
if (isShellTool(toolName)) return !isReadOnlyChain(String(input.command ?? ""), toolName === "powershell", cwd);
|
|
33181
33309
|
return true;
|
|
33182
33310
|
}
|
|
33311
|
+
function shellStart(toolName, input, cwd) {
|
|
33312
|
+
return toolName === "bg_start" && typeof input.cwd === "string" && input.cwd ? resolve3(cwd, input.cwd) : cwd;
|
|
33313
|
+
}
|
|
33183
33314
|
var CHECK_COMMAND = /\b(?:vitest|jest|pytest|mocha|ava|tsc|eslint|biome|ruff|mypy|rspec|phpunit|ctest|tox|nox|gradle|mvn)\b|\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:test|build|check|lint|typecheck)\b|\b(?:cargo|go|dotnet|swift|make|deno)\s+(?:test|build|check|vet|clippy)\b|\bnode\b[^\n]*--test\b|\btest\.sh\b/;
|
|
33184
33315
|
function isCheckCommand(command) {
|
|
33185
33316
|
return CHECK_COMMAND.test(command);
|
|
@@ -34169,11 +34300,10 @@ function describeCall2(toolName, input) {
|
|
|
34169
34300
|
const body = text9(record4.content) || text9(record4.newText) || text9(record4.new_string) || text9(record4.rewrite);
|
|
34170
34301
|
return clip(`${path}${body ? ` <- ${body}` : ""}` || JSON.stringify(record4), 500);
|
|
34171
34302
|
}
|
|
34172
|
-
function readOnlyShell(toolName, input) {
|
|
34303
|
+
function readOnlyShell(toolName, input, cwd) {
|
|
34173
34304
|
if (!isShellTool(toolName) && toolName !== "bg_start") return false;
|
|
34174
|
-
const command = input?.command;
|
|
34175
34305
|
const powershell = toolName === "powershell" || toolName === "bg_start" && process.platform === "win32";
|
|
34176
|
-
return typeof command === "string" && isReadOnlyChain(command, powershell);
|
|
34306
|
+
return typeof input.command === "string" && isReadOnlyChain(input.command, powershell, cwd, shellStart(toolName, input, cwd));
|
|
34177
34307
|
}
|
|
34178
34308
|
function registerConstraints(runtime) {
|
|
34179
34309
|
const options = runtime.options("constraints", {
|
|
@@ -34189,7 +34319,7 @@ function registerConstraints(runtime) {
|
|
|
34189
34319
|
failOpen(async (event, ctx) => {
|
|
34190
34320
|
runtime.touch(ctx);
|
|
34191
34321
|
if (!MUTATING.has(event.toolName)) return void 0;
|
|
34192
|
-
if (options.skipReadOnly && readOnlyShell(event.toolName, event.input)) return void 0;
|
|
34322
|
+
if (options.skipReadOnly && readOnlyShell(event.toolName, event.input, ctx.cwd)) return void 0;
|
|
34193
34323
|
const constraints = (runtime.frame?.constraints ?? []).slice(-options.maxConstraints).map((entry) => entry.text);
|
|
34194
34324
|
const mode = runtime.mode(toolConstraint.id);
|
|
34195
34325
|
if (constraints.length === 0 || mode === "off") return void 0;
|
|
@@ -34201,7 +34331,7 @@ function registerConstraints(runtime) {
|
|
|
34201
34331
|
}
|
|
34202
34332
|
const decision = await Promise.race([
|
|
34203
34333
|
runtime.engine.decide(toolConstraint, input, { signal: ctx.signal }),
|
|
34204
|
-
new Promise((
|
|
34334
|
+
new Promise((resolve16) => setTimeout(() => resolve16(void 0), options.waitMs))
|
|
34205
34335
|
]);
|
|
34206
34336
|
if (!decision || decision.mode !== "active" || decision.source !== "judge") return void 0;
|
|
34207
34337
|
const broken = decision.outcome.broken.map((index) => constraints[index]).filter(Boolean);
|
|
@@ -35688,9 +35818,9 @@ function isLoopbackUrl(url) {
|
|
|
35688
35818
|
if (host2 === "localhost" || host2.endsWith(".localhost")) return true;
|
|
35689
35819
|
return isIP(host2) !== 0 && classifyAddress(host2) === "loopback";
|
|
35690
35820
|
}
|
|
35691
|
-
function checkedLookup(policy,
|
|
35821
|
+
function checkedLookup(policy, resolve16 = dnsLookup) {
|
|
35692
35822
|
return (hostname, options, callback) => {
|
|
35693
|
-
|
|
35823
|
+
resolve16(hostname, { ...options, all: true }, (error, answer) => {
|
|
35694
35824
|
if (error) return callback(error);
|
|
35695
35825
|
const addresses = Array.isArray(answer) ? answer : [];
|
|
35696
35826
|
if (addresses.length === 0) return callback(new FetchRefusal("dns", `${hostname} has no address`));
|
|
@@ -35734,8 +35864,8 @@ var Bounds = class {
|
|
|
35734
35864
|
start;
|
|
35735
35865
|
resolve;
|
|
35736
35866
|
places = /* @__PURE__ */ new Map();
|
|
35737
|
-
constructor(start,
|
|
35738
|
-
this.resolve =
|
|
35867
|
+
constructor(start, resolve16 = systemResolve) {
|
|
35868
|
+
this.resolve = resolve16;
|
|
35739
35869
|
let parsed;
|
|
35740
35870
|
try {
|
|
35741
35871
|
parsed = new URL(start);
|
|
@@ -35928,7 +36058,7 @@ var SNAPSHOT_SCRIPT = String.raw`(() => {
|
|
|
35928
36058
|
// packages/kyrn-judge/src/browser/session.ts
|
|
35929
36059
|
var StalePage = class extends Error {
|
|
35930
36060
|
};
|
|
35931
|
-
var sleep = (ms) => new Promise((
|
|
36061
|
+
var sleep = (ms) => new Promise((resolve16) => setTimeout(resolve16, ms));
|
|
35932
36062
|
var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
35933
36063
|
var BrowserSession = class _BrowserSession {
|
|
35934
36064
|
/** The address this tab was opened on: where the run was asked to go, before any page sent it elsewhere. */
|
|
@@ -36313,7 +36443,7 @@ var CdpConnection = class _CdpConnection {
|
|
|
36313
36443
|
socket.addEventListener("error", () => this.failAll("The browser connection failed"));
|
|
36314
36444
|
}
|
|
36315
36445
|
static connect(url, timeoutMs = 5e3) {
|
|
36316
|
-
return new Promise((
|
|
36446
|
+
return new Promise((resolve16, reject) => {
|
|
36317
36447
|
const socket = new WebSocket(url);
|
|
36318
36448
|
const timer = setTimeout(() => {
|
|
36319
36449
|
socket.close();
|
|
@@ -36321,7 +36451,7 @@ var CdpConnection = class _CdpConnection {
|
|
|
36321
36451
|
}, timeoutMs);
|
|
36322
36452
|
socket.addEventListener("open", () => {
|
|
36323
36453
|
clearTimeout(timer);
|
|
36324
|
-
|
|
36454
|
+
resolve16(new _CdpConnection(socket));
|
|
36325
36455
|
});
|
|
36326
36456
|
socket.addEventListener("error", () => {
|
|
36327
36457
|
clearTimeout(timer);
|
|
@@ -36356,7 +36486,7 @@ var CdpConnection = class _CdpConnection {
|
|
|
36356
36486
|
send(method, params = {}, sessionId, timeoutMs = 3e4) {
|
|
36357
36487
|
if (this.closed) return Promise.reject(new CdpError("The browser connection is closed"));
|
|
36358
36488
|
const id = this.nextId++;
|
|
36359
|
-
return new Promise((
|
|
36489
|
+
return new Promise((resolve16, reject) => {
|
|
36360
36490
|
const timer = setTimeout(() => {
|
|
36361
36491
|
this.pending.delete(id);
|
|
36362
36492
|
reject(new CdpError(`The browser did not answer ${method} within ${Math.round(timeoutMs / 1e3)}s`));
|
|
@@ -36364,7 +36494,7 @@ var CdpConnection = class _CdpConnection {
|
|
|
36364
36494
|
this.pending.set(id, {
|
|
36365
36495
|
resolve: (value) => {
|
|
36366
36496
|
clearTimeout(timer);
|
|
36367
|
-
|
|
36497
|
+
resolve16(value);
|
|
36368
36498
|
},
|
|
36369
36499
|
reject: (error) => {
|
|
36370
36500
|
clearTimeout(timer);
|
|
@@ -36638,11 +36768,11 @@ async function isAlive(endpoint) {
|
|
|
36638
36768
|
}
|
|
36639
36769
|
function exitOf(child, ms) {
|
|
36640
36770
|
if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve();
|
|
36641
|
-
return new Promise((
|
|
36642
|
-
const timer = setTimeout(
|
|
36771
|
+
return new Promise((resolve16) => {
|
|
36772
|
+
const timer = setTimeout(resolve16, ms);
|
|
36643
36773
|
child.once("exit", () => {
|
|
36644
36774
|
clearTimeout(timer);
|
|
36645
|
-
|
|
36775
|
+
resolve16();
|
|
36646
36776
|
});
|
|
36647
36777
|
});
|
|
36648
36778
|
}
|
|
@@ -36684,7 +36814,7 @@ async function launchChrome(options = {}) {
|
|
|
36684
36814
|
code: "browser_exited_on_start",
|
|
36685
36815
|
params: { exitCode: child.exitCode }
|
|
36686
36816
|
});
|
|
36687
|
-
await new Promise((
|
|
36817
|
+
await new Promise((resolve16) => setTimeout(resolve16, 100));
|
|
36688
36818
|
}
|
|
36689
36819
|
child.kill();
|
|
36690
36820
|
await exitOf(child, 5e3);
|
|
@@ -36787,7 +36917,7 @@ var EmbeddedBrowser = class _EmbeddedBrowser {
|
|
|
36787
36917
|
const state = await this.control();
|
|
36788
36918
|
if (state.stop) return false;
|
|
36789
36919
|
if (!state.paused) return true;
|
|
36790
|
-
await new Promise((
|
|
36920
|
+
await new Promise((resolve16) => setTimeout(resolve16, pollMs));
|
|
36791
36921
|
}
|
|
36792
36922
|
}
|
|
36793
36923
|
};
|
|
@@ -37527,7 +37657,7 @@ ${result.stdout}`))
|
|
|
37527
37657
|
};
|
|
37528
37658
|
}
|
|
37529
37659
|
function spawnOnce(binary, timeoutMs, args, env, input, limit) {
|
|
37530
|
-
return new Promise((
|
|
37660
|
+
return new Promise((resolve16, reject) => {
|
|
37531
37661
|
let child;
|
|
37532
37662
|
try {
|
|
37533
37663
|
child = spawn4(binary, [...args], { env: { ...env }, windowsHide: true, stdio: ["pipe", "pipe", "pipe"] });
|
|
@@ -37563,10 +37693,10 @@ function spawnOnce(binary, timeoutMs, args, env, input, limit) {
|
|
|
37563
37693
|
child.on("close", (code) => {
|
|
37564
37694
|
clearTimeout(timer);
|
|
37565
37695
|
if (truncated) {
|
|
37566
|
-
|
|
37696
|
+
resolve16({ code: 0, stdout: Buffer.concat(out).toString("utf8"), stderr: "", truncated: true });
|
|
37567
37697
|
return;
|
|
37568
37698
|
}
|
|
37569
|
-
|
|
37699
|
+
resolve16({
|
|
37570
37700
|
code: timedOut ? TIMED_OUT : code ?? 1,
|
|
37571
37701
|
stdout: Buffer.concat(out).toString("utf8"),
|
|
37572
37702
|
stderr: timedOut ? `timed out after ${timeoutMs} ms` : Buffer.concat(err).toString("utf8")
|
|
@@ -37611,14 +37741,14 @@ import {
|
|
|
37611
37741
|
mkdirSync as mkdirSync8,
|
|
37612
37742
|
readdirSync as readdirSync2,
|
|
37613
37743
|
readFileSync as readFileSync9,
|
|
37614
|
-
realpathSync,
|
|
37744
|
+
realpathSync as realpathSync2,
|
|
37615
37745
|
rmdirSync,
|
|
37616
37746
|
rmSync as rmSync5,
|
|
37617
37747
|
statSync as statSync6,
|
|
37618
37748
|
unlinkSync as unlinkSync2,
|
|
37619
37749
|
writeFileSync as writeFileSync6
|
|
37620
37750
|
} from "node:fs";
|
|
37621
|
-
import { basename as basename3, dirname as dirname4, isAbsolute as
|
|
37751
|
+
import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute3, join as join17, relative, resolve as resolve4, sep } from "node:path";
|
|
37622
37752
|
var BUILT_IN_IGNORES = [
|
|
37623
37753
|
"node_modules/",
|
|
37624
37754
|
"bower_components/",
|
|
@@ -37696,7 +37826,7 @@ var SnapshotTooLarge = class extends Error {
|
|
|
37696
37826
|
function projectKey(root) {
|
|
37697
37827
|
let real2 = root;
|
|
37698
37828
|
try {
|
|
37699
|
-
real2 =
|
|
37829
|
+
real2 = realpathSync2.native(root);
|
|
37700
37830
|
} catch {
|
|
37701
37831
|
}
|
|
37702
37832
|
return createHash3("sha256").update(real2).digest("hex").slice(0, 16);
|
|
@@ -37715,9 +37845,9 @@ function isSafePath(path) {
|
|
|
37715
37845
|
}
|
|
37716
37846
|
var onDisk = (store, path) => join17(store.root, ...path.split("/"));
|
|
37717
37847
|
function realPath(path) {
|
|
37718
|
-
const absolute3 =
|
|
37848
|
+
const absolute3 = resolve4(path);
|
|
37719
37849
|
try {
|
|
37720
|
-
return
|
|
37850
|
+
return realpathSync2.native(absolute3);
|
|
37721
37851
|
} catch {
|
|
37722
37852
|
const parent = dirname4(absolute3);
|
|
37723
37853
|
return parent === absolute3 ? absolute3 : join17(realPath(parent), basename3(absolute3));
|
|
@@ -37725,7 +37855,7 @@ function realPath(path) {
|
|
|
37725
37855
|
}
|
|
37726
37856
|
function inside(outer, inner) {
|
|
37727
37857
|
const rel = relative(realPath(outer), realPath(inner));
|
|
37728
|
-
return rel === ".." || rel.startsWith(`..${sep}`) ||
|
|
37858
|
+
return rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute3(rel) ? void 0 : rel;
|
|
37729
37859
|
}
|
|
37730
37860
|
function isWithin(outer, inner) {
|
|
37731
37861
|
return inside(outer, inner) !== void 0;
|
|
@@ -38314,7 +38444,7 @@ function registerCheckpoint(runtime, roots, deps = {}) {
|
|
|
38314
38444
|
};
|
|
38315
38445
|
}
|
|
38316
38446
|
pending = void 0;
|
|
38317
|
-
const mutating = isMutatingCall(event.toolName, event.input);
|
|
38447
|
+
const mutating = isMutatingCall(event.toolName, event.input, ctx.cwd);
|
|
38318
38448
|
calls.set(event.toolCallId, { name: event.toolName, input: event.input, mutating });
|
|
38319
38449
|
if (mutating) turn.changed = true;
|
|
38320
38450
|
if (!mutating || off || turn.checkpoint || turn.snapshotFailed) return void 0;
|
|
@@ -38407,8 +38537,8 @@ function registerCheckpoint(runtime, roots, deps = {}) {
|
|
|
38407
38537
|
let body = `Abandoned because: ${reason}`;
|
|
38408
38538
|
const writer = runtime.writer();
|
|
38409
38539
|
if (writer && turn.steps.length > 0) {
|
|
38410
|
-
const timeout = new Promise((
|
|
38411
|
-
setTimeout(() =>
|
|
38540
|
+
const timeout = new Promise((resolve16) => {
|
|
38541
|
+
setTimeout(() => resolve16(void 0), 8e3).unref?.();
|
|
38412
38542
|
});
|
|
38413
38543
|
const reply = await Promise.race([
|
|
38414
38544
|
writer({
|
|
@@ -38752,8 +38882,8 @@ The agent will then start over from your request, with a note about what didn't
|
|
|
38752
38882
|
const wasBusy = busy > 0;
|
|
38753
38883
|
await Promise.race([
|
|
38754
38884
|
chain,
|
|
38755
|
-
new Promise((
|
|
38756
|
-
setTimeout(
|
|
38885
|
+
new Promise((resolve16) => {
|
|
38886
|
+
setTimeout(resolve16, 3e3).unref?.();
|
|
38757
38887
|
})
|
|
38758
38888
|
]);
|
|
38759
38889
|
if (store) releaseLocks(store, wasBusy && busy > 0 ? 0 : 12e4);
|
|
@@ -41038,8 +41168,8 @@ function registerFrame(runtime) {
|
|
|
41038
41168
|
let timer;
|
|
41039
41169
|
const late = await Promise.race([
|
|
41040
41170
|
ask.pending.then(() => false),
|
|
41041
|
-
new Promise((
|
|
41042
|
-
timer = setTimeout(() =>
|
|
41171
|
+
new Promise((resolve16) => {
|
|
41172
|
+
timer = setTimeout(() => resolve16(true), Math.max(0, options.waitMs - (Date.now() - ask.startedAt)));
|
|
41043
41173
|
})
|
|
41044
41174
|
]);
|
|
41045
41175
|
if (timer) clearTimeout(timer);
|
|
@@ -41891,7 +42021,7 @@ async function pkce() {
|
|
|
41891
42021
|
return { verifier, challenge: base64url(new Uint8Array(digest2)) };
|
|
41892
42022
|
}
|
|
41893
42023
|
function listen(config, state) {
|
|
41894
|
-
return new Promise((
|
|
42024
|
+
return new Promise((resolve16, reject) => {
|
|
41895
42025
|
let settle = () => {
|
|
41896
42026
|
};
|
|
41897
42027
|
const wait = new Promise((done) => {
|
|
@@ -41938,7 +42068,7 @@ function listen(config, state) {
|
|
|
41938
42068
|
server.listen(
|
|
41939
42069
|
config.callbackPort,
|
|
41940
42070
|
config.callbackHost,
|
|
41941
|
-
() =>
|
|
42071
|
+
() => resolve16({ server, wait, cancel: () => settle(void 0) })
|
|
41942
42072
|
);
|
|
41943
42073
|
});
|
|
41944
42074
|
}
|
|
@@ -42031,7 +42161,7 @@ async function geminiProject(config, token, interaction) {
|
|
|
42031
42161
|
if (!started.ok) throw new Error(`onboardUser failed (${started.status}): ${(await started.text()).slice(0, 300)}`);
|
|
42032
42162
|
let operation = await started.json();
|
|
42033
42163
|
for (let attempt = 0; !operation.done && operation.name && attempt < 60; attempt++) {
|
|
42034
|
-
await new Promise((
|
|
42164
|
+
await new Promise((resolve16) => setTimeout(resolve16, attempt === 0 ? 1e3 : 5e3));
|
|
42035
42165
|
const polled = await fetch(`${endpoint}/v1internal/${operation.name}`, { headers, signal: interaction.signal });
|
|
42036
42166
|
if (!polled.ok) throw new Error(`Setting up the project failed (${polled.status})`);
|
|
42037
42167
|
operation = await polled.json();
|
|
@@ -42911,7 +43041,7 @@ function gitArgs(args, platform = process.platform) {
|
|
|
42911
43041
|
];
|
|
42912
43042
|
}
|
|
42913
43043
|
var INHERITED = ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR", "GIT_PREFIX"];
|
|
42914
|
-
var spawnGit2 = (args, options) => new Promise((
|
|
43044
|
+
var spawnGit2 = (args, options) => new Promise((resolve16) => {
|
|
42915
43045
|
const env = { ...process.env };
|
|
42916
43046
|
for (const name of INHERITED) delete env[name];
|
|
42917
43047
|
Object.assign(env, { LC_ALL: "C", LANGUAGE: "C", GIT_TERMINAL_PROMPT: "0" }, options.env);
|
|
@@ -42928,7 +43058,7 @@ var spawnGit2 = (args, options) => new Promise((resolve15) => {
|
|
|
42928
43058
|
signal: options.signal
|
|
42929
43059
|
});
|
|
42930
43060
|
} catch (error) {
|
|
42931
|
-
|
|
43061
|
+
resolve16({ code: -1, stdout: Buffer.alloc(0), stderr: String(error), missing: true });
|
|
42932
43062
|
return;
|
|
42933
43063
|
}
|
|
42934
43064
|
child.stdout?.on("data", (chunk) => out.push(chunk));
|
|
@@ -42936,9 +43066,9 @@ var spawnGit2 = (args, options) => new Promise((resolve15) => {
|
|
|
42936
43066
|
stderr = (stderr + chunk.toString("utf8")).slice(-8e3);
|
|
42937
43067
|
});
|
|
42938
43068
|
child.on("error", (error) => {
|
|
42939
|
-
|
|
43069
|
+
resolve16({ code: -1, stdout: Buffer.concat(out), stderr: error.message, missing: error.code === "ENOENT" });
|
|
42940
43070
|
});
|
|
42941
|
-
child.on("close", (code) =>
|
|
43071
|
+
child.on("close", (code) => resolve16({ code: code ?? -1, stdout: Buffer.concat(out), stderr }));
|
|
42942
43072
|
child.stdin?.on("error", () => void 0);
|
|
42943
43073
|
child.stdin?.end(options.input);
|
|
42944
43074
|
});
|
|
@@ -43982,7 +44112,7 @@ var spawnRunner = async (task, assignment, signal, env, observer) => {
|
|
|
43982
44112
|
await writeFile2(promptPath, assignment.agent.systemPrompt, { encoding: "utf8", mode: 384 });
|
|
43983
44113
|
}
|
|
43984
44114
|
try {
|
|
43985
|
-
return await new Promise((
|
|
44115
|
+
return await new Promise((resolve16, reject) => {
|
|
43986
44116
|
const invocation = piInvocation(childArgs(task, assignment, promptPath));
|
|
43987
44117
|
const child = spawn6(invocation.command, invocation.args, {
|
|
43988
44118
|
// An isolated sub-agent works in its own checkout; everyone else where the parent is.
|
|
@@ -44019,7 +44149,7 @@ var spawnRunner = async (task, assignment, signal, env, observer) => {
|
|
|
44019
44149
|
finished = true;
|
|
44020
44150
|
signal?.removeEventListener("abort", onAbort);
|
|
44021
44151
|
if (error) reject(error);
|
|
44022
|
-
else
|
|
44152
|
+
else resolve16(lastText.trim());
|
|
44023
44153
|
};
|
|
44024
44154
|
const onAbort = () => {
|
|
44025
44155
|
terminate();
|
|
@@ -44766,7 +44896,7 @@ ${lines3.join("\n")}`);
|
|
|
44766
44896
|
return void 0;
|
|
44767
44897
|
}
|
|
44768
44898
|
if (lastCalled || !options.lastCall) return void 0;
|
|
44769
|
-
await Promise.race([queue, new Promise((
|
|
44899
|
+
await Promise.race([queue, new Promise((resolve16) => setTimeout(resolve16, LAST_CALL_WAIT_MS))]);
|
|
44770
44900
|
if (inbox.length === 0) return void 0;
|
|
44771
44901
|
const lines2 = takeInbox();
|
|
44772
44902
|
if (lines2.length === 0) return void 0;
|
|
@@ -44778,7 +44908,7 @@ ${lines3.join("\n")}`);
|
|
|
44778
44908
|
runtime.pi.on(
|
|
44779
44909
|
"agent_end",
|
|
44780
44910
|
failOpen(async () => {
|
|
44781
|
-
await Promise.race([queue, new Promise((
|
|
44911
|
+
await Promise.race([queue, new Promise((resolve16) => setTimeout(resolve16, 6e3))]);
|
|
44782
44912
|
return void 0;
|
|
44783
44913
|
})
|
|
44784
44914
|
);
|
|
@@ -45077,12 +45207,12 @@ function registerHiveCommand(runtime) {
|
|
|
45077
45207
|
return void 0;
|
|
45078
45208
|
})
|
|
45079
45209
|
);
|
|
45080
|
-
const untilTurnEnds = () => new Promise((
|
|
45210
|
+
const untilTurnEnds = () => new Promise((resolve16) => {
|
|
45081
45211
|
let timer;
|
|
45082
45212
|
const over = () => {
|
|
45083
45213
|
clearTimeout(timer);
|
|
45084
45214
|
waiting = void 0;
|
|
45085
|
-
|
|
45215
|
+
resolve16();
|
|
45086
45216
|
};
|
|
45087
45217
|
waiting = { started: false, over };
|
|
45088
45218
|
timer = setTimeout(() => {
|
|
@@ -45174,7 +45304,7 @@ var import_pi_coding_agent9 = __toESM(require_pi_coding_agent(), 1);
|
|
|
45174
45304
|
var import_pi_tui4 = __toESM(require_pi_tui(), 1);
|
|
45175
45305
|
|
|
45176
45306
|
// packages/kyrn-judge/src/import/index.ts
|
|
45177
|
-
import { mkdirSync as mkdirSync13, readdirSync as readdirSync6, readFileSync as readFileSync16, realpathSync as
|
|
45307
|
+
import { mkdirSync as mkdirSync13, readdirSync as readdirSync6, readFileSync as readFileSync16, realpathSync as realpathSync3, renameSync as renameSync7, statSync as statSync11, writeFileSync as writeFileSync11 } from "node:fs";
|
|
45178
45308
|
import { homedir as homedir7 } from "node:os";
|
|
45179
45309
|
import { join as join32 } from "node:path";
|
|
45180
45310
|
|
|
@@ -45300,7 +45430,7 @@ function list2(value) {
|
|
|
45300
45430
|
import { createHash as createHash5, randomBytes as randomBytes2, randomUUID as randomUUID7 } from "node:crypto";
|
|
45301
45431
|
import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync5, renameSync as renameSync6, rmSync as rmSync7, statSync as statSync7, writeSync } from "node:fs";
|
|
45302
45432
|
import { homedir as homedir5 } from "node:os";
|
|
45303
|
-
import { isAbsolute as
|
|
45433
|
+
import { isAbsolute as isAbsolute4, join as join30, resolve as resolve5 } from "node:path";
|
|
45304
45434
|
var TOOL_NAMES = {
|
|
45305
45435
|
"claude-code": "Claude Code",
|
|
45306
45436
|
codex: "Codex",
|
|
@@ -45353,7 +45483,7 @@ function expand(path) {
|
|
|
45353
45483
|
}
|
|
45354
45484
|
function absolute(path, base = process.cwd()) {
|
|
45355
45485
|
const expanded = expand(path);
|
|
45356
|
-
return
|
|
45486
|
+
return isAbsolute4(expanded) ? resolve5(expanded) : resolve5(base, expanded);
|
|
45357
45487
|
}
|
|
45358
45488
|
function defaultSessionDir(cwd, agentDir) {
|
|
45359
45489
|
const safe = `--${absolute(cwd).replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
@@ -47180,7 +47310,7 @@ function sameFolder(a, b) {
|
|
|
47180
47310
|
const canonical2 = (dir) => {
|
|
47181
47311
|
const path = absolute(dir);
|
|
47182
47312
|
try {
|
|
47183
|
-
return
|
|
47313
|
+
return realpathSync3.native(path);
|
|
47184
47314
|
} catch {
|
|
47185
47315
|
return path;
|
|
47186
47316
|
}
|
|
@@ -47599,15 +47729,15 @@ ${theme.fg("dim", detail)}`, 0, 0));
|
|
|
47599
47729
|
}
|
|
47600
47730
|
|
|
47601
47731
|
// packages/kyrn-judge/src/extension/features/inherit.ts
|
|
47602
|
-
import { isAbsolute as
|
|
47732
|
+
import { isAbsolute as isAbsolute5, join as join38, resolve as resolve8 } from "node:path";
|
|
47603
47733
|
|
|
47604
47734
|
// packages/kyrn-judge/src/inherit/files.ts
|
|
47605
|
-
import { existsSync as existsSync13, readdirSync as readdirSync7, readFileSync as readFileSync17, realpathSync as
|
|
47606
|
-
import { dirname as dirname7, join as join33, resolve as
|
|
47735
|
+
import { existsSync as existsSync13, readdirSync as readdirSync7, readFileSync as readFileSync17, realpathSync as realpathSync4, statSync as statSync12 } from "node:fs";
|
|
47736
|
+
import { dirname as dirname7, join as join33, resolve as resolve6 } from "node:path";
|
|
47607
47737
|
var MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
47608
47738
|
function projectChain(projectDir, home) {
|
|
47609
|
-
const start =
|
|
47610
|
-
const homeDir =
|
|
47739
|
+
const start = resolve6(projectDir);
|
|
47740
|
+
const homeDir = resolve6(home);
|
|
47611
47741
|
const chain = [];
|
|
47612
47742
|
let current = start;
|
|
47613
47743
|
for (let depth = 0; depth < 32; depth++) {
|
|
@@ -47666,9 +47796,9 @@ function listFiles(dir, extensions, depth = 4) {
|
|
|
47666
47796
|
}
|
|
47667
47797
|
function canonical(path) {
|
|
47668
47798
|
try {
|
|
47669
|
-
return
|
|
47799
|
+
return realpathSync4(path);
|
|
47670
47800
|
} catch {
|
|
47671
|
-
return
|
|
47801
|
+
return resolve6(path);
|
|
47672
47802
|
}
|
|
47673
47803
|
}
|
|
47674
47804
|
|
|
@@ -47931,7 +48061,7 @@ import { mkdirSync as mkdirSync14, readFileSync as readFileSync18, writeFileSync
|
|
|
47931
48061
|
import { dirname as dirname8, join as join37 } from "node:path";
|
|
47932
48062
|
|
|
47933
48063
|
// packages/kyrn-judge/src/inherit/mcp-config.ts
|
|
47934
|
-
import { join as join35, resolve as
|
|
48064
|
+
import { join as join35, resolve as resolve7 } from "node:path";
|
|
47935
48065
|
|
|
47936
48066
|
// packages/kyrn-judge/src/inherit/json-members.ts
|
|
47937
48067
|
var QUOTE = 34;
|
|
@@ -48374,7 +48504,7 @@ function discoverMcpServers(options, problems) {
|
|
|
48374
48504
|
let disabledInClaude = /* @__PURE__ */ new Set();
|
|
48375
48505
|
if (inherit && switches.claude) {
|
|
48376
48506
|
const path = join35(roots.home, ".claude.json");
|
|
48377
|
-
const dirs = [
|
|
48507
|
+
const dirs = [resolve7(roots.projectDir), ...chain.slice(1)];
|
|
48378
48508
|
const wanted = new Set(dirs.map((dir) => pathKey(dir, platform)));
|
|
48379
48509
|
const config = parseJson(path, problems, {
|
|
48380
48510
|
mcpServers: true,
|
|
@@ -48414,14 +48544,14 @@ function discoverMcpServers(options, problems) {
|
|
|
48414
48544
|
}
|
|
48415
48545
|
}
|
|
48416
48546
|
if (inherit) {
|
|
48417
|
-
const userFiles = /* @__PURE__ */ new Set([
|
|
48547
|
+
const userFiles = /* @__PURE__ */ new Set([resolve7(join35(roots.home, ".cursor", "mcp.json"))]);
|
|
48418
48548
|
for (const dir of chain) {
|
|
48419
48549
|
const files = [
|
|
48420
48550
|
{ path: join35(dir, ".mcp.json"), tool: "claude", on: switches.claude },
|
|
48421
48551
|
{ path: join35(dir, ".cursor", "mcp.json"), tool: "cursor", on: switches.cursor }
|
|
48422
48552
|
];
|
|
48423
48553
|
for (const file of files) {
|
|
48424
|
-
if (!file.on || userFiles.has(
|
|
48554
|
+
if (!file.on || userFiles.has(resolve7(file.path))) continue;
|
|
48425
48555
|
if (!roots.projectTrusted) {
|
|
48426
48556
|
if (readText(file.path, []) !== void 0) {
|
|
48427
48557
|
skipped.push({ name: "*", source: file.path, reason: "the project is not trusted" });
|
|
@@ -48753,7 +48883,7 @@ ${lines2.join("\n")}`
|
|
|
48753
48883
|
if (!scan2 || event.isError || !TOUCHING_TOOLS.includes(event.toolName)) return void 0;
|
|
48754
48884
|
const path = event.input.path;
|
|
48755
48885
|
if (typeof path !== "string" || !path) return void 0;
|
|
48756
|
-
const file =
|
|
48886
|
+
const file = isAbsolute5(path) ? path : resolve8(ctx.cwd, path);
|
|
48757
48887
|
const matching = rulesForFile(scan2.rules, file).filter((rule) => !delivered.has(rule.path));
|
|
48758
48888
|
if (matching.length === 0) return void 0;
|
|
48759
48889
|
const notes = matching.map((rule) => {
|
|
@@ -49472,7 +49602,7 @@ function decompressed(response) {
|
|
|
49472
49602
|
return response.pipe(through);
|
|
49473
49603
|
}
|
|
49474
49604
|
function once(url, limits, policy, signal) {
|
|
49475
|
-
return new Promise((
|
|
49605
|
+
return new Promise((resolve16, reject) => {
|
|
49476
49606
|
const send = url.protocol === "https:" ? httpsRequest : httpRequest;
|
|
49477
49607
|
const request = send(
|
|
49478
49608
|
url,
|
|
@@ -49488,7 +49618,7 @@ function once(url, limits, policy, signal) {
|
|
|
49488
49618
|
...limits.headers
|
|
49489
49619
|
}
|
|
49490
49620
|
},
|
|
49491
|
-
|
|
49621
|
+
resolve16
|
|
49492
49622
|
);
|
|
49493
49623
|
request.on("error", reject);
|
|
49494
49624
|
request.end();
|
|
@@ -50198,7 +50328,7 @@ ${lines2.join("\n\n")}`
|
|
|
50198
50328
|
id: "tool:web",
|
|
50199
50329
|
kind: "tool",
|
|
50200
50330
|
title: "Web reading and search",
|
|
50201
|
-
description: "Read a web page as text and search the web
|
|
50331
|
+
description: "Read a web page as text, and search the web with no key or through Tavily with TAVILY_API_KEY set. The default search source also works from mainland China.",
|
|
50202
50332
|
tools: ["web_fetch", "web_search"],
|
|
50203
50333
|
exposure: "always"
|
|
50204
50334
|
});
|
|
@@ -50450,8 +50580,8 @@ function registerInterjection(runtime) {
|
|
|
50450
50580
|
const earlier = previous;
|
|
50451
50581
|
let release = () => {
|
|
50452
50582
|
};
|
|
50453
|
-
previous = new Promise((
|
|
50454
|
-
release = () => setTimeout(
|
|
50583
|
+
previous = new Promise((resolve16) => {
|
|
50584
|
+
release = () => setTimeout(resolve16, 0);
|
|
50455
50585
|
});
|
|
50456
50586
|
try {
|
|
50457
50587
|
const other = await otherWay(event, sent).catch(() => void 0);
|
|
@@ -50682,7 +50812,7 @@ function registerLayaNotice(runtime, skipped, roots, muHome2) {
|
|
|
50682
50812
|
var import_pi_coding_agent12 = __toESM(require_pi_coding_agent(), 1);
|
|
50683
50813
|
import { readFileSync as readFileSync20, statSync as statSync15 } from "node:fs";
|
|
50684
50814
|
import { homedir as homedir8 } from "node:os";
|
|
50685
|
-
import { join as join40, relative as relative4, resolve as
|
|
50815
|
+
import { join as join40, relative as relative4, resolve as resolve9 } from "node:path";
|
|
50686
50816
|
|
|
50687
50817
|
// packages/kyrn-judge/src/decisions/diagnostics-delivery.ts
|
|
50688
50818
|
var diagnosticsDelivery = defineDecision({
|
|
@@ -51134,12 +51264,12 @@ var LspClient = class {
|
|
|
51134
51264
|
this.state = "stopping";
|
|
51135
51265
|
this.clearTimers();
|
|
51136
51266
|
if (child && child.exitCode === null && child.signalCode === null) {
|
|
51137
|
-
const gone = new Promise((
|
|
51267
|
+
const gone = new Promise((resolve16) => child.once("exit", () => resolve16()));
|
|
51138
51268
|
if (wasRunning) {
|
|
51139
51269
|
await this.request("shutdown", void 0, 2e3).catch(() => void 0);
|
|
51140
51270
|
this.notify("exit", void 0);
|
|
51141
51271
|
}
|
|
51142
|
-
await Promise.race([gone, new Promise((
|
|
51272
|
+
await Promise.race([gone, new Promise((resolve16) => setTimeout(resolve16, wasRunning ? 1e3 : 0))]);
|
|
51143
51273
|
killTree(child, this.platform);
|
|
51144
51274
|
}
|
|
51145
51275
|
this.state = "stopped";
|
|
@@ -51244,16 +51374,16 @@ var LspClient = class {
|
|
|
51244
51374
|
return true;
|
|
51245
51375
|
};
|
|
51246
51376
|
if (settled()) return Promise.resolve(true);
|
|
51247
|
-
return new Promise((
|
|
51377
|
+
return new Promise((resolve16) => {
|
|
51248
51378
|
const check = () => {
|
|
51249
51379
|
if (!settled()) return;
|
|
51250
51380
|
clearTimeout(timer);
|
|
51251
51381
|
this.waiters.delete(check);
|
|
51252
|
-
|
|
51382
|
+
resolve16(true);
|
|
51253
51383
|
};
|
|
51254
51384
|
const timer = setTimeout(() => {
|
|
51255
51385
|
this.waiters.delete(check);
|
|
51256
|
-
|
|
51386
|
+
resolve16(false);
|
|
51257
51387
|
}, budgetMs);
|
|
51258
51388
|
this.waiters.add(check);
|
|
51259
51389
|
});
|
|
@@ -51445,7 +51575,7 @@ var LspClient = class {
|
|
|
51445
51575
|
}
|
|
51446
51576
|
request(method, params, timeoutMs) {
|
|
51447
51577
|
const id = this.nextId++;
|
|
51448
|
-
return new Promise((
|
|
51578
|
+
return new Promise((resolve16, reject) => {
|
|
51449
51579
|
const timer = setTimeout(
|
|
51450
51580
|
() => {
|
|
51451
51581
|
this.pending.delete(id);
|
|
@@ -51454,7 +51584,7 @@ var LspClient = class {
|
|
|
51454
51584
|
},
|
|
51455
51585
|
timeoutMs ?? this.options.requestTimeoutMs ?? 1e4
|
|
51456
51586
|
);
|
|
51457
|
-
this.pending.set(id, { resolve:
|
|
51587
|
+
this.pending.set(id, { resolve: resolve16, reject, timer });
|
|
51458
51588
|
this.send({ id, method, params });
|
|
51459
51589
|
});
|
|
51460
51590
|
}
|
|
@@ -52149,7 +52279,7 @@ function registerLsp(runtime) {
|
|
|
52149
52279
|
const raw = event.input.path;
|
|
52150
52280
|
if (typeof raw !== "string" || !raw.trim()) return void 0;
|
|
52151
52281
|
const named = raw.startsWith("@") ? raw.slice(1) : raw;
|
|
52152
|
-
const file =
|
|
52282
|
+
const file = resolve9(
|
|
52153
52283
|
ctx.cwd,
|
|
52154
52284
|
named === "~" || named.startsWith("~/") ? join40(homedir8(), named.slice(1)) : named
|
|
52155
52285
|
);
|
|
@@ -52395,7 +52525,7 @@ function capabilityId(serverName) {
|
|
|
52395
52525
|
// packages/kyrn-judge/src/mcp/store.ts
|
|
52396
52526
|
import { createHash as createHash7 } from "node:crypto";
|
|
52397
52527
|
import { mkdirSync as mkdirSync16, readFileSync as readFileSync21, renameSync as renameSync9, writeFileSync as writeFileSync14 } from "node:fs";
|
|
52398
|
-
import { join as join41, resolve as
|
|
52528
|
+
import { join as join41, resolve as resolve10 } from "node:path";
|
|
52399
52529
|
var DESCRIPTION_LENGTH2 = 200;
|
|
52400
52530
|
function sorted(map) {
|
|
52401
52531
|
return Object.entries(map).sort(([left], [right]) => left.localeCompare(right));
|
|
@@ -52426,7 +52556,7 @@ function readJson(path, empty) {
|
|
|
52426
52556
|
function writeJson(path, value) {
|
|
52427
52557
|
if (!path) return;
|
|
52428
52558
|
try {
|
|
52429
|
-
mkdirSync16(
|
|
52559
|
+
mkdirSync16(resolve10(path, ".."), { recursive: true });
|
|
52430
52560
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
52431
52561
|
writeFileSync14(temporary, `${JSON.stringify(value, null, " ")}
|
|
52432
52562
|
`);
|
|
@@ -52464,11 +52594,11 @@ var McpStore = class {
|
|
|
52464
52594
|
writeJson(this.cachePath, this.cache);
|
|
52465
52595
|
}
|
|
52466
52596
|
isApproved(projectDir, server) {
|
|
52467
|
-
return this.approvals.projects?.[
|
|
52597
|
+
return this.approvals.projects?.[resolve10(projectDir)]?.[server.name] === definitionHash(server);
|
|
52468
52598
|
}
|
|
52469
52599
|
approve(projectDir, server) {
|
|
52470
52600
|
this.approvals = readJson(this.approvalPath, this.approvals);
|
|
52471
|
-
const project =
|
|
52601
|
+
const project = resolve10(projectDir);
|
|
52472
52602
|
this.approvals.projects = {
|
|
52473
52603
|
...this.approvals.projects,
|
|
52474
52604
|
[project]: { ...this.approvals.projects?.[project], [server.name]: definitionHash(server) }
|
|
@@ -52620,9 +52750,9 @@ function registerMcp(runtime, roots) {
|
|
|
52620
52750
|
if (!ctx) throw new Error("no session is running");
|
|
52621
52751
|
unregister(entry);
|
|
52622
52752
|
let timer;
|
|
52623
|
-
const settled = new Promise((
|
|
52624
|
-
timer = setTimeout(() =>
|
|
52625
|
-
entry.waiter =
|
|
52753
|
+
const settled = new Promise((resolve16) => {
|
|
52754
|
+
timer = setTimeout(() => resolve16(void 0), options.startTimeoutMs);
|
|
52755
|
+
entry.waiter = resolve16;
|
|
52626
52756
|
});
|
|
52627
52757
|
let event;
|
|
52628
52758
|
try {
|
|
@@ -54460,12 +54590,12 @@ import { posix as posix3, win32 as win323 } from "node:path";
|
|
|
54460
54590
|
var STDERR_LIMIT = 64 * 1024;
|
|
54461
54591
|
var KILL_GRACE_MS2 = 2e3;
|
|
54462
54592
|
var PIPE_GRACE_MS = 500;
|
|
54463
|
-
var run = (command, args, options = {}) => new Promise((
|
|
54593
|
+
var run = (command, args, options = {}) => new Promise((resolve16) => {
|
|
54464
54594
|
const platform = options.platform ?? process.platform;
|
|
54465
54595
|
const env = { ...process.env, ...options.env };
|
|
54466
54596
|
const invocation = invocationFor(command, args, { platform, env });
|
|
54467
54597
|
if (!invocation) {
|
|
54468
|
-
|
|
54598
|
+
resolve16({ code: 127, stdout: "", stderr: "", missing: true, stopped: false });
|
|
54469
54599
|
return;
|
|
54470
54600
|
}
|
|
54471
54601
|
const encoding = options.encoding ?? "utf8";
|
|
@@ -54511,7 +54641,7 @@ var run = (command, args, options = {}) => new Promise((resolve15) => {
|
|
|
54511
54641
|
if (late) clearTimeout(late);
|
|
54512
54642
|
options.signal?.removeEventListener("abort", stop);
|
|
54513
54643
|
if (options.onLine && carry && !stopped) options.onLine(carry);
|
|
54514
|
-
|
|
54644
|
+
resolve16({ code, stdout: Buffer.concat(chunks).toString(encoding), stderr, missing, stopped });
|
|
54515
54645
|
};
|
|
54516
54646
|
if (options.onLine) {
|
|
54517
54647
|
child.stdout?.setEncoding(encoding);
|
|
@@ -54612,7 +54742,7 @@ function installHint(binary, platform) {
|
|
|
54612
54742
|
var import_pi_coding_agent14 = __toESM(require_pi_coding_agent(), 1);
|
|
54613
54743
|
var import_typebox11 = __toESM(require_typebox(), 1);
|
|
54614
54744
|
import { readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
54615
|
-
import { resolve as
|
|
54745
|
+
import { resolve as resolve11 } from "node:path";
|
|
54616
54746
|
|
|
54617
54747
|
// packages/kyrn-judge/src/packs/ast-grep.ts
|
|
54618
54748
|
function sgArgs(query) {
|
|
@@ -54910,7 +55040,7 @@ function astGrepPack(shared, options) {
|
|
|
54910
55040
|
read: (path) => readFile3(path),
|
|
54911
55041
|
write: (path, data) => writeFile3(path, data),
|
|
54912
55042
|
locked: import_pi_coding_agent14.withFileMutationQueue,
|
|
54913
|
-
resolve: (file) =>
|
|
55043
|
+
resolve: (file) => resolve11(ctx.cwd, file)
|
|
54914
55044
|
},
|
|
54915
55045
|
{ apply: params.apply === true, maxDiffChars: options.maxDiffChars }
|
|
54916
55046
|
);
|
|
@@ -55602,9 +55732,9 @@ function report2(outcome) {
|
|
|
55602
55732
|
|
|
55603
55733
|
// packages/kyrn-judge/src/extension/features/packs/conflicts.ts
|
|
55604
55734
|
var import_typebox12 = __toESM(require_typebox(), 1);
|
|
55605
|
-
import { realpathSync as
|
|
55735
|
+
import { realpathSync as realpathSync5 } from "node:fs";
|
|
55606
55736
|
import { readFile as readFile5, writeFile as writeFile6 } from "node:fs/promises";
|
|
55607
|
-
import { basename as basename13, dirname as dirname11, isAbsolute as
|
|
55737
|
+
import { basename as basename13, dirname as dirname11, isAbsolute as isAbsolute6, join as join46, relative as relative5 } from "node:path";
|
|
55608
55738
|
|
|
55609
55739
|
// packages/kyrn-judge/src/packs/conflicts.ts
|
|
55610
55740
|
import { mkdtemp as mkdtemp2, rm as rm5, writeFile as writeFile5 } from "node:fs/promises";
|
|
@@ -55739,7 +55869,7 @@ function looksBinary(content) {
|
|
|
55739
55869
|
// packages/kyrn-judge/src/extension/features/packs/conflicts.ts
|
|
55740
55870
|
function real(path) {
|
|
55741
55871
|
try {
|
|
55742
|
-
return
|
|
55872
|
+
return realpathSync5.native(path);
|
|
55743
55873
|
} catch {
|
|
55744
55874
|
const parent = dirname11(path);
|
|
55745
55875
|
return parent === path ? path : join46(real(parent), basename13(path));
|
|
@@ -55759,7 +55889,7 @@ function conflictsPack(shared, options) {
|
|
|
55759
55889
|
return { repo, files };
|
|
55760
55890
|
};
|
|
55761
55891
|
const inRepo = (root, cwd, path) => {
|
|
55762
|
-
const inside2 = relative5(real(root), real(
|
|
55892
|
+
const inside2 = relative5(real(root), real(isAbsolute6(path) ? path : join46(cwd, path))).replaceAll("\\", "/");
|
|
55763
55893
|
if (inside2.startsWith("../") || inside2 === "..") throw new Error(`${path} is outside the repository`);
|
|
55764
55894
|
return inside2;
|
|
55765
55895
|
};
|
|
@@ -55944,7 +56074,7 @@ function conflictsPack(shared, options) {
|
|
|
55944
56074
|
|
|
55945
56075
|
// packages/kyrn-judge/src/extension/features/packs/debugger.ts
|
|
55946
56076
|
var import_typebox13 = __toESM(require_typebox(), 1);
|
|
55947
|
-
import { isAbsolute as
|
|
56077
|
+
import { isAbsolute as isAbsolute7, relative as relative6, resolve as resolve12 } from "node:path";
|
|
55948
56078
|
|
|
55949
56079
|
// packages/kyrn-judge/src/dap/adapters.ts
|
|
55950
56080
|
import { extname, posix as posix4, win32 as win324 } from "node:path";
|
|
@@ -56052,15 +56182,15 @@ import { spawn as spawn9, spawnSync as spawnSync2 } from "node:child_process";
|
|
|
56052
56182
|
import { connect, createServer as createServer2 } from "node:net";
|
|
56053
56183
|
var DapError = class extends Error {
|
|
56054
56184
|
};
|
|
56055
|
-
var sleep2 = (ms) => new Promise((
|
|
56185
|
+
var sleep2 = (ms) => new Promise((resolve16) => setTimeout(resolve16, ms));
|
|
56056
56186
|
async function freePort() {
|
|
56057
|
-
return new Promise((
|
|
56187
|
+
return new Promise((resolve16, reject) => {
|
|
56058
56188
|
const server = createServer2();
|
|
56059
56189
|
server.once("error", reject);
|
|
56060
56190
|
server.listen(0, "127.0.0.1", () => {
|
|
56061
56191
|
const address = server.address();
|
|
56062
56192
|
const port = typeof address === "object" && address ? address.port : 0;
|
|
56063
|
-
server.close(() =>
|
|
56193
|
+
server.close(() => resolve16(port));
|
|
56064
56194
|
});
|
|
56065
56195
|
});
|
|
56066
56196
|
}
|
|
@@ -56118,8 +56248,8 @@ var DapClient = class {
|
|
|
56118
56248
|
while (true) {
|
|
56119
56249
|
if (this.ended) throw new DapError(this.why());
|
|
56120
56250
|
try {
|
|
56121
|
-
const socket = await new Promise((
|
|
56122
|
-
const attempt = connect(port, "127.0.0.1", () =>
|
|
56251
|
+
const socket = await new Promise((resolve16, reject) => {
|
|
56252
|
+
const attempt = connect(port, "127.0.0.1", () => resolve16(attempt));
|
|
56123
56253
|
attempt.once("error", reject);
|
|
56124
56254
|
});
|
|
56125
56255
|
socket.on("close", () => this.fail("the debug adapter closed the connection"));
|
|
@@ -56195,7 +56325,7 @@ var DapClient = class {
|
|
|
56195
56325
|
request(command, args = {}, timeoutMs) {
|
|
56196
56326
|
if (this.ended) return Promise.reject(new DapError(`${command}: ${this.why()}`));
|
|
56197
56327
|
const seq = this.seq++;
|
|
56198
|
-
return new Promise((
|
|
56328
|
+
return new Promise((resolve16, reject) => {
|
|
56199
56329
|
const timer = setTimeout(
|
|
56200
56330
|
() => {
|
|
56201
56331
|
this.pending.delete(seq);
|
|
@@ -56203,7 +56333,7 @@ var DapClient = class {
|
|
|
56203
56333
|
},
|
|
56204
56334
|
timeoutMs ?? this.options.requestTimeoutMs ?? 3e4
|
|
56205
56335
|
);
|
|
56206
|
-
this.pending.set(seq, { command, resolve:
|
|
56336
|
+
this.pending.set(seq, { command, resolve: resolve16, reject, timer });
|
|
56207
56337
|
this.write({ seq, type: "request", command, arguments: args });
|
|
56208
56338
|
});
|
|
56209
56339
|
}
|
|
@@ -56219,12 +56349,12 @@ var DapClient = class {
|
|
|
56219
56349
|
if (names.includes(this.received[at].event)) return this.received[at];
|
|
56220
56350
|
}
|
|
56221
56351
|
if (this.ended || signal?.aborted || Date.now() >= deadline) return void 0;
|
|
56222
|
-
await new Promise((
|
|
56352
|
+
await new Promise((resolve16) => {
|
|
56223
56353
|
const wake = () => {
|
|
56224
56354
|
this.waiters.delete(wake);
|
|
56225
56355
|
signal?.removeEventListener("abort", wake);
|
|
56226
56356
|
clearTimeout(timer);
|
|
56227
|
-
|
|
56357
|
+
resolve16();
|
|
56228
56358
|
};
|
|
56229
56359
|
const timer = setTimeout(wake, Math.max(1, deadline - Date.now()));
|
|
56230
56360
|
this.waiters.add(wake);
|
|
@@ -56508,7 +56638,7 @@ var UNTRUSTED5 = "Values and output below come from the program being debugged:
|
|
|
56508
56638
|
function shown(path, cwd) {
|
|
56509
56639
|
if (!path) return "?";
|
|
56510
56640
|
const inside2 = relative6(cwd, path);
|
|
56511
|
-
return inside2 && !inside2.startsWith("..") && !
|
|
56641
|
+
return inside2 && !inside2.startsWith("..") && !isAbsolute7(inside2) ? inside2 : path;
|
|
56512
56642
|
}
|
|
56513
56643
|
function variableLine(variable) {
|
|
56514
56644
|
const type = variable.type ? ` (${variable.type})` : "";
|
|
@@ -56683,8 +56813,8 @@ function debuggerPack(shared, options) {
|
|
|
56683
56813
|
}),
|
|
56684
56814
|
execute: async (_toolCallId, params, signal, _onUpdate, ctx) => {
|
|
56685
56815
|
runtime.touch(ctx);
|
|
56686
|
-
const cwd = params.cwd ?
|
|
56687
|
-
const program = params.program ?
|
|
56816
|
+
const cwd = params.cwd ? resolve12(ctx.cwd, params.cwd) : ctx.cwd;
|
|
56817
|
+
const program = params.program ? resolve12(cwd, params.program) : void 0;
|
|
56688
56818
|
const extra = launchExtra(params.launch);
|
|
56689
56819
|
const module = typeof extra.module === "string" ? extra.module : void 0;
|
|
56690
56820
|
if (!program && !module) throw new Error("Name the program to run (or, for Python, launch.module).");
|
|
@@ -56723,7 +56853,7 @@ function debuggerPack(shared, options) {
|
|
|
56723
56853
|
spec.id,
|
|
56724
56854
|
launch,
|
|
56725
56855
|
params.breakpoints.map((point) => ({
|
|
56726
|
-
file:
|
|
56856
|
+
file: resolve12(cwd, point.file),
|
|
56727
56857
|
line: Math.max(1, Math.floor(point.line)),
|
|
56728
56858
|
condition: point.condition?.trim() || void 0
|
|
56729
56859
|
})),
|
|
@@ -57147,7 +57277,7 @@ function registerPacks(runtime) {
|
|
|
57147
57277
|
// packages/kyrn-judge/src/extension/features/permissions.ts
|
|
57148
57278
|
var import_pi_coding_agent15 = __toESM(require_pi_coding_agent(), 1);
|
|
57149
57279
|
import { homedir as homedir11 } from "node:os";
|
|
57150
|
-
import { join as join48, resolve as
|
|
57280
|
+
import { join as join48, resolve as resolve14, sep as sep3 } from "node:path";
|
|
57151
57281
|
|
|
57152
57282
|
// packages/kyrn-judge/src/decisions/tool-approval.ts
|
|
57153
57283
|
var APPROVE_AT = 0.8;
|
|
@@ -57187,9 +57317,9 @@ var toolApproval = defineDecision({
|
|
|
57187
57317
|
});
|
|
57188
57318
|
|
|
57189
57319
|
// packages/kyrn-judge/src/permissions/modes.ts
|
|
57190
|
-
import { lstatSync as lstatSync2, mkdirSync as mkdirSync18, readFileSync as readFileSync23, readlinkSync, realpathSync as
|
|
57320
|
+
import { lstatSync as lstatSync2, mkdirSync as mkdirSync18, readFileSync as readFileSync23, readlinkSync, realpathSync as realpathSync6, renameSync as renameSync10, writeFileSync as writeFileSync15 } from "node:fs";
|
|
57191
57321
|
import { homedir as homedir10 } from "node:os";
|
|
57192
|
-
import { basename as basename14, dirname as dirname12, isAbsolute as
|
|
57322
|
+
import { basename as basename14, dirname as dirname12, isAbsolute as isAbsolute8, join as join47, relative as relative7, resolve as resolve13, sep as sep2 } from "node:path";
|
|
57193
57323
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
57194
57324
|
var PERMISSION_MODES = ["full", "judge", "ask"];
|
|
57195
57325
|
var MODE_TEXT = {
|
|
@@ -57272,12 +57402,12 @@ function pathOf2(input) {
|
|
|
57272
57402
|
}
|
|
57273
57403
|
function realPath2(path, depth = 0) {
|
|
57274
57404
|
try {
|
|
57275
|
-
return
|
|
57405
|
+
return realpathSync6.native(path);
|
|
57276
57406
|
} catch {
|
|
57277
57407
|
if (depth < 40) {
|
|
57278
57408
|
try {
|
|
57279
57409
|
if (lstatSync2(path).isSymbolicLink())
|
|
57280
|
-
return realPath2(
|
|
57410
|
+
return realPath2(resolve13(dirname12(path), readlinkSync(path)), depth + 1);
|
|
57281
57411
|
} catch {
|
|
57282
57412
|
}
|
|
57283
57413
|
}
|
|
@@ -57305,12 +57435,12 @@ function toolPath(cwd, raw, home = homedir10()) {
|
|
|
57305
57435
|
return void 0;
|
|
57306
57436
|
}
|
|
57307
57437
|
}
|
|
57308
|
-
return realPath2(
|
|
57438
|
+
return realPath2(isAbsolute8(path) ? resolve13(path) : resolve13(cwd, path));
|
|
57309
57439
|
}
|
|
57310
57440
|
function inProject(cwd, target) {
|
|
57311
57441
|
if (target === void 0) return void 0;
|
|
57312
|
-
const rel = relative7(realPath2(
|
|
57313
|
-
return rel === ".." || rel.startsWith(`..${sep2}`) ||
|
|
57442
|
+
const rel = relative7(realPath2(resolve13(cwd)), target);
|
|
57443
|
+
return rel === ".." || rel.startsWith(`..${sep2}`) || isAbsolute8(rel) ? void 0 : rel;
|
|
57314
57444
|
}
|
|
57315
57445
|
function projectFile(cwd, target) {
|
|
57316
57446
|
const rel = inProject(cwd, target);
|
|
@@ -57345,7 +57475,9 @@ function permissionNeed(toolName, input, cwd, protectedPaths2 = [], chains = tru
|
|
|
57345
57475
|
if (isShellTool(toolName) || toolName === "bg_start") {
|
|
57346
57476
|
const command = text8(input.command);
|
|
57347
57477
|
const powershell = toolName === "powershell" || toolName === "bg_start" && process.platform === "win32";
|
|
57348
|
-
|
|
57478
|
+
const start = shellStart(toolName, input, cwd);
|
|
57479
|
+
if (chains ? isReadOnlyChain(command, powershell, cwd, start) : isReadOnlyCommand(command, powershell, cwd, start))
|
|
57480
|
+
return void 0;
|
|
57349
57481
|
const guarded = touches(command);
|
|
57350
57482
|
const prefix = commandPrefix(command);
|
|
57351
57483
|
return {
|
|
@@ -57361,7 +57493,7 @@ function permissionNeed(toolName, input, cwd, protectedPaths2 = [], chains = tru
|
|
|
57361
57493
|
const paths = [...path ? [path] : [], ...listed2];
|
|
57362
57494
|
const targets = paths.map((each) => ({ said: each, target: toolPath(cwd, each) }));
|
|
57363
57495
|
const summary = clip5(`${toolName} ${path || listed2.join(" ") || text8(input.id) || text8(input.pattern)}`, 300);
|
|
57364
|
-
const guarded = targets.flatMap(({ said, target }) => [
|
|
57496
|
+
const guarded = targets.flatMap(({ said, target }) => [resolve13(cwd, said), ...target ? [target] : []]).map(touches).find(Boolean);
|
|
57365
57497
|
if (guarded) return { kind: "edit", summary, protected: guarded };
|
|
57366
57498
|
const away = targets.find(({ target }) => !projectFile(cwd, target));
|
|
57367
57499
|
return away ? {
|
|
@@ -57482,7 +57614,7 @@ function protectedPaths(roots) {
|
|
|
57482
57614
|
return real2 && real2 !== roots.agentDir ? [...spelled, real2] : spelled;
|
|
57483
57615
|
}
|
|
57484
57616
|
function projectSettings(cwd) {
|
|
57485
|
-
const spelled = join48(
|
|
57617
|
+
const spelled = join48(resolve14(cwd), import_pi_coding_agent15.CONFIG_DIR_NAME);
|
|
57486
57618
|
const real2 = toolPath(cwd, import_pi_coding_agent15.CONFIG_DIR_NAME) ?? spelled;
|
|
57487
57619
|
return [.../* @__PURE__ */ new Set([spelled, real2])].map((path) => `${path}${sep3}`);
|
|
57488
57620
|
}
|
|
@@ -58276,8 +58408,8 @@ function registerPreflight(runtime) {
|
|
|
58276
58408
|
}
|
|
58277
58409
|
let skip = () => {
|
|
58278
58410
|
};
|
|
58279
|
-
const skipped = new Promise((
|
|
58280
|
-
skip = () =>
|
|
58411
|
+
const skipped = new Promise((resolve16) => {
|
|
58412
|
+
skip = () => resolve16("skipped");
|
|
58281
58413
|
});
|
|
58282
58414
|
const unsubscribe = panel ? ctx.ui.onTerminalInput((keys) => {
|
|
58283
58415
|
if (!(0, import_pi_tui6.matchesKey)(keys, "escape")) return void 0;
|
|
@@ -58285,8 +58417,8 @@ function registerPreflight(runtime) {
|
|
|
58285
58417
|
return { consume: true };
|
|
58286
58418
|
}) : void 0;
|
|
58287
58419
|
let timer;
|
|
58288
|
-
const timeout = new Promise((
|
|
58289
|
-
timer = setTimeout(() =>
|
|
58420
|
+
const timeout = new Promise((resolve16) => {
|
|
58421
|
+
timer = setTimeout(() => resolve16("timeout"), options.waitMs);
|
|
58290
58422
|
});
|
|
58291
58423
|
try {
|
|
58292
58424
|
current.waitEndedBy = await Promise.race([pending.then(() => "verdict"), timeout, skipped]);
|
|
@@ -58752,11 +58884,11 @@ var SandboxApiError = class extends Error {
|
|
|
58752
58884
|
this.status = status;
|
|
58753
58885
|
}
|
|
58754
58886
|
};
|
|
58755
|
-
var sleep3 = (ms, signal) => new Promise((
|
|
58887
|
+
var sleep3 = (ms, signal) => new Promise((resolve16, reject) => {
|
|
58756
58888
|
if (signal?.aborted) return reject(new Error("aborted"));
|
|
58757
58889
|
const timer = setTimeout(() => {
|
|
58758
58890
|
signal?.removeEventListener("abort", onAbort);
|
|
58759
|
-
|
|
58891
|
+
resolve16();
|
|
58760
58892
|
}, ms);
|
|
58761
58893
|
const onAbort = () => {
|
|
58762
58894
|
clearTimeout(timer);
|
|
@@ -59000,7 +59132,7 @@ function errorDetail(text9) {
|
|
|
59000
59132
|
|
|
59001
59133
|
// packages/kyrn-judge/src/sandbox/operations.ts
|
|
59002
59134
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
59003
|
-
import { extname as extname2, isAbsolute as
|
|
59135
|
+
import { extname as extname2, isAbsolute as isAbsolute9, posix as posix6, relative as relative9, sep as sep5 } from "node:path";
|
|
59004
59136
|
|
|
59005
59137
|
// packages/kyrn-judge/src/sandbox/session.ts
|
|
59006
59138
|
import { posix as posix5 } from "node:path";
|
|
@@ -59091,7 +59223,7 @@ function createTar(entries) {
|
|
|
59091
59223
|
// packages/kyrn-judge/src/sandbox/project.ts
|
|
59092
59224
|
var gzipAsync = promisify(gzip);
|
|
59093
59225
|
function runGit2(args, cwd, input) {
|
|
59094
|
-
return new Promise((
|
|
59226
|
+
return new Promise((resolve16) => {
|
|
59095
59227
|
const child = spawn10("git", args, {
|
|
59096
59228
|
cwd,
|
|
59097
59229
|
stdio: [input ? "pipe" : "ignore", "pipe", "pipe"],
|
|
@@ -59102,10 +59234,10 @@ function runGit2(args, cwd, input) {
|
|
|
59102
59234
|
const err = [];
|
|
59103
59235
|
child.stdout?.on("data", (chunk) => out.push(chunk));
|
|
59104
59236
|
child.stderr?.on("data", (chunk) => err.push(chunk));
|
|
59105
|
-
child.on("error", (error) =>
|
|
59237
|
+
child.on("error", (error) => resolve16({ code: 127, stdout: Buffer.alloc(0), stderr: error.message }));
|
|
59106
59238
|
child.on(
|
|
59107
59239
|
"close",
|
|
59108
|
-
(code) =>
|
|
59240
|
+
(code) => resolve16({ code: code ?? 1, stdout: Buffer.concat(out), stderr: Buffer.concat(err).toString("utf8") })
|
|
59109
59241
|
);
|
|
59110
59242
|
if (input) {
|
|
59111
59243
|
child.stdin?.on("error", () => void 0);
|
|
@@ -59275,13 +59407,13 @@ function tail(buffer, chars = 600) {
|
|
|
59275
59407
|
function untilAborted(work, signal) {
|
|
59276
59408
|
if (!signal) return work;
|
|
59277
59409
|
if (signal.aborted) return Promise.reject(new Error("aborted"));
|
|
59278
|
-
return new Promise((
|
|
59410
|
+
return new Promise((resolve16, reject) => {
|
|
59279
59411
|
const onAbort = () => reject(new Error("aborted"));
|
|
59280
59412
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
59281
59413
|
work.then(
|
|
59282
59414
|
(value) => {
|
|
59283
59415
|
signal.removeEventListener("abort", onAbort);
|
|
59284
|
-
|
|
59416
|
+
resolve16(value);
|
|
59285
59417
|
},
|
|
59286
59418
|
(error) => {
|
|
59287
59419
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -59533,14 +59665,14 @@ var SandboxSession = class {
|
|
|
59533
59665
|
function toSandboxPath(localPath, root, workdir) {
|
|
59534
59666
|
const inside2 = relative9(root, localPath);
|
|
59535
59667
|
if (inside2 === "") return workdir;
|
|
59536
|
-
if (inside2 !== ".." && !inside2.startsWith(`..${sep5}`) && !
|
|
59668
|
+
if (inside2 !== ".." && !inside2.startsWith(`..${sep5}`) && !isAbsolute9(inside2)) {
|
|
59537
59669
|
return posix6.join(workdir, inside2.split(sep5).join("/"));
|
|
59538
59670
|
}
|
|
59539
59671
|
return localPath.split(sep5).join("/");
|
|
59540
59672
|
}
|
|
59541
59673
|
function insideProject(localPath, root) {
|
|
59542
59674
|
const inside2 = relative9(root, localPath);
|
|
59543
|
-
return inside2 === "" || inside2 !== ".." && !inside2.startsWith(`..${sep5}`) && !
|
|
59675
|
+
return inside2 === "" || inside2 !== ".." && !inside2.startsWith(`..${sep5}`) && !isAbsolute9(inside2);
|
|
59544
59676
|
}
|
|
59545
59677
|
var IMAGE_TYPES2 = {
|
|
59546
59678
|
".png": "image/png",
|
|
@@ -60590,7 +60722,7 @@ import { join as join52 } from "node:path";
|
|
|
60590
60722
|
|
|
60591
60723
|
// packages/kyrn-judge/src/auth/exit.ts
|
|
60592
60724
|
import { mkdirSync as mkdirSync20, rmdirSync as rmdirSync2 } from "node:fs";
|
|
60593
|
-
import { resolve as
|
|
60725
|
+
import { resolve as resolve15 } from "node:path";
|
|
60594
60726
|
import { setTimeout as sleep4 } from "node:timers/promises";
|
|
60595
60727
|
async function holdLocksUntilExit(files, {
|
|
60596
60728
|
limitMs = 3e3,
|
|
@@ -60617,7 +60749,7 @@ async function holdLocksUntilExit(files, {
|
|
|
60617
60749
|
return release;
|
|
60618
60750
|
}
|
|
60619
60751
|
function lockFolders(files) {
|
|
60620
|
-
return [...new Set(files.map((file) => `${
|
|
60752
|
+
return [...new Set(files.map((file) => `${resolve15(file)}.lock`))];
|
|
60621
60753
|
}
|
|
60622
60754
|
function takeAll(locks) {
|
|
60623
60755
|
const taken = [];
|