agent-control-plane 0.1.0
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/LICENSE +21 -0
- package/README.md +589 -0
- package/SKILL.md +149 -0
- package/assets/workflow-catalog.json +57 -0
- package/bin/audit-issue-routing.sh +74 -0
- package/bin/issue-resource-class.sh +58 -0
- package/bin/label-follow-up-issues.sh +114 -0
- package/bin/pr-risk.sh +532 -0
- package/bin/sync-pr-labels.sh +112 -0
- package/hooks/heartbeat-hooks.sh +573 -0
- package/hooks/issue-reconcile-hooks.sh +217 -0
- package/hooks/pr-reconcile-hooks.sh +225 -0
- package/npm/bin/agent-control-plane.js +1984 -0
- package/npm/public-bin/agent-control-plane +3 -0
- package/package.json +61 -0
- package/tools/bin/agent-cleanup-worktree +247 -0
- package/tools/bin/agent-github-update-labels +66 -0
- package/tools/bin/agent-init-worktree +216 -0
- package/tools/bin/agent-project-archive-run +52 -0
- package/tools/bin/agent-project-capture-worker +46 -0
- package/tools/bin/agent-project-catch-up-merged-prs +137 -0
- package/tools/bin/agent-project-cleanup-session +244 -0
- package/tools/bin/agent-project-detached-launch +107 -0
- package/tools/bin/agent-project-heartbeat-loop +2347 -0
- package/tools/bin/agent-project-open-issue-worktree +89 -0
- package/tools/bin/agent-project-open-pr-worktree +80 -0
- package/tools/bin/agent-project-publish-issue-pr +349 -0
- package/tools/bin/agent-project-reconcile-issue-session +1128 -0
- package/tools/bin/agent-project-reconcile-pr-session +1005 -0
- package/tools/bin/agent-project-retry-state +147 -0
- package/tools/bin/agent-project-run-claude-session +657 -0
- package/tools/bin/agent-project-run-codex-resilient +718 -0
- package/tools/bin/agent-project-run-codex-session +316 -0
- package/tools/bin/agent-project-run-kilo-session +27 -0
- package/tools/bin/agent-project-run-openclaw-session +984 -0
- package/tools/bin/agent-project-run-opencode-session +27 -0
- package/tools/bin/agent-project-sync-anchor-repo +128 -0
- package/tools/bin/agent-project-worker-status +143 -0
- package/tools/bin/audit-agent-worktrees.sh +310 -0
- package/tools/bin/audit-issue-routing.sh +11 -0
- package/tools/bin/audit-retained-layout.sh +58 -0
- package/tools/bin/audit-retained-overlap.sh +135 -0
- package/tools/bin/audit-retained-worktrees.sh +228 -0
- package/tools/bin/branch-verification-guard.sh +351 -0
- package/tools/bin/capture-worker.sh +18 -0
- package/tools/bin/check-skill-contracts.sh +324 -0
- package/tools/bin/cleanup-worktree.sh +44 -0
- package/tools/bin/codex-quota +31 -0
- package/tools/bin/create-follow-up-issue.sh +114 -0
- package/tools/bin/dashboard-launchd-bootstrap.sh +38 -0
- package/tools/bin/flow-config-lib.sh +2127 -0
- package/tools/bin/flow-resident-worker-lib.sh +683 -0
- package/tools/bin/flow-runtime-doctor.sh +97 -0
- package/tools/bin/flow-shell-lib.sh +266 -0
- package/tools/bin/heartbeat-recovery-preflight.sh +106 -0
- package/tools/bin/heartbeat-safe-auto.sh +551 -0
- package/tools/bin/install-dashboard-launchd.sh +152 -0
- package/tools/bin/install-project-launchd.sh +219 -0
- package/tools/bin/issue-publish-scope-guard.sh +242 -0
- package/tools/bin/issue-requires-local-workspace-install.sh +31 -0
- package/tools/bin/issue-resource-class.sh +12 -0
- package/tools/bin/kick-scheduler.sh +75 -0
- package/tools/bin/label-follow-up-issues.sh +14 -0
- package/tools/bin/new-pr-worktree.sh +50 -0
- package/tools/bin/new-worktree.sh +49 -0
- package/tools/bin/pr-risk.sh +12 -0
- package/tools/bin/prepare-worktree.sh +140 -0
- package/tools/bin/profile-activate.sh +109 -0
- package/tools/bin/profile-adopt.sh +219 -0
- package/tools/bin/profile-smoke.sh +461 -0
- package/tools/bin/project-init.sh +189 -0
- package/tools/bin/project-launchd-bootstrap.sh +54 -0
- package/tools/bin/project-remove.sh +155 -0
- package/tools/bin/project-runtime-supervisor.sh +56 -0
- package/tools/bin/project-runtimectl.sh +586 -0
- package/tools/bin/provider-cooldown-state.sh +166 -0
- package/tools/bin/publish-issue-worker.sh +31 -0
- package/tools/bin/reconcile-issue-worker.sh +34 -0
- package/tools/bin/reconcile-pr-worker.sh +34 -0
- package/tools/bin/record-verification.sh +71 -0
- package/tools/bin/render-architecture-infographics.sh +110 -0
- package/tools/bin/render-dashboard-demo-media.sh +333 -0
- package/tools/bin/render-dashboard-snapshot.py +16 -0
- package/tools/bin/render-flow-config.sh +86 -0
- package/tools/bin/retry-state.sh +31 -0
- package/tools/bin/reuse-issue-worktree.sh +75 -0
- package/tools/bin/run-codex-bypass.sh +3 -0
- package/tools/bin/run-codex-safe.sh +3 -0
- package/tools/bin/run-codex-task.sh +231 -0
- package/tools/bin/scaffold-profile.sh +374 -0
- package/tools/bin/serve-dashboard.sh +5 -0
- package/tools/bin/split-retained-slice.sh +124 -0
- package/tools/bin/start-issue-worker.sh +796 -0
- package/tools/bin/start-pr-fix-worker.sh +458 -0
- package/tools/bin/start-pr-merge-repair-worker.sh +8 -0
- package/tools/bin/start-pr-review-worker.sh +227 -0
- package/tools/bin/start-resident-issue-loop.sh +908 -0
- package/tools/bin/sync-agent-repo.sh +52 -0
- package/tools/bin/sync-dependency-baseline.sh +247 -0
- package/tools/bin/sync-pr-labels.sh +12 -0
- package/tools/bin/sync-recurring-issue-checklist.sh +274 -0
- package/tools/bin/sync-shared-agent-home.sh +214 -0
- package/tools/bin/sync-vscode-workspace.sh +157 -0
- package/tools/bin/test-smoke.sh +63 -0
- package/tools/bin/uninstall-project-launchd.sh +55 -0
- package/tools/bin/update-github-labels.sh +14 -0
- package/tools/bin/worker-status.sh +19 -0
- package/tools/bin/workflow-catalog.sh +77 -0
- package/tools/dashboard/app.js +286 -0
- package/tools/dashboard/dashboard_snapshot.py +466 -0
- package/tools/dashboard/index.html +41 -0
- package/tools/dashboard/server.py +64 -0
- package/tools/dashboard/styles.css +351 -0
- package/tools/templates/issue-prompt-template.md +109 -0
- package/tools/templates/pr-fix-template.md +120 -0
- package/tools/templates/pr-merge-repair-template.md +91 -0
- package/tools/templates/pr-review-template.md +62 -0
- package/tools/templates/scheduled-issue-prompt-template.md +62 -0
- package/tools/tests/test-agent-control-plane-npm-cli.sh +279 -0
- package/tools/tests/test-agent-github-update-labels-falls-back-to-repository-id.sh +56 -0
- package/tools/tests/test-agent-project-claude-session-wrapper-clears-stale-sandbox-artifacts.sh +89 -0
- package/tools/tests/test-agent-project-claude-session-wrapper-does-not-retry-provider-quota.sh +82 -0
- package/tools/tests/test-agent-project-claude-session-wrapper-retries-transient-failures.sh +90 -0
- package/tools/tests/test-agent-project-claude-session-wrapper-times-out.sh +73 -0
- package/tools/tests/test-agent-project-claude-session-wrapper.sh +103 -0
- package/tools/tests/test-agent-project-cleanup-session-orphan-fallback.sh +90 -0
- package/tools/tests/test-agent-project-cleanup-session-skip-worktree-cleanup.sh +90 -0
- package/tools/tests/test-agent-project-codex-live-thread-persist.sh +76 -0
- package/tools/tests/test-agent-project-codex-recovery.sh +731 -0
- package/tools/tests/test-agent-project-codex-session-wrapper-clears-stale-sandbox-artifacts.sh +105 -0
- package/tools/tests/test-agent-project-codex-session-wrapper.sh +97 -0
- package/tools/tests/test-agent-project-open-pr-worktree-config-prefix.sh +81 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-clears-stale-sandbox-artifacts.sh +109 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-infers-blocked-result-contract.sh +89 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-recovers-literal-env-artifacts.sh +113 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-recovers-version-mismatch.sh +135 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-resident.sh +179 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-reuses-existing-agent-after-add-race.sh +119 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper-terminates-rate-limit-hang.sh +91 -0
- package/tools/tests/test-agent-project-openclaw-session-wrapper.sh +117 -0
- package/tools/tests/test-agent-project-publish-issue-pr-prunes-stale-worktree-entry.sh +148 -0
- package/tools/tests/test-agent-project-publish-issue-pr-reads-archived-session.sh +146 -0
- package/tools/tests/test-agent-project-publish-issue-pr-recovers-final-head.sh +145 -0
- package/tools/tests/test-agent-project-publish-issue-pr-reuses-existing-worktree.sh +147 -0
- package/tools/tests/test-agent-project-reconcile-failure-reason.sh +456 -0
- package/tools/tests/test-agent-project-reconcile-issue-archived-session-fallback.sh +96 -0
- package/tools/tests/test-agent-project-reconcile-issue-before-blocked.sh +90 -0
- package/tools/tests/test-agent-project-reconcile-issue-host-verification-recovery-uses-recovered-worktree.sh +212 -0
- package/tools/tests/test-agent-project-reconcile-issue-host-verification-recovery.sh +207 -0
- package/tools/tests/test-agent-project-reconcile-issue-provider-quota-schedules-provider-cooldown.sh +101 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-backfills-lane-metadata-from-worker-key.sh +113 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-clears-stale-failed-summary.sh +117 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-initializes-shared-agent-home.sh +55 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-normalizes-runner-state.sh +125 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-records-invalid-contract-summary.sh +118 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-skips-duplicate-blocked-comment.sh +144 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-standardizes-no-commits-blocker.sh +145 -0
- package/tools/tests/test-agent-project-reconcile-issue-session-synthesizes-blocked-comment.sh +139 -0
- package/tools/tests/test-agent-project-reconcile-pr-blocked-host-recovery.sh +242 -0
- package/tools/tests/test-agent-project-reconcile-pr-guard-blocked-no-commit.sh +142 -0
- package/tools/tests/test-agent-project-reconcile-pr-provider-quota-schedules-provider-cooldown.sh +106 -0
- package/tools/tests/test-agent-project-reconcile-pr-session-initializes-shared-agent-home.sh +66 -0
- package/tools/tests/test-agent-project-reconcile-pr-updated-branch-noop.sh +129 -0
- package/tools/tests/test-audit-agent-worktrees-active-launch-skips-git-inspection.sh +69 -0
- package/tools/tests/test-audit-agent-worktrees-broken-worktree.sh +43 -0
- package/tools/tests/test-audit-agent-worktrees-pending-launch-owner.sh +46 -0
- package/tools/tests/test-audit-agent-worktrees-unreconciled-owner.sh +79 -0
- package/tools/tests/test-audit-issue-routing-managed-branch-globs.sh +56 -0
- package/tools/tests/test-branch-verification-guard-generated-artifacts.sh +72 -0
- package/tools/tests/test-branch-verification-guard-targeted-coverage.sh +125 -0
- package/tools/tests/test-codex-quota-manager-failure-driven-rotation.sh +178 -0
- package/tools/tests/test-codex-quota-wrapper.sh +37 -0
- package/tools/tests/test-contribution-docs.sh +18 -0
- package/tools/tests/test-control-plane-dashboard-runtime-smoke.sh +343 -0
- package/tools/tests/test-create-follow-up-issue.sh +73 -0
- package/tools/tests/test-dashboard-launchd-bootstrap.sh +55 -0
- package/tools/tests/test-flow-export-execution-env-exports-repo-id.sh +30 -0
- package/tools/tests/test-flow-export-github-cli-auth-env-prefers-git-credential.sh +48 -0
- package/tools/tests/test-flow-github-api-repo-fallback-preserves-input.sh +85 -0
- package/tools/tests/test-flow-github-api-repo-prefers-explicit-repository-id.sh +60 -0
- package/tools/tests/test-flow-github-issue-list-falls-back-to-repository-id.sh +64 -0
- package/tools/tests/test-flow-github-pr-list-falls-back-to-repository-id.sh +77 -0
- package/tools/tests/test-flow-resident-can-reuse-does-not-leak-metadata.sh +52 -0
- package/tools/tests/test-flow-resident-reap-stale-controllers.sh +63 -0
- package/tools/tests/test-flow-resolve-codex-quota-tools.sh +104 -0
- package/tools/tests/test-flow-runtime-doctor-profile-selection.sh +27 -0
- package/tools/tests/test-heartbeat-codex-pr-linked-issue-exclusion.sh +79 -0
- package/tools/tests/test-heartbeat-hooks-enqueue-resident-issue-for-idle-controller.sh +115 -0
- package/tools/tests/test-heartbeat-hooks-enqueue-resident-issue-for-live-lane-controller.sh +117 -0
- package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop-claude.sh +96 -0
- package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop-codex.sh +96 -0
- package/tools/tests/test-heartbeat-hooks-start-resident-issue-loop.sh +96 -0
- package/tools/tests/test-heartbeat-loop-auth-wait-does-not-consume-capacity.sh +170 -0
- package/tools/tests/test-heartbeat-loop-blocked-recovery-lane.sh +201 -0
- package/tools/tests/test-heartbeat-loop-blocked-recovery-vs-pr-reservation.sh +201 -0
- package/tools/tests/test-heartbeat-loop-idle-resident-controller-does-not-block-launches.sh +160 -0
- package/tools/tests/test-heartbeat-loop-pr-launch-dedup.sh +133 -0
- package/tools/tests/test-heartbeat-loop-provider-cooldown-suppresses-launches.sh +157 -0
- package/tools/tests/test-heartbeat-loop-reaps-stale-resident-controller.sh +181 -0
- package/tools/tests/test-heartbeat-loop-waiting-provider-resident-controller-does-not-block-launches.sh +160 -0
- package/tools/tests/test-heartbeat-ready-issues-blocked-recovery.sh +134 -0
- package/tools/tests/test-heartbeat-safe-auto-dynamic-concurrency.sh +162 -0
- package/tools/tests/test-heartbeat-safe-auto-no-tmux-sessions.sh +136 -0
- package/tools/tests/test-heartbeat-safe-auto-openclaw-skips-codex-quota.sh +139 -0
- package/tools/tests/test-heartbeat-safe-auto-quota-health-signal.sh +119 -0
- package/tools/tests/test-heartbeat-safe-auto-stale-shared-loop-pid-does-not-skip.sh +140 -0
- package/tools/tests/test-heartbeat-safe-auto-static-capacity-without-quota-cache.sh +142 -0
- package/tools/tests/test-heartbeat-safe-auto-zero-healthy-pools.sh +141 -0
- package/tools/tests/test-heartbeat-sync-issue-labels-empty-schedule.sh +65 -0
- package/tools/tests/test-heartbeat-sync-open-agent-prs-terminal-clears-running.sh +179 -0
- package/tools/tests/test-install-dashboard-launchd.sh +78 -0
- package/tools/tests/test-install-project-launchd-adds-tool-paths.sh +87 -0
- package/tools/tests/test-install-project-launchd.sh +110 -0
- package/tools/tests/test-issue-local-workspace-install-policy.sh +81 -0
- package/tools/tests/test-issue-publish-scope-guard-docs-signal.sh +70 -0
- package/tools/tests/test-issue-reconcile-hooks-success-clears-blocked.sh +36 -0
- package/tools/tests/test-kick-scheduler-requires-explicit-profile.sh +47 -0
- package/tools/tests/test-label-follow-up-issues-falls-back-to-repository-id.sh +132 -0
- package/tools/tests/test-manual-operator-entrypoints-require-explicit-profile.sh +64 -0
- package/tools/tests/test-package-funding-metadata.sh +21 -0
- package/tools/tests/test-package-public-metadata.sh +62 -0
- package/tools/tests/test-placeholder-worker-adapters.sh +38 -0
- package/tools/tests/test-pr-reconcile-hooks-refreshes-recurring-issue-checklist.sh +110 -0
- package/tools/tests/test-pr-risk-cohesive-mobile-locale-scope.sh +70 -0
- package/tools/tests/test-pr-risk-fix-label-semantics.sh +114 -0
- package/tools/tests/test-pr-risk-local-first-no-checks.sh +70 -0
- package/tools/tests/test-prepare-worktree-simple-repo-baseline.sh +67 -0
- package/tools/tests/test-profile-activate.sh +33 -0
- package/tools/tests/test-profile-adopt-allow-missing-repo.sh +68 -0
- package/tools/tests/test-profile-adopt-skip-workspace-sync-missing-file.sh +61 -0
- package/tools/tests/test-profile-adopt-syncs-anchor-and-workspace.sh +90 -0
- package/tools/tests/test-profile-smoke-collision.sh +44 -0
- package/tools/tests/test-profile-smoke-invalid-claude-config.sh +31 -0
- package/tools/tests/test-profile-smoke-invalid-provider-pool.sh +68 -0
- package/tools/tests/test-profile-smoke-repo-slug-mismatch.sh +36 -0
- package/tools/tests/test-profile-smoke.sh +45 -0
- package/tools/tests/test-project-init-force-and-skip-sync.sh +61 -0
- package/tools/tests/test-project-init-repo-slug-mismatch.sh +29 -0
- package/tools/tests/test-project-init.sh +66 -0
- package/tools/tests/test-project-launchd-bootstrap.sh +66 -0
- package/tools/tests/test-project-remove.sh +150 -0
- package/tools/tests/test-project-runtime-supervisor.sh +47 -0
- package/tools/tests/test-project-runtimectl-launchd.sh +115 -0
- package/tools/tests/test-project-runtimectl-missing-profile.sh +54 -0
- package/tools/tests/test-project-runtimectl-start-falls-back-to-bootstrap.sh +108 -0
- package/tools/tests/test-project-runtimectl-status-reports-supervisor-as-heartbeat-parent.sh +95 -0
- package/tools/tests/test-project-runtimectl-status-supervisor-running.sh +59 -0
- package/tools/tests/test-project-runtimectl-stop-cancels-pending-kick.sh +85 -0
- package/tools/tests/test-project-runtimectl-stop-clears-running-labels.sh +78 -0
- package/tools/tests/test-project-runtimectl.sh +212 -0
- package/tools/tests/test-provider-cooldown-state-prefers-runtime-worker-context.sh +39 -0
- package/tools/tests/test-provider-cooldown-state.sh +59 -0
- package/tools/tests/test-public-repo-docs.sh +159 -0
- package/tools/tests/test-reconcile-pr-worker-acp-config-routing.sh +75 -0
- package/tools/tests/test-render-dashboard-snapshot.sh +149 -0
- package/tools/tests/test-render-flow-config-demo-profile.sh +36 -0
- package/tools/tests/test-render-flow-config-provider-pool-fallback.sh +81 -0
- package/tools/tests/test-render-flow-config.sh +52 -0
- package/tools/tests/test-run-codex-task-claude-routing.sh +125 -0
- package/tools/tests/test-run-codex-task-codex-resident-routing.sh +108 -0
- package/tools/tests/test-run-codex-task-kilo-routing.sh +98 -0
- package/tools/tests/test-run-codex-task-openclaw-resident-routing.sh +117 -0
- package/tools/tests/test-run-codex-task-openclaw-routing.sh +113 -0
- package/tools/tests/test-run-codex-task-opencode-routing.sh +98 -0
- package/tools/tests/test-run-codex-task-provider-pool-fallback-routing.sh +146 -0
- package/tools/tests/test-scaffold-profile.sh +108 -0
- package/tools/tests/test-serve-dashboard.sh +93 -0
- package/tools/tests/test-start-issue-worker-blocked-context.sh +129 -0
- package/tools/tests/test-start-issue-worker-blocks-complete-recurring-checklist.sh +189 -0
- package/tools/tests/test-start-issue-worker-local-install-routing.sh +157 -0
- package/tools/tests/test-start-issue-worker-profile-template-routing.sh +149 -0
- package/tools/tests/test-start-issue-worker-recurring-resident-reuse-codex.sh +212 -0
- package/tools/tests/test-start-issue-worker-recurring-resident-reuse.sh +219 -0
- package/tools/tests/test-start-issue-worker-renders-verification-snippet.sh +155 -0
- package/tools/tests/test-start-issue-worker-resident-reuse-falls-back-to-new-worktree.sh +199 -0
- package/tools/tests/test-start-pr-fix-worker-host-blocker-context.sh +275 -0
- package/tools/tests/test-start-resident-issue-loop-adopts-next-recurring-issue.sh +185 -0
- package/tools/tests/test-start-resident-issue-loop-clears-pending-while-waiting-due.sh +152 -0
- package/tools/tests/test-start-resident-issue-loop-consumes-queued-lease.sh +186 -0
- package/tools/tests/test-start-resident-issue-loop-fails-over-provider-pool.sh +212 -0
- package/tools/tests/test-start-resident-issue-loop-immediate-cycles.sh +148 -0
- package/tools/tests/test-start-resident-issue-loop-waits-for-provider.sh +194 -0
- package/tools/tests/test-start-resident-issue-loop-waits-for-terminal-reconcile-status.sh +198 -0
- package/tools/tests/test-start-resident-issue-loop-yields-to-live-lane-controller.sh +145 -0
- package/tools/tests/test-sync-pr-labels-fix-lane-uses-repair-queued.sh +67 -0
- package/tools/tests/test-sync-recurring-issue-checklist-backfills-workflow-complete-blocker.sh +70 -0
- package/tools/tests/test-sync-recurring-issue-checklist.sh +95 -0
- package/tools/tests/test-sync-shared-agent-home-local-source-root.sh +66 -0
- package/tools/tests/test-sync-shared-agent-home-preserves-unrelated-workflow-catalog-skill.sh +47 -0
- package/tools/tests/test-test-smoke.sh +86 -0
- package/tools/tests/test-uninstall-project-launchd.sh +37 -0
- package/tools/tests/test-update-github-labels-prefers-sibling-helper.sh +49 -0
- package/tools/tests/test-workflow-catalog.sh +43 -0
- package/tools/vendor/codex-quota/LICENSE +21 -0
- package/tools/vendor/codex-quota/README.md +459 -0
- package/tools/vendor/codex-quota/codex-quota.js +261 -0
- package/tools/vendor/codex-quota/lib/claude-accounts.js +226 -0
- package/tools/vendor/codex-quota/lib/claude-oauth.js +174 -0
- package/tools/vendor/codex-quota/lib/claude-tokens.js +471 -0
- package/tools/vendor/codex-quota/lib/claude-usage.js +929 -0
- package/tools/vendor/codex-quota/lib/codex-accounts.js +205 -0
- package/tools/vendor/codex-quota/lib/codex-tokens.js +326 -0
- package/tools/vendor/codex-quota/lib/codex-usage.js +32 -0
- package/tools/vendor/codex-quota/lib/color.js +72 -0
- package/tools/vendor/codex-quota/lib/constants.js +57 -0
- package/tools/vendor/codex-quota/lib/container.js +143 -0
- package/tools/vendor/codex-quota/lib/display.js +1111 -0
- package/tools/vendor/codex-quota/lib/fs.js +63 -0
- package/tools/vendor/codex-quota/lib/handlers.js +2060 -0
- package/tools/vendor/codex-quota/lib/jwt.js +33 -0
- package/tools/vendor/codex-quota/lib/oauth.js +486 -0
- package/tools/vendor/codex-quota/lib/paths.js +34 -0
- package/tools/vendor/codex-quota/lib/prompts.js +44 -0
- package/tools/vendor/codex-quota/lib/sync.js +1438 -0
- package/tools/vendor/codex-quota/lib/token-match.js +96 -0
- package/tools/vendor/codex-quota-manager/scripts/auto-switch.sh +500 -0
- package/tools/vendor/codex-quota-manager/scripts/batch-add.sh +123 -0
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
ROOT_DIR = Path(__file__).resolve().parents[2]
|
|
15
|
+
TOOLS_BIN_DIR = ROOT_DIR / "tools" / "bin"
|
|
16
|
+
RENDER_FLOW_CONFIG = TOOLS_BIN_DIR / "render-flow-config.sh"
|
|
17
|
+
WORKER_STATUS_TOOL = TOOLS_BIN_DIR / "agent-project-worker-status"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def utc_now_iso() -> str:
|
|
21
|
+
return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def profile_registry_root() -> Path:
|
|
25
|
+
override = os.environ.get("ACP_PROFILE_REGISTRY_ROOT", "").strip()
|
|
26
|
+
if override:
|
|
27
|
+
return Path(override).expanduser()
|
|
28
|
+
return Path.home() / ".agent-runtime" / "control-plane" / "profiles"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def split_key_value_text(text: str) -> list[str]:
|
|
32
|
+
return [line.strip() for line in re.split(r"(?:\r?\n|\\n)+", text) if line.strip()]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def normalize_value(raw: str) -> str:
|
|
36
|
+
value = raw.strip()
|
|
37
|
+
if value in {"''", '""'}:
|
|
38
|
+
return ""
|
|
39
|
+
if len(value) >= 2 and value[0] == value[-1] and value[0] in {"'", '"'}:
|
|
40
|
+
return value[1:-1]
|
|
41
|
+
return value
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def parse_key_value_text(text: str) -> dict[str, str]:
|
|
45
|
+
data: dict[str, str] = {}
|
|
46
|
+
for line in split_key_value_text(text):
|
|
47
|
+
if "=" not in line:
|
|
48
|
+
continue
|
|
49
|
+
key, value = line.split("=", 1)
|
|
50
|
+
data[key.strip()] = normalize_value(value)
|
|
51
|
+
return data
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def read_env_file(path: Path) -> dict[str, str]:
|
|
55
|
+
if not path.is_file():
|
|
56
|
+
return {}
|
|
57
|
+
return parse_key_value_text(path.read_text(encoding="utf-8", errors="replace"))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def parse_simple_yaml(path: Path) -> dict[str, str]:
|
|
61
|
+
data: dict[str, str] = {}
|
|
62
|
+
if not path.is_file():
|
|
63
|
+
return data
|
|
64
|
+
|
|
65
|
+
stack: list[tuple[int, str]] = []
|
|
66
|
+
for raw_line in path.read_text(encoding="utf-8", errors="replace").splitlines():
|
|
67
|
+
line = raw_line.rstrip()
|
|
68
|
+
if not line or line.lstrip().startswith("#"):
|
|
69
|
+
continue
|
|
70
|
+
indent = len(line) - len(line.lstrip(" "))
|
|
71
|
+
stripped = line.strip()
|
|
72
|
+
if not stripped:
|
|
73
|
+
continue
|
|
74
|
+
if stripped.endswith(":"):
|
|
75
|
+
key = stripped[:-1].strip()
|
|
76
|
+
while stack and stack[-1][0] >= indent:
|
|
77
|
+
stack.pop()
|
|
78
|
+
stack.append((indent, key))
|
|
79
|
+
continue
|
|
80
|
+
if ":" not in stripped:
|
|
81
|
+
continue
|
|
82
|
+
key, value = stripped.split(":", 1)
|
|
83
|
+
key = key.strip()
|
|
84
|
+
value = normalize_value(value)
|
|
85
|
+
path_parts = [entry[1] for entry in stack]
|
|
86
|
+
path_parts.append(key)
|
|
87
|
+
data[".".join(path_parts)] = value
|
|
88
|
+
return data
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def run_key_value_script(script: Path, env: dict[str, str], *args: str) -> dict[str, str]:
|
|
92
|
+
output = subprocess.check_output(
|
|
93
|
+
["bash", str(script), *args],
|
|
94
|
+
cwd=str(ROOT_DIR),
|
|
95
|
+
env=env,
|
|
96
|
+
text=True,
|
|
97
|
+
stderr=subprocess.DEVNULL,
|
|
98
|
+
timeout=30,
|
|
99
|
+
)
|
|
100
|
+
return parse_key_value_text(output)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def list_profile_ids(registry_root: Path) -> list[str]:
|
|
104
|
+
if not registry_root.is_dir():
|
|
105
|
+
return []
|
|
106
|
+
profile_ids: list[str] = []
|
|
107
|
+
for entry in sorted(registry_root.iterdir()):
|
|
108
|
+
if not entry.is_dir():
|
|
109
|
+
continue
|
|
110
|
+
if (entry / "control-plane.yaml").is_file():
|
|
111
|
+
profile_ids.append(entry.name)
|
|
112
|
+
return profile_ids
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def env_with_profile(profile_id: str, registry_root: Path) -> dict[str, str]:
|
|
116
|
+
env = os.environ.copy()
|
|
117
|
+
env["ACP_PROJECT_ID"] = profile_id
|
|
118
|
+
env["ACP_PROFILE_REGISTRY_ROOT"] = str(registry_root)
|
|
119
|
+
return env
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def safe_int(value: str | None) -> int | None:
|
|
123
|
+
if not value:
|
|
124
|
+
return None
|
|
125
|
+
try:
|
|
126
|
+
return int(str(value).strip())
|
|
127
|
+
except ValueError:
|
|
128
|
+
return None
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def pid_alive(value: str | None) -> bool:
|
|
132
|
+
pid = safe_int(value)
|
|
133
|
+
if not pid or pid <= 0:
|
|
134
|
+
return False
|
|
135
|
+
try:
|
|
136
|
+
os.kill(pid, 0)
|
|
137
|
+
except OSError:
|
|
138
|
+
return False
|
|
139
|
+
return True
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def file_mtime_iso(path: Path) -> str:
|
|
143
|
+
return datetime.fromtimestamp(path.stat().st_mtime, tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def classify_run_result(status: str, outcome: str, failure_reason: str) -> tuple[str, str]:
|
|
147
|
+
normalized_status = (status or "").strip().upper()
|
|
148
|
+
normalized_outcome = (outcome or "").strip()
|
|
149
|
+
normalized_failure = (failure_reason or "").strip()
|
|
150
|
+
|
|
151
|
+
if normalized_status == "RUNNING":
|
|
152
|
+
return ("running", "In progress")
|
|
153
|
+
if normalized_status == "FAILED":
|
|
154
|
+
if normalized_failure:
|
|
155
|
+
return ("failed", f"Failed: {normalized_failure}")
|
|
156
|
+
return ("failed", "Failed")
|
|
157
|
+
if normalized_status == "SUCCEEDED":
|
|
158
|
+
if normalized_outcome == "implemented":
|
|
159
|
+
return ("implemented", "Implemented")
|
|
160
|
+
if normalized_outcome == "reported":
|
|
161
|
+
return ("reported", "Reported")
|
|
162
|
+
if normalized_outcome == "blocked":
|
|
163
|
+
return ("blocked", "Blocked")
|
|
164
|
+
if normalized_outcome:
|
|
165
|
+
return ("completed", normalized_outcome)
|
|
166
|
+
return ("completed", "Completed")
|
|
167
|
+
return ("unknown", normalized_status or "Unknown")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def collect_runs(runs_root: Path) -> list[dict[str, Any]]:
|
|
171
|
+
if not runs_root.is_dir():
|
|
172
|
+
return []
|
|
173
|
+
|
|
174
|
+
runs: list[dict[str, Any]] = []
|
|
175
|
+
for run_dir in sorted(
|
|
176
|
+
[entry for entry in runs_root.iterdir() if entry.is_dir()],
|
|
177
|
+
key=lambda item: item.stat().st_mtime,
|
|
178
|
+
reverse=True,
|
|
179
|
+
):
|
|
180
|
+
run_env = read_env_file(run_dir / "run.env")
|
|
181
|
+
session = run_env.get("SESSION", run_dir.name)
|
|
182
|
+
try:
|
|
183
|
+
status_env = run_key_value_script(
|
|
184
|
+
WORKER_STATUS_TOOL,
|
|
185
|
+
os.environ.copy(),
|
|
186
|
+
"--runs-root",
|
|
187
|
+
str(runs_root),
|
|
188
|
+
"--session",
|
|
189
|
+
session,
|
|
190
|
+
)
|
|
191
|
+
except subprocess.CalledProcessError:
|
|
192
|
+
status_env = {}
|
|
193
|
+
|
|
194
|
+
runner_env = read_env_file(run_dir / "runner.env")
|
|
195
|
+
result_env = read_env_file(run_dir / "result.env")
|
|
196
|
+
lifecycle_status = status_env.get("STATUS", "UNKNOWN")
|
|
197
|
+
outcome = result_env.get("OUTCOME", "")
|
|
198
|
+
failure_reason = status_env.get("FAILURE_REASON", runner_env.get("LAST_FAILURE_REASON", ""))
|
|
199
|
+
result_kind, result_label = classify_run_result(lifecycle_status, outcome, failure_reason)
|
|
200
|
+
item = {
|
|
201
|
+
"session": session,
|
|
202
|
+
"task_kind": run_env.get("TASK_KIND", ""),
|
|
203
|
+
"task_id": run_env.get("TASK_ID", ""),
|
|
204
|
+
"mode": run_env.get("MODE", ""),
|
|
205
|
+
"status": lifecycle_status,
|
|
206
|
+
"lifecycle_status": lifecycle_status,
|
|
207
|
+
"started_at": run_env.get("STARTED_AT", ""),
|
|
208
|
+
"updated_at": runner_env.get("UPDATED_AT", "") or result_env.get("UPDATED_AT", "") or file_mtime_iso(run_dir),
|
|
209
|
+
"coding_worker": run_env.get("CODING_WORKER", ""),
|
|
210
|
+
"branch": run_env.get("BRANCH", ""),
|
|
211
|
+
"worktree": run_env.get("WORKTREE", ""),
|
|
212
|
+
"thread_id": status_env.get("THREAD_ID", runner_env.get("THREAD_ID", "")),
|
|
213
|
+
"failure_reason": failure_reason,
|
|
214
|
+
"outcome": outcome,
|
|
215
|
+
"action": result_env.get("ACTION", ""),
|
|
216
|
+
"result_only_completion": status_env.get("RESULT_ONLY_COMPLETION", "no"),
|
|
217
|
+
"result_kind": result_kind,
|
|
218
|
+
"result_label": result_label,
|
|
219
|
+
"resident_worker_key": run_env.get("RESIDENT_WORKER_KEY", ""),
|
|
220
|
+
"provider_model": run_env.get("OPENCLAW_MODEL", "") or run_env.get("CLAUDE_MODEL", ""),
|
|
221
|
+
"provider_pool_name": run_env.get("ACTIVE_PROVIDER_POOL_NAME", ""),
|
|
222
|
+
"run_dir": str(run_dir),
|
|
223
|
+
}
|
|
224
|
+
runs.append(item)
|
|
225
|
+
return runs
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def collect_resident_controllers(state_root: Path) -> list[dict[str, Any]]:
|
|
229
|
+
controllers_root = state_root / "resident-workers" / "issues"
|
|
230
|
+
if not controllers_root.is_dir():
|
|
231
|
+
return []
|
|
232
|
+
|
|
233
|
+
items: list[dict[str, Any]] = []
|
|
234
|
+
for path in sorted(controllers_root.glob("*/controller.env"), key=lambda item: item.stat().st_mtime, reverse=True):
|
|
235
|
+
env = read_env_file(path)
|
|
236
|
+
controller_pid = env.get("CONTROLLER_PID", "")
|
|
237
|
+
items.append(
|
|
238
|
+
{
|
|
239
|
+
"issue_id": env.get("ISSUE_ID", path.parent.name),
|
|
240
|
+
"session": env.get("SESSION", ""),
|
|
241
|
+
"controller_pid": controller_pid,
|
|
242
|
+
"controller_live": pid_alive(controller_pid),
|
|
243
|
+
"mode": env.get("CONTROLLER_MODE", ""),
|
|
244
|
+
"loop_count": safe_int(env.get("CONTROLLER_LOOP_COUNT")),
|
|
245
|
+
"state": env.get("CONTROLLER_STATE", ""),
|
|
246
|
+
"reason": env.get("CONTROLLER_REASON", ""),
|
|
247
|
+
"next_wake_at": env.get("NEXT_WAKE_AT", ""),
|
|
248
|
+
"updated_at": env.get("UPDATED_AT", "") or file_mtime_iso(path),
|
|
249
|
+
"worker_key": env.get("ACTIVE_RESIDENT_WORKER_KEY", ""),
|
|
250
|
+
"lane_kind": env.get("ACTIVE_RESIDENT_LANE_KIND", ""),
|
|
251
|
+
"lane_value": env.get("ACTIVE_RESIDENT_LANE_VALUE", ""),
|
|
252
|
+
"provider_pool_name": env.get("ACTIVE_PROVIDER_POOL_NAME", ""),
|
|
253
|
+
"provider_backend": env.get("ACTIVE_PROVIDER_BACKEND", ""),
|
|
254
|
+
"provider_model": env.get("ACTIVE_PROVIDER_MODEL", ""),
|
|
255
|
+
"provider_key": env.get("ACTIVE_PROVIDER_KEY", ""),
|
|
256
|
+
"provider_switch_count": safe_int(env.get("PROVIDER_SWITCH_COUNT")) or 0,
|
|
257
|
+
"provider_failover_count": safe_int(env.get("PROVIDER_FAILOVER_COUNT")) or 0,
|
|
258
|
+
"provider_wait_count": safe_int(env.get("PROVIDER_WAIT_COUNT")) or 0,
|
|
259
|
+
"provider_wait_total_seconds": safe_int(env.get("PROVIDER_WAIT_TOTAL_SECONDS")) or 0,
|
|
260
|
+
"provider_last_wait_seconds": safe_int(env.get("PROVIDER_LAST_WAIT_SECONDS")) or 0,
|
|
261
|
+
"last_provider_switch_at": env.get("LAST_PROVIDER_SWITCH_AT", ""),
|
|
262
|
+
"last_provider_switch_reason": env.get("LAST_PROVIDER_SWITCH_REASON", ""),
|
|
263
|
+
"last_provider_from_backend": env.get("LAST_PROVIDER_FROM_BACKEND", ""),
|
|
264
|
+
"last_provider_from_model": env.get("LAST_PROVIDER_FROM_MODEL", ""),
|
|
265
|
+
"last_provider_to_backend": env.get("LAST_PROVIDER_TO_BACKEND", ""),
|
|
266
|
+
"last_provider_to_model": env.get("LAST_PROVIDER_TO_MODEL", ""),
|
|
267
|
+
"controller_file": str(path),
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
return items
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def collect_resident_workers(state_root: Path) -> list[dict[str, Any]]:
|
|
274
|
+
resident_root = state_root / "resident-workers" / "issues"
|
|
275
|
+
if not resident_root.is_dir():
|
|
276
|
+
return []
|
|
277
|
+
|
|
278
|
+
items: list[dict[str, Any]] = []
|
|
279
|
+
for path in sorted(resident_root.glob("*/metadata.env"), key=lambda item: item.stat().st_mtime, reverse=True):
|
|
280
|
+
env = read_env_file(path)
|
|
281
|
+
items.append(
|
|
282
|
+
{
|
|
283
|
+
"key": env.get("RESIDENT_WORKER_KEY", path.parent.name),
|
|
284
|
+
"scope": env.get("RESIDENT_WORKER_SCOPE", "issue"),
|
|
285
|
+
"kind": env.get("RESIDENT_WORKER_KIND", ""),
|
|
286
|
+
"issue_id": env.get("ISSUE_ID", ""),
|
|
287
|
+
"coding_worker": env.get("CODING_WORKER", ""),
|
|
288
|
+
"task_count": safe_int(env.get("TASK_COUNT")) or 0,
|
|
289
|
+
"last_status": env.get("LAST_STATUS", ""),
|
|
290
|
+
"last_started_at": env.get("LAST_STARTED_AT", ""),
|
|
291
|
+
"last_finished_at": env.get("LAST_FINISHED_AT", ""),
|
|
292
|
+
"last_run_session": env.get("LAST_RUN_SESSION", ""),
|
|
293
|
+
"last_outcome": env.get("LAST_OUTCOME", ""),
|
|
294
|
+
"last_action": env.get("LAST_ACTION", ""),
|
|
295
|
+
"last_failure_reason": env.get("LAST_FAILURE_REASON", ""),
|
|
296
|
+
"worktree": env.get("WORKTREE", ""),
|
|
297
|
+
"metadata_file": str(path),
|
|
298
|
+
}
|
|
299
|
+
)
|
|
300
|
+
return items
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def collect_provider_cooldowns(state_root: Path) -> list[dict[str, Any]]:
|
|
304
|
+
providers_root = state_root / "retries" / "providers"
|
|
305
|
+
if not providers_root.is_dir():
|
|
306
|
+
return []
|
|
307
|
+
|
|
308
|
+
now_epoch = int(datetime.now(timezone.utc).timestamp())
|
|
309
|
+
items: list[dict[str, Any]] = []
|
|
310
|
+
for path in sorted(providers_root.glob("*.env"), key=lambda item: item.stat().st_mtime, reverse=True):
|
|
311
|
+
env = read_env_file(path)
|
|
312
|
+
next_attempt_epoch = safe_int(env.get("NEXT_ATTEMPT_EPOCH"))
|
|
313
|
+
items.append(
|
|
314
|
+
{
|
|
315
|
+
"provider_key": path.stem,
|
|
316
|
+
"attempts": safe_int(env.get("ATTEMPTS")) or 0,
|
|
317
|
+
"next_attempt_epoch": next_attempt_epoch,
|
|
318
|
+
"next_attempt_at": env.get("NEXT_ATTEMPT_AT", ""),
|
|
319
|
+
"last_reason": env.get("LAST_REASON", ""),
|
|
320
|
+
"updated_at": env.get("UPDATED_AT", "") or file_mtime_iso(path),
|
|
321
|
+
"active": bool(next_attempt_epoch and next_attempt_epoch > now_epoch),
|
|
322
|
+
"state_file": str(path),
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
return items
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def collect_scheduled_issues(state_root: Path) -> list[dict[str, Any]]:
|
|
329
|
+
scheduled_root = state_root / "scheduled-issues"
|
|
330
|
+
if not scheduled_root.is_dir():
|
|
331
|
+
return []
|
|
332
|
+
|
|
333
|
+
items: list[dict[str, Any]] = []
|
|
334
|
+
for path in sorted(scheduled_root.glob("*.env"), key=lambda item: item.stat().st_mtime, reverse=True):
|
|
335
|
+
env = read_env_file(path)
|
|
336
|
+
items.append(
|
|
337
|
+
{
|
|
338
|
+
"issue_id": path.stem,
|
|
339
|
+
"interval_seconds": safe_int(env.get("INTERVAL_SECONDS")) or 0,
|
|
340
|
+
"last_started_at": env.get("LAST_STARTED_AT", ""),
|
|
341
|
+
"next_due_at": env.get("NEXT_DUE_AT", ""),
|
|
342
|
+
"updated_at": env.get("UPDATED_AT", "") or file_mtime_iso(path),
|
|
343
|
+
"state_file": str(path),
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
return items
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def collect_issue_queue(state_root: Path) -> dict[str, list[dict[str, Any]]]:
|
|
350
|
+
queue_root = state_root / "resident-workers" / "issue-queue"
|
|
351
|
+
pending_root = queue_root / "pending"
|
|
352
|
+
claims_root = queue_root / "claims"
|
|
353
|
+
|
|
354
|
+
def collect_files(root: Path) -> list[dict[str, Any]]:
|
|
355
|
+
if not root.is_dir():
|
|
356
|
+
return []
|
|
357
|
+
items: list[dict[str, Any]] = []
|
|
358
|
+
for path in sorted(root.glob("*.env"), key=lambda item: item.stat().st_mtime, reverse=True):
|
|
359
|
+
env = read_env_file(path)
|
|
360
|
+
items.append(
|
|
361
|
+
{
|
|
362
|
+
"issue_id": env.get("ISSUE_ID", path.stem.removeprefix("issue-")),
|
|
363
|
+
"session": env.get("SESSION", ""),
|
|
364
|
+
"claim_file": env.get("CLAIM_FILE", ""),
|
|
365
|
+
"updated_at": env.get("UPDATED_AT", "") or file_mtime_iso(path),
|
|
366
|
+
"state_file": str(path),
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
return items
|
|
370
|
+
|
|
371
|
+
return {
|
|
372
|
+
"pending": collect_files(pending_root),
|
|
373
|
+
"claims": collect_files(claims_root),
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def build_profile_snapshot(profile_id: str, registry_root: Path) -> dict[str, Any]:
|
|
378
|
+
env = env_with_profile(profile_id, registry_root)
|
|
379
|
+
render_env = run_key_value_script(RENDER_FLOW_CONFIG, env)
|
|
380
|
+
config_yaml = Path(render_env.get("CONFIG_YAML", registry_root / profile_id / "control-plane.yaml"))
|
|
381
|
+
yaml_env = parse_simple_yaml(config_yaml)
|
|
382
|
+
|
|
383
|
+
runs_root = Path(render_env.get("EFFECTIVE_RUNS_ROOT", ""))
|
|
384
|
+
state_root = Path(render_env.get("EFFECTIVE_STATE_ROOT", ""))
|
|
385
|
+
runs = collect_runs(runs_root)
|
|
386
|
+
controllers = collect_resident_controllers(state_root)
|
|
387
|
+
resident_workers = collect_resident_workers(state_root)
|
|
388
|
+
cooldowns = collect_provider_cooldowns(state_root)
|
|
389
|
+
scheduled = collect_scheduled_issues(state_root)
|
|
390
|
+
queue = collect_issue_queue(state_root)
|
|
391
|
+
|
|
392
|
+
return {
|
|
393
|
+
"id": profile_id,
|
|
394
|
+
"repo_slug": yaml_env.get("repo.slug", ""),
|
|
395
|
+
"repo_root": render_env.get("EFFECTIVE_REPO_ROOT", ""),
|
|
396
|
+
"runs_root": str(runs_root),
|
|
397
|
+
"state_root": str(state_root),
|
|
398
|
+
"issue_prefix": yaml_env.get("session_naming.issue_prefix", ""),
|
|
399
|
+
"pr_prefix": yaml_env.get("session_naming.pr_prefix", ""),
|
|
400
|
+
"coding_worker": render_env.get("EFFECTIVE_CODING_WORKER", ""),
|
|
401
|
+
"provider_pool": {
|
|
402
|
+
"order": render_env.get("EFFECTIVE_PROVIDER_POOL_ORDER", ""),
|
|
403
|
+
"name": render_env.get("EFFECTIVE_PROVIDER_POOL_NAME", ""),
|
|
404
|
+
"backend": render_env.get("EFFECTIVE_PROVIDER_POOL_BACKEND", ""),
|
|
405
|
+
"model": render_env.get("EFFECTIVE_PROVIDER_POOL_MODEL", ""),
|
|
406
|
+
"key": render_env.get("EFFECTIVE_PROVIDER_POOL_KEY", ""),
|
|
407
|
+
"selection_reason": render_env.get("EFFECTIVE_PROVIDER_POOL_SELECTION_REASON", ""),
|
|
408
|
+
"next_attempt_at": render_env.get("EFFECTIVE_PROVIDER_POOL_NEXT_ATTEMPT_AT", ""),
|
|
409
|
+
"last_reason": render_env.get("EFFECTIVE_PROVIDER_POOL_LAST_REASON", ""),
|
|
410
|
+
"pools_exhausted": render_env.get("EFFECTIVE_PROVIDER_POOLS_EXHAUSTED", ""),
|
|
411
|
+
},
|
|
412
|
+
"counts": {
|
|
413
|
+
"active_runs": len(runs),
|
|
414
|
+
"running_runs": sum(1 for item in runs if item["status"] == "RUNNING"),
|
|
415
|
+
"failed_runs": sum(1 for item in runs if item["status"] == "FAILED"),
|
|
416
|
+
"succeeded_runs": sum(1 for item in runs if item["status"] == "SUCCEEDED"),
|
|
417
|
+
"implemented_runs": sum(1 for item in runs if item["result_kind"] == "implemented"),
|
|
418
|
+
"reported_runs": sum(1 for item in runs if item["result_kind"] == "reported"),
|
|
419
|
+
"blocked_runs": sum(1 for item in runs if item["result_kind"] == "blocked"),
|
|
420
|
+
"completed_runs": sum(
|
|
421
|
+
1 for item in runs if item["status"] == "SUCCEEDED" and item["result_kind"] not in {"implemented", "reported", "blocked"}
|
|
422
|
+
),
|
|
423
|
+
"resident_controllers": len(controllers),
|
|
424
|
+
"live_resident_controllers": sum(1 for item in controllers if item["state"] != "stopped" and item["controller_live"]),
|
|
425
|
+
"resident_workers": len(resident_workers),
|
|
426
|
+
"queued_issues": len(queue["pending"]),
|
|
427
|
+
"claimed_issues": len(queue["claims"]),
|
|
428
|
+
"provider_cooldowns": sum(1 for item in cooldowns if item["active"]),
|
|
429
|
+
"scheduled_issues": len(scheduled),
|
|
430
|
+
},
|
|
431
|
+
"runs": runs,
|
|
432
|
+
"resident_controllers": controllers,
|
|
433
|
+
"resident_workers": resident_workers,
|
|
434
|
+
"provider_cooldowns": cooldowns,
|
|
435
|
+
"scheduled_issues": scheduled,
|
|
436
|
+
"issue_queue": queue,
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
def build_snapshot() -> dict[str, Any]:
|
|
441
|
+
registry_root = profile_registry_root()
|
|
442
|
+
profiles = [build_profile_snapshot(profile_id, registry_root) for profile_id in list_profile_ids(registry_root)]
|
|
443
|
+
return {
|
|
444
|
+
"generated_at": utc_now_iso(),
|
|
445
|
+
"flow_skill_dir": str(ROOT_DIR),
|
|
446
|
+
"profile_registry_root": str(registry_root),
|
|
447
|
+
"profile_count": len(profiles),
|
|
448
|
+
"profiles": profiles,
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def main(argv: list[str] | None = None) -> int:
|
|
453
|
+
import argparse
|
|
454
|
+
|
|
455
|
+
parser = argparse.ArgumentParser(description="Render an ACP worker dashboard snapshot as JSON.")
|
|
456
|
+
parser.add_argument("--pretty", action="store_true", help="Pretty-print JSON output.")
|
|
457
|
+
args = parser.parse_args(argv)
|
|
458
|
+
|
|
459
|
+
snapshot = build_snapshot()
|
|
460
|
+
json.dump(snapshot, sys.stdout, indent=2 if args.pretty else None, sort_keys=False)
|
|
461
|
+
sys.stdout.write("\n")
|
|
462
|
+
return 0
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
if __name__ == "__main__":
|
|
466
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>ACP Worker Dashboard</title>
|
|
7
|
+
<link rel="stylesheet" href="./styles.css" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<main class="page">
|
|
11
|
+
<header class="hero">
|
|
12
|
+
<div>
|
|
13
|
+
<p class="eyebrow">Agent Control Plane</p>
|
|
14
|
+
<h1>Worker Dashboard</h1>
|
|
15
|
+
<p class="subtitle">
|
|
16
|
+
Track active runs, resident controllers, queue pressure, and provider failover in one place.
|
|
17
|
+
</p>
|
|
18
|
+
<p class="subtitle">
|
|
19
|
+
Lifecycle shows whether a worker session finished cleanly. Result shows whether that cycle implemented work, reported findings, or stopped blocked.
|
|
20
|
+
</p>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="hero-actions">
|
|
23
|
+
<button id="refresh-button" type="button">Refresh now</button>
|
|
24
|
+
<div class="meta">
|
|
25
|
+
<div>Auto refresh: <strong>5s</strong></div>
|
|
26
|
+
<div id="generated-at">Loading snapshot...</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</header>
|
|
30
|
+
|
|
31
|
+
<section id="overview" class="overview"></section>
|
|
32
|
+
<section id="profiles" class="profiles"></section>
|
|
33
|
+
</main>
|
|
34
|
+
|
|
35
|
+
<template id="empty-table-template">
|
|
36
|
+
<div class="empty-state">No data right now.</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script src="./app.js" defer></script>
|
|
40
|
+
</body>
|
|
41
|
+
</html>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from functools import partial
|
|
8
|
+
from http import HTTPStatus
|
|
9
|
+
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from urllib.parse import urlparse
|
|
12
|
+
|
|
13
|
+
from dashboard_snapshot import build_snapshot
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
DASHBOARD_DIR = Path(__file__).resolve().parent
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DashboardHandler(SimpleHTTPRequestHandler):
|
|
20
|
+
server_version = "ACPDashboard/1.0"
|
|
21
|
+
|
|
22
|
+
def do_GET(self) -> None:
|
|
23
|
+
parsed = urlparse(self.path)
|
|
24
|
+
if parsed.path == "/api/snapshot.json":
|
|
25
|
+
payload = build_snapshot()
|
|
26
|
+
encoded = json.dumps(payload, indent=2).encode("utf-8")
|
|
27
|
+
self.send_response(HTTPStatus.OK)
|
|
28
|
+
self.send_header("Content-Type", "application/json; charset=utf-8")
|
|
29
|
+
self.send_header("Content-Length", str(len(encoded)))
|
|
30
|
+
self.send_header("Cache-Control", "no-store")
|
|
31
|
+
self.end_headers()
|
|
32
|
+
self.wfile.write(encoded)
|
|
33
|
+
return
|
|
34
|
+
return super().do_GET()
|
|
35
|
+
|
|
36
|
+
def end_headers(self) -> None:
|
|
37
|
+
if self.path != "/api/snapshot.json":
|
|
38
|
+
self.send_header("Cache-Control", "no-store")
|
|
39
|
+
super().end_headers()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def main(argv: list[str] | None = None) -> int:
|
|
43
|
+
parser = argparse.ArgumentParser(description="Serve the ACP worker dashboard.")
|
|
44
|
+
parser.add_argument("--host", default="127.0.0.1", help="Bind host. Default: 127.0.0.1")
|
|
45
|
+
parser.add_argument("--port", type=int, default=8765, help="Bind port. Default: 8765")
|
|
46
|
+
parser.add_argument(
|
|
47
|
+
"--registry-root",
|
|
48
|
+
default="",
|
|
49
|
+
help="Override ACP profile registry root for dashboard snapshot generation.",
|
|
50
|
+
)
|
|
51
|
+
args = parser.parse_args(argv)
|
|
52
|
+
|
|
53
|
+
if args.registry_root:
|
|
54
|
+
os.environ["ACP_PROFILE_REGISTRY_ROOT"] = args.registry_root
|
|
55
|
+
|
|
56
|
+
handler = partial(DashboardHandler, directory=str(DASHBOARD_DIR))
|
|
57
|
+
server = ThreadingHTTPServer((args.host, args.port), handler)
|
|
58
|
+
print(f"ACP_DASHBOARD_URL=http://{args.host}:{args.port}", flush=True)
|
|
59
|
+
server.serve_forever()
|
|
60
|
+
return 0
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
if __name__ == "__main__":
|
|
64
|
+
raise SystemExit(main())
|