@orbit-build/cli 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +385 -215
- package/package.json +1 -1
- package/skills/math-model-draft/SKILL.md +18 -0
- package/skills/math-model-draft/assets/project-template/paper/AI/345/267/245/345/205/267/344/275/277/347/224/250/350/257/246/346/203/205.tex +1 -0
- package/skills/math-model-draft/assets/project-template/paper/main.tex +5 -0
- package/skills/math-model-draft/scripts/audit_paper.py +73 -16
- package/skills/math-model-draft/scripts/build_paper.py +4 -1
- package/skills/math-model-draft/scripts/evidence_freeze.py +107 -0
- package/skills/math-model-draft/scripts/finalize_project.py +8 -0
- package/skills/math-model-draft/scripts/inspect_inputs.py +63 -18
- package/skills/math-model-draft/scripts/package_support.py +4 -0
- package/skills/math-model-draft/scripts/validate_project.py +22 -3
package/dist/index.js
CHANGED
|
@@ -28461,9 +28461,9 @@ ${lanes.join("\n")}
|
|
|
28461
28461
|
path6,
|
|
28462
28462
|
data,
|
|
28463
28463
|
!!writeBom,
|
|
28464
|
-
(
|
|
28465
|
-
(
|
|
28466
|
-
(
|
|
28464
|
+
(path24, data2, writeByteOrderMark) => originalWriteFile.call(sys2, path24, data2, writeByteOrderMark),
|
|
28465
|
+
(path24) => sys2.createDirectory(path24),
|
|
28466
|
+
(path24) => sys2.directoryExists(path24)
|
|
28467
28467
|
);
|
|
28468
28468
|
}
|
|
28469
28469
|
var sys = (() => {
|
|
@@ -42938,13 +42938,13 @@ ${lanes.join("\n")}
|
|
|
42938
42938
|
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
|
|
42939
42939
|
}
|
|
42940
42940
|
return flatten(results);
|
|
42941
|
-
function visitDirectory(
|
|
42941
|
+
function visitDirectory(path24, absolutePath, depth2) {
|
|
42942
42942
|
const canonicalPath = toCanonical(realpath(absolutePath));
|
|
42943
42943
|
if (visited.has(canonicalPath)) return;
|
|
42944
42944
|
visited.set(canonicalPath, true);
|
|
42945
|
-
const { files, directories } = getFileSystemEntries(
|
|
42945
|
+
const { files, directories } = getFileSystemEntries(path24);
|
|
42946
42946
|
for (const current of toSorted(files, compareStringsCaseSensitive)) {
|
|
42947
|
-
const name = combinePaths(
|
|
42947
|
+
const name = combinePaths(path24, current);
|
|
42948
42948
|
const absoluteName = combinePaths(absolutePath, current);
|
|
42949
42949
|
if (extensions && !fileExtensionIsOneOf(name, extensions)) continue;
|
|
42950
42950
|
if (excludeRegex && excludeRegex.test(absoluteName)) continue;
|
|
@@ -42964,7 +42964,7 @@ ${lanes.join("\n")}
|
|
|
42964
42964
|
}
|
|
42965
42965
|
}
|
|
42966
42966
|
for (const current of toSorted(directories, compareStringsCaseSensitive)) {
|
|
42967
|
-
const name = combinePaths(
|
|
42967
|
+
const name = combinePaths(path24, current);
|
|
42968
42968
|
const absoluteName = combinePaths(absolutePath, current);
|
|
42969
42969
|
if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) {
|
|
42970
42970
|
visitDirectory(name, absoluteName, depth2);
|
|
@@ -43225,10 +43225,10 @@ ${lanes.join("\n")}
|
|
|
43225
43225
|
const match = str.match(/\//g);
|
|
43226
43226
|
return match ? match.length : 0;
|
|
43227
43227
|
}
|
|
43228
|
-
function compareNumberOfDirectorySeparators(path1,
|
|
43228
|
+
function compareNumberOfDirectorySeparators(path1, path24) {
|
|
43229
43229
|
return compareValues(
|
|
43230
43230
|
numberOfDirectorySeparators(path1),
|
|
43231
|
-
numberOfDirectorySeparators(
|
|
43231
|
+
numberOfDirectorySeparators(path24)
|
|
43232
43232
|
);
|
|
43233
43233
|
}
|
|
43234
43234
|
var extensionsToRemove = [
|
|
@@ -65889,12 +65889,12 @@ ${lanes.join("\n")}
|
|
|
65889
65889
|
const includeRe = patterns.includeFilePattern && getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames);
|
|
65890
65890
|
if (includeRe) {
|
|
65891
65891
|
if (excludeRe) {
|
|
65892
|
-
return (
|
|
65892
|
+
return (path24) => !(includeRe.test(path24) && !excludeRe.test(path24));
|
|
65893
65893
|
}
|
|
65894
|
-
return (
|
|
65894
|
+
return (path24) => !includeRe.test(path24);
|
|
65895
65895
|
}
|
|
65896
65896
|
if (excludeRe) {
|
|
65897
|
-
return (
|
|
65897
|
+
return (path24) => excludeRe.test(path24);
|
|
65898
65898
|
}
|
|
65899
65899
|
return returnTrue;
|
|
65900
65900
|
}
|
|
@@ -66692,7 +66692,7 @@ ${lanes.join("\n")}
|
|
|
66692
66692
|
if (extendedConfigCache && (value = extendedConfigCache.get(path6))) {
|
|
66693
66693
|
({ extendedResult, extendedConfig } = value);
|
|
66694
66694
|
} else {
|
|
66695
|
-
extendedResult = readJsonConfigFile(extendedConfigPath, (
|
|
66695
|
+
extendedResult = readJsonConfigFile(extendedConfigPath, (path24) => host.readFile(path24));
|
|
66696
66696
|
if (!extendedResult.parseDiagnostics.length) {
|
|
66697
66697
|
extendedConfig = parseConfig(
|
|
66698
66698
|
/*json*/
|
|
@@ -67345,9 +67345,9 @@ ${lanes.join("\n")}
|
|
|
67345
67345
|
return typeRoots;
|
|
67346
67346
|
}
|
|
67347
67347
|
var nodeModulesAtTypes = combinePaths("node_modules", "@types");
|
|
67348
|
-
function arePathsEqual(path1,
|
|
67348
|
+
function arePathsEqual(path1, path24, host) {
|
|
67349
67349
|
const useCaseSensitiveFileNames2 = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames;
|
|
67350
|
-
return comparePaths(path1,
|
|
67350
|
+
return comparePaths(path1, path24, !useCaseSensitiveFileNames2) === 0;
|
|
67351
67351
|
}
|
|
67352
67352
|
function getOriginalAndResolvedFileName(fileName, host, traceEnabled) {
|
|
67353
67353
|
const resolvedFileName = realPath(fileName, host, traceEnabled);
|
|
@@ -69603,9 +69603,9 @@ ${lanes.join("\n")}
|
|
|
69603
69603
|
}
|
|
69604
69604
|
const extension = tryGetExtensionFromPath2(subst);
|
|
69605
69605
|
if (extension !== void 0) {
|
|
69606
|
-
const
|
|
69607
|
-
if (
|
|
69608
|
-
return noPackageId({ path:
|
|
69606
|
+
const path24 = tryFile(candidate, onlyRecordFailures, state);
|
|
69607
|
+
if (path24 !== void 0) {
|
|
69608
|
+
return noPackageId({ path: path24, ext: extension, resolvedUsingTsExtension: void 0 });
|
|
69609
69609
|
}
|
|
69610
69610
|
}
|
|
69611
69611
|
return loader(extensions, candidate, onlyRecordFailures || !directoryProbablyExists(getDirectoryPath(candidate), state.host), state);
|
|
@@ -162090,7 +162090,7 @@ ${lanes.join("\n")}
|
|
|
162090
162090
|
const watcher = fileWatchesOfAffectingLocations.get(path6);
|
|
162091
162091
|
if (watcher == null ? void 0 : watcher.resolutions) (affectingPathChecks ?? (affectingPathChecks = /* @__PURE__ */ new Set())).add(path6);
|
|
162092
162092
|
if (watcher == null ? void 0 : watcher.files) (affectingPathChecksForFile ?? (affectingPathChecksForFile = /* @__PURE__ */ new Set())).add(path6);
|
|
162093
|
-
(_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((
|
|
162093
|
+
(_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((path24) => invalidateAffectingFileWatcher(path24, packageJsonMap));
|
|
162094
162094
|
packageJsonMap == null ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path6));
|
|
162095
162095
|
}
|
|
162096
162096
|
function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
|
|
@@ -197548,12 +197548,12 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
197548
197548
|
];
|
|
197549
197549
|
}
|
|
197550
197550
|
return patternWorker(path6, pattern, initializer, dotDotDotToken, { tabstop: 1 });
|
|
197551
|
-
function patternWorker(
|
|
197551
|
+
function patternWorker(path24, pattern2, initializer2, dotDotDotToken2, counter) {
|
|
197552
197552
|
if (isObjectBindingPattern(pattern2) && !dotDotDotToken2) {
|
|
197553
197553
|
const oldTabstop = counter.tabstop;
|
|
197554
197554
|
const childCounter = { tabstop: oldTabstop };
|
|
197555
197555
|
const rootParam = getJSDocParamAnnotation(
|
|
197556
|
-
|
|
197556
|
+
path24,
|
|
197557
197557
|
initializer2,
|
|
197558
197558
|
dotDotDotToken2,
|
|
197559
197559
|
isJs,
|
|
@@ -197567,7 +197567,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
197567
197567
|
);
|
|
197568
197568
|
let childTags = [];
|
|
197569
197569
|
for (const element of pattern2.elements) {
|
|
197570
|
-
const elementTags = elementWorker(
|
|
197570
|
+
const elementTags = elementWorker(path24, element, childCounter);
|
|
197571
197571
|
if (!elementTags) {
|
|
197572
197572
|
childTags = void 0;
|
|
197573
197573
|
break;
|
|
@@ -197582,7 +197582,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
197582
197582
|
}
|
|
197583
197583
|
return [
|
|
197584
197584
|
getJSDocParamAnnotation(
|
|
197585
|
-
|
|
197585
|
+
path24,
|
|
197586
197586
|
initializer2,
|
|
197587
197587
|
dotDotDotToken2,
|
|
197588
197588
|
isJs,
|
|
@@ -197596,13 +197596,13 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
197596
197596
|
)
|
|
197597
197597
|
];
|
|
197598
197598
|
}
|
|
197599
|
-
function elementWorker(
|
|
197599
|
+
function elementWorker(path24, element, counter) {
|
|
197600
197600
|
if (!element.propertyName && isIdentifier(element.name) || isIdentifier(element.name)) {
|
|
197601
197601
|
const propertyName = element.propertyName ? tryGetTextOfPropertyName(element.propertyName) : element.name.text;
|
|
197602
197602
|
if (!propertyName) {
|
|
197603
197603
|
return void 0;
|
|
197604
197604
|
}
|
|
197605
|
-
const paramName = `${
|
|
197605
|
+
const paramName = `${path24}.${propertyName}`;
|
|
197606
197606
|
return [
|
|
197607
197607
|
getJSDocParamAnnotation(
|
|
197608
197608
|
paramName,
|
|
@@ -197620,7 +197620,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
197620
197620
|
];
|
|
197621
197621
|
} else if (element.propertyName) {
|
|
197622
197622
|
const propertyName = tryGetTextOfPropertyName(element.propertyName);
|
|
197623
|
-
return propertyName && patternWorker(`${
|
|
197623
|
+
return propertyName && patternWorker(`${path24}.${propertyName}`, element.name, element.initializer, element.dotDotDotToken, counter);
|
|
197624
197624
|
}
|
|
197625
197625
|
return void 0;
|
|
197626
197626
|
}
|
|
@@ -222740,12 +222740,12 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
222740
222740
|
project.markAutoImportProviderAsDirty();
|
|
222741
222741
|
} else {
|
|
222742
222742
|
if (project.initialLoadPending) {
|
|
222743
|
-
(_b = (_a = this.configFileExistenceInfoCache.get(projectCanonicalPath)) == null ? void 0 : _a.openFilesImpactedByConfigFile) == null ? void 0 : _b.forEach((
|
|
222743
|
+
(_b = (_a = this.configFileExistenceInfoCache.get(projectCanonicalPath)) == null ? void 0 : _a.openFilesImpactedByConfigFile) == null ? void 0 : _b.forEach((path24) => {
|
|
222744
222744
|
var _a2;
|
|
222745
|
-
if (!((_a2 = this.pendingOpenFileProjectUpdates) == null ? void 0 : _a2.has(
|
|
222745
|
+
if (!((_a2 = this.pendingOpenFileProjectUpdates) == null ? void 0 : _a2.has(path24))) {
|
|
222746
222746
|
(this.pendingOpenFileProjectUpdates ?? (this.pendingOpenFileProjectUpdates = /* @__PURE__ */ new Map())).set(
|
|
222747
|
-
|
|
222748
|
-
this.configFileForOpenFiles.get(
|
|
222747
|
+
path24,
|
|
222748
|
+
this.configFileForOpenFiles.get(path24)
|
|
222749
222749
|
);
|
|
222750
222750
|
}
|
|
222751
222751
|
});
|
|
@@ -238026,6 +238026,8 @@ function localizeOrbit(language, english, simplifiedChinese, traditionalChinese)
|
|
|
238026
238026
|
return language === "zh" ? simplifiedChinese : english;
|
|
238027
238027
|
}
|
|
238028
238028
|
var ORBIT_CONFIG_SCHEMA_VERSION = 1;
|
|
238029
|
+
var DEFAULT_AGENT_MAX_ITERATIONS = 64;
|
|
238030
|
+
var MAX_AGENT_MAX_ITERATIONS = 200;
|
|
238029
238031
|
var EnvironmentVariableNameSchema = z2.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/);
|
|
238030
238032
|
var HttpHeaderNameSchema = z2.string().max(256).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/);
|
|
238031
238033
|
var HttpHeaderValueSchema = z2.string().max(16384).refine((value) => !/[\r\n]/.test(value));
|
|
@@ -238284,8 +238286,8 @@ var ConfigSchema = z2.object({
|
|
|
238284
238286
|
testCommands: z2.array(z2.string().max(2e4)).max(100).default([])
|
|
238285
238287
|
}).default({}),
|
|
238286
238288
|
agent: z2.object({
|
|
238287
|
-
maxIterations: z2.number().int().min(1).max(
|
|
238288
|
-
fastMaxOutputTokens: z2.number().int().min(256).max(384e3).default(
|
|
238289
|
+
maxIterations: z2.number().int().min(1).max(MAX_AGENT_MAX_ITERATIONS).default(DEFAULT_AGENT_MAX_ITERATIONS),
|
|
238290
|
+
fastMaxOutputTokens: z2.number().int().min(256).max(384e3).default(32768),
|
|
238289
238291
|
maxOutputTokens: z2.number().int().min(256).max(384e3).default(16384),
|
|
238290
238292
|
teamPreset: z2.enum(["fast", "balanced", "thorough"]).default("balanced"),
|
|
238291
238293
|
maxReviewAttempts: z2.number().int().min(1).max(10).default(3),
|
|
@@ -238486,10 +238488,10 @@ var DEFAULT_CONFIG = {
|
|
|
238486
238488
|
testCommands: []
|
|
238487
238489
|
},
|
|
238488
238490
|
agent: {
|
|
238489
|
-
//
|
|
238490
|
-
//
|
|
238491
|
-
maxIterations:
|
|
238492
|
-
fastMaxOutputTokens:
|
|
238491
|
+
// Long enough for document, migration, and verification workflows; the
|
|
238492
|
+
// progress guard, periodic checkpoints, and budget still bound bad runs.
|
|
238493
|
+
maxIterations: DEFAULT_AGENT_MAX_ITERATIONS,
|
|
238494
|
+
fastMaxOutputTokens: 32768,
|
|
238493
238495
|
maxOutputTokens: 16384,
|
|
238494
238496
|
teamPreset: "balanced",
|
|
238495
238497
|
maxReviewAttempts: 3,
|
|
@@ -239988,7 +239990,7 @@ function runConfig(cwd) {
|
|
|
239988
239990
|
|
|
239989
239991
|
// src/commands/doctor.ts
|
|
239990
239992
|
import { execSync as execSync2 } from "child_process";
|
|
239991
|
-
import { existsSync as
|
|
239993
|
+
import { existsSync as existsSync12 } from "fs";
|
|
239992
239994
|
import { basename as basename3, join as join11 } from "path";
|
|
239993
239995
|
import picocolors6 from "picocolors";
|
|
239994
239996
|
import { z as z41 } from "zod";
|
|
@@ -243045,11 +243047,6 @@ function validateToolFinishReason(finishReason, toolCallCount) {
|
|
|
243045
243047
|
"DeepSeek reported a tool-call finish without returning a tool call."
|
|
243046
243048
|
);
|
|
243047
243049
|
}
|
|
243048
|
-
if (toolCallCount > 0 && finishReason !== "tool_calls") {
|
|
243049
|
-
throw new Error(
|
|
243050
|
-
"DeepSeek returned a tool call without the tool_calls finish reason."
|
|
243051
|
-
);
|
|
243052
|
-
}
|
|
243053
243050
|
}
|
|
243054
243051
|
function normalizeOfficialMaxTokens(value) {
|
|
243055
243052
|
if (value === void 0) return void 0;
|
|
@@ -244169,12 +244166,12 @@ function normalizeOllamaOpenAiBaseUrl(baseUrl) {
|
|
|
244169
244166
|
}
|
|
244170
244167
|
|
|
244171
244168
|
// src/runtime/CacheDiagnostics.ts
|
|
244172
|
-
import { existsSync as
|
|
244169
|
+
import { existsSync as existsSync11, readdirSync as readdirSync5 } from "fs";
|
|
244173
244170
|
import { join as join10 } from "path";
|
|
244174
244171
|
import picocolors4 from "picocolors";
|
|
244175
244172
|
|
|
244176
244173
|
// ../core/dist/index.js
|
|
244177
|
-
import { existsSync as
|
|
244174
|
+
import { existsSync as existsSync10, readdirSync as readdirSync4 } from "fs";
|
|
244178
244175
|
import { createHash as createHash5 } from "crypto";
|
|
244179
244176
|
import { join as join9 } from "path";
|
|
244180
244177
|
import { z as z30 } from "zod";
|
|
@@ -245799,9 +245796,11 @@ import { z as z14 } from "zod";
|
|
|
245799
245796
|
import glob2 from "fast-glob";
|
|
245800
245797
|
import { z as z15 } from "zod";
|
|
245801
245798
|
import { z as z16 } from "zod";
|
|
245802
|
-
import { z as z17 } from "zod";
|
|
245803
245799
|
import { existsSync as existsSync52 } from "fs";
|
|
245804
245800
|
import { join as join23 } from "path";
|
|
245801
|
+
import { z as z17 } from "zod";
|
|
245802
|
+
import { existsSync as existsSync6 } from "fs";
|
|
245803
|
+
import { join as join32 } from "path";
|
|
245805
245804
|
import { z as z19 } from "zod";
|
|
245806
245805
|
var import_ipaddr = __toESM(require_ipaddr(), 1);
|
|
245807
245806
|
import { lookup } from "dns/promises";
|
|
@@ -247411,6 +247410,53 @@ function readProcessFailureMessage(result) {
|
|
|
247411
247410
|
const message2 = typeof record.shortMessage === "string" ? record.shortMessage : typeof record.message === "string" ? record.message : "The child process failed.";
|
|
247412
247411
|
return safeProcessFailureMessage(message2);
|
|
247413
247412
|
}
|
|
247413
|
+
function firstExistingPath(candidates, pathExists2 = existsSync52) {
|
|
247414
|
+
for (const candidate of candidates) {
|
|
247415
|
+
if (candidate && pathExists2(candidate)) return candidate;
|
|
247416
|
+
}
|
|
247417
|
+
return null;
|
|
247418
|
+
}
|
|
247419
|
+
function resolveCommandShellInvocation(command, options = {}) {
|
|
247420
|
+
const platform = options.platform ?? process.platform;
|
|
247421
|
+
const environment = options.environment ?? process.env;
|
|
247422
|
+
const pathExists2 = options.pathExists ?? existsSync52;
|
|
247423
|
+
if (platform !== "win32") {
|
|
247424
|
+
const bash2 = firstExistingPath(
|
|
247425
|
+
[environment.ORBIT_BASH_PATH, "/bin/bash", "/usr/bin/bash"],
|
|
247426
|
+
pathExists2
|
|
247427
|
+
);
|
|
247428
|
+
if (bash2) {
|
|
247429
|
+
return {
|
|
247430
|
+
file: bash2,
|
|
247431
|
+
args: ["--noprofile", "--norc", "-c", command]
|
|
247432
|
+
};
|
|
247433
|
+
}
|
|
247434
|
+
return {
|
|
247435
|
+
file: "/bin/sh",
|
|
247436
|
+
args: ["-c", command]
|
|
247437
|
+
};
|
|
247438
|
+
}
|
|
247439
|
+
const bash = firstExistingPath(
|
|
247440
|
+
[
|
|
247441
|
+
environment.ORBIT_BASH_PATH,
|
|
247442
|
+
environment.ProgramFiles ? join23(environment.ProgramFiles, "Git", "bin", "bash.exe") : void 0,
|
|
247443
|
+
environment["ProgramFiles(x86)"] ? join23(environment["ProgramFiles(x86)"], "Git", "bin", "bash.exe") : void 0,
|
|
247444
|
+
environment.LOCALAPPDATA ? join23(environment.LOCALAPPDATA, "Programs", "Git", "bin", "bash.exe") : void 0,
|
|
247445
|
+
environment.LOCALAPPDATA ? join23(environment.LOCALAPPDATA, "hermes", "git", "bin", "bash.exe") : void 0
|
|
247446
|
+
],
|
|
247447
|
+
pathExists2
|
|
247448
|
+
);
|
|
247449
|
+
if (bash) {
|
|
247450
|
+
return {
|
|
247451
|
+
file: bash,
|
|
247452
|
+
args: ["--noprofile", "--norc", "-lc", command]
|
|
247453
|
+
};
|
|
247454
|
+
}
|
|
247455
|
+
return {
|
|
247456
|
+
file: environment.ComSpec?.trim() || "cmd.exe",
|
|
247457
|
+
args: ["/d", "/s", "/c", command]
|
|
247458
|
+
};
|
|
247459
|
+
}
|
|
247414
247460
|
var BashInputSchema = z16.object({
|
|
247415
247461
|
command: z16.string().min(1).max(1e5),
|
|
247416
247462
|
timeoutMs: z16.number().int().positive().optional(),
|
|
@@ -247463,9 +247509,9 @@ var BashTool = class {
|
|
|
247463
247509
|
}
|
|
247464
247510
|
}
|
|
247465
247511
|
try {
|
|
247466
|
-
const
|
|
247512
|
+
const invocation = resolveCommandShellInvocation(input.command);
|
|
247513
|
+
const result = await execa(invocation.file, invocation.args, {
|
|
247467
247514
|
...HIDDEN_CHILD_PROCESS_OPTIONS,
|
|
247468
|
-
shell: true,
|
|
247469
247515
|
cwd: ctx.cwd,
|
|
247470
247516
|
timeout,
|
|
247471
247517
|
reject: false,
|
|
@@ -247539,9 +247585,9 @@ var RunTestsTool = class {
|
|
|
247539
247585
|
const configuredTimeout = ctx.config?.tools?.bash?.timeoutMs;
|
|
247540
247586
|
const timeout = typeof configuredTimeout === "number" && Number.isFinite(configuredTimeout) ? Math.max(1e3, configuredTimeout) : 12e4;
|
|
247541
247587
|
try {
|
|
247542
|
-
const
|
|
247588
|
+
const invocation = resolveCommandShellInvocation(testCommand);
|
|
247589
|
+
const result = await execa(invocation.file, invocation.args, {
|
|
247543
247590
|
...HIDDEN_CHILD_PROCESS_OPTIONS,
|
|
247544
|
-
shell: true,
|
|
247545
247591
|
cwd: ctx.cwd,
|
|
247546
247592
|
reject: false,
|
|
247547
247593
|
signal: ctx.abortSignal,
|
|
@@ -247596,36 +247642,36 @@ Exit code: ${exitCode}`,
|
|
|
247596
247642
|
}
|
|
247597
247643
|
}
|
|
247598
247644
|
inferTestCommand(cwd) {
|
|
247599
|
-
if (
|
|
247645
|
+
if (existsSync6(join32(cwd, "Cargo.toml"))) {
|
|
247600
247646
|
return "cargo test";
|
|
247601
247647
|
}
|
|
247602
|
-
if (
|
|
247648
|
+
if (existsSync6(join32(cwd, "go.mod"))) {
|
|
247603
247649
|
return "go test ./...";
|
|
247604
247650
|
}
|
|
247605
|
-
if (
|
|
247651
|
+
if (existsSync6(join32(cwd, "pom.xml"))) {
|
|
247606
247652
|
return "mvn test";
|
|
247607
247653
|
}
|
|
247608
|
-
if (
|
|
247654
|
+
if (existsSync6(join32(cwd, "build.gradle"))) {
|
|
247609
247655
|
return "./gradlew test";
|
|
247610
247656
|
}
|
|
247611
|
-
if (
|
|
247657
|
+
if (existsSync6(join32(cwd, "package.json"))) {
|
|
247612
247658
|
try {
|
|
247613
247659
|
const raw = readBoundedRegularFile(
|
|
247614
|
-
|
|
247660
|
+
join32(cwd, "package.json"),
|
|
247615
247661
|
1024 * 1024
|
|
247616
247662
|
);
|
|
247617
247663
|
if (raw === void 0) return "npm test";
|
|
247618
247664
|
const pkg = JSON.parse(raw);
|
|
247619
247665
|
if (pkg.scripts?.test) {
|
|
247620
|
-
if (
|
|
247621
|
-
if (
|
|
247666
|
+
if (existsSync6(join32(cwd, "pnpm-lock.yaml"))) return "pnpm test";
|
|
247667
|
+
if (existsSync6(join32(cwd, "yarn.lock"))) return "yarn test";
|
|
247622
247668
|
return "npm test";
|
|
247623
247669
|
}
|
|
247624
247670
|
} catch {
|
|
247625
247671
|
}
|
|
247626
247672
|
return "npm test";
|
|
247627
247673
|
}
|
|
247628
|
-
if (
|
|
247674
|
+
if (existsSync6(join32(cwd, "pytest.ini")) || existsSync6(join32(cwd, "pyproject.toml"))) {
|
|
247629
247675
|
return "pytest";
|
|
247630
247676
|
}
|
|
247631
247677
|
return "npm test";
|
|
@@ -249116,10 +249162,10 @@ var BackgroundTaskRuntime = class {
|
|
|
249116
249162
|
const startedAt = Date.now();
|
|
249117
249163
|
let child;
|
|
249118
249164
|
try {
|
|
249119
|
-
|
|
249165
|
+
const invocation = resolveCommandShellInvocation(request.command);
|
|
249166
|
+
child = spawn(invocation.file, invocation.args, {
|
|
249120
249167
|
...HIDDEN_CHILD_PROCESS_OPTIONS,
|
|
249121
249168
|
cwd: safeCwd,
|
|
249122
|
-
shell: true,
|
|
249123
249169
|
detached: process.platform !== "win32",
|
|
249124
249170
|
stdio: ["ignore", "pipe", "pipe"]
|
|
249125
249171
|
});
|
|
@@ -249430,7 +249476,7 @@ function errorMessage(error) {
|
|
|
249430
249476
|
}
|
|
249431
249477
|
|
|
249432
249478
|
// ../sandbox/dist/index.js
|
|
249433
|
-
import { existsSync as
|
|
249479
|
+
import { existsSync as existsSync7, lstatSync as lstatSync3, mkdirSync as mkdirSync3, readdirSync as readdirSync2, rmSync as rmSync2 } from "fs";
|
|
249434
249480
|
import { join as join6 } from "path";
|
|
249435
249481
|
import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
|
|
249436
249482
|
import { z as z24 } from "zod";
|
|
@@ -249510,7 +249556,7 @@ var CheckpointManager = class {
|
|
|
249510
249556
|
}
|
|
249511
249557
|
loadPersistedCheckpoints() {
|
|
249512
249558
|
const sessionDir = this.getSessionCheckpointDir();
|
|
249513
|
-
if (!
|
|
249559
|
+
if (!existsSync7(sessionDir)) return;
|
|
249514
249560
|
const loaded = [];
|
|
249515
249561
|
for (const entry of readdirSync2(sessionDir, { withFileTypes: true })) {
|
|
249516
249562
|
if (!entry.isDirectory() || !CheckpointIdSchema.safeParse(entry.name).success) {
|
|
@@ -249518,7 +249564,7 @@ var CheckpointManager = class {
|
|
|
249518
249564
|
}
|
|
249519
249565
|
const checkpointDir = resolveSafePath(sessionDir, entry.name);
|
|
249520
249566
|
const metaPath = resolveSafePath(checkpointDir, "meta.json");
|
|
249521
|
-
if (!
|
|
249567
|
+
if (!existsSync7(metaPath)) continue;
|
|
249522
249568
|
try {
|
|
249523
249569
|
const parsed = PersistedCheckpointMetadataSchema.safeParse(
|
|
249524
249570
|
JSON.parse(
|
|
@@ -249557,7 +249603,7 @@ var CheckpointManager = class {
|
|
|
249557
249603
|
*/
|
|
249558
249604
|
readPersistedBackup(checkpointDir) {
|
|
249559
249605
|
const encryptedPath = resolveSafePath(checkpointDir, "backup_content.enc");
|
|
249560
|
-
if (
|
|
249606
|
+
if (existsSync7(encryptedPath)) {
|
|
249561
249607
|
const key = this.resolveEncryptionKey();
|
|
249562
249608
|
if (!key) return null;
|
|
249563
249609
|
try {
|
|
@@ -249571,7 +249617,7 @@ var CheckpointManager = class {
|
|
|
249571
249617
|
}
|
|
249572
249618
|
}
|
|
249573
249619
|
const plaintextPath = resolveSafePath(checkpointDir, "backup_content.txt");
|
|
249574
|
-
if (!
|
|
249620
|
+
if (!existsSync7(plaintextPath)) return null;
|
|
249575
249621
|
return readBoundedRegularFile(plaintextPath, CHECKPOINT_CONTENT_MAX_BYTES) ?? null;
|
|
249576
249622
|
}
|
|
249577
249623
|
async captureBeforeState(toolCallId, filePath) {
|
|
@@ -249579,7 +249625,7 @@ var CheckpointManager = class {
|
|
|
249579
249625
|
const validFilePath = z24.string().min(1).max(4096).parse(filePath);
|
|
249580
249626
|
const safePath = resolveSafePath(this.cwd, validFilePath);
|
|
249581
249627
|
let originalContent = null;
|
|
249582
|
-
if (
|
|
249628
|
+
if (existsSync7(safePath)) {
|
|
249583
249629
|
const stats = lstatSync3(safePath);
|
|
249584
249630
|
if (!stats.isFile() && !stats.isSymbolicLink()) {
|
|
249585
249631
|
throw new Error(`Checkpoint target must be a file: ${validFilePath}`);
|
|
@@ -249644,7 +249690,7 @@ var CheckpointManager = class {
|
|
|
249644
249690
|
this.getSessionCheckpointDir(),
|
|
249645
249691
|
checkpointId
|
|
249646
249692
|
);
|
|
249647
|
-
if (
|
|
249693
|
+
if (existsSync7(checkpointDir)) {
|
|
249648
249694
|
rmSync2(checkpointDir, { recursive: true, force: true });
|
|
249649
249695
|
}
|
|
249650
249696
|
}
|
|
@@ -249951,7 +249997,7 @@ import { createHash as createHash2, randomUUID as randomUUID32 } from "crypto";
|
|
|
249951
249997
|
import glob3 from "fast-glob";
|
|
249952
249998
|
import { z as z35 } from "zod";
|
|
249953
249999
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
249954
|
-
import { existsSync as
|
|
250000
|
+
import { existsSync as existsSync8, promises as fsPromises2 } from "fs";
|
|
249955
250001
|
import { dirname as dirname4, resolve as resolve4 } from "path";
|
|
249956
250002
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
249957
250003
|
import { z as z25 } from "zod";
|
|
@@ -249964,7 +250010,7 @@ import { existsSync as existsSync43 } from "fs";
|
|
|
249964
250010
|
import { pathToFileURL } from "url";
|
|
249965
250011
|
import { z as z43 } from "zod";
|
|
249966
250012
|
import { dirname as dirname5 } from "path";
|
|
249967
|
-
import { isAbsolute as isAbsolute22, join as
|
|
250013
|
+
import { isAbsolute as isAbsolute22, join as join33, resolve as resolve42 } from "path";
|
|
249968
250014
|
import { homedir as homedir4 } from "os";
|
|
249969
250015
|
import { existsSync as existsSync53, promises as fs2 } from "fs";
|
|
249970
250016
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -250267,7 +250313,7 @@ var JSVectorStore = class {
|
|
|
250267
250313
|
this.initializeCachePath();
|
|
250268
250314
|
try {
|
|
250269
250315
|
const parentDir = dirname4(this.dbPath);
|
|
250270
|
-
if (!
|
|
250316
|
+
if (!existsSync8(parentDir)) {
|
|
250271
250317
|
await fsPromises2.mkdir(parentDir, { recursive: true });
|
|
250272
250318
|
}
|
|
250273
250319
|
const dataToSave = {
|
|
@@ -250301,7 +250347,7 @@ var JSVectorStore = class {
|
|
|
250301
250347
|
}
|
|
250302
250348
|
async loadFromDisk() {
|
|
250303
250349
|
this.initializeCachePath();
|
|
250304
|
-
if (!
|
|
250350
|
+
if (!existsSync8(this.dbPath)) {
|
|
250305
250351
|
this.documents = [];
|
|
250306
250352
|
this.header = null;
|
|
250307
250353
|
this.cacheState = "missing";
|
|
@@ -250347,7 +250393,7 @@ var JSVectorStore = class {
|
|
|
250347
250393
|
this.header = null;
|
|
250348
250394
|
this.loaded = true;
|
|
250349
250395
|
this.cacheState = "missing";
|
|
250350
|
-
if (
|
|
250396
|
+
if (existsSync8(this.dbPath)) {
|
|
250351
250397
|
try {
|
|
250352
250398
|
await fsPromises2.unlink(this.dbPath);
|
|
250353
250399
|
} catch {
|
|
@@ -251810,13 +251856,13 @@ async function findSkillFiles(root) {
|
|
|
251810
251856
|
continue;
|
|
251811
251857
|
}
|
|
251812
251858
|
queue.push({
|
|
251813
|
-
path:
|
|
251859
|
+
path: join33(directory, entry.name),
|
|
251814
251860
|
depth: current.depth + 1
|
|
251815
251861
|
});
|
|
251816
251862
|
discoveredDirectories += 1;
|
|
251817
251863
|
} else if (entry.isFile() && entry.name === "SKILL.md") {
|
|
251818
251864
|
if (files.length < MAX_SKILL_FILES) {
|
|
251819
|
-
files.push(
|
|
251865
|
+
files.push(join33(directory, entry.name));
|
|
251820
251866
|
} else if (!fileLimitReported) {
|
|
251821
251867
|
diagnostics.push({
|
|
251822
251868
|
path: normalizePath2(root),
|
|
@@ -252629,7 +252675,7 @@ import { z as z38 } from "zod";
|
|
|
252629
252675
|
import { z as z83 } from "zod";
|
|
252630
252676
|
import picocolors3 from "picocolors";
|
|
252631
252677
|
import path42 from "path";
|
|
252632
|
-
import
|
|
252678
|
+
import fs32 from "fs";
|
|
252633
252679
|
import { randomUUID as randomUUID42 } from "crypto";
|
|
252634
252680
|
import { exec as exec2, execFile as execFile3 } from "child_process";
|
|
252635
252681
|
import { promisify as promisify3 } from "util";
|
|
@@ -253759,6 +253805,9 @@ import path32 from "path";
|
|
|
253759
253805
|
// ../permissions/dist/index.js
|
|
253760
253806
|
import os2 from "os";
|
|
253761
253807
|
import path4 from "path";
|
|
253808
|
+
import fs3 from "fs";
|
|
253809
|
+
import os22 from "os";
|
|
253810
|
+
import path22 from "path";
|
|
253762
253811
|
var DANGEROUS_COMMAND_REGEXES = [
|
|
253763
253812
|
/\brm\s+-rf\b/i,
|
|
253764
253813
|
/\brm\s+.*(?:--recursive|-r)\b/i,
|
|
@@ -253848,6 +253897,9 @@ function tokenize2(command) {
|
|
|
253848
253897
|
if (current) tokens.push(current);
|
|
253849
253898
|
return tokens;
|
|
253850
253899
|
}
|
|
253900
|
+
function extractCommandExecutable(command) {
|
|
253901
|
+
return tokenize2(command)[0];
|
|
253902
|
+
}
|
|
253851
253903
|
function extractCommandPaths(command) {
|
|
253852
253904
|
const pathTokens = [];
|
|
253853
253905
|
const bareTokens = [];
|
|
@@ -253863,7 +253915,11 @@ function extractCommandPaths(command) {
|
|
|
253863
253915
|
}
|
|
253864
253916
|
for (const candidate of candidates) {
|
|
253865
253917
|
if (!candidate || candidate.includes("://")) continue;
|
|
253866
|
-
|
|
253918
|
+
if (/^\/dev\/(?:null|stdin|stdout|stderr|tty)$/i.test(candidate)) {
|
|
253919
|
+
continue;
|
|
253920
|
+
}
|
|
253921
|
+
const hasBackslashPath = /^\\\\/.test(candidate) || /(?:^|[\w.)-])\\[\w.(~-]/.test(candidate);
|
|
253922
|
+
const looksLikePath = candidate.includes("/") || hasBackslashPath || /^[A-Za-z]:/.test(candidate) || candidate.startsWith("~") || /^\.[\w.-]+$/.test(candidate);
|
|
253867
253923
|
if (looksLikePath) {
|
|
253868
253924
|
pathTokens.push(candidate);
|
|
253869
253925
|
} else if (/^[\w][\w.-]*$/.test(candidate)) {
|
|
@@ -253875,8 +253931,14 @@ function extractCommandPaths(command) {
|
|
|
253875
253931
|
}
|
|
253876
253932
|
function resolveCommandPathCandidate(token, workspaceRoot) {
|
|
253877
253933
|
const home = os2.homedir();
|
|
253878
|
-
|
|
253934
|
+
let expanded = token.replace(/^~(?=$|[\\/])/, home).replace(/^\$HOME(?=$|[\\/])/, home).replace(/^%USERPROFILE%/i, home);
|
|
253879
253935
|
if (/[%$]/.test(expanded)) return null;
|
|
253936
|
+
if (process.platform === "win32") {
|
|
253937
|
+
const msysPath = /^\/([A-Za-z])(?:\/(.*))?$/.exec(expanded);
|
|
253938
|
+
if (msysPath) {
|
|
253939
|
+
expanded = `${msysPath[1].toUpperCase()}:\\${(msysPath[2] || "").replace(/\//g, "\\")}`;
|
|
253940
|
+
}
|
|
253941
|
+
}
|
|
253880
253942
|
try {
|
|
253881
253943
|
return path4.resolve(workspaceRoot, expanded);
|
|
253882
253944
|
} catch {
|
|
@@ -253890,6 +253952,38 @@ var PermissionEngine = class {
|
|
|
253890
253952
|
}
|
|
253891
253953
|
config;
|
|
253892
253954
|
workspaceRoot;
|
|
253955
|
+
trustedRoots = [];
|
|
253956
|
+
/** Active, validated Skill roots authorized for this turn. */
|
|
253957
|
+
setTrustedRoots(roots) {
|
|
253958
|
+
this.trustedRoots = roots;
|
|
253959
|
+
}
|
|
253960
|
+
commandTrustedRoots(mode) {
|
|
253961
|
+
if (mode !== "auto") return this.trustedRoots;
|
|
253962
|
+
const fontRoots = process.platform === "win32" ? [path22.join(process.env.WINDIR || "C:\\Windows", "Fonts")] : process.platform === "darwin" ? [
|
|
253963
|
+
"/Library/Fonts",
|
|
253964
|
+
"/System/Library/Fonts",
|
|
253965
|
+
path22.join(os22.homedir(), "Library", "Fonts")
|
|
253966
|
+
] : [
|
|
253967
|
+
"/usr/share/fonts",
|
|
253968
|
+
"/usr/local/share/fonts",
|
|
253969
|
+
path22.join(os22.homedir(), ".local", "share", "fonts")
|
|
253970
|
+
];
|
|
253971
|
+
return Array.from(
|
|
253972
|
+
/* @__PURE__ */ new Set([...this.trustedRoots, os22.tmpdir(), ...fontRoots])
|
|
253973
|
+
);
|
|
253974
|
+
}
|
|
253975
|
+
isTrustedExecutable(resolved) {
|
|
253976
|
+
const executableDirectory = path22.resolve(path22.dirname(resolved));
|
|
253977
|
+
const pathRoots = (process.env.PATH || "").split(path22.delimiter).map((entry) => entry.trim()).filter(Boolean).map((entry) => path22.resolve(entry));
|
|
253978
|
+
if (!pathRoots.some((entry) => entry === executableDirectory)) return false;
|
|
253979
|
+
try {
|
|
253980
|
+
const stat = fs3.statSync(resolved);
|
|
253981
|
+
if (!stat.isFile()) return false;
|
|
253982
|
+
return process.platform === "win32" ? /\.(?:exe|cmd|bat|com)$/i.test(resolved) : (stat.mode & 73) !== 0;
|
|
253983
|
+
} catch {
|
|
253984
|
+
return false;
|
|
253985
|
+
}
|
|
253986
|
+
}
|
|
253893
253987
|
evaluate(toolName, args, declaredRisk) {
|
|
253894
253988
|
const mode = this.config.permissions.mode;
|
|
253895
253989
|
const protectedPaths = this.config.permissions.protectedPaths;
|
|
@@ -253998,6 +254092,8 @@ var PermissionEngine = class {
|
|
|
253998
254092
|
}
|
|
253999
254093
|
if (this.workspaceRoot) {
|
|
254000
254094
|
const workspaceRoot = this.workspaceRoot;
|
|
254095
|
+
const trustedRoots = this.commandTrustedRoots(mode);
|
|
254096
|
+
const executableToken = extractCommandExecutable(cmdString);
|
|
254001
254097
|
const unresolvedPath = commandPaths.pathTokens.find(
|
|
254002
254098
|
(token) => resolveCommandPathCandidate(token, workspaceRoot) === null
|
|
254003
254099
|
);
|
|
@@ -254017,7 +254113,9 @@ var PermissionEngine = class {
|
|
|
254017
254113
|
}
|
|
254018
254114
|
const outsidePath = commandPaths.pathTokens.find((token) => {
|
|
254019
254115
|
const resolved = resolveCommandPathCandidate(token, workspaceRoot);
|
|
254020
|
-
return resolved !== null && !checkWorkspaceBoundary(workspaceRoot, resolved)
|
|
254116
|
+
return resolved !== null && !checkWorkspaceBoundary(workspaceRoot, resolved) && !trustedRoots.some(
|
|
254117
|
+
(root) => checkWorkspaceBoundary(root, resolved)
|
|
254118
|
+
) && !(mode === "auto" && token === executableToken && this.isTrustedExecutable(resolved));
|
|
254021
254119
|
});
|
|
254022
254120
|
if (outsidePath) {
|
|
254023
254121
|
if (mode === "strict") {
|
|
@@ -254133,7 +254231,7 @@ import { dirname as dirname7, isAbsolute as isAbsolute4, join as join8, relative
|
|
|
254133
254231
|
import {
|
|
254134
254232
|
appendFileSync,
|
|
254135
254233
|
closeSync as closeSync2,
|
|
254136
|
-
existsSync as
|
|
254234
|
+
existsSync as existsSync9,
|
|
254137
254235
|
fsyncSync as fsyncSync2,
|
|
254138
254236
|
lstatSync as lstatSync5,
|
|
254139
254237
|
mkdirSync as mkdirSync5,
|
|
@@ -254156,7 +254254,7 @@ import { homedir as homedir5 } from "os";
|
|
|
254156
254254
|
import { basename as basename2, dirname as dirname23, isAbsolute as isAbsolute23, join as join25, parse as parse2, resolve as resolve24 } from "path";
|
|
254157
254255
|
import { z as z210 } from "zod";
|
|
254158
254256
|
import { existsSync as existsSync26, lstatSync as lstatSync32, mkdirSync as mkdirSync22, readdirSync as readdirSync22 } from "fs";
|
|
254159
|
-
import { basename as basename22, join as
|
|
254257
|
+
import { basename as basename22, join as join34, resolve as resolve32 } from "path";
|
|
254160
254258
|
import { z as z37 } from "zod";
|
|
254161
254259
|
var SafeObjectKeySchema = z29.string().refine(
|
|
254162
254260
|
(key) => !["__proto__", "constructor", "prototype"].includes(key),
|
|
@@ -254567,7 +254665,7 @@ function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
|
254567
254665
|
const backupPath = `${destinationPath}.${process.pid}.${randomUUID6()}.bak`;
|
|
254568
254666
|
let previousMoved = false;
|
|
254569
254667
|
try {
|
|
254570
|
-
if (
|
|
254668
|
+
if (existsSync9(destinationPath)) {
|
|
254571
254669
|
renameSync3(destinationPath, backupPath);
|
|
254572
254670
|
previousMoved = true;
|
|
254573
254671
|
}
|
|
@@ -254579,7 +254677,7 @@ function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
|
254579
254677
|
}
|
|
254580
254678
|
}
|
|
254581
254679
|
} catch (error) {
|
|
254582
|
-
if (previousMoved &&
|
|
254680
|
+
if (previousMoved && existsSync9(backupPath) && !existsSync9(destinationPath)) {
|
|
254583
254681
|
try {
|
|
254584
254682
|
renameSync3(backupPath, destinationPath);
|
|
254585
254683
|
} catch {
|
|
@@ -254587,7 +254685,7 @@ function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
|
254587
254685
|
}
|
|
254588
254686
|
throw error;
|
|
254589
254687
|
} finally {
|
|
254590
|
-
if (
|
|
254688
|
+
if (existsSync9(destinationPath)) {
|
|
254591
254689
|
try {
|
|
254592
254690
|
rmSync4(backupPath, { force: true });
|
|
254593
254691
|
} catch {
|
|
@@ -254689,9 +254787,9 @@ var SessionStore = class {
|
|
|
254689
254787
|
} catch {
|
|
254690
254788
|
return void 0;
|
|
254691
254789
|
}
|
|
254692
|
-
if (!
|
|
254790
|
+
if (!existsSync9(sessionFile)) return void 0;
|
|
254693
254791
|
for (const candidate of [sessionFile, `${sessionFile}.bak`]) {
|
|
254694
|
-
if (!
|
|
254792
|
+
if (!existsSync9(candidate)) continue;
|
|
254695
254793
|
const parsed = readValidatedSnapshot(candidate, SessionSchema);
|
|
254696
254794
|
if (parsed?.id === id) return parsed;
|
|
254697
254795
|
}
|
|
@@ -254714,7 +254812,7 @@ var SessionStore = class {
|
|
|
254714
254812
|
let dirs;
|
|
254715
254813
|
try {
|
|
254716
254814
|
sessionRoot = this.resolveSessionRoot();
|
|
254717
|
-
if (!
|
|
254815
|
+
if (!existsSync9(sessionRoot)) return [];
|
|
254718
254816
|
dirs = readdirSync3(sessionRoot);
|
|
254719
254817
|
} catch {
|
|
254720
254818
|
return [];
|
|
@@ -254747,7 +254845,7 @@ var SessionStore = class {
|
|
|
254747
254845
|
} catch {
|
|
254748
254846
|
return [];
|
|
254749
254847
|
}
|
|
254750
|
-
if (!
|
|
254848
|
+
if (!existsSync9(file)) return [];
|
|
254751
254849
|
let content;
|
|
254752
254850
|
try {
|
|
254753
254851
|
content = readBoundedRegularFile(file, SESSION_LOG_MAX_BYTES) ?? "";
|
|
@@ -254831,7 +254929,7 @@ var SessionStore = class {
|
|
|
254831
254929
|
return void 0;
|
|
254832
254930
|
}
|
|
254833
254931
|
for (const candidate of [file, `${file}.bak`]) {
|
|
254834
|
-
if (!
|
|
254932
|
+
if (!existsSync9(candidate)) continue;
|
|
254835
254933
|
const parsed = readValidatedSnapshot(candidate, RunJournalSchema);
|
|
254836
254934
|
if (parsed?.sessionId === sessionId) return parsed;
|
|
254837
254935
|
}
|
|
@@ -254915,7 +255013,7 @@ var SessionStore = class {
|
|
|
254915
255013
|
return void 0;
|
|
254916
255014
|
}
|
|
254917
255015
|
for (const candidate of [file, `${file}.bak`]) {
|
|
254918
|
-
if (!
|
|
255016
|
+
if (!existsSync9(candidate)) continue;
|
|
254919
255017
|
const parsed = readValidatedSnapshot(candidate, TaskPlanSchema);
|
|
254920
255018
|
if (parsed?.sessionId === sessionId) return parsed;
|
|
254921
255019
|
}
|
|
@@ -254942,7 +255040,7 @@ var SessionStore = class {
|
|
|
254942
255040
|
return void 0;
|
|
254943
255041
|
}
|
|
254944
255042
|
for (const candidate of [file, `${file}.bak`]) {
|
|
254945
|
-
if (!
|
|
255043
|
+
if (!existsSync9(candidate)) continue;
|
|
254946
255044
|
const parsed = readValidatedSnapshot(candidate, AgentInputQueueSchema);
|
|
254947
255045
|
if (parsed?.sessionId === sessionId) return parsed;
|
|
254948
255046
|
}
|
|
@@ -255000,7 +255098,7 @@ var SessionStore = class {
|
|
|
255000
255098
|
} catch {
|
|
255001
255099
|
return [];
|
|
255002
255100
|
}
|
|
255003
|
-
if (!
|
|
255101
|
+
if (!existsSync9(file)) return [];
|
|
255004
255102
|
try {
|
|
255005
255103
|
return (readBoundedRegularFile(file, SESSION_LOG_MAX_BYTES) ?? "").split("\n").filter((line) => line.trim()).flatMap((line) => {
|
|
255006
255104
|
try {
|
|
@@ -255028,7 +255126,7 @@ var SessionStore = class {
|
|
|
255028
255126
|
return [];
|
|
255029
255127
|
}
|
|
255030
255128
|
for (const candidate of [file, `${file}.bak`]) {
|
|
255031
|
-
if (!
|
|
255129
|
+
if (!existsSync9(candidate)) continue;
|
|
255032
255130
|
const parsed = readValidatedSnapshot(candidate, StoredHistorySchema);
|
|
255033
255131
|
if (parsed) return parsed;
|
|
255034
255132
|
}
|
|
@@ -255037,7 +255135,7 @@ var SessionStore = class {
|
|
|
255037
255135
|
deleteSession(id) {
|
|
255038
255136
|
SessionIdSchema.parse(id);
|
|
255039
255137
|
const dir = this.resolveSessionDirectory(id);
|
|
255040
|
-
if (
|
|
255138
|
+
if (existsSync9(dir)) {
|
|
255041
255139
|
rmSync4(dir, { recursive: true, force: true });
|
|
255042
255140
|
}
|
|
255043
255141
|
}
|
|
@@ -255060,7 +255158,7 @@ var SessionStore = class {
|
|
|
255060
255158
|
if (sessionRoot === this.cwd) {
|
|
255061
255159
|
throw new Error("Orbit session root cannot be the workspace root.");
|
|
255062
255160
|
}
|
|
255063
|
-
if (
|
|
255161
|
+
if (existsSync9(sessionRoot)) {
|
|
255064
255162
|
const rootStats = lstatSync5(sessionRoot);
|
|
255065
255163
|
if (rootStats.isSymbolicLink() || !rootStats.isDirectory()) {
|
|
255066
255164
|
throw new Error("Orbit session root must be a real directory.");
|
|
@@ -255076,7 +255174,7 @@ var SessionStore = class {
|
|
|
255076
255174
|
if (relativePath !== validId || relativePath.includes(sep) || isAbsolute4(relativePath)) {
|
|
255077
255175
|
throw new Error(`Invalid session directory: ${id}`);
|
|
255078
255176
|
}
|
|
255079
|
-
if (
|
|
255177
|
+
if (existsSync9(resolved)) {
|
|
255080
255178
|
const stats = lstatSync5(resolved);
|
|
255081
255179
|
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
255082
255180
|
throw new Error(`Invalid session directory: ${id}`);
|
|
@@ -255859,7 +255957,7 @@ var AgentRunStore = class {
|
|
|
255859
255957
|
try {
|
|
255860
255958
|
return [
|
|
255861
255959
|
this.read(
|
|
255862
|
-
resolveSafePath(this.cwd,
|
|
255960
|
+
resolveSafePath(this.cwd, join34(".orbit", "agent-runs", name))
|
|
255863
255961
|
)
|
|
255864
255962
|
];
|
|
255865
255963
|
} catch {
|
|
@@ -255900,7 +255998,7 @@ var AgentRunStore = class {
|
|
|
255900
255998
|
AgentRunIdSchema.parse(runId);
|
|
255901
255999
|
return resolveSafePath(
|
|
255902
256000
|
this.cwd,
|
|
255903
|
-
|
|
256001
|
+
join34(".orbit", "agent-runs", `${runId}.json`)
|
|
255904
256002
|
);
|
|
255905
256003
|
}
|
|
255906
256004
|
assertInitialized() {
|
|
@@ -255921,7 +256019,7 @@ import { randomUUID as randomUUID33 } from "crypto";
|
|
|
255921
256019
|
import { z as z64 } from "zod";
|
|
255922
256020
|
import { z as z73 } from "zod";
|
|
255923
256021
|
import fs23 from "fs";
|
|
255924
|
-
import
|
|
256022
|
+
import path23 from "path";
|
|
255925
256023
|
import { exec, execFile as execFile22 } from "child_process";
|
|
255926
256024
|
import { promisify as promisify2 } from "util";
|
|
255927
256025
|
import { z as z103 } from "zod";
|
|
@@ -256162,7 +256260,7 @@ var PromptCacheSlabBuilder = class {
|
|
|
256162
256260
|
}
|
|
256163
256261
|
static buildDiagnostics(cwd) {
|
|
256164
256262
|
const dir = join9(cwd, ".orbit", "cache-slabs");
|
|
256165
|
-
if (!
|
|
256263
|
+
if (!existsSync10(dir)) {
|
|
256166
256264
|
return [
|
|
256167
256265
|
"Cache diagnostics:",
|
|
256168
256266
|
"- No cache slab metadata found yet.",
|
|
@@ -256264,7 +256362,7 @@ function resolveContextWindowStatus(input) {
|
|
|
256264
256362
|
modelCapabilities.maxContextTokens || DEFAULT_MODEL_CONTEXT_TOKENS
|
|
256265
256363
|
)
|
|
256266
256364
|
);
|
|
256267
|
-
const configuredMaxOutputTokens = model === config.models.fast ? config.agent?.fastMaxOutputTokens ??
|
|
256365
|
+
const configuredMaxOutputTokens = model === config.models.fast ? config.agent?.fastMaxOutputTokens ?? 32768 : config.agent?.maxOutputTokens ?? 16384;
|
|
256268
256366
|
const modelMaxOutputTokens = modelCapabilities.maxOutputTokens || configuredMaxOutputTokens;
|
|
256269
256367
|
const maxOutputByContext = Math.max(1, Math.floor(maxContextTokens * 0.25));
|
|
256270
256368
|
const reservedOutputTokens = Math.max(
|
|
@@ -256939,6 +257037,7 @@ var AgentCompletedEventSchema = z38.object({
|
|
|
256939
257037
|
payload: z38.object({
|
|
256940
257038
|
taskId: z38.string(),
|
|
256941
257039
|
success: z38.boolean(),
|
|
257040
|
+
status: z38.enum(["completed", "failed", "aborted"]).optional(),
|
|
256942
257041
|
result: z38.unknown().optional(),
|
|
256943
257042
|
error: z38.string().optional()
|
|
256944
257043
|
})
|
|
@@ -258069,7 +258168,7 @@ var VerificationContractManager = class {
|
|
|
258069
258168
|
this.loadContract();
|
|
258070
258169
|
}
|
|
258071
258170
|
loadContract() {
|
|
258072
|
-
const contractPath =
|
|
258171
|
+
const contractPath = path23.join(this.cwd, ".orbit", "verification.json");
|
|
258073
258172
|
if (fs23.existsSync(contractPath)) {
|
|
258074
258173
|
try {
|
|
258075
258174
|
const content = readBoundedRegularFile(
|
|
@@ -258343,8 +258442,8 @@ function restoreSessionHistory(sessionManager, state) {
|
|
|
258343
258442
|
}
|
|
258344
258443
|
function resolveMaxLoopAttempts(config) {
|
|
258345
258444
|
const raw = config.agent?.maxIterations;
|
|
258346
|
-
if (!Number.isFinite(raw)) return
|
|
258347
|
-
return Math.max(1, Math.min(
|
|
258445
|
+
if (!Number.isFinite(raw)) return DEFAULT_AGENT_MAX_ITERATIONS;
|
|
258446
|
+
return Math.max(1, Math.min(MAX_AGENT_MAX_ITERATIONS, Math.floor(raw)));
|
|
258348
258447
|
}
|
|
258349
258448
|
function workspaceUserId(cwd) {
|
|
258350
258449
|
const workspaceIdentity = path32.resolve(cwd).replace(/\\/g, "/");
|
|
@@ -258391,6 +258490,22 @@ function hookErrorOutput(error) {
|
|
|
258391
258490
|
if (output.trim()) return output;
|
|
258392
258491
|
return typeof record.message === "string" ? record.message : String(error);
|
|
258393
258492
|
}
|
|
258493
|
+
function hasSuccessfulFileMutations(history) {
|
|
258494
|
+
const mutationCallIds = /* @__PURE__ */ new Set();
|
|
258495
|
+
for (const message2 of history) {
|
|
258496
|
+
for (const block of message2.content) {
|
|
258497
|
+
if (block.type === "tool_call" && isFileMutationTool(block.toolCall.name)) {
|
|
258498
|
+
mutationCallIds.add(block.toolCall.id);
|
|
258499
|
+
}
|
|
258500
|
+
}
|
|
258501
|
+
}
|
|
258502
|
+
if (mutationCallIds.size === 0) return false;
|
|
258503
|
+
return history.some(
|
|
258504
|
+
(message2) => message2.content.some(
|
|
258505
|
+
(block) => block.type === "tool_result" && mutationCallIds.has(block.toolResult.toolCallId) && block.toolResult.isError !== true
|
|
258506
|
+
)
|
|
258507
|
+
);
|
|
258508
|
+
}
|
|
258394
258509
|
var AgentLoop = class _AgentLoop {
|
|
258395
258510
|
constructor(cwd, config, provider, interaction, options, bootstrap) {
|
|
258396
258511
|
this.cwd = cwd;
|
|
@@ -258445,6 +258560,7 @@ var AgentLoop = class _AgentLoop {
|
|
|
258445
258560
|
this.stepRunner.setReadRoots(
|
|
258446
258561
|
active.map((skill) => ({ name: skill.name, path: skill.rootDir }))
|
|
258447
258562
|
);
|
|
258563
|
+
this.permissionEngine.setTrustedRoots(active.map((skill) => skill.rootDir));
|
|
258448
258564
|
const signature = JSON.stringify(
|
|
258449
258565
|
active.map((skill) => [skill.name, skill.activation])
|
|
258450
258566
|
);
|
|
@@ -258499,6 +258615,7 @@ var AgentLoop = class _AgentLoop {
|
|
|
258499
258615
|
fallbackExpiresAfterAttempt = 0;
|
|
258500
258616
|
contextOverflowRetriesForRun = 0;
|
|
258501
258617
|
outputLimitRetriesForRun = 0;
|
|
258618
|
+
completionVerificationNudgedForRun = false;
|
|
258502
258619
|
approvedToolScopes = /* @__PURE__ */ new Set();
|
|
258503
258620
|
terminalFailure = null;
|
|
258504
258621
|
verificationStatus = "not_run";
|
|
@@ -258718,6 +258835,7 @@ ${normalized}`);
|
|
|
258718
258835
|
}
|
|
258719
258836
|
async executeRun() {
|
|
258720
258837
|
const runStartedAt = /* @__PURE__ */ new Date();
|
|
258838
|
+
let iterationLimitReached = false;
|
|
258721
258839
|
eventBus.emitEvent("agent_start", {
|
|
258722
258840
|
taskId: this.state.sessionId,
|
|
258723
258841
|
task: this.state.task
|
|
@@ -258729,6 +258847,7 @@ ${normalized}`);
|
|
|
258729
258847
|
this.fallbackExpiresAfterAttempt = 0;
|
|
258730
258848
|
this.contextOverflowRetriesForRun = 0;
|
|
258731
258849
|
this.outputLimitRetriesForRun = 0;
|
|
258850
|
+
this.completionVerificationNudgedForRun = false;
|
|
258732
258851
|
this.approvedToolScopes.clear();
|
|
258733
258852
|
this.terminalFailure = null;
|
|
258734
258853
|
this.verificationStatus = "not_run";
|
|
@@ -258862,8 +258981,8 @@ ${normalized}`);
|
|
|
258862
258981
|
try {
|
|
258863
258982
|
const indexer = new SymbolIndexer(this.cwd);
|
|
258864
258983
|
const indexPath = indexer.indexPath;
|
|
258865
|
-
if (
|
|
258866
|
-
const stat =
|
|
258984
|
+
if (fs32.existsSync(indexPath)) {
|
|
258985
|
+
const stat = fs32.statSync(indexPath);
|
|
258867
258986
|
if (stat.mtimeMs === this.lastSymbolsMtime && this.cachedRepoMapText) {
|
|
258868
258987
|
repoMapText = this.cachedRepoMapText;
|
|
258869
258988
|
} else {
|
|
@@ -259392,11 +259511,7 @@ Orbit: ${this.interaction.formatMarkdown?.(responseText) || responseText}`
|
|
|
259392
259511
|
if (steeringApplied || backgroundReconciled) continue;
|
|
259393
259512
|
}
|
|
259394
259513
|
if (toolCallsToExecute.length === 0) {
|
|
259395
|
-
const hasEdits = this.state.history
|
|
259396
|
-
(msg) => msg.role === "assistant" && msg.content.some(
|
|
259397
|
-
(b3) => b3.type === "tool_call" && (b3.toolCall.name === "write_file" || b3.toolCall.name === "edit_file" || b3.toolCall.name === "replace_file_content" || b3.toolCall.name === "multi_replace_file_content")
|
|
259398
|
-
)
|
|
259399
|
-
);
|
|
259514
|
+
const hasEdits = hasSuccessfulFileMutations(this.state.history);
|
|
259400
259515
|
if (hasEdits) {
|
|
259401
259516
|
if (this.verificationManager.hasContract()) {
|
|
259402
259517
|
this.sessionManager.setRunState("verifying", "verification", {
|
|
@@ -259567,6 +259682,38 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
259567
259682
|
}
|
|
259568
259683
|
}
|
|
259569
259684
|
}
|
|
259685
|
+
if (hasEdits && this.verificationStatus === "not_run" && !this.completionVerificationNudgedForRun) {
|
|
259686
|
+
this.completionVerificationNudgedForRun = true;
|
|
259687
|
+
this.state.history.push({
|
|
259688
|
+
id: `msg_completion_verification_${Date.now()}`,
|
|
259689
|
+
role: "user",
|
|
259690
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
259691
|
+
content: [
|
|
259692
|
+
{
|
|
259693
|
+
type: "text",
|
|
259694
|
+
text: [
|
|
259695
|
+
"Orbit completion gate: files were modified, but no verification has run.",
|
|
259696
|
+
"Use run_tests now with the smallest relevant build, test, compile, or syntax check for the changed files.",
|
|
259697
|
+
"If it fails, repair the root cause before claiming completion. Do not repeat discovery."
|
|
259698
|
+
].join(" ")
|
|
259699
|
+
}
|
|
259700
|
+
],
|
|
259701
|
+
metadata: { kind: "completion_verification" }
|
|
259702
|
+
});
|
|
259703
|
+
this.sessionManager.saveHistory(this.state.history);
|
|
259704
|
+
this.interaction.showText(
|
|
259705
|
+
picocolors3.yellow(
|
|
259706
|
+
"\n\u26A0 Completion gate: modified files require a verification check before Orbit can finish."
|
|
259707
|
+
)
|
|
259708
|
+
);
|
|
259709
|
+
continue;
|
|
259710
|
+
}
|
|
259711
|
+
if (hasEdits && this.verificationStatus !== "passed") {
|
|
259712
|
+
this.terminalFailure = {
|
|
259713
|
+
code: "verification_failed",
|
|
259714
|
+
message: this.verificationStatus === "failed" ? "The final verification check failed." : "Modified files were not verified before completion."
|
|
259715
|
+
};
|
|
259716
|
+
}
|
|
259570
259717
|
this.state.done = true;
|
|
259571
259718
|
break;
|
|
259572
259719
|
}
|
|
@@ -260161,7 +260308,7 @@ ${stdout.substring(0, 2e4)}`
|
|
|
260161
260308
|
}
|
|
260162
260309
|
if (finalResult.ok && targetPath && absoluteTargetPath && (tc.name === "write_file" || tc.name === "edit_file" || tc.name === "replace_file_content" || tc.name === "multi_replace_file_content")) {
|
|
260163
260310
|
try {
|
|
260164
|
-
if (
|
|
260311
|
+
if (fs32.existsSync(path42.join(this.cwd, "biome.json")) || fs32.existsSync(path42.join(this.cwd, "biome.jsonc"))) {
|
|
260165
260312
|
this.interaction.showText(`\u25CF Running Biome Auto-Format...`);
|
|
260166
260313
|
await executeLocalPackageBinary(
|
|
260167
260314
|
this.cwd,
|
|
@@ -260180,7 +260327,7 @@ ${stdout.substring(0, 2e4)}`
|
|
|
260180
260327
|
];
|
|
260181
260328
|
let hasPrettierConfig = false;
|
|
260182
260329
|
for (const c2 of prettierCandidates) {
|
|
260183
|
-
if (
|
|
260330
|
+
if (fs32.existsSync(path42.join(this.cwd, c2))) {
|
|
260184
260331
|
hasPrettierConfig = true;
|
|
260185
260332
|
break;
|
|
260186
260333
|
}
|
|
@@ -260205,7 +260352,7 @@ ${stdout.substring(0, 2e4)}`
|
|
|
260205
260352
|
];
|
|
260206
260353
|
let hasEslintConfig = false;
|
|
260207
260354
|
for (const c2 of eslintCandidates) {
|
|
260208
|
-
if (
|
|
260355
|
+
if (fs32.existsSync(path42.join(this.cwd, c2))) {
|
|
260209
260356
|
hasEslintConfig = true;
|
|
260210
260357
|
break;
|
|
260211
260358
|
}
|
|
@@ -260223,7 +260370,7 @@ ${stdout.substring(0, 2e4)}`
|
|
|
260223
260370
|
let lintPackage = "eslint";
|
|
260224
260371
|
let lintBinary = "eslint";
|
|
260225
260372
|
let lintArgs = ["--quiet", absoluteTargetPath];
|
|
260226
|
-
if (
|
|
260373
|
+
if (fs32.existsSync(path42.join(this.cwd, "biome.json")) || fs32.existsSync(path42.join(this.cwd, "biome.jsonc"))) {
|
|
260227
260374
|
lintPackage = "@biomejs/biome";
|
|
260228
260375
|
lintBinary = "biome";
|
|
260229
260376
|
lintArgs = ["lint", absoluteTargetPath];
|
|
@@ -260281,10 +260428,10 @@ ${stdout.substring(0, 2e4)}`
|
|
|
260281
260428
|
);
|
|
260282
260429
|
if (installPkg) {
|
|
260283
260430
|
this.interaction.showText(`\u25CF Installing "${pkg}"...`);
|
|
260284
|
-
const isPnpm =
|
|
260431
|
+
const isPnpm = fs32.existsSync(
|
|
260285
260432
|
path42.join(this.cwd, "pnpm-lock.yaml")
|
|
260286
260433
|
);
|
|
260287
|
-
const isYarn =
|
|
260434
|
+
const isYarn = fs32.existsSync(
|
|
260288
260435
|
path42.join(this.cwd, "yarn.lock")
|
|
260289
260436
|
);
|
|
260290
260437
|
try {
|
|
@@ -260380,7 +260527,7 @@ ${stdout.substring(0, 2e4)}`
|
|
|
260380
260527
|
`;
|
|
260381
260528
|
}
|
|
260382
260529
|
if (newImports) {
|
|
260383
|
-
|
|
260530
|
+
fs32.writeFileSync(
|
|
260384
260531
|
absoluteTargetPath,
|
|
260385
260532
|
newImports + fileContent,
|
|
260386
260533
|
"utf8"
|
|
@@ -260601,7 +260748,7 @@ ${stdout.substring(0, 2e4)}`
|
|
|
260601
260748
|
lastB = hunk.endB;
|
|
260602
260749
|
}
|
|
260603
260750
|
mergedLines.push(...linesBefore.slice(lastB));
|
|
260604
|
-
|
|
260751
|
+
fs32.writeFileSync(
|
|
260605
260752
|
absoluteTargetPath,
|
|
260606
260753
|
mergedLines.join("\n"),
|
|
260607
260754
|
"utf8"
|
|
@@ -260668,6 +260815,9 @@ ${stdout.substring(0, 2e4)}`
|
|
|
260668
260815
|
status,
|
|
260669
260816
|
{ startedAt: toolStartedAt }
|
|
260670
260817
|
);
|
|
260818
|
+
if (tc.name === "run_tests") {
|
|
260819
|
+
this.verificationStatus = finalResult.ok ? "passed" : "failed";
|
|
260820
|
+
}
|
|
260671
260821
|
if (finalResult.ok) {
|
|
260672
260822
|
const statusText = this.truncatePlain(
|
|
260673
260823
|
redactSecrets(finalResult.display || "Done"),
|
|
@@ -260739,13 +260889,10 @@ ${guardNudge.message}` : ""),
|
|
|
260739
260889
|
this.sessionManager.saveHistory(this.state.history);
|
|
260740
260890
|
}
|
|
260741
260891
|
if (this.state.attemptCount >= this.state.maxAttempts && !this.state.done) {
|
|
260742
|
-
|
|
260743
|
-
code: "iteration_limit",
|
|
260744
|
-
message: `Maximum loop iterations (${this.state.maxAttempts}) reached before the task completed.`
|
|
260745
|
-
};
|
|
260892
|
+
iterationLimitReached = true;
|
|
260746
260893
|
this.interaction.showText(
|
|
260747
260894
|
`
|
|
260748
|
-
\
|
|
260895
|
+
\u26A0\uFE0F Paused: Maximum consecutive loop iterations (${this.state.maxAttempts}) completed. Resume this session to continue; completed tool results and verification evidence were preserved.`
|
|
260749
260896
|
);
|
|
260750
260897
|
}
|
|
260751
260898
|
const sessions = this.sessionManager.getSessionStore().getEvents(this.state.sessionId);
|
|
@@ -260764,7 +260911,7 @@ ${guardNudge.message}` : ""),
|
|
|
260764
260911
|
this.interaction.showText(
|
|
260765
260912
|
` Session Cost: $${this.sessionCost.toFixed(4)}`
|
|
260766
260913
|
);
|
|
260767
|
-
if (!this.terminalFailure && this.config.autoCommit && modifiedFiles.length > 0) {
|
|
260914
|
+
if (!this.terminalFailure && !iterationLimitReached && this.config.autoCommit && modifiedFiles.length > 0) {
|
|
260768
260915
|
this.interaction.showText(`
|
|
260769
260916
|
\u25CF Auto-committing changes...`);
|
|
260770
260917
|
try {
|
|
@@ -260844,6 +260991,12 @@ ${diff.substring(0, 2e4)}`
|
|
|
260844
260991
|
this.terminalFailure.message
|
|
260845
260992
|
);
|
|
260846
260993
|
}
|
|
260994
|
+
if (iterationLimitReached) {
|
|
260995
|
+
return this.createAbortedOutcome(
|
|
260996
|
+
"iteration_limit",
|
|
260997
|
+
`Paused after ${this.state.maxAttempts} consecutive loop iterations. Resume the session to continue.`
|
|
260998
|
+
);
|
|
260999
|
+
}
|
|
260847
261000
|
return {
|
|
260848
261001
|
status: "completed",
|
|
260849
261002
|
sessionId: this.state.sessionId,
|
|
@@ -260860,9 +261013,10 @@ ${diff.substring(0, 2e4)}`
|
|
|
260860
261013
|
}
|
|
260861
261014
|
finalizeOutcome(outcome) {
|
|
260862
261015
|
try {
|
|
261016
|
+
const iterationPause = outcome.status === "aborted" && outcome.reason === "iteration_limit";
|
|
260863
261017
|
this.sessionManager.setRunState(
|
|
260864
261018
|
outcome.status,
|
|
260865
|
-
outcome.status === "completed" ? "finished" : "terminated",
|
|
261019
|
+
outcome.status === "completed" ? "finished" : iterationPause ? "paused" : "terminated",
|
|
260866
261020
|
{ attempt: this.state.attemptCount }
|
|
260867
261021
|
);
|
|
260868
261022
|
this.sessionManager.setStatus(
|
|
@@ -260878,6 +261032,7 @@ ${diff.substring(0, 2e4)}`
|
|
|
260878
261032
|
eventBus.emitEvent("agent_completed", {
|
|
260879
261033
|
taskId: this.state.sessionId,
|
|
260880
261034
|
success: outcome.status === "completed",
|
|
261035
|
+
status: outcome.status,
|
|
260881
261036
|
result: outcome,
|
|
260882
261037
|
error: outcome.status === "failed" ? outcome.error.message : outcome.status === "aborted" ? outcome.message : void 0
|
|
260883
261038
|
});
|
|
@@ -261451,11 +261606,11 @@ ${diff.substring(0, 2e4)}`
|
|
|
261451
261606
|
const safePath = resolveSafePath(this.cwd, backup.path);
|
|
261452
261607
|
try {
|
|
261453
261608
|
if (backup.originalContent === null) {
|
|
261454
|
-
if (
|
|
261455
|
-
|
|
261609
|
+
if (fs32.existsSync(safePath)) {
|
|
261610
|
+
fs32.unlinkSync(safePath);
|
|
261456
261611
|
}
|
|
261457
261612
|
} else {
|
|
261458
|
-
|
|
261613
|
+
fs32.writeFileSync(safePath, backup.originalContent, "utf8");
|
|
261459
261614
|
}
|
|
261460
261615
|
return true;
|
|
261461
261616
|
} catch {
|
|
@@ -263146,7 +263301,7 @@ function latestObservation(metadata) {
|
|
|
263146
263301
|
}
|
|
263147
263302
|
function buildCacheDiagnostics(cwd) {
|
|
263148
263303
|
const dir = join10(cwd, ".orbit", "cache-slabs");
|
|
263149
|
-
if (!
|
|
263304
|
+
if (!existsSync11(dir)) {
|
|
263150
263305
|
return picocolors4.gray(
|
|
263151
263306
|
"\u25CF No cache telemetry yet. It will appear after a completed DeepSeek request."
|
|
263152
263307
|
);
|
|
@@ -263826,11 +263981,11 @@ function statusLine(ok, text, warn = false) {
|
|
|
263826
263981
|
return warn ? picocolors6.yellow(`\u26A0\uFE0F ${text}`) : picocolors6.red(`\u2716 ${text}`);
|
|
263827
263982
|
}
|
|
263828
263983
|
function packageManager(cwd) {
|
|
263829
|
-
if (
|
|
263830
|
-
if (
|
|
263831
|
-
if (
|
|
263832
|
-
if (
|
|
263833
|
-
if (
|
|
263984
|
+
if (existsSync12(join11(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
263985
|
+
if (existsSync12(join11(cwd, "yarn.lock"))) return "yarn";
|
|
263986
|
+
if (existsSync12(join11(cwd, "bun.lockb"))) return "bun";
|
|
263987
|
+
if (existsSync12(join11(cwd, "package-lock.json"))) return "npm";
|
|
263988
|
+
if (existsSync12(join11(cwd, "package.json"))) return "npm";
|
|
263834
263989
|
return "unknown";
|
|
263835
263990
|
}
|
|
263836
263991
|
function boolText(value) {
|
|
@@ -264094,7 +264249,7 @@ function buildDeepSeekDoctorSection(cwd, config) {
|
|
|
264094
264249
|
);
|
|
264095
264250
|
lines.push(
|
|
264096
264251
|
picocolors6.gray(
|
|
264097
|
-
`\u25CF Orbit 0731 policy: Flash=${config.agent?.fastMaxOutputTokens ??
|
|
264252
|
+
`\u25CF Orbit 0731 policy: Flash=${config.agent?.fastMaxOutputTokens ?? 32768} output tokens with thinking low for simple work, high for complex work, and max for repair; Pro=${config.agent?.maxOutputTokens ?? 16384} with thinking high/max.`
|
|
264098
264253
|
)
|
|
264099
264254
|
);
|
|
264100
264255
|
lines.push(
|
|
@@ -266143,7 +266298,7 @@ import picocolors20 from "picocolors";
|
|
|
266143
266298
|
// src/tui/FullscreenTui.ts
|
|
266144
266299
|
import { join as join13 } from "path";
|
|
266145
266300
|
import { homedir as homedir7 } from "os";
|
|
266146
|
-
import { existsSync as
|
|
266301
|
+
import { existsSync as existsSync13 } from "fs";
|
|
266147
266302
|
import { exec as exec3 } from "child_process";
|
|
266148
266303
|
import readline3 from "readline";
|
|
266149
266304
|
|
|
@@ -268145,9 +268300,9 @@ var FullscreenTui = class {
|
|
|
268145
268300
|
const planPath2 = join13(this.cwd, ".orbit", "task.md");
|
|
268146
268301
|
const planPath1 = join13(this.cwd, "task.md");
|
|
268147
268302
|
let planPath = "";
|
|
268148
|
-
if (
|
|
268303
|
+
if (existsSync13(planPath2)) {
|
|
268149
268304
|
planPath = planPath2;
|
|
268150
|
-
} else if (
|
|
268305
|
+
} else if (existsSync13(planPath1)) {
|
|
268151
268306
|
planPath = planPath1;
|
|
268152
268307
|
}
|
|
268153
268308
|
if (!planPath) {
|
|
@@ -270146,7 +270301,7 @@ import { z as z67 } from "zod";
|
|
|
270146
270301
|
import picocolors18 from "picocolors";
|
|
270147
270302
|
|
|
270148
270303
|
// src/commands/customCommands.ts
|
|
270149
|
-
import { existsSync as
|
|
270304
|
+
import { existsSync as existsSync14, readdirSync as readdirSync6 } from "fs";
|
|
270150
270305
|
import { basename as basename4, extname as extname2, join as join14 } from "path";
|
|
270151
270306
|
import { homedir as homedir8 } from "os";
|
|
270152
270307
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -270203,7 +270358,7 @@ function parseCommandFile(filePath, source) {
|
|
|
270203
270358
|
};
|
|
270204
270359
|
}
|
|
270205
270360
|
function loadDirectory(directory, source) {
|
|
270206
|
-
if (!
|
|
270361
|
+
if (!existsSync14(directory)) return [];
|
|
270207
270362
|
const commands = [];
|
|
270208
270363
|
const queue = [directory];
|
|
270209
270364
|
while (queue.length > 0 && commands.length < 200) {
|
|
@@ -270273,7 +270428,7 @@ function resolveBundledCommandsDirectory() {
|
|
|
270273
270428
|
new URL("../../commands/", import.meta.url),
|
|
270274
270429
|
new URL("../commands/", import.meta.url)
|
|
270275
270430
|
].map((candidate) => fileURLToPath3(candidate));
|
|
270276
|
-
return candidates.find((candidate) =>
|
|
270431
|
+
return candidates.find((candidate) => existsSync14(candidate)) ?? candidates[0];
|
|
270277
270432
|
}
|
|
270278
270433
|
function expandCustomCommand(command, rawArguments) {
|
|
270279
270434
|
const args = rawArguments.trim();
|
|
@@ -270363,7 +270518,7 @@ import { z as z56 } from "zod";
|
|
|
270363
270518
|
|
|
270364
270519
|
// src/runtime/AutocompleteCandidates.ts
|
|
270365
270520
|
import glob4 from "fast-glob";
|
|
270366
|
-
import { existsSync as
|
|
270521
|
+
import { existsSync as existsSync15, readdirSync as readdirSync7 } from "fs";
|
|
270367
270522
|
import { homedir as homedir9 } from "os";
|
|
270368
270523
|
import { dirname as dirname8, join as join15, resolve as resolve7 } from "path";
|
|
270369
270524
|
import { z as z51 } from "zod";
|
|
@@ -270426,7 +270581,7 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
|
|
|
270426
270581
|
}
|
|
270427
270582
|
try {
|
|
270428
270583
|
const indexPath = join15(cwd, ".orbit", "symbols.json");
|
|
270429
|
-
if (
|
|
270584
|
+
if (existsSync15(indexPath)) {
|
|
270430
270585
|
const raw = await readBoundedRegularFileAsync(
|
|
270431
270586
|
indexPath,
|
|
270432
270587
|
AUTOCOMPLETE_SYMBOL_INDEX_MAX_BYTES
|
|
@@ -270448,9 +270603,9 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
|
|
|
270448
270603
|
cwd,
|
|
270449
270604
|
config.session?.path ?? ".orbit/sessions"
|
|
270450
270605
|
);
|
|
270451
|
-
if (
|
|
270606
|
+
if (existsSync15(sessionDir)) {
|
|
270452
270607
|
for (const dir of readdirSync7(sessionDir)) {
|
|
270453
|
-
if (
|
|
270608
|
+
if (existsSync15(join15(sessionDir, dir, "session.json"))) {
|
|
270454
270609
|
sessions.push(dir);
|
|
270455
270610
|
}
|
|
270456
270611
|
}
|
|
@@ -275845,8 +276000,9 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
275845
276000
|
} else if (['agent_start', 'agent_spawn', 'agent_status', 'agent_completed'].includes(event.type)) {
|
|
275846
276001
|
const agentId = payload.childId || payload.taskId || payload.role || 'agent';
|
|
275847
276002
|
const role = payload.role || payload.task || agentId;
|
|
275848
|
-
const
|
|
275849
|
-
const
|
|
276003
|
+
const paused = event.type === 'agent_completed' && payload.status === 'aborted';
|
|
276004
|
+
const status = paused ? 'paused' : (payload.status || (event.type === 'agent_completed' ? (payload.success ? copy.done : copy.error) : copy.running));
|
|
276005
|
+
const kind = event.type === 'agent_completed' ? (paused ? 'warning' : (payload.success ? 'success' : 'error')) : '';
|
|
275850
276006
|
addActivity(role + ' · ' + status, kind, 'agent-' + agentId);
|
|
275851
276007
|
void reconcileStatus();
|
|
275852
276008
|
} else if (['agent_input_queued', 'agent_input_consumed', 'agent_input_removed', 'agent_input_updated', 'agent_input_moved', 'agent_input_queue_cleared'].includes(event.type)) {
|
|
@@ -276352,9 +276508,13 @@ function sanitizeWebEventPayload(type, payload) {
|
|
|
276352
276508
|
case "agent_completed": {
|
|
276353
276509
|
const taskId = safeWebText(payload.taskId, 200);
|
|
276354
276510
|
if (!taskId) return void 0;
|
|
276511
|
+
const status = ["completed", "failed", "aborted"].includes(
|
|
276512
|
+
String(payload.status)
|
|
276513
|
+
) ? String(payload.status) : void 0;
|
|
276355
276514
|
return {
|
|
276356
276515
|
taskId,
|
|
276357
276516
|
success: payload.success === true,
|
|
276517
|
+
...status ? { status } : {},
|
|
276358
276518
|
error: safeWebText(payload.error, 1e3)
|
|
276359
276519
|
};
|
|
276360
276520
|
}
|
|
@@ -286561,7 +286721,7 @@ async function handleWorkspaceConfigCommand(configArgument, dependencies) {
|
|
|
286561
286721
|
|
|
286562
286722
|
// src/runtime/commands/ContextCommandHandler.ts
|
|
286563
286723
|
import glob5 from "fast-glob";
|
|
286564
|
-
import { existsSync as
|
|
286724
|
+
import { existsSync as existsSync16, statSync as statSync3 } from "fs";
|
|
286565
286725
|
import { isAbsolute as isAbsolute6, relative as relative8, resolve as resolve10 } from "path";
|
|
286566
286726
|
import picocolors12 from "picocolors";
|
|
286567
286727
|
function parseAddArgument(argument) {
|
|
@@ -286711,7 +286871,7 @@ async function handleAdd(argument, dependencies) {
|
|
|
286711
286871
|
);
|
|
286712
286872
|
return HANDLED_COMMAND;
|
|
286713
286873
|
}
|
|
286714
|
-
if (!
|
|
286874
|
+
if (!existsSync16(absolutePath)) {
|
|
286715
286875
|
const normalizedArgument = fileArgument.toLowerCase();
|
|
286716
286876
|
const matched = candidates.filter(
|
|
286717
286877
|
(file) => file.toLowerCase().includes(normalizedArgument) || file.toLowerCase().endsWith(`/${normalizedArgument}`)
|
|
@@ -286914,7 +287074,7 @@ async function handleContextCommand(command, argument, dependencies) {
|
|
|
286914
287074
|
|
|
286915
287075
|
// src/runtime/commands/RollbackCommandHandler.ts
|
|
286916
287076
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
286917
|
-
import { existsSync as
|
|
287077
|
+
import { existsSync as existsSync17, rmSync as rmSync5 } from "fs";
|
|
286918
287078
|
import picocolors13 from "picocolors";
|
|
286919
287079
|
import { z as z57 } from "zod";
|
|
286920
287080
|
var GitStatusCodeSchema = z57.string().length(2).regex(/^[ MADRCU?!]{2}$/);
|
|
@@ -287024,7 +287184,7 @@ async function handleRollbackCommand(command, argument, dependencies) {
|
|
|
287024
287184
|
try {
|
|
287025
287185
|
git.checkout(dependencies.cwd, filePath);
|
|
287026
287186
|
} catch {
|
|
287027
|
-
if (
|
|
287187
|
+
if (existsSync17(absolutePath)) {
|
|
287028
287188
|
(dependencies.removePath ?? removeWorkspacePath)(absolutePath);
|
|
287029
287189
|
}
|
|
287030
287190
|
}
|
|
@@ -287749,7 +287909,7 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
|
|
|
287749
287909
|
|
|
287750
287910
|
// src/runtime/ProjectLauncher.ts
|
|
287751
287911
|
import { spawn as spawn3 } from "child_process";
|
|
287752
|
-
import { existsSync as
|
|
287912
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync6, realpathSync as realpathSync3, statSync as statSync4 } from "fs";
|
|
287753
287913
|
import { dirname as dirname9, isAbsolute as isAbsolute7, parse as parse4, resolve as resolve11 } from "path";
|
|
287754
287914
|
var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
|
|
287755
287915
|
async function launchOrbitProject(request, options = {}) {
|
|
@@ -287840,11 +288000,11 @@ function parseReadyUrl(message2) {
|
|
|
287840
288000
|
return sanitizeLocalWebUiUrl(message2.url);
|
|
287841
288001
|
}
|
|
287842
288002
|
function createProjectDirectory(projectPath) {
|
|
287843
|
-
if (
|
|
288003
|
+
if (existsSync18(projectPath)) {
|
|
287844
288004
|
throw new Error("Project folder already exists. Use Open folder instead.");
|
|
287845
288005
|
}
|
|
287846
288006
|
const parentPath = dirname9(projectPath);
|
|
287847
|
-
if (!
|
|
288007
|
+
if (!existsSync18(parentPath)) {
|
|
287848
288008
|
throw new Error(
|
|
287849
288009
|
"The parent folder does not exist. Choose an existing location first."
|
|
287850
288010
|
);
|
|
@@ -287866,7 +288026,7 @@ function createProjectDirectory(projectPath) {
|
|
|
287866
288026
|
}
|
|
287867
288027
|
}
|
|
287868
288028
|
function requireProjectDirectory(projectPath) {
|
|
287869
|
-
if (!
|
|
288029
|
+
if (!existsSync18(projectPath)) {
|
|
287870
288030
|
throw new Error("Project folder does not exist.");
|
|
287871
288031
|
}
|
|
287872
288032
|
if (!statSync4(projectPath).isDirectory()) {
|
|
@@ -289672,7 +289832,7 @@ ${picocolors18.green("\u2714")} Switched security mode to: ${picocolors18.green(
|
|
|
289672
289832
|
);
|
|
289673
289833
|
return { shouldExit: false, processed: true };
|
|
289674
289834
|
}
|
|
289675
|
-
return { shouldExit: false, processed: false };
|
|
289835
|
+
return { shouldExit: false, processed: false, input: trimmed };
|
|
289676
289836
|
}
|
|
289677
289837
|
async submitWebPrompt(prompt, attachments = [], executionMode = "default") {
|
|
289678
289838
|
const trimmed = prompt.trim();
|
|
@@ -289714,13 +289874,14 @@ ${picocolors18.green("\u2714")} Switched security mode to: ${picocolors18.green(
|
|
|
289714
289874
|
if (routeResult.processed) {
|
|
289715
289875
|
return { ok: true };
|
|
289716
289876
|
}
|
|
289877
|
+
const routedPrompt = routeResult.input ?? trimmed;
|
|
289717
289878
|
if (this.tui.isActive) {
|
|
289718
289879
|
this.tui.addUserMessage(trimmed);
|
|
289719
289880
|
} else {
|
|
289720
289881
|
console.log(picocolors18.cyan(`web \u203A ${trimmed}`));
|
|
289721
289882
|
}
|
|
289722
289883
|
this.loop.prepareUserTurn(
|
|
289723
|
-
|
|
289884
|
+
routedPrompt,
|
|
289724
289885
|
attachments.map((attachment) => ({
|
|
289725
289886
|
type: "image",
|
|
289726
289887
|
mediaType: attachment.mediaType,
|
|
@@ -289742,7 +289903,7 @@ ${picocolors18.green("\u2714")} Switched security mode to: ${picocolors18.green(
|
|
|
289742
289903
|
this.cwd,
|
|
289743
289904
|
this.config,
|
|
289744
289905
|
this.providerInstance,
|
|
289745
|
-
|
|
289906
|
+
routedPrompt,
|
|
289746
289907
|
webInteraction
|
|
289747
289908
|
);
|
|
289748
289909
|
}
|
|
@@ -290594,7 +290755,8 @@ Risk Warning: ${reason}`);
|
|
|
290594
290755
|
tuiInteraction,
|
|
290595
290756
|
{
|
|
290596
290757
|
disableStatusBar: useFullscreenTui,
|
|
290597
|
-
sessionId: resumeSessionId
|
|
290758
|
+
sessionId: resumeSessionId,
|
|
290759
|
+
autoContinueRunaway: isFullAccessEnabled(this.config)
|
|
290598
290760
|
}
|
|
290599
290761
|
);
|
|
290600
290762
|
tui.setActiveInputHandler((submitted) => {
|
|
@@ -290869,7 +291031,8 @@ Risk Warning: ${reason}`);
|
|
|
290869
291031
|
if (routeResult.processed) {
|
|
290870
291032
|
continue;
|
|
290871
291033
|
}
|
|
290872
|
-
|
|
291034
|
+
const routedInput = routeResult.input ?? trimmed;
|
|
291035
|
+
loop.prepareUserTurn(routedInput);
|
|
290873
291036
|
const terminalTurnId = randomUUID11();
|
|
290874
291037
|
eventBus.emitEvent("ui_turn_started", {
|
|
290875
291038
|
turnId: terminalTurnId,
|
|
@@ -290883,7 +291046,7 @@ Risk Warning: ${reason}`);
|
|
|
290883
291046
|
this.cwd,
|
|
290884
291047
|
this.config,
|
|
290885
291048
|
this.providerInstance,
|
|
290886
|
-
|
|
291049
|
+
routedInput,
|
|
290887
291050
|
tuiInteraction
|
|
290888
291051
|
);
|
|
290889
291052
|
tui.setActiveRunnable(orchestratorInstance);
|
|
@@ -291247,7 +291410,7 @@ Risk Warning: ${reason}`);
|
|
|
291247
291410
|
requireSession: Boolean(options?.resumeSessionId),
|
|
291248
291411
|
disableStatusBar: !!options?.nonInteractive || !!options?.jsonl,
|
|
291249
291412
|
nonInteractive: !!options?.nonInteractive,
|
|
291250
|
-
autoContinueRunaway: !!options?.autoContinueRunaway
|
|
291413
|
+
autoContinueRunaway: !!options?.autoContinueRunaway || isFullAccessEnabled(config)
|
|
291251
291414
|
}
|
|
291252
291415
|
);
|
|
291253
291416
|
return await loop.run();
|
|
@@ -292154,7 +292317,7 @@ async function runSkillsCommand(action, options = {}) {
|
|
|
292154
292317
|
|
|
292155
292318
|
// src/commands/trace.ts
|
|
292156
292319
|
import {
|
|
292157
|
-
existsSync as
|
|
292320
|
+
existsSync as existsSync19,
|
|
292158
292321
|
lstatSync as lstatSync6,
|
|
292159
292322
|
mkdirSync as mkdirSync7,
|
|
292160
292323
|
renameSync as renameSync4,
|
|
@@ -292182,7 +292345,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
|
|
|
292182
292345
|
}
|
|
292183
292346
|
const outputPath = resolveSafePath(cwd, value.out);
|
|
292184
292347
|
const directory = dirname11(outputPath);
|
|
292185
|
-
if (
|
|
292348
|
+
if (existsSync19(directory)) {
|
|
292186
292349
|
const stats = lstatSync6(directory);
|
|
292187
292350
|
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
292188
292351
|
throw new Error("Trace output directory must be a real directory.");
|
|
@@ -292197,7 +292360,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
|
|
|
292197
292360
|
flag: "wx",
|
|
292198
292361
|
mode: 384
|
|
292199
292362
|
});
|
|
292200
|
-
if (
|
|
292363
|
+
if (existsSync19(outputPath)) rmSync7(outputPath, { force: true });
|
|
292201
292364
|
renameSync4(temporaryPath, outputPath);
|
|
292202
292365
|
} finally {
|
|
292203
292366
|
rmSync7(temporaryPath, { force: true });
|
|
@@ -292209,7 +292372,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
|
|
|
292209
292372
|
import { exec as execCallback, execFileSync as execFileSync7 } from "child_process";
|
|
292210
292373
|
import {
|
|
292211
292374
|
copyFileSync,
|
|
292212
|
-
existsSync as
|
|
292375
|
+
existsSync as existsSync20,
|
|
292213
292376
|
lstatSync as lstatSync7,
|
|
292214
292377
|
mkdirSync as mkdirSync8,
|
|
292215
292378
|
renameSync as renameSync5,
|
|
@@ -292548,7 +292711,7 @@ function writeEvaluationReport(cwd, runId, report) {
|
|
|
292548
292711
|
}
|
|
292549
292712
|
function writeJsonAtomically2(filePath, value) {
|
|
292550
292713
|
const directory = dirname12(filePath);
|
|
292551
|
-
if (
|
|
292714
|
+
if (existsSync20(directory)) {
|
|
292552
292715
|
const stats = lstatSync7(directory);
|
|
292553
292716
|
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
292554
292717
|
throw new Error("Evaluation output directory must be a real directory.");
|
|
@@ -292563,7 +292726,7 @@ function writeJsonAtomically2(filePath, value) {
|
|
|
292563
292726
|
flag: "wx",
|
|
292564
292727
|
mode: 384
|
|
292565
292728
|
});
|
|
292566
|
-
if (
|
|
292729
|
+
if (existsSync20(filePath)) rmSync8(filePath, { force: true });
|
|
292567
292730
|
renameSync5(temporaryPath, filePath);
|
|
292568
292731
|
} finally {
|
|
292569
292732
|
rmSync8(temporaryPath, { force: true });
|
|
@@ -292834,7 +292997,7 @@ import { z as z76 } from "zod";
|
|
|
292834
292997
|
|
|
292835
292998
|
// src/runtime/ProjectBackup.ts
|
|
292836
292999
|
import {
|
|
292837
|
-
existsSync as
|
|
293000
|
+
existsSync as existsSync21,
|
|
292838
293001
|
lstatSync as lstatSync9,
|
|
292839
293002
|
mkdirSync as mkdirSync9,
|
|
292840
293003
|
readdirSync as readdirSync9,
|
|
@@ -292910,7 +293073,7 @@ function createProjectBackup(projectDirectory) {
|
|
|
292910
293073
|
const orbitRoot = join19(projectRoot, ".orbit");
|
|
292911
293074
|
const files = [];
|
|
292912
293075
|
let totalBytes = 0;
|
|
292913
|
-
if (
|
|
293076
|
+
if (existsSync21(orbitRoot)) {
|
|
292914
293077
|
for (const absolutePath of listBackupFiles(orbitRoot)) {
|
|
292915
293078
|
if (files.length >= MAX_BACKUP_FILES) {
|
|
292916
293079
|
throw new Error(`Project backup exceeds ${MAX_BACKUP_FILES} files.`);
|
|
@@ -292989,7 +293152,7 @@ function restoreProjectBackup(projectDirectory, bundle, options = {}) {
|
|
|
292989
293152
|
file,
|
|
292990
293153
|
destination: resolveBackupDestination(orbitRoot, file.path)
|
|
292991
293154
|
}));
|
|
292992
|
-
const conflicts2 = planned.filter(({ destination }) =>
|
|
293155
|
+
const conflicts2 = planned.filter(({ destination }) => existsSync21(destination)).map(({ file }) => file.path);
|
|
292993
293156
|
if (conflicts2.length > 0 && !options.force) {
|
|
292994
293157
|
throw new Error(
|
|
292995
293158
|
`Restore would overwrite ${conflicts2.length} file(s). Re-run with --force after reviewing the backup.`
|
|
@@ -293076,18 +293239,18 @@ function assertDirectoryChainHasNoSymlink(root, target) {
|
|
|
293076
293239
|
throw new Error("Backup restore directory escapes the project.");
|
|
293077
293240
|
}
|
|
293078
293241
|
let current = absoluteRoot;
|
|
293079
|
-
if (
|
|
293242
|
+
if (existsSync21(current) && lstatSync9(current).isSymbolicLink()) {
|
|
293080
293243
|
throw new Error(`Refusing to restore through symbolic link: ${current}`);
|
|
293081
293244
|
}
|
|
293082
293245
|
for (const part of relativeTarget.split(sep2).filter(Boolean)) {
|
|
293083
293246
|
current = join19(current, part);
|
|
293084
|
-
if (
|
|
293247
|
+
if (existsSync21(current) && lstatSync9(current).isSymbolicLink()) {
|
|
293085
293248
|
throw new Error(`Refusing to restore through symbolic link: ${current}`);
|
|
293086
293249
|
}
|
|
293087
293250
|
}
|
|
293088
293251
|
}
|
|
293089
293252
|
function replaceFileAtomically2(temporaryPath, destination) {
|
|
293090
|
-
if (!
|
|
293253
|
+
if (!existsSync21(destination)) {
|
|
293091
293254
|
renameSync6(temporaryPath, destination);
|
|
293092
293255
|
return;
|
|
293093
293256
|
}
|
|
@@ -293097,7 +293260,7 @@ function replaceFileAtomically2(temporaryPath, destination) {
|
|
|
293097
293260
|
renameSync6(temporaryPath, destination);
|
|
293098
293261
|
rmSync10(previousPath, { force: true });
|
|
293099
293262
|
} catch (error) {
|
|
293100
|
-
if (!
|
|
293263
|
+
if (!existsSync21(destination) && existsSync21(previousPath)) {
|
|
293101
293264
|
renameSync6(previousPath, destination);
|
|
293102
293265
|
}
|
|
293103
293266
|
throw error;
|
|
@@ -293209,7 +293372,7 @@ import picocolors28 from "picocolors";
|
|
|
293209
293372
|
|
|
293210
293373
|
// src/runtime/ExtensionManager.ts
|
|
293211
293374
|
import {
|
|
293212
|
-
existsSync as
|
|
293375
|
+
existsSync as existsSync28,
|
|
293213
293376
|
lstatSync as lstatSync10,
|
|
293214
293377
|
mkdirSync as mkdirSync10,
|
|
293215
293378
|
readdirSync as readdirSync10,
|
|
@@ -293248,7 +293411,7 @@ var ExtensionManager = class {
|
|
|
293248
293411
|
list() {
|
|
293249
293412
|
try {
|
|
293250
293413
|
return this.readRegistry().filter(
|
|
293251
|
-
(extension) => this.isManagedExtensionPath(extension) &&
|
|
293414
|
+
(extension) => this.isManagedExtensionPath(extension) && existsSync28(extension.path) && !lstatSync10(extension.path).isSymbolicLink()
|
|
293252
293415
|
);
|
|
293253
293416
|
} catch {
|
|
293254
293417
|
return [];
|
|
@@ -293301,12 +293464,12 @@ var ExtensionManager = class {
|
|
|
293301
293464
|
try {
|
|
293302
293465
|
copyDirectorySafely(sourceRoot, staging);
|
|
293303
293466
|
const digest = hashExtensionDirectory(staging);
|
|
293304
|
-
if (
|
|
293467
|
+
if (existsSync28(target)) {
|
|
293305
293468
|
renameSync7(target, targetBackup);
|
|
293306
293469
|
targetBackedUp = true;
|
|
293307
293470
|
}
|
|
293308
293471
|
for (const prompt of promptTargets) {
|
|
293309
|
-
if (!
|
|
293472
|
+
if (!existsSync28(prompt.target)) continue;
|
|
293310
293473
|
mkdirSync10(dirname14(prompt.backup), { recursive: true });
|
|
293311
293474
|
renameSync7(prompt.target, prompt.backup);
|
|
293312
293475
|
prompt.backedUp = true;
|
|
@@ -293342,14 +293505,14 @@ var ExtensionManager = class {
|
|
|
293342
293505
|
if (targetInstalled) {
|
|
293343
293506
|
rmSync11(target, { recursive: true, force: true });
|
|
293344
293507
|
}
|
|
293345
|
-
if (targetBackedUp &&
|
|
293508
|
+
if (targetBackedUp && existsSync28(targetBackup)) {
|
|
293346
293509
|
renameSync7(targetBackup, target);
|
|
293347
293510
|
}
|
|
293348
293511
|
for (const prompt of promptTargets) {
|
|
293349
293512
|
if (promptMutationStarted) {
|
|
293350
293513
|
rmSync11(prompt.target, { recursive: true, force: true });
|
|
293351
293514
|
}
|
|
293352
|
-
if (prompt.backedUp &&
|
|
293515
|
+
if (prompt.backedUp && existsSync28(prompt.backup)) {
|
|
293353
293516
|
mkdirSync10(dirname14(prompt.target), { recursive: true });
|
|
293354
293517
|
renameSync7(prompt.backup, prompt.target);
|
|
293355
293518
|
}
|
|
@@ -293377,7 +293540,7 @@ var ExtensionManager = class {
|
|
|
293377
293540
|
);
|
|
293378
293541
|
}
|
|
293379
293542
|
const installed = registry.find(
|
|
293380
|
-
(entry) => entry.id === id &&
|
|
293543
|
+
(entry) => entry.id === id && existsSync28(entry.path) && !lstatSync10(entry.path).isSymbolicLink()
|
|
293381
293544
|
);
|
|
293382
293545
|
if (!installed) return false;
|
|
293383
293546
|
const rollbackRoot = join20(
|
|
@@ -293397,7 +293560,7 @@ var ExtensionManager = class {
|
|
|
293397
293560
|
].map((entry) => ({ ...entry, backedUp: false }));
|
|
293398
293561
|
try {
|
|
293399
293562
|
for (const entry of targets) {
|
|
293400
|
-
if (!
|
|
293563
|
+
if (!existsSync28(entry.target)) continue;
|
|
293401
293564
|
mkdirSync10(dirname14(entry.backup), { recursive: true });
|
|
293402
293565
|
renameSync7(entry.target, entry.backup);
|
|
293403
293566
|
entry.backedUp = true;
|
|
@@ -293408,7 +293571,7 @@ var ExtensionManager = class {
|
|
|
293408
293571
|
} catch (error) {
|
|
293409
293572
|
try {
|
|
293410
293573
|
for (const entry of targets) {
|
|
293411
|
-
if (!entry.backedUp || !
|
|
293574
|
+
if (!entry.backedUp || !existsSync28(entry.backup)) continue;
|
|
293412
293575
|
mkdirSync10(dirname14(entry.target), { recursive: true });
|
|
293413
293576
|
renameSync7(entry.backup, entry.target);
|
|
293414
293577
|
}
|
|
@@ -293537,7 +293700,7 @@ function validateContributionFiles(root, manifest) {
|
|
|
293537
293700
|
`Invalid extension contribution path: ${contribution.path}`
|
|
293538
293701
|
);
|
|
293539
293702
|
}
|
|
293540
|
-
if (!
|
|
293703
|
+
if (!existsSync28(target) || lstatSync10(target).isSymbolicLink()) {
|
|
293541
293704
|
throw new Error(
|
|
293542
293705
|
`Extension contribution is missing or unsafe: ${contribution.path}`
|
|
293543
293706
|
);
|
|
@@ -293688,18 +293851,11 @@ function removeExtension(id) {
|
|
|
293688
293851
|
}
|
|
293689
293852
|
|
|
293690
293853
|
// src/index.ts
|
|
293691
|
-
import { existsSync as
|
|
293854
|
+
import { existsSync as existsSync29, realpathSync as realpathSync4, statSync as statSync5 } from "fs";
|
|
293692
293855
|
import { resolve as resolve19 } from "path";
|
|
293693
|
-
|
|
293694
|
-
|
|
293695
|
-
|
|
293696
|
-
process.exitCode = Math.max(currentExitCode, exitCodeForOutcome(outcome));
|
|
293697
|
-
}
|
|
293698
|
-
program.name("orbit").description("Orbit - Local AI Coding Agent Runtime").version(readCliVersion()).argument("[task]", "task description for Orbit to execute").option("--provider <provider>", "specify model provider").option("--model <model>", "specify model name").option(
|
|
293699
|
-
"--yes",
|
|
293700
|
-
"enable guarded Full Access for this run (dangerous commands and secrets stay protected)"
|
|
293701
|
-
).option("--multi", "run in multi-agent planning/coding/review mode").option("--direct", "run interactive REPL in direct console streaming mode").action(async (task, options) => {
|
|
293702
|
-
const cwd = process.cwd();
|
|
293856
|
+
|
|
293857
|
+
// src/runtime/CliRunOverrides.ts
|
|
293858
|
+
function createCliRunOverrides(options) {
|
|
293703
293859
|
const overrides = {};
|
|
293704
293860
|
if (options.provider) {
|
|
293705
293861
|
overrides.provider = { default: options.provider };
|
|
@@ -293710,9 +293866,29 @@ program.name("orbit").description("Orbit - Local AI Coding Agent Runtime").versi
|
|
|
293710
293866
|
if (options.direct) {
|
|
293711
293867
|
overrides.direct = true;
|
|
293712
293868
|
}
|
|
293713
|
-
if (options.
|
|
293869
|
+
if (options.fullAccess) {
|
|
293714
293870
|
overrides.permissions = createPermissionModeOverride("auto").permissions;
|
|
293715
293871
|
}
|
|
293872
|
+
return overrides;
|
|
293873
|
+
}
|
|
293874
|
+
|
|
293875
|
+
// src/index.ts
|
|
293876
|
+
var program = new Command();
|
|
293877
|
+
function applyOutcomeExitCode(outcome) {
|
|
293878
|
+
const currentExitCode = typeof process.exitCode === "number" ? process.exitCode : 0;
|
|
293879
|
+
process.exitCode = Math.max(currentExitCode, exitCodeForOutcome(outcome));
|
|
293880
|
+
}
|
|
293881
|
+
program.name("orbit").description("Orbit - Local AI Coding Agent Runtime").version(readCliVersion()).argument("[task]", "task description for Orbit to execute").option("--provider <provider>", "specify model provider").option("--model <model>", "specify model name").option(
|
|
293882
|
+
"--yes",
|
|
293883
|
+
"enable guarded Full Access for this run (dangerous commands and secrets stay protected)"
|
|
293884
|
+
).option("--multi", "run in multi-agent planning/coding/review mode").option("--direct", "run interactive REPL in direct console streaming mode").action(async (task, options) => {
|
|
293885
|
+
const cwd = process.cwd();
|
|
293886
|
+
const overrides = createCliRunOverrides({
|
|
293887
|
+
provider: options.provider,
|
|
293888
|
+
model: options.model,
|
|
293889
|
+
direct: !!options.direct,
|
|
293890
|
+
fullAccess: !!options.yes
|
|
293891
|
+
});
|
|
293716
293892
|
const outcome = await runAgent(cwd, task, overrides, !!options.multi);
|
|
293717
293893
|
applyOutcomeExitCode(outcome);
|
|
293718
293894
|
});
|
|
@@ -293898,18 +294074,14 @@ program.command("webui").description("start Orbit as a browser-first local codin
|
|
|
293898
294074
|
if (port !== void 0 && (!Number.isInteger(port) || port < 0 || port > 65535)) {
|
|
293899
294075
|
throw new Error("Web UI port must be an integer from 0 to 65535.");
|
|
293900
294076
|
}
|
|
293901
|
-
const overrides = {
|
|
293902
|
-
|
|
293903
|
-
|
|
293904
|
-
|
|
293905
|
-
|
|
293906
|
-
|
|
293907
|
-
}
|
|
293908
|
-
if (options.yes) {
|
|
293909
|
-
overrides.permissions = { mode: "auto" };
|
|
293910
|
-
}
|
|
294077
|
+
const overrides = createCliRunOverrides({
|
|
294078
|
+
provider: options.provider,
|
|
294079
|
+
model: options.model,
|
|
294080
|
+
direct: true,
|
|
294081
|
+
fullAccess: !!options.yes
|
|
294082
|
+
});
|
|
293911
294083
|
const requestedCwd = resolve19(localOptions.cwd || process.cwd());
|
|
293912
|
-
if (!
|
|
294084
|
+
if (!existsSync29(requestedCwd) || !statSync5(requestedCwd).isDirectory()) {
|
|
293913
294085
|
throw new Error(
|
|
293914
294086
|
`Web UI project directory does not exist: ${requestedCwd}`
|
|
293915
294087
|
);
|
|
@@ -293923,13 +294095,11 @@ program.command("webui").description("start Orbit as a browser-first local codin
|
|
|
293923
294095
|
program.command("exec").description("run a task in non-interactive mode and stream events as JSONL").argument("<prompt>", "the task prompt to execute").option("--provider <provider>", "specify model provider").option("--model <model>", "specify model name").option("--resume <session>", "resume a persisted Orbit session").option("--jsonl", "output event logs in JSONL format").action(async (prompt, localOptions, command) => {
|
|
293924
294096
|
const options = { ...command.optsWithGlobals(), ...localOptions };
|
|
293925
294097
|
const cwd = process.cwd();
|
|
293926
|
-
const overrides = {
|
|
293927
|
-
|
|
293928
|
-
|
|
293929
|
-
|
|
293930
|
-
|
|
293931
|
-
overrides.models = { default: options.model };
|
|
293932
|
-
}
|
|
294098
|
+
const overrides = createCliRunOverrides({
|
|
294099
|
+
provider: options.provider,
|
|
294100
|
+
model: options.model,
|
|
294101
|
+
fullAccess: !!options.yes
|
|
294102
|
+
});
|
|
293933
294103
|
const outcome = await runAgent(cwd, prompt, overrides, false, {
|
|
293934
294104
|
nonInteractive: true,
|
|
293935
294105
|
jsonl: !!options.jsonl,
|