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
package/SKILL.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-control-plane
|
|
3
|
+
description: Use when working on the shared multi-project agent control plane, including scheduler/runtime orchestration, worktree and worker lifecycle, profile onboarding, and cross-project automation flows.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent Control Plane
|
|
7
|
+
|
|
8
|
+
This repository is the canonical `agent-control-plane` package. It owns the
|
|
9
|
+
generic scheduler/runtime, worktree lifecycle, profile onboarding, queue/risk
|
|
10
|
+
automation, and profile-scoped prompt/template resolution used across multiple
|
|
11
|
+
projects.
|
|
12
|
+
|
|
13
|
+
Installed project profiles live under
|
|
14
|
+
`~/.agent-runtime/control-plane/profiles/<id>/`. Treat the control plane itself
|
|
15
|
+
as generic, then load the selected profile's local guidance only when the task
|
|
16
|
+
is truly about that project. Integrated project data should stay in that
|
|
17
|
+
external profile registry, not inside this repository.
|
|
18
|
+
|
|
19
|
+
## What Lives Here
|
|
20
|
+
|
|
21
|
+
- core operating manual in this `SKILL.md`
|
|
22
|
+
- installed project profiles in `~/.agent-runtime/control-plane/profiles/*/control-plane.yaml`
|
|
23
|
+
- installed profile notes in `~/.agent-runtime/control-plane/profiles/*/README.md`
|
|
24
|
+
- workflow catalog in `assets/workflow-catalog.json`
|
|
25
|
+
- worker dashboard in `tools/dashboard/` with launchers in `tools/bin/render-dashboard-snapshot.py`
|
|
26
|
+
and `tools/bin/serve-dashboard.sh`
|
|
27
|
+
- dashboard autostart helpers in `tools/bin/dashboard-launchd-bootstrap.sh` and
|
|
28
|
+
`tools/bin/install-dashboard-launchd.sh`
|
|
29
|
+
- project autostart helpers in `tools/bin/project-launchd-bootstrap.sh`,
|
|
30
|
+
`tools/bin/install-project-launchd.sh`, and
|
|
31
|
+
`tools/bin/uninstall-project-launchd.sh`
|
|
32
|
+
- queue/label/risk scripts in `bin/`
|
|
33
|
+
- heartbeat and reconcile hooks in `hooks/`
|
|
34
|
+
- shared runtime wrappers, onboarding tools, and tests in `tools/bin/` and
|
|
35
|
+
`tools/tests/`
|
|
36
|
+
|
|
37
|
+
The vendored runtime entrypoints used by live schedulers are published from this
|
|
38
|
+
checkout into the shared canonical skill copy under
|
|
39
|
+
`skills/openclaw/agent-control-plane`, then copied into
|
|
40
|
+
`~/.agent-runtime/runtime-home/skills/openclaw/agent-control-plane` by
|
|
41
|
+
`tools/bin/sync-shared-agent-home.sh`.
|
|
42
|
+
|
|
43
|
+
## Required Startup Sequence
|
|
44
|
+
|
|
45
|
+
Before doing non-trivial work in this repository or on an integrated project:
|
|
46
|
+
|
|
47
|
+
1. Determine the active profile with `AGENT_PROJECT_ID`, `ACP_PROJECT_ID`, or
|
|
48
|
+
`tools/bin/render-flow-config.sh`.
|
|
49
|
+
2. Read the selected profile notes in
|
|
50
|
+
`~/.agent-runtime/control-plane/profiles/<id>/README.md` when they exist.
|
|
51
|
+
3. Read the selected repo's local startup docs before changing behavior:
|
|
52
|
+
`AGENTS.md`, `openspec/AGENT_RULES.md`, `openspec/AGENTS.md`,
|
|
53
|
+
`openspec/project.md`, and `openspec/CONVENTIONS.md`.
|
|
54
|
+
4. Use a clean read-only inspection checkout first; move to an isolated
|
|
55
|
+
worktree or agent-owned checkout before making non-trivial edits.
|
|
56
|
+
5. If the task changes product behavior, inspect the active OpenSpec changes
|
|
57
|
+
before implementation.
|
|
58
|
+
|
|
59
|
+
For onboarding a new repository onto the shared control plane:
|
|
60
|
+
|
|
61
|
+
1. Prefer `tools/bin/project-init.sh --profile-id <id> --repo-slug <owner/repo>`
|
|
62
|
+
2. Fill in `~/.agent-runtime/control-plane/profiles/<id>/README.md`
|
|
63
|
+
3. If you need manual control, the underlying steps remain:
|
|
64
|
+
`tools/bin/scaffold-profile.sh`, `tools/bin/profile-smoke.sh`,
|
|
65
|
+
`tools/bin/profile-adopt.sh`, and `tools/bin/sync-shared-agent-home.sh`
|
|
66
|
+
|
|
67
|
+
For runtime control of one installed profile:
|
|
68
|
+
|
|
69
|
+
1. Check state with `tools/bin/project-runtimectl.sh status --profile-id <id>`
|
|
70
|
+
2. Start or ensure runtime with `tools/bin/project-runtimectl.sh start --profile-id <id>`
|
|
71
|
+
3. Stop or recycle runtime with `tools/bin/project-runtimectl.sh stop --profile-id <id>`
|
|
72
|
+
4. Use `tools/bin/project-runtimectl.sh restart --profile-id <id>` for a clean bounce
|
|
73
|
+
5. Use `tools/bin/install-project-launchd.sh --profile-id <id>` when one
|
|
74
|
+
profile should survive reboot/login via a per-project LaunchAgent
|
|
75
|
+
6. Remove per-project autostart with
|
|
76
|
+
`tools/bin/uninstall-project-launchd.sh --profile-id <id>`
|
|
77
|
+
7. Remove an installed profile with `tools/bin/project-remove.sh --profile-id <id>`
|
|
78
|
+
|
|
79
|
+
## Task Routing
|
|
80
|
+
|
|
81
|
+
Pick the smallest matching path and load only the relevant references:
|
|
82
|
+
|
|
83
|
+
- Control-plane layout, publication model, and profile ownership:
|
|
84
|
+
`references/control-plane-map.md`
|
|
85
|
+
- Control-plane operator commands and profile-management entrypoints:
|
|
86
|
+
`references/commands.md`
|
|
87
|
+
- Control-plane repository layout:
|
|
88
|
+
`references/repo-map.md`
|
|
89
|
+
- Control-plane docs and profile guidance locations:
|
|
90
|
+
`references/docs-map.md`
|
|
91
|
+
- Project-specific rules and repo commands:
|
|
92
|
+
`~/.agent-runtime/control-plane/profiles/<id>/README.md`
|
|
93
|
+
|
|
94
|
+
## Repo Rules That Matter Most
|
|
95
|
+
|
|
96
|
+
- Keep the core engine generic. Put repo-specific behavior behind a profile,
|
|
97
|
+
profile templates, or profile-scoped docs instead of hardcoding it into the
|
|
98
|
+
shared runtime.
|
|
99
|
+
- Follow OpenSpec and the selected repo's local rules before implementing
|
|
100
|
+
product behavior changes.
|
|
101
|
+
- Do not simplify or change approach without explicit user approval.
|
|
102
|
+
- Prefer deterministic wrappers and config-driven routing over special-case
|
|
103
|
+
conditionals.
|
|
104
|
+
- For any non-trivial write task, use a dedicated agent worktree or another
|
|
105
|
+
isolated clean checkout.
|
|
106
|
+
- Preserve dirty retained checkouts; continue from a fresh isolated worktree
|
|
107
|
+
instead of layering more edits there.
|
|
108
|
+
- Prefer canonical docs and profile-local notes over stale audits or incidental
|
|
109
|
+
markdown snapshots.
|
|
110
|
+
- When updating the control plane itself, repair published copies after the
|
|
111
|
+
source change so runtime and source do not drift.
|
|
112
|
+
|
|
113
|
+
## Common Operating Patterns
|
|
114
|
+
|
|
115
|
+
### Analysis and Planning
|
|
116
|
+
|
|
117
|
+
- Resolve the active profile first.
|
|
118
|
+
- Read `~/.agent-runtime/control-plane/profiles/<id>/README.md` for repo-local context.
|
|
119
|
+
- Use `references/docs-map.md` to find the canonical control-plane or
|
|
120
|
+
profile-local source instead of scanning random files.
|
|
121
|
+
|
|
122
|
+
### Implementation
|
|
123
|
+
|
|
124
|
+
- Keep generic scheduler/runtime changes in the shared engine.
|
|
125
|
+
- Put repo-specific prompts, commands, or heuristics in the installed profile
|
|
126
|
+
directory under `~/.agent-runtime/control-plane/profiles/<id>/`.
|
|
127
|
+
- Keep changes reversible and tightly scoped.
|
|
128
|
+
|
|
129
|
+
### Testing
|
|
130
|
+
|
|
131
|
+
- Use `references/commands.md` for control-plane checks.
|
|
132
|
+
- Use the selected profile's README for repo-specific dev/test commands.
|
|
133
|
+
- Re-run `tools/bin/profile-smoke.sh`, `tools/bin/check-skill-contracts.sh`,
|
|
134
|
+
dashboard tests, and targeted shell tests after meaningful control-plane
|
|
135
|
+
changes.
|
|
136
|
+
|
|
137
|
+
### Publishing and Runtime Health
|
|
138
|
+
|
|
139
|
+
- Use `tools/bin/flow-runtime-doctor.sh` to confirm source/runtime sync.
|
|
140
|
+
- Use `tools/bin/sync-shared-agent-home.sh` after changing runtime-facing files.
|
|
141
|
+
- Prefer copied published artifacts over symlink aliases.
|
|
142
|
+
|
|
143
|
+
## References
|
|
144
|
+
|
|
145
|
+
- `references/control-plane-map.md`
|
|
146
|
+
- `references/commands.md`
|
|
147
|
+
- `references/repo-map.md`
|
|
148
|
+
- `references/docs-map.md`
|
|
149
|
+
- `~/.agent-runtime/control-plane/profiles/<id>/README.md`
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"control_plane": "agent-control-plane",
|
|
4
|
+
"default_profile": null,
|
|
5
|
+
"profile_selection": "explicit",
|
|
6
|
+
"workflows": [
|
|
7
|
+
{
|
|
8
|
+
"id": "issue-implementation",
|
|
9
|
+
"kind": "issue",
|
|
10
|
+
"trigger": "Open issue with agent-ready and without agent-running/agent-blocked",
|
|
11
|
+
"entrypoint": "tools/bin/start-issue-worker.sh",
|
|
12
|
+
"summary": "Primary implementation loop for focused issues that should end in a PR or a blocked report."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "issue-blocked-recovery",
|
|
16
|
+
"kind": "issue",
|
|
17
|
+
"trigger": "Open issue with agent-blocked plus retry-state reason after cooldown",
|
|
18
|
+
"entrypoint": "tools/bin/start-issue-worker.sh",
|
|
19
|
+
"summary": "Retries previously blocked issue sessions in a controlled lane without mixing them with fresh intake."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "issue-scheduled-check",
|
|
23
|
+
"kind": "issue",
|
|
24
|
+
"trigger": "Issue body contains Agent schedule/ Schedule/ Cadence metadata",
|
|
25
|
+
"entrypoint": "tools/bin/start-issue-worker.sh",
|
|
26
|
+
"summary": "Runs recurring health, checks, or smoke-style verification and updates status labels instead of shipping product changes."
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "pr-review",
|
|
30
|
+
"kind": "pull_request",
|
|
31
|
+
"trigger": "Agent-managed PR becomes eligible for double-check, human-review, or automerge decisioning",
|
|
32
|
+
"entrypoint": "tools/bin/start-pr-review-worker.sh",
|
|
33
|
+
"summary": "Evaluates final-review state and advances merge, double-check, or human-review lanes."
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "pr-fix",
|
|
37
|
+
"kind": "pull_request",
|
|
38
|
+
"trigger": "Agent-managed PR has actionable review feedback, host blocker, broad scope, or failing branch-local checks",
|
|
39
|
+
"entrypoint": "tools/bin/start-pr-fix-worker.sh",
|
|
40
|
+
"summary": "Launches a repair pass for PRs that still need code changes on the current head."
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "pr-merge-repair",
|
|
44
|
+
"kind": "pull_request",
|
|
45
|
+
"trigger": "Agent-managed PR has mergeStateStatus DIRTY",
|
|
46
|
+
"entrypoint": "tools/bin/start-pr-merge-repair-worker.sh",
|
|
47
|
+
"summary": "Handles merge-only repair when the PR needs branch reconciliation rather than a normal review fix."
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "follow-up-splitting",
|
|
51
|
+
"kind": "issue",
|
|
52
|
+
"trigger": "Issue implementation determines scope should be split into narrower follow-up issues",
|
|
53
|
+
"entrypoint": "tools/bin/create-follow-up-issue.sh",
|
|
54
|
+
"summary": "Creates focused follow-up issues and optionally closes the umbrella issue as superseded."
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
# shellcheck source=/dev/null
|
|
6
|
+
source "${SCRIPT_DIR}/../tools/bin/flow-config-lib.sh"
|
|
7
|
+
|
|
8
|
+
CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
|
|
9
|
+
REPO_SLUG="$(flow_resolve_repo_slug "${CONFIG_YAML}")"
|
|
10
|
+
AGENT_PR_PREFIXES_JSON="$(flow_managed_pr_prefixes_json "${CONFIG_YAML}")"
|
|
11
|
+
AGENT_PR_ISSUE_CAPTURE_REGEX="$(flow_managed_issue_branch_regex "${CONFIG_YAML}")"
|
|
12
|
+
MIN_AGE_MINUTES="${1:-30}"
|
|
13
|
+
|
|
14
|
+
open_agent_pr_issue_ids="$(
|
|
15
|
+
gh pr list -R "$REPO_SLUG" --state open --limit 100 --json headRefName,body,labels,comments \
|
|
16
|
+
| jq --argjson agentPrPrefixes "${AGENT_PR_PREFIXES_JSON}" --arg branchIssueRegex "${AGENT_PR_ISSUE_CAPTURE_REGEX}" '
|
|
17
|
+
map(
|
|
18
|
+
. as $pr
|
|
19
|
+
| select(
|
|
20
|
+
any($agentPrPrefixes[]; (($pr.headRefName // "") | startswith(.)))
|
|
21
|
+
or any(($pr.labels // [])[]?; .name == "agent-handoff")
|
|
22
|
+
or any(($pr.comments // [])[]?; ((.body // "") | test("^## PR (final review blocker|repair worker summary|repair summary|repair update)"; "i")))
|
|
23
|
+
)
|
|
24
|
+
| [
|
|
25
|
+
(
|
|
26
|
+
$pr.headRefName
|
|
27
|
+
| capture($branchIssueRegex)?
|
|
28
|
+
| .id
|
|
29
|
+
),
|
|
30
|
+
(
|
|
31
|
+
($pr.body // "")
|
|
32
|
+
| capture("(?i)\\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\\s+#(?<id>[0-9]+)\\b")?
|
|
33
|
+
| .id
|
|
34
|
+
)
|
|
35
|
+
]
|
|
36
|
+
| .[]
|
|
37
|
+
| select(. != null and . != "")
|
|
38
|
+
)
|
|
39
|
+
| unique
|
|
40
|
+
'
|
|
41
|
+
)"
|
|
42
|
+
|
|
43
|
+
gh issue list -R "$REPO_SLUG" --state open --limit 100 --json number,title,createdAt,updatedAt,labels \
|
|
44
|
+
| jq -r --argjson openAgentPrIssueIds "$open_agent_pr_issue_ids" --argjson minAgeMinutes "$MIN_AGE_MINUTES" '
|
|
45
|
+
def label_names: [.labels[]?.name];
|
|
46
|
+
def age_minutes:
|
|
47
|
+
((now - ((.createdAt | sub("\\.[0-9]+Z$"; "Z") | fromdateiso8601))) / 60);
|
|
48
|
+
def has_open_agent_pr:
|
|
49
|
+
((.number | tostring) as $issueId | ($openAgentPrIssueIds | index($issueId)) != null);
|
|
50
|
+
map(
|
|
51
|
+
. + {
|
|
52
|
+
reason:
|
|
53
|
+
(if any(label_names[]?; . == "agent-running") and (has_open_agent_pr | not) then
|
|
54
|
+
"stale-agent-running"
|
|
55
|
+
elif any(label_names[]?; . == "agent-blocked") then
|
|
56
|
+
"blocked-manual-review"
|
|
57
|
+
else
|
|
58
|
+
""
|
|
59
|
+
end)
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
| map(select(.reason != "" and (age_minutes >= $minAgeMinutes)))
|
|
63
|
+
| sort_by(.createdAt, .number)
|
|
64
|
+
| .[]
|
|
65
|
+
| [
|
|
66
|
+
(.number | tostring),
|
|
67
|
+
.reason,
|
|
68
|
+
.createdAt,
|
|
69
|
+
.updatedAt,
|
|
70
|
+
(label_names | join(",")),
|
|
71
|
+
.title
|
|
72
|
+
]
|
|
73
|
+
| @tsv
|
|
74
|
+
'
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
# shellcheck source=/dev/null
|
|
6
|
+
source "${SCRIPT_DIR}/../tools/bin/flow-config-lib.sh"
|
|
7
|
+
|
|
8
|
+
ISSUE_ID="${1:?usage: issue-resource-class.sh ISSUE_ID}"
|
|
9
|
+
CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
|
|
10
|
+
REPO_SLUG="$(flow_resolve_repo_slug "${CONFIG_YAML}")"
|
|
11
|
+
|
|
12
|
+
ISSUE_JSON="$(gh issue view "$ISSUE_ID" -R "$REPO_SLUG" --json number,title,body,labels)"
|
|
13
|
+
|
|
14
|
+
CLASS_OUT="$(
|
|
15
|
+
ISSUE_JSON="$ISSUE_JSON" python3 <<'PY'
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import re
|
|
19
|
+
|
|
20
|
+
issue = json.loads(os.environ["ISSUE_JSON"])
|
|
21
|
+
labels = {str(label.get("name", "")).strip().lower() for label in issue.get("labels", [])}
|
|
22
|
+
title = str(issue.get("title", "") or "")
|
|
23
|
+
body = str(issue.get("body", "") or "")
|
|
24
|
+
|
|
25
|
+
explicit_e2e_labels = {
|
|
26
|
+
"agent-e2e-heavy",
|
|
27
|
+
"e2e",
|
|
28
|
+
"playwright",
|
|
29
|
+
"detox",
|
|
30
|
+
"maestro",
|
|
31
|
+
}
|
|
32
|
+
title_pattern = re.compile(
|
|
33
|
+
r"(^|[^a-z0-9])(e2e|end-to-end|end to end|playwright|detox|maestro)([^a-z0-9]|$)",
|
|
34
|
+
re.IGNORECASE,
|
|
35
|
+
)
|
|
36
|
+
body_pattern = re.compile(
|
|
37
|
+
r"(^|[^a-z0-9])("
|
|
38
|
+
r"playwright|detox|maestro|"
|
|
39
|
+
r"e2e([ -]+(test|tests|smoke|suite|run|runs|flaky|flake|spec))|"
|
|
40
|
+
r"end-to-end([ -]+(test|tests|smoke|suite|run|runs|flaky|flake|spec))"
|
|
41
|
+
r")([^a-z0-9]|$)",
|
|
42
|
+
re.IGNORECASE,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
is_e2e = (
|
|
46
|
+
bool(labels.intersection(explicit_e2e_labels))
|
|
47
|
+
or bool(title_pattern.search(title))
|
|
48
|
+
or bool(body_pattern.search(body))
|
|
49
|
+
)
|
|
50
|
+
issue_class = "e2e-heavy" if is_e2e else "standard"
|
|
51
|
+
|
|
52
|
+
print(f"CLASS={issue_class}")
|
|
53
|
+
print(f"IS_E2E={'yes' if is_e2e else 'no'}")
|
|
54
|
+
PY
|
|
55
|
+
)"
|
|
56
|
+
|
|
57
|
+
printf 'ISSUE_ID=%s\n' "$ISSUE_ID"
|
|
58
|
+
printf '%s\n' "$CLASS_OUT"
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SESSION="${1:?usage: label-follow-up-issues.sh SESSION}"
|
|
5
|
+
ADAPTER_BIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
FLOW_SKILL_DIR="$(cd "${ADAPTER_BIN_DIR}/.." && pwd)"
|
|
7
|
+
FLOW_TOOLS_DIR="${FLOW_SKILL_DIR}/tools/bin"
|
|
8
|
+
# shellcheck source=/dev/null
|
|
9
|
+
source "${FLOW_TOOLS_DIR}/flow-config-lib.sh"
|
|
10
|
+
CONFIG_YAML="$(resolve_flow_config_yaml "${BASH_SOURCE[0]}")"
|
|
11
|
+
flow_export_execution_env "${CONFIG_YAML}"
|
|
12
|
+
flow_export_project_env_aliases
|
|
13
|
+
REPO_SLUG="$(flow_resolve_repo_slug "${CONFIG_YAML}")"
|
|
14
|
+
AGENT_ROOT="$(flow_resolve_agent_root "${CONFIG_YAML}")"
|
|
15
|
+
RUNS_ROOT="$(flow_resolve_runs_root "${CONFIG_YAML}")"
|
|
16
|
+
HISTORY_ROOT="$(flow_resolve_history_root "${CONFIG_YAML}")"
|
|
17
|
+
|
|
18
|
+
find_archived_session_dir() {
|
|
19
|
+
local root="${1:-}"
|
|
20
|
+
local target_session="${2:-}"
|
|
21
|
+
[[ -n "$root" && -d "$root" && -n "$target_session" ]] || return 1
|
|
22
|
+
|
|
23
|
+
find "$root" -mindepth 1 -maxdepth 1 -type d -name "${target_session}-*" ! -name "${target_session}-stale-*" 2>/dev/null \
|
|
24
|
+
| sort -r \
|
|
25
|
+
| head -n 1
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
status_out="$(
|
|
29
|
+
bash "${FLOW_TOOLS_DIR}/agent-project-worker-status" \
|
|
30
|
+
--runs-root "$RUNS_ROOT" \
|
|
31
|
+
--session "$SESSION"
|
|
32
|
+
)"
|
|
33
|
+
meta_file="$(awk -F= '/^META_FILE=/{print $2}' <<<"$status_out")"
|
|
34
|
+
if [[ -z "$meta_file" || ! -f "$meta_file" ]]; then
|
|
35
|
+
archived_run_dir="$(find_archived_session_dir "$HISTORY_ROOT" "$SESSION" || true)"
|
|
36
|
+
if [[ -n "$archived_run_dir" && -f "${archived_run_dir}/run.env" ]]; then
|
|
37
|
+
meta_file="${archived_run_dir}/run.env"
|
|
38
|
+
fi
|
|
39
|
+
fi
|
|
40
|
+
if [[ -z "$meta_file" || ! -f "$meta_file" ]]; then
|
|
41
|
+
echo "missing metadata for session $SESSION" >&2
|
|
42
|
+
exit 1
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
set -a
|
|
46
|
+
# shellcheck source=/dev/null
|
|
47
|
+
source "$meta_file"
|
|
48
|
+
set +a
|
|
49
|
+
|
|
50
|
+
if [[ -z "${ISSUE_ID:-}" ]]; then
|
|
51
|
+
echo "session $SESSION is missing ISSUE_ID" >&2
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
if [[ -z "${STARTED_AT:-}" ]]; then
|
|
55
|
+
echo "session $SESSION is missing STARTED_AT" >&2
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
actor_login="${GITHUB_ACTOR:-$(gh api user --jq .login)}"
|
|
60
|
+
|
|
61
|
+
issue_numbers=()
|
|
62
|
+
while IFS= read -r number; do
|
|
63
|
+
[[ -n "$number" ]] || continue
|
|
64
|
+
issue_numbers+=("$number")
|
|
65
|
+
done < <(
|
|
66
|
+
flow_github_api_repo "${REPO_SLUG}" "issues/${ISSUE_ID}/comments?per_page=100" --paginate --slurp 2>/dev/null \
|
|
67
|
+
| jq -r --arg actor "$actor_login" --arg started "$STARTED_AT" '
|
|
68
|
+
.[]?
|
|
69
|
+
| if type == "array" then .[] else . end
|
|
70
|
+
| select(.user.login == $actor)
|
|
71
|
+
| select(.created_at >= $started)
|
|
72
|
+
| .body // ""
|
|
73
|
+
' \
|
|
74
|
+
| rg -o '#[0-9]+' \
|
|
75
|
+
| tr -d '#' \
|
|
76
|
+
| sort -n \
|
|
77
|
+
| uniq
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
count=0
|
|
81
|
+
if [[ ${#issue_numbers[@]} -eq 0 ]]; then
|
|
82
|
+
printf 'COUNT=%s\n' "$count"
|
|
83
|
+
exit 0
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
for number in "${issue_numbers[@]}"; do
|
|
87
|
+
[[ "$number" == "$ISSUE_ID" ]] && continue
|
|
88
|
+
|
|
89
|
+
issue_json="$(flow_github_issue_view_json "${REPO_SLUG}" "${number}" 2>/dev/null || true)"
|
|
90
|
+
[[ -z "$issue_json" ]] && continue
|
|
91
|
+
|
|
92
|
+
if jq -e 'has("pull_request")' >/dev/null <<<"$issue_json"; then
|
|
93
|
+
continue
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
state="$(jq -r '.state // "" | ascii_downcase' <<<"$issue_json")"
|
|
97
|
+
[[ "$state" == "open" ]] || continue
|
|
98
|
+
|
|
99
|
+
if jq -e 'any(.labels[]?; .name == "agent-running" or .name == "agent-blocked")' >/dev/null <<<"$issue_json"; then
|
|
100
|
+
continue
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
class_out="$("${ADAPTER_BIN_DIR}/issue-resource-class.sh" "$number")"
|
|
104
|
+
is_e2e="$(awk -F= '/^IS_E2E=/{print $2}' <<<"$class_out")"
|
|
105
|
+
|
|
106
|
+
if [[ "$is_e2e" == "yes" ]]; then
|
|
107
|
+
bash "${FLOW_TOOLS_DIR}/agent-github-update-labels" --repo-slug "$REPO_SLUG" --number "$number" --add agent-e2e-heavy >/dev/null
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
printf 'LABELED=%s\n' "$number"
|
|
111
|
+
count=$((count + 1))
|
|
112
|
+
done
|
|
113
|
+
|
|
114
|
+
printf 'COUNT=%s\n' "$count"
|