@0perator/operator 0.1.61 → 0.1.153
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 +1037 -1
- package/LICENSE +19 -0
- package/dist/acp/agent.js +103 -0
- package/dist/acp/run.js +23 -0
- package/dist/auth/client.js +4 -1
- package/dist/auth/login-intent.js +12 -0
- package/dist/autonomy/board-run.js +65 -0
- package/dist/autonomy/board.js +83 -0
- package/dist/autonomy/dream.js +71 -0
- package/dist/autonomy/headless.js +70 -0
- package/dist/autonomy/index.js +260 -0
- package/dist/autonomy/keepawake.js +84 -0
- package/dist/autonomy/loop.js +82 -0
- package/dist/autonomy/reporter.js +54 -0
- package/dist/autonomy/routine-run.js +25 -0
- package/dist/autonomy/routines.js +173 -0
- package/dist/autonomy/session-factory.js +61 -0
- package/dist/background/index.js +269 -20
- package/dist/background/worktree.js +62 -0
- package/dist/cli.js +535 -112
- package/dist/config/brand.js +81 -0
- package/dist/config/operator-harness.js +86 -0
- package/dist/config/persona.js +174 -0
- package/dist/config/settings.js +98 -9
- package/dist/engine/agent.js +447 -51
- package/dist/engine/aurora.js +180 -64
- package/dist/engine/compaction.js +97 -5
- package/dist/engine/grandmaster.js +69 -10
- package/dist/engine/router-adapter.js +3 -0
- package/dist/engine/selfheal.js +35 -0
- package/dist/engine/verify-gate.js +81 -0
- package/dist/mcp/index.js +1 -1
- package/dist/permissions/index.js +13 -7
- package/dist/router/models.js +13 -4
- package/dist/router/router.js +46 -7
- package/dist/selfimprove/index.js +88 -0
- package/dist/services/preflight.js +42 -1
- package/dist/session.js +228 -21
- package/dist/telemetry/events.js +9 -0
- package/dist/tools/executor.js +48 -24
- package/dist/tools/git-status.js +71 -0
- package/dist/tools/mutating.js +9 -0
- package/dist/tools/registry.js +214 -11
- package/dist/tools/result-cap.js +23 -0
- package/dist/tools/searxng.js +42 -2
- package/dist/ui/ActivitySpinner.js +6 -5
- package/dist/ui/App.js +23 -5
- package/dist/ui/AuthScreen.js +1 -1
- package/dist/ui/BgPanel.js +60 -5
- package/dist/ui/Composer.js +135 -13
- package/dist/ui/Header.js +14 -6
- package/dist/ui/InputRule.js +2 -1
- package/dist/ui/Markdown.js +69 -10
- package/dist/ui/Masthead.js +6 -4
- package/dist/ui/PlanPane.js +23 -0
- package/dist/ui/QuestionPrompt.js +22 -8
- package/dist/ui/StatsCard.js +15 -0
- package/dist/ui/StatusRule.js +13 -4
- package/dist/ui/SummaryCard.js +18 -0
- package/dist/ui/Table.js +114 -0
- package/dist/ui/ThinkingSpinner.js +6 -4
- package/dist/ui/ToolBatch.js +12 -0
- package/dist/ui/ToolStep.js +12 -4
- package/dist/ui/Transcript.js +30 -6
- package/dist/ui/chart.js +34 -0
- package/dist/ui/editdiff.js +84 -0
- package/dist/ui/highlight.js +89 -0
- package/dist/ui/osc.js +32 -0
- package/dist/ui/planExit.js +26 -0
- package/dist/ui/term.js +16 -0
- package/dist/ui/theme.js +60 -0
- package/dist/ui/tree.js +71 -0
- package/dist/util/slash.js +15 -0
- package/dist/util/throttle.js +28 -0
- package/package.json +10 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Per-agent git worktree isolation for file-editing background sub-agents (SPEC §7). A code-editing child
|
|
2
|
+
// used to share the foreground's working tree, so two agents could race on the same file (observed live:
|
|
3
|
+
// foreground + bg1 both editing cli.py). Instead, give each such child its OWN git worktree on its OWN
|
|
4
|
+
// branch, branched from HEAD: its edits are quarantined there (the Executor roots the child's tools at the
|
|
5
|
+
// worktree dir), and when it finishes we commit whatever it changed onto the branch and remove the
|
|
6
|
+
// worktree — so the work survives as a reviewable branch and never touched the foreground tree.
|
|
7
|
+
//
|
|
8
|
+
// Best-effort by design: if the cwd isn't a git repo (or git fails), createWorktree returns null and the
|
|
9
|
+
// caller falls back to the shared cwd (no isolation) rather than erroring — isolation is an enhancement,
|
|
10
|
+
// not a requirement. Async so a `git worktree add` never blocks the foreground render loop.
|
|
11
|
+
import { execFile } from "node:child_process";
|
|
12
|
+
import { promisify } from "node:util";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
const run = promisify(execFile);
|
|
16
|
+
/** Create an isolated worktree for background agent `id` off the repo containing `cwd`. Returns null when
|
|
17
|
+
* `cwd` is not inside a git repo or git fails — the caller then runs the agent in the shared cwd. */
|
|
18
|
+
export async function createWorktree(id, cwd) {
|
|
19
|
+
let repoRoot;
|
|
20
|
+
try {
|
|
21
|
+
const { stdout } = await run("git", ["rev-parse", "--show-toplevel"], { cwd });
|
|
22
|
+
repoRoot = stdout.trim();
|
|
23
|
+
if (!repoRoot)
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null; // not a git repo — no isolation available
|
|
28
|
+
}
|
|
29
|
+
const branch = `operator/${id}-${Date.now().toString(36)}`;
|
|
30
|
+
const dir = join(tmpdir(), "operator-worktrees", `${id}-${Date.now().toString(36)}`);
|
|
31
|
+
try {
|
|
32
|
+
await run("git", ["-C", repoRoot, "worktree", "add", "-b", branch, dir, "HEAD"], { maxBuffer: 8 * 1024 * 1024 });
|
|
33
|
+
return { dir, branch, repoRoot };
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null; // detached HEAD, dirty index conflict, etc. — fall back to shared cwd
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Finish a worktree: commit whatever the agent changed onto its branch (so the work survives), then remove
|
|
40
|
+
* the worktree dir. The branch is left behind for review/merge. Returns a one-line status for the summary,
|
|
41
|
+
* or "" when nothing was set up. Never throws. */
|
|
42
|
+
export async function finalizeWorktree(wt, label) {
|
|
43
|
+
if (!wt)
|
|
44
|
+
return "";
|
|
45
|
+
let committed = false;
|
|
46
|
+
try {
|
|
47
|
+
const { stdout } = await run("git", ["-C", wt.dir, "status", "--porcelain"]);
|
|
48
|
+
if (stdout.trim()) {
|
|
49
|
+
await run("git", ["-C", wt.dir, "add", "-A"]);
|
|
50
|
+
await run("git", ["-C", wt.dir, "commit", "-m", `bg agent: ${label}`.slice(0, 200)], {
|
|
51
|
+
env: { ...process.env, GIT_AUTHOR_NAME: "operator", GIT_AUTHOR_EMAIL: "operator@axe", GIT_COMMITTER_NAME: "operator", GIT_COMMITTER_EMAIL: "operator@axe" },
|
|
52
|
+
});
|
|
53
|
+
committed = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch { /* commit is best-effort */ }
|
|
57
|
+
try {
|
|
58
|
+
await run("git", ["-C", wt.repoRoot, "worktree", "remove", "--force", wt.dir]);
|
|
59
|
+
}
|
|
60
|
+
catch { /* leave the dir if removal fails — better than losing the branch */ }
|
|
61
|
+
return committed ? ` · changes on branch ${wt.branch} (review: git diff HEAD..${wt.branch})` : ` · no file changes (branch ${wt.branch} discarded)`;
|
|
62
|
+
}
|