bosun 0.29.2 → 0.29.4
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/.env.example +1 -1
- package/agent-pool.mjs +21 -3
- package/agent-sdk.mjs +2 -2
- package/cli.mjs +12 -0
- package/codex-config.mjs +261 -39
- package/codex-shell.mjs +3 -3
- package/config-doctor.mjs +244 -0
- package/monitor.mjs +31 -0
- package/package.json +1 -1
- package/setup.mjs +227 -75
- package/task-executor.mjs +4 -0
- package/ui/components/chat-view.js +69 -53
- package/ui/components/session-list.js +4 -4
- package/ui/components/shared.js +4 -0
- package/ui/components/workspace-switcher.js +17 -6
- package/ui/demo.html +19 -1
- package/ui/styles/sessions.css +167 -21
- package/ui/styles/workspace-switcher.css +21 -0
- package/ui/tabs/chat.js +10 -0
- package/ui/tabs/dashboard.js +26 -32
- package/ui/tabs/tasks.js +43 -6
- package/ui-server.mjs +12 -0
- package/workspace-manager.mjs +37 -0
package/config-doctor.mjs
CHANGED
|
@@ -699,3 +699,247 @@ export function formatConfigDoctorReport(result) {
|
|
|
699
699
|
|
|
700
700
|
return lines.join("\n");
|
|
701
701
|
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Run workspace-specific health checks.
|
|
705
|
+
* Validates workspace repos, git status, writable roots, worktree health.
|
|
706
|
+
* @param {{ configDir?: string, repoRoot?: string }} options
|
|
707
|
+
* @returns {{ ok: boolean, workspaces: Array, issues: { errors: Array, warnings: Array, infos: Array } }}
|
|
708
|
+
*/
|
|
709
|
+
export function runWorkspaceHealthCheck(options = {}) {
|
|
710
|
+
const configDir = options.configDir || process.env.BOSUN_DIR || join(homedir(), "bosun");
|
|
711
|
+
const repoRoot = options.repoRoot || process.cwd();
|
|
712
|
+
const issues = { errors: [], warnings: [], infos: [] };
|
|
713
|
+
const workspaceResults = [];
|
|
714
|
+
|
|
715
|
+
// 1. Check if workspaces are configured
|
|
716
|
+
let workspaces = [];
|
|
717
|
+
try {
|
|
718
|
+
const configPath = join(configDir, "bosun.config.json");
|
|
719
|
+
if (existsSync(configPath)) {
|
|
720
|
+
const config = JSON.parse(readFileSync(configPath, "utf8"));
|
|
721
|
+
workspaces = config.workspaces || [];
|
|
722
|
+
}
|
|
723
|
+
} catch (err) {
|
|
724
|
+
issues.errors.push({
|
|
725
|
+
code: "WS_CONFIG_READ_FAILED",
|
|
726
|
+
message: `Failed to read workspace config: ${err.message}`,
|
|
727
|
+
fix: "Check bosun.config.json is valid JSON",
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
if (workspaces.length === 0) {
|
|
732
|
+
issues.infos.push({
|
|
733
|
+
code: "WS_NONE_CONFIGURED",
|
|
734
|
+
message: "No workspaces configured — agents use developer repo directly.",
|
|
735
|
+
fix: "Run 'bosun --workspace-add <name>' to create a workspace for isolated agent execution.",
|
|
736
|
+
});
|
|
737
|
+
return { ok: true, workspaces: workspaceResults, issues };
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
// 2. Check each workspace
|
|
741
|
+
for (const ws of workspaces) {
|
|
742
|
+
const wsResult = {
|
|
743
|
+
id: ws.id || "unknown",
|
|
744
|
+
name: ws.name || ws.id || "unnamed",
|
|
745
|
+
path: ws.path || "",
|
|
746
|
+
repos: [],
|
|
747
|
+
ok: true,
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
// 2a. Workspace directory exists
|
|
751
|
+
const wsPath = ws.path || join(configDir, "workspaces", ws.id || ws.name);
|
|
752
|
+
if (!existsSync(wsPath)) {
|
|
753
|
+
issues.warnings.push({
|
|
754
|
+
code: "WS_DIR_MISSING",
|
|
755
|
+
message: `Workspace "${wsResult.name}" directory missing: ${wsPath}`,
|
|
756
|
+
fix: `Run 'bosun --setup' or mkdir -p "${wsPath}"`,
|
|
757
|
+
});
|
|
758
|
+
wsResult.ok = false;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// 2b. Check repos in workspace
|
|
762
|
+
for (const repo of ws.repos || []) {
|
|
763
|
+
const repoName = repo.name || repo.slug || "unknown";
|
|
764
|
+
const repoPath = join(wsPath, repoName);
|
|
765
|
+
const repoStatus = { name: repoName, path: repoPath, ok: true, issues: [] };
|
|
766
|
+
|
|
767
|
+
if (!existsSync(repoPath)) {
|
|
768
|
+
repoStatus.ok = false;
|
|
769
|
+
repoStatus.issues.push("directory missing");
|
|
770
|
+
issues.errors.push({
|
|
771
|
+
code: "WS_REPO_MISSING",
|
|
772
|
+
message: `Workspace repo "${repoName}" not found at ${repoPath}`,
|
|
773
|
+
fix: `Run 'bosun --workspace-add-repo <url>' or 'bosun --setup' to clone it`,
|
|
774
|
+
});
|
|
775
|
+
} else {
|
|
776
|
+
const gitPath = join(repoPath, ".git");
|
|
777
|
+
if (!existsSync(gitPath)) {
|
|
778
|
+
repoStatus.ok = false;
|
|
779
|
+
repoStatus.issues.push(".git missing");
|
|
780
|
+
issues.errors.push({
|
|
781
|
+
code: "WS_REPO_NO_GIT",
|
|
782
|
+
message: `Workspace repo "${repoName}" has no .git at ${repoPath}`,
|
|
783
|
+
fix: `Clone the repo: git clone <url> "${repoPath}"`,
|
|
784
|
+
});
|
|
785
|
+
} else {
|
|
786
|
+
// Check remote connectivity (quick)
|
|
787
|
+
try {
|
|
788
|
+
const branch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
789
|
+
cwd: repoPath, encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "pipe"],
|
|
790
|
+
}).trim();
|
|
791
|
+
repoStatus.branch = branch;
|
|
792
|
+
repoStatus.issues.push(`on branch: ${branch}`);
|
|
793
|
+
} catch {
|
|
794
|
+
repoStatus.issues.push("git status check failed");
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// Check for uncommitted changes
|
|
798
|
+
try {
|
|
799
|
+
const status = execSync("git status --porcelain", {
|
|
800
|
+
cwd: repoPath, encoding: "utf8", timeout: 5000, stdio: ["pipe", "pipe", "pipe"],
|
|
801
|
+
}).trim();
|
|
802
|
+
if (status) {
|
|
803
|
+
const lines = status.split("\n").length;
|
|
804
|
+
repoStatus.issues.push(`${lines} uncommitted change(s)`);
|
|
805
|
+
issues.infos.push({
|
|
806
|
+
code: "WS_REPO_DIRTY",
|
|
807
|
+
message: `Workspace repo "${repoName}" has ${lines} uncommitted change(s)`,
|
|
808
|
+
fix: null,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
} catch { /* ignore */ }
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
wsResult.repos.push(repoStatus);
|
|
816
|
+
if (!repoStatus.ok) wsResult.ok = false;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
workspaceResults.push(wsResult);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// 3. Check Codex sandbox writable_roots coverage
|
|
823
|
+
const codexConfigPath = join(homedir(), ".codex", "config.toml");
|
|
824
|
+
if (existsSync(codexConfigPath)) {
|
|
825
|
+
try {
|
|
826
|
+
const toml = readFileSync(codexConfigPath, "utf8");
|
|
827
|
+
const rootsMatch = toml.match(/writable_roots\s*=\s*\[([^\]]*)\]/);
|
|
828
|
+
if (rootsMatch) {
|
|
829
|
+
const roots = rootsMatch[1].split(",").map(r => r.trim().replace(/^"|"$/g, "")).filter(Boolean);
|
|
830
|
+
for (const ws of workspaces) {
|
|
831
|
+
const wsPath = ws.path || join(configDir, "workspaces", ws.id || ws.name);
|
|
832
|
+
for (const repo of ws.repos || []) {
|
|
833
|
+
const repoPath = join(wsPath, repo.name || repo.slug || "");
|
|
834
|
+
const gitPath = join(repoPath, ".git");
|
|
835
|
+
if (existsSync(gitPath) && !roots.some(r => gitPath.startsWith(r) || r === gitPath)) {
|
|
836
|
+
issues.warnings.push({
|
|
837
|
+
code: "WS_SANDBOX_MISSING_ROOT",
|
|
838
|
+
message: `Workspace repo .git not in Codex writable_roots: ${gitPath}`,
|
|
839
|
+
fix: `Run 'bosun --setup' to update Codex sandbox config, or add "${gitPath}" to writable_roots in ~/.codex/config.toml`,
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// Check for phantom/relative writable roots
|
|
846
|
+
for (const root of roots) {
|
|
847
|
+
if (!root.startsWith("/")) {
|
|
848
|
+
issues.warnings.push({
|
|
849
|
+
code: "WS_SANDBOX_RELATIVE_ROOT",
|
|
850
|
+
message: `Relative path in Codex writable_roots: "${root}" — may resolve incorrectly`,
|
|
851
|
+
fix: `Remove "${root}" from writable_roots in ~/.codex/config.toml and run 'bosun --setup'`,
|
|
852
|
+
});
|
|
853
|
+
} else if (!existsSync(root) && root !== "/tmp") {
|
|
854
|
+
issues.infos.push({
|
|
855
|
+
code: "WS_SANDBOX_PHANTOM_ROOT",
|
|
856
|
+
message: `Codex writable_root path does not exist: ${root}`,
|
|
857
|
+
fix: null,
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
} catch { /* ignore parse errors */ }
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// 4. Check BOSUN_AGENT_REPO_ROOT
|
|
866
|
+
const agentRoot = process.env.BOSUN_AGENT_REPO_ROOT || "";
|
|
867
|
+
if (agentRoot) {
|
|
868
|
+
if (!existsSync(agentRoot)) {
|
|
869
|
+
issues.warnings.push({
|
|
870
|
+
code: "WS_AGENT_ROOT_MISSING",
|
|
871
|
+
message: `BOSUN_AGENT_REPO_ROOT points to non-existent path: ${agentRoot}`,
|
|
872
|
+
fix: "Run 'bosun --setup' to bootstrap workspace repos",
|
|
873
|
+
});
|
|
874
|
+
} else if (!existsSync(join(agentRoot, ".git"))) {
|
|
875
|
+
issues.warnings.push({
|
|
876
|
+
code: "WS_AGENT_ROOT_NO_GIT",
|
|
877
|
+
message: `BOSUN_AGENT_REPO_ROOT has no .git: ${agentRoot}`,
|
|
878
|
+
fix: "Clone the repo at the workspace path or update BOSUN_AGENT_REPO_ROOT",
|
|
879
|
+
});
|
|
880
|
+
} else {
|
|
881
|
+
issues.infos.push({
|
|
882
|
+
code: "WS_AGENT_ROOT_OK",
|
|
883
|
+
message: `Agent repo root: ${agentRoot}`,
|
|
884
|
+
fix: null,
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
const hasErrors = issues.errors.length > 0;
|
|
890
|
+
return { ok: !hasErrors, workspaces: workspaceResults, issues };
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Format workspace health report for CLI output.
|
|
895
|
+
* @param {{ ok: boolean, workspaces: Array, issues: object }} result
|
|
896
|
+
* @returns {string}
|
|
897
|
+
*/
|
|
898
|
+
export function formatWorkspaceHealthReport(result) {
|
|
899
|
+
const lines = [];
|
|
900
|
+
lines.push("=== bosun workspace health ===");
|
|
901
|
+
lines.push(`Status: ${result.ok ? "HEALTHY" : "ISSUES FOUND"}`);
|
|
902
|
+
lines.push("");
|
|
903
|
+
|
|
904
|
+
if (result.workspaces.length === 0) {
|
|
905
|
+
lines.push(" No workspaces configured.");
|
|
906
|
+
lines.push("");
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
for (const ws of result.workspaces) {
|
|
910
|
+
const icon = ws.ok ? "✓" : "✗";
|
|
911
|
+
lines.push(` ${icon} ${ws.name} (${ws.id})`);
|
|
912
|
+
for (const repo of ws.repos) {
|
|
913
|
+
const rIcon = repo.ok ? "✓" : "✗";
|
|
914
|
+
const details = repo.issues.length > 0 ? ` — ${repo.issues.join(", ")}` : "";
|
|
915
|
+
lines.push(` ${rIcon} ${repo.name}${details}`);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
lines.push("");
|
|
919
|
+
|
|
920
|
+
if (result.issues.errors.length > 0) {
|
|
921
|
+
lines.push("Errors:");
|
|
922
|
+
for (const e of result.issues.errors) {
|
|
923
|
+
lines.push(` ✗ ${e.message}`);
|
|
924
|
+
if (e.fix) lines.push(` fix: ${e.fix}`);
|
|
925
|
+
}
|
|
926
|
+
lines.push("");
|
|
927
|
+
}
|
|
928
|
+
if (result.issues.warnings.length > 0) {
|
|
929
|
+
lines.push("Warnings:");
|
|
930
|
+
for (const w of result.issues.warnings) {
|
|
931
|
+
lines.push(` ⚠ ${w.message}`);
|
|
932
|
+
if (w.fix) lines.push(` fix: ${w.fix}`);
|
|
933
|
+
}
|
|
934
|
+
lines.push("");
|
|
935
|
+
}
|
|
936
|
+
if (result.issues.infos.length > 0) {
|
|
937
|
+
lines.push("Info:");
|
|
938
|
+
for (const i of result.issues.infos) {
|
|
939
|
+
lines.push(` ℹ ${i.message}`);
|
|
940
|
+
}
|
|
941
|
+
lines.push("");
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
return lines.join("\n");
|
|
945
|
+
}
|
package/monitor.mjs
CHANGED
|
@@ -593,6 +593,37 @@ if (effectiveRepoRoot && process.cwd() !== effectiveRepoRoot) {
|
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
|
|
596
|
+
// ── Periodic Workspace Sync ─────────────────────────────────────────────────
|
|
597
|
+
// Every 30 minutes, fetch latest changes for all workspace repos so agents
|
|
598
|
+
// always work against recent upstream. Only runs if workspaces are configured.
|
|
599
|
+
const WORKSPACE_SYNC_INTERVAL_MS = 30 * 60 * 1000; // 30 minutes
|
|
600
|
+
let workspaceSyncTimer = null;
|
|
601
|
+
{
|
|
602
|
+
const wsArray = config.repositories?.filter((r) => r.workspace) || [];
|
|
603
|
+
if (wsArray.length > 0) {
|
|
604
|
+
const workspaceIds = [...new Set(wsArray.map((r) => r.workspace).filter(Boolean))];
|
|
605
|
+
const doWorkspaceSync = () => {
|
|
606
|
+
for (const wsId of workspaceIds) {
|
|
607
|
+
try {
|
|
608
|
+
const results = pullWorkspaceRepos(config.configDir, wsId);
|
|
609
|
+
const failed = results.filter((r) => !r.success);
|
|
610
|
+
if (failed.length > 0) {
|
|
611
|
+
console.warn(`[monitor] workspace sync: ${failed.length} repo(s) failed in ${wsId}`);
|
|
612
|
+
} else {
|
|
613
|
+
console.log(`[monitor] workspace sync: ${wsId} up to date (${results.length} repos)`);
|
|
614
|
+
}
|
|
615
|
+
} catch (err) {
|
|
616
|
+
console.warn(`[monitor] workspace sync failed for ${wsId}: ${err.message}`);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
workspaceSyncTimer = setInterval(doWorkspaceSync, WORKSPACE_SYNC_INTERVAL_MS);
|
|
621
|
+
// Unref so the timer doesn't keep the process alive during shutdown
|
|
622
|
+
if (workspaceSyncTimer?.unref) workspaceSyncTimer.unref();
|
|
623
|
+
console.log(`[monitor] workspace sync: scheduled every ${WORKSPACE_SYNC_INTERVAL_MS / 60000} min for ${workspaceIds.length} workspace(s)`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
596
627
|
console.log(`[monitor] task planner mode: ${plannerMode}`);
|
|
597
628
|
console.log(`[monitor] kanban backend: ${kanbanBackend}`);
|
|
598
629
|
console.log(`[monitor] executor mode: ${executorMode}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bosun",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.4",
|
|
4
4
|
"description": "AI-powered orchestrator supervisor — manages AI agent executors with failover, auto-restarts on failure, analyzes crashes with Codex SDK, creates PRs via Vibe-Kanban API, and sends Telegram notifications. Supports N executors with weighted distribution, multi-repo projects, and auto-setup.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache 2.0",
|