toolroll 0.9.125 → 0.9.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/README.md +1 -1
- package/dist/agent-detect.js +23 -3
- package/dist/assignment.js +14 -4
- package/dist/bounded-spawn.js +5 -36
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +29 -29
- package/dist/browser-open.js +49 -0
- package/dist/chat-acceptance.js +1 -1
- package/dist/check-only.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/connect-cli.js +2 -8
- package/dist/contracts/engine-api.js +8 -0
- package/dist/direct-chat.js +26 -18
- package/dist/doctor.js +30 -3
- package/dist/easy-start.js +44 -17
- package/dist/engine-reads.js +34 -1
- package/dist/evals.js +17 -19
- package/dist/first-run.js +5 -1
- package/dist/flexible-conversation.js +79 -1
- package/dist/flexible-import.js +162 -4
- package/dist/flexible-save.js +51 -4
- package/dist/flexible-session.js +34 -8
- package/dist/flexible-start.js +2 -1
- package/dist/flow-code.js +2 -2
- package/dist/invoke.js +4 -4
- package/dist/landed-rows.js +138 -0
- package/dist/laptop-background.js +2 -11
- package/dist/linux-packages.js +46 -0
- package/dist/local-landing.js +46 -7
- package/dist/merge-checklist.js +62 -8
- package/dist/operate.js +90 -33
- package/dist/preflight.js +14 -0
- package/dist/process-identity.js +155 -0
- package/dist/quick-start.js +6 -1
- package/dist/release.js +8 -0
- package/dist/result-follow-ups.js +8 -1
- package/dist/revision-catch-up.js +98 -0
- package/dist/runner-process.js +9 -25
- package/dist/sandbox-launch.js +3 -2
- package/dist/sandbox-runtime.js +115 -15
- package/dist/sandbox-tools.js +91 -6
- package/dist/server/direct-chat.js +4 -3
- package/dist/server/engine-api.js +13 -8
- package/dist/server/merge-ready-view.js +4 -2
- package/dist/server/pages.js +5 -2
- package/dist/server/render-pages.js +1 -0
- package/dist/server/render-results.js +9 -7
- package/dist/server/render-tasks.js +2 -2
- package/dist/server/task-views.js +16 -9
- package/dist/server/tasks.js +2 -2
- package/dist/shown-text.js +14 -0
- package/dist/skill-library.js +2 -12
- package/dist/status-probe.js +32 -0
- package/dist/task-base.js +13 -2
- package/dist/task-status.js +18 -8
- package/dist/teardown-git.js +6 -0
- package/dist/telegram-status.js +1 -1
- package/dist/toolroll-update-cli.js +2 -1
- package/dist/toolroll-update.js +4 -0
- package/dist/trust-repair.js +187 -0
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/unreachable.js +15 -0
- package/dist/work-index.js +51 -3
- package/dist/workspace-ui.js +4 -2
- package/package.json +1 -1
package/dist/flexible-import.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { closeSync, constants as fsConstants, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, opendirSync, openSync, readFileSync, readSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { closeSync, constants as fsConstants, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, opendirSync, openSync, readFileSync, readSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
4
4
|
import { FLEXIBLE_UNAVAILABLE } from "./flexible.js";
|
|
5
5
|
import { flexibleProjectKnown, flexibleThread, flexibleThreadBranch, flexibleThreadPaths, withFlexibleThreadLock } from "./flexible-thread.js";
|
|
@@ -8,7 +8,8 @@ import { PROTECTED_FILES, protectedChanges, protectedLinks } from "./agent-fence
|
|
|
8
8
|
import { scanPatchForSecrets } from "./evidence.js";
|
|
9
9
|
import { PROOF_LIMITS } from "./proof.js";
|
|
10
10
|
import { run } from "./exec.js";
|
|
11
|
-
import { hardenedGit, recordedCommonDir } from "./teardown-git.js";
|
|
11
|
+
import { hardenedGit, recordedCommonDir, viewedGitSync } from "./teardown-git.js";
|
|
12
|
+
import { identityEnv, projectGitIdentity, THREAD_IDENTITY } from "./git-identity.js";
|
|
12
13
|
const NOTHING = "Nothing was imported.";
|
|
13
14
|
const PRE_WORDS = {
|
|
14
15
|
"not-available": FLEXIBLE_UNAVAILABLE,
|
|
@@ -820,9 +821,10 @@ export async function projectMergeHint(store, input) {
|
|
|
820
821
|
const head = await read(project, ["symbolic-ref", "-q", "HEAD"]);
|
|
821
822
|
const ref = head.code === 0 ? head.stdout.trim() : "";
|
|
822
823
|
if (!ref.startsWith("refs/heads/"))
|
|
823
|
-
return { repo: project, branch: null, fastForward: false };
|
|
824
|
+
return { repo: project, branch: null, fastForward: false, contained: false };
|
|
824
825
|
const ancestor = await read(project, ["merge-base", "--is-ancestor", "--end-of-options", ref, input.candidate]);
|
|
825
|
-
|
|
826
|
+
const contained = await read(project, ["merge-base", "--is-ancestor", "--end-of-options", input.candidate, ref]);
|
|
827
|
+
return { repo: project, branch: ref.slice("refs/heads/".length), fastForward: ancestor.code === 0, contained: contained.code === 0 };
|
|
826
828
|
}
|
|
827
829
|
export async function settleInterruptedImport(store, input) {
|
|
828
830
|
const thread = flexibleThread(store, input.thread);
|
|
@@ -857,3 +859,159 @@ export async function settleInterruptedImport(store, input) {
|
|
|
857
859
|
}
|
|
858
860
|
return { ok: true, importRef: importState, branch: branchState };
|
|
859
861
|
}
|
|
862
|
+
export const LEFTOVER_COMMIT_MESSAGE = "Edits the thread's agent left uncommitted\n\nCommitted by Toolroll when the thread's work was saved.\n";
|
|
863
|
+
function onThreadBranch(paths, id) {
|
|
864
|
+
const file = join(paths.repo, ".git", "HEAD");
|
|
865
|
+
try {
|
|
866
|
+
const held = lstatSync(file);
|
|
867
|
+
if (!held.isFile() || held.isSymbolicLink() || held.size > 512)
|
|
868
|
+
return false;
|
|
869
|
+
return readFileSync(file, "utf8") === `ref: refs/heads/${flexibleThreadBranch(id)}\n`;
|
|
870
|
+
}
|
|
871
|
+
catch {
|
|
872
|
+
return false;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
function nulNames(stdout) {
|
|
876
|
+
const fields = stdout.split("\0");
|
|
877
|
+
if (fields.at(-1) === "")
|
|
878
|
+
fields.pop();
|
|
879
|
+
if (fields.some(one => one === "" || /[\n\r]/.test(one)))
|
|
880
|
+
return null;
|
|
881
|
+
return [...new Set(fields)].sort();
|
|
882
|
+
}
|
|
883
|
+
export async function flexibleLeftover(store, input) {
|
|
884
|
+
const limits = limitsOf(undefined);
|
|
885
|
+
const deadline = Date.now() + limits.importMs;
|
|
886
|
+
const source = sourceOf(store, input.thread, limits, deadline);
|
|
887
|
+
if ("ok" in source)
|
|
888
|
+
return { state: "unknown", why: source.message };
|
|
889
|
+
const tip = threadBranchTip(source.paths, source.thread.id);
|
|
890
|
+
if (tip === null || tip.length !== source.thread.baseSha.length)
|
|
891
|
+
return { state: "unknown", why: "its branch couldn't be read" };
|
|
892
|
+
if (!onThreadBranch(source.paths, source.thread.id))
|
|
893
|
+
return { state: "unknown", why: "its copy isn't on the thread's branch" };
|
|
894
|
+
const inner = input.runner ?? run;
|
|
895
|
+
const repo = source.paths.repo;
|
|
896
|
+
let scratch;
|
|
897
|
+
try {
|
|
898
|
+
const imports = join(source.paths.root, FLEXIBLE_IMPORTS_DIR);
|
|
899
|
+
try {
|
|
900
|
+
mkdirSync(imports, { mode: 0o700 });
|
|
901
|
+
}
|
|
902
|
+
catch (error) {
|
|
903
|
+
if (error.code !== "EEXIST")
|
|
904
|
+
throw error;
|
|
905
|
+
}
|
|
906
|
+
if (!ownFolder(imports))
|
|
907
|
+
return { state: "unknown", why: "Toolroll's own folder for it isn't private" };
|
|
908
|
+
scratch = mkdtempSync(join(imports, `${source.thread.id}-index-`));
|
|
909
|
+
}
|
|
910
|
+
catch {
|
|
911
|
+
return { state: "unknown", why: "Toolroll couldn't make a folder of its own to read it in" };
|
|
912
|
+
}
|
|
913
|
+
const index = join(scratch, "index");
|
|
914
|
+
const git = (mode, args, env = {}, maxBuffer) => {
|
|
915
|
+
const left = deadline - Date.now();
|
|
916
|
+
if (left <= 0)
|
|
917
|
+
throw new DeadlinePassed("the time ran out");
|
|
918
|
+
return hardenedGit(inner, mode, { repo })("git", [...IMPORT_FLAGS, ...args], { cwd: repo, timeoutMs: Math.max(1, Math.min(60_000, left)), env: { ...env, GIT_INDEX_FILE: index }, ...(maxBuffer === undefined ? {} : { maxBuffer }) });
|
|
919
|
+
};
|
|
920
|
+
const big = 32 * 1024 * 1024;
|
|
921
|
+
try {
|
|
922
|
+
if (!input.commit) {
|
|
923
|
+
if ((await git("read", ["read-tree", tip])).code !== 0)
|
|
924
|
+
return { state: "unknown", why: "its branch couldn't be read" };
|
|
925
|
+
const refreshed = await git("read", ["update-index", "-q", "--refresh"]);
|
|
926
|
+
if (refreshed.code !== 0 && refreshed.code !== 1)
|
|
927
|
+
return { state: "unknown", why: "its files couldn't be read" };
|
|
928
|
+
const changed = await git("read", ["diff-files", "--name-only", "-z", "--no-renames"], {}, big);
|
|
929
|
+
const untracked = await git("read", ["ls-files", "-z", "--others", "--exclude-standard"], {}, big);
|
|
930
|
+
const found = changed.code === 0 && untracked.code === 0 ? nulNames(`${changed.stdout}${untracked.stdout}`) : null;
|
|
931
|
+
if (found === null)
|
|
932
|
+
return { state: "unknown", why: "its files couldn't be read" };
|
|
933
|
+
return found.length === 0 ? { state: "none" } : { state: "found", paths: found };
|
|
934
|
+
}
|
|
935
|
+
if ((await git("build", ["read-tree", tip])).code !== 0)
|
|
936
|
+
return { state: "unknown", why: "its branch couldn't be read" };
|
|
937
|
+
if ((await git("build", ["add", "-A"])).code !== 0)
|
|
938
|
+
return { state: "unknown", why: "its files couldn't be read" };
|
|
939
|
+
const raw = await git("build", ["diff", "--cached", "--raw", "--no-renames", "--no-abbrev", "-z", tip], {}, big);
|
|
940
|
+
const staged = raw.code === 0 ? parseRawDiff(raw.stdout) : null;
|
|
941
|
+
if (staged === null)
|
|
942
|
+
return { state: "unknown", why: "its files couldn't be read" };
|
|
943
|
+
if (staged.length === 0)
|
|
944
|
+
return { state: "none" };
|
|
945
|
+
const found = staged.map(one => one.path).sort();
|
|
946
|
+
const keep = (why) => ({ state: "kept", paths: found, why });
|
|
947
|
+
if (staged.length > PROOF_LIMITS.changed)
|
|
948
|
+
return keep(`they change ${staged.length} files, more than Toolroll saves at once`);
|
|
949
|
+
const added = staged.filter(one => one.status !== "D");
|
|
950
|
+
if (added.some(one => one.newMode === "160000"))
|
|
951
|
+
return keep("they hold another repository");
|
|
952
|
+
const placeholders = placeholderBlobs(source.format);
|
|
953
|
+
if (added.some(one => PLACEHOLDER_NAMES.has(one.path) && placeholders.has(one.newSha)))
|
|
954
|
+
return keep("they include one of Toolroll's placeholder files");
|
|
955
|
+
const names = staged.map(one => foldPath(one.path));
|
|
956
|
+
if (names.some(one => one.split("/").includes(".git")) || protectedChanges(names).length > 0
|
|
957
|
+
|| protectedLinks(added.filter(one => one.newMode === "120000").map(one => foldPath(one.path))).length > 0)
|
|
958
|
+
return keep("they touch a file Toolroll protects");
|
|
959
|
+
for (const one of added) {
|
|
960
|
+
let held;
|
|
961
|
+
try {
|
|
962
|
+
held = lstatSync(join(repo, one.path));
|
|
963
|
+
}
|
|
964
|
+
catch {
|
|
965
|
+
return keep("a file changed while it was read");
|
|
966
|
+
}
|
|
967
|
+
if (one.newMode === "120000") {
|
|
968
|
+
if (!held.isSymbolicLink())
|
|
969
|
+
return keep("a file changed while it was read");
|
|
970
|
+
const target = await git("build", ["cat-file", "blob", one.newSha]);
|
|
971
|
+
if (target.code !== 0 || linkLeadsOut(one.path, target.stdout))
|
|
972
|
+
return keep("they add a link that leads outside the project");
|
|
973
|
+
}
|
|
974
|
+
else if (!held.isFile() || held.nlink > 1)
|
|
975
|
+
return keep("they include a file Toolroll can't save safely");
|
|
976
|
+
else if (held.size > limits.blobBytes)
|
|
977
|
+
return keep(`a file is over ${Math.round(limits.blobBytes / 1024 / 1024)} MB`);
|
|
978
|
+
}
|
|
979
|
+
const patch = await git("build", ["diff", "--cached", "-p", "--no-ext-diff", "--no-textconv", "--no-color", "--no-renames", tip], {}, limits.patchBytes);
|
|
980
|
+
if (patch.code !== 0)
|
|
981
|
+
return keep("they couldn't be read whole");
|
|
982
|
+
if (scanPatchForSecrets(patch.stdout).length > 0)
|
|
983
|
+
return keep("an added line looks like a real key");
|
|
984
|
+
const identity = await projectGitIdentity(source.project, THREAD_IDENTITY, inner);
|
|
985
|
+
if (!identity.ok)
|
|
986
|
+
return keep(`the project's git identity couldn't be read (${identity.why})`);
|
|
987
|
+
const tree = (await git("build", ["write-tree"])).stdout.trim();
|
|
988
|
+
if (!SHA.test(tree))
|
|
989
|
+
return keep("git couldn't write them");
|
|
990
|
+
const made = await git("build", ["commit-tree", "--no-gpg-sign", "-p", tip, "-m", LEFTOVER_COMMIT_MESSAGE, tree], identityEnv(identity.identity));
|
|
991
|
+
const commit = made.stdout.trim();
|
|
992
|
+
if (made.code !== 0 || !SHA.test(commit) || commit.length !== tip.length)
|
|
993
|
+
return keep("git refused the commit");
|
|
994
|
+
if (input.allowed !== undefined && !input.allowed())
|
|
995
|
+
return { state: "refused" };
|
|
996
|
+
let moved;
|
|
997
|
+
try {
|
|
998
|
+
moved = viewedGitSync(repo, ["update-ref", "--no-deref", `refs/heads/${flexibleThreadBranch(source.thread.id)}`, commit, tip], { write: true, binding: { repo }, timeoutMs: Math.max(1, Math.min(60_000, deadline - Date.now())) }).status === 0;
|
|
999
|
+
}
|
|
1000
|
+
catch {
|
|
1001
|
+
moved = false;
|
|
1002
|
+
}
|
|
1003
|
+
if (!moved || threadBranchTip(source.paths, source.thread.id) !== commit)
|
|
1004
|
+
return { state: "unknown", why: "the thread's branch moved while it was saved" };
|
|
1005
|
+
try {
|
|
1006
|
+
renameSync(index, join(repo, ".git", "index"));
|
|
1007
|
+
}
|
|
1008
|
+
catch { }
|
|
1009
|
+
return { state: "committed", commit, paths: found };
|
|
1010
|
+
}
|
|
1011
|
+
catch (error) {
|
|
1012
|
+
return { state: "unknown", why: error instanceof DeadlinePassed ? "the time ran out" : "its files couldn't be read" };
|
|
1013
|
+
}
|
|
1014
|
+
finally {
|
|
1015
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
1016
|
+
}
|
|
1017
|
+
}
|
package/dist/flexible-save.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { canonicalJson } from "./canonical-json.js";
|
|
3
3
|
import { flexibleStanding } from "./flexible.js";
|
|
4
|
-
import { flexibleImportRef, importFlexibleCandidate, projectMergeHint, projectThreadBranch, readFlexibleCandidate } from "./flexible-import.js";
|
|
4
|
+
import { flexibleImportRef, flexibleLeftover, importFlexibleCandidate, projectMergeHint, projectThreadBranch, readFlexibleCandidate } from "./flexible-import.js";
|
|
5
|
+
import { unsettledLaunch } from "./flexible-launch.js";
|
|
5
6
|
import { branchHeld, nextSeq, turnRunning } from "./flexible-ship.js";
|
|
6
7
|
import { flexibleThread, flexibleThreadBranch, withFlexibleThreadLock } from "./flexible-thread.js";
|
|
7
8
|
import { machineActing } from "./scope.js";
|
|
@@ -37,6 +38,8 @@ async function nextWords(store, thread, candidate, branch, runner) {
|
|
|
37
38
|
const ff = gitCommand(hint.repo, ["merge", "--ff-only", branch]), merge = gitCommand(hint.repo, ["merge", branch]);
|
|
38
39
|
if (hint.branch === null)
|
|
39
40
|
return { next: `To use it: check out the branch you want it on, then ${ff === null ? UNSAFE_FOLDER(`git merge --ff-only ${branch}`) : `run \`${ff}\`.`}`, command: ff };
|
|
41
|
+
if (hint.contained)
|
|
42
|
+
return { next: `It's already in ${hint.branch}: nothing to merge.`, command: null };
|
|
40
43
|
if (hint.fastForward)
|
|
41
44
|
return { next: ff === null ? `To put it on ${hint.branch}: ${UNSAFE_FOLDER(`git merge --ff-only ${branch}`)}` : `To put it on ${hint.branch}: \`${ff}\`.`, command: ff };
|
|
42
45
|
return { next: `${hint.branch} moved since the thread started, so it won't fast-forward. ${merge === null ? UNSAFE_FOLDER(`git merge ${branch}`) : `To merge it: \`${merge}\`.`}`, command: merge };
|
|
@@ -56,9 +59,30 @@ export async function saveFlexibleBranch(store, input) {
|
|
|
56
59
|
const locked = await withFlexibleThreadLock(input.thread, async () => {
|
|
57
60
|
if (turnRunning(store, input.thread))
|
|
58
61
|
return refuse("thread-running");
|
|
62
|
+
const standingNow = () => store.transact(() => {
|
|
63
|
+
const thread = flexibleThread(store, input.thread);
|
|
64
|
+
if (thread === null)
|
|
65
|
+
return refuse("thread-unknown");
|
|
66
|
+
if (thread.state !== "ready")
|
|
67
|
+
return refuse("thread-removed");
|
|
68
|
+
return saverStanding(store, thread, input.by) ?? (input.prove() ? null : refuse("stale-generation"));
|
|
69
|
+
});
|
|
70
|
+
const standing = standingNow();
|
|
71
|
+
if (standing !== null)
|
|
72
|
+
return standing;
|
|
73
|
+
let late = null;
|
|
74
|
+
const allowed = () => {
|
|
75
|
+
late = turnRunning(store, input.thread) || unsettledLaunch(store, input.thread) !== null ? refuse("changed") : standingNow();
|
|
76
|
+
return late === null;
|
|
77
|
+
};
|
|
78
|
+
const leftover = await flexibleLeftover(store, { thread: input.thread, commit: unsettledLaunch(store, input.thread) === null, allowed, ...runner });
|
|
79
|
+
if (leftover.state === "refused")
|
|
80
|
+
return late ?? refuse("changed");
|
|
81
|
+
const uncommitted = leftoverNote(leftover);
|
|
82
|
+
const withNote = (next) => ({ ...next, leftover: leftover.state, uncommitted });
|
|
59
83
|
const read = await readFlexibleCandidate(store, { thread: input.thread, ...runner });
|
|
60
84
|
if (!read.ok)
|
|
61
|
-
return read;
|
|
85
|
+
return uncommitted !== null && "check" in read && read.check === "nothing-to-send" ? { ...read, message: `${read.message} ${uncommitted}` } : read;
|
|
62
86
|
const branch = flexibleThreadBranch(input.thread);
|
|
63
87
|
const held = branchHeld(store, input.thread);
|
|
64
88
|
if (held === read.candidate) {
|
|
@@ -67,7 +91,7 @@ export async function saveFlexibleBranch(store, input) {
|
|
|
67
91
|
return refuse("branch-gone");
|
|
68
92
|
if (actual !== read.candidate)
|
|
69
93
|
return refuse("branch-moved");
|
|
70
|
-
return { ok: true, already: true, branch, candidate: read.candidate, seq: null, changedPaths: read.changedPaths, ...(await nextWords(store, input.thread, read.candidate, branch, input.runner)) };
|
|
94
|
+
return { ok: true, already: true, branch, candidate: read.candidate, seq: null, changedPaths: read.changedPaths, ...withNote(await nextWords(store, input.thread, read.candidate, branch, input.runner)) };
|
|
71
95
|
}
|
|
72
96
|
const at = input.now.toISOString();
|
|
73
97
|
const recorded = store.transact(() => {
|
|
@@ -105,7 +129,7 @@ export async function saveFlexibleBranch(store, input) {
|
|
|
105
129
|
return imported;
|
|
106
130
|
}
|
|
107
131
|
store.transact(() => { store.handle.prepare("UPDATE flexible_ship SET state = 'imported', state_at = ? WHERE id = ? AND state = 'approved'").run(at, recorded.digest); });
|
|
108
|
-
return { ok: true, already: false, branch, candidate: read.candidate, seq: recorded.seq, changedPaths: read.changedPaths, ...(await nextWords(store, input.thread, read.candidate, branch, input.runner)) };
|
|
132
|
+
return { ok: true, already: false, branch, candidate: read.candidate, seq: recorded.seq, changedPaths: read.changedPaths, ...withNote(await nextWords(store, input.thread, read.candidate, branch, input.runner)) };
|
|
109
133
|
});
|
|
110
134
|
if (locked.ok === false && (locked.reason === "not-available" || locked.reason === "thread-unknown"))
|
|
111
135
|
return refuse("thread-unknown");
|
|
@@ -126,3 +150,26 @@ export function latestFlexibleSave(store, thread) {
|
|
|
126
150
|
return null;
|
|
127
151
|
return { seq: Number(newest["seq"]), candidate: String(newest["candidate"]), at: String(newest["state_at"]) };
|
|
128
152
|
}
|
|
153
|
+
function leftoverNote(leftover) {
|
|
154
|
+
switch (leftover.state) {
|
|
155
|
+
case "none": return null;
|
|
156
|
+
case "committed": return `It includes the edits the agent hadn't committed (${filesWord(leftover.paths.length)}).`;
|
|
157
|
+
case "found": return `The agent's uncommitted edits (${filesWord(leftover.paths.length)}) aren't in it while its agent is running: end the thread, then save again.`;
|
|
158
|
+
case "kept": return `The agent's uncommitted edits (${filesWord(leftover.paths.length)}) weren't saved: ${leftover.why}. They stay in the thread's copy.`;
|
|
159
|
+
case "unknown": return `Toolroll couldn't check the thread's copy for uncommitted edits: ${leftover.why}.`;
|
|
160
|
+
case "refused": return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const filesWord = (n) => `${n} file${n === 1 ? "" : "s"}`;
|
|
164
|
+
export async function flexibleUncommittedFiles(store, input) {
|
|
165
|
+
if (unsettledLaunch(store, input.thread) !== null)
|
|
166
|
+
return [];
|
|
167
|
+
const found = await flexibleLeftover(store, { thread: input.thread, commit: false, ...(input.runner === undefined ? {} : { runner: input.runner }) });
|
|
168
|
+
return found.state === "found" ? found.paths : [];
|
|
169
|
+
}
|
|
170
|
+
export function flexibleSavedWords(saved) {
|
|
171
|
+
const commit = saved.candidate.slice(0, 12);
|
|
172
|
+
if (!saved.already)
|
|
173
|
+
return `Saved as ${saved.branch} (commit ${commit}, ${filesWord(saved.changedPaths.length)}).${saved.uncommitted === null ? "" : ` ${saved.uncommitted}`}`;
|
|
174
|
+
return saved.uncommitted === null ? `Already saved as ${saved.branch} (commit ${commit}).` : `Its committed work is already saved as ${saved.branch} (commit ${commit}). ${saved.uncommitted}`;
|
|
175
|
+
}
|
package/dist/flexible-session.js
CHANGED
|
@@ -14,7 +14,7 @@ import { flexibleThread, prepareFlexibleThread, removeFlexibleThread, stopFlexib
|
|
|
14
14
|
import { admitFlexibleTurn, finishFlexibleTurn, flexibleTurn, interruptFlexibleThreadTurns, interruptFlexibleTurnsOf, withdrawFlexibleTurn } from "./flexible-turns.js";
|
|
15
15
|
import { userFrame } from "./live-input.js";
|
|
16
16
|
import { cleanLiveText, createLiveRecorder, HIDDEN_LINE, liveSecretHit } from "./live-records.js";
|
|
17
|
-
import { flexibleConversationOf, flexibleTurnMessage, recordFlexibleFiles, recordFlexibleReply, recordFlexibleSaid, recordFlexibleStartTip, saidLines } from "./flexible-conversation.js";
|
|
17
|
+
import { flexibleConversationOf, flexibleTurnMessage, flexibleTurnRecordsOf, keepFlexibleTurnRecords, recordFlexibleFiles, recordFlexibleReply, recordFlexibleSaid, recordFlexibleStartTip, saidLines, sayTextOf } from "./flexible-conversation.js";
|
|
18
18
|
import { flexibleThreadTip, readFlexibleChanges } from "./flexible-import.js";
|
|
19
19
|
import { primaryResultEvent } from "./stream-scope.js";
|
|
20
20
|
const WORDS = Object.freeze({
|
|
@@ -481,12 +481,30 @@ export function attachFlexibleAgent(store, sessions, input) {
|
|
|
481
481
|
recorder: createLiveRecorder({ base: thread.folder === "" ? null : `${thread.folder}/repo`, commands: false, clock }) };
|
|
482
482
|
session.agent = link;
|
|
483
483
|
let outputTurn = input.turn;
|
|
484
|
+
const shown = new Map();
|
|
485
|
+
const kept = new Set();
|
|
486
|
+
const keepShown = (turn) => {
|
|
487
|
+
if (turn === null || kept.has(turn))
|
|
488
|
+
return;
|
|
489
|
+
kept.add(turn);
|
|
490
|
+
try {
|
|
491
|
+
keepFlexibleTurnRecords(thread.folder, turn, shown.get(turn) ?? []);
|
|
492
|
+
}
|
|
493
|
+
catch { }
|
|
494
|
+
shown.delete(turn);
|
|
495
|
+
};
|
|
484
496
|
const keep = (given) => {
|
|
485
497
|
if (link.turn !== null)
|
|
486
498
|
outputTurn = link.turn;
|
|
487
499
|
const records = withoutRefusedLines(store, outputTurn, given);
|
|
488
500
|
if (records.length === 0)
|
|
489
501
|
return;
|
|
502
|
+
if (outputTurn !== null && !kept.has(outputTurn)) {
|
|
503
|
+
const mine = shown.get(outputTurn) ?? [];
|
|
504
|
+
if (mine.length < FLEXIBLE_RECORDS_KEPT)
|
|
505
|
+
mine.push(...records);
|
|
506
|
+
shown.set(outputTurn, mine);
|
|
507
|
+
}
|
|
490
508
|
session.records.push(...records);
|
|
491
509
|
if (session.records.length > FLEXIBLE_RECORDS_KEPT) {
|
|
492
510
|
const drop = session.records.length - FLEXIBLE_RECORDS_KEPT;
|
|
@@ -531,12 +549,15 @@ export function attachFlexibleAgent(store, sessions, input) {
|
|
|
531
549
|
keep(link.recorder.observe(raw));
|
|
532
550
|
if (primaryResultEvent(raw) && link.turn !== null) {
|
|
533
551
|
const failed = raw["is_error"] === true;
|
|
534
|
-
|
|
552
|
+
const said = sayTextOf(shown.get(link.turn) ?? []);
|
|
553
|
+
const reply = said.trim() !== "" ? said : typeof raw["result"] === "string" ? raw["result"] : null;
|
|
554
|
+
if (!failed && reply !== null) {
|
|
535
555
|
try {
|
|
536
|
-
recordFlexibleReply(store, { turn: link.turn, reply
|
|
556
|
+
recordFlexibleReply(store, { turn: link.turn, reply });
|
|
537
557
|
}
|
|
538
558
|
catch { }
|
|
539
559
|
}
|
|
560
|
+
keepShown(link.turn);
|
|
540
561
|
void endFlexibleThreadTurn(store, sessions, { thread: input.thread, turn: link.turn, outcome: failed ? "unknown" : "finished", ...(failed ? { detail: "The agent stopped with an error." } : {}), ...clocked });
|
|
541
562
|
}
|
|
542
563
|
};
|
|
@@ -569,6 +590,7 @@ export function attachFlexibleAgent(store, sessions, input) {
|
|
|
569
590
|
keep(link.recorder.end());
|
|
570
591
|
session.agent = null;
|
|
571
592
|
}
|
|
593
|
+
keepShown(outputTurn);
|
|
572
594
|
revokeFlexibleAnswers(store, sessions.catalog, { thread: input.thread, connection: link.launch, reason: "the agent stopped", ...clocked });
|
|
573
595
|
bump(sessions, input.thread);
|
|
574
596
|
});
|
|
@@ -1315,10 +1337,14 @@ function conversationRecords(store, thread) {
|
|
|
1315
1337
|
catch {
|
|
1316
1338
|
return [];
|
|
1317
1339
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1340
|
+
const folder = flexibleThread(store, thread)?.folder ?? "";
|
|
1341
|
+
return turns.filter(one => one.status !== "admitted" && one.status !== "running").flatMap((one) => {
|
|
1342
|
+
const shown = folder === "" ? [] : flexibleTurnRecordsOf(folder, one.turn);
|
|
1343
|
+
return [
|
|
1344
|
+
{ k: "you", at: one.saidAt, t: saidLines(one.said) },
|
|
1345
|
+
...(shown.length > 0 ? shown : one.reply === null ? [] : [{ k: "say", at: one.saidAt, t: saidLines(one.reply, 400) }]),
|
|
1346
|
+
];
|
|
1347
|
+
});
|
|
1322
1348
|
}
|
|
1323
1349
|
const FILES_READ_PER_TURN = 1;
|
|
1324
1350
|
const FILES_READ_MS = 10_000;
|
|
@@ -1363,7 +1389,7 @@ export async function flexibleThreadChanges(store, input) {
|
|
|
1363
1389
|
return { tip: read.tip, changes: { ok: true, patch: read.patch, truncated: read.truncated } };
|
|
1364
1390
|
}
|
|
1365
1391
|
function saveInsteadWords(thread) {
|
|
1366
|
-
return `To use its work now, save it as a branch in your repository instead (S on the thread
|
|
1392
|
+
return `To use its work now, save it as a branch in your repository instead (S on the thread, or \`toolroll thread save ${thread.slice(0, 8)}\`).`;
|
|
1367
1393
|
}
|
|
1368
1394
|
export function flexibleThreadEdited(sessions, input) {
|
|
1369
1395
|
const session = sessions.threads.get(input.thread);
|
package/dist/flexible-start.js
CHANGED
|
@@ -78,7 +78,8 @@ export function flexibleStartCard(store, input) {
|
|
|
78
78
|
FLEXIBLE_UNKNOWN_COST_WORDS,
|
|
79
79
|
], fields: ["flexible.caps"], ...(caps.measuredMicrousdPerDay === null ? { risky: true } : {}) },
|
|
80
80
|
shipNeeds === null ? { label: "Ship", words: FLEXIBLE_SHIP_WORDS, fields: ["flexible.ship"] }
|
|
81
|
-
: { label: "Ship", words: shipNeeds.short, lines: [
|
|
81
|
+
: { label: "Ship", words: shipNeeds.short, lines: ["Until then, you can save its work as a branch in your repository instead (S on the thread, or `toolroll thread save <id>`).",
|
|
82
|
+
`After that: ${lowerFirst(FLEXIBLE_SHIP_WORDS)}`], fields: ["flexible.ship"] },
|
|
82
83
|
{ label: "Terms", words: `this project's Flexible terms, turned on by ${terms.signer}`, lines: [`They last until someone turns them off or lowers them, or ${terms.signer}'s account or access changes.`], fields: ["flexible.terms"] },
|
|
83
84
|
];
|
|
84
85
|
if (runtime === "interactive") {
|
package/dist/flow-code.js
CHANGED
|
@@ -6,7 +6,7 @@ import { dirname, join } from "node:path";
|
|
|
6
6
|
import { buildCacheEnv, buildCacheFolder, checkLaunchRoot, fenceFor, linuxFenceAvailable, macosFenceAvailable, runFolders, taskBoundary, trustedWorktreeBinding, writeAllowlist } from "./agent-fence.js";
|
|
7
7
|
import { readDenyPath } from "./project-sandbox.js";
|
|
8
8
|
import { poolRootOf } from "./worktree.js";
|
|
9
|
-
import {
|
|
9
|
+
import { noConfinementWords } from "./sandbox-runtime.js";
|
|
10
10
|
import { SETUP_ENV_ALLOWLIST, SETUP_ENV_DENYLIST } from "./builder.js";
|
|
11
11
|
import { redactSecretLines, scanForSecrets } from "./evidence.js";
|
|
12
12
|
import { scrubSecrets } from "./flow-secrets.js";
|
|
@@ -130,7 +130,7 @@ export async function flowLaunch(store, options) {
|
|
|
130
130
|
const available = options.available ?? (() => macosFenceAvailable() || linuxFenceAvailable());
|
|
131
131
|
const fenced = available();
|
|
132
132
|
if (!fenced && !store.unfencedAgentsAllowed()) {
|
|
133
|
-
return { problem: "
|
|
133
|
+
return { problem: noConfinementWords("the flow's script", "it didn't run") };
|
|
134
134
|
}
|
|
135
135
|
let own;
|
|
136
136
|
try {
|
package/dist/invoke.js
CHANGED
|
@@ -28,7 +28,7 @@ import { localModeOn } from "./local-owner.js";
|
|
|
28
28
|
import { CHECK_STAMP_VERSION, EVERYWHERE, unfencedStamp } from "./check-stamp.js";
|
|
29
29
|
import { CHECK_ACCESS_DEFAULT, checkAccessHere, localModeCap, narrowestAccess, narrowestNetwork, signInsAvailable } from "./check-access.js";
|
|
30
30
|
import { readDenyPath } from "./project-sandbox.js";
|
|
31
|
-
import {
|
|
31
|
+
import { noConfinementWords, sandboxRuntimeWords } from "./sandbox-runtime.js";
|
|
32
32
|
import { canonicalJson } from "./canonical-json.js";
|
|
33
33
|
import { deliveredFile } from "./code-map-admission.js";
|
|
34
34
|
import { skillsGrant } from "./skills-manifest.js";
|
|
@@ -337,7 +337,7 @@ export async function invokeAgent(store, runId, spec, invocation, options) {
|
|
|
337
337
|
codexHome?.cleanup();
|
|
338
338
|
removeAgentDatabase(isolatedDb.dir);
|
|
339
339
|
return { kind: "refused", reason: "containment", providerVersion: attested?.version ?? null,
|
|
340
|
-
diagnostic: "
|
|
340
|
+
diagnostic: noConfinementWords("an agent", "nothing was started") };
|
|
341
341
|
}
|
|
342
342
|
let egress = null;
|
|
343
343
|
let runTemp = null;
|
|
@@ -791,7 +791,7 @@ export function fencedCommands(store, runId, writes, inner, available = () => ma
|
|
|
791
791
|
stampLaunch(store, [runId], unfencedStamp());
|
|
792
792
|
return inner(file, args, options);
|
|
793
793
|
}
|
|
794
|
-
return { code: 1, stdout: "", stderr: "
|
|
794
|
+
return { code: 1, stdout: "", stderr: `${noConfinementWords("the build's commands", "they didn't run")}\n`, timedOut: false, notFound: false };
|
|
795
795
|
}
|
|
796
796
|
const own = realpathSync(mkdtempSync(join(checkLaunchRoot(), "so-cmd-")));
|
|
797
797
|
try {
|
|
@@ -847,7 +847,7 @@ export function fencedCheckoutCommands(store, repo, checkout, inner, available =
|
|
|
847
847
|
stampLaunch(store, stampRuns, unfencedStamp());
|
|
848
848
|
return inner(file, args, options);
|
|
849
849
|
}
|
|
850
|
-
return { code: 1, stdout: "", stderr: "
|
|
850
|
+
return { code: 1, stdout: "", stderr: `${noConfinementWords("the project's checks", "they didn't run")}\n`, timedOut: false, notFound: false };
|
|
851
851
|
}
|
|
852
852
|
const databaseFile = store.databaseFile();
|
|
853
853
|
if (databaseFile === null) {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { LAND_DESTINATION, LAND_HANDOFF, LAND_HANDOFF_SETTLED, LAND_INTENT, LAND_SETTLED, landableBranch, revertedOnBranch } from "./local-landing.js";
|
|
2
|
+
import { recentGitReads } from "./task-base.js";
|
|
3
|
+
const listReads = recentGitReads();
|
|
4
|
+
export const LANDED_GIT_READS = 24;
|
|
5
|
+
class GitBudgetSpent extends Error {
|
|
6
|
+
}
|
|
7
|
+
const OID = /^[0-9a-f]{40}$/;
|
|
8
|
+
const short = (oid) => oid.slice(0, 7);
|
|
9
|
+
function intentOf(id, d) {
|
|
10
|
+
if (d["v"] !== 1 || typeof d["ref"] !== "string" || typeof d["old"] !== "string" || typeof d["commit"] !== "string" || !OID.test(d["old"]) || !OID.test(d["commit"])
|
|
11
|
+
|| (d["mode"] !== "files" && d["mode"] !== "ref") || typeof d["key"] !== "string" || (d["kind"] !== "land" && d["kind"] !== "undo"))
|
|
12
|
+
return null;
|
|
13
|
+
return { id, kind: d["kind"], ref: d["ref"], old: d["old"], commit: d["commit"], candidate: typeof d["candidate"] === "string" && OID.test(d["candidate"]) ? d["candidate"] : d["commit"],
|
|
14
|
+
reverts: typeof d["reverts"] === "number" || typeof d["reverts"] === "string" ? d["reverts"] : null, fromHandoff: typeof d["fromHandoff"] === "number" ? d["fromHandoff"] : null };
|
|
15
|
+
}
|
|
16
|
+
function handoffOf(id, d) {
|
|
17
|
+
const ok = d["v"] === 1 && typeof d["key"] === "string" && typeof d["ref"] === "string" && typeof d["old"] === "string" && OID.test(d["old"]) && typeof d["commit"] === "string" && OID.test(d["commit"])
|
|
18
|
+
&& typeof d["keep"] === "string" && typeof d["folder"] === "string" && typeof d["candidate"] === "string" && OID.test(d["candidate"]);
|
|
19
|
+
return ok ? { id, ref: d["ref"], old: d["old"], commit: d["commit"], candidate: d["candidate"] } : null;
|
|
20
|
+
}
|
|
21
|
+
const parsed = (text) => {
|
|
22
|
+
try {
|
|
23
|
+
const value = JSON.parse(String(text ?? "null"));
|
|
24
|
+
return value !== null && typeof value === "object" ? value : null;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export function landedRowsOf(store, rows, read = listReads) {
|
|
31
|
+
const out = new Map();
|
|
32
|
+
const done = rows.filter(one => one.assignmentState === "complete" && one.repo !== null && one.resultRunId !== null);
|
|
33
|
+
if (done.length === 0)
|
|
34
|
+
return out;
|
|
35
|
+
const ids = [...new Set(done.map(one => one.rootId))], repos = [...new Set(done.map(one => one.repo))], runs = [...new Set(done.map(one => one.resultRunId))];
|
|
36
|
+
const marks = (n) => Array.from({ length: n }, () => "?").join(",");
|
|
37
|
+
const found = store.handle.prepare(`
|
|
38
|
+
WITH heads AS (SELECT id, head_revision FROM run WHERE id IN (${marks(runs.length)})),
|
|
39
|
+
handed AS (SELECT id, task_id, repo, action, outcome, detail FROM action_ledger WHERE task_id IN (${marks(ids.length)}) AND action = ?
|
|
40
|
+
AND (CASE WHEN json_valid(detail) THEN json_extract(detail, '$.candidate') END) IN (SELECT head_revision FROM heads))
|
|
41
|
+
SELECT 'ledger' AS kind, id, task_id, repo, action, outcome, detail FROM action_ledger WHERE task_id IN (${marks(ids.length)}) AND action IN (?, ?)
|
|
42
|
+
UNION ALL SELECT 'ledger', id, task_id, repo, action, outcome, detail FROM handed
|
|
43
|
+
UNION ALL SELECT 'ledger', id, task_id, repo, action, outcome, NULL FROM action_ledger WHERE task_id IN (${marks(ids.length)}) AND action = ? AND outcome IN (SELECT id || ':kept' FROM handed)
|
|
44
|
+
UNION ALL SELECT 'destination', id, NULL, repo, action, NULL, detail FROM action_ledger
|
|
45
|
+
WHERE id IN (SELECT max(id) FROM action_ledger WHERE repo IN (${marks(repos.length)}) AND action = ? AND source = 'request' GROUP BY repo)
|
|
46
|
+
UNION ALL SELECT 'grant', NULL, NULL, repo, NULL, NULL, NULL FROM publication_grant WHERE repo IN (${marks(repos.length)}) AND revoked_at IS NULL
|
|
47
|
+
UNION ALL SELECT 'run', id, NULL, NULL, NULL, head_revision, NULL FROM heads`)
|
|
48
|
+
.all(...runs, ...ids, LAND_HANDOFF, ...ids, LAND_INTENT, LAND_SETTLED, ...ids, LAND_HANDOFF_SETTLED, ...repos, LAND_DESTINATION, ...repos);
|
|
49
|
+
const heads = new Map(), granted = new Set(), destinations = new Map();
|
|
50
|
+
const intents = new Map(), handoffs = new Map();
|
|
51
|
+
const settled = new Map(), kept = new Set();
|
|
52
|
+
for (const row of found) {
|
|
53
|
+
const kind = String(row["kind"]), id = Number(row["id"]);
|
|
54
|
+
if (kind === "run") {
|
|
55
|
+
heads.set(id, row["outcome"] == null ? null : String(row["outcome"]));
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (kind === "grant") {
|
|
59
|
+
granted.add(String(row["repo"]));
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (kind === "destination") {
|
|
63
|
+
const ref = parsed(row["detail"])?.["ref"], repo = String(row["repo"]);
|
|
64
|
+
if ((destinations.get(repo)?.id ?? -1) < id)
|
|
65
|
+
destinations.set(repo, { id, ref: typeof ref === "string" && typeof parsed(row["detail"])?.["common"] === "string" ? ref : "" });
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const action = String(row["action"]), outcome = String(row["outcome"] ?? ""), task = String(row["task_id"]);
|
|
69
|
+
if (action === LAND_SETTLED) {
|
|
70
|
+
const intent = Number(outcome.slice(0, outcome.indexOf(":")));
|
|
71
|
+
if (outcome.includes(":") && (settled.get(intent)?.id ?? -1) < id)
|
|
72
|
+
settled.set(intent, { id, outcome: outcome.slice(outcome.indexOf(":") + 1) });
|
|
73
|
+
}
|
|
74
|
+
else if (action === LAND_HANDOFF_SETTLED) {
|
|
75
|
+
if (/^\d+:kept$/.test(outcome))
|
|
76
|
+
kept.add(Number(outcome.slice(0, outcome.indexOf(":"))));
|
|
77
|
+
}
|
|
78
|
+
else if (action === LAND_INTENT) {
|
|
79
|
+
const one = intentOf(id, parsed(row["detail"]) ?? {});
|
|
80
|
+
if (one !== null)
|
|
81
|
+
intents.set(task, [...(intents.get(task) ?? []), one]);
|
|
82
|
+
}
|
|
83
|
+
else if (action === LAND_HANDOFF) {
|
|
84
|
+
const one = handoffOf(id, parsed(row["detail"]) ?? {});
|
|
85
|
+
if (one !== null)
|
|
86
|
+
handoffs.set(task, [...(handoffs.get(task) ?? []), { repo: String(row["repo"]), one }]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const landedOutcome = (intent) => settled.get(intent)?.outcome.startsWith("landed") === true;
|
|
90
|
+
let left = LANDED_GIT_READS;
|
|
91
|
+
const budgeted = (cwd, args) => {
|
|
92
|
+
if (left <= 0)
|
|
93
|
+
throw new GitBudgetSpent();
|
|
94
|
+
left -= 1;
|
|
95
|
+
return read(cwd, args);
|
|
96
|
+
};
|
|
97
|
+
for (const row of done) {
|
|
98
|
+
try {
|
|
99
|
+
const words = landedWordsOf(row);
|
|
100
|
+
if (words !== null)
|
|
101
|
+
out.set(row.rootId, words);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (error instanceof GitBudgetSpent)
|
|
105
|
+
break;
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
function landedWordsOf(row) {
|
|
111
|
+
const repo = row.repo, head = heads.get(row.resultRunId) ?? null;
|
|
112
|
+
if (granted.has(repo) || (!intents.has(row.rootId) && !handoffs.has(row.rootId)))
|
|
113
|
+
return null;
|
|
114
|
+
const all = [...(intents.get(row.rootId) ?? [])].sort((a, b) => b.id - a.id);
|
|
115
|
+
const record = all.find(one => one.kind === "land" && landedOutcome(one.id)) ?? null;
|
|
116
|
+
const name = record === null ? null : record.fromHandoff !== null ? `handoff:${record.fromHandoff}` : `intent:${record.id}`;
|
|
117
|
+
const undone = record !== null && all.some(one => one.kind === "undo" && (one.reverts === name || one.reverts === record.id) && landedOutcome(one.id));
|
|
118
|
+
if (record === null || undone) {
|
|
119
|
+
if (head === null || !OID.test(head))
|
|
120
|
+
return null;
|
|
121
|
+
const destination = destinations.get(repo)?.ref ?? null;
|
|
122
|
+
const ref = destination !== null && destination !== "" ? destination : (() => { const named = budgeted(repo, ["symbolic-ref", "-q", "HEAD"]); return named !== null && named.startsWith("refs/heads/") ? named : null; })();
|
|
123
|
+
if (ref === null || !landableBranch(ref.slice("refs/heads/".length)))
|
|
124
|
+
return null;
|
|
125
|
+
const handed = (handoffs.get(row.rootId) ?? []).filter(one => one.repo === repo && kept.has(one.one.id) && one.one.candidate === head && one.one.ref === ref)
|
|
126
|
+
.sort((a, b) => b.one.id - a.one.id).map(one => ({ commit: one.one.commit, old: one.one.old }));
|
|
127
|
+
const on = [{ commit: head, old: null }, ...handed].find(one => budgeted(repo, ["merge-base", "--is-ancestor", one.commit, ref]) !== null);
|
|
128
|
+
if (on === undefined)
|
|
129
|
+
return null;
|
|
130
|
+
const reverted = on.old !== null && revertedOnBranch(repo, ref, { old: on.old, commit: on.commit }, budgeted);
|
|
131
|
+
return `Landed on ${ref.slice("refs/heads/".length)} (${short(on.commit)})${reverted ? " · a later commit reverted it" : ""}`;
|
|
132
|
+
}
|
|
133
|
+
if (head === null || record.candidate !== head)
|
|
134
|
+
return null;
|
|
135
|
+
const reverted = revertedOnBranch(repo, record.ref, record, budgeted);
|
|
136
|
+
return `Landed on ${record.ref.replace(/^refs\/heads\//, "")} (${short(record.commit)})${reverted ? " · a later commit reverted it" : ""}`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { processParentId } from "./process-identity.js";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
|
|
3
3
|
import { createServer } from "node:net";
|
|
4
4
|
import { homedir, hostname } from "node:os";
|
|
@@ -52,16 +52,7 @@ function installedBuild(entry) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
function parentPid(pid) {
|
|
55
|
-
|
|
56
|
-
return null;
|
|
57
|
-
try {
|
|
58
|
-
const raw = execFileSync("/bin/ps", ["-p", String(pid), "-o", "ppid="], { encoding: "utf8", env: { PATH: "/usr/bin:/bin", LC_ALL: "C" }, stdio: ["ignore", "pipe", "ignore"], timeout: 2_000 });
|
|
59
|
-
const parent = Number(raw.trim());
|
|
60
|
-
return Number.isSafeInteger(parent) && parent > 0 ? parent : null;
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
55
|
+
return processParentId(pid);
|
|
65
56
|
}
|
|
66
57
|
function portIsFree(port) {
|
|
67
58
|
return new Promise(resolve => {
|