runcastle 1.5.5 → 1.5.6
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/bin/runcastle.js +1597 -1518
- package/index.js +1597 -1518
- package/package.json +1 -1
- package/skills/burner/implement-ticket.md +11 -11
- package/skills/burner/resolve-conflict.md +1 -1
- package/skills/burner/review-ticket.md +3 -1
- package/skills/packs/runcastle/skills/feature/SKILL.md +1 -1
- package/skills/packs/runcastle/skills/feature/references/planning-alone.md +4 -2
- package/skills/packs/runcastle/skills/feature/references/rounds.md +6 -2
- package/skills/packs/runcastle/skills/feature/references/tickets.md +6 -4
- package/skills/packs/runcastle/skills/prepare/SKILL.md +1 -1
- package/web/assets/{index-CPgKzYyE.js → index-DJf8BQof.js} +1 -1
- package/web/index.html +1 -1
package/bin/runcastle.js
CHANGED
|
@@ -206,7 +206,8 @@ var init_review_gates = __esm(() => {
|
|
|
206
206
|
z2.object({
|
|
207
207
|
status: z2.literal("ran"),
|
|
208
208
|
commit: z2.string(),
|
|
209
|
-
commands: z2.array(GateCommandResult)
|
|
209
|
+
commands: z2.array(GateCommandResult),
|
|
210
|
+
reusedFrom: z2.object({ kind: z2.enum(["round", "review"]), id: z2.string() }).optional()
|
|
210
211
|
})
|
|
211
212
|
]);
|
|
212
213
|
});
|
|
@@ -4350,12 +4351,14 @@ async function commitsSince(repoPath, sha, branch) {
|
|
|
4350
4351
|
return;
|
|
4351
4352
|
}
|
|
4352
4353
|
}
|
|
4353
|
-
async function diffPaths(repoPath, from, to) {
|
|
4354
|
+
async function diffPaths(repoPath, from, to, opts = {}) {
|
|
4354
4355
|
try {
|
|
4355
4356
|
const out = (await git(repoPath).raw(["diff", "--name-only", from, to])).trim();
|
|
4356
4357
|
return out ? out.split(`
|
|
4357
4358
|
`).map((s) => s.trim()).filter(Boolean) : [];
|
|
4358
|
-
} catch {
|
|
4359
|
+
} catch (err) {
|
|
4360
|
+
if (opts.throwOnError)
|
|
4361
|
+
throw err;
|
|
4359
4362
|
return [];
|
|
4360
4363
|
}
|
|
4361
4364
|
}
|
|
@@ -9642,1012 +9645,339 @@ var init_kill_registry = __esm(() => {
|
|
|
9642
9645
|
REGISTRY_KEY2 = Symbol.for("runcastle.kill.registry");
|
|
9643
9646
|
});
|
|
9644
9647
|
|
|
9645
|
-
//
|
|
9646
|
-
import {
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
}
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
const parsed = JSON.parse(readFileSync11(configFile, "utf8"));
|
|
9658
|
-
if (typeof parsed !== "object" || parsed === null)
|
|
9659
|
-
return {};
|
|
9660
|
-
return foldLegacyModelConfig(migrateCollapsedModelSteps(parsed));
|
|
9661
|
-
} catch {
|
|
9662
|
-
return {};
|
|
9648
|
+
// ../../node_modules/.bun/@ai-hero+sandcastle@0.12.0/node_modules/@ai-hero/sandcastle/dist/chunk-NGBM7T3E.js
|
|
9649
|
+
import { createRequire as createRequire4 } from "module";
|
|
9650
|
+
var require$1, __create, __defProp2, __getOwnPropDesc, __getOwnPropNames, __getProtoOf, __hasOwnProp, __require2, __commonJS = (cb, mod) => function __require22() {
|
|
9651
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9652
|
+
}, __export2 = (target, all) => {
|
|
9653
|
+
for (var name in all)
|
|
9654
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
9655
|
+
}, __copyProps = (to, from, except, desc5) => {
|
|
9656
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9657
|
+
for (let key of __getOwnPropNames(from))
|
|
9658
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9659
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc5 = __getOwnPropDesc(from, key)) || desc5.enumerable });
|
|
9663
9660
|
}
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9661
|
+
return to;
|
|
9662
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")), __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, mod)), MAX_TAIL_CHARS, BoundedTail = class {
|
|
9663
|
+
items = [];
|
|
9664
|
+
totalChars = 0;
|
|
9665
|
+
maxChars;
|
|
9666
|
+
separator;
|
|
9667
|
+
constructor(maxChars = MAX_TAIL_CHARS, separator = "") {
|
|
9668
|
+
this.maxChars = maxChars;
|
|
9669
|
+
this.separator = separator;
|
|
9670
|
+
}
|
|
9671
|
+
push(item) {
|
|
9672
|
+
const bounded = item.length > this.maxChars ? item.slice(item.length - this.maxChars) : item;
|
|
9673
|
+
this.totalChars += bounded.length + (this.items.length > 0 ? this.separator.length : 0);
|
|
9674
|
+
this.items.push(bounded);
|
|
9675
|
+
while (this.totalChars > this.maxChars && this.items.length > 1) {
|
|
9676
|
+
const dropped = this.items.shift();
|
|
9677
|
+
this.totalChars -= dropped.length + this.separator.length;
|
|
9676
9678
|
}
|
|
9677
|
-
|
|
9679
|
+
}
|
|
9680
|
+
toString() {
|
|
9681
|
+
return this.items.join(this.separator);
|
|
9682
|
+
}
|
|
9683
|
+
}, elidePayloadTokens = (command) => command.replace(/'[A-Za-z0-9+\/=]{120,}'/g, "'\u2026'"), formatExecFailureMessage = (command, result, maxTailChars = MAX_TAIL_CHARS) => {
|
|
9684
|
+
const output = [result.stdout, result.stderr].map((stream) => (stream ?? "").trimEnd()).filter((stream) => stream.length > 0).join(`
|
|
9685
|
+
`);
|
|
9686
|
+
const tail = output.length > maxTailChars ? output.slice(output.length - maxTailChars) : output;
|
|
9687
|
+
const headline = `Command failed (exit ${result.exitCode}): ${elidePayloadTokens(command)}`;
|
|
9688
|
+
return tail ? `${headline}
|
|
9689
|
+
${tail}` : headline;
|
|
9690
|
+
};
|
|
9691
|
+
var init_chunk_NGBM7T3E = __esm(() => {
|
|
9692
|
+
require$1 = createRequire4(import.meta.url);
|
|
9693
|
+
__create = Object.create;
|
|
9694
|
+
__defProp2 = Object.defineProperty;
|
|
9695
|
+
__getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9696
|
+
__getOwnPropNames = Object.getOwnPropertyNames;
|
|
9697
|
+
__getProtoOf = Object.getPrototypeOf;
|
|
9698
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9699
|
+
__require2 = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9700
|
+
get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
|
|
9701
|
+
}) : x)(function(x) {
|
|
9702
|
+
if (typeof require$1 !== "undefined")
|
|
9703
|
+
return require$1.apply(this, arguments);
|
|
9704
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9678
9705
|
});
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
if (desc5.envVar) {
|
|
9719
|
-
const raw = layers.env[desc5.envVar];
|
|
9720
|
-
if (raw !== undefined && raw !== "") {
|
|
9721
|
-
return { ...base, value: desc5.parseEnv(raw), source: "env", editable: false };
|
|
9706
|
+
MAX_TAIL_CHARS = 64 * 1024;
|
|
9707
|
+
});
|
|
9708
|
+
|
|
9709
|
+
// ../../node_modules/.bun/@ai-hero+sandcastle@0.12.0/node_modules/@ai-hero/sandcastle/dist/chunk-VOG34SRF.js
|
|
9710
|
+
import { createRequire as createRequire5 } from "module";
|
|
9711
|
+
import * as clack from "@clack/prompts";
|
|
9712
|
+
import { join as join$1, basename as basename3, dirname as dirname8, resolve as resolve10, posix as posix2, normalize, isAbsolute as isAbsolute2 } from "path";
|
|
9713
|
+
import { styleText, promisify } from "util";
|
|
9714
|
+
import { existsSync as existsSync15, statSync as statSync5 } from "fs";
|
|
9715
|
+
import { tmpdir as tmpdir2, homedir as homedir3 } from "os";
|
|
9716
|
+
import { mkdtemp, writeFile, mkdir, readFile as readFile2, rm, readdir, stat } from "fs/promises";
|
|
9717
|
+
import { exec, execFile } from "child_process";
|
|
9718
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
9719
|
+
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
9720
|
+
switch (arguments.length) {
|
|
9721
|
+
case 1:
|
|
9722
|
+
return a;
|
|
9723
|
+
case 2:
|
|
9724
|
+
return ab(a);
|
|
9725
|
+
case 3:
|
|
9726
|
+
return bc(ab(a));
|
|
9727
|
+
case 4:
|
|
9728
|
+
return cd(bc(ab(a)));
|
|
9729
|
+
case 5:
|
|
9730
|
+
return de(cd(bc(ab(a))));
|
|
9731
|
+
case 6:
|
|
9732
|
+
return ef(de(cd(bc(ab(a)))));
|
|
9733
|
+
case 7:
|
|
9734
|
+
return fg(ef(de(cd(bc(ab(a))))));
|
|
9735
|
+
case 8:
|
|
9736
|
+
return gh(fg(ef(de(cd(bc(ab(a)))))));
|
|
9737
|
+
case 9:
|
|
9738
|
+
return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
|
|
9739
|
+
default: {
|
|
9740
|
+
let ret = arguments[0];
|
|
9741
|
+
for (let i = 1;i < arguments.length; i++) {
|
|
9742
|
+
ret = arguments[i](ret);
|
|
9743
|
+
}
|
|
9744
|
+
return ret;
|
|
9722
9745
|
}
|
|
9723
9746
|
}
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9747
|
+
}
|
|
9748
|
+
function mul64(out, aHi, aLo, bHi, bLo) {
|
|
9749
|
+
let c1 = (aLo >>> 16) * (bLo & 65535) >>> 0;
|
|
9750
|
+
let c0 = (aLo & 65535) * (bLo >>> 16) >>> 0;
|
|
9751
|
+
let lo = (aLo & 65535) * (bLo & 65535) >>> 0;
|
|
9752
|
+
let hi = (aLo >>> 16) * (bLo >>> 16) + ((c0 >>> 16) + (c1 >>> 16)) >>> 0;
|
|
9753
|
+
c0 = c0 << 16 >>> 0;
|
|
9754
|
+
lo = lo + c0 >>> 0;
|
|
9755
|
+
if (lo >>> 0 < c0 >>> 0) {
|
|
9756
|
+
hi = hi + 1 >>> 0;
|
|
9729
9757
|
}
|
|
9730
|
-
|
|
9731
|
-
|
|
9758
|
+
c1 = c1 << 16 >>> 0;
|
|
9759
|
+
lo = lo + c1 >>> 0;
|
|
9760
|
+
if (lo >>> 0 < c1 >>> 0) {
|
|
9761
|
+
hi = hi + 1 >>> 0;
|
|
9732
9762
|
}
|
|
9733
|
-
|
|
9734
|
-
|
|
9763
|
+
hi = hi + Math.imul(aLo, bHi) >>> 0;
|
|
9764
|
+
hi = hi + Math.imul(aHi, bLo) >>> 0;
|
|
9765
|
+
out[0] = hi;
|
|
9766
|
+
out[1] = lo;
|
|
9735
9767
|
}
|
|
9736
|
-
function
|
|
9737
|
-
|
|
9738
|
-
const
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
projectId,
|
|
9745
|
-
fields: [...fields, ...stepModelFields(fileRaw)],
|
|
9746
|
-
discovery: discoverySnapshot(ctx)
|
|
9747
|
-
};
|
|
9768
|
+
function add64(out, aHi, aLo, bHi, bLo) {
|
|
9769
|
+
let hi = aHi + bHi >>> 0;
|
|
9770
|
+
const lo = aLo + bLo >>> 0;
|
|
9771
|
+
if (lo >>> 0 < aLo >>> 0) {
|
|
9772
|
+
hi = hi + 1 | 0;
|
|
9773
|
+
}
|
|
9774
|
+
out[0] = hi;
|
|
9775
|
+
out[1] = lo;
|
|
9748
9776
|
}
|
|
9749
|
-
function
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
if (input.key.startsWith("stepModels.")) {
|
|
9753
|
-
return updateStepModel(ctx, input, configFile, io);
|
|
9777
|
+
function yieldWrapGet(self) {
|
|
9778
|
+
if (typeof self === "object" && self !== null && YieldWrapTypeId in self) {
|
|
9779
|
+
return self[YieldWrapTypeId]();
|
|
9754
9780
|
}
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
if (
|
|
9759
|
-
|
|
9760
|
-
if (raw !== undefined && raw !== "") {
|
|
9761
|
-
throw new InvalidInputError(`${desc5.key} is set by environment variable ${desc5.envVar}; unset it to edit`);
|
|
9762
|
-
}
|
|
9781
|
+
throw new Error(getBugErrorMessage("yieldWrapGet"));
|
|
9782
|
+
}
|
|
9783
|
+
function equals() {
|
|
9784
|
+
if (arguments.length === 1) {
|
|
9785
|
+
return (self) => compareBoth(self, arguments[0]);
|
|
9763
9786
|
}
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
ctx.db.update(projects).set({ [desc5.projectColumn]: null }).where(eq11(projects.id, project.id)).run();
|
|
9770
|
-
recordHuman(ctx, project.id, desc5.key, null);
|
|
9771
|
-
emitProject(ctx, project.id, {
|
|
9772
|
-
type: "settings.updated",
|
|
9773
|
-
message: `${desc5.key} override cleared`,
|
|
9774
|
-
data: { key: desc5.key, scope: "project", value: null }
|
|
9775
|
-
});
|
|
9776
|
-
return field(getSettings(ctx, input.projectId, io), desc5.key);
|
|
9787
|
+
return compareBoth(arguments[0], arguments[1]);
|
|
9788
|
+
}
|
|
9789
|
+
function compareBoth(self, that) {
|
|
9790
|
+
if (self === that) {
|
|
9791
|
+
return true;
|
|
9777
9792
|
}
|
|
9778
|
-
const
|
|
9779
|
-
if (
|
|
9780
|
-
|
|
9793
|
+
const selfType = typeof self;
|
|
9794
|
+
if (selfType !== typeof that) {
|
|
9795
|
+
return false;
|
|
9781
9796
|
}
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9797
|
+
if (selfType === "object" || selfType === "function") {
|
|
9798
|
+
if (self !== null && that !== null) {
|
|
9799
|
+
if (isEqual(self) && isEqual(that)) {
|
|
9800
|
+
if (hash(self) === hash(that) && self[symbol2](that)) {
|
|
9801
|
+
return true;
|
|
9802
|
+
} else {
|
|
9803
|
+
return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
9804
|
+
}
|
|
9805
|
+
} else if (self instanceof Date && that instanceof Date) {
|
|
9806
|
+
const t1 = self.getTime();
|
|
9807
|
+
const t2 = that.getTime();
|
|
9808
|
+
return t1 === t2 || Number.isNaN(t1) && Number.isNaN(t2);
|
|
9809
|
+
} else if (self instanceof URL && that instanceof URL) {
|
|
9810
|
+
return self.href === that.href;
|
|
9811
|
+
}
|
|
9812
|
+
}
|
|
9813
|
+
if (structuralRegionState.enabled) {
|
|
9814
|
+
if (Array.isArray(self) && Array.isArray(that)) {
|
|
9815
|
+
return self.length === that.length && self.every((v, i) => compareBoth(v, that[i]));
|
|
9816
|
+
}
|
|
9817
|
+
if (Object.getPrototypeOf(self) === Object.prototype && Object.getPrototypeOf(that) === Object.prototype) {
|
|
9818
|
+
const keysSelf = Object.keys(self);
|
|
9819
|
+
const keysThat = Object.keys(that);
|
|
9820
|
+
if (keysSelf.length === keysThat.length) {
|
|
9821
|
+
for (const key of keysSelf) {
|
|
9822
|
+
if (!((key in that) && compareBoth(self[key], that[key]))) {
|
|
9823
|
+
return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
9824
|
+
}
|
|
9825
|
+
}
|
|
9826
|
+
return true;
|
|
9827
|
+
}
|
|
9828
|
+
}
|
|
9829
|
+
return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
9830
|
+
}
|
|
9793
9831
|
}
|
|
9794
|
-
|
|
9795
|
-
|
|
9832
|
+
return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
9833
|
+
}
|
|
9834
|
+
function formatDate(date2) {
|
|
9835
|
+
try {
|
|
9836
|
+
return date2.toISOString();
|
|
9837
|
+
} catch {
|
|
9838
|
+
return "Invalid Date";
|
|
9796
9839
|
}
|
|
9797
|
-
writeGlobal(configFile, desc5.configKey, value);
|
|
9798
|
-
ctx.config[desc5.configKey] = value;
|
|
9799
|
-
emitProject(ctx, GLOBAL_EVENT_KEY, {
|
|
9800
|
-
type: "settings.updated",
|
|
9801
|
-
message: `${desc5.key} set to ${describeValue(value)}`,
|
|
9802
|
-
data: { key: desc5.key, scope: "global", value }
|
|
9803
|
-
});
|
|
9804
|
-
return field(getSettings(ctx, input.projectId, io), desc5.key);
|
|
9805
9840
|
}
|
|
9806
|
-
function
|
|
9807
|
-
|
|
9808
|
-
|
|
9841
|
+
function safeToString(input) {
|
|
9842
|
+
try {
|
|
9843
|
+
const s = input.toString();
|
|
9844
|
+
return typeof s === "string" ? s : String(s);
|
|
9845
|
+
} catch {
|
|
9846
|
+
return "[toString threw]";
|
|
9809
9847
|
}
|
|
9810
|
-
removeGlobal(configFile, desc5.configKey);
|
|
9811
|
-
delete ctx.config[desc5.configKey];
|
|
9812
|
-
emitProject(ctx, GLOBAL_EVENT_KEY, {
|
|
9813
|
-
type: "settings.updated",
|
|
9814
|
-
message: `${desc5.key} cleared`,
|
|
9815
|
-
data: { key: desc5.key, scope: "global", value: null }
|
|
9816
|
-
});
|
|
9817
|
-
return field(getSettings(ctx, input.projectId, io), desc5.key);
|
|
9818
9848
|
}
|
|
9819
|
-
function
|
|
9820
|
-
return
|
|
9849
|
+
function formatPropertyKey(name) {
|
|
9850
|
+
return isString(name) ? JSON.stringify(name) : String(name);
|
|
9821
9851
|
}
|
|
9822
|
-
function
|
|
9823
|
-
const
|
|
9824
|
-
|
|
9825
|
-
|
|
9852
|
+
function formatUnknown(input, options) {
|
|
9853
|
+
const seen = /* @__PURE__ */ new WeakSet;
|
|
9854
|
+
const wrap = (v, body) => {
|
|
9855
|
+
const ctor = v?.constructor;
|
|
9856
|
+
return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body;
|
|
9857
|
+
};
|
|
9858
|
+
const ownKeys = (o) => {
|
|
9859
|
+
try {
|
|
9860
|
+
return Reflect.ownKeys(o);
|
|
9861
|
+
} catch {
|
|
9862
|
+
return ["[ownKeys threw]"];
|
|
9863
|
+
}
|
|
9864
|
+
};
|
|
9865
|
+
function go2(v, d = 0) {
|
|
9866
|
+
if (Array.isArray(v)) {
|
|
9867
|
+
if (seen.has(v))
|
|
9868
|
+
return CIRCULAR;
|
|
9869
|
+
seen.add(v);
|
|
9870
|
+
return `[${v.map((x) => go2(x, d)).join(",")}]`;
|
|
9871
|
+
}
|
|
9872
|
+
if (isDate(v))
|
|
9873
|
+
return formatDate(v);
|
|
9874
|
+
if (hasProperty(v, "toString") && isFunction2(v["toString"]) && v["toString"] !== Object.prototype.toString && v["toString"] !== Array.prototype.toString) {
|
|
9875
|
+
const s = safeToString(v);
|
|
9876
|
+
if (v instanceof Error && v.cause) {
|
|
9877
|
+
return `${s} (cause: ${go2(v.cause, d)})`;
|
|
9878
|
+
}
|
|
9879
|
+
return s;
|
|
9880
|
+
}
|
|
9881
|
+
if (isString(v))
|
|
9882
|
+
return JSON.stringify(v);
|
|
9883
|
+
if (isNumber(v) || v == null || isBoolean(v) || isSymbol(v))
|
|
9884
|
+
return String(v);
|
|
9885
|
+
if (isBigInt(v))
|
|
9886
|
+
return String(v) + "n";
|
|
9887
|
+
if (v instanceof Set || v instanceof Map) {
|
|
9888
|
+
if (seen.has(v))
|
|
9889
|
+
return CIRCULAR;
|
|
9890
|
+
seen.add(v);
|
|
9891
|
+
return `${v.constructor.name}(${go2(Array.from(v), d)})`;
|
|
9892
|
+
}
|
|
9893
|
+
if (isObject(v)) {
|
|
9894
|
+
if (seen.has(v))
|
|
9895
|
+
return CIRCULAR;
|
|
9896
|
+
seen.add(v);
|
|
9897
|
+
const keys5 = ownKeys(v);
|
|
9898
|
+
{
|
|
9899
|
+
const body2 = `{${keys5.map((k) => `${formatPropertyKey(k)}:${go2(v[k], d)}`).join(",")}}`;
|
|
9900
|
+
return wrap(v, body2);
|
|
9901
|
+
}
|
|
9902
|
+
}
|
|
9903
|
+
return String(v);
|
|
9904
|
+
}
|
|
9905
|
+
return go2(input, 0);
|
|
9826
9906
|
}
|
|
9827
|
-
function
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9907
|
+
function copy2(src, srcPos, dest, destPos, len) {
|
|
9908
|
+
for (let i = srcPos;i < Math.min(src.length, srcPos + len); i++) {
|
|
9909
|
+
dest[destPos + i - srcPos] = src[i];
|
|
9910
|
+
}
|
|
9911
|
+
return dest;
|
|
9831
9912
|
}
|
|
9832
|
-
function
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9913
|
+
function popcount(x) {
|
|
9914
|
+
x -= x >> 1 & 1431655765;
|
|
9915
|
+
x = (x & 858993459) + (x >> 2 & 858993459);
|
|
9916
|
+
x = x + (x >> 4) & 252645135;
|
|
9917
|
+
x += x >> 8;
|
|
9918
|
+
x += x >> 16;
|
|
9919
|
+
return x & 127;
|
|
9836
9920
|
}
|
|
9837
|
-
function
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9921
|
+
function hashFragment(shift2, h) {
|
|
9922
|
+
return h >>> shift2 & MASK;
|
|
9923
|
+
}
|
|
9924
|
+
function toBitmap(x) {
|
|
9925
|
+
return 1 << x;
|
|
9926
|
+
}
|
|
9927
|
+
function fromBitmap(bitmap, bit) {
|
|
9928
|
+
return popcount(bitmap & bit - 1);
|
|
9929
|
+
}
|
|
9930
|
+
function arrayUpdate(mutate5, at, v, arr) {
|
|
9931
|
+
let out = arr;
|
|
9932
|
+
if (!mutate5) {
|
|
9933
|
+
const len = arr.length;
|
|
9934
|
+
out = new Array(len);
|
|
9935
|
+
for (let i = 0;i < len; ++i)
|
|
9936
|
+
out[i] = arr[i];
|
|
9849
9937
|
}
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
if (value === null)
|
|
9853
|
-
delete stepModels[modelStep];
|
|
9854
|
-
else
|
|
9855
|
-
stepModels[modelStep] = value;
|
|
9856
|
-
ctx.config.stepModels = stepModels;
|
|
9857
|
-
emitProject(ctx, GLOBAL_EVENT_KEY, {
|
|
9858
|
-
type: "settings.updated",
|
|
9859
|
-
message: value === null ? `${input.key} override cleared` : `${input.key} set to ${value}`,
|
|
9860
|
-
data: { key: input.key, scope: "global", value }
|
|
9861
|
-
});
|
|
9862
|
-
return field(getSettings(ctx, input.projectId, io), input.key);
|
|
9938
|
+
out[at] = v;
|
|
9939
|
+
return out;
|
|
9863
9940
|
}
|
|
9864
|
-
function
|
|
9865
|
-
const
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9941
|
+
function arraySpliceOut(mutate5, at, arr) {
|
|
9942
|
+
const newLen = arr.length - 1;
|
|
9943
|
+
let i = 0;
|
|
9944
|
+
let g = 0;
|
|
9945
|
+
let out = arr;
|
|
9946
|
+
if (mutate5) {
|
|
9947
|
+
i = g = at;
|
|
9948
|
+
} else {
|
|
9949
|
+
out = new Array(newLen);
|
|
9950
|
+
while (i < at)
|
|
9951
|
+
out[g++] = arr[i++];
|
|
9952
|
+
}
|
|
9953
|
+
++i;
|
|
9954
|
+
while (i <= newLen)
|
|
9955
|
+
out[g++] = arr[i++];
|
|
9956
|
+
if (mutate5) {
|
|
9957
|
+
out.length = newLen;
|
|
9958
|
+
}
|
|
9959
|
+
return out;
|
|
9873
9960
|
}
|
|
9874
|
-
function
|
|
9875
|
-
const
|
|
9876
|
-
if (
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9961
|
+
function arraySpliceIn(mutate5, at, v, arr) {
|
|
9962
|
+
const len = arr.length;
|
|
9963
|
+
if (mutate5) {
|
|
9964
|
+
let i2 = len;
|
|
9965
|
+
while (i2 >= at)
|
|
9966
|
+
arr[i2--] = arr[i2];
|
|
9967
|
+
arr[at] = v;
|
|
9968
|
+
return arr;
|
|
9969
|
+
}
|
|
9970
|
+
let i = 0, g = 0;
|
|
9971
|
+
const out = new Array(len + 1);
|
|
9972
|
+
while (i < at)
|
|
9973
|
+
out[g++] = arr[i++];
|
|
9974
|
+
out[at] = v;
|
|
9975
|
+
while (i < len)
|
|
9976
|
+
out[++g] = arr[i++];
|
|
9977
|
+
return out;
|
|
9886
9978
|
}
|
|
9887
|
-
function
|
|
9888
|
-
|
|
9889
|
-
if (!f)
|
|
9890
|
-
throw new InvalidInputError(`setting ${key} not visible in this scope`);
|
|
9891
|
-
return f;
|
|
9892
|
-
}
|
|
9893
|
-
var GLOBAL_EVENT_KEY = "global", idEnv = (raw) => raw, DESCRIPTORS, DEFAULTS, GLOBAL_CLEARABLE_KEYS, STEP_SET;
|
|
9894
|
-
var init_settings = __esm(() => {
|
|
9895
|
-
init_src();
|
|
9896
|
-
init_config_load();
|
|
9897
|
-
init_paths();
|
|
9898
|
-
init_model_discovery();
|
|
9899
|
-
init_schema();
|
|
9900
|
-
init_errors();
|
|
9901
|
-
init_events();
|
|
9902
|
-
init_findings();
|
|
9903
|
-
init_repo();
|
|
9904
|
-
init_sandbox_image();
|
|
9905
|
-
DESCRIPTORS = [
|
|
9906
|
-
{
|
|
9907
|
-
key: "serverPort",
|
|
9908
|
-
configKey: "serverPort",
|
|
9909
|
-
envVar: "RUNCASTLE_SERVER_PORT",
|
|
9910
|
-
restartRequired: true,
|
|
9911
|
-
valueSchema: z5.number().int().positive(),
|
|
9912
|
-
parseEnv: (raw) => Number(raw)
|
|
9913
|
-
},
|
|
9914
|
-
{
|
|
9915
|
-
key: "model",
|
|
9916
|
-
configKey: "model",
|
|
9917
|
-
envVar: "RUNCASTLE_MODEL",
|
|
9918
|
-
projectColumn: "model",
|
|
9919
|
-
restartRequired: false,
|
|
9920
|
-
valueSchema: z5.string().min(1),
|
|
9921
|
-
parseEnv: idEnv
|
|
9922
|
-
},
|
|
9923
|
-
{
|
|
9924
|
-
key: "models",
|
|
9925
|
-
configKey: "models",
|
|
9926
|
-
restartRequired: false,
|
|
9927
|
-
valueSchema: z5.array(ModelEntry),
|
|
9928
|
-
parseEnv: idEnv
|
|
9929
|
-
},
|
|
9930
|
-
{
|
|
9931
|
-
key: "sandbox",
|
|
9932
|
-
configKey: "sandbox",
|
|
9933
|
-
envVar: "RUNCASTLE_SANDBOX",
|
|
9934
|
-
projectColumn: "sandbox",
|
|
9935
|
-
restartRequired: false,
|
|
9936
|
-
valueSchema: z5.enum(["docker", "podman", "noSandbox"]),
|
|
9937
|
-
parseEnv: idEnv
|
|
9938
|
-
},
|
|
9939
|
-
{
|
|
9940
|
-
key: "sandboxImage",
|
|
9941
|
-
configKey: "sandboxImage",
|
|
9942
|
-
envVar: "RUNCASTLE_SANDBOX_IMAGE",
|
|
9943
|
-
projectColumn: "sandboxImage",
|
|
9944
|
-
restartRequired: false,
|
|
9945
|
-
valueSchema: z5.string().min(1),
|
|
9946
|
-
parseEnv: idEnv
|
|
9947
|
-
},
|
|
9948
|
-
{
|
|
9949
|
-
key: "sessionMcp",
|
|
9950
|
-
configKey: "sessionMcp",
|
|
9951
|
-
envVar: "RUNCASTLE_SESSION_MCP",
|
|
9952
|
-
restartRequired: false,
|
|
9953
|
-
valueSchema: z5.enum(["inherit", "runcastleOnly"]),
|
|
9954
|
-
parseEnv: idEnv
|
|
9955
|
-
},
|
|
9956
|
-
{
|
|
9957
|
-
key: "burnConcurrency",
|
|
9958
|
-
configKey: "burnConcurrency",
|
|
9959
|
-
envVar: "RUNCASTLE_BURN_CONCURRENCY",
|
|
9960
|
-
restartRequired: false,
|
|
9961
|
-
valueSchema: z5.number().int().min(1).max(8),
|
|
9962
|
-
parseEnv: (raw) => Number(raw)
|
|
9963
|
-
},
|
|
9964
|
-
{
|
|
9965
|
-
key: "burnMaxIterations",
|
|
9966
|
-
configKey: "burnMaxIterations",
|
|
9967
|
-
envVar: "RUNCASTLE_BURN_MAX_ITERATIONS",
|
|
9968
|
-
restartRequired: false,
|
|
9969
|
-
valueSchema: z5.number().int().min(1).max(10),
|
|
9970
|
-
parseEnv: (raw) => Number(raw)
|
|
9971
|
-
},
|
|
9972
|
-
{
|
|
9973
|
-
key: "burnAttempts",
|
|
9974
|
-
configKey: "burnAttempts",
|
|
9975
|
-
envVar: "RUNCASTLE_BURN_ATTEMPTS",
|
|
9976
|
-
restartRequired: false,
|
|
9977
|
-
valueSchema: z5.number().int().min(1).max(5),
|
|
9978
|
-
parseEnv: (raw) => Number(raw)
|
|
9979
|
-
},
|
|
9980
|
-
{
|
|
9981
|
-
key: "burnConflictAttempts",
|
|
9982
|
-
configKey: "burnConflictAttempts",
|
|
9983
|
-
envVar: "RUNCASTLE_BURN_CONFLICT_ATTEMPTS",
|
|
9984
|
-
restartRequired: false,
|
|
9985
|
-
valueSchema: z5.number().int().min(0).max(3),
|
|
9986
|
-
parseEnv: (raw) => Number(raw)
|
|
9987
|
-
},
|
|
9988
|
-
{
|
|
9989
|
-
key: "burnCpus",
|
|
9990
|
-
configKey: "burnCpus",
|
|
9991
|
-
envVar: "RUNCASTLE_BURN_CPUS",
|
|
9992
|
-
restartRequired: false,
|
|
9993
|
-
valueSchema: z5.number().positive().max(256),
|
|
9994
|
-
parseEnv: (raw) => Number(raw)
|
|
9995
|
-
},
|
|
9996
|
-
{
|
|
9997
|
-
key: "setupCommand",
|
|
9998
|
-
configKey: "setupCommand",
|
|
9999
|
-
envVar: "RUNCASTLE_SETUP_COMMAND",
|
|
10000
|
-
projectColumn: "setupCommand",
|
|
10001
|
-
restartRequired: false,
|
|
10002
|
-
valueSchema: z5.string().min(1),
|
|
10003
|
-
parseEnv: idEnv
|
|
10004
|
-
},
|
|
10005
|
-
{
|
|
10006
|
-
key: "verifyCommands",
|
|
10007
|
-
configKey: "verifyCommands",
|
|
10008
|
-
envVar: "RUNCASTLE_VERIFY_COMMANDS",
|
|
10009
|
-
projectColumn: "verifyCommands",
|
|
10010
|
-
restartRequired: false,
|
|
10011
|
-
valueSchema: z5.string().min(1),
|
|
10012
|
-
parseEnv: idEnv
|
|
10013
|
-
},
|
|
10014
|
-
{
|
|
10015
|
-
key: "knownFailures",
|
|
10016
|
-
configKey: "knownFailures",
|
|
10017
|
-
envVar: "RUNCASTLE_KNOWN_FAILURES",
|
|
10018
|
-
projectColumn: "knownFailures",
|
|
10019
|
-
restartRequired: false,
|
|
10020
|
-
valueSchema: z5.string().min(1),
|
|
10021
|
-
parseEnv: idEnv
|
|
10022
|
-
},
|
|
10023
|
-
{
|
|
10024
|
-
key: "devCommand",
|
|
10025
|
-
projectColumn: "devCommand",
|
|
10026
|
-
restartRequired: false,
|
|
10027
|
-
valueSchema: z5.string().min(1),
|
|
10028
|
-
parseEnv: idEnv
|
|
10029
|
-
},
|
|
10030
|
-
{
|
|
10031
|
-
key: "sessionBranch",
|
|
10032
|
-
projectColumn: "sessionBranch",
|
|
10033
|
-
restartRequired: false,
|
|
10034
|
-
valueSchema: z5.string().min(1),
|
|
10035
|
-
parseEnv: idEnv
|
|
10036
|
-
},
|
|
10037
|
-
{
|
|
10038
|
-
key: "docsCommitPrefix",
|
|
10039
|
-
projectColumn: "docsCommitPrefix",
|
|
10040
|
-
restartRequired: false,
|
|
10041
|
-
valueSchema: z5.string().min(1),
|
|
10042
|
-
parseEnv: idEnv,
|
|
10043
|
-
defaultValue: DEFAULT_DOCS_COMMIT_PREFIX
|
|
10044
|
-
},
|
|
10045
|
-
{
|
|
10046
|
-
key: "dbResetCommand",
|
|
10047
|
-
projectColumn: "dbResetCommand",
|
|
10048
|
-
restartRequired: false,
|
|
10049
|
-
valueSchema: z5.string().min(1),
|
|
10050
|
-
parseEnv: idEnv
|
|
10051
|
-
},
|
|
10052
|
-
{
|
|
10053
|
-
key: "driveSetupCommand",
|
|
10054
|
-
projectColumn: "driveSetupCommand",
|
|
10055
|
-
restartRequired: false,
|
|
10056
|
-
valueSchema: z5.string().min(1),
|
|
10057
|
-
parseEnv: idEnv
|
|
10058
|
-
},
|
|
10059
|
-
{
|
|
10060
|
-
key: "driveStopCommand",
|
|
10061
|
-
projectColumn: "driveStopCommand",
|
|
10062
|
-
restartRequired: false,
|
|
10063
|
-
valueSchema: z5.string().min(1),
|
|
10064
|
-
parseEnv: idEnv
|
|
10065
|
-
},
|
|
10066
|
-
{
|
|
10067
|
-
key: "driveInstructions",
|
|
10068
|
-
projectColumn: "driveInstructions",
|
|
10069
|
-
restartRequired: false,
|
|
10070
|
-
valueSchema: z5.string().min(1),
|
|
10071
|
-
parseEnv: idEnv
|
|
10072
|
-
},
|
|
10073
|
-
{
|
|
10074
|
-
key: "scenarioRunner",
|
|
10075
|
-
projectColumn: "scenarioRunner",
|
|
10076
|
-
restartRequired: false,
|
|
10077
|
-
valueSchema: z5.string().min(1),
|
|
10078
|
-
parseEnv: idEnv
|
|
10079
|
-
}
|
|
10080
|
-
];
|
|
10081
|
-
DEFAULTS = RuncastleConfig.parse({});
|
|
10082
|
-
GLOBAL_CLEARABLE_KEYS = new Set(["sandboxImage"]);
|
|
10083
|
-
STEP_SET = new Set(MODEL_STEPS);
|
|
10084
|
-
});
|
|
10085
|
-
|
|
10086
|
-
// src/services/setup.ts
|
|
10087
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync12, readdirSync as readdirSync6, writeFileSync as writeFileSync8 } from "fs";
|
|
10088
|
-
import { dirname as dirname9, join as join17 } from "path";
|
|
10089
|
-
async function writeGitIdentity(exec, identity) {
|
|
10090
|
-
const name = identity.name.trim();
|
|
10091
|
-
const email = identity.email.trim();
|
|
10092
|
-
if (name.length === 0)
|
|
10093
|
-
throw new InvalidInputError("git user.name cannot be empty");
|
|
10094
|
-
if (!email.includes("@"))
|
|
10095
|
-
throw new InvalidInputError("git user.email must be an email address");
|
|
10096
|
-
await exec("git", ["config", "--global", "user.name", name]);
|
|
10097
|
-
await exec("git", ["config", "--global", "user.email", email]);
|
|
10098
|
-
return gitIdentityProbe(exec);
|
|
10099
|
-
}
|
|
10100
|
-
function upsertEnvVar(content, key, value) {
|
|
10101
|
-
const line = `${key}=${value}`;
|
|
10102
|
-
const lines2 = content.length === 0 ? [] : content.replace(/\n$/, "").split(`
|
|
10103
|
-
`);
|
|
10104
|
-
const matcher = new RegExp(`^(export\\s+)?${key}=`);
|
|
10105
|
-
let replaced = false;
|
|
10106
|
-
const next = lines2.map((l) => {
|
|
10107
|
-
if (matcher.test(l)) {
|
|
10108
|
-
replaced = true;
|
|
10109
|
-
const exportPrefix = l.startsWith("export ") ? "export " : "";
|
|
10110
|
-
return `${exportPrefix}${line}`;
|
|
10111
|
-
}
|
|
10112
|
-
return l;
|
|
10113
|
-
});
|
|
10114
|
-
if (!replaced)
|
|
10115
|
-
next.push(line);
|
|
10116
|
-
return `${next.join(`
|
|
10117
|
-
`)}
|
|
10118
|
-
`;
|
|
10119
|
-
}
|
|
10120
|
-
async function saveAfkCredential(io, rawValue, runtime = DEFAULT_RUNTIME) {
|
|
10121
|
-
const spec = RUNTIME_SPECS[runtime];
|
|
10122
|
-
const value = rawValue.trim();
|
|
10123
|
-
if (value.length === 0)
|
|
10124
|
-
throw new InvalidInputError(`${spec.label} ${spec.afkNoun} cannot be empty`);
|
|
10125
|
-
if (/[\r\n]/.test(value)) {
|
|
10126
|
-
throw new InvalidInputError(`${spec.label} ${spec.afkNoun} cannot contain a newline`);
|
|
10127
|
-
}
|
|
10128
|
-
io.write(upsertEnvVar(io.read(), spec.afkKey, value));
|
|
10129
|
-
return io.verify(value);
|
|
10130
|
-
}
|
|
10131
|
-
function seedRuntimeFor(ready) {
|
|
10132
|
-
return ready.includes(DEFAULT_RUNTIME) ? DEFAULT_RUNTIME : ready[0];
|
|
10133
|
-
}
|
|
10134
|
-
function seedModelDefaults(ctx, ready, io = {}) {
|
|
10135
|
-
const runtime = seedRuntimeFor(ready);
|
|
10136
|
-
if (!runtime)
|
|
10137
|
-
return null;
|
|
10138
|
-
const pair = RUNTIME_DEFAULT_MODELS[runtime];
|
|
10139
|
-
const write = (key, value) => {
|
|
10140
|
-
try {
|
|
10141
|
-
updateSettings(ctx, { key, value }, io);
|
|
10142
|
-
return value;
|
|
10143
|
-
} catch (err) {
|
|
10144
|
-
if (err instanceof InvalidInputError)
|
|
10145
|
-
return;
|
|
10146
|
-
throw err;
|
|
10147
|
-
}
|
|
10148
|
-
};
|
|
10149
|
-
const model = write("model", pair.flagship);
|
|
10150
|
-
const smoke = write("stepModels.smoke", pair.smoke);
|
|
10151
|
-
return {
|
|
10152
|
-
runtime,
|
|
10153
|
-
...model ? { model } : {},
|
|
10154
|
-
...smoke ? { smoke } : {}
|
|
10155
|
-
};
|
|
10156
|
-
}
|
|
10157
|
-
function runtimeInstallGuide(platform) {
|
|
10158
|
-
switch (platform) {
|
|
10159
|
-
case "win32":
|
|
10160
|
-
return {
|
|
10161
|
-
command: "winget install RedHat.Podman",
|
|
10162
|
-
note: "Then initialize the VM: podman machine init && podman machine start"
|
|
10163
|
-
};
|
|
10164
|
-
case "darwin":
|
|
10165
|
-
return {
|
|
10166
|
-
command: "brew install podman",
|
|
10167
|
-
note: "Then initialize the VM: podman machine init && podman machine start"
|
|
10168
|
-
};
|
|
10169
|
-
default:
|
|
10170
|
-
return {
|
|
10171
|
-
command: "sudo apt install podman # or: sudo dnf install podman / sudo pacman -S podman",
|
|
10172
|
-
note: "Podman is rootless on Linux \u2014 no machine step needed."
|
|
10173
|
-
};
|
|
10174
|
-
}
|
|
10175
|
-
}
|
|
10176
|
-
async function resolveRuntime(exec, preferred) {
|
|
10177
|
-
const present = async (bin) => {
|
|
10178
|
-
const out = await exec(bin, ["--version"]);
|
|
10179
|
-
return out.ok && out.code === 0;
|
|
10180
|
-
};
|
|
10181
|
-
if (await present(preferred))
|
|
10182
|
-
return preferred;
|
|
10183
|
-
const other = preferred === "docker" ? "podman" : "docker";
|
|
10184
|
-
if (await present(other))
|
|
10185
|
-
return other;
|
|
10186
|
-
return preferred;
|
|
10187
|
-
}
|
|
10188
|
-
function terminalSpec(kind) {
|
|
10189
|
-
if (kind === "setup-token")
|
|
10190
|
-
return { cmd: "claude", args: ["setup-token"] };
|
|
10191
|
-
for (const spec of Object.values(RUNTIME_SPECS)) {
|
|
10192
|
-
if (kind === LOGIN_TERMINAL_KIND[spec.runtime])
|
|
10193
|
-
return { cmd: spec.bin, args: spec.loginArgs };
|
|
10194
|
-
}
|
|
10195
|
-
throw new InvalidInputError(`no terminal command for ${kind}`);
|
|
10196
|
-
}
|
|
10197
|
-
function refreshSandcastleConfig(templateDir, targetDir) {
|
|
10198
|
-
const dir = join17(targetDir, ".sandcastle");
|
|
10199
|
-
mkdirSync9(dir, { recursive: true });
|
|
10200
|
-
for (const name of readdirSync6(templateDir)) {
|
|
10201
|
-
copyFileSync2(join17(templateDir, name), join17(dir, name));
|
|
10202
|
-
}
|
|
10203
|
-
return dir;
|
|
10204
|
-
}
|
|
10205
|
-
function prepareSandboxBuildContext(templateDir = sandcastleTemplateDir(), target = sandboxBuildDir()) {
|
|
10206
|
-
mkdirSync9(target, { recursive: true });
|
|
10207
|
-
return refreshSandcastleConfig(templateDir, target);
|
|
10208
|
-
}
|
|
10209
|
-
function createCredentialVerifier(exec, runtime = DEFAULT_RUNTIME) {
|
|
10210
|
-
const spec = RUNTIME_SPECS[runtime];
|
|
10211
|
-
return async (value) => {
|
|
10212
|
-
if (value.length < 8) {
|
|
10213
|
-
return {
|
|
10214
|
-
valid: false,
|
|
10215
|
-
detail: `${spec.afkNoun} looks malformed (too short) \u2014 saved to ~/.runcastle/.env anyway`,
|
|
10216
|
-
fix: `${spec.afkFix}. It starts with \`sk-\`.`
|
|
10217
|
-
};
|
|
10218
|
-
}
|
|
10219
|
-
const out = await exec(spec.bin, ["--version"]);
|
|
10220
|
-
if (!out.ok) {
|
|
10221
|
-
return {
|
|
10222
|
-
valid: false,
|
|
10223
|
-
detail: `${spec.afkNoun} saved to ~/.runcastle/.env, but runcastle could not launch \`${spec.bin}\` to verify it. ` + "That is a PATH problem in this server process, not a missing install \u2014 a terminal that finds " + `\`${spec.bin}\` proves nothing about the PATH runcastle was started with.`,
|
|
10224
|
-
fix: `Quit runcastle and start it again from a terminal where \`${spec.bin} --version\` works. ` + `If it still fails, pin the path: set ${spec.binOverrideEnv} to the full path from ` + `\`where.exe ${spec.bin}\` (Windows) or \`which ${spec.bin}\` (macOS/Linux), then restart runcastle.`
|
|
10225
|
-
};
|
|
10226
|
-
}
|
|
10227
|
-
if (out.code !== 0) {
|
|
10228
|
-
const why = (out.stderr.trim() || out.stdout.trim()).split(`
|
|
10229
|
-
`)[0] ?? "";
|
|
10230
|
-
return {
|
|
10231
|
-
valid: false,
|
|
10232
|
-
detail: `${spec.afkNoun} saved to ~/.runcastle/.env, but \`${spec.bin} --version\` exited ${out.code}` + `${why ? `: ${why}` : " with no output"}.`,
|
|
10233
|
-
fix: `Run \`${spec.bin} --version\` yourself and fix what it reports \u2014 the ${spec.label} install is broken, not the ${spec.afkNoun}.`
|
|
10234
|
-
};
|
|
10235
|
-
}
|
|
10236
|
-
return { valid: true, detail: `${spec.afkNoun} captured to ~/.runcastle/.env` };
|
|
10237
|
-
};
|
|
10238
|
-
}
|
|
10239
|
-
function fileAfkTokenIo(exec, runtime = DEFAULT_RUNTIME) {
|
|
10240
|
-
const path = envPath();
|
|
10241
|
-
return {
|
|
10242
|
-
read: () => existsSync16(path) ? readFileSync12(path, "utf8") : "",
|
|
10243
|
-
write: (content) => {
|
|
10244
|
-
mkdirSync9(dirname9(path), { recursive: true });
|
|
10245
|
-
writeFileSync8(path, content, "utf8");
|
|
10246
|
-
},
|
|
10247
|
-
verify: createCredentialVerifier(exec, runtime)
|
|
10248
|
-
};
|
|
10249
|
-
}
|
|
10250
|
-
var AFK_TOKEN_KEY, CODEX_API_KEY, RUNTIME_AUTH_KEY, RUNTIME_AUTH_SETUP_HINT, LOGIN_TERMINAL_KIND;
|
|
10251
|
-
var init_setup = __esm(() => {
|
|
10252
|
-
init_src();
|
|
10253
|
-
init_paths();
|
|
10254
|
-
init_doctor();
|
|
10255
|
-
init_errors();
|
|
10256
|
-
init_asset_paths();
|
|
10257
|
-
init_settings();
|
|
10258
|
-
AFK_TOKEN_KEY = RUNTIME_SPECS["claude-code"].afkKey;
|
|
10259
|
-
CODEX_API_KEY = RUNTIME_SPECS.codex.afkKey;
|
|
10260
|
-
RUNTIME_AUTH_KEY = {
|
|
10261
|
-
"claude-code": AFK_TOKEN_KEY,
|
|
10262
|
-
codex: CODEX_API_KEY
|
|
10263
|
-
};
|
|
10264
|
-
RUNTIME_AUTH_SETUP_HINT = {
|
|
10265
|
-
"claude-code": RUNTIME_SPECS["claude-code"].afkFix,
|
|
10266
|
-
codex: `Run \`${RUNTIME_SPECS.codex.loginCommand}\` on this host, then burn again`
|
|
10267
|
-
};
|
|
10268
|
-
LOGIN_TERMINAL_KIND = {
|
|
10269
|
-
"claude-code": "claude-login",
|
|
10270
|
-
codex: "codex-login"
|
|
10271
|
-
};
|
|
10272
|
-
});
|
|
10273
|
-
|
|
10274
|
-
// src/services/agent-stream.ts
|
|
10275
|
-
function beginTranscript(ticketId) {
|
|
10276
|
-
transcripts.set(ticketId, { live: true, chunks: [], nextIndex: 0, bytes: 0 });
|
|
10277
|
-
publishLive({ kind: "transcript", ticketId });
|
|
10278
|
-
}
|
|
10279
|
-
function appendTranscript(ticketId, chunk) {
|
|
10280
|
-
const t = transcripts.get(ticketId);
|
|
10281
|
-
if (!t)
|
|
10282
|
-
return;
|
|
10283
|
-
const full = { ...chunk, i: t.nextIndex, ts: chunk.ts ?? Date.now() };
|
|
10284
|
-
t.nextIndex += 1;
|
|
10285
|
-
t.chunks.push(full);
|
|
10286
|
-
t.bytes += full.text.length;
|
|
10287
|
-
while (t.chunks.length > MAX_CHUNKS || t.bytes > MAX_BYTES && t.chunks.length > 1) {
|
|
10288
|
-
const dropped = t.chunks.shift();
|
|
10289
|
-
if (!dropped)
|
|
10290
|
-
break;
|
|
10291
|
-
t.bytes -= dropped.text.length;
|
|
10292
|
-
}
|
|
10293
|
-
publishLive({ kind: "transcript", ticketId });
|
|
10294
|
-
}
|
|
10295
|
-
function endTranscript(ticketId) {
|
|
10296
|
-
const t = transcripts.get(ticketId);
|
|
10297
|
-
if (t)
|
|
10298
|
-
t.live = false;
|
|
10299
|
-
publishLive({ kind: "transcript", ticketId });
|
|
10300
|
-
}
|
|
10301
|
-
function readTranscript(ticketId, after = -1) {
|
|
10302
|
-
const t = transcripts.get(ticketId);
|
|
10303
|
-
if (!t)
|
|
10304
|
-
return { live: false, chunks: [], firstIndex: 0, nextIndex: 0 };
|
|
10305
|
-
return {
|
|
10306
|
-
live: t.live,
|
|
10307
|
-
chunks: after < 0 ? [...t.chunks] : t.chunks.filter((c) => c.i > after),
|
|
10308
|
-
firstIndex: t.chunks[0]?.i ?? t.nextIndex,
|
|
10309
|
-
nextIndex: t.nextIndex
|
|
10310
|
-
};
|
|
10311
|
-
}
|
|
10312
|
-
var MAX_CHUNKS = 4000, MAX_BYTES = 1500000, transcripts;
|
|
10313
|
-
var init_agent_stream = __esm(() => {
|
|
10314
|
-
init_bus();
|
|
10315
|
-
transcripts = new Map;
|
|
10316
|
-
});
|
|
10317
|
-
|
|
10318
|
-
// ../../node_modules/.bun/@ai-hero+sandcastle@0.12.0/node_modules/@ai-hero/sandcastle/dist/chunk-NGBM7T3E.js
|
|
10319
|
-
import { createRequire as createRequire4 } from "module";
|
|
10320
|
-
var require$1, __create, __defProp2, __getOwnPropDesc, __getOwnPropNames, __getProtoOf, __hasOwnProp, __require2, __commonJS = (cb, mod) => function __require22() {
|
|
10321
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10322
|
-
}, __export2 = (target, all) => {
|
|
10323
|
-
for (var name in all)
|
|
10324
|
-
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
10325
|
-
}, __copyProps = (to, from, except, desc5) => {
|
|
10326
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10327
|
-
for (let key of __getOwnPropNames(from))
|
|
10328
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10329
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc5 = __getOwnPropDesc(from, key)) || desc5.enumerable });
|
|
10330
|
-
}
|
|
10331
|
-
return to;
|
|
10332
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")), __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, mod)), MAX_TAIL_CHARS, BoundedTail = class {
|
|
10333
|
-
items = [];
|
|
10334
|
-
totalChars = 0;
|
|
10335
|
-
maxChars;
|
|
10336
|
-
separator;
|
|
10337
|
-
constructor(maxChars = MAX_TAIL_CHARS, separator = "") {
|
|
10338
|
-
this.maxChars = maxChars;
|
|
10339
|
-
this.separator = separator;
|
|
10340
|
-
}
|
|
10341
|
-
push(item) {
|
|
10342
|
-
const bounded = item.length > this.maxChars ? item.slice(item.length - this.maxChars) : item;
|
|
10343
|
-
this.totalChars += bounded.length + (this.items.length > 0 ? this.separator.length : 0);
|
|
10344
|
-
this.items.push(bounded);
|
|
10345
|
-
while (this.totalChars > this.maxChars && this.items.length > 1) {
|
|
10346
|
-
const dropped = this.items.shift();
|
|
10347
|
-
this.totalChars -= dropped.length + this.separator.length;
|
|
10348
|
-
}
|
|
10349
|
-
}
|
|
10350
|
-
toString() {
|
|
10351
|
-
return this.items.join(this.separator);
|
|
10352
|
-
}
|
|
10353
|
-
}, elidePayloadTokens = (command) => command.replace(/'[A-Za-z0-9+\/=]{120,}'/g, "'\u2026'"), formatExecFailureMessage = (command, result, maxTailChars = MAX_TAIL_CHARS) => {
|
|
10354
|
-
const output = [result.stdout, result.stderr].map((stream) => (stream ?? "").trimEnd()).filter((stream) => stream.length > 0).join(`
|
|
10355
|
-
`);
|
|
10356
|
-
const tail = output.length > maxTailChars ? output.slice(output.length - maxTailChars) : output;
|
|
10357
|
-
const headline = `Command failed (exit ${result.exitCode}): ${elidePayloadTokens(command)}`;
|
|
10358
|
-
return tail ? `${headline}
|
|
10359
|
-
${tail}` : headline;
|
|
10360
|
-
};
|
|
10361
|
-
var init_chunk_NGBM7T3E = __esm(() => {
|
|
10362
|
-
require$1 = createRequire4(import.meta.url);
|
|
10363
|
-
__create = Object.create;
|
|
10364
|
-
__defProp2 = Object.defineProperty;
|
|
10365
|
-
__getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10366
|
-
__getOwnPropNames = Object.getOwnPropertyNames;
|
|
10367
|
-
__getProtoOf = Object.getPrototypeOf;
|
|
10368
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10369
|
-
__require2 = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10370
|
-
get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
|
|
10371
|
-
}) : x)(function(x) {
|
|
10372
|
-
if (typeof require$1 !== "undefined")
|
|
10373
|
-
return require$1.apply(this, arguments);
|
|
10374
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10375
|
-
});
|
|
10376
|
-
MAX_TAIL_CHARS = 64 * 1024;
|
|
10377
|
-
});
|
|
10378
|
-
|
|
10379
|
-
// ../../node_modules/.bun/@ai-hero+sandcastle@0.12.0/node_modules/@ai-hero/sandcastle/dist/chunk-VOG34SRF.js
|
|
10380
|
-
import { createRequire as createRequire5 } from "module";
|
|
10381
|
-
import * as clack from "@clack/prompts";
|
|
10382
|
-
import { join as join$1, basename as basename3, dirname as dirname10, resolve as resolve10, posix as posix2, normalize, isAbsolute as isAbsolute2 } from "path";
|
|
10383
|
-
import { styleText, promisify } from "util";
|
|
10384
|
-
import { existsSync as existsSync17, statSync as statSync5 } from "fs";
|
|
10385
|
-
import { tmpdir as tmpdir2, homedir as homedir3 } from "os";
|
|
10386
|
-
import { mkdtemp, writeFile, mkdir, readFile as readFile2, rm, readdir, stat } from "fs/promises";
|
|
10387
|
-
import { exec, execFile } from "child_process";
|
|
10388
|
-
import { randomBytes as randomBytes2 } from "crypto";
|
|
10389
|
-
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
10390
|
-
switch (arguments.length) {
|
|
10391
|
-
case 1:
|
|
10392
|
-
return a;
|
|
10393
|
-
case 2:
|
|
10394
|
-
return ab(a);
|
|
10395
|
-
case 3:
|
|
10396
|
-
return bc(ab(a));
|
|
10397
|
-
case 4:
|
|
10398
|
-
return cd(bc(ab(a)));
|
|
10399
|
-
case 5:
|
|
10400
|
-
return de(cd(bc(ab(a))));
|
|
10401
|
-
case 6:
|
|
10402
|
-
return ef(de(cd(bc(ab(a)))));
|
|
10403
|
-
case 7:
|
|
10404
|
-
return fg(ef(de(cd(bc(ab(a))))));
|
|
10405
|
-
case 8:
|
|
10406
|
-
return gh(fg(ef(de(cd(bc(ab(a)))))));
|
|
10407
|
-
case 9:
|
|
10408
|
-
return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
|
|
10409
|
-
default: {
|
|
10410
|
-
let ret = arguments[0];
|
|
10411
|
-
for (let i = 1;i < arguments.length; i++) {
|
|
10412
|
-
ret = arguments[i](ret);
|
|
10413
|
-
}
|
|
10414
|
-
return ret;
|
|
10415
|
-
}
|
|
10416
|
-
}
|
|
10417
|
-
}
|
|
10418
|
-
function mul64(out, aHi, aLo, bHi, bLo) {
|
|
10419
|
-
let c1 = (aLo >>> 16) * (bLo & 65535) >>> 0;
|
|
10420
|
-
let c0 = (aLo & 65535) * (bLo >>> 16) >>> 0;
|
|
10421
|
-
let lo = (aLo & 65535) * (bLo & 65535) >>> 0;
|
|
10422
|
-
let hi = (aLo >>> 16) * (bLo >>> 16) + ((c0 >>> 16) + (c1 >>> 16)) >>> 0;
|
|
10423
|
-
c0 = c0 << 16 >>> 0;
|
|
10424
|
-
lo = lo + c0 >>> 0;
|
|
10425
|
-
if (lo >>> 0 < c0 >>> 0) {
|
|
10426
|
-
hi = hi + 1 >>> 0;
|
|
10427
|
-
}
|
|
10428
|
-
c1 = c1 << 16 >>> 0;
|
|
10429
|
-
lo = lo + c1 >>> 0;
|
|
10430
|
-
if (lo >>> 0 < c1 >>> 0) {
|
|
10431
|
-
hi = hi + 1 >>> 0;
|
|
10432
|
-
}
|
|
10433
|
-
hi = hi + Math.imul(aLo, bHi) >>> 0;
|
|
10434
|
-
hi = hi + Math.imul(aHi, bLo) >>> 0;
|
|
10435
|
-
out[0] = hi;
|
|
10436
|
-
out[1] = lo;
|
|
10437
|
-
}
|
|
10438
|
-
function add64(out, aHi, aLo, bHi, bLo) {
|
|
10439
|
-
let hi = aHi + bHi >>> 0;
|
|
10440
|
-
const lo = aLo + bLo >>> 0;
|
|
10441
|
-
if (lo >>> 0 < aLo >>> 0) {
|
|
10442
|
-
hi = hi + 1 | 0;
|
|
10443
|
-
}
|
|
10444
|
-
out[0] = hi;
|
|
10445
|
-
out[1] = lo;
|
|
10446
|
-
}
|
|
10447
|
-
function yieldWrapGet(self) {
|
|
10448
|
-
if (typeof self === "object" && self !== null && YieldWrapTypeId in self) {
|
|
10449
|
-
return self[YieldWrapTypeId]();
|
|
10450
|
-
}
|
|
10451
|
-
throw new Error(getBugErrorMessage("yieldWrapGet"));
|
|
10452
|
-
}
|
|
10453
|
-
function equals() {
|
|
10454
|
-
if (arguments.length === 1) {
|
|
10455
|
-
return (self) => compareBoth(self, arguments[0]);
|
|
10456
|
-
}
|
|
10457
|
-
return compareBoth(arguments[0], arguments[1]);
|
|
10458
|
-
}
|
|
10459
|
-
function compareBoth(self, that) {
|
|
10460
|
-
if (self === that) {
|
|
10461
|
-
return true;
|
|
10462
|
-
}
|
|
10463
|
-
const selfType = typeof self;
|
|
10464
|
-
if (selfType !== typeof that) {
|
|
10465
|
-
return false;
|
|
10466
|
-
}
|
|
10467
|
-
if (selfType === "object" || selfType === "function") {
|
|
10468
|
-
if (self !== null && that !== null) {
|
|
10469
|
-
if (isEqual(self) && isEqual(that)) {
|
|
10470
|
-
if (hash(self) === hash(that) && self[symbol2](that)) {
|
|
10471
|
-
return true;
|
|
10472
|
-
} else {
|
|
10473
|
-
return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
10474
|
-
}
|
|
10475
|
-
} else if (self instanceof Date && that instanceof Date) {
|
|
10476
|
-
const t1 = self.getTime();
|
|
10477
|
-
const t2 = that.getTime();
|
|
10478
|
-
return t1 === t2 || Number.isNaN(t1) && Number.isNaN(t2);
|
|
10479
|
-
} else if (self instanceof URL && that instanceof URL) {
|
|
10480
|
-
return self.href === that.href;
|
|
10481
|
-
}
|
|
10482
|
-
}
|
|
10483
|
-
if (structuralRegionState.enabled) {
|
|
10484
|
-
if (Array.isArray(self) && Array.isArray(that)) {
|
|
10485
|
-
return self.length === that.length && self.every((v, i) => compareBoth(v, that[i]));
|
|
10486
|
-
}
|
|
10487
|
-
if (Object.getPrototypeOf(self) === Object.prototype && Object.getPrototypeOf(that) === Object.prototype) {
|
|
10488
|
-
const keysSelf = Object.keys(self);
|
|
10489
|
-
const keysThat = Object.keys(that);
|
|
10490
|
-
if (keysSelf.length === keysThat.length) {
|
|
10491
|
-
for (const key of keysSelf) {
|
|
10492
|
-
if (!((key in that) && compareBoth(self[key], that[key]))) {
|
|
10493
|
-
return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
10494
|
-
}
|
|
10495
|
-
}
|
|
10496
|
-
return true;
|
|
10497
|
-
}
|
|
10498
|
-
}
|
|
10499
|
-
return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
10500
|
-
}
|
|
10501
|
-
}
|
|
10502
|
-
return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
10503
|
-
}
|
|
10504
|
-
function formatDate(date2) {
|
|
10505
|
-
try {
|
|
10506
|
-
return date2.toISOString();
|
|
10507
|
-
} catch {
|
|
10508
|
-
return "Invalid Date";
|
|
10509
|
-
}
|
|
10510
|
-
}
|
|
10511
|
-
function safeToString(input) {
|
|
10512
|
-
try {
|
|
10513
|
-
const s = input.toString();
|
|
10514
|
-
return typeof s === "string" ? s : String(s);
|
|
10515
|
-
} catch {
|
|
10516
|
-
return "[toString threw]";
|
|
10517
|
-
}
|
|
10518
|
-
}
|
|
10519
|
-
function formatPropertyKey(name) {
|
|
10520
|
-
return isString(name) ? JSON.stringify(name) : String(name);
|
|
10521
|
-
}
|
|
10522
|
-
function formatUnknown(input, options) {
|
|
10523
|
-
const seen = /* @__PURE__ */ new WeakSet;
|
|
10524
|
-
const wrap = (v, body) => {
|
|
10525
|
-
const ctor = v?.constructor;
|
|
10526
|
-
return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body;
|
|
10527
|
-
};
|
|
10528
|
-
const ownKeys = (o) => {
|
|
10529
|
-
try {
|
|
10530
|
-
return Reflect.ownKeys(o);
|
|
10531
|
-
} catch {
|
|
10532
|
-
return ["[ownKeys threw]"];
|
|
10533
|
-
}
|
|
10534
|
-
};
|
|
10535
|
-
function go2(v, d = 0) {
|
|
10536
|
-
if (Array.isArray(v)) {
|
|
10537
|
-
if (seen.has(v))
|
|
10538
|
-
return CIRCULAR;
|
|
10539
|
-
seen.add(v);
|
|
10540
|
-
return `[${v.map((x) => go2(x, d)).join(",")}]`;
|
|
10541
|
-
}
|
|
10542
|
-
if (isDate(v))
|
|
10543
|
-
return formatDate(v);
|
|
10544
|
-
if (hasProperty(v, "toString") && isFunction2(v["toString"]) && v["toString"] !== Object.prototype.toString && v["toString"] !== Array.prototype.toString) {
|
|
10545
|
-
const s = safeToString(v);
|
|
10546
|
-
if (v instanceof Error && v.cause) {
|
|
10547
|
-
return `${s} (cause: ${go2(v.cause, d)})`;
|
|
10548
|
-
}
|
|
10549
|
-
return s;
|
|
10550
|
-
}
|
|
10551
|
-
if (isString(v))
|
|
10552
|
-
return JSON.stringify(v);
|
|
10553
|
-
if (isNumber(v) || v == null || isBoolean(v) || isSymbol(v))
|
|
10554
|
-
return String(v);
|
|
10555
|
-
if (isBigInt(v))
|
|
10556
|
-
return String(v) + "n";
|
|
10557
|
-
if (v instanceof Set || v instanceof Map) {
|
|
10558
|
-
if (seen.has(v))
|
|
10559
|
-
return CIRCULAR;
|
|
10560
|
-
seen.add(v);
|
|
10561
|
-
return `${v.constructor.name}(${go2(Array.from(v), d)})`;
|
|
10562
|
-
}
|
|
10563
|
-
if (isObject(v)) {
|
|
10564
|
-
if (seen.has(v))
|
|
10565
|
-
return CIRCULAR;
|
|
10566
|
-
seen.add(v);
|
|
10567
|
-
const keys5 = ownKeys(v);
|
|
10568
|
-
{
|
|
10569
|
-
const body2 = `{${keys5.map((k) => `${formatPropertyKey(k)}:${go2(v[k], d)}`).join(",")}}`;
|
|
10570
|
-
return wrap(v, body2);
|
|
10571
|
-
}
|
|
10572
|
-
}
|
|
10573
|
-
return String(v);
|
|
10574
|
-
}
|
|
10575
|
-
return go2(input, 0);
|
|
10576
|
-
}
|
|
10577
|
-
function copy2(src, srcPos, dest, destPos, len) {
|
|
10578
|
-
for (let i = srcPos;i < Math.min(src.length, srcPos + len); i++) {
|
|
10579
|
-
dest[destPos + i - srcPos] = src[i];
|
|
10580
|
-
}
|
|
10581
|
-
return dest;
|
|
10582
|
-
}
|
|
10583
|
-
function popcount(x) {
|
|
10584
|
-
x -= x >> 1 & 1431655765;
|
|
10585
|
-
x = (x & 858993459) + (x >> 2 & 858993459);
|
|
10586
|
-
x = x + (x >> 4) & 252645135;
|
|
10587
|
-
x += x >> 8;
|
|
10588
|
-
x += x >> 16;
|
|
10589
|
-
return x & 127;
|
|
10590
|
-
}
|
|
10591
|
-
function hashFragment(shift2, h) {
|
|
10592
|
-
return h >>> shift2 & MASK;
|
|
10593
|
-
}
|
|
10594
|
-
function toBitmap(x) {
|
|
10595
|
-
return 1 << x;
|
|
10596
|
-
}
|
|
10597
|
-
function fromBitmap(bitmap, bit) {
|
|
10598
|
-
return popcount(bitmap & bit - 1);
|
|
10599
|
-
}
|
|
10600
|
-
function arrayUpdate(mutate5, at, v, arr) {
|
|
10601
|
-
let out = arr;
|
|
10602
|
-
if (!mutate5) {
|
|
10603
|
-
const len = arr.length;
|
|
10604
|
-
out = new Array(len);
|
|
10605
|
-
for (let i = 0;i < len; ++i)
|
|
10606
|
-
out[i] = arr[i];
|
|
10607
|
-
}
|
|
10608
|
-
out[at] = v;
|
|
10609
|
-
return out;
|
|
10610
|
-
}
|
|
10611
|
-
function arraySpliceOut(mutate5, at, arr) {
|
|
10612
|
-
const newLen = arr.length - 1;
|
|
10613
|
-
let i = 0;
|
|
10614
|
-
let g = 0;
|
|
10615
|
-
let out = arr;
|
|
10616
|
-
if (mutate5) {
|
|
10617
|
-
i = g = at;
|
|
10618
|
-
} else {
|
|
10619
|
-
out = new Array(newLen);
|
|
10620
|
-
while (i < at)
|
|
10621
|
-
out[g++] = arr[i++];
|
|
10622
|
-
}
|
|
10623
|
-
++i;
|
|
10624
|
-
while (i <= newLen)
|
|
10625
|
-
out[g++] = arr[i++];
|
|
10626
|
-
if (mutate5) {
|
|
10627
|
-
out.length = newLen;
|
|
10628
|
-
}
|
|
10629
|
-
return out;
|
|
10630
|
-
}
|
|
10631
|
-
function arraySpliceIn(mutate5, at, v, arr) {
|
|
10632
|
-
const len = arr.length;
|
|
10633
|
-
if (mutate5) {
|
|
10634
|
-
let i2 = len;
|
|
10635
|
-
while (i2 >= at)
|
|
10636
|
-
arr[i2--] = arr[i2];
|
|
10637
|
-
arr[at] = v;
|
|
10638
|
-
return arr;
|
|
10639
|
-
}
|
|
10640
|
-
let i = 0, g = 0;
|
|
10641
|
-
const out = new Array(len + 1);
|
|
10642
|
-
while (i < at)
|
|
10643
|
-
out[g++] = arr[i++];
|
|
10644
|
-
out[at] = v;
|
|
10645
|
-
while (i < len)
|
|
10646
|
-
out[++g] = arr[i++];
|
|
10647
|
-
return out;
|
|
10648
|
-
}
|
|
10649
|
-
function isEmptyNode(a) {
|
|
10650
|
-
return isTagged(a, "EmptyNode");
|
|
9979
|
+
function isEmptyNode(a) {
|
|
9980
|
+
return isTagged(a, "EmptyNode");
|
|
10651
9981
|
}
|
|
10652
9982
|
function isLeafNode(node) {
|
|
10653
9983
|
return isEmptyNode(node) || node._tag === "LeafNode" || node._tag === "CollisionNode";
|
|
@@ -10747,8 +10077,8 @@ function taggedMatch() {
|
|
|
10747
10077
|
const cases = arguments[1];
|
|
10748
10078
|
return cases[value5._tag](value5);
|
|
10749
10079
|
}
|
|
10750
|
-
function aliasOrValue(
|
|
10751
|
-
return aliases?.[
|
|
10080
|
+
function aliasOrValue(field, aliases) {
|
|
10081
|
+
return aliases?.[field.toLocaleLowerCase()] ?? Number(field);
|
|
10752
10082
|
}
|
|
10753
10083
|
function defineLength(length3, fn2) {
|
|
10754
10084
|
return Object.defineProperty(fn2, "length", {
|
|
@@ -11073,7 +10403,7 @@ var Effect_exports, isFunction = (input) => typeof input === "function", dual =
|
|
|
11073
10403
|
};
|
|
11074
10404
|
};
|
|
11075
10405
|
}
|
|
11076
|
-
}, identity = (a) => a, constant = (value5) => () => value5, constTrue, constFalse, constNull, constUndefined, constVoid, make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that), isStrictEquivalent = (x, y) => x === y, strict = () => isStrictEquivalent,
|
|
10406
|
+
}, identity = (a) => a, constant = (value5) => () => value5, constTrue, constFalse, constNull, constUndefined, constVoid, make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that), isStrictEquivalent = (x, y) => x === y, strict = () => isStrictEquivalent, number4, mapInput, Date2, array4 = (item) => make((self, that) => {
|
|
11077
10407
|
if (self.length !== that.length) {
|
|
11078
10408
|
return false;
|
|
11079
10409
|
}
|
|
@@ -11169,22 +10499,22 @@ var Effect_exports, isFunction = (input) => typeof input === "function", dual =
|
|
|
11169
10499
|
case "number":
|
|
11170
10500
|
return number22(self);
|
|
11171
10501
|
case "bigint":
|
|
11172
|
-
return
|
|
10502
|
+
return string4(self.toString(10));
|
|
11173
10503
|
case "boolean":
|
|
11174
|
-
return
|
|
10504
|
+
return string4(String(self));
|
|
11175
10505
|
case "symbol":
|
|
11176
|
-
return
|
|
10506
|
+
return string4(String(self));
|
|
11177
10507
|
case "string":
|
|
11178
|
-
return
|
|
10508
|
+
return string4(self);
|
|
11179
10509
|
case "undefined":
|
|
11180
|
-
return
|
|
10510
|
+
return string4("undefined");
|
|
11181
10511
|
case "function":
|
|
11182
10512
|
case "object": {
|
|
11183
10513
|
if (self === null) {
|
|
11184
|
-
return
|
|
10514
|
+
return string4("null");
|
|
11185
10515
|
} else if (self instanceof Date) {
|
|
11186
10516
|
if (Number.isNaN(self.getTime())) {
|
|
11187
|
-
return
|
|
10517
|
+
return string4("Invalid Date");
|
|
11188
10518
|
}
|
|
11189
10519
|
return hash(self.toISOString());
|
|
11190
10520
|
} else if (self instanceof URL) {
|
|
@@ -11215,7 +10545,7 @@ var Effect_exports, isFunction = (input) => typeof input === "function", dual =
|
|
|
11215
10545
|
h ^= n /= 4294967295;
|
|
11216
10546
|
}
|
|
11217
10547
|
return optimize(h);
|
|
11218
|
-
},
|
|
10548
|
+
}, string4 = (str) => {
|
|
11219
10549
|
let h = 5381, i = str.length;
|
|
11220
10550
|
while (i) {
|
|
11221
10551
|
h = h * 33 ^ str.charCodeAt(--i);
|
|
@@ -11224,7 +10554,7 @@ var Effect_exports, isFunction = (input) => typeof input === "function", dual =
|
|
|
11224
10554
|
}, structureKeys = (o, keys5) => {
|
|
11225
10555
|
let h = 12289;
|
|
11226
10556
|
for (let i = 0;i < keys5.length; i++) {
|
|
11227
|
-
h ^= pipe(
|
|
10557
|
+
h ^= pipe(string4(keys5[i]), combine(hash(o[keys5[i]])));
|
|
11228
10558
|
}
|
|
11229
10559
|
return optimize(h);
|
|
11230
10560
|
}, structure = (o) => structureKeys(o, Object.keys(o)), array22 = (arr) => {
|
|
@@ -11460,7 +10790,7 @@ var Effect_exports, isFunction = (input) => typeof input === "function", dual =
|
|
|
11460
10790
|
next4 = b2;
|
|
11461
10791
|
}
|
|
11462
10792
|
return out;
|
|
11463
|
-
}, getEquivalence2, dedupeWith, dedupe = (self) => dedupeWith(self, equivalence()),
|
|
10793
|
+
}, getEquivalence2, dedupeWith, dedupe = (self) => dedupeWith(self, equivalence()), join17, TypeId4, emptyArray, getEquivalence3 = (isEquivalent) => make((self, that) => self.length === that.length && toReadonlyArray(self).every((value5, i) => isEquivalent(value5, unsafeGet2(that, i)))), _equivalence3, ChunkProto, makeChunk = (backing) => {
|
|
11464
10794
|
const chunk4 = Object.create(ChunkProto);
|
|
11465
10795
|
chunk4.backing = backing;
|
|
11466
10796
|
switch (backing._tag) {
|
|
@@ -11504,26 +10834,26 @@ var Effect_exports, isFunction = (input) => typeof input === "function", dual =
|
|
|
11504
10834
|
}, isChunk = (u) => hasProperty(u, TypeId4), _empty, empty3 = () => _empty, make5 = (...as12) => unsafeFromNonEmptyArray(as12), of2 = (a) => makeChunk({
|
|
11505
10835
|
_tag: "ISingleton",
|
|
11506
10836
|
a
|
|
11507
|
-
}), fromIterable3 = (self) => isChunk(self) ? self : unsafeFromArray(fromIterable2(self)), copyToArray = (self,
|
|
10837
|
+
}), fromIterable3 = (self) => isChunk(self) ? self : unsafeFromArray(fromIterable2(self)), copyToArray = (self, array5, initial) => {
|
|
11508
10838
|
switch (self.backing._tag) {
|
|
11509
10839
|
case "IArray": {
|
|
11510
|
-
copy2(self.backing.array, 0,
|
|
10840
|
+
copy2(self.backing.array, 0, array5, initial, self.length);
|
|
11511
10841
|
break;
|
|
11512
10842
|
}
|
|
11513
10843
|
case "IConcat": {
|
|
11514
|
-
copyToArray(self.left,
|
|
11515
|
-
copyToArray(self.right,
|
|
10844
|
+
copyToArray(self.left, array5, initial);
|
|
10845
|
+
copyToArray(self.right, array5, initial + self.left.length);
|
|
11516
10846
|
break;
|
|
11517
10847
|
}
|
|
11518
10848
|
case "ISingleton": {
|
|
11519
|
-
|
|
10849
|
+
array5[initial] = self.backing.a;
|
|
11520
10850
|
break;
|
|
11521
10851
|
}
|
|
11522
10852
|
case "ISlice": {
|
|
11523
10853
|
let i = 0;
|
|
11524
10854
|
let j = initial;
|
|
11525
10855
|
while (i < self.length) {
|
|
11526
|
-
|
|
10856
|
+
array5[j] = unsafeGet2(self, i);
|
|
11527
10857
|
i += 1;
|
|
11528
10858
|
j += 1;
|
|
11529
10859
|
}
|
|
@@ -13113,7 +12443,7 @@ ${prefix}}`;
|
|
|
13113
12443
|
}), constContext, context = () => constContext, contextWithEffect = (f) => flatMap7(context(), f), provideContext, provideSomeContext, mapInputContext, filterEffectOrElse, filterEffectOrFail, currentSpanFromFiber = (fiber) => {
|
|
13114
12444
|
const span4 = fiber.currentSpan;
|
|
13115
12445
|
return span4 !== undefined && span4._tag === "Span" ? some2(span4) : none2();
|
|
13116
|
-
}, NoopSpanProto, noopSpan = (options) => Object.assign(Object.create(NoopSpanProto), options), ClockSymbolKey = "effect/Clock", ClockTypeId, clockTag, MAX_TIMER_MILLIS, globalClockScheduler, performanceNowNanos, processOrPerformanceNow, ClockImpl, make20 = () => new ClockImpl, Order2, escape = (
|
|
12446
|
+
}, NoopSpanProto, noopSpan = (options) => Object.assign(Object.create(NoopSpanProto), options), ClockSymbolKey = "effect/Clock", ClockTypeId, clockTag, MAX_TIMER_MILLIS, globalClockScheduler, performanceNowNanos, processOrPerformanceNow, ClockImpl, make20 = () => new ClockImpl, Order2, escape = (string5) => string5.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&"), OP_AND = "And", OP_OR = "Or", OP_INVALID_DATA = "InvalidData", OP_MISSING_DATA = "MissingData", OP_SOURCE_UNAVAILABLE = "SourceUnavailable", OP_UNSUPPORTED = "Unsupported", ConfigErrorSymbolKey = "effect/ConfigError", ConfigErrorTypeId, proto2, And = (self, that) => {
|
|
13117
12447
|
const error3 = Object.create(proto2);
|
|
13118
12448
|
error3._op = OP_AND;
|
|
13119
12449
|
error3.left = self;
|
|
@@ -13159,7 +12489,7 @@ ${prefix}}`;
|
|
|
13159
12489
|
Object.defineProperty(error3, "toString", {
|
|
13160
12490
|
enumerable: false,
|
|
13161
12491
|
value() {
|
|
13162
|
-
const path2 = pipe(this.path,
|
|
12492
|
+
const path2 = pipe(this.path, join17(options.pathDelim));
|
|
13163
12493
|
return `(Invalid data at ${path2}: "${this.message}")`;
|
|
13164
12494
|
}
|
|
13165
12495
|
});
|
|
@@ -13174,7 +12504,7 @@ ${prefix}}`;
|
|
|
13174
12504
|
Object.defineProperty(error3, "toString", {
|
|
13175
12505
|
enumerable: false,
|
|
13176
12506
|
value() {
|
|
13177
|
-
const path2 = pipe(this.path,
|
|
12507
|
+
const path2 = pipe(this.path, join17(options.pathDelim));
|
|
13178
12508
|
return `(Missing data at ${path2}: "${this.message}")`;
|
|
13179
12509
|
}
|
|
13180
12510
|
});
|
|
@@ -13190,7 +12520,7 @@ ${prefix}}`;
|
|
|
13190
12520
|
Object.defineProperty(error3, "toString", {
|
|
13191
12521
|
enumerable: false,
|
|
13192
12522
|
value() {
|
|
13193
|
-
const path2 = pipe(this.path,
|
|
12523
|
+
const path2 = pipe(this.path, join17(options.pathDelim));
|
|
13194
12524
|
return `(Source unavailable at ${path2}: "${this.message}")`;
|
|
13195
12525
|
}
|
|
13196
12526
|
});
|
|
@@ -13205,7 +12535,7 @@ ${prefix}}`;
|
|
|
13205
12535
|
Object.defineProperty(error3, "toString", {
|
|
13206
12536
|
enumerable: false,
|
|
13207
12537
|
value() {
|
|
13208
|
-
const path2 = pipe(this.path,
|
|
12538
|
+
const path2 = pipe(this.path, join17(options.pathDelim));
|
|
13209
12539
|
return `(Unsupported operation at ${path2}: "${this.message}")`;
|
|
13210
12540
|
}
|
|
13211
12541
|
});
|
|
@@ -13235,7 +12565,7 @@ ${prefix}}`;
|
|
|
13235
12565
|
pathDelim: "_",
|
|
13236
12566
|
seqDelim: ","
|
|
13237
12567
|
}, options);
|
|
13238
|
-
const makePathString = (path) => pipe(path,
|
|
12568
|
+
const makePathString = (path) => pipe(path, join17(pathDelim));
|
|
13239
12569
|
const unmakePathString = (pathString) => pathString.split(pathDelim);
|
|
13240
12570
|
const getEnv = () => typeof process !== "undefined" && ("env" in process) && typeof process.env === "object" ? process.env : {};
|
|
13241
12571
|
const load = (path, primitive2, split2 = true) => {
|
|
@@ -13356,7 +12686,7 @@ ${prefix}}`;
|
|
|
13356
12686
|
return fail2(right3.left);
|
|
13357
12687
|
}
|
|
13358
12688
|
if (isRight2(left3) && isRight2(right3)) {
|
|
13359
|
-
const path = pipe(prefix,
|
|
12689
|
+
const path = pipe(prefix, join17("."));
|
|
13360
12690
|
const fail19 = fromFlatLoopFail(prefix, path);
|
|
13361
12691
|
const [lefts, rights] = extend(fail19, fail19, pipe(left3.right, map3(right2)), pipe(right3.right, map3(right2)));
|
|
13362
12692
|
return pipe(lefts, zip(rights), forEachSequential(([left4, right4]) => pipe(zip2(left4, right4), map10(([left5, right5]) => op.zip(left5, right5)))));
|
|
@@ -13376,8 +12706,8 @@ ${prefix}}`;
|
|
|
13376
12706
|
}));
|
|
13377
12707
|
}
|
|
13378
12708
|
return pipe(splitPathString(text2, delimiter), forEachSequential((char) => primitive2.parse(char.trim())), mapError(prefixed(path)));
|
|
13379
|
-
}, transpose = (
|
|
13380
|
-
return Object.keys(
|
|
12709
|
+
}, transpose = (array5) => {
|
|
12710
|
+
return Object.keys(array5[0]).map((column) => array5.map((row) => row[column]));
|
|
13381
12711
|
}, indicesFrom = (quotedIndices) => pipe(forEachSequential(quotedIndices, parseQuotedIndex), mapBoth2({
|
|
13382
12712
|
onFailure: () => empty2(),
|
|
13383
12713
|
onSuccess: sort(Order2)
|
|
@@ -13630,7 +12960,7 @@ ${prefix}}`;
|
|
|
13630
12960
|
return isMicroExit(that) && that._tag === options.op && equals(this[args], that[args]);
|
|
13631
12961
|
},
|
|
13632
12962
|
[symbol]() {
|
|
13633
|
-
return cached2(this, combine(
|
|
12963
|
+
return cached2(this, combine(string4(options.op))(hash(this[args])));
|
|
13634
12964
|
}
|
|
13635
12965
|
};
|
|
13636
12966
|
return function(value5) {
|
|
@@ -14956,9 +14286,9 @@ ${prefix}}`;
|
|
|
14956
14286
|
return options?.discard !== true && reconcile._tag === "Some" ? map10(forEach7(effects, identity, options), reconcile.value) : forEach7(effects, identity, options);
|
|
14957
14287
|
}, allWith = (options) => (arg) => all5(arg, options), allSuccesses = (elements, options) => map10(all5(fromIterable2(elements).map(exit), options), filterMap2((exit4) => exitIsSuccess(exit4) ? some2(exit4.effect_instruction_i0) : none2())), replicate, replicateEffect, forEach7, forEachParUnbounded = (self, f, batching) => suspend(() => {
|
|
14958
14288
|
const as12 = fromIterable2(self);
|
|
14959
|
-
const
|
|
14960
|
-
const fn2 = (a, i) => flatMap7(f(a, i), (b) => sync(() =>
|
|
14961
|
-
return zipRight2(forEachConcurrentDiscard(as12, fn2, batching, false), succeed(
|
|
14289
|
+
const array5 = new Array(as12.length);
|
|
14290
|
+
const fn2 = (a, i) => flatMap7(f(a, i), (b) => sync(() => array5[i] = b));
|
|
14291
|
+
return zipRight2(forEachConcurrentDiscard(as12, fn2, batching, false), succeed(array5));
|
|
14962
14292
|
}), forEachConcurrentDiscard = (self, f, batching, processAll, n) => uninterruptibleMask((restore) => transplant((graft) => withFiberRuntime((parent) => {
|
|
14963
14293
|
let todos = Array.from(self).reverse();
|
|
14964
14294
|
let target = todos.length;
|
|
@@ -15113,9 +14443,9 @@ ${prefix}}`;
|
|
|
15113
14443
|
})));
|
|
15114
14444
|
}))), forEachParN = (self, n, f, batching) => suspend(() => {
|
|
15115
14445
|
const as12 = fromIterable2(self);
|
|
15116
|
-
const
|
|
15117
|
-
const fn2 = (a, i) => map10(f(a, i), (b) =>
|
|
15118
|
-
return zipRight2(forEachConcurrentDiscard(as12, fn2, batching, false, n), succeed(
|
|
14446
|
+
const array5 = new Array(as12.length);
|
|
14447
|
+
const fn2 = (a, i) => map10(f(a, i), (b) => array5[i] = b);
|
|
14448
|
+
return zipRight2(forEachConcurrentDiscard(as12, fn2, batching, false, n), succeed(array5));
|
|
15119
14449
|
}), fork = (self) => withFiberRuntime((state, status3) => succeed(unsafeFork2(self, state, status3.runtimeFlags))), forkDaemon = (self) => forkWithScopeOverride(self, globalScope), forkWithErrorHandler, unsafeFork2 = (effect3, parentFiber, parentRuntimeFlags, overrideScope = null) => {
|
|
15120
14450
|
const childFiber = unsafeMakeChildFiber(effect3, parentFiber, parentRuntimeFlags, overrideScope);
|
|
15121
14451
|
childFiber.resume(effect3);
|
|
@@ -15532,11 +14862,11 @@ ${prefix}}`;
|
|
|
15532
14862
|
return end5 - time2 <= 0 ? some2(computeCachedValue(self, timeToLive, time2)) : none2();
|
|
15533
14863
|
}
|
|
15534
14864
|
}
|
|
15535
|
-
})), flatMap7((option5) => isNone2(option5) ? dieMessage("BUG: Effect.cachedInvalidate - please report an issue at https://github.com/Effect-TS/effect/issues") : restore(deferredAwait(option5.value[1]))))), invalidateCache = (cache) => set4(cache, none2()), ensuringChild, ensuringChildren, forkAll, forkIn, forkScoped = (self) => scopeWith((scope5) => forkIn(self, scope5)), fromFiber = (fiber) => join22(fiber), fromFiberEffect = (fiber) => suspend(() => flatMap7(fiber, join22)), memoKeySymbol, Key, cachedFunction = (f,
|
|
14865
|
+
})), flatMap7((option5) => isNone2(option5) ? dieMessage("BUG: Effect.cachedInvalidate - please report an issue at https://github.com/Effect-TS/effect/issues") : restore(deferredAwait(option5.value[1]))))), invalidateCache = (cache) => set4(cache, none2()), ensuringChild, ensuringChildren, forkAll, forkIn, forkScoped = (self) => scopeWith((scope5) => forkIn(self, scope5)), fromFiber = (fiber) => join22(fiber), fromFiberEffect = (fiber) => suspend(() => flatMap7(fiber, join22)), memoKeySymbol, Key, cachedFunction = (f, eq11) => {
|
|
15536
14866
|
return pipe(sync(() => empty22()), flatMap7(makeSynchronized), map10((ref) => (a) => pipe(ref.modifyEffect((map27) => {
|
|
15537
|
-
const result = pipe(map27, get12(new Key(a,
|
|
14867
|
+
const result = pipe(map27, get12(new Key(a, eq11)));
|
|
15538
14868
|
if (isNone2(result)) {
|
|
15539
|
-
return pipe(deferredMake(), tap2((deferred) => pipe(diffFiberRefs(f(a)), intoDeferred(deferred), fork)), map10((deferred) => [deferred, pipe(map27, set6(new Key(a,
|
|
14869
|
+
return pipe(deferredMake(), tap2((deferred) => pipe(diffFiberRefs(f(a)), intoDeferred(deferred), fork)), map10((deferred) => [deferred, pipe(map27, set6(new Key(a, eq11), deferred))]));
|
|
15540
14870
|
}
|
|
15541
14871
|
return succeed([result.value, map27]);
|
|
15542
14872
|
}), flatMap7(deferredAwait), flatMap7(([patch9, b]) => pipe(patchFiberRefs(patch9), as2(b))))));
|
|
@@ -16221,8 +15551,8 @@ ${prefix}}`;
|
|
|
16221
15551
|
const capacity3 = options.max - options.min + 1;
|
|
16222
15552
|
const values3 = /* @__PURE__ */ new Set;
|
|
16223
15553
|
const fields = input.split(",");
|
|
16224
|
-
for (const
|
|
16225
|
-
const [raw, step4] = splitStep(
|
|
15554
|
+
for (const field of fields) {
|
|
15555
|
+
const [raw, step4] = splitStep(field);
|
|
16226
15556
|
if (raw === "*" && step4 === undefined) {
|
|
16227
15557
|
return right2(/* @__PURE__ */ new Set);
|
|
16228
15558
|
}
|
|
@@ -20245,9 +19575,9 @@ schema (${ast._tag}): ${ast}`;
|
|
|
20245
19575
|
const transformations = [];
|
|
20246
19576
|
for (let i = 0;i < ownKeys.length; i++) {
|
|
20247
19577
|
const key = ownKeys[i];
|
|
20248
|
-
const
|
|
20249
|
-
if (isPropertySignature(
|
|
20250
|
-
const ast =
|
|
19578
|
+
const field = fields[key];
|
|
19579
|
+
if (isPropertySignature(field)) {
|
|
19580
|
+
const ast = field.ast;
|
|
20251
19581
|
switch (ast._tag) {
|
|
20252
19582
|
case "PropertySignatureDeclaration": {
|
|
20253
19583
|
const type2 = ast.type;
|
|
@@ -20267,9 +19597,9 @@ schema (${ast._tag}): ${ast}`;
|
|
|
20267
19597
|
}
|
|
20268
19598
|
}
|
|
20269
19599
|
} else {
|
|
20270
|
-
from.push(new PropertySignature(key,
|
|
20271
|
-
to.push(new PropertySignature(key, typeAST(
|
|
20272
|
-
pss.push(new PropertySignature(key,
|
|
19600
|
+
from.push(new PropertySignature(key, field.ast, false, true));
|
|
19601
|
+
to.push(new PropertySignature(key, typeAST(field.ast), false, true));
|
|
19602
|
+
pss.push(new PropertySignature(key, field.ast, false, true));
|
|
20273
19603
|
}
|
|
20274
19604
|
}
|
|
20275
19605
|
if (isNonEmptyReadonlyArray(transformations)) {
|
|
@@ -20309,9 +19639,9 @@ schema (${ast._tag}): ${ast}`;
|
|
|
20309
19639
|
}, lazilyMergeDefaults = (fields, out) => {
|
|
20310
19640
|
const ownKeys = Reflect.ownKeys(fields);
|
|
20311
19641
|
for (const key of ownKeys) {
|
|
20312
|
-
const
|
|
20313
|
-
if (out[key] === undefined && isPropertySignature(
|
|
20314
|
-
const ast =
|
|
19642
|
+
const field = fields[key];
|
|
19643
|
+
if (out[key] === undefined && isPropertySignature(field)) {
|
|
19644
|
+
const ast = field.ast;
|
|
20315
19645
|
const defaultValue = ast._tag === "PropertySignatureDeclaration" ? ast.defaultValue : ast.to.defaultValue;
|
|
20316
19646
|
if (defaultValue !== undefined) {
|
|
20317
19647
|
out[key] = defaultValue();
|
|
@@ -21288,7 +20618,7 @@ schema (${ast._tag}): ${ast}`;
|
|
|
21288
20618
|
const cowFlags = getCopyOnWriteFlags(process.platform);
|
|
21289
20619
|
for (const relativePath of paths) {
|
|
21290
20620
|
const src = join$1(hostRepoDir, relativePath);
|
|
21291
|
-
if (!
|
|
20621
|
+
if (!existsSync15(src)) {
|
|
21292
20622
|
continue;
|
|
21293
20623
|
}
|
|
21294
20624
|
const dest = join$1(worktreePath, relativePath);
|
|
@@ -21430,7 +20760,7 @@ ${e instanceof Error ? e.message : String(e)}`
|
|
|
21430
20760
|
await mkdir(patchesRoot, { recursive: true });
|
|
21431
20761
|
let dirName = base;
|
|
21432
20762
|
let counter6 = 0;
|
|
21433
|
-
while (
|
|
20763
|
+
while (existsSync15(join$1(patchesRoot, dirName))) {
|
|
21434
20764
|
counter6++;
|
|
21435
20765
|
dirName = `${base}-${counter6}`;
|
|
21436
20766
|
}
|
|
@@ -21521,7 +20851,7 @@ ${e instanceof Error ? e.message : String(e)}`
|
|
|
21521
20851
|
const hostFilePath = join$1(untrackedDir, relPath);
|
|
21522
20852
|
yield* Effect_exports.tryPromise({
|
|
21523
20853
|
try: async () => {
|
|
21524
|
-
await mkdir(
|
|
20854
|
+
await mkdir(dirname8(hostFilePath), { recursive: true });
|
|
21525
20855
|
await handle.copyFileOut(sandboxFilePath, hostFilePath);
|
|
21526
20856
|
},
|
|
21527
20857
|
catch: (e) => new SyncError({
|
|
@@ -21553,7 +20883,7 @@ ${e instanceof Error ? e.message : String(e)}`
|
|
|
21553
20883
|
for (const relPath of untrackedFiles) {
|
|
21554
20884
|
const srcPath = join$1(untrackedDir, relPath);
|
|
21555
20885
|
const destPath = join$1(hostRepoDir, relPath);
|
|
21556
|
-
await mkdir(
|
|
20886
|
+
await mkdir(dirname8(destPath), { recursive: true });
|
|
21557
20887
|
const content = await readFile2(srcPath);
|
|
21558
20888
|
await writeFile(destPath, content);
|
|
21559
20889
|
}
|
|
@@ -21938,7 +21268,7 @@ ${result.stderr}`
|
|
|
21938
21268
|
yield* Effect_exports.gen(function* () {
|
|
21939
21269
|
for (const relativePath of pathsToCopy) {
|
|
21940
21270
|
const hostPath = join$1(options.hostRepoDir, relativePath);
|
|
21941
|
-
if (!
|
|
21271
|
+
if (!existsSync15(hostPath)) {
|
|
21942
21272
|
continue;
|
|
21943
21273
|
}
|
|
21944
21274
|
const sandboxPath = posix2.join(handle.worktreePath, relativePath);
|
|
@@ -22080,7 +21410,7 @@ Worktree removed (no uncommitted changes)`);
|
|
|
22080
21410
|
};
|
|
22081
21411
|
}
|
|
22082
21412
|
const resolvedHostPath = resolveHostPath(m.hostPath);
|
|
22083
|
-
if (!
|
|
21413
|
+
if (!existsSync15(resolvedHostPath)) {
|
|
22084
21414
|
throw new Error(`Mount hostPath does not exist: ${m.hostPath}` + (m.hostPath !== resolvedHostPath ? ` (resolved to ${resolvedHostPath})` : ""));
|
|
22085
21415
|
}
|
|
22086
21416
|
return {
|
|
@@ -22204,7 +21534,7 @@ Worktree removed (no uncommitted changes)`);
|
|
|
22204
21534
|
}
|
|
22205
21535
|
if (!isFile2)
|
|
22206
21536
|
continue;
|
|
22207
|
-
const parentDir =
|
|
21537
|
+
const parentDir = dirname8(mount.sandboxPath);
|
|
22208
21538
|
if (parentDir === sandboxHomedir)
|
|
22209
21539
|
continue;
|
|
22210
21540
|
if (!parentDir.startsWith(sandboxHomedir + "/")) {
|
|
@@ -22592,9 +21922,9 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
22592
21922
|
constNull = /* @__PURE__ */ constant(null);
|
|
22593
21923
|
constUndefined = /* @__PURE__ */ constant(undefined);
|
|
22594
21924
|
constVoid = constUndefined;
|
|
22595
|
-
|
|
21925
|
+
number4 = /* @__PURE__ */ strict();
|
|
22596
21926
|
mapInput = /* @__PURE__ */ dual(2, (self, f) => make((x, y) => self(f(x), f(y))));
|
|
22597
|
-
Date2 = /* @__PURE__ */ mapInput(
|
|
21927
|
+
Date2 = /* @__PURE__ */ mapInput(number4, (date2) => date2.getTime());
|
|
22598
21928
|
isFunction2 = isFunction;
|
|
22599
21929
|
hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && (property in self));
|
|
22600
21930
|
isTagged = /* @__PURE__ */ dual(2, (self, tag4) => hasProperty(self, "_tag") && self["_tag"] === tag4);
|
|
@@ -23179,7 +22509,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
23179
22509
|
});
|
|
23180
22510
|
reduce = /* @__PURE__ */ dual(3, (self, b, f) => fromIterable2(self).reduce((b2, a, i) => f(b2, a, i), b));
|
|
23181
22511
|
reduceRight = /* @__PURE__ */ dual(3, (self, b, f) => fromIterable2(self).reduceRight((b2, a, i) => f(b2, a, i), b));
|
|
23182
|
-
getEquivalence2 =
|
|
22512
|
+
getEquivalence2 = array4;
|
|
23183
22513
|
dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
23184
22514
|
const input = fromIterable2(self);
|
|
23185
22515
|
if (isNonEmptyReadonlyArray(input)) {
|
|
@@ -23194,7 +22524,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
23194
22524
|
}
|
|
23195
22525
|
return [];
|
|
23196
22526
|
});
|
|
23197
|
-
|
|
22527
|
+
join17 = /* @__PURE__ */ dual(2, (self, sep2) => fromIterable2(self).join(sep2));
|
|
23198
22528
|
TypeId4 = /* @__PURE__ */ Symbol.for("effect/Chunk");
|
|
23199
22529
|
emptyArray = [];
|
|
23200
22530
|
_equivalence3 = /* @__PURE__ */ getEquivalence3(equals);
|
|
@@ -23672,7 +23002,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
23672
23002
|
}
|
|
23673
23003
|
}));
|
|
23674
23004
|
forEach2 = /* @__PURE__ */ dual(2, (self, f) => forEach(self._keyMap, (_, k) => f(k)));
|
|
23675
|
-
reduce4 = /* @__PURE__ */ dual(3, (self, zero2, f) => reduce3(self._keyMap, zero2, (
|
|
23005
|
+
reduce4 = /* @__PURE__ */ dual(3, (self, zero2, f) => reduce3(self._keyMap, zero2, (z5, _, a) => f(z5, a)));
|
|
23676
23006
|
empty6 = empty5;
|
|
23677
23007
|
fromIterable6 = fromIterable5;
|
|
23678
23008
|
make9 = make8;
|
|
@@ -24321,7 +23651,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
24321
23651
|
return self;
|
|
24322
23652
|
});
|
|
24323
23653
|
FiberIdTypeId = /* @__PURE__ */ Symbol.for(FiberIdSymbolKey);
|
|
24324
|
-
emptyHash = /* @__PURE__ */
|
|
23654
|
+
emptyHash = /* @__PURE__ */ string4(`${FiberIdSymbolKey}-${OP_NONE}`);
|
|
24325
23655
|
None = class {
|
|
24326
23656
|
[FiberIdTypeId] = FiberIdTypeId;
|
|
24327
23657
|
_tag = OP_NONE;
|
|
@@ -24356,7 +23686,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
24356
23686
|
this.startTimeMillis = startTimeMillis;
|
|
24357
23687
|
}
|
|
24358
23688
|
[symbol]() {
|
|
24359
|
-
return cached2(this,
|
|
23689
|
+
return cached2(this, string4(`${FiberIdSymbolKey}-${this._tag}-${this.id}-${this.startTimeMillis}`));
|
|
24360
23690
|
}
|
|
24361
23691
|
[symbol2](that) {
|
|
24362
23692
|
return isFiberId(that) && that._tag === OP_RUNTIME && this.id === that.id && this.startTimeMillis === that.startTimeMillis;
|
|
@@ -24387,7 +23717,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
24387
23717
|
}
|
|
24388
23718
|
_hash;
|
|
24389
23719
|
[symbol]() {
|
|
24390
|
-
return pipe(
|
|
23720
|
+
return pipe(string4(`${FiberIdSymbolKey}-${this._tag}`), combine(hash(this.left)), combine(hash(this.right)), cached2(this));
|
|
24391
23721
|
}
|
|
24392
23722
|
[symbol2](that) {
|
|
24393
23723
|
return isFiberId(that) && that._tag === OP_COMPOSITE && equals(this.left, that.left) && equals(this.right, that.right);
|
|
@@ -24499,7 +23829,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
24499
23829
|
return pipeArguments(this, arguments);
|
|
24500
23830
|
}
|
|
24501
23831
|
};
|
|
24502
|
-
NilHash = /* @__PURE__ */
|
|
23832
|
+
NilHash = /* @__PURE__ */ string4("Nil");
|
|
24503
23833
|
NilProto = {
|
|
24504
23834
|
[TypeId8]: TypeId8,
|
|
24505
23835
|
_tag: "Nil",
|
|
@@ -24948,7 +24278,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
24948
24278
|
return exitIsExit(that) && that._op === "Failure" && equals(this.effect_instruction_i0, that.effect_instruction_i0);
|
|
24949
24279
|
}
|
|
24950
24280
|
[symbol]() {
|
|
24951
|
-
return pipe(
|
|
24281
|
+
return pipe(string4(this._tag), combine(hash(this.effect_instruction_i0)), cached2(this));
|
|
24952
24282
|
}
|
|
24953
24283
|
get cause() {
|
|
24954
24284
|
return this.effect_instruction_i0;
|
|
@@ -24988,7 +24318,7 @@ var init_chunk_VOG34SRF = __esm(() => {
|
|
|
24988
24318
|
return exitIsExit(that) && that._op === "Success" && equals(this.effect_instruction_i0, that.effect_instruction_i0);
|
|
24989
24319
|
}
|
|
24990
24320
|
[symbol]() {
|
|
24991
|
-
return pipe(
|
|
24321
|
+
return pipe(string4(this._tag), combine(hash(this.effect_instruction_i0)), cached2(this));
|
|
24992
24322
|
}
|
|
24993
24323
|
get value() {
|
|
24994
24324
|
return this.effect_instruction_i0;
|
|
@@ -26143,7 +25473,7 @@ ${this.stack.split(`
|
|
|
26143
25473
|
diff6 = diff5;
|
|
26144
25474
|
patch7 = patch6;
|
|
26145
25475
|
FiberStatusTypeId = /* @__PURE__ */ Symbol.for(FiberStatusSymbolKey);
|
|
26146
|
-
DoneHash = /* @__PURE__ */
|
|
25476
|
+
DoneHash = /* @__PURE__ */ string4(`${FiberStatusSymbolKey}-${OP_DONE}`);
|
|
26147
25477
|
Done = class {
|
|
26148
25478
|
[FiberStatusTypeId] = FiberStatusTypeId;
|
|
26149
25479
|
_tag = OP_DONE;
|
|
@@ -26671,7 +26001,7 @@ ${this.stack.split(`
|
|
|
26671
26001
|
constructor(key, value5) {
|
|
26672
26002
|
this.key = key;
|
|
26673
26003
|
this.value = value5;
|
|
26674
|
-
this._hash =
|
|
26004
|
+
this._hash = string4(MetricLabelSymbolKey + this.key + this.value);
|
|
26675
26005
|
}
|
|
26676
26006
|
[symbol]() {
|
|
26677
26007
|
return this._hash;
|
|
@@ -26841,12 +26171,12 @@ ${this.stack.split(`
|
|
|
26841
26171
|
while (!(next4 = iterator.next()).done) {
|
|
26842
26172
|
const index2 = i++;
|
|
26843
26173
|
const value5 = next4.value;
|
|
26844
|
-
result = flatMap7(result, (state) => map10(f(state, value5, index2), ([
|
|
26174
|
+
result = flatMap7(result, (state) => map10(f(state, value5, index2), ([z5, b]) => {
|
|
26845
26175
|
builder.push(b);
|
|
26846
|
-
return
|
|
26176
|
+
return z5;
|
|
26847
26177
|
}));
|
|
26848
26178
|
}
|
|
26849
|
-
return map10(result, (
|
|
26179
|
+
return map10(result, (z5) => [z5, builder]);
|
|
26850
26180
|
}));
|
|
26851
26181
|
mapErrorCause = /* @__PURE__ */ dual(2, (self, f) => matchCauseEffect(self, {
|
|
26852
26182
|
onFailure: (c) => failCauseSync(() => f(c)),
|
|
@@ -27242,7 +26572,7 @@ ${this.stack.split(`
|
|
|
27242
26572
|
[MetricBoundariesTypeId] = MetricBoundariesTypeId;
|
|
27243
26573
|
constructor(values3) {
|
|
27244
26574
|
this.values = values3;
|
|
27245
|
-
this._hash = pipe(
|
|
26575
|
+
this._hash = pipe(string4(MetricBoundariesSymbolKey), combine(array22(this.values)));
|
|
27246
26576
|
}
|
|
27247
26577
|
_hash;
|
|
27248
26578
|
[symbol]() {
|
|
@@ -27273,7 +26603,7 @@ ${this.stack.split(`
|
|
|
27273
26603
|
constructor(incremental, bigint) {
|
|
27274
26604
|
this.incremental = incremental;
|
|
27275
26605
|
this.bigint = bigint;
|
|
27276
|
-
this._hash =
|
|
26606
|
+
this._hash = string4(CounterKeyTypeSymbolKey);
|
|
27277
26607
|
}
|
|
27278
26608
|
_hash;
|
|
27279
26609
|
[symbol]() {
|
|
@@ -27292,7 +26622,7 @@ ${this.stack.split(`
|
|
|
27292
26622
|
[HistogramKeyTypeTypeId] = HistogramKeyTypeTypeId;
|
|
27293
26623
|
constructor(boundaries) {
|
|
27294
26624
|
this.boundaries = boundaries;
|
|
27295
|
-
this._hash = pipe(
|
|
26625
|
+
this._hash = pipe(string4(HistogramKeyTypeSymbolKey), combine(hash(this.boundaries)));
|
|
27296
26626
|
}
|
|
27297
26627
|
_hash;
|
|
27298
26628
|
[symbol]() {
|
|
@@ -27321,7 +26651,7 @@ ${this.stack.split(`
|
|
|
27321
26651
|
this.keyType = keyType;
|
|
27322
26652
|
this.description = description;
|
|
27323
26653
|
this.tags = tags2;
|
|
27324
|
-
this._hash = pipe(
|
|
26654
|
+
this._hash = pipe(string4(this.name + this.description), combine(hash(this.keyType)), combine(array22(this.tags)));
|
|
27325
26655
|
}
|
|
27326
26656
|
_hash;
|
|
27327
26657
|
[symbol]() {
|
|
@@ -27461,7 +26791,7 @@ ${this.stack.split(`
|
|
|
27461
26791
|
}
|
|
27462
26792
|
_hash;
|
|
27463
26793
|
[symbol]() {
|
|
27464
|
-
return pipe(
|
|
26794
|
+
return pipe(string4(FrequencyStateSymbolKey), combine(array22(fromIterable2(this.occurrences.entries()))), cached2(this));
|
|
27465
26795
|
}
|
|
27466
26796
|
[symbol2](that) {
|
|
27467
26797
|
return isFrequencyState(that) && arrayEquals(fromIterable2(this.occurrences.entries()), fromIterable2(that.occurrences.entries()));
|
|
@@ -29055,9 +28385,9 @@ ${this.stack.split(`
|
|
|
29055
28385
|
a;
|
|
29056
28386
|
eq;
|
|
29057
28387
|
[memoKeySymbol] = memoKeySymbol;
|
|
29058
|
-
constructor(a,
|
|
28388
|
+
constructor(a, eq11) {
|
|
29059
28389
|
this.a = a;
|
|
29060
|
-
this.eq =
|
|
28390
|
+
this.eq = eq11;
|
|
29061
28391
|
}
|
|
29062
28392
|
[symbol2](that) {
|
|
29063
28393
|
if (hasProperty(that, memoKeySymbol)) {
|
|
@@ -29766,7 +29096,7 @@ ${this.stack.split(`
|
|
|
29766
29096
|
...ProtoTimeZone,
|
|
29767
29097
|
_tag: "Named",
|
|
29768
29098
|
[symbol]() {
|
|
29769
|
-
return cached2(this,
|
|
29099
|
+
return cached2(this, string4(`Named:${this.id}`));
|
|
29770
29100
|
},
|
|
29771
29101
|
[symbol2](that) {
|
|
29772
29102
|
return isTimeZone(that) && that._tag === "Named" && this.id === that.id;
|
|
@@ -29786,7 +29116,7 @@ ${this.stack.split(`
|
|
|
29786
29116
|
...ProtoTimeZone,
|
|
29787
29117
|
_tag: "Offset",
|
|
29788
29118
|
[symbol]() {
|
|
29789
|
-
return cached2(this,
|
|
29119
|
+
return cached2(this, string4(`Offset:${this.offset}`));
|
|
29790
29120
|
},
|
|
29791
29121
|
[symbol2](that) {
|
|
29792
29122
|
return isTimeZone(that) && that._tag === "Offset" && this.offset === that.offset;
|
|
@@ -29869,7 +29199,7 @@ ${this.stack.split(`
|
|
|
29869
29199
|
[ParseErrorTypeId] = ParseErrorTypeId;
|
|
29870
29200
|
};
|
|
29871
29201
|
Equivalence2 = /* @__PURE__ */ make((self, that) => restrictionsEquals(self.seconds, that.seconds) && restrictionsEquals(self.minutes, that.minutes) && restrictionsEquals(self.hours, that.hours) && restrictionsEquals(self.days, that.days) && restrictionsEquals(self.months, that.months) && restrictionsEquals(self.weekdays, that.weekdays));
|
|
29872
|
-
restrictionsArrayEquals = /* @__PURE__ */
|
|
29202
|
+
restrictionsArrayEquals = /* @__PURE__ */ array4(number4);
|
|
29873
29203
|
equals3 = /* @__PURE__ */ dual(2, (self, that) => Equivalence2(self, that));
|
|
29874
29204
|
secondOptions = {
|
|
29875
29205
|
min: 0,
|
|
@@ -30082,8 +29412,8 @@ ${this.stack.split(`
|
|
|
30082
29412
|
onDecision = /* @__PURE__ */ dual(2, (self, f) => makeWithState(self.initial, (now2, input, state) => flatMap7(self.step(now2, input, state), ([state2, out, decision]) => as2(f(out, decision), [state2, out, decision]))));
|
|
30083
29413
|
provideContext3 = /* @__PURE__ */ dual(2, (self, context8) => makeWithState(self.initial, (now2, input, state) => provideContext(self.step(now2, input, state), context8)));
|
|
30084
29414
|
provideService2 = /* @__PURE__ */ dual(3, (self, tag4, service3) => makeWithState(self.initial, (now2, input, state) => contextWithEffect((env2) => provideContext(self.step(now2, input, state), add4(env2, tag4, service3)))));
|
|
30085
|
-
reduce11 = /* @__PURE__ */ dual(3, (self, zero2, f) => reduceEffect2(self, zero2, (
|
|
30086
|
-
reduceEffect2 = /* @__PURE__ */ dual(3, (self, zero2, f) => makeWithState([self.initial, zero2], (now2, input, [s,
|
|
29415
|
+
reduce11 = /* @__PURE__ */ dual(3, (self, zero2, f) => reduceEffect2(self, zero2, (z5, out) => sync(() => f(z5, out))));
|
|
29416
|
+
reduceEffect2 = /* @__PURE__ */ dual(3, (self, zero2, f) => makeWithState([self.initial, zero2], (now2, input, [s, z5]) => flatMap7(self.step(now2, input, s), ([s2, out, decision]) => isDone4(decision) ? succeed([[s2, z5], z5, decision]) : map10(f(z5, out), (z22) => [[s2, z22], z5, decision]))));
|
|
30087
29417
|
resetAfter = /* @__PURE__ */ dual(2, (self, durationInput) => {
|
|
30088
29418
|
const duration4 = decode(durationInput);
|
|
30089
29419
|
return pipe(self, intersect5(elapsed), resetWhen(([, time2]) => greaterThanOrEqualTo(time2, duration4)), map17((out) => out[0]));
|
|
@@ -31893,7 +31223,7 @@ ${this.stack.split(`
|
|
|
31893
31223
|
return match9(exit4, {
|
|
31894
31224
|
onFailure: (cause3) => onDecision3(done10(failCause3(cause3))),
|
|
31895
31225
|
onSuccess: match({
|
|
31896
|
-
onLeft: (
|
|
31226
|
+
onLeft: (z5) => onDecision3(done10(succeed3(z5))),
|
|
31897
31227
|
onRight: (elem) => succeed10(flatMap13(write(elem), () => flatMap13(fromEffect5(forkIn2(interruptible4(pull), scope5)), (leftFiber) => go2(both2(leftFiber, fiber)))))
|
|
31898
31228
|
})
|
|
31899
31229
|
});
|
|
@@ -32359,9 +31689,9 @@ ${this.stack.split(`
|
|
|
32359
31689
|
upstreamDone.ref = true;
|
|
32360
31690
|
}), succeedNow(done10))
|
|
32361
31691
|
});
|
|
32362
|
-
const transducer = pipe(sink, toChannel, collectElements, flatMap13(([leftover2,
|
|
31692
|
+
const transducer = pipe(sink, toChannel, collectElements, flatMap13(([leftover2, z5]) => pipe(succeed12([upstreamDone.ref, concatAndGet(leftover2)]), flatMap13(([done10, newLeftovers]) => {
|
|
32363
31693
|
const nextChannel = done10 && isEmpty(newLeftovers) ? void_7 : transducer;
|
|
32364
|
-
return pipe(write(of2(
|
|
31694
|
+
return pipe(write(of2(z5)), flatMap13(() => nextChannel));
|
|
32365
31695
|
}))));
|
|
32366
31696
|
return pipe(toChannel2(self), pipeTo(upstreamMarker), pipeTo(buffer3), pipeToOrFail(transducer));
|
|
32367
31697
|
});
|
|
@@ -33515,7 +32845,7 @@ ${this.stack.split(`
|
|
|
33515
32845
|
FileDisplay = {
|
|
33516
32846
|
layer: (filePath) => Layer_exports.effect(Display, Effect_exports.gen(function* () {
|
|
33517
32847
|
const fs = yield* FileSystem_exports.FileSystem;
|
|
33518
|
-
yield* fs.makeDirectory(
|
|
32848
|
+
yield* fs.makeDirectory(dirname8(filePath), { recursive: true }).pipe(Effect_exports.orDie);
|
|
33519
32849
|
const delimiter = `
|
|
33520
32850
|
--- Run started: ${(/* @__PURE__ */ new Date()).toISOString()} ---
|
|
33521
32851
|
`;
|
|
@@ -46049,17 +45379,17 @@ ${len.toString(16)}\r
|
|
|
46049
45379
|
lastCall() {
|
|
46050
45380
|
return this.logs.at(-1);
|
|
46051
45381
|
}
|
|
46052
|
-
nthCall(
|
|
46053
|
-
if (typeof
|
|
45382
|
+
nthCall(number5) {
|
|
45383
|
+
if (typeof number5 !== "number") {
|
|
46054
45384
|
throw new InvalidArgumentError("nthCall must be called with a number");
|
|
46055
45385
|
}
|
|
46056
|
-
if (!Number.isInteger(
|
|
45386
|
+
if (!Number.isInteger(number5)) {
|
|
46057
45387
|
throw new InvalidArgumentError("nthCall must be called with an integer");
|
|
46058
45388
|
}
|
|
46059
|
-
if (Math.sign(
|
|
45389
|
+
if (Math.sign(number5) !== 1) {
|
|
46060
45390
|
throw new InvalidArgumentError("nthCall must be called with a positive value. use firstCall or lastCall instead");
|
|
46061
45391
|
}
|
|
46062
|
-
return this.logs.at(
|
|
45392
|
+
return this.logs.at(number5 - 1);
|
|
46063
45393
|
}
|
|
46064
45394
|
filterCalls(criteria, options) {
|
|
46065
45395
|
if (this.logs.length === 0) {
|
|
@@ -50354,24 +49684,24 @@ ${pendingInterceptorsFormatter.format(pending3)}`.trim());
|
|
|
50354
49684
|
}
|
|
50355
49685
|
toSortedArray() {
|
|
50356
49686
|
const size6 = this.headersMap.size;
|
|
50357
|
-
const
|
|
49687
|
+
const array5 = new Array(size6);
|
|
50358
49688
|
if (size6 <= 32) {
|
|
50359
49689
|
if (size6 === 0) {
|
|
50360
|
-
return
|
|
49690
|
+
return array5;
|
|
50361
49691
|
}
|
|
50362
49692
|
const iterator = this.headersMap[Symbol.iterator]();
|
|
50363
49693
|
const firstValue = iterator.next().value;
|
|
50364
|
-
|
|
49694
|
+
array5[0] = [firstValue[0], firstValue[1].value];
|
|
50365
49695
|
assert(firstValue[1].value !== null);
|
|
50366
49696
|
for (let i = 1, j = 0, right3 = 0, left3 = 0, pivot = 0, x, value;i < size6; ++i) {
|
|
50367
49697
|
value = iterator.next().value;
|
|
50368
|
-
x =
|
|
49698
|
+
x = array5[i] = [value[0], value[1].value];
|
|
50369
49699
|
assert(x[1] !== null);
|
|
50370
49700
|
left3 = 0;
|
|
50371
49701
|
right3 = i;
|
|
50372
49702
|
while (left3 < right3) {
|
|
50373
49703
|
pivot = left3 + (right3 - left3 >> 1);
|
|
50374
|
-
if (
|
|
49704
|
+
if (array5[pivot][0] <= x[0]) {
|
|
50375
49705
|
left3 = pivot + 1;
|
|
50376
49706
|
} else {
|
|
50377
49707
|
right3 = pivot;
|
|
@@ -50380,22 +49710,22 @@ ${pendingInterceptorsFormatter.format(pending3)}`.trim());
|
|
|
50380
49710
|
if (i !== pivot) {
|
|
50381
49711
|
j = i;
|
|
50382
49712
|
while (j > left3) {
|
|
50383
|
-
|
|
49713
|
+
array5[j] = array5[--j];
|
|
50384
49714
|
}
|
|
50385
|
-
|
|
49715
|
+
array5[left3] = x;
|
|
50386
49716
|
}
|
|
50387
49717
|
}
|
|
50388
49718
|
if (!iterator.next().done) {
|
|
50389
49719
|
throw new TypeError("Unreachable");
|
|
50390
49720
|
}
|
|
50391
|
-
return
|
|
49721
|
+
return array5;
|
|
50392
49722
|
} else {
|
|
50393
49723
|
let i = 0;
|
|
50394
49724
|
for (const { 0: name, 1: { value } } of this.headersMap) {
|
|
50395
|
-
|
|
49725
|
+
array5[i++] = [name, value];
|
|
50396
49726
|
assert(value !== null);
|
|
50397
49727
|
}
|
|
50398
|
-
return
|
|
49728
|
+
return array5.sort(compareHeaderName);
|
|
50399
49729
|
}
|
|
50400
49730
|
}
|
|
50401
49731
|
};
|
|
@@ -55584,14 +54914,14 @@ ${pendingInterceptorsFormatter.format(pending3)}`.trim());
|
|
|
55584
54914
|
data = new Uint8Array(ArrayBuffer.isView(chunk) ? new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength) : chunk.slice());
|
|
55585
54915
|
opcode = opcodes.BINARY;
|
|
55586
54916
|
} else {
|
|
55587
|
-
let
|
|
54917
|
+
let string5;
|
|
55588
54918
|
try {
|
|
55589
|
-
|
|
54919
|
+
string5 = webidl.converters.DOMString(chunk);
|
|
55590
54920
|
} catch (e) {
|
|
55591
54921
|
promise3.reject(e);
|
|
55592
54922
|
return promise3.promise;
|
|
55593
54923
|
}
|
|
55594
|
-
data = new TextEncoder().encode(
|
|
54924
|
+
data = new TextEncoder().encode(string5);
|
|
55595
54925
|
opcode = opcodes.TEXT;
|
|
55596
54926
|
}
|
|
55597
54927
|
if (!this.#handler.closeState.has(sentCloseFrameState.SENT) && !this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
@@ -55884,41 +55214,41 @@ ${pendingInterceptorsFormatter.format(pending3)}`.trim());
|
|
|
55884
55214
|
if (colonPosition === 0) {
|
|
55885
55215
|
return;
|
|
55886
55216
|
}
|
|
55887
|
-
let
|
|
55217
|
+
let field = "";
|
|
55888
55218
|
let value = "";
|
|
55889
55219
|
if (colonPosition !== -1) {
|
|
55890
|
-
|
|
55220
|
+
field = line.subarray(0, colonPosition).toString("utf8");
|
|
55891
55221
|
let valueStart = colonPosition + 1;
|
|
55892
55222
|
if (line[valueStart] === SPACE) {
|
|
55893
55223
|
++valueStart;
|
|
55894
55224
|
}
|
|
55895
55225
|
value = line.subarray(valueStart).toString("utf8");
|
|
55896
55226
|
} else {
|
|
55897
|
-
|
|
55227
|
+
field = line.toString("utf8");
|
|
55898
55228
|
value = "";
|
|
55899
55229
|
}
|
|
55900
|
-
switch (
|
|
55230
|
+
switch (field) {
|
|
55901
55231
|
case "data":
|
|
55902
|
-
if (event[
|
|
55903
|
-
event[
|
|
55232
|
+
if (event[field] === undefined) {
|
|
55233
|
+
event[field] = value;
|
|
55904
55234
|
} else {
|
|
55905
|
-
event[
|
|
55235
|
+
event[field] += `
|
|
55906
55236
|
${value}`;
|
|
55907
55237
|
}
|
|
55908
55238
|
break;
|
|
55909
55239
|
case "retry":
|
|
55910
55240
|
if (isASCIINumber(value)) {
|
|
55911
|
-
event[
|
|
55241
|
+
event[field] = value;
|
|
55912
55242
|
}
|
|
55913
55243
|
break;
|
|
55914
55244
|
case "id":
|
|
55915
55245
|
if (isValidLastEventId(value)) {
|
|
55916
|
-
event[
|
|
55246
|
+
event[field] = value;
|
|
55917
55247
|
}
|
|
55918
55248
|
break;
|
|
55919
55249
|
case "event":
|
|
55920
55250
|
if (value.length > 0) {
|
|
55921
|
-
event[
|
|
55251
|
+
event[field] = value;
|
|
55922
55252
|
}
|
|
55923
55253
|
break;
|
|
55924
55254
|
}
|
|
@@ -56990,8 +56320,8 @@ var init_chunk_62WN33RK = __esm(() => {
|
|
|
56990
56320
|
|
|
56991
56321
|
// ../../node_modules/.bun/@ai-hero+sandcastle@0.12.0/node_modules/@ai-hero/sandcastle/dist/index.js
|
|
56992
56322
|
import { createRequire as createRequire9 } from "module";
|
|
56993
|
-
import { mkdirSync as
|
|
56994
|
-
import path, { join as
|
|
56323
|
+
import { mkdirSync as mkdirSync8, appendFileSync } from "fs";
|
|
56324
|
+
import path, { join as join19, posix as posix4, dirname as dirname10, relative as relative3 } from "path";
|
|
56995
56325
|
import { styleText as styleText2 } from "util";
|
|
56996
56326
|
import * as clack2 from "@clack/prompts";
|
|
56997
56327
|
import { readdir as readdir2, access as access3, readFile as readFile4, mkdir as mkdir3, writeFile as writeFile3, rm as rm3 } from "fs/promises";
|
|
@@ -57060,7 +56390,7 @@ async function run6(options) {
|
|
|
57060
56390
|
const targetBranch = effectiveBranchType === "merge-to-head" ? currentHostBranch : undefined;
|
|
57061
56391
|
const resolvedLogging = options.logging ?? {
|
|
57062
56392
|
type: "file",
|
|
57063
|
-
path:
|
|
56393
|
+
path: join19(hostRepoDir, ".sandcastle", "logs", buildLogFilename(resolvedBranch, targetBranch, options.name))
|
|
57064
56394
|
};
|
|
57065
56395
|
const displayLayer = resolvedLogging.type === "file" ? (() => {
|
|
57066
56396
|
printFileDisplayStartup({
|
|
@@ -57694,7 +57024,7 @@ ${errorDetail}`
|
|
|
57694
57024
|
}
|
|
57695
57025
|
return vars;
|
|
57696
57026
|
}), resolveEnv = (repoDir) => Effect_exports.gen(function* () {
|
|
57697
|
-
const sandcastleEnv = yield* parseEnvFile2(
|
|
57027
|
+
const sandcastleEnv = yield* parseEnvFile2(join19(repoDir, ".sandcastle", ".env"));
|
|
57698
57028
|
const result = {};
|
|
57699
57029
|
for (const key of Object.keys(sandcastleEnv)) {
|
|
57700
57030
|
const value = sandcastleEnv[key] || process.env[key];
|
|
@@ -57891,7 +57221,7 @@ Emit only a corrected <${error.tag}> block. Do not change files or run commands.
|
|
|
57891
57221
|
if (logging.type === "file") {
|
|
57892
57222
|
const logPath = logging.path;
|
|
57893
57223
|
try {
|
|
57894
|
-
|
|
57224
|
+
mkdirSync8(path.dirname(logPath), { recursive: true });
|
|
57895
57225
|
} catch {}
|
|
57896
57226
|
return (line) => {
|
|
57897
57227
|
try {
|
|
@@ -57966,7 +57296,7 @@ Emit only a corrected <${error.tag}> block. Do not change files or run commands.
|
|
|
57966
57296
|
}).pipe(Effect_exports.provide(silentDisplayLayer)));
|
|
57967
57297
|
const resolvedLogging = runOptions.logging ?? {
|
|
57968
57298
|
type: "file",
|
|
57969
|
-
path:
|
|
57299
|
+
path: join19(hostRepoDir, ".sandcastle", "logs", buildLogFilename(branch, undefined, runOptions.name))
|
|
57970
57300
|
};
|
|
57971
57301
|
const runDisplayLayer = resolvedLogging.type === "file" ? (() => {
|
|
57972
57302
|
printFileDisplayStartup({
|
|
@@ -58192,7 +57522,7 @@ Emit only a corrected <${error.tag}> block. Do not change files or run commands.
|
|
|
58192
57522
|
hostRepoDir: hostRepoDir2,
|
|
58193
57523
|
env,
|
|
58194
57524
|
worktreeOrRepoPath: worktreePath2
|
|
58195
|
-
}) : resolveGitMounts(
|
|
57525
|
+
}) : resolveGitMounts(join19(hostRepoDir2, ".git")).pipe(Effect_exports.provide(NodeFileSystem_exports2.layer), Effect_exports.catchAll(() => Effect_exports.succeed([])), Effect_exports.flatMap((gitMounts) => patchGitMountsForWindows(gitMounts, worktreePath2, SANDBOX_REPO_DIR)), Effect_exports.flatMap((gitMounts) => startSandbox({
|
|
58196
57526
|
provider,
|
|
58197
57527
|
hostRepoDir: hostRepoDir2,
|
|
58198
57528
|
env,
|
|
@@ -58277,11 +57607,11 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58277
57607
|
const normalized = isRoot ? cwd : cwd.replace(/[\\/]+$/, "");
|
|
58278
57608
|
return normalized.replace(/^([A-Za-z]):/, "$1").replace(/[\\/]/g, "-");
|
|
58279
57609
|
}, claudeHostSessionPath = (cwd, id3, projectsDir) => {
|
|
58280
|
-
const base = projectsDir ??
|
|
58281
|
-
return
|
|
57610
|
+
const base = projectsDir ?? join19(process.env.HOME ?? "~", ".claude", "projects");
|
|
57611
|
+
return join19(base, encodeProjectPath(cwd), `${id3}.jsonl`);
|
|
58282
57612
|
}, claudeSandboxSessionPath = (cwd, id3, projectsDir) => posix4.join(projectsDir, encodeProjectPath(cwd), `${id3}.jsonl`), claudeSubagentsDirInSandbox = (cwd, id3, projectsDir) => posix4.join(projectsDir, encodeProjectPath(cwd), id3, "subagents"), claudeSubagentsDirOnHost = (cwd, id3, projectsDir) => {
|
|
58283
|
-
const base = projectsDir ??
|
|
58284
|
-
return
|
|
57613
|
+
const base = projectsDir ?? join19(process.env.HOME ?? "~", ".claude", "projects");
|
|
57614
|
+
return join19(base, encodeProjectPath(cwd), id3, "subagents");
|
|
58285
57615
|
}, listClaudeSubagentSessionsInSandbox = async (cwd, id3, handle, sandboxProjectsDir) => {
|
|
58286
57616
|
const dir = claudeSubagentsDirInSandbox(cwd, id3, sandboxProjectsDir);
|
|
58287
57617
|
const result = await handle.exec(`find ${JSON.stringify(dir)} -type f -name ${JSON.stringify("agent-*.jsonl")} 2>/dev/null`);
|
|
@@ -58293,7 +57623,7 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58293
57623
|
return stdout.split(`
|
|
58294
57624
|
`).filter((line) => line !== "");
|
|
58295
57625
|
}, findClaudeSessionOnHost = async (id3, projectsDir) => {
|
|
58296
|
-
const root = projectsDir ??
|
|
57626
|
+
const root = projectsDir ?? join19(process.env.HOME ?? "~", ".claude", "projects");
|
|
58297
57627
|
let entries;
|
|
58298
57628
|
try {
|
|
58299
57629
|
entries = await readdir2(root, { withFileTypes: true });
|
|
@@ -58303,7 +57633,7 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58303
57633
|
for (const entry of entries) {
|
|
58304
57634
|
if (!entry.isDirectory())
|
|
58305
57635
|
continue;
|
|
58306
|
-
const candidate =
|
|
57636
|
+
const candidate = join19(root, entry.name, `${id3}.jsonl`);
|
|
58307
57637
|
if (await pathExists(candidate)) {
|
|
58308
57638
|
return { path: candidate, searchedRoot: root };
|
|
58309
57639
|
}
|
|
@@ -58339,7 +57669,7 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58339
57669
|
return;
|
|
58340
57670
|
}
|
|
58341
57671
|
for (const entry of entries) {
|
|
58342
|
-
const child =
|
|
57672
|
+
const child = join19(dir, entry.name);
|
|
58343
57673
|
if (entry.isFile() && isCodexSessionFilename(entry.name, id3)) {
|
|
58344
57674
|
return child;
|
|
58345
57675
|
}
|
|
@@ -58353,11 +57683,11 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58353
57683
|
};
|
|
58354
57684
|
return visit(rootDir);
|
|
58355
57685
|
}, findCodexSessionOnHost = async (id3, sessionsDir) => {
|
|
58356
|
-
const root = sessionsDir ??
|
|
57686
|
+
const root = sessionsDir ?? join19(process.env.HOME ?? "~", ".codex", "sessions");
|
|
58357
57687
|
const path2 = await findCodexSessionPath(root, id3);
|
|
58358
57688
|
return { path: path2, searchedRoot: root };
|
|
58359
57689
|
}, locateCodexHostSession = async (id3, sessionsDir) => {
|
|
58360
|
-
const root = sessionsDir ??
|
|
57690
|
+
const root = sessionsDir ?? join19(process.env.HOME ?? "~", ".codex", "sessions");
|
|
58361
57691
|
const path2 = await findCodexSessionPath(root, id3);
|
|
58362
57692
|
if (!path2)
|
|
58363
57693
|
throw new Error(`session ${id3} not found in ${root}`);
|
|
@@ -58433,7 +57763,7 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58433
57763
|
} catch {}
|
|
58434
57764
|
return [];
|
|
58435
57765
|
}, CURSOR_PRINT_PROMPT_MAX_BYTES, readSandboxFile = async (handle, sandboxPath, tag) => {
|
|
58436
|
-
const tmpPath =
|
|
57766
|
+
const tmpPath = join19(tmpdir4(), `sandcastle-${tag}-${Date.now()}-${Math.random().toString(36).slice(2)}.jsonl`);
|
|
58437
57767
|
await handle.copyFileOut(sandboxPath, tmpPath);
|
|
58438
57768
|
try {
|
|
58439
57769
|
return await readFile4(tmpPath, "utf-8");
|
|
@@ -58441,7 +57771,7 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58441
57771
|
await rm3(tmpPath, { force: true }).catch(() => {});
|
|
58442
57772
|
}
|
|
58443
57773
|
}, writeSandboxFile = async (handle, sandboxPath, content, tag) => {
|
|
58444
|
-
const tmpPath =
|
|
57774
|
+
const tmpPath = join19(tmpdir4(), `sandcastle-${tag}-${Date.now()}-${Math.random().toString(36).slice(2)}.jsonl`);
|
|
58445
57775
|
await writeFile3(tmpPath, content);
|
|
58446
57776
|
try {
|
|
58447
57777
|
await handle.exec(`mkdir -p ${JSON.stringify(posix4.dirname(sandboxPath))}`);
|
|
@@ -58459,7 +57789,7 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58459
57789
|
}) => {
|
|
58460
57790
|
const jsonl = await readSandboxFile(handle, sourcePath, tag);
|
|
58461
57791
|
const rewritten = transferClaudeSession(jsonl, fromCwd, toCwd);
|
|
58462
|
-
await mkdir3(
|
|
57792
|
+
await mkdir3(dirname10(destPath), { recursive: true });
|
|
58463
57793
|
await writeFile3(destPath, rewritten);
|
|
58464
57794
|
}, makeClaudeSessionStorage = (options) => {
|
|
58465
57795
|
const hostProjectsDir = options?.sessionStorage?.hostProjectsDir;
|
|
@@ -58491,7 +57821,7 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58491
57821
|
sourcePath: sandboxSubagentPath,
|
|
58492
57822
|
fromCwd: sandboxCwd,
|
|
58493
57823
|
toCwd: hostCwd,
|
|
58494
|
-
destPath:
|
|
57824
|
+
destPath: join19(hostSubagentsDir, posix4.basename(sandboxSubagentPath)),
|
|
58495
57825
|
tag: "claude-sub"
|
|
58496
57826
|
});
|
|
58497
57827
|
} catch (err) {
|
|
@@ -58528,9 +57858,9 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58528
57858
|
const located = await locateCodexSandboxSession(sessionId, handle, sandboxSessionsDir);
|
|
58529
57859
|
const jsonl = await readSandboxFile(handle, located.path, "codex-cap");
|
|
58530
57860
|
const rewritten = transferCodexSession(jsonl, sandboxCwd, hostCwd);
|
|
58531
|
-
const root = hostSessionsDir ??
|
|
58532
|
-
const target =
|
|
58533
|
-
await mkdir3(
|
|
57861
|
+
const root = hostSessionsDir ?? join19(process.env.HOME ?? "~", ".codex", "sessions");
|
|
57862
|
+
const target = join19(root, located.relativePath);
|
|
57863
|
+
await mkdir3(dirname10(target), { recursive: true });
|
|
58534
57864
|
await writeFile3(target, rewritten);
|
|
58535
57865
|
capturedPaths.set(sessionId, target);
|
|
58536
57866
|
},
|
|
@@ -58649,90 +57979,763 @@ Worktree preserved at ${worktreePath}`);
|
|
|
58649
57979
|
} else if (dangerouslySkipPermissions) {
|
|
58650
57980
|
args2.push("--dangerously-skip-permissions");
|
|
58651
57981
|
}
|
|
58652
|
-
args2.push("--model", model);
|
|
58653
|
-
if (options?.effort)
|
|
58654
|
-
args2.push("--effort", options.effort);
|
|
58655
|
-
if (prompt)
|
|
58656
|
-
args2.push(prompt);
|
|
58657
|
-
return args2;
|
|
58658
|
-
},
|
|
58659
|
-
parseStreamLine(line) {
|
|
58660
|
-
return parseStreamJsonLine(line);
|
|
58661
|
-
},
|
|
58662
|
-
parseSessionUsage(content) {
|
|
58663
|
-
const lines2 = content.split(`
|
|
57982
|
+
args2.push("--model", model);
|
|
57983
|
+
if (options?.effort)
|
|
57984
|
+
args2.push("--effort", options.effort);
|
|
57985
|
+
if (prompt)
|
|
57986
|
+
args2.push(prompt);
|
|
57987
|
+
return args2;
|
|
57988
|
+
},
|
|
57989
|
+
parseStreamLine(line) {
|
|
57990
|
+
return parseStreamJsonLine(line);
|
|
57991
|
+
},
|
|
57992
|
+
parseSessionUsage(content) {
|
|
57993
|
+
const lines2 = content.split(`
|
|
57994
|
+
`);
|
|
57995
|
+
for (let i = lines2.length - 1;i >= 0; i--) {
|
|
57996
|
+
const line = lines2[i];
|
|
57997
|
+
if (!line.startsWith("{"))
|
|
57998
|
+
continue;
|
|
57999
|
+
try {
|
|
58000
|
+
const obj = JSON.parse(line);
|
|
58001
|
+
if (obj.type === "assistant" && obj.message?.usage) {
|
|
58002
|
+
const u = obj.message.usage;
|
|
58003
|
+
if (typeof u.input_tokens === "number" && typeof u.cache_creation_input_tokens === "number" && typeof u.cache_read_input_tokens === "number" && typeof u.output_tokens === "number") {
|
|
58004
|
+
return {
|
|
58005
|
+
inputTokens: u.input_tokens,
|
|
58006
|
+
cacheCreationInputTokens: u.cache_creation_input_tokens,
|
|
58007
|
+
cacheReadInputTokens: u.cache_read_input_tokens,
|
|
58008
|
+
outputTokens: u.output_tokens
|
|
58009
|
+
};
|
|
58010
|
+
}
|
|
58011
|
+
}
|
|
58012
|
+
} catch {}
|
|
58013
|
+
}
|
|
58014
|
+
return;
|
|
58015
|
+
}
|
|
58016
|
+
});
|
|
58017
|
+
var init_dist = __esm(() => {
|
|
58018
|
+
init_chunk_DJRHWPEH();
|
|
58019
|
+
init_chunk_VOG34SRF();
|
|
58020
|
+
init_chunk_BIWNFKGV();
|
|
58021
|
+
init_chunk_62WN33RK();
|
|
58022
|
+
init_chunk_NGBM7T3E();
|
|
58023
|
+
init_chunk_NGBM7T3E();
|
|
58024
|
+
createRequire9(import.meta.url);
|
|
58025
|
+
AgentStreamEmitter = class extends Context_exports.Tag("AgentStreamEmitter")() {
|
|
58026
|
+
};
|
|
58027
|
+
MARKED_SHELL_BLOCK_PATTERN = new RegExp(`!${SHELL_BLOCK_MARKER}\`([^\`]+)\``, "g");
|
|
58028
|
+
SENTENCE_BOUNDARY_RE = /[.!?] $/;
|
|
58029
|
+
DEFAULT_IDLE_TIMEOUT_SECONDS = 10 * 60;
|
|
58030
|
+
SHELL_BLOCK_PATTERN = /!`([^`]+)`/g;
|
|
58031
|
+
BUILT_IN_PROMPT_ARG_KEYS = [
|
|
58032
|
+
"SOURCE_BRANCH",
|
|
58033
|
+
"TARGET_BRANCH"
|
|
58034
|
+
];
|
|
58035
|
+
PLACEHOLDER_PATTERN = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
|
|
58036
|
+
StructuredOutputError = class extends Error {
|
|
58037
|
+
tag;
|
|
58038
|
+
rawMatched;
|
|
58039
|
+
cause;
|
|
58040
|
+
commits;
|
|
58041
|
+
branch;
|
|
58042
|
+
preservedWorktreePath;
|
|
58043
|
+
sessionId;
|
|
58044
|
+
sessionFilePath;
|
|
58045
|
+
constructor(message, options) {
|
|
58046
|
+
super(message);
|
|
58047
|
+
this.name = "StructuredOutputError";
|
|
58048
|
+
this.tag = options.tag;
|
|
58049
|
+
this.rawMatched = options.rawMatched;
|
|
58050
|
+
this.cause = options.cause;
|
|
58051
|
+
this.commits = options.commits;
|
|
58052
|
+
this.branch = options.branch;
|
|
58053
|
+
this.preservedWorktreePath = options.preservedWorktreePath;
|
|
58054
|
+
this.sessionId = options.sessionId;
|
|
58055
|
+
this.sessionFilePath = options.sessionFilePath;
|
|
58056
|
+
}
|
|
58057
|
+
};
|
|
58058
|
+
TOOL_ARG_FIELDS = {
|
|
58059
|
+
Bash: "command",
|
|
58060
|
+
WebSearch: "query",
|
|
58061
|
+
WebFetch: "url",
|
|
58062
|
+
Agent: "description"
|
|
58063
|
+
};
|
|
58064
|
+
CURSOR_PRINT_PROMPT_MAX_BYTES = 120 * 1024;
|
|
58065
|
+
COPILOT_PRINT_PROMPT_MAX_BYTES = 120 * 1024;
|
|
58066
|
+
});
|
|
58067
|
+
|
|
58068
|
+
// src/services/settings.ts
|
|
58069
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync7 } from "fs";
|
|
58070
|
+
import { dirname as dirname11 } from "path";
|
|
58071
|
+
import * as z5 from "zod";
|
|
58072
|
+
import { eq as eq11 } from "drizzle-orm";
|
|
58073
|
+
function hostDefaults(logicalCpus) {
|
|
58074
|
+
return { ...DEFAULTS, burnConcurrency: resolveDefaultBurnConcurrency(logicalCpus) };
|
|
58075
|
+
}
|
|
58076
|
+
function readRawConfig(configFile) {
|
|
58077
|
+
if (!existsSync16(configFile))
|
|
58078
|
+
return {};
|
|
58079
|
+
try {
|
|
58080
|
+
const parsed = JSON.parse(readFileSync11(configFile, "utf8"));
|
|
58081
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
58082
|
+
return {};
|
|
58083
|
+
return foldLegacyModelConfig(migrateCollapsedModelSteps(parsed));
|
|
58084
|
+
} catch {
|
|
58085
|
+
return {};
|
|
58086
|
+
}
|
|
58087
|
+
}
|
|
58088
|
+
function rawStepModels(fileRaw) {
|
|
58089
|
+
const raw = fileRaw.stepModels;
|
|
58090
|
+
return typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : {};
|
|
58091
|
+
}
|
|
58092
|
+
function stepModelFields(fileRaw) {
|
|
58093
|
+
const set7 = rawStepModels(fileRaw);
|
|
58094
|
+
return MODEL_STEPS.map((step4) => {
|
|
58095
|
+
const base = { key: `stepModels.${step4}`, restartRequired: false, scope: "global" };
|
|
58096
|
+
const v = set7[step4];
|
|
58097
|
+
if (typeof v === "string" && v !== "") {
|
|
58098
|
+
return { ...base, value: v, source: "file", editable: true };
|
|
58099
|
+
}
|
|
58100
|
+
return { ...base, value: DEFAULTS.stepModels[step4] ?? null, source: "default", editable: true };
|
|
58101
|
+
});
|
|
58102
|
+
}
|
|
58103
|
+
function projectOverrides(ctx, projectId) {
|
|
58104
|
+
const row = ctx.db.select({
|
|
58105
|
+
model: projects.model,
|
|
58106
|
+
sandbox: projects.sandbox,
|
|
58107
|
+
sandboxImage: projects.sandboxImage,
|
|
58108
|
+
sessionBranch: projects.sessionBranch,
|
|
58109
|
+
devCommand: projects.devCommand,
|
|
58110
|
+
setupCommand: projects.setupCommand,
|
|
58111
|
+
verifyCommands: projects.verifyCommands,
|
|
58112
|
+
knownFailures: projects.knownFailures,
|
|
58113
|
+
dbResetCommand: projects.dbResetCommand,
|
|
58114
|
+
driveSetupCommand: projects.driveSetupCommand,
|
|
58115
|
+
driveStopCommand: projects.driveStopCommand,
|
|
58116
|
+
driveInstructions: projects.driveInstructions,
|
|
58117
|
+
scenarioRunner: projects.scenarioRunner,
|
|
58118
|
+
docsCommitPrefix: projects.docsCommitPrefix
|
|
58119
|
+
}).from(projects).where(eq11(projects.id, projectId)).get();
|
|
58120
|
+
return {
|
|
58121
|
+
model: row?.model ?? null,
|
|
58122
|
+
sandbox: row?.sandbox ?? null,
|
|
58123
|
+
sandboxImage: row?.sandboxImage ?? null,
|
|
58124
|
+
sessionBranch: row?.sessionBranch ?? null,
|
|
58125
|
+
devCommand: row?.devCommand ?? null,
|
|
58126
|
+
setupCommand: row?.setupCommand ?? null,
|
|
58127
|
+
verifyCommands: row?.verifyCommands ?? null,
|
|
58128
|
+
knownFailures: row?.knownFailures ?? null,
|
|
58129
|
+
dbResetCommand: row?.dbResetCommand ?? null,
|
|
58130
|
+
driveSetupCommand: row?.driveSetupCommand ?? null,
|
|
58131
|
+
driveStopCommand: row?.driveStopCommand ?? null,
|
|
58132
|
+
driveInstructions: row?.driveInstructions ?? null,
|
|
58133
|
+
scenarioRunner: row?.scenarioRunner ?? null,
|
|
58134
|
+
docsCommitPrefix: row?.docsCommitPrefix ?? null
|
|
58135
|
+
};
|
|
58136
|
+
}
|
|
58137
|
+
function resolveField(desc5, layers) {
|
|
58138
|
+
const scoped7 = layers.overrides !== null;
|
|
58139
|
+
const scope5 = scoped7 && desc5.projectColumn ? "project" : "global";
|
|
58140
|
+
const base = { key: desc5.key, restartRequired: desc5.restartRequired, scope: scope5 };
|
|
58141
|
+
if (desc5.envVar) {
|
|
58142
|
+
const raw = layers.env[desc5.envVar];
|
|
58143
|
+
if (raw !== undefined && raw !== "") {
|
|
58144
|
+
return { ...base, value: desc5.parseEnv(raw), source: "env", editable: false };
|
|
58145
|
+
}
|
|
58146
|
+
}
|
|
58147
|
+
if (layers.overrides && desc5.projectColumn) {
|
|
58148
|
+
const ov = layers.overrides[desc5.projectColumn];
|
|
58149
|
+
if (ov !== null && ov !== "") {
|
|
58150
|
+
return { ...base, value: ov, source: "project", editable: true };
|
|
58151
|
+
}
|
|
58152
|
+
}
|
|
58153
|
+
if (desc5.configKey && Object.prototype.hasOwnProperty.call(layers.fileRaw, desc5.configKey)) {
|
|
58154
|
+
return { ...base, value: layers.fileRaw[desc5.configKey], source: "file", editable: true };
|
|
58155
|
+
}
|
|
58156
|
+
const value = desc5.configKey ? layers.defaults[desc5.configKey] ?? null : desc5.defaultValue ?? null;
|
|
58157
|
+
return { ...base, value, source: "default", editable: true };
|
|
58158
|
+
}
|
|
58159
|
+
function getSettings(ctx, projectId, io = {}) {
|
|
58160
|
+
const env = io.env ?? process.env;
|
|
58161
|
+
const fileRaw = readRawConfig(io.configFile ?? configPath());
|
|
58162
|
+
const overrides = projectId !== undefined ? projectOverrides(ctx, projectId) : null;
|
|
58163
|
+
const defaults = hostDefaults(io.logicalCpus ?? hostLogicalCpus());
|
|
58164
|
+
const visible = DESCRIPTORS.filter((d) => projectId !== undefined || d.configKey !== undefined);
|
|
58165
|
+
const fields = visible.map((d) => resolveField(d, { env, fileRaw, overrides, defaults }));
|
|
58166
|
+
return {
|
|
58167
|
+
projectId,
|
|
58168
|
+
fields: [...fields, ...stepModelFields(fileRaw)],
|
|
58169
|
+
discovery: discoverySnapshot(ctx)
|
|
58170
|
+
};
|
|
58171
|
+
}
|
|
58172
|
+
function updateSettings(ctx, input, io = {}) {
|
|
58173
|
+
const env = io.env ?? process.env;
|
|
58174
|
+
const configFile = io.configFile ?? configPath();
|
|
58175
|
+
if (input.key.startsWith("stepModels.")) {
|
|
58176
|
+
return updateStepModel(ctx, input, configFile, io);
|
|
58177
|
+
}
|
|
58178
|
+
const desc5 = DESCRIPTORS.find((d) => d.key === input.key);
|
|
58179
|
+
if (!desc5)
|
|
58180
|
+
throw new InvalidInputError(`unknown setting: ${input.key}`);
|
|
58181
|
+
if (desc5.envVar) {
|
|
58182
|
+
const raw = env[desc5.envVar];
|
|
58183
|
+
if (raw !== undefined && raw !== "") {
|
|
58184
|
+
throw new InvalidInputError(`${desc5.key} is set by environment variable ${desc5.envVar}; unset it to edit`);
|
|
58185
|
+
}
|
|
58186
|
+
}
|
|
58187
|
+
const toProject = input.projectId !== undefined && desc5.projectColumn !== undefined;
|
|
58188
|
+
if (input.value === null) {
|
|
58189
|
+
if (!toProject)
|
|
58190
|
+
return clearGlobal(ctx, desc5, input, configFile, io);
|
|
58191
|
+
const project3 = requireProjectById(ctx, input.projectId);
|
|
58192
|
+
ctx.db.update(projects).set({ [desc5.projectColumn]: null }).where(eq11(projects.id, project3.id)).run();
|
|
58193
|
+
recordHuman(ctx, project3.id, desc5.key, null);
|
|
58194
|
+
emitProject(ctx, project3.id, {
|
|
58195
|
+
type: "settings.updated",
|
|
58196
|
+
message: `${desc5.key} override cleared`,
|
|
58197
|
+
data: { key: desc5.key, scope: "project", value: null }
|
|
58198
|
+
});
|
|
58199
|
+
return field(getSettings(ctx, input.projectId, io), desc5.key);
|
|
58200
|
+
}
|
|
58201
|
+
const parsed = desc5.valueSchema.safeParse(input.value);
|
|
58202
|
+
if (!parsed.success) {
|
|
58203
|
+
throw new InvalidInputError(`invalid value for ${desc5.key}: ${parsed.error.issues[0]?.message}`);
|
|
58204
|
+
}
|
|
58205
|
+
const value = parsed.data;
|
|
58206
|
+
if (toProject) {
|
|
58207
|
+
const project3 = requireProjectById(ctx, input.projectId);
|
|
58208
|
+
ctx.db.update(projects).set({ [desc5.projectColumn]: String(value) }).where(eq11(projects.id, project3.id)).run();
|
|
58209
|
+
recordHuman(ctx, project3.id, desc5.key, String(value));
|
|
58210
|
+
emitProject(ctx, project3.id, {
|
|
58211
|
+
type: "settings.updated",
|
|
58212
|
+
message: `${desc5.key} override set to ${String(value)}`,
|
|
58213
|
+
data: { key: desc5.key, scope: "project", value }
|
|
58214
|
+
});
|
|
58215
|
+
return field(getSettings(ctx, input.projectId, io), desc5.key);
|
|
58216
|
+
}
|
|
58217
|
+
if (!desc5.configKey) {
|
|
58218
|
+
throw new InvalidInputError(`${desc5.key} is a per-project setting; provide a projectId`);
|
|
58219
|
+
}
|
|
58220
|
+
writeGlobal(configFile, desc5.configKey, value);
|
|
58221
|
+
ctx.config[desc5.configKey] = value;
|
|
58222
|
+
emitProject(ctx, GLOBAL_EVENT_KEY, {
|
|
58223
|
+
type: "settings.updated",
|
|
58224
|
+
message: `${desc5.key} set to ${describeValue(value)}`,
|
|
58225
|
+
data: { key: desc5.key, scope: "global", value }
|
|
58226
|
+
});
|
|
58227
|
+
return field(getSettings(ctx, input.projectId, io), desc5.key);
|
|
58228
|
+
}
|
|
58229
|
+
function clearGlobal(ctx, desc5, input, configFile, io) {
|
|
58230
|
+
if (!desc5.configKey || !GLOBAL_CLEARABLE_KEYS.has(desc5.key)) {
|
|
58231
|
+
throw new InvalidInputError(`${desc5.key} cannot be cleared`);
|
|
58232
|
+
}
|
|
58233
|
+
removeGlobal(configFile, desc5.configKey);
|
|
58234
|
+
delete ctx.config[desc5.configKey];
|
|
58235
|
+
emitProject(ctx, GLOBAL_EVENT_KEY, {
|
|
58236
|
+
type: "settings.updated",
|
|
58237
|
+
message: `${desc5.key} cleared`,
|
|
58238
|
+
data: { key: desc5.key, scope: "global", value: null }
|
|
58239
|
+
});
|
|
58240
|
+
return field(getSettings(ctx, input.projectId, io), desc5.key);
|
|
58241
|
+
}
|
|
58242
|
+
function describeValue(value) {
|
|
58243
|
+
return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
58244
|
+
}
|
|
58245
|
+
function writeGlobal(configFile, configKey, value) {
|
|
58246
|
+
const raw = readRawConfig(configFile);
|
|
58247
|
+
raw[configKey] = value;
|
|
58248
|
+
saveRawConfig(configFile, raw);
|
|
58249
|
+
}
|
|
58250
|
+
function removeGlobal(configFile, configKey) {
|
|
58251
|
+
const raw = readRawConfig(configFile);
|
|
58252
|
+
delete raw[configKey];
|
|
58253
|
+
saveRawConfig(configFile, raw);
|
|
58254
|
+
}
|
|
58255
|
+
function saveRawConfig(configFile, raw) {
|
|
58256
|
+
mkdirSync9(dirname11(configFile), { recursive: true });
|
|
58257
|
+
writeFileSync7(configFile, `${JSON.stringify(raw, null, 2)}
|
|
58258
|
+
`);
|
|
58259
|
+
}
|
|
58260
|
+
function updateStepModel(ctx, input, configFile, io) {
|
|
58261
|
+
const step4 = input.key.slice("stepModels.".length);
|
|
58262
|
+
if (!STEP_SET.has(step4))
|
|
58263
|
+
throw new InvalidInputError(`unknown model step: ${step4}`);
|
|
58264
|
+
const modelStep = step4;
|
|
58265
|
+
let value = null;
|
|
58266
|
+
if (input.value !== null) {
|
|
58267
|
+
const parsed = z5.string().min(1).safeParse(input.value);
|
|
58268
|
+
if (!parsed.success) {
|
|
58269
|
+
throw new InvalidInputError(`invalid value for ${input.key}: ${parsed.error.issues[0]?.message}`);
|
|
58270
|
+
}
|
|
58271
|
+
value = parsed.data;
|
|
58272
|
+
}
|
|
58273
|
+
writeStepModel(configFile, modelStep, value);
|
|
58274
|
+
const stepModels = ctx.config.stepModels ?? {};
|
|
58275
|
+
if (value === null)
|
|
58276
|
+
delete stepModels[modelStep];
|
|
58277
|
+
else
|
|
58278
|
+
stepModels[modelStep] = value;
|
|
58279
|
+
ctx.config.stepModels = stepModels;
|
|
58280
|
+
emitProject(ctx, GLOBAL_EVENT_KEY, {
|
|
58281
|
+
type: "settings.updated",
|
|
58282
|
+
message: value === null ? `${input.key} override cleared` : `${input.key} set to ${value}`,
|
|
58283
|
+
data: { key: input.key, scope: "global", value }
|
|
58284
|
+
});
|
|
58285
|
+
return field(getSettings(ctx, input.projectId, io), input.key);
|
|
58286
|
+
}
|
|
58287
|
+
function writeStepModel(configFile, step4, value) {
|
|
58288
|
+
const raw = readRawConfig(configFile);
|
|
58289
|
+
const stepModels = { ...rawStepModels(raw) };
|
|
58290
|
+
if (value === null)
|
|
58291
|
+
delete stepModels[step4];
|
|
58292
|
+
else
|
|
58293
|
+
stepModels[step4] = value;
|
|
58294
|
+
raw.stepModels = stepModels;
|
|
58295
|
+
saveRawConfig(configFile, raw);
|
|
58296
|
+
}
|
|
58297
|
+
function warnLegacyGlobalImage(ctx) {
|
|
58298
|
+
const legacy = legacyGlobalImage(ctx.config.sandboxImage, allProjects(ctx).map((p) => p.id));
|
|
58299
|
+
if (legacy === null)
|
|
58300
|
+
return null;
|
|
58301
|
+
const message = legacyGlobalImageReason(legacy);
|
|
58302
|
+
console.warn(`runcastle: ${message}`);
|
|
58303
|
+
emitProject(ctx, GLOBAL_EVENT_KEY, {
|
|
58304
|
+
type: "settings.legacyImage",
|
|
58305
|
+
message,
|
|
58306
|
+
data: { key: "sandboxImage", scope: "global", value: legacy }
|
|
58307
|
+
});
|
|
58308
|
+
return legacy;
|
|
58309
|
+
}
|
|
58310
|
+
function field(view, key) {
|
|
58311
|
+
const f = view.fields.find((x) => x.key === key);
|
|
58312
|
+
if (!f)
|
|
58313
|
+
throw new InvalidInputError(`setting ${key} not visible in this scope`);
|
|
58314
|
+
return f;
|
|
58315
|
+
}
|
|
58316
|
+
var GLOBAL_EVENT_KEY = "global", idEnv = (raw) => raw, DESCRIPTORS, DEFAULTS, GLOBAL_CLEARABLE_KEYS, STEP_SET;
|
|
58317
|
+
var init_settings = __esm(() => {
|
|
58318
|
+
init_src();
|
|
58319
|
+
init_config_load();
|
|
58320
|
+
init_paths();
|
|
58321
|
+
init_model_discovery();
|
|
58322
|
+
init_schema();
|
|
58323
|
+
init_errors();
|
|
58324
|
+
init_events();
|
|
58325
|
+
init_findings();
|
|
58326
|
+
init_repo();
|
|
58327
|
+
init_sandbox_image();
|
|
58328
|
+
DESCRIPTORS = [
|
|
58329
|
+
{
|
|
58330
|
+
key: "serverPort",
|
|
58331
|
+
configKey: "serverPort",
|
|
58332
|
+
envVar: "RUNCASTLE_SERVER_PORT",
|
|
58333
|
+
restartRequired: true,
|
|
58334
|
+
valueSchema: z5.number().int().positive(),
|
|
58335
|
+
parseEnv: (raw) => Number(raw)
|
|
58336
|
+
},
|
|
58337
|
+
{
|
|
58338
|
+
key: "model",
|
|
58339
|
+
configKey: "model",
|
|
58340
|
+
envVar: "RUNCASTLE_MODEL",
|
|
58341
|
+
projectColumn: "model",
|
|
58342
|
+
restartRequired: false,
|
|
58343
|
+
valueSchema: z5.string().min(1),
|
|
58344
|
+
parseEnv: idEnv
|
|
58345
|
+
},
|
|
58346
|
+
{
|
|
58347
|
+
key: "models",
|
|
58348
|
+
configKey: "models",
|
|
58349
|
+
restartRequired: false,
|
|
58350
|
+
valueSchema: z5.array(ModelEntry),
|
|
58351
|
+
parseEnv: idEnv
|
|
58352
|
+
},
|
|
58353
|
+
{
|
|
58354
|
+
key: "sandbox",
|
|
58355
|
+
configKey: "sandbox",
|
|
58356
|
+
envVar: "RUNCASTLE_SANDBOX",
|
|
58357
|
+
projectColumn: "sandbox",
|
|
58358
|
+
restartRequired: false,
|
|
58359
|
+
valueSchema: z5.enum(["docker", "podman", "noSandbox"]),
|
|
58360
|
+
parseEnv: idEnv
|
|
58361
|
+
},
|
|
58362
|
+
{
|
|
58363
|
+
key: "sandboxImage",
|
|
58364
|
+
configKey: "sandboxImage",
|
|
58365
|
+
envVar: "RUNCASTLE_SANDBOX_IMAGE",
|
|
58366
|
+
projectColumn: "sandboxImage",
|
|
58367
|
+
restartRequired: false,
|
|
58368
|
+
valueSchema: z5.string().min(1),
|
|
58369
|
+
parseEnv: idEnv
|
|
58370
|
+
},
|
|
58371
|
+
{
|
|
58372
|
+
key: "sessionMcp",
|
|
58373
|
+
configKey: "sessionMcp",
|
|
58374
|
+
envVar: "RUNCASTLE_SESSION_MCP",
|
|
58375
|
+
restartRequired: false,
|
|
58376
|
+
valueSchema: z5.enum(["inherit", "runcastleOnly"]),
|
|
58377
|
+
parseEnv: idEnv
|
|
58378
|
+
},
|
|
58379
|
+
{
|
|
58380
|
+
key: "burnConcurrency",
|
|
58381
|
+
configKey: "burnConcurrency",
|
|
58382
|
+
envVar: "RUNCASTLE_BURN_CONCURRENCY",
|
|
58383
|
+
restartRequired: false,
|
|
58384
|
+
valueSchema: z5.number().int().min(1).max(8),
|
|
58385
|
+
parseEnv: (raw) => Number(raw)
|
|
58386
|
+
},
|
|
58387
|
+
{
|
|
58388
|
+
key: "burnMaxIterations",
|
|
58389
|
+
configKey: "burnMaxIterations",
|
|
58390
|
+
envVar: "RUNCASTLE_BURN_MAX_ITERATIONS",
|
|
58391
|
+
restartRequired: false,
|
|
58392
|
+
valueSchema: z5.number().int().min(1).max(10),
|
|
58393
|
+
parseEnv: (raw) => Number(raw)
|
|
58394
|
+
},
|
|
58395
|
+
{
|
|
58396
|
+
key: "burnAttempts",
|
|
58397
|
+
configKey: "burnAttempts",
|
|
58398
|
+
envVar: "RUNCASTLE_BURN_ATTEMPTS",
|
|
58399
|
+
restartRequired: false,
|
|
58400
|
+
valueSchema: z5.number().int().min(1).max(5),
|
|
58401
|
+
parseEnv: (raw) => Number(raw)
|
|
58402
|
+
},
|
|
58403
|
+
{
|
|
58404
|
+
key: "burnConflictAttempts",
|
|
58405
|
+
configKey: "burnConflictAttempts",
|
|
58406
|
+
envVar: "RUNCASTLE_BURN_CONFLICT_ATTEMPTS",
|
|
58407
|
+
restartRequired: false,
|
|
58408
|
+
valueSchema: z5.number().int().min(0).max(3),
|
|
58409
|
+
parseEnv: (raw) => Number(raw)
|
|
58410
|
+
},
|
|
58411
|
+
{
|
|
58412
|
+
key: "burnCpus",
|
|
58413
|
+
configKey: "burnCpus",
|
|
58414
|
+
envVar: "RUNCASTLE_BURN_CPUS",
|
|
58415
|
+
restartRequired: false,
|
|
58416
|
+
valueSchema: z5.number().positive().max(256),
|
|
58417
|
+
parseEnv: (raw) => Number(raw)
|
|
58418
|
+
},
|
|
58419
|
+
{
|
|
58420
|
+
key: "setupCommand",
|
|
58421
|
+
configKey: "setupCommand",
|
|
58422
|
+
envVar: "RUNCASTLE_SETUP_COMMAND",
|
|
58423
|
+
projectColumn: "setupCommand",
|
|
58424
|
+
restartRequired: false,
|
|
58425
|
+
valueSchema: z5.string().min(1),
|
|
58426
|
+
parseEnv: idEnv
|
|
58427
|
+
},
|
|
58428
|
+
{
|
|
58429
|
+
key: "verifyCommands",
|
|
58430
|
+
configKey: "verifyCommands",
|
|
58431
|
+
envVar: "RUNCASTLE_VERIFY_COMMANDS",
|
|
58432
|
+
projectColumn: "verifyCommands",
|
|
58433
|
+
restartRequired: false,
|
|
58434
|
+
valueSchema: z5.string().min(1),
|
|
58435
|
+
parseEnv: idEnv
|
|
58436
|
+
},
|
|
58437
|
+
{
|
|
58438
|
+
key: "knownFailures",
|
|
58439
|
+
configKey: "knownFailures",
|
|
58440
|
+
envVar: "RUNCASTLE_KNOWN_FAILURES",
|
|
58441
|
+
projectColumn: "knownFailures",
|
|
58442
|
+
restartRequired: false,
|
|
58443
|
+
valueSchema: z5.string().min(1),
|
|
58444
|
+
parseEnv: idEnv
|
|
58445
|
+
},
|
|
58446
|
+
{
|
|
58447
|
+
key: "devCommand",
|
|
58448
|
+
projectColumn: "devCommand",
|
|
58449
|
+
restartRequired: false,
|
|
58450
|
+
valueSchema: z5.string().min(1),
|
|
58451
|
+
parseEnv: idEnv
|
|
58452
|
+
},
|
|
58453
|
+
{
|
|
58454
|
+
key: "sessionBranch",
|
|
58455
|
+
projectColumn: "sessionBranch",
|
|
58456
|
+
restartRequired: false,
|
|
58457
|
+
valueSchema: z5.string().min(1),
|
|
58458
|
+
parseEnv: idEnv
|
|
58459
|
+
},
|
|
58460
|
+
{
|
|
58461
|
+
key: "docsCommitPrefix",
|
|
58462
|
+
projectColumn: "docsCommitPrefix",
|
|
58463
|
+
restartRequired: false,
|
|
58464
|
+
valueSchema: z5.string().min(1),
|
|
58465
|
+
parseEnv: idEnv,
|
|
58466
|
+
defaultValue: DEFAULT_DOCS_COMMIT_PREFIX
|
|
58467
|
+
},
|
|
58468
|
+
{
|
|
58469
|
+
key: "dbResetCommand",
|
|
58470
|
+
projectColumn: "dbResetCommand",
|
|
58471
|
+
restartRequired: false,
|
|
58472
|
+
valueSchema: z5.string().min(1),
|
|
58473
|
+
parseEnv: idEnv
|
|
58474
|
+
},
|
|
58475
|
+
{
|
|
58476
|
+
key: "driveSetupCommand",
|
|
58477
|
+
projectColumn: "driveSetupCommand",
|
|
58478
|
+
restartRequired: false,
|
|
58479
|
+
valueSchema: z5.string().min(1),
|
|
58480
|
+
parseEnv: idEnv
|
|
58481
|
+
},
|
|
58482
|
+
{
|
|
58483
|
+
key: "driveStopCommand",
|
|
58484
|
+
projectColumn: "driveStopCommand",
|
|
58485
|
+
restartRequired: false,
|
|
58486
|
+
valueSchema: z5.string().min(1),
|
|
58487
|
+
parseEnv: idEnv
|
|
58488
|
+
},
|
|
58489
|
+
{
|
|
58490
|
+
key: "driveInstructions",
|
|
58491
|
+
projectColumn: "driveInstructions",
|
|
58492
|
+
restartRequired: false,
|
|
58493
|
+
valueSchema: z5.string().min(1),
|
|
58494
|
+
parseEnv: idEnv
|
|
58495
|
+
},
|
|
58496
|
+
{
|
|
58497
|
+
key: "scenarioRunner",
|
|
58498
|
+
projectColumn: "scenarioRunner",
|
|
58499
|
+
restartRequired: false,
|
|
58500
|
+
valueSchema: z5.string().min(1),
|
|
58501
|
+
parseEnv: idEnv
|
|
58502
|
+
}
|
|
58503
|
+
];
|
|
58504
|
+
DEFAULTS = RuncastleConfig.parse({});
|
|
58505
|
+
GLOBAL_CLEARABLE_KEYS = new Set(["sandboxImage"]);
|
|
58506
|
+
STEP_SET = new Set(MODEL_STEPS);
|
|
58507
|
+
});
|
|
58508
|
+
|
|
58509
|
+
// src/services/setup.ts
|
|
58510
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync17, mkdirSync as mkdirSync10, readFileSync as readFileSync12, readdirSync as readdirSync6, writeFileSync as writeFileSync8 } from "fs";
|
|
58511
|
+
import { dirname as dirname12, join as join20 } from "path";
|
|
58512
|
+
async function writeGitIdentity(exec3, identity4) {
|
|
58513
|
+
const name = identity4.name.trim();
|
|
58514
|
+
const email = identity4.email.trim();
|
|
58515
|
+
if (name.length === 0)
|
|
58516
|
+
throw new InvalidInputError("git user.name cannot be empty");
|
|
58517
|
+
if (!email.includes("@"))
|
|
58518
|
+
throw new InvalidInputError("git user.email must be an email address");
|
|
58519
|
+
await exec3("git", ["config", "--global", "user.name", name]);
|
|
58520
|
+
await exec3("git", ["config", "--global", "user.email", email]);
|
|
58521
|
+
return gitIdentityProbe(exec3);
|
|
58522
|
+
}
|
|
58523
|
+
function upsertEnvVar(content, key, value) {
|
|
58524
|
+
const line = `${key}=${value}`;
|
|
58525
|
+
const lines2 = content.length === 0 ? [] : content.replace(/\n$/, "").split(`
|
|
58664
58526
|
`);
|
|
58665
|
-
|
|
58666
|
-
|
|
58667
|
-
|
|
58668
|
-
|
|
58669
|
-
|
|
58670
|
-
|
|
58671
|
-
|
|
58672
|
-
const u = obj.message.usage;
|
|
58673
|
-
if (typeof u.input_tokens === "number" && typeof u.cache_creation_input_tokens === "number" && typeof u.cache_read_input_tokens === "number" && typeof u.output_tokens === "number") {
|
|
58674
|
-
return {
|
|
58675
|
-
inputTokens: u.input_tokens,
|
|
58676
|
-
cacheCreationInputTokens: u.cache_creation_input_tokens,
|
|
58677
|
-
cacheReadInputTokens: u.cache_read_input_tokens,
|
|
58678
|
-
outputTokens: u.output_tokens
|
|
58679
|
-
};
|
|
58680
|
-
}
|
|
58681
|
-
}
|
|
58682
|
-
} catch {}
|
|
58527
|
+
const matcher = new RegExp(`^(export\\s+)?${key}=`);
|
|
58528
|
+
let replaced = false;
|
|
58529
|
+
const next4 = lines2.map((l) => {
|
|
58530
|
+
if (matcher.test(l)) {
|
|
58531
|
+
replaced = true;
|
|
58532
|
+
const exportPrefix = l.startsWith("export ") ? "export " : "";
|
|
58533
|
+
return `${exportPrefix}${line}`;
|
|
58683
58534
|
}
|
|
58684
|
-
return;
|
|
58535
|
+
return l;
|
|
58536
|
+
});
|
|
58537
|
+
if (!replaced)
|
|
58538
|
+
next4.push(line);
|
|
58539
|
+
return `${next4.join(`
|
|
58540
|
+
`)}
|
|
58541
|
+
`;
|
|
58542
|
+
}
|
|
58543
|
+
async function saveAfkCredential(io, rawValue, runtime5 = DEFAULT_RUNTIME) {
|
|
58544
|
+
const spec = RUNTIME_SPECS[runtime5];
|
|
58545
|
+
const value = rawValue.trim();
|
|
58546
|
+
if (value.length === 0)
|
|
58547
|
+
throw new InvalidInputError(`${spec.label} ${spec.afkNoun} cannot be empty`);
|
|
58548
|
+
if (/[\r\n]/.test(value)) {
|
|
58549
|
+
throw new InvalidInputError(`${spec.label} ${spec.afkNoun} cannot contain a newline`);
|
|
58685
58550
|
}
|
|
58686
|
-
|
|
58687
|
-
|
|
58688
|
-
|
|
58689
|
-
|
|
58690
|
-
|
|
58691
|
-
|
|
58692
|
-
|
|
58693
|
-
|
|
58694
|
-
|
|
58695
|
-
|
|
58551
|
+
io.write(upsertEnvVar(io.read(), spec.afkKey, value));
|
|
58552
|
+
return io.verify(value);
|
|
58553
|
+
}
|
|
58554
|
+
function seedRuntimeFor(ready) {
|
|
58555
|
+
return ready.includes(DEFAULT_RUNTIME) ? DEFAULT_RUNTIME : ready[0];
|
|
58556
|
+
}
|
|
58557
|
+
function seedModelDefaults(ctx, ready, io = {}) {
|
|
58558
|
+
const runtime5 = seedRuntimeFor(ready);
|
|
58559
|
+
if (!runtime5)
|
|
58560
|
+
return null;
|
|
58561
|
+
const pair = RUNTIME_DEFAULT_MODELS[runtime5];
|
|
58562
|
+
const write4 = (key, value) => {
|
|
58563
|
+
try {
|
|
58564
|
+
updateSettings(ctx, { key, value }, io);
|
|
58565
|
+
return value;
|
|
58566
|
+
} catch (err) {
|
|
58567
|
+
if (err instanceof InvalidInputError)
|
|
58568
|
+
return;
|
|
58569
|
+
throw err;
|
|
58570
|
+
}
|
|
58696
58571
|
};
|
|
58697
|
-
|
|
58698
|
-
|
|
58699
|
-
|
|
58700
|
-
|
|
58701
|
-
|
|
58702
|
-
|
|
58703
|
-
|
|
58704
|
-
|
|
58705
|
-
|
|
58706
|
-
|
|
58707
|
-
|
|
58708
|
-
|
|
58709
|
-
|
|
58710
|
-
|
|
58711
|
-
|
|
58712
|
-
|
|
58713
|
-
|
|
58714
|
-
|
|
58715
|
-
|
|
58716
|
-
|
|
58717
|
-
|
|
58718
|
-
|
|
58719
|
-
|
|
58720
|
-
|
|
58721
|
-
|
|
58722
|
-
|
|
58723
|
-
|
|
58724
|
-
|
|
58725
|
-
|
|
58572
|
+
const model = write4("model", pair.flagship);
|
|
58573
|
+
const smoke = write4("stepModels.smoke", pair.smoke);
|
|
58574
|
+
return {
|
|
58575
|
+
runtime: runtime5,
|
|
58576
|
+
...model ? { model } : {},
|
|
58577
|
+
...smoke ? { smoke } : {}
|
|
58578
|
+
};
|
|
58579
|
+
}
|
|
58580
|
+
function runtimeInstallGuide(platform) {
|
|
58581
|
+
switch (platform) {
|
|
58582
|
+
case "win32":
|
|
58583
|
+
return {
|
|
58584
|
+
command: "winget install RedHat.Podman",
|
|
58585
|
+
note: "Then initialize the VM: podman machine init && podman machine start"
|
|
58586
|
+
};
|
|
58587
|
+
case "darwin":
|
|
58588
|
+
return {
|
|
58589
|
+
command: "brew install podman",
|
|
58590
|
+
note: "Then initialize the VM: podman machine init && podman machine start"
|
|
58591
|
+
};
|
|
58592
|
+
default:
|
|
58593
|
+
return {
|
|
58594
|
+
command: "sudo apt install podman # or: sudo dnf install podman / sudo pacman -S podman",
|
|
58595
|
+
note: "Podman is rootless on Linux \u2014 no machine step needed."
|
|
58596
|
+
};
|
|
58597
|
+
}
|
|
58598
|
+
}
|
|
58599
|
+
async function resolveRuntime(exec3, preferred) {
|
|
58600
|
+
const present = async (bin) => {
|
|
58601
|
+
const out = await exec3(bin, ["--version"]);
|
|
58602
|
+
return out.ok && out.code === 0;
|
|
58603
|
+
};
|
|
58604
|
+
if (await present(preferred))
|
|
58605
|
+
return preferred;
|
|
58606
|
+
const other = preferred === "docker" ? "podman" : "docker";
|
|
58607
|
+
if (await present(other))
|
|
58608
|
+
return other;
|
|
58609
|
+
return preferred;
|
|
58610
|
+
}
|
|
58611
|
+
function terminalSpec(kind) {
|
|
58612
|
+
if (kind === "setup-token")
|
|
58613
|
+
return { cmd: "claude", args: ["setup-token"] };
|
|
58614
|
+
for (const spec of Object.values(RUNTIME_SPECS)) {
|
|
58615
|
+
if (kind === LOGIN_TERMINAL_KIND[spec.runtime])
|
|
58616
|
+
return { cmd: spec.bin, args: spec.loginArgs };
|
|
58617
|
+
}
|
|
58618
|
+
throw new InvalidInputError(`no terminal command for ${kind}`);
|
|
58619
|
+
}
|
|
58620
|
+
function refreshSandcastleConfig(templateDir, targetDir) {
|
|
58621
|
+
const dir = join20(targetDir, ".sandcastle");
|
|
58622
|
+
mkdirSync10(dir, { recursive: true });
|
|
58623
|
+
for (const name of readdirSync6(templateDir)) {
|
|
58624
|
+
copyFileSync2(join20(templateDir, name), join20(dir, name));
|
|
58625
|
+
}
|
|
58626
|
+
return dir;
|
|
58627
|
+
}
|
|
58628
|
+
function prepareSandboxBuildContext(templateDir = sandcastleTemplateDir(), target = sandboxBuildDir()) {
|
|
58629
|
+
mkdirSync10(target, { recursive: true });
|
|
58630
|
+
return refreshSandcastleConfig(templateDir, target);
|
|
58631
|
+
}
|
|
58632
|
+
function createCredentialVerifier(exec3, runtime5 = DEFAULT_RUNTIME) {
|
|
58633
|
+
const spec = RUNTIME_SPECS[runtime5];
|
|
58634
|
+
return async (value) => {
|
|
58635
|
+
if (value.length < 8) {
|
|
58636
|
+
return {
|
|
58637
|
+
valid: false,
|
|
58638
|
+
detail: `${spec.afkNoun} looks malformed (too short) \u2014 saved to ~/.runcastle/.env anyway`,
|
|
58639
|
+
fix: `${spec.afkFix}. It starts with \`sk-\`.`
|
|
58640
|
+
};
|
|
58641
|
+
}
|
|
58642
|
+
const out = await exec3(spec.bin, ["--version"]);
|
|
58643
|
+
if (!out.ok) {
|
|
58644
|
+
return {
|
|
58645
|
+
valid: false,
|
|
58646
|
+
detail: `${spec.afkNoun} saved to ~/.runcastle/.env, but runcastle could not launch \`${spec.bin}\` to verify it. ` + "That is a PATH problem in this server process, not a missing install \u2014 a terminal that finds " + `\`${spec.bin}\` proves nothing about the PATH runcastle was started with.`,
|
|
58647
|
+
fix: `Quit runcastle and start it again from a terminal where \`${spec.bin} --version\` works. ` + `If it still fails, pin the path: set ${spec.binOverrideEnv} to the full path from ` + `\`where.exe ${spec.bin}\` (Windows) or \`which ${spec.bin}\` (macOS/Linux), then restart runcastle.`
|
|
58648
|
+
};
|
|
58649
|
+
}
|
|
58650
|
+
if (out.code !== 0) {
|
|
58651
|
+
const why = (out.stderr.trim() || out.stdout.trim()).split(`
|
|
58652
|
+
`)[0] ?? "";
|
|
58653
|
+
return {
|
|
58654
|
+
valid: false,
|
|
58655
|
+
detail: `${spec.afkNoun} saved to ~/.runcastle/.env, but \`${spec.bin} --version\` exited ${out.code}` + `${why ? `: ${why}` : " with no output"}.`,
|
|
58656
|
+
fix: `Run \`${spec.bin} --version\` yourself and fix what it reports \u2014 the ${spec.label} install is broken, not the ${spec.afkNoun}.`
|
|
58657
|
+
};
|
|
58726
58658
|
}
|
|
58659
|
+
return { valid: true, detail: `${spec.afkNoun} captured to ~/.runcastle/.env` };
|
|
58727
58660
|
};
|
|
58728
|
-
|
|
58729
|
-
|
|
58730
|
-
|
|
58731
|
-
|
|
58732
|
-
|
|
58661
|
+
}
|
|
58662
|
+
function fileAfkTokenIo(exec3, runtime5 = DEFAULT_RUNTIME) {
|
|
58663
|
+
const path2 = envPath();
|
|
58664
|
+
return {
|
|
58665
|
+
read: () => existsSync17(path2) ? readFileSync12(path2, "utf8") : "",
|
|
58666
|
+
write: (content) => {
|
|
58667
|
+
mkdirSync10(dirname12(path2), { recursive: true });
|
|
58668
|
+
writeFileSync8(path2, content, "utf8");
|
|
58669
|
+
},
|
|
58670
|
+
verify: createCredentialVerifier(exec3, runtime5)
|
|
58733
58671
|
};
|
|
58734
|
-
|
|
58735
|
-
|
|
58672
|
+
}
|
|
58673
|
+
var AFK_TOKEN_KEY, CODEX_API_KEY, RUNTIME_AUTH_KEY, RUNTIME_AUTH_SETUP_HINT, LOGIN_TERMINAL_KIND;
|
|
58674
|
+
var init_setup = __esm(() => {
|
|
58675
|
+
init_src();
|
|
58676
|
+
init_paths();
|
|
58677
|
+
init_doctor();
|
|
58678
|
+
init_errors();
|
|
58679
|
+
init_asset_paths();
|
|
58680
|
+
init_settings();
|
|
58681
|
+
AFK_TOKEN_KEY = RUNTIME_SPECS["claude-code"].afkKey;
|
|
58682
|
+
CODEX_API_KEY = RUNTIME_SPECS.codex.afkKey;
|
|
58683
|
+
RUNTIME_AUTH_KEY = {
|
|
58684
|
+
"claude-code": AFK_TOKEN_KEY,
|
|
58685
|
+
codex: CODEX_API_KEY
|
|
58686
|
+
};
|
|
58687
|
+
RUNTIME_AUTH_SETUP_HINT = {
|
|
58688
|
+
"claude-code": RUNTIME_SPECS["claude-code"].afkFix,
|
|
58689
|
+
codex: `Run \`${RUNTIME_SPECS.codex.loginCommand}\` on this host, then burn again`
|
|
58690
|
+
};
|
|
58691
|
+
LOGIN_TERMINAL_KIND = {
|
|
58692
|
+
"claude-code": "claude-login",
|
|
58693
|
+
codex: "codex-login"
|
|
58694
|
+
};
|
|
58695
|
+
});
|
|
58696
|
+
|
|
58697
|
+
// src/services/agent-stream.ts
|
|
58698
|
+
function beginTranscript(ticketId) {
|
|
58699
|
+
transcripts.set(ticketId, { live: true, chunks: [], nextIndex: 0, bytes: 0 });
|
|
58700
|
+
publishLive({ kind: "transcript", ticketId });
|
|
58701
|
+
}
|
|
58702
|
+
function appendTranscript(ticketId, chunk) {
|
|
58703
|
+
const t = transcripts.get(ticketId);
|
|
58704
|
+
if (!t)
|
|
58705
|
+
return;
|
|
58706
|
+
const full = { ...chunk, i: t.nextIndex, ts: chunk.ts ?? Date.now() };
|
|
58707
|
+
t.nextIndex += 1;
|
|
58708
|
+
t.chunks.push(full);
|
|
58709
|
+
t.bytes += full.text.length;
|
|
58710
|
+
while (t.chunks.length > MAX_CHUNKS || t.bytes > MAX_BYTES && t.chunks.length > 1) {
|
|
58711
|
+
const dropped = t.chunks.shift();
|
|
58712
|
+
if (!dropped)
|
|
58713
|
+
break;
|
|
58714
|
+
t.bytes -= dropped.text.length;
|
|
58715
|
+
}
|
|
58716
|
+
publishLive({ kind: "transcript", ticketId });
|
|
58717
|
+
}
|
|
58718
|
+
function endTranscript(ticketId) {
|
|
58719
|
+
const t = transcripts.get(ticketId);
|
|
58720
|
+
if (t)
|
|
58721
|
+
t.live = false;
|
|
58722
|
+
publishLive({ kind: "transcript", ticketId });
|
|
58723
|
+
}
|
|
58724
|
+
function readTranscript(ticketId, after3 = -1) {
|
|
58725
|
+
const t = transcripts.get(ticketId);
|
|
58726
|
+
if (!t)
|
|
58727
|
+
return { live: false, chunks: [], firstIndex: 0, nextIndex: 0 };
|
|
58728
|
+
return {
|
|
58729
|
+
live: t.live,
|
|
58730
|
+
chunks: after3 < 0 ? [...t.chunks] : t.chunks.filter((c) => c.i > after3),
|
|
58731
|
+
firstIndex: t.chunks[0]?.i ?? t.nextIndex,
|
|
58732
|
+
nextIndex: t.nextIndex
|
|
58733
|
+
};
|
|
58734
|
+
}
|
|
58735
|
+
var MAX_CHUNKS = 4000, MAX_BYTES = 1500000, transcripts;
|
|
58736
|
+
var init_agent_stream = __esm(() => {
|
|
58737
|
+
init_bus();
|
|
58738
|
+
transcripts = new Map;
|
|
58736
58739
|
});
|
|
58737
58740
|
|
|
58738
58741
|
// src/workflows/burn-guard.ts
|
|
@@ -59032,252 +59035,8 @@ var init_recorder_reap = __esm(() => {
|
|
|
59032
59035
|
};
|
|
59033
59036
|
});
|
|
59034
59037
|
|
|
59035
|
-
// src/workflows/review-gates.ts
|
|
59036
|
-
var exports_review_gates = {};
|
|
59037
|
-
__export(exports_review_gates, {
|
|
59038
|
-
withThrowawayBranch: () => withThrowawayBranch,
|
|
59039
|
-
timeoutReason: () => timeoutReason,
|
|
59040
|
-
runReviewGates: () => runReviewGates,
|
|
59041
|
-
reviewGateBranch: () => reviewGateBranch,
|
|
59042
|
-
parseVerifyCommands: () => parseVerifyCommands,
|
|
59043
|
-
headline: () => headline,
|
|
59044
|
-
execWithTimeout: () => execWithTimeout,
|
|
59045
|
-
errorText: () => errorText,
|
|
59046
|
-
errorDetail: () => errorDetail,
|
|
59047
|
-
burnGateSandbox: () => burnGateSandbox,
|
|
59048
|
-
SandboxSetupError: () => SandboxSetupError,
|
|
59049
|
-
GATE_COMMAND_TIMEOUT_MS: () => GATE_COMMAND_TIMEOUT_MS
|
|
59050
|
-
});
|
|
59051
|
-
import { mkdirSync as mkdirSync11, rmSync as rmSync3, writeFileSync as writeFileSync9 } from "fs";
|
|
59052
|
-
import { stripVTControlCharacters as stripVTControlCharacters2 } from "util";
|
|
59053
|
-
function reviewGateBranch(ticketId) {
|
|
59054
|
-
return `runcastle/gates/${ticketId}`;
|
|
59055
|
-
}
|
|
59056
|
-
function parseVerifyCommands(verifyCommands) {
|
|
59057
|
-
return (verifyCommands ?? "").split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
59058
|
-
}
|
|
59059
|
-
function errorText(err) {
|
|
59060
|
-
return err instanceof Error ? err.message : String(err);
|
|
59061
|
-
}
|
|
59062
|
-
function errorDetail(err) {
|
|
59063
|
-
if (err instanceof SandboxSetupError)
|
|
59064
|
-
return `${err.message}
|
|
59065
|
-
|
|
59066
|
-
${stripVTControlCharacters2(err.output)}`;
|
|
59067
|
-
return err instanceof Error ? err.stack ?? err.message : String(err);
|
|
59068
|
-
}
|
|
59069
|
-
function headline(text3) {
|
|
59070
|
-
return text3.split(/\r?\n/).find((line) => line.trim())?.trim() ?? "unknown error";
|
|
59071
|
-
}
|
|
59072
|
-
async function withThrowawayBranch(repoPath, branch, sha, use) {
|
|
59073
|
-
const discardBranch = async () => {
|
|
59074
|
-
await cleanupBurnWorktree(repoPath, branch);
|
|
59075
|
-
await deleteTempBranch(repoPath, branch);
|
|
59076
|
-
};
|
|
59077
|
-
try {
|
|
59078
|
-
await discardBranch();
|
|
59079
|
-
await pinBranchAt(repoPath, branch, sha);
|
|
59080
|
-
await excludeBurnWorktrees(repoPath);
|
|
59081
|
-
return await use();
|
|
59082
|
-
} finally {
|
|
59083
|
-
await discardBranch();
|
|
59084
|
-
}
|
|
59085
|
-
}
|
|
59086
|
-
async function execWithTimeout(sandbox3, command, timeoutMs) {
|
|
59087
|
-
let timer;
|
|
59088
|
-
const timedOut = new Promise((done10) => {
|
|
59089
|
-
timer = setTimeout(() => done10("timeout"), timeoutMs);
|
|
59090
|
-
});
|
|
59091
|
-
try {
|
|
59092
|
-
return await Promise.race([sandbox3.exec(command), timedOut]);
|
|
59093
|
-
} finally {
|
|
59094
|
-
clearTimeout(timer);
|
|
59095
|
-
}
|
|
59096
|
-
}
|
|
59097
|
-
async function runSandboxSetup(exec3, setup, timeoutMs) {
|
|
59098
|
-
const streamed = [];
|
|
59099
|
-
const result = await execWithTimeout({ exec: (command) => exec3(command, { onLine: (line) => streamed.push(line) }) }, setup, timeoutMs);
|
|
59100
|
-
if (result === "timeout") {
|
|
59101
|
-
throw new SandboxSetupError(`the sync-and-install setup ${timeoutReason(timeoutMs)}`, streamed.join(`
|
|
59102
|
-
`));
|
|
59103
|
-
}
|
|
59104
|
-
if (result.exitCode !== 0) {
|
|
59105
|
-
throw new SandboxSetupError(`the sync-and-install setup exited ${result.exitCode}`, [result.stdout, result.stderr].filter(Boolean).join(`
|
|
59106
|
-
`));
|
|
59107
|
-
}
|
|
59108
|
-
}
|
|
59109
|
-
function timeoutReason(timeoutMs) {
|
|
59110
|
-
return `timed out after ${Math.round(timeoutMs / 60000)} minutes`;
|
|
59111
|
-
}
|
|
59112
|
-
async function runReviewGates(input) {
|
|
59113
|
-
const { config: config2, project: project3, ticketId, sha } = input;
|
|
59114
|
-
const commands = parseVerifyCommands(resolvePreparedSettings(config2, project3).verifyCommands);
|
|
59115
|
-
if (commands.length === 0)
|
|
59116
|
-
return { status: "none_configured" };
|
|
59117
|
-
const withSandbox = input.deps?.withSandbox ?? burnGateSandbox(config2, project3);
|
|
59118
|
-
const timeoutMs = input.deps?.commandTimeoutMs ?? GATE_COMMAND_TIMEOUT_MS;
|
|
59119
|
-
const branch = reviewGateBranch(ticketId);
|
|
59120
|
-
const results = [];
|
|
59121
|
-
try {
|
|
59122
|
-
rmSync3(reviewGateLogDir(ticketId), { recursive: true, force: true });
|
|
59123
|
-
mkdirSync11(reviewGateLogDir(ticketId), { recursive: true });
|
|
59124
|
-
await withThrowawayBranch(project3.repoPath, branch, sha, async () => {
|
|
59125
|
-
while (results.length < commands.length) {
|
|
59126
|
-
await withSandbox(branch, async (sandbox3) => {
|
|
59127
|
-
for (const [i, command] of commands.entries()) {
|
|
59128
|
-
if (i < results.length)
|
|
59129
|
-
continue;
|
|
59130
|
-
const { result, stillRunning } = await runGateCommand(sandbox3, command, ticketId, `${i}.log`, timeoutMs);
|
|
59131
|
-
results.push(result);
|
|
59132
|
-
if (stillRunning)
|
|
59133
|
-
return;
|
|
59134
|
-
}
|
|
59135
|
-
});
|
|
59136
|
-
}
|
|
59137
|
-
});
|
|
59138
|
-
return { status: "ran", commit: sha, commands: results };
|
|
59139
|
-
} catch (err) {
|
|
59140
|
-
if (results.length > 0) {
|
|
59141
|
-
const detail = errorDetail(err);
|
|
59142
|
-
const reason = `the gate sandbox could not be reopened: ${headline(errorText(err))}`;
|
|
59143
|
-
for (const [i, command] of commands.entries()) {
|
|
59144
|
-
if (i < results.length)
|
|
59145
|
-
continue;
|
|
59146
|
-
writeFileSync9(reviewGateLogPath(ticketId, `${i}.log`), `${detail}
|
|
59147
|
-
`);
|
|
59148
|
-
results.push({ command, outcome: "couldnt_run", exitCode: null, reason, log: `${i}.log` });
|
|
59149
|
-
}
|
|
59150
|
-
return { status: "ran", commit: sha, commands: results };
|
|
59151
|
-
}
|
|
59152
|
-
return {
|
|
59153
|
-
status: "couldnt_run",
|
|
59154
|
-
commit: sha,
|
|
59155
|
-
reason: `the gate sandbox could not be set up: ${headline(errorText(err))}`,
|
|
59156
|
-
log: writeRunLog(ticketId, err)
|
|
59157
|
-
};
|
|
59158
|
-
}
|
|
59159
|
-
}
|
|
59160
|
-
function writeRunLog(ticketId, err) {
|
|
59161
|
-
try {
|
|
59162
|
-
writeFileSync9(reviewGateLogPath(ticketId, "run.log"), `${errorDetail(err)}
|
|
59163
|
-
`);
|
|
59164
|
-
return "run.log";
|
|
59165
|
-
} catch {
|
|
59166
|
-
return null;
|
|
59167
|
-
}
|
|
59168
|
-
}
|
|
59169
|
-
async function runGateCommand(sandbox3, command, ticketId, log6, timeoutMs) {
|
|
59170
|
-
const logPath = reviewGateLogPath(ticketId, log6);
|
|
59171
|
-
try {
|
|
59172
|
-
const result = await execWithTimeout(sandbox3, command, timeoutMs);
|
|
59173
|
-
if (result === "timeout") {
|
|
59174
|
-
const reason = timeoutReason(timeoutMs);
|
|
59175
|
-
writeFileSync9(logPath, `${reason}
|
|
59176
|
-
`);
|
|
59177
|
-
return {
|
|
59178
|
-
result: { command, outcome: "couldnt_run", exitCode: null, reason, log: log6 },
|
|
59179
|
-
stillRunning: true
|
|
59180
|
-
};
|
|
59181
|
-
}
|
|
59182
|
-
writeFileSync9(logPath, [result.stdout, result.stderr].filter(Boolean).join(`
|
|
59183
|
-
`));
|
|
59184
|
-
return {
|
|
59185
|
-
result: result.exitCode === 0 ? { command, outcome: "passed", exitCode: 0, log: log6 } : { command, outcome: "failed", exitCode: result.exitCode, log: log6 },
|
|
59186
|
-
stillRunning: false
|
|
59187
|
-
};
|
|
59188
|
-
} catch (err) {
|
|
59189
|
-
const reason = `could not start: ${headline(errorText(err))}`;
|
|
59190
|
-
writeFileSync9(logPath, `${errorText(err)}
|
|
59191
|
-
`);
|
|
59192
|
-
return {
|
|
59193
|
-
result: { command, outcome: "couldnt_run", exitCode: null, reason, log: log6 },
|
|
59194
|
-
stillRunning: false
|
|
59195
|
-
};
|
|
59196
|
-
}
|
|
59197
|
-
}
|
|
59198
|
-
function burnGateSandbox(config2, project3, deps = {}) {
|
|
59199
|
-
const open3 = deps.open ?? createSandbox;
|
|
59200
|
-
const setupTimeoutMs = deps.setupTimeoutMs ?? SETUP_HOOK_TIMEOUT_MS;
|
|
59201
|
-
return (branch, use) => {
|
|
59202
|
-
const allocator = resolveBurnCacheMode(config2) === "volume" ? getBurnSlotAllocator(config2.burnConcurrency) : undefined;
|
|
59203
|
-
return withBurnCacheSlot(allocator, async (slot) => {
|
|
59204
|
-
if (slot !== undefined) {
|
|
59205
|
-
await ensureBurnCacheVolume({
|
|
59206
|
-
engine: config2.sandbox === "podman" ? "podman" : "docker",
|
|
59207
|
-
imageName: resolveSandboxImage(config2, project3),
|
|
59208
|
-
projectId: project3.id,
|
|
59209
|
-
exec: createSystemExec({ cwd: project3.repoPath })
|
|
59210
|
-
});
|
|
59211
|
-
}
|
|
59212
|
-
const workspaceMode = resolveBurnWorkspaceMode(slot === undefined ? { ...config2, burnCache: "off" } : config2);
|
|
59213
|
-
const toolchain = readRepoToolchain(project3.repoPath);
|
|
59214
|
-
const pm = detectPackageManager(toolchain);
|
|
59215
|
-
const setupCommand = resolveSetupCommand(toolchain, resolvePreparedSettings(config2, project3).setupCommand);
|
|
59216
|
-
const cache = buildBurnCacheMounts(slot, project3.id, config2.sandbox, pm);
|
|
59217
|
-
const onHost2 = config2.sandbox === "noSandbox";
|
|
59218
|
-
for (const mount of cache.mounts) {
|
|
59219
|
-
if ("hostPath" in mount)
|
|
59220
|
-
mkdirSync11(mount.hostPath, { recursive: true });
|
|
59221
|
-
}
|
|
59222
|
-
const setup = slot !== undefined ? buildSlotSetupCommand(slot, branch, setupCommand, pm, buildSlotStamp(resolveSandboxImage(config2, project3), toolchain.packageManagerField)) : workspaceMode === "isolated" ? buildIsolatedSetupCommand(branch, setupCommand, pm) : setupCommand;
|
|
59223
|
-
const cwd = slot !== undefined ? slotRepoPath(slot) : workspaceMode === "isolated" ? ISOLATED_REPO_PATH : undefined;
|
|
59224
|
-
const lane = branch;
|
|
59225
|
-
const sandbox3 = await open3({
|
|
59226
|
-
branch,
|
|
59227
|
-
sandbox: selectSandbox(config2, project3, cache.mounts, cache.env, {
|
|
59228
|
-
onChildSpawn: registerHostChildren(lane, {})
|
|
59229
|
-
}),
|
|
59230
|
-
cwd: project3.repoPath
|
|
59231
|
-
});
|
|
59232
|
-
let running3 = 0;
|
|
59233
|
-
const exec3 = async (command, opts) => {
|
|
59234
|
-
running3++;
|
|
59235
|
-
try {
|
|
59236
|
-
return await sandbox3.exec(command, opts);
|
|
59237
|
-
} finally {
|
|
59238
|
-
running3--;
|
|
59239
|
-
}
|
|
59240
|
-
};
|
|
59241
|
-
try {
|
|
59242
|
-
if (setup) {
|
|
59243
|
-
const script = onHost2 ? setup : `git config --global --add safe.directory '*' && ${setup}`;
|
|
59244
|
-
await runSandboxSetup(exec3, script, setupTimeoutMs);
|
|
59245
|
-
}
|
|
59246
|
-
return await use({
|
|
59247
|
-
exec: (command) => exec3(command, cwd ? { cwd } : {})
|
|
59248
|
-
});
|
|
59249
|
-
} finally {
|
|
59250
|
-
if (running3 > 0)
|
|
59251
|
-
await killRegistry().killAndWait(lane);
|
|
59252
|
-
killRegistry().release(lane);
|
|
59253
|
-
await sandbox3.close();
|
|
59254
|
-
}
|
|
59255
|
-
});
|
|
59256
|
-
};
|
|
59257
|
-
}
|
|
59258
|
-
var GATE_COMMAND_TIMEOUT_MS, SandboxSetupError;
|
|
59259
|
-
var init_review_gates2 = __esm(() => {
|
|
59260
|
-
init_dist();
|
|
59261
|
-
init_src();
|
|
59262
|
-
init_paths();
|
|
59263
|
-
init_system_exec();
|
|
59264
|
-
init_git();
|
|
59265
|
-
init_burn_cache();
|
|
59266
|
-
init_kill_registry();
|
|
59267
|
-
init_ticket_burner();
|
|
59268
|
-
GATE_COMMAND_TIMEOUT_MS = SETUP_HOOK_TIMEOUT_MS;
|
|
59269
|
-
SandboxSetupError = class SandboxSetupError extends Error {
|
|
59270
|
-
output;
|
|
59271
|
-
constructor(message, output) {
|
|
59272
|
-
super(message);
|
|
59273
|
-
this.output = output;
|
|
59274
|
-
this.name = "SandboxSetupError";
|
|
59275
|
-
}
|
|
59276
|
-
};
|
|
59277
|
-
});
|
|
59278
|
-
|
|
59279
59038
|
// src/workflows/review-ticket.ts
|
|
59280
|
-
import { existsSync as existsSync19, mkdirSync as
|
|
59039
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync13, readdirSync as readdirSync7, renameSync, rmSync as rmSync3, writeFileSync as writeFileSync9 } from "fs";
|
|
59281
59040
|
import { spawnSync } from "child_process";
|
|
59282
59041
|
import { basename as basename4, dirname as dirname13, join as join23 } from "path";
|
|
59283
59042
|
function reviewTemplatePath(ticket) {
|
|
@@ -59416,10 +59175,10 @@ function composeReviewDigest(resolution, agentDigest) {
|
|
|
59416
59175
|
if (resolution.reviewVerdict !== "unverified")
|
|
59417
59176
|
return agentDigest;
|
|
59418
59177
|
const mode = resolution.reviewMode;
|
|
59419
|
-
const
|
|
59420
|
-
return agentDigest ? `${
|
|
59178
|
+
const headline = `${mode ? `${mode} mode` : "mode unrecorded"} \xB7 ` + `${mode ? `${mode.toUpperCase()} FAILED` : "NO DECLARATION"} \xB7 nothing verified` + (resolution.reason ? ` \u2014 ${resolution.reason}` : "");
|
|
59179
|
+
return agentDigest ? `${headline}
|
|
59421
59180
|
|
|
59422
|
-
${agentDigest}` :
|
|
59181
|
+
${agentDigest}` : headline;
|
|
59423
59182
|
}
|
|
59424
59183
|
function buildDriveInstructions(instructions) {
|
|
59425
59184
|
const text3 = instructions?.trim();
|
|
@@ -59476,7 +59235,7 @@ function buildGateNotes(gateRun, ticketId, config2, project3) {
|
|
|
59476
59235
|
out.push(`The server could not run the gates on the feature branch${gateRun.commit ? ` at \`${shortCommit(gateRun.commit)}\`` : ""}: ${gateRun.reason}.`, ...gateRun.log ? [`Its captured output is at \`${reviewGateLogPath(ticketId, gateRun.log)}\`.`] : [], "", "That is an observation about the environment, not a defect against the branch: report it as an observation, say plainly in your digest that the gates did not run, and carry on with the review. Never describe the gates as passed.");
|
|
59477
59236
|
break;
|
|
59478
59237
|
case "ran":
|
|
59479
|
-
out.push(`Before you started, the server ran this project's verify commands once each on the feature branch at \`${shortCommit(gateRun.commit)}\`, in a sandbox with the branch checked out and its dependencies installed:`, "", ...gateRun.commands.map((result) => gateCommandNote(ticketId, result)), "", "A failed command is a defect against the branch, with the command as its repro: read its output file, then read the branch (`git diff` / `git show`) to explain what broke it. A command that couldn't run is an observation, not a defect.");
|
|
59238
|
+
out.push(gateRun.reusedFrom ? `The server did not re-run this project's verify commands for this pass: the result below is from an earlier pass on the feature branch at \`${shortCommit(gateRun.commit)}\`, and the branch has not moved since (or only this feature's docs changed). They ran once each, in a sandbox with the branch checked out and its dependencies installed:` : `Before you started, the server ran this project's verify commands once each on the feature branch at \`${shortCommit(gateRun.commit)}\`, in a sandbox with the branch checked out and its dependencies installed:`, "", ...gateRun.commands.map((result) => gateCommandNote(ticketId, result)), "", "A failed command is a defect against the branch, with the command as its repro: read its output file, then read the branch (`git diff` / `git show`) to explain what broke it. A command that couldn't run is an observation, not a defect.");
|
|
59480
59239
|
break;
|
|
59481
59240
|
}
|
|
59482
59241
|
out.push("");
|
|
@@ -59523,7 +59282,7 @@ async function writeReviewArtifacts(ticket, runId, config2, recorderReap = reapR
|
|
|
59523
59282
|
await prepareReviewArtifactsDirectory(ticket.id, dir, { recorderReap });
|
|
59524
59283
|
const mcpConfigPath = join23(dir, "mcp.json");
|
|
59525
59284
|
const mcpConfig = renderRunMcpConfig(runId, config2);
|
|
59526
|
-
|
|
59285
|
+
writeFileSync9(mcpConfigPath, JSON.stringify(mcpConfig, null, 2), "utf8");
|
|
59527
59286
|
return {
|
|
59528
59287
|
dir,
|
|
59529
59288
|
mcp: { path: mcpConfigPath, config: mcpConfig },
|
|
@@ -59552,6 +59311,11 @@ async function runBranchGates(ctx, ticket, deps) {
|
|
|
59552
59311
|
};
|
|
59553
59312
|
}
|
|
59554
59313
|
try {
|
|
59314
|
+
const reused = await ctx.reuseGates?.(ticket.id, sha).catch(() => {
|
|
59315
|
+
return;
|
|
59316
|
+
});
|
|
59317
|
+
if (reused)
|
|
59318
|
+
return reused;
|
|
59555
59319
|
const runGates = deps.runGates ?? (await Promise.resolve().then(() => (init_review_gates2(), exports_review_gates))).runReviewGates;
|
|
59556
59320
|
return await runGates({ config: deps.config, project: project3, ticketId: ticket.id, sha });
|
|
59557
59321
|
} catch (err) {
|
|
@@ -59606,7 +59370,7 @@ async function reviewTicketOutcome(ctx, ticket, deps, timer) {
|
|
|
59606
59370
|
VERIFIES_PASS: verifies ? `#${verifies.seq} \xB7 ${inheritedMode === "drive" ? "Drive" : "Gates"} mode` : "no earlier review in this run \xB7 Gates mode",
|
|
59607
59371
|
AUTO_FIX_CAP: String(AUTO_FIX_CAP)
|
|
59608
59372
|
});
|
|
59609
|
-
|
|
59373
|
+
mkdirSync11(logsDir(), { recursive: true });
|
|
59610
59374
|
const throttle = createStreamThrottle((e) => ctx.emitEvent({ ...e, ticketId: ticket.id }));
|
|
59611
59375
|
beginTranscript(ticket.id);
|
|
59612
59376
|
const ticketAbort = registerTicketAbort(ticket.id);
|
|
@@ -59709,13 +59473,13 @@ async function reviewTicketOutcome(ctx, ticket, deps, timer) {
|
|
|
59709
59473
|
};
|
|
59710
59474
|
}
|
|
59711
59475
|
function couldNotReview(ticket, reason, digest) {
|
|
59712
|
-
const
|
|
59476
|
+
const headline = `Review could not run: ${reason}`;
|
|
59713
59477
|
return {
|
|
59714
59478
|
status: "failed",
|
|
59715
|
-
error: `ticket ${ticket.seq}: ${
|
|
59479
|
+
error: `ticket ${ticket.seq}: ${headline}`,
|
|
59716
59480
|
digest: digest ? `${digest}
|
|
59717
59481
|
|
|
59718
|
-
**${
|
|
59482
|
+
**${headline}**` : `**${headline}**`
|
|
59719
59483
|
};
|
|
59720
59484
|
}
|
|
59721
59485
|
var FFMPEG_BIN = "ffmpeg", spawnVersion = (path2) => {
|
|
@@ -59740,10 +59504,10 @@ var init_review_ticket = __esm(() => {
|
|
|
59740
59504
|
withheldDrives = new Map;
|
|
59741
59505
|
DECLARATION = /(?:^|\n)REVIEW-MODE:\s*(drive|gates)\s*\nREVIEW-VERDICT:\s*(verified|unverified)\b(?:\s*\nREVIEW-REASON:[ \t]*([^\r\n]*))?/i;
|
|
59742
59506
|
REVIEW_DIRECTORY_FS = {
|
|
59743
|
-
mkdir:
|
|
59507
|
+
mkdir: mkdirSync11,
|
|
59744
59508
|
readDir: readdirSync7,
|
|
59745
59509
|
rename: renameSync,
|
|
59746
|
-
remove:
|
|
59510
|
+
remove: rmSync3
|
|
59747
59511
|
};
|
|
59748
59512
|
});
|
|
59749
59513
|
|
|
@@ -60301,7 +60065,7 @@ var init_podman = __esm(() => {
|
|
|
60301
60065
|
});
|
|
60302
60066
|
|
|
60303
60067
|
// src/workflows/ticket-burner.ts
|
|
60304
|
-
import { existsSync as existsSync20, mkdirSync as
|
|
60068
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync12, readFileSync as readFileSync14, readdirSync as readdirSync8, rmSync as rmSync4 } from "fs";
|
|
60305
60069
|
import { dirname as dirname14, join as join25, posix as posixPath, win32 as winPath } from "path";
|
|
60306
60070
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
60307
60071
|
function missingImageRuntimeMessage(runtime5, image) {
|
|
@@ -60620,7 +60384,7 @@ function buildFixNotes(ticket) {
|
|
|
60620
60384
|
return [
|
|
60621
60385
|
"### This ticket fixes a review finding",
|
|
60622
60386
|
"",
|
|
60623
|
-
"It was minted from a defect the review of this same lap reported, and its `context` carries the reviewer's repro step verbatim. **Before you declare done, re-run that repro step exactly, and say in your digest that you re-ran it and what happened.** Nothing reviews your change afterwards \u2014 that repro step is the check, and the
|
|
60387
|
+
"It was minted from a defect the review of this same lap reported, and its `context` carries the reviewer's repro step verbatim. **Before you declare done, re-run that repro step exactly, and say in your digest that you re-ran it and what happened.** Nothing reviews your change afterwards \u2014 that repro step is the check, and the host's gates run on top of it. If the defect is a failed gate, re-run exactly the check that failed, narrowed to what failed (the failing test files, or the failing command), and say in your digest that you did; never the full suite."
|
|
60624
60388
|
].join(`
|
|
60625
60389
|
`);
|
|
60626
60390
|
}
|
|
@@ -60793,7 +60557,7 @@ function takeSetupMarker(worktreePath) {
|
|
|
60793
60557
|
} catch {
|
|
60794
60558
|
return;
|
|
60795
60559
|
}
|
|
60796
|
-
|
|
60560
|
+
rmSync4(file, { force: true });
|
|
60797
60561
|
return parseSetupMarker(text3);
|
|
60798
60562
|
}
|
|
60799
60563
|
function fmtSeconds(ms) {
|
|
@@ -60886,7 +60650,7 @@ function buildAttachmentCopyCommands(sources, platform = process.platform) {
|
|
|
60886
60650
|
];
|
|
60887
60651
|
}
|
|
60888
60652
|
async function clearAttachments(workspacePath, repoPath) {
|
|
60889
|
-
|
|
60653
|
+
rmSync4(join25(workspacePath, ATTACHMENTS_DIR), { recursive: true, force: true });
|
|
60890
60654
|
await unexcludePath(repoPath, ATTACHMENTS_PREFIX);
|
|
60891
60655
|
}
|
|
60892
60656
|
function buildVerifyNotes(config2) {
|
|
@@ -60894,15 +60658,15 @@ function buildVerifyNotes(config2) {
|
|
|
60894
60658
|
const failures2 = config2.knownFailures?.trim();
|
|
60895
60659
|
const out = [];
|
|
60896
60660
|
if (commands) {
|
|
60897
|
-
out.push("
|
|
60661
|
+
out.push("The host runs these commands once, in full, at the end of the round. They are correct for this repo, so use them to learn the right tools and workspace/package filter names rather than guessing \u2014 but do NOT run them whole. Run the static check (typecheck or its equivalent) once across the project, and narrow the tests to the files that cover your change:", "", "```", commands, "```");
|
|
60898
60662
|
} else {
|
|
60899
|
-
out.push("No verification commands are configured, so derive
|
|
60663
|
+
out.push("No verification commands are configured, so derive the static-check and test commands ONCE from the repo (root `package.json` scripts, the workspace's own manifest, CI config) \u2014 reading a manifest is free, discovering a filter name by running the wrong suite is not. Then run the static check once across the project and the tests narrowed to the files that cover your change; never the whole suite. Reuse the commands verbatim for the rest of the ticket.");
|
|
60900
60664
|
}
|
|
60901
60665
|
out.push("");
|
|
60902
60666
|
if (failures2) {
|
|
60903
|
-
out.push("These tests ALREADY fail on this repo before you touch anything:", "", "```", failures2, "```", "", "Treat that as your baseline \u2014 do NOT spend a run establishing it yourself. Only a failure outside this set is yours to fix; if you hit one that looks pre-existing but is not listed, confirm it on a single targeted run of that one test, never a whole-suite re-run.");
|
|
60667
|
+
out.push("These tests ALREADY fail on this repo before you touch anything:", "", "```", failures2, "```", "", "Treat that as your baseline \u2014 do NOT spend a run establishing it yourself. A failing test in a targeted run that is in this list is not yours. Only a failure outside this set is yours to fix; if you hit one that looks pre-existing but is not listed, confirm it on a single targeted run of that one test, never a whole-suite re-run.");
|
|
60904
60668
|
} else {
|
|
60905
|
-
out.push("No pre-existing-failure baseline is configured
|
|
60669
|
+
out.push("No pre-existing-failure baseline is configured, and you do not run the whole suite to build one. If a targeted test fails and looks unrelated to your change, confirm it ONCE against the pre-change code (`git show <base>:<path>`, where `<base>` is the commit your branch started from, or a detached scratch worktree at it) \u2014 never with a full run.");
|
|
60906
60670
|
}
|
|
60907
60671
|
return out.join(`
|
|
60908
60672
|
`);
|
|
@@ -61221,8 +60985,8 @@ function delayUnlessAborted(ms, signal) {
|
|
|
61221
60985
|
function stopTicketRun(ticketId) {
|
|
61222
60986
|
return abortTicketRun(ticketId, new Error("ticket stopped by user"));
|
|
61223
60987
|
}
|
|
61224
|
-
function haltTicketRun(ticketId,
|
|
61225
|
-
return abortTicketRun(ticketId, new RunHaltedAbort(
|
|
60988
|
+
function haltTicketRun(ticketId, headline) {
|
|
60989
|
+
return abortTicketRun(ticketId, new RunHaltedAbort(headline));
|
|
61226
60990
|
}
|
|
61227
60991
|
function ticketStopReason(reason) {
|
|
61228
60992
|
return reason instanceof RunHaltedAbort ? `stopped: run halted (${reason.headline})` : "stopped by user";
|
|
@@ -61954,7 +61718,7 @@ async function burnTicket(ctx, ticket, config2, token, model, hostAgentVersions,
|
|
|
61954
61718
|
const mounts = [...cache.mounts];
|
|
61955
61719
|
for (const mount of cache.mounts) {
|
|
61956
61720
|
if ("hostPath" in mount)
|
|
61957
|
-
|
|
61721
|
+
mkdirSync12(mount.hostPath, { recursive: true });
|
|
61958
61722
|
}
|
|
61959
61723
|
const codexAuthMount = codexAuthMountFor(model.runtime, config2.sandbox);
|
|
61960
61724
|
if (codexAuthMount)
|
|
@@ -61964,7 +61728,7 @@ async function burnTicket(ctx, ticket, config2, token, model, hostAgentVersions,
|
|
|
61964
61728
|
const agentOptions = guardInstalled ? { bypassHookTrust: true } : {};
|
|
61965
61729
|
const slotStamp = buildSlotStamp(resolveSandboxImage(config2, project3), toolchain.packageManagerField);
|
|
61966
61730
|
const setupHookFor = (branch) => withPrelude(slot !== undefined ? buildSlotSetupCommand(slot, branch, setupCommand, pm, slotStamp) : workspaceMode === "isolated" ? buildIsolatedSetupCommand(branch, setupCommand, pm) : setupCommand);
|
|
61967
|
-
|
|
61731
|
+
mkdirSync12(logsDir(), { recursive: true });
|
|
61968
61732
|
const logFilePath = join25(logsDir(), `burn-${feature.id}-${ticket.seq}.log`);
|
|
61969
61733
|
const throttle = createStreamThrottle((e) => ctx.emitEvent({ ...e, ticketId: ticket.id }));
|
|
61970
61734
|
beginTranscript(ticket.id);
|
|
@@ -62304,22 +62068,22 @@ ${retryNotes}` : basePrompt,
|
|
|
62304
62068
|
}
|
|
62305
62069
|
const verdict = classifyTicketRunError(err, model.runtime, setupCommand);
|
|
62306
62070
|
if (verdict === "retryable" && attempt < maxAttempts) {
|
|
62307
|
-
const
|
|
62071
|
+
const headline = errorHeadline(msg);
|
|
62308
62072
|
retryNotes = buildRetryNotes({
|
|
62309
|
-
error:
|
|
62073
|
+
error: headline,
|
|
62310
62074
|
commitCount: salvaged.length,
|
|
62311
62075
|
lastCommand: lastCommand.last()
|
|
62312
62076
|
});
|
|
62313
62077
|
ctx.emitEvent({
|
|
62314
62078
|
type: "ticket.retrying",
|
|
62315
|
-
message: `ticket ${ticket.seq} attempt ${attempt}/${maxAttempts} died (${
|
|
62079
|
+
message: `ticket ${ticket.seq} attempt ${attempt}/${maxAttempts} died (${headline}) \u2014 retrying${salvaged.length > 0 ? ` from ${salvaged.length} preserved commit(s)` : ""}`,
|
|
62316
62080
|
ticketId: ticket.id,
|
|
62317
62081
|
data: { attempt, maxAttempts, error: msg, preservedCommits: salvaged.length }
|
|
62318
62082
|
});
|
|
62319
62083
|
appendTranscript(ticket.id, {
|
|
62320
62084
|
kind: "text",
|
|
62321
62085
|
text: `
|
|
62322
|
-
\u2014 attempt ${attempt} interrupted (${
|
|
62086
|
+
\u2014 attempt ${attempt} interrupted (${headline}); starting attempt ${attempt + 1}${salvaged.length > 0 ? " with committed work preserved" : ""} \u2014
|
|
62323
62087
|
`
|
|
62324
62088
|
});
|
|
62325
62089
|
await delayUnlessAborted(retryDelayMs(attempt), signal);
|
|
@@ -62632,9 +62396,9 @@ var init_ticket_burner = __esm(() => {
|
|
|
62632
62396
|
activeTicketAborts = new Map;
|
|
62633
62397
|
RunHaltedAbort = class RunHaltedAbort extends Error {
|
|
62634
62398
|
headline;
|
|
62635
|
-
constructor(
|
|
62636
|
-
super(`ticket stopped: run halted (${
|
|
62637
|
-
this.headline =
|
|
62399
|
+
constructor(headline) {
|
|
62400
|
+
super(`ticket stopped: run halted (${headline})`);
|
|
62401
|
+
this.headline = headline;
|
|
62638
62402
|
this.name = "RunHaltedAbort";
|
|
62639
62403
|
}
|
|
62640
62404
|
};
|
|
@@ -62645,6 +62409,316 @@ var init_ticket_burner = __esm(() => {
|
|
|
62645
62409
|
};
|
|
62646
62410
|
});
|
|
62647
62411
|
|
|
62412
|
+
// src/workflows/review-gates.ts
|
|
62413
|
+
var exports_review_gates = {};
|
|
62414
|
+
__export(exports_review_gates, {
|
|
62415
|
+
withThrowawayBranch: () => withThrowawayBranch,
|
|
62416
|
+
timeoutReason: () => timeoutReason,
|
|
62417
|
+
runReviewGates: () => runReviewGates,
|
|
62418
|
+
reviewGateBranch: () => reviewGateBranch,
|
|
62419
|
+
parseVerifyCommands: () => parseVerifyCommands,
|
|
62420
|
+
headline: () => headline,
|
|
62421
|
+
execWithTimeout: () => execWithTimeout,
|
|
62422
|
+
errorText: () => errorText,
|
|
62423
|
+
errorDetail: () => errorDetail,
|
|
62424
|
+
burnGateSandbox: () => burnGateSandbox,
|
|
62425
|
+
SandboxSetupError: () => SandboxSetupError,
|
|
62426
|
+
GATE_COMMAND_TIMEOUT_MS: () => GATE_COMMAND_TIMEOUT_MS
|
|
62427
|
+
});
|
|
62428
|
+
import { mkdirSync as mkdirSync13, rmSync as rmSync5, writeFileSync as writeFileSync10 } from "fs";
|
|
62429
|
+
import { stripVTControlCharacters as stripVTControlCharacters2 } from "util";
|
|
62430
|
+
function reviewGateBranch(ticketId) {
|
|
62431
|
+
return `runcastle/gates/${ticketId}`;
|
|
62432
|
+
}
|
|
62433
|
+
function parseVerifyCommands(verifyCommands) {
|
|
62434
|
+
return (verifyCommands ?? "").split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
62435
|
+
}
|
|
62436
|
+
function errorText(err) {
|
|
62437
|
+
return err instanceof Error ? err.message : String(err);
|
|
62438
|
+
}
|
|
62439
|
+
function errorDetail(err) {
|
|
62440
|
+
if (err instanceof SandboxSetupError)
|
|
62441
|
+
return `${err.message}
|
|
62442
|
+
|
|
62443
|
+
${stripVTControlCharacters2(err.output)}`;
|
|
62444
|
+
return err instanceof Error ? err.stack ?? err.message : String(err);
|
|
62445
|
+
}
|
|
62446
|
+
function headline(text3) {
|
|
62447
|
+
return text3.split(/\r?\n/).find((line) => line.trim())?.trim() ?? "unknown error";
|
|
62448
|
+
}
|
|
62449
|
+
async function withThrowawayBranch(repoPath, branch, sha, use) {
|
|
62450
|
+
const discardBranch = async () => {
|
|
62451
|
+
await cleanupBurnWorktree(repoPath, branch);
|
|
62452
|
+
await deleteTempBranch(repoPath, branch);
|
|
62453
|
+
};
|
|
62454
|
+
try {
|
|
62455
|
+
await discardBranch();
|
|
62456
|
+
await pinBranchAt(repoPath, branch, sha);
|
|
62457
|
+
await excludeBurnWorktrees(repoPath);
|
|
62458
|
+
return await use();
|
|
62459
|
+
} finally {
|
|
62460
|
+
await discardBranch();
|
|
62461
|
+
}
|
|
62462
|
+
}
|
|
62463
|
+
async function execWithTimeout(sandbox3, command, timeoutMs) {
|
|
62464
|
+
let timer;
|
|
62465
|
+
const timedOut = new Promise((done10) => {
|
|
62466
|
+
timer = setTimeout(() => done10("timeout"), timeoutMs);
|
|
62467
|
+
});
|
|
62468
|
+
try {
|
|
62469
|
+
return await Promise.race([sandbox3.exec(command), timedOut]);
|
|
62470
|
+
} finally {
|
|
62471
|
+
clearTimeout(timer);
|
|
62472
|
+
}
|
|
62473
|
+
}
|
|
62474
|
+
async function runSandboxSetup(exec3, setup, timeoutMs) {
|
|
62475
|
+
const streamed = [];
|
|
62476
|
+
const result = await execWithTimeout({ exec: (command) => exec3(command, { onLine: (line) => streamed.push(line) }) }, setup, timeoutMs);
|
|
62477
|
+
if (result === "timeout") {
|
|
62478
|
+
throw new SandboxSetupError(`the sync-and-install setup ${timeoutReason(timeoutMs)}`, streamed.join(`
|
|
62479
|
+
`));
|
|
62480
|
+
}
|
|
62481
|
+
if (result.exitCode !== 0) {
|
|
62482
|
+
throw new SandboxSetupError(`the sync-and-install setup exited ${result.exitCode}`, [result.stdout, result.stderr].filter(Boolean).join(`
|
|
62483
|
+
`));
|
|
62484
|
+
}
|
|
62485
|
+
}
|
|
62486
|
+
function timeoutReason(timeoutMs) {
|
|
62487
|
+
return `timed out after ${Math.round(timeoutMs / 60000)} minutes`;
|
|
62488
|
+
}
|
|
62489
|
+
async function runReviewGates(input) {
|
|
62490
|
+
const { config: config2, project: project3, ticketId, sha } = input;
|
|
62491
|
+
const commands = parseVerifyCommands(resolvePreparedSettings(config2, project3).verifyCommands);
|
|
62492
|
+
if (commands.length === 0)
|
|
62493
|
+
return { status: "none_configured" };
|
|
62494
|
+
const withSandbox = input.deps?.withSandbox ?? burnGateSandbox(config2, project3);
|
|
62495
|
+
const timeoutMs = input.deps?.commandTimeoutMs ?? GATE_COMMAND_TIMEOUT_MS;
|
|
62496
|
+
const branch = reviewGateBranch(ticketId);
|
|
62497
|
+
const results = [];
|
|
62498
|
+
try {
|
|
62499
|
+
rmSync5(reviewGateLogDir(ticketId), { recursive: true, force: true });
|
|
62500
|
+
mkdirSync13(reviewGateLogDir(ticketId), { recursive: true });
|
|
62501
|
+
await withThrowawayBranch(project3.repoPath, branch, sha, async () => {
|
|
62502
|
+
while (results.length < commands.length) {
|
|
62503
|
+
await withSandbox(branch, async (sandbox3) => {
|
|
62504
|
+
for (const [i, command] of commands.entries()) {
|
|
62505
|
+
if (i < results.length)
|
|
62506
|
+
continue;
|
|
62507
|
+
const { result, stillRunning } = await runGateCommand(sandbox3, command, ticketId, `${i}.log`, timeoutMs);
|
|
62508
|
+
results.push(result);
|
|
62509
|
+
if (stillRunning)
|
|
62510
|
+
return;
|
|
62511
|
+
}
|
|
62512
|
+
});
|
|
62513
|
+
}
|
|
62514
|
+
});
|
|
62515
|
+
return { status: "ran", commit: sha, commands: results };
|
|
62516
|
+
} catch (err) {
|
|
62517
|
+
if (results.length > 0) {
|
|
62518
|
+
const detail = errorDetail(err);
|
|
62519
|
+
const reason = `the gate sandbox could not be reopened: ${headline(errorText(err))}`;
|
|
62520
|
+
for (const [i, command] of commands.entries()) {
|
|
62521
|
+
if (i < results.length)
|
|
62522
|
+
continue;
|
|
62523
|
+
writeFileSync10(reviewGateLogPath(ticketId, `${i}.log`), `${detail}
|
|
62524
|
+
`);
|
|
62525
|
+
results.push({ command, outcome: "couldnt_run", exitCode: null, reason, log: `${i}.log` });
|
|
62526
|
+
}
|
|
62527
|
+
return { status: "ran", commit: sha, commands: results };
|
|
62528
|
+
}
|
|
62529
|
+
return {
|
|
62530
|
+
status: "couldnt_run",
|
|
62531
|
+
commit: sha,
|
|
62532
|
+
reason: `the gate sandbox could not be set up: ${headline(errorText(err))}`,
|
|
62533
|
+
log: writeRunLog(ticketId, err)
|
|
62534
|
+
};
|
|
62535
|
+
}
|
|
62536
|
+
}
|
|
62537
|
+
function writeRunLog(ticketId, err) {
|
|
62538
|
+
try {
|
|
62539
|
+
writeFileSync10(reviewGateLogPath(ticketId, "run.log"), `${errorDetail(err)}
|
|
62540
|
+
`);
|
|
62541
|
+
return "run.log";
|
|
62542
|
+
} catch {
|
|
62543
|
+
return null;
|
|
62544
|
+
}
|
|
62545
|
+
}
|
|
62546
|
+
async function runGateCommand(sandbox3, command, ticketId, log6, timeoutMs) {
|
|
62547
|
+
const logPath = reviewGateLogPath(ticketId, log6);
|
|
62548
|
+
try {
|
|
62549
|
+
const result = await execWithTimeout(sandbox3, command, timeoutMs);
|
|
62550
|
+
if (result === "timeout") {
|
|
62551
|
+
const reason = timeoutReason(timeoutMs);
|
|
62552
|
+
writeFileSync10(logPath, `${reason}
|
|
62553
|
+
`);
|
|
62554
|
+
return {
|
|
62555
|
+
result: { command, outcome: "couldnt_run", exitCode: null, reason, log: log6 },
|
|
62556
|
+
stillRunning: true
|
|
62557
|
+
};
|
|
62558
|
+
}
|
|
62559
|
+
writeFileSync10(logPath, [result.stdout, result.stderr].filter(Boolean).join(`
|
|
62560
|
+
`));
|
|
62561
|
+
return {
|
|
62562
|
+
result: result.exitCode === 0 ? { command, outcome: "passed", exitCode: 0, log: log6 } : { command, outcome: "failed", exitCode: result.exitCode, log: log6 },
|
|
62563
|
+
stillRunning: false
|
|
62564
|
+
};
|
|
62565
|
+
} catch (err) {
|
|
62566
|
+
const reason = `could not start: ${headline(errorText(err))}`;
|
|
62567
|
+
writeFileSync10(logPath, `${errorText(err)}
|
|
62568
|
+
`);
|
|
62569
|
+
return {
|
|
62570
|
+
result: { command, outcome: "couldnt_run", exitCode: null, reason, log: log6 },
|
|
62571
|
+
stillRunning: false
|
|
62572
|
+
};
|
|
62573
|
+
}
|
|
62574
|
+
}
|
|
62575
|
+
function burnGateSandbox(config2, project3, deps = {}) {
|
|
62576
|
+
const open3 = deps.open ?? createSandbox;
|
|
62577
|
+
const setupTimeoutMs = deps.setupTimeoutMs ?? SETUP_HOOK_TIMEOUT_MS;
|
|
62578
|
+
return (branch, use) => {
|
|
62579
|
+
const allocator = resolveBurnCacheMode(config2) === "volume" ? getBurnSlotAllocator(config2.burnConcurrency) : undefined;
|
|
62580
|
+
return withBurnCacheSlot(allocator, async (slot) => {
|
|
62581
|
+
if (slot !== undefined) {
|
|
62582
|
+
await ensureBurnCacheVolume({
|
|
62583
|
+
engine: config2.sandbox === "podman" ? "podman" : "docker",
|
|
62584
|
+
imageName: resolveSandboxImage(config2, project3),
|
|
62585
|
+
projectId: project3.id,
|
|
62586
|
+
exec: createSystemExec({ cwd: project3.repoPath })
|
|
62587
|
+
});
|
|
62588
|
+
}
|
|
62589
|
+
const workspaceMode = resolveBurnWorkspaceMode(slot === undefined ? { ...config2, burnCache: "off" } : config2);
|
|
62590
|
+
const toolchain = readRepoToolchain(project3.repoPath);
|
|
62591
|
+
const pm = detectPackageManager(toolchain);
|
|
62592
|
+
const setupCommand = resolveSetupCommand(toolchain, resolvePreparedSettings(config2, project3).setupCommand);
|
|
62593
|
+
const cache = buildBurnCacheMounts(slot, project3.id, config2.sandbox, pm);
|
|
62594
|
+
const onHost2 = config2.sandbox === "noSandbox";
|
|
62595
|
+
for (const mount of cache.mounts) {
|
|
62596
|
+
if ("hostPath" in mount)
|
|
62597
|
+
mkdirSync13(mount.hostPath, { recursive: true });
|
|
62598
|
+
}
|
|
62599
|
+
const setup = slot !== undefined ? buildSlotSetupCommand(slot, branch, setupCommand, pm, buildSlotStamp(resolveSandboxImage(config2, project3), toolchain.packageManagerField)) : workspaceMode === "isolated" ? buildIsolatedSetupCommand(branch, setupCommand, pm) : setupCommand;
|
|
62600
|
+
const cwd = slot !== undefined ? slotRepoPath(slot) : workspaceMode === "isolated" ? ISOLATED_REPO_PATH : undefined;
|
|
62601
|
+
const lane = branch;
|
|
62602
|
+
const sandbox3 = await open3({
|
|
62603
|
+
branch,
|
|
62604
|
+
sandbox: selectSandbox(config2, project3, cache.mounts, cache.env, {
|
|
62605
|
+
onChildSpawn: registerHostChildren(lane, {})
|
|
62606
|
+
}),
|
|
62607
|
+
cwd: project3.repoPath
|
|
62608
|
+
});
|
|
62609
|
+
let running3 = 0;
|
|
62610
|
+
const exec3 = async (command, opts) => {
|
|
62611
|
+
running3++;
|
|
62612
|
+
try {
|
|
62613
|
+
return await sandbox3.exec(command, opts);
|
|
62614
|
+
} finally {
|
|
62615
|
+
running3--;
|
|
62616
|
+
}
|
|
62617
|
+
};
|
|
62618
|
+
try {
|
|
62619
|
+
if (setup) {
|
|
62620
|
+
const script = onHost2 ? setup : `git config --global --add safe.directory '*' && ${setup}`;
|
|
62621
|
+
await runSandboxSetup(exec3, script, setupTimeoutMs);
|
|
62622
|
+
}
|
|
62623
|
+
return await use({
|
|
62624
|
+
exec: (command) => exec3(command, cwd ? { cwd } : {})
|
|
62625
|
+
});
|
|
62626
|
+
} finally {
|
|
62627
|
+
if (running3 > 0)
|
|
62628
|
+
await killRegistry().killAndWait(lane);
|
|
62629
|
+
killRegistry().release(lane);
|
|
62630
|
+
await sandbox3.close();
|
|
62631
|
+
}
|
|
62632
|
+
});
|
|
62633
|
+
};
|
|
62634
|
+
}
|
|
62635
|
+
var GATE_COMMAND_TIMEOUT_MS, SandboxSetupError;
|
|
62636
|
+
var init_review_gates2 = __esm(() => {
|
|
62637
|
+
init_dist();
|
|
62638
|
+
init_src();
|
|
62639
|
+
init_paths();
|
|
62640
|
+
init_system_exec();
|
|
62641
|
+
init_git();
|
|
62642
|
+
init_burn_cache();
|
|
62643
|
+
init_kill_registry();
|
|
62644
|
+
init_ticket_burner();
|
|
62645
|
+
GATE_COMMAND_TIMEOUT_MS = SETUP_HOOK_TIMEOUT_MS;
|
|
62646
|
+
SandboxSetupError = class SandboxSetupError extends Error {
|
|
62647
|
+
output;
|
|
62648
|
+
constructor(message, output) {
|
|
62649
|
+
super(message);
|
|
62650
|
+
this.output = output;
|
|
62651
|
+
this.name = "SandboxSetupError";
|
|
62652
|
+
}
|
|
62653
|
+
};
|
|
62654
|
+
});
|
|
62655
|
+
|
|
62656
|
+
// src/workflows/gate-reuse.ts
|
|
62657
|
+
import { cpSync as cpSync2, existsSync as existsSync21, mkdirSync as mkdirSync14, rmSync as rmSync6 } from "fs";
|
|
62658
|
+
function pickReusableGates(candidates, commands, unmoved) {
|
|
62659
|
+
return [...candidates].sort((a, b) => b.at - a.at).find((c) => c.gates.status === "ran" && c.gates.commands.every((r) => r.outcome !== "couldnt_run") && c.gates.commands.length === commands.length && c.gates.commands.every((r, i) => r.command === commands[i]) && unmoved(c.gates.commit));
|
|
62660
|
+
}
|
|
62661
|
+
function onlyFeatureDocs(paths, slug) {
|
|
62662
|
+
const prefix = `${featureDocsRel(slug)}/`;
|
|
62663
|
+
return paths.every((p) => p.startsWith(prefix));
|
|
62664
|
+
}
|
|
62665
|
+
async function reuseGateResult(input) {
|
|
62666
|
+
const { ctx, config: config2, project: project3, feature, ownerId, sha } = input;
|
|
62667
|
+
try {
|
|
62668
|
+
const { parseVerifyCommands: parseVerifyCommands2 } = await Promise.resolve().then(() => (init_review_gates2(), exports_review_gates));
|
|
62669
|
+
const commands = parseVerifyCommands2(resolvePreparedSettings(config2, project3).verifyCommands);
|
|
62670
|
+
if (commands.length === 0)
|
|
62671
|
+
return;
|
|
62672
|
+
const candidates = [];
|
|
62673
|
+
for (const run7 of listRunsByFeature(ctx, feature.id)) {
|
|
62674
|
+
if (run7.gates && run7.id !== ownerId) {
|
|
62675
|
+
candidates.push({ kind: "round", id: run7.id, at: run7.endedAt ?? run7.startedAt, gates: run7.gates });
|
|
62676
|
+
}
|
|
62677
|
+
}
|
|
62678
|
+
for (const t of listByFeature(ctx, feature.id)) {
|
|
62679
|
+
if (t.kind === "review" && t.reviewGateRun && t.id !== ownerId) {
|
|
62680
|
+
candidates.push({ kind: "review", id: t.id, at: t.completedAt ?? Date.now(), gates: t.reviewGateRun });
|
|
62681
|
+
}
|
|
62682
|
+
}
|
|
62683
|
+
const verdicts = new Map;
|
|
62684
|
+
for (const c of candidates) {
|
|
62685
|
+
if (c.gates.status !== "ran" || verdicts.has(c.gates.commit))
|
|
62686
|
+
continue;
|
|
62687
|
+
const commit = c.gates.commit;
|
|
62688
|
+
if (commit === sha) {
|
|
62689
|
+
verdicts.set(commit, true);
|
|
62690
|
+
} else if (!await headSha(project3.repoPath, commit)) {
|
|
62691
|
+
verdicts.set(commit, false);
|
|
62692
|
+
} else {
|
|
62693
|
+
const paths = await diffPaths(project3.repoPath, commit, sha, { throwOnError: true }).catch(() => {
|
|
62694
|
+
return;
|
|
62695
|
+
});
|
|
62696
|
+
verdicts.set(commit, paths !== undefined && onlyFeatureDocs(paths, feature.slug));
|
|
62697
|
+
}
|
|
62698
|
+
}
|
|
62699
|
+
const hit = pickReusableGates(candidates, commands, (commit) => verdicts.get(commit) === true);
|
|
62700
|
+
if (!hit || hit.gates.status !== "ran")
|
|
62701
|
+
return;
|
|
62702
|
+
const from = reviewGateLogDir(hit.id);
|
|
62703
|
+
if (!existsSync21(from))
|
|
62704
|
+
return;
|
|
62705
|
+
const to = reviewGateLogDir(ownerId);
|
|
62706
|
+
rmSync6(to, { recursive: true, force: true });
|
|
62707
|
+
mkdirSync14(to, { recursive: true });
|
|
62708
|
+
cpSync2(from, to, { recursive: true });
|
|
62709
|
+
return { ...hit.gates, reusedFrom: { kind: hit.kind, id: hit.id } };
|
|
62710
|
+
} catch {
|
|
62711
|
+
return;
|
|
62712
|
+
}
|
|
62713
|
+
}
|
|
62714
|
+
var init_gate_reuse = __esm(() => {
|
|
62715
|
+
init_src();
|
|
62716
|
+
init_paths();
|
|
62717
|
+
init_git();
|
|
62718
|
+
init_repo();
|
|
62719
|
+
init_tickets();
|
|
62720
|
+
});
|
|
62721
|
+
|
|
62648
62722
|
// src/workflows/registry.ts
|
|
62649
62723
|
function getWorkflow(id3) {
|
|
62650
62724
|
return workflowRegistry.get(id3);
|
|
@@ -62725,6 +62799,7 @@ async function startRun(ctx, featureId, workflowId, opts = {}) {
|
|
|
62725
62799
|
addTicketTokens: (id3, usage2, sessionIds) => addTicketTokens(ctx, id3, usage2, sessionIds),
|
|
62726
62800
|
storeTickets: (inputs) => storeTickets(ctx, featureId, inputs),
|
|
62727
62801
|
listFindings: () => listByFeature2(ctx, featureId),
|
|
62802
|
+
reuseGates: (ownerId, sha) => reuseGateResult({ ctx, config: ctx.config, project: project3, feature, ownerId, sha }),
|
|
62728
62803
|
updateFinding: (findingId, progress, reason) => {
|
|
62729
62804
|
markFixProgress(ctx, findingId, progress, reason);
|
|
62730
62805
|
},
|
|
@@ -62747,7 +62822,9 @@ async function endRound(ctx, runId, featureId, runGates) {
|
|
|
62747
62822
|
const project3 = projectForFeature(ctx, feature);
|
|
62748
62823
|
let gates;
|
|
62749
62824
|
try {
|
|
62750
|
-
|
|
62825
|
+
const sha = await headSha(project3.repoPath, feature.branch);
|
|
62826
|
+
const reused = sha ? await reuseGateResult({ ctx, config: ctx.config, project: project3, feature, ownerId: runId, sha }) : undefined;
|
|
62827
|
+
gates = reused ?? await runGates({ ctx, project: project3, feature, runId });
|
|
62751
62828
|
} catch (err) {
|
|
62752
62829
|
gates = {
|
|
62753
62830
|
status: "couldnt_run",
|
|
@@ -62857,6 +62934,7 @@ var init_runner = __esm(() => {
|
|
|
62857
62934
|
init_tickets();
|
|
62858
62935
|
init_usage2();
|
|
62859
62936
|
init_kill_registry();
|
|
62937
|
+
init_gate_reuse();
|
|
62860
62938
|
init_registry2();
|
|
62861
62939
|
controllers = new Map;
|
|
62862
62940
|
BRANCH_CLAIMING = new Set(["ticket-burner"]);
|
|
@@ -62917,7 +62995,7 @@ var init_prep = __esm(() => {
|
|
|
62917
62995
|
});
|
|
62918
62996
|
|
|
62919
62997
|
// src/services/project-notes.ts
|
|
62920
|
-
import { existsSync as
|
|
62998
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync15, rmSync as rmSync7, writeFileSync as writeFileSync11 } from "fs";
|
|
62921
62999
|
import { and as and11, count as count3, desc as desc6, eq as eq14, inArray as inArray8 } from "drizzle-orm";
|
|
62922
63000
|
function rowToNote(row) {
|
|
62923
63001
|
return ProjectNote.parse({
|
|
@@ -62926,7 +63004,7 @@ function rowToNote(row) {
|
|
|
62926
63004
|
featureId: row.featureId ?? undefined,
|
|
62927
63005
|
driveBranch: row.driveBranch ?? undefined,
|
|
62928
63006
|
driveCommit: row.driveCommit ?? undefined,
|
|
62929
|
-
screenshotUrl:
|
|
63007
|
+
screenshotUrl: existsSync22(projectNotePath(row.id)) ? projectNoteScreenshotUrl(row.id) : undefined
|
|
62930
63008
|
});
|
|
62931
63009
|
}
|
|
62932
63010
|
function clean(value, label) {
|
|
@@ -62982,7 +63060,7 @@ function deleteNote(ctx, noteId) {
|
|
|
62982
63060
|
const note2 = getNote(ctx, noteId);
|
|
62983
63061
|
requireOpen(note2, "delete");
|
|
62984
63062
|
ctx.db.delete(projectNotes).where(eq14(projectNotes.id, noteId)).run();
|
|
62985
|
-
|
|
63063
|
+
rmSync7(projectNotePath(noteId), { force: true });
|
|
62986
63064
|
emitProject(ctx, note2.projectId, { type: "project_note.deleted", message: "project note deleted", data: { noteId } });
|
|
62987
63065
|
}
|
|
62988
63066
|
function triage(ctx, noteIds, outcome, featureId, verb = "triaged") {
|
|
@@ -63024,7 +63102,7 @@ function reopenNote(ctx, noteId) {
|
|
|
63024
63102
|
}
|
|
63025
63103
|
function attachScreenshot(ctx, noteId, png) {
|
|
63026
63104
|
const note2 = getNote(ctx, noteId);
|
|
63027
|
-
|
|
63105
|
+
mkdirSync15(projectNotesDir(), { recursive: true });
|
|
63028
63106
|
writeFileSync11(projectNotePath(note2.id), png);
|
|
63029
63107
|
emitProject(ctx, note2.projectId, { type: "project_note.screenshot", message: "screenshot attached to project note", data: { noteId } });
|
|
63030
63108
|
return getNote(ctx, noteId);
|
|
@@ -63590,7 +63668,7 @@ var init_conversations = __esm(() => {
|
|
|
63590
63668
|
});
|
|
63591
63669
|
|
|
63592
63670
|
// src/services/main-chat-excerpt.ts
|
|
63593
|
-
import { mkdirSync as
|
|
63671
|
+
import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync12 } from "fs";
|
|
63594
63672
|
import { join as join27 } from "path";
|
|
63595
63673
|
function trimTurn(text3) {
|
|
63596
63674
|
const t = text3.trim();
|
|
@@ -63644,7 +63722,7 @@ function mainChatContext(ctx, feature, sessionId, base) {
|
|
|
63644
63722
|
const tooLong = quote.length > EXCERPT_INLINE_MAX_CHARS || base.length + quote.length + 1000 > MAX_KICKOFF_ARGV;
|
|
63645
63723
|
if (tooLong) {
|
|
63646
63724
|
const dir = sessionDir(sessionId);
|
|
63647
|
-
|
|
63725
|
+
mkdirSync16(dir, { recursive: true });
|
|
63648
63726
|
const file = join27(dir, "main-chat-excerpt.md");
|
|
63649
63727
|
writeFileSync12(file, `${quote}
|
|
63650
63728
|
`, "utf8");
|
|
@@ -63814,7 +63892,7 @@ var init_untouched = __esm(() => {
|
|
|
63814
63892
|
});
|
|
63815
63893
|
|
|
63816
63894
|
// src/launcher/launcher.ts
|
|
63817
|
-
import { existsSync as
|
|
63895
|
+
import { existsSync as existsSync23 } from "fs";
|
|
63818
63896
|
import { join as join28 } from "path";
|
|
63819
63897
|
import { and as and13, eq as eq16 } from "drizzle-orm";
|
|
63820
63898
|
function ptyExitMessage(exitCode) {
|
|
@@ -64480,7 +64558,7 @@ async function launchScenarioSession(ctx, input, opts = {}) {
|
|
|
64480
64558
|
});
|
|
64481
64559
|
return { sessionId: docked.id };
|
|
64482
64560
|
}
|
|
64483
|
-
const setup = !
|
|
64561
|
+
const setup = !existsSync23(join28(project3.repoPath, ".runcastle", "scenarios"));
|
|
64484
64562
|
const model = resolveModelEntry("prepare", rosterConfig(ctx), project3);
|
|
64485
64563
|
const runtime5 = runtimeAdapterFor(model.runtime);
|
|
64486
64564
|
assertRuntimeReady(runtime5, opts);
|
|
@@ -64688,7 +64766,7 @@ async function buildPrepareBrief(ctx, project3) {
|
|
|
64688
64766
|
};
|
|
64689
64767
|
}
|
|
64690
64768
|
function probePrepareHost(repoPath) {
|
|
64691
|
-
const has4 = (rel) =>
|
|
64769
|
+
const has4 = (rel) => existsSync23(join28(repoPath, rel));
|
|
64692
64770
|
const lock = LOCKFILES.find(([file]) => has4(file));
|
|
64693
64771
|
return {
|
|
64694
64772
|
platform: process.platform,
|
|
@@ -65040,9 +65118,10 @@ function gatesLine(gates) {
|
|
|
65040
65118
|
if (gates.status === "couldnt_run")
|
|
65041
65119
|
return `Gates: could not run \u2014 ${gates.reason}`;
|
|
65042
65120
|
const failed = gates.commands.filter((c) => c.outcome !== "passed");
|
|
65121
|
+
const reused = gates.reusedFrom ? ` (not re-run: the branch had not moved since commit ${gates.commit.slice(0, 7)}, where they ran)` : "";
|
|
65043
65122
|
if (failed.length === 0)
|
|
65044
|
-
return `Gates: all ${gates.commands.length} verify command(s) passed.`;
|
|
65045
|
-
return `Gates: FAILED \u2014 ${failed.map((c) => `\`${c.command}\` (${c.outcome})`).join(", ")}.`;
|
|
65123
|
+
return `Gates: all ${gates.commands.length} verify command(s) passed${reused}.`;
|
|
65124
|
+
return `Gates: FAILED${reused} \u2014 ${failed.map((c) => `\`${c.command}\` (${c.outcome})`).join(", ")}.`;
|
|
65046
65125
|
}
|
|
65047
65126
|
function composeRoundWake(ctx, featureId, runId) {
|
|
65048
65127
|
const run7 = getRunRow(ctx, runId);
|
|
@@ -65095,7 +65174,7 @@ var init_lead_delivery = __esm(() => {
|
|
|
65095
65174
|
|
|
65096
65175
|
// src/services/features.ts
|
|
65097
65176
|
import { asc as asc6, desc as desc8, eq as eq17, or } from "drizzle-orm";
|
|
65098
|
-
import { rmSync as
|
|
65177
|
+
import { rmSync as rmSync8 } from "fs";
|
|
65099
65178
|
async function createFeature(ctx, input) {
|
|
65100
65179
|
const project3 = requireProjectById(ctx, input.projectId);
|
|
65101
65180
|
const slug = uniqueSlug(ctx, project3.id, input.title);
|
|
@@ -65545,7 +65624,7 @@ async function deleteFeature(ctx, featureId) {
|
|
|
65545
65624
|
}
|
|
65546
65625
|
for (const s of listSessionsByFeature(ctx, featureId)) {
|
|
65547
65626
|
try {
|
|
65548
|
-
|
|
65627
|
+
rmSync8(sessionDir(s.id), { recursive: true, force: true });
|
|
65549
65628
|
} catch {}
|
|
65550
65629
|
}
|
|
65551
65630
|
deleteFeatureRows(ctx, featureId);
|
|
@@ -65595,7 +65674,7 @@ var init_features = __esm(() => {
|
|
|
65595
65674
|
});
|
|
65596
65675
|
|
|
65597
65676
|
// src/services/test-notes.ts
|
|
65598
|
-
import { existsSync as
|
|
65677
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync17, rmSync as rmSync9, writeFileSync as writeFileSync13 } from "fs";
|
|
65599
65678
|
import { asc as asc7, eq as eq18, inArray as inArray10 } from "drizzle-orm";
|
|
65600
65679
|
function rowToNote2(row) {
|
|
65601
65680
|
return TestNote.parse({
|
|
@@ -65607,7 +65686,7 @@ function rowToNote2(row) {
|
|
|
65607
65686
|
ticketId: row.ticketId ?? undefined,
|
|
65608
65687
|
reviewTicketId: row.reviewTicketId ?? undefined,
|
|
65609
65688
|
videoTimestamp: row.videoTimestamp ?? undefined,
|
|
65610
|
-
screenshotUrl:
|
|
65689
|
+
screenshotUrl: existsSync24(annotationPath(row.id)) ? noteScreenshotUrl(row.id) : undefined,
|
|
65611
65690
|
sentAt: row.sentAt ?? undefined,
|
|
65612
65691
|
createdAt: row.createdAt,
|
|
65613
65692
|
updatedAt: row.updatedAt
|
|
@@ -65671,7 +65750,7 @@ function editNote2(ctx, noteId, text3) {
|
|
|
65671
65750
|
function deleteNote2(ctx, noteId) {
|
|
65672
65751
|
const current2 = getNote2(ctx, noteId);
|
|
65673
65752
|
ctx.db.delete(testNotes).where(eq18(testNotes.id, noteId)).run();
|
|
65674
|
-
|
|
65753
|
+
rmSync9(annotationPath(noteId), { force: true });
|
|
65675
65754
|
emit(ctx, current2.featureId, {
|
|
65676
65755
|
type: "note.deleted",
|
|
65677
65756
|
message: "note deleted",
|
|
@@ -65680,7 +65759,7 @@ function deleteNote2(ctx, noteId) {
|
|
|
65680
65759
|
}
|
|
65681
65760
|
function attachScreenshot2(ctx, noteId, png) {
|
|
65682
65761
|
const note2 = getNote2(ctx, noteId);
|
|
65683
|
-
|
|
65762
|
+
mkdirSync17(annotationsDir(), { recursive: true });
|
|
65684
65763
|
writeFileSync13(annotationPath(noteId), png);
|
|
65685
65764
|
emit(ctx, note2.featureId, {
|
|
65686
65765
|
type: "note.screenshot",
|
|
@@ -65771,7 +65850,7 @@ var init_drive_call = __esm(() => {
|
|
|
65771
65850
|
});
|
|
65772
65851
|
|
|
65773
65852
|
// src/services/outcome.ts
|
|
65774
|
-
import { mkdirSync as
|
|
65853
|
+
import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync14 } from "fs";
|
|
65775
65854
|
import { join as join29 } from "path";
|
|
65776
65855
|
function digestHasSubstance(text3) {
|
|
65777
65856
|
return text3.split(`
|
|
@@ -65863,7 +65942,7 @@ async function promoteOutcomeDoc(ctx, project3, feature, target, delta) {
|
|
|
65863
65942
|
});
|
|
65864
65943
|
await onBranch(project3.repoPath, target, async () => {
|
|
65865
65944
|
const docsDir = join29(project3.repoPath, ...featureDocsRel(feature.slug).split("/"));
|
|
65866
|
-
|
|
65945
|
+
mkdirSync18(docsDir, { recursive: true });
|
|
65867
65946
|
writeFileSync14(join29(docsDir, "outcome.md"), doc, "utf8");
|
|
65868
65947
|
await commitDocs(project3.repoPath, docsCommitMessage(`outcome for ${feature.slug}`, project3.docsCommitPrefix));
|
|
65869
65948
|
});
|
|
@@ -65983,7 +66062,7 @@ var init_merge = __esm(() => {
|
|
|
65983
66062
|
});
|
|
65984
66063
|
|
|
65985
66064
|
// src/mcp/orchestrator-tools.ts
|
|
65986
|
-
import { existsSync as
|
|
66065
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync19, readFileSync as readFileSync16, writeFileSync as writeFileSync15 } from "fs";
|
|
65987
66066
|
import { dirname as dirname15 } from "path";
|
|
65988
66067
|
import { and as and14, eq as eq19 } from "drizzle-orm";
|
|
65989
66068
|
import * as z6 from "zod";
|
|
@@ -66143,12 +66222,12 @@ var init_orchestrator_tools = __esm(() => {
|
|
|
66143
66222
|
}
|
|
66144
66223
|
const project3 = projectForFeature(ctx, feature);
|
|
66145
66224
|
const worktree = worktreeDir(project3.id, feature.slug);
|
|
66146
|
-
if (!
|
|
66225
|
+
if (!existsSync25(worktree)) {
|
|
66147
66226
|
throw new GateError(`\`${feature.slug}\` has no worktree to write its brief in.`);
|
|
66148
66227
|
}
|
|
66149
66228
|
const briefPath = featureDocPath(project3, feature, "brief.md");
|
|
66150
|
-
const prior =
|
|
66151
|
-
|
|
66229
|
+
const prior = existsSync25(briefPath) ? readFileSync16(briefPath, "utf8") : "";
|
|
66230
|
+
mkdirSync19(dirname15(briefPath), { recursive: true });
|
|
66152
66231
|
writeFileSync15(briefPath, withBriefSection(prior, text3), "utf8");
|
|
66153
66232
|
await commitDocs(worktree, docsCommitMessage(`add to ${feature.slug} brief`, project3.docsCommitPrefix));
|
|
66154
66233
|
await landChatCommits(ctx, project3, feature);
|
|
@@ -66225,7 +66304,7 @@ function serializedLength(result) {
|
|
|
66225
66304
|
var MCP_READ_CEILING_CHARS = 60000;
|
|
66226
66305
|
|
|
66227
66306
|
// src/mcp/server.ts
|
|
66228
|
-
import { existsSync as
|
|
66307
|
+
import { existsSync as existsSync26, readFileSync as readFileSync17 } from "fs";
|
|
66229
66308
|
import { join as join30, relative as relative4, resolve as resolve11, sep as sep2 } from "path";
|
|
66230
66309
|
import { StreamableHTTPTransport } from "@hono/mcp";
|
|
66231
66310
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -66981,7 +67060,7 @@ function toolReadAdr(ctx, session, input) {
|
|
|
66981
67060
|
if (rel === "" || rel.startsWith("..") || rel.split(sep2).includes("..")) {
|
|
66982
67061
|
throw new InvalidInputError(`adr path escapes ${ADR_DIR_REL}: ${input.relPath}`);
|
|
66983
67062
|
}
|
|
66984
|
-
if (!
|
|
67063
|
+
if (!existsSync26(target))
|
|
66985
67064
|
throw new NotFoundError(`adr not found: ${input.relPath}`);
|
|
66986
67065
|
return { relPath: `${ADR_DIR_REL}/${name}`, content: readFileSync17(target, "utf8") };
|
|
66987
67066
|
}
|
|
@@ -67011,7 +67090,7 @@ function toolReadFeatureBrief(ctx, session, input) {
|
|
|
67011
67090
|
if (!feature)
|
|
67012
67091
|
throw new NotFoundError(`feature not found: ${input.slug}`);
|
|
67013
67092
|
const onDisk = join30(session.worktreePath, featureDocsRel(feature.slug), "brief.md");
|
|
67014
|
-
const brief = feature.status === "shipped" &&
|
|
67093
|
+
const brief = feature.status === "shipped" && existsSync26(onDisk) ? readFileSync17(onDisk, "utf8") : feature.brief;
|
|
67015
67094
|
return {
|
|
67016
67095
|
slug: feature.slug,
|
|
67017
67096
|
title: feature.title,
|
|
@@ -68699,7 +68778,7 @@ var init_stream = __esm(() => {
|
|
|
68699
68778
|
});
|
|
68700
68779
|
|
|
68701
68780
|
// src/routes/web.ts
|
|
68702
|
-
import { existsSync as
|
|
68781
|
+
import { existsSync as existsSync27, statSync as statSync7 } from "fs";
|
|
68703
68782
|
import { readFile as readFile5 } from "fs/promises";
|
|
68704
68783
|
import { extname, join as join31, normalize as normalize2, resolve as resolve13, sep as sep3 } from "path";
|
|
68705
68784
|
function contentType(path2) {
|
|
@@ -68752,7 +68831,7 @@ function mountWebApp(app, distDir) {
|
|
|
68752
68831
|
}
|
|
68753
68832
|
function mountWebAppIfBuilt(app) {
|
|
68754
68833
|
const dist = resolveWebDist();
|
|
68755
|
-
if (
|
|
68834
|
+
if (existsSync27(join31(dist, "index.html")))
|
|
68756
68835
|
mountWebApp(app, dist);
|
|
68757
68836
|
}
|
|
68758
68837
|
var MIME;
|
|
@@ -68803,18 +68882,18 @@ var init_version = () => {};
|
|
|
68803
68882
|
|
|
68804
68883
|
// src/services/install-id.ts
|
|
68805
68884
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
68806
|
-
import { existsSync as
|
|
68885
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync20, readFileSync as readFileSync19, writeFileSync as writeFileSync16 } from "fs";
|
|
68807
68886
|
import { dirname as dirname17 } from "path";
|
|
68808
68887
|
function getInstallId() {
|
|
68809
68888
|
const file = installIdPath();
|
|
68810
68889
|
try {
|
|
68811
|
-
if (
|
|
68890
|
+
if (existsSync28(file)) {
|
|
68812
68891
|
const existing = readFileSync19(file, "utf8").trim();
|
|
68813
68892
|
if (UUID_RE.test(existing))
|
|
68814
68893
|
return existing;
|
|
68815
68894
|
}
|
|
68816
68895
|
const id3 = randomUUID3();
|
|
68817
|
-
|
|
68896
|
+
mkdirSync20(dirname17(file), { recursive: true });
|
|
68818
68897
|
writeFileSync16(file, `${id3}
|
|
68819
68898
|
`);
|
|
68820
68899
|
return id3;
|
|
@@ -68985,7 +69064,7 @@ var init_context = __esm(() => {
|
|
|
68985
69064
|
});
|
|
68986
69065
|
|
|
68987
69066
|
// src/services/design-crop.ts
|
|
68988
|
-
import { mkdirSync as
|
|
69067
|
+
import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync17 } from "fs";
|
|
68989
69068
|
import { join as join35 } from "path";
|
|
68990
69069
|
function cropMessage(path2, text3) {
|
|
68991
69070
|
return `[Screenshot: ${path2}] ${text3.replace(/\s*[\r\n]+\s*/g, " ").trim()}`.trimEnd();
|
|
@@ -68996,7 +69075,7 @@ function sendDesignCrop(ctx, featureId, png, text3) {
|
|
|
68996
69075
|
if (!chat)
|
|
68997
69076
|
throw new GateError(NO_LIVE_CHAT);
|
|
68998
69077
|
const dir = designCropsDir(featureId);
|
|
68999
|
-
|
|
69078
|
+
mkdirSync21(dir, { recursive: true });
|
|
69000
69079
|
const path2 = join35(dir, `${Date.now()}.png`);
|
|
69001
69080
|
writeFileSync17(path2, png);
|
|
69002
69081
|
if (!writeToLiveTerminal(chat.id, cropMessage(path2, text3)))
|
|
@@ -69194,7 +69273,7 @@ var init_drive_prerequisites = __esm(() => {
|
|
|
69194
69273
|
});
|
|
69195
69274
|
|
|
69196
69275
|
// src/services/fsbrowse.ts
|
|
69197
|
-
import { existsSync as
|
|
69276
|
+
import { existsSync as existsSync29, readdirSync as readdirSync9, statSync as statSync8 } from "fs";
|
|
69198
69277
|
import { homedir as homedir4 } from "os";
|
|
69199
69278
|
import { basename as basename5, dirname as dirname18, isAbsolute as isAbsolute4, join as join36, resolve as resolve14, sep as sep4 } from "path";
|
|
69200
69279
|
function expandPath(input, home = homedir4()) {
|
|
@@ -69210,7 +69289,7 @@ function expandPath(input, home = homedir4()) {
|
|
|
69210
69289
|
}
|
|
69211
69290
|
function looksLikeRepo(dir) {
|
|
69212
69291
|
try {
|
|
69213
|
-
return
|
|
69292
|
+
return existsSync29(join36(dir, ".git"));
|
|
69214
69293
|
} catch {
|
|
69215
69294
|
return false;
|
|
69216
69295
|
}
|
|
@@ -69221,20 +69300,20 @@ function listRoots(home = homedir4()) {
|
|
|
69221
69300
|
for (let code = 67;code <= 90; code++) {
|
|
69222
69301
|
const drive = `${String.fromCharCode(code)}:${sep4}`;
|
|
69223
69302
|
try {
|
|
69224
|
-
if (
|
|
69303
|
+
if (existsSync29(drive))
|
|
69225
69304
|
roots3.push({ label: drive.replace(/\\$/, ""), path: drive, kind: "drive" });
|
|
69226
69305
|
} catch {}
|
|
69227
69306
|
}
|
|
69228
69307
|
} else {
|
|
69229
69308
|
roots3.push({ label: "/", path: "/", kind: "drive" });
|
|
69230
69309
|
}
|
|
69231
|
-
if (
|
|
69310
|
+
if (existsSync29(home))
|
|
69232
69311
|
roots3.push({ label: "Home", path: home, kind: "home" });
|
|
69233
69312
|
const seen = new Set(roots3.map(pathKey));
|
|
69234
69313
|
for (const name of COMMON_DIRS) {
|
|
69235
69314
|
const candidate = join36(home, name);
|
|
69236
69315
|
const key = pathKey({ path: candidate });
|
|
69237
|
-
if (seen.has(key) || !
|
|
69316
|
+
if (seen.has(key) || !existsSync29(candidate))
|
|
69238
69317
|
continue;
|
|
69239
69318
|
seen.add(key);
|
|
69240
69319
|
roots3.push({ label: name, path: candidate, kind: "common" });
|
|
@@ -69265,7 +69344,7 @@ function browseDir(input, showHidden = false, home = homedir4()) {
|
|
|
69265
69344
|
if (!isAbsolute4(target)) {
|
|
69266
69345
|
throw new InvalidInputError(`path is not absolute: ${target}`);
|
|
69267
69346
|
}
|
|
69268
|
-
if (!
|
|
69347
|
+
if (!existsSync29(target)) {
|
|
69269
69348
|
throw new InvalidInputError(`path does not exist: ${target}`);
|
|
69270
69349
|
}
|
|
69271
69350
|
let dir = target;
|
|
@@ -69330,7 +69409,7 @@ var init_fsbrowse = __esm(() => {
|
|
|
69330
69409
|
});
|
|
69331
69410
|
|
|
69332
69411
|
// src/services/projects.ts
|
|
69333
|
-
import { existsSync as
|
|
69412
|
+
import { existsSync as existsSync30 } from "fs";
|
|
69334
69413
|
import { basename as basename6, join as join37 } from "path";
|
|
69335
69414
|
import { eq as eq20, isNull } from "drizzle-orm";
|
|
69336
69415
|
function listProjects(ctx) {
|
|
@@ -69415,7 +69494,7 @@ async function assertRepoTolerant(ctx, repoPath) {
|
|
|
69415
69494
|
} catch (e) {
|
|
69416
69495
|
if (!isNotImplemented(e))
|
|
69417
69496
|
throw e;
|
|
69418
|
-
if (!
|
|
69497
|
+
if (!existsSync30(join37(repoPath, ".git"))) {
|
|
69419
69498
|
throw new InvalidInputError(`not a git repository: ${repoPath}`);
|
|
69420
69499
|
}
|
|
69421
69500
|
}
|
|
@@ -69561,12 +69640,12 @@ var init_settings2 = __esm(() => {
|
|
|
69561
69640
|
});
|
|
69562
69641
|
|
|
69563
69642
|
// src/doctor/afk-env.ts
|
|
69564
|
-
import { existsSync as
|
|
69643
|
+
import { existsSync as existsSync31, readFileSync as readFileSync20 } from "fs";
|
|
69565
69644
|
function envWithAfkCredentials() {
|
|
69566
69645
|
const merged = { ...process.env };
|
|
69567
69646
|
try {
|
|
69568
69647
|
const path2 = envPath();
|
|
69569
|
-
if (
|
|
69648
|
+
if (existsSync31(path2)) {
|
|
69570
69649
|
const fromFile = parseEnvFile3(readFileSync20(path2, "utf8"));
|
|
69571
69650
|
for (const runtime5 of AGENT_RUNTIMES) {
|
|
69572
69651
|
const key = RUNTIME_SPECS[runtime5].afkKey;
|