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,275 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
FLOW_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
5
|
+
SOURCE_SCRIPT="${FLOW_ROOT}/tools/bin/start-pr-fix-worker.sh"
|
|
6
|
+
SOURCE_TEMPLATE="${FLOW_ROOT}/tools/templates/pr-fix-template.md"
|
|
7
|
+
SOURCE_CONFIG_LIB="${FLOW_ROOT}/tools/bin/flow-config-lib.sh"
|
|
8
|
+
SOURCE_SHELL_LIB="${FLOW_ROOT}/tools/bin/flow-shell-lib.sh"
|
|
9
|
+
|
|
10
|
+
tmpdir="$(mktemp -d)"
|
|
11
|
+
trap 'rm -rf "$tmpdir"' EXIT
|
|
12
|
+
|
|
13
|
+
workspace_root="$tmpdir/workspace/tools"
|
|
14
|
+
bin_dir="$workspace_root/bin"
|
|
15
|
+
template_dir="$workspace_root/templates"
|
|
16
|
+
assets_dir="$workspace_root/assets"
|
|
17
|
+
profile_registry_root="$tmpdir/profile-registry"
|
|
18
|
+
profile_dir="$profile_registry_root/alpha"
|
|
19
|
+
shim_bin_dir="$tmpdir/shims"
|
|
20
|
+
agent_root="$tmpdir/agent-root"
|
|
21
|
+
history_root="$agent_root/history"
|
|
22
|
+
runs_root="$agent_root/runs"
|
|
23
|
+
repo_root="$tmpdir/repo-root"
|
|
24
|
+
worktree_root="$tmpdir/worktree"
|
|
25
|
+
origin_repo="$tmpdir/origin.git"
|
|
26
|
+
node_bin_dir="$(dirname "$(command -v node)")"
|
|
27
|
+
|
|
28
|
+
mkdir -p "$bin_dir" "$template_dir" "$assets_dir" "$profile_dir" "$shim_bin_dir" "$history_root" "$runs_root" "$repo_root" "$worktree_root"
|
|
29
|
+
|
|
30
|
+
cp "$SOURCE_SCRIPT" "$bin_dir/start-pr-fix-worker.sh"
|
|
31
|
+
cp "$SOURCE_CONFIG_LIB" "$bin_dir/flow-config-lib.sh"
|
|
32
|
+
cp "$SOURCE_SHELL_LIB" "$bin_dir/flow-shell-lib.sh"
|
|
33
|
+
cp "$SOURCE_TEMPLATE" "$template_dir/pr-fix-template.md"
|
|
34
|
+
printf '{}\n' >"$assets_dir/workflow-catalog.json"
|
|
35
|
+
|
|
36
|
+
cat >"$profile_dir/control-plane.yaml" <<EOF
|
|
37
|
+
schema_version: "1"
|
|
38
|
+
id: "alpha"
|
|
39
|
+
repo:
|
|
40
|
+
slug: "example/repo"
|
|
41
|
+
root: "$repo_root"
|
|
42
|
+
default_branch: "main"
|
|
43
|
+
runtime:
|
|
44
|
+
orchestrator_agent_root: "$agent_root"
|
|
45
|
+
worktree_root: "$worktree_root"
|
|
46
|
+
agent_repo_root: "$repo_root"
|
|
47
|
+
runs_root: "$runs_root"
|
|
48
|
+
state_root: "$agent_root/state"
|
|
49
|
+
retained_repo_root: "$repo_root"
|
|
50
|
+
vscode_workspace_file: "$tmpdir/alpha.code-workspace"
|
|
51
|
+
session_naming:
|
|
52
|
+
issue_prefix: "fl-issue-"
|
|
53
|
+
pr_prefix: "fl-pr-"
|
|
54
|
+
issue_branch_prefix: "agent/alpha/issue"
|
|
55
|
+
pr_worktree_branch_prefix: "agent/alpha/pr"
|
|
56
|
+
managed_pr_branch_globs: "agent/alpha/* codex/* openclaw/*"
|
|
57
|
+
execution:
|
|
58
|
+
coding_worker: "codex"
|
|
59
|
+
safe_profile: "mock-safe"
|
|
60
|
+
bypass_profile: "mock-bypass"
|
|
61
|
+
openclaw:
|
|
62
|
+
model: "openrouter/stepfun/step-3.5-flash:free"
|
|
63
|
+
thinking: "minimal"
|
|
64
|
+
timeout_seconds: 600
|
|
65
|
+
verification:
|
|
66
|
+
web_playwright_command: "pnpm exec playwright test"
|
|
67
|
+
review_requires_independent_final_review: true
|
|
68
|
+
EOF
|
|
69
|
+
|
|
70
|
+
cat >"$bin_dir/new-pr-worktree.sh" <<EOF
|
|
71
|
+
#!/usr/bin/env bash
|
|
72
|
+
set -euo pipefail
|
|
73
|
+
printf 'WORKTREE=%s\n' "$worktree_root"
|
|
74
|
+
EOF
|
|
75
|
+
|
|
76
|
+
cat >"$bin_dir/run-codex-safe.sh" <<'EOF'
|
|
77
|
+
#!/usr/bin/env bash
|
|
78
|
+
set -euo pipefail
|
|
79
|
+
printf 'RUNNER=stub\n'
|
|
80
|
+
EOF
|
|
81
|
+
|
|
82
|
+
cat >"$bin_dir/run-codex-bypass.sh" <<'EOF'
|
|
83
|
+
#!/usr/bin/env bash
|
|
84
|
+
set -euo pipefail
|
|
85
|
+
printf 'RUNNER=stub\n'
|
|
86
|
+
EOF
|
|
87
|
+
|
|
88
|
+
cat >"$bin_dir/pr-risk.sh" <<'EOF'
|
|
89
|
+
#!/usr/bin/env bash
|
|
90
|
+
set -euo pipefail
|
|
91
|
+
cat <<'JSON'
|
|
92
|
+
{"risk":"high","riskReason":"paths-outside-low-risk-allowlist:apps/api/src/modules/auth/auth.service.ts","linkedIssueId":415,"files":["apps/api/src/modules/auth/auth.service.extended.spec.ts","apps/api/src/modules/auth/auth.service.ts","apps/web/e2e/archive/auth/tenant-isolation-login.spec.ts","apps/web/src/app/(auth)/login/page.spec.tsx","apps/web/src/app/(auth)/login/page.tsx"],"checkFailures":[],"pendingChecks":[],"missingReasons":["agent-status-blocker-present"]}
|
|
93
|
+
JSON
|
|
94
|
+
EOF
|
|
95
|
+
|
|
96
|
+
cat >"$bin_dir/agent-github-update-labels" <<'EOF'
|
|
97
|
+
#!/usr/bin/env bash
|
|
98
|
+
set -euo pipefail
|
|
99
|
+
exit 0
|
|
100
|
+
EOF
|
|
101
|
+
|
|
102
|
+
cat >"$shim_bin_dir/gh" <<'EOF'
|
|
103
|
+
#!/usr/bin/env bash
|
|
104
|
+
set -euo pipefail
|
|
105
|
+
|
|
106
|
+
if [[ "${1:-}" == "pr" && "${2:-}" == "view" ]]; then
|
|
107
|
+
cat <<'JSON'
|
|
108
|
+
{"number":601,"title":"fix(auth): carry host verification blocker into prompt","body":"Closes #415","url":"https://example.test/pr/601","headRefName":"agent/alpha/issue-415-host-blocker-context","baseRefName":"main","mergeStateStatus":"CLEAN","statusCheckRollup":[],"labels":[{"name":"agent-repair-queued"}],"comments":[]}
|
|
109
|
+
JSON
|
|
110
|
+
exit 0
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
if [[ "${1:-}" == "api" ]]; then
|
|
114
|
+
case "${2:-}" in
|
|
115
|
+
repos/example/repo/pulls/601)
|
|
116
|
+
cat <<'JSON'
|
|
117
|
+
{"head":{"sha":"sha601"},"mergeable":true}
|
|
118
|
+
JSON
|
|
119
|
+
exit 0
|
|
120
|
+
;;
|
|
121
|
+
repos/example/repo/pulls/601/comments)
|
|
122
|
+
printf '[]\n'
|
|
123
|
+
exit 0
|
|
124
|
+
;;
|
|
125
|
+
repos/example/repo/issues/601/comments)
|
|
126
|
+
printf '[]\n'
|
|
127
|
+
exit 0
|
|
128
|
+
;;
|
|
129
|
+
esac
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
echo "unexpected gh args: $*" >&2
|
|
133
|
+
exit 1
|
|
134
|
+
EOF
|
|
135
|
+
|
|
136
|
+
cat >"$shim_bin_dir/tmux" <<'EOF'
|
|
137
|
+
#!/usr/bin/env bash
|
|
138
|
+
set -euo pipefail
|
|
139
|
+
if [[ "${1:-}" == "has-session" ]]; then
|
|
140
|
+
exit 1
|
|
141
|
+
fi
|
|
142
|
+
exit 0
|
|
143
|
+
EOF
|
|
144
|
+
|
|
145
|
+
chmod +x \
|
|
146
|
+
"$bin_dir/start-pr-fix-worker.sh" \
|
|
147
|
+
"$bin_dir/flow-config-lib.sh" \
|
|
148
|
+
"$bin_dir/flow-shell-lib.sh" \
|
|
149
|
+
"$bin_dir/new-pr-worktree.sh" \
|
|
150
|
+
"$bin_dir/run-codex-safe.sh" \
|
|
151
|
+
"$bin_dir/run-codex-bypass.sh" \
|
|
152
|
+
"$bin_dir/pr-risk.sh" \
|
|
153
|
+
"$bin_dir/agent-github-update-labels" \
|
|
154
|
+
"$shim_bin_dir/gh" \
|
|
155
|
+
"$shim_bin_dir/tmux"
|
|
156
|
+
|
|
157
|
+
git init --bare "$origin_repo" >/dev/null 2>&1
|
|
158
|
+
git clone "$origin_repo" "$worktree_root" >/dev/null 2>&1
|
|
159
|
+
|
|
160
|
+
mkdir -p \
|
|
161
|
+
"$worktree_root/apps/api/src/modules/auth" \
|
|
162
|
+
"$worktree_root/apps/web/e2e/archive/auth" \
|
|
163
|
+
"$worktree_root/apps/web/src/app/(auth)/login"
|
|
164
|
+
|
|
165
|
+
cat >"$worktree_root/apps/api/src/modules/auth/auth.service.ts" <<'EOF'
|
|
166
|
+
export const loginFailureMode = 'legacy';
|
|
167
|
+
EOF
|
|
168
|
+
|
|
169
|
+
cat >"$worktree_root/apps/api/src/modules/auth/auth.service.extended.spec.ts" <<'EOF'
|
|
170
|
+
describe('auth service', () => {
|
|
171
|
+
it('handles login failures', () => {
|
|
172
|
+
expect(true).toBe(true)
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
EOF
|
|
176
|
+
|
|
177
|
+
cat >"$worktree_root/apps/web/src/app/(auth)/login/page.tsx" <<'EOF'
|
|
178
|
+
export default function LoginPage() {
|
|
179
|
+
return null
|
|
180
|
+
}
|
|
181
|
+
EOF
|
|
182
|
+
|
|
183
|
+
cat >"$worktree_root/apps/web/src/app/(auth)/login/page.spec.tsx" <<'EOF'
|
|
184
|
+
describe('login page', () => {
|
|
185
|
+
it('renders', () => {
|
|
186
|
+
expect(true).toBe(true)
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
EOF
|
|
190
|
+
|
|
191
|
+
cat >"$worktree_root/apps/web/e2e/archive/auth/tenant-isolation-login.spec.ts" <<'EOF'
|
|
192
|
+
test('tenant isolation login', async () => {
|
|
193
|
+
expect(true).toBeTruthy()
|
|
194
|
+
})
|
|
195
|
+
EOF
|
|
196
|
+
|
|
197
|
+
git -C "$worktree_root" add .
|
|
198
|
+
git -C "$worktree_root" -c user.name=Test -c user.email=test@example.com commit -m "init" >/dev/null
|
|
199
|
+
git -C "$worktree_root" branch -M main >/dev/null 2>&1
|
|
200
|
+
git -C "$worktree_root" push origin main >/dev/null 2>&1
|
|
201
|
+
git -C "$worktree_root" checkout -b agent/alpha/issue-415-host-blocker-context >/dev/null 2>&1
|
|
202
|
+
|
|
203
|
+
cat >"$worktree_root/apps/api/src/modules/auth/auth.service.ts" <<'EOF'
|
|
204
|
+
export const loginFailureMode = 'generic-invalid-credentials';
|
|
205
|
+
EOF
|
|
206
|
+
|
|
207
|
+
cat >"$worktree_root/apps/api/src/modules/auth/auth.service.extended.spec.ts" <<'EOF'
|
|
208
|
+
describe('auth service', () => {
|
|
209
|
+
it('normalizes tenant login failures', () => {
|
|
210
|
+
expect(true).toBe(true)
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
EOF
|
|
214
|
+
|
|
215
|
+
cat >"$worktree_root/apps/web/src/app/(auth)/login/page.tsx" <<'EOF'
|
|
216
|
+
export default function LoginPage() {
|
|
217
|
+
return 'Invalid credentials'
|
|
218
|
+
}
|
|
219
|
+
EOF
|
|
220
|
+
|
|
221
|
+
cat >"$worktree_root/apps/web/src/app/(auth)/login/page.spec.tsx" <<'EOF'
|
|
222
|
+
describe('login page', () => {
|
|
223
|
+
it('shows the generic invalid credentials message', () => {
|
|
224
|
+
expect(true).toBe(true)
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
EOF
|
|
228
|
+
|
|
229
|
+
cat >"$worktree_root/apps/web/e2e/archive/auth/tenant-isolation-login.spec.ts" <<'EOF'
|
|
230
|
+
test('tenant isolation login hides tenant existence', async () => {
|
|
231
|
+
expect(true).toBeTruthy()
|
|
232
|
+
})
|
|
233
|
+
EOF
|
|
234
|
+
|
|
235
|
+
git -C "$worktree_root" add .
|
|
236
|
+
git -C "$worktree_root" -c user.name=Test -c user.email=test@example.com commit -m "pr changes" >/dev/null
|
|
237
|
+
|
|
238
|
+
mkdir -p "$history_root/fl-pr-601-20260316-000001"
|
|
239
|
+
cat >"$history_root/fl-pr-601-20260316-000001/host-blocker.md" <<'EOF'
|
|
240
|
+
Verification guard blocked branch publication.
|
|
241
|
+
|
|
242
|
+
Why it was blocked:
|
|
243
|
+
- missing API typecheck or repo typecheck for API changes
|
|
244
|
+
- missing Web verification command for web changes
|
|
245
|
+
EOF
|
|
246
|
+
|
|
247
|
+
worker_output="$(
|
|
248
|
+
PATH="$shim_bin_dir:$node_bin_dir:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin" \
|
|
249
|
+
ACP_PROFILE_REGISTRY_ROOT="$profile_registry_root" \
|
|
250
|
+
ACP_PROJECT_ID="alpha" \
|
|
251
|
+
ACP_PR_SESSION_PREFIX="fl-pr-" \
|
|
252
|
+
F_LOSNING_PR_SESSION_PREFIX="fl-pr-" \
|
|
253
|
+
F_LOSNING_AGENT_ROOT="$agent_root" \
|
|
254
|
+
F_LOSNING_REPO_SLUG="example/repo" \
|
|
255
|
+
F_LOSNING_REPO_ROOT="$repo_root" \
|
|
256
|
+
F_LOSNING_DEPENDENCY_SOURCE_ROOT="$repo_root" \
|
|
257
|
+
bash "$bin_dir/start-pr-fix-worker.sh" 601 safe fix
|
|
258
|
+
)"
|
|
259
|
+
|
|
260
|
+
prompt_file="$(awk -F= '/^PROMPT=/{print $2}' <<<"$worker_output")"
|
|
261
|
+
test -n "$prompt_file"
|
|
262
|
+
test -f "$prompt_file"
|
|
263
|
+
|
|
264
|
+
grep -Fq 'Current host-side publish blocker summary:' "$prompt_file"
|
|
265
|
+
grep -Fq 'Verification guard blocked branch publication.' "$prompt_file"
|
|
266
|
+
grep -Fq 'missing API typecheck or repo typecheck for API changes' "$prompt_file"
|
|
267
|
+
grep -Fq 'Required targeted verification coverage before `updated-branch`:' "$prompt_file"
|
|
268
|
+
grep -Fq 'apps/api/src/modules/auth/auth.service.extended.spec.ts' "$prompt_file"
|
|
269
|
+
grep -Fq 'apps/web/e2e/archive/auth/tenant-isolation-login.spec.ts' "$prompt_file"
|
|
270
|
+
grep -Fq 'Pre-approved local verification fallbacks:' "$prompt_file"
|
|
271
|
+
grep -Fq 'loopback retry command:' "$prompt_file"
|
|
272
|
+
grep -Fq 'playwright test e2e/archive/auth/tenant-isolation-login.spec.ts --project=chromium' "$prompt_file"
|
|
273
|
+
grep -Fq 'Do not ask the user for clarification, approval, or a next-step choice from inside the worker.' "$prompt_file"
|
|
274
|
+
|
|
275
|
+
echo "start-pr-fix-worker host blocker context test passed"
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
FLOW_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
5
|
+
REAL_LOOP="${FLOW_ROOT}/tools/bin/start-resident-issue-loop.sh"
|
|
6
|
+
REAL_CONFIG_LIB="${FLOW_ROOT}/tools/bin/flow-config-lib.sh"
|
|
7
|
+
REAL_SHELL_LIB="${FLOW_ROOT}/tools/bin/flow-shell-lib.sh"
|
|
8
|
+
REAL_RESIDENT_LIB="${FLOW_ROOT}/tools/bin/flow-resident-worker-lib.sh"
|
|
9
|
+
|
|
10
|
+
tmpdir="$(mktemp -d)"
|
|
11
|
+
trap 'rm -rf "$tmpdir"' EXIT
|
|
12
|
+
|
|
13
|
+
skill_root="$tmpdir/skill"
|
|
14
|
+
bin_dir="$skill_root/tools/bin"
|
|
15
|
+
hooks_dir="$skill_root/hooks"
|
|
16
|
+
assets_dir="$skill_root/assets"
|
|
17
|
+
profile_registry_root="$tmpdir/profile-registry"
|
|
18
|
+
profile_dir="$profile_registry_root/demo"
|
|
19
|
+
shim_dir="$tmpdir/shim"
|
|
20
|
+
agent_root="$tmpdir/agent"
|
|
21
|
+
repo_root="$tmpdir/repo"
|
|
22
|
+
capture_dir="$tmpdir/capture"
|
|
23
|
+
|
|
24
|
+
mkdir -p "$bin_dir" "$hooks_dir" "$assets_dir" "$profile_dir" "$shim_dir" "$agent_root" "$repo_root" "$capture_dir"
|
|
25
|
+
cp "$REAL_LOOP" "$bin_dir/start-resident-issue-loop.sh"
|
|
26
|
+
cp "$REAL_CONFIG_LIB" "$bin_dir/flow-config-lib.sh"
|
|
27
|
+
cp "$REAL_SHELL_LIB" "$bin_dir/flow-shell-lib.sh"
|
|
28
|
+
cp "$REAL_RESIDENT_LIB" "$bin_dir/flow-resident-worker-lib.sh"
|
|
29
|
+
printf '{}\n' >"$assets_dir/workflow-catalog.json"
|
|
30
|
+
|
|
31
|
+
cat >"$profile_dir/control-plane.yaml" <<EOF
|
|
32
|
+
schema_version: "1"
|
|
33
|
+
id: "demo"
|
|
34
|
+
repo:
|
|
35
|
+
slug: "example/demo"
|
|
36
|
+
root: "$repo_root"
|
|
37
|
+
default_branch: "main"
|
|
38
|
+
runtime:
|
|
39
|
+
orchestrator_agent_root: "$agent_root"
|
|
40
|
+
worktree_root: "$tmpdir/worktrees"
|
|
41
|
+
agent_repo_root: "$repo_root"
|
|
42
|
+
runs_root: "$agent_root/runs"
|
|
43
|
+
state_root: "$agent_root/state"
|
|
44
|
+
history_root: "$agent_root/history"
|
|
45
|
+
retained_repo_root: "$repo_root"
|
|
46
|
+
vscode_workspace_file: "$tmpdir/demo.code-workspace"
|
|
47
|
+
session_naming:
|
|
48
|
+
issue_prefix: "demo-issue-"
|
|
49
|
+
pr_prefix: "demo-pr-"
|
|
50
|
+
execution:
|
|
51
|
+
coding_worker: "openclaw"
|
|
52
|
+
resident_workers:
|
|
53
|
+
issue_reuse_enabled: true
|
|
54
|
+
issue_controller_max_immediate_cycles: 1
|
|
55
|
+
controller_poll_seconds: 1
|
|
56
|
+
issue_controller_idle_timeout_seconds: 1
|
|
57
|
+
EOF
|
|
58
|
+
|
|
59
|
+
cat >"$hooks_dir/heartbeat-hooks.sh" <<'EOF'
|
|
60
|
+
#!/usr/bin/env bash
|
|
61
|
+
set -euo pipefail
|
|
62
|
+
|
|
63
|
+
heartbeat_open_agent_pr_issue_ids() {
|
|
64
|
+
local count_file="${TEST_CAPTURE_DIR:?}/start-count.txt"
|
|
65
|
+
local count="0"
|
|
66
|
+
if [[ -f "${count_file}" ]]; then
|
|
67
|
+
count="$(cat "${count_file}")"
|
|
68
|
+
fi
|
|
69
|
+
if [[ "${count}" =~ ^[1-9][0-9]*$ ]]; then
|
|
70
|
+
printf '["440"]\n'
|
|
71
|
+
else
|
|
72
|
+
printf '[]\n'
|
|
73
|
+
fi
|
|
74
|
+
}
|
|
75
|
+
heartbeat_list_ready_issue_ids() { printf '440\n441\n'; }
|
|
76
|
+
heartbeat_issue_is_recurring() {
|
|
77
|
+
case "${1:-}" in
|
|
78
|
+
440|441) printf 'yes\n' ;;
|
|
79
|
+
*) printf 'no\n' ;;
|
|
80
|
+
esac
|
|
81
|
+
}
|
|
82
|
+
heartbeat_issue_is_scheduled() { printf 'no\n'; }
|
|
83
|
+
heartbeat_issue_is_heavy() { printf 'no\n'; }
|
|
84
|
+
heartbeat_mark_issue_running() {
|
|
85
|
+
printf 'RUNNING:%s:%s\n' "${1:?issue id required}" "${2:-no}" >>"${TEST_CAPTURE_DIR:?}/events.log"
|
|
86
|
+
}
|
|
87
|
+
heartbeat_issue_launch_failed() {
|
|
88
|
+
printf 'FAILED:%s\n' "${1:?issue id required}" >>"${TEST_CAPTURE_DIR:?}/events.log"
|
|
89
|
+
}
|
|
90
|
+
EOF
|
|
91
|
+
chmod +x "$hooks_dir/heartbeat-hooks.sh"
|
|
92
|
+
|
|
93
|
+
cat >"$shim_dir/gh" <<'EOF'
|
|
94
|
+
#!/usr/bin/env bash
|
|
95
|
+
set -euo pipefail
|
|
96
|
+
|
|
97
|
+
if [[ "${1:-}" == "issue" && "${2:-}" == "view" ]]; then
|
|
98
|
+
issue_id="${3:-0}"
|
|
99
|
+
cat <<JSON
|
|
100
|
+
{"number":${issue_id},"state":"OPEN","title":"Resident issue ${issue_id}","body":"Keep this issue moving.","url":"https://example.test/issues/${issue_id}","labels":[{"name":"agent-keep-open"}],"comments":[]}
|
|
101
|
+
JSON
|
|
102
|
+
exit 0
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
if [[ "${1:-}" == "pr" && "${2:-}" == "list" ]]; then
|
|
106
|
+
printf '[]\n'
|
|
107
|
+
exit 0
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
exit 64
|
|
111
|
+
EOF
|
|
112
|
+
chmod +x "$shim_dir/gh"
|
|
113
|
+
|
|
114
|
+
cat >"$shim_dir/tmux" <<'EOF'
|
|
115
|
+
#!/usr/bin/env bash
|
|
116
|
+
set -euo pipefail
|
|
117
|
+
|
|
118
|
+
if [[ "${1:-}" == "has-session" ]]; then
|
|
119
|
+
pid_file="${TEST_CAPTURE_DIR:?}/tmux-session.pid"
|
|
120
|
+
if [[ -f "${pid_file}" ]]; then
|
|
121
|
+
pid="$(tr -d '[:space:]' <"${pid_file}" 2>/dev/null || true)"
|
|
122
|
+
if [[ -n "${pid}" ]] && kill -0 "${pid}" 2>/dev/null; then
|
|
123
|
+
exit 0
|
|
124
|
+
fi
|
|
125
|
+
rm -f "${pid_file}"
|
|
126
|
+
fi
|
|
127
|
+
exit 1
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
exit 1
|
|
131
|
+
EOF
|
|
132
|
+
chmod +x "$shim_dir/tmux"
|
|
133
|
+
|
|
134
|
+
cat >"$bin_dir/start-issue-worker.sh" <<'EOF'
|
|
135
|
+
#!/usr/bin/env bash
|
|
136
|
+
set -euo pipefail
|
|
137
|
+
|
|
138
|
+
issue_id="${1:?issue id required}"
|
|
139
|
+
capture_dir="${TEST_CAPTURE_DIR:?}"
|
|
140
|
+
count_file="${capture_dir}/start-count.txt"
|
|
141
|
+
count="0"
|
|
142
|
+
if [[ -f "${count_file}" ]]; then
|
|
143
|
+
count="$(cat "${count_file}")"
|
|
144
|
+
fi
|
|
145
|
+
count="$((count + 1))"
|
|
146
|
+
printf '%s\n' "${count}" >"${count_file}"
|
|
147
|
+
printf 'START:%s:%s\n' "${issue_id}" "${count}" >>"${capture_dir}/events.log"
|
|
148
|
+
(sleep 0.2) &
|
|
149
|
+
printf '%s\n' "$!" >"${capture_dir}/tmux-session.pid"
|
|
150
|
+
EOF
|
|
151
|
+
chmod +x "$bin_dir/start-issue-worker.sh"
|
|
152
|
+
|
|
153
|
+
cat >"$bin_dir/reconcile-issue-worker.sh" <<'EOF'
|
|
154
|
+
#!/usr/bin/env bash
|
|
155
|
+
set -euo pipefail
|
|
156
|
+
printf 'RECONCILE:%s\n' "${1:?session required}" >>"${TEST_CAPTURE_DIR:?}/events.log"
|
|
157
|
+
EOF
|
|
158
|
+
chmod +x "$bin_dir/reconcile-issue-worker.sh"
|
|
159
|
+
|
|
160
|
+
PATH="$shim_dir:$PATH" \
|
|
161
|
+
ACP_PROJECT_ID="demo" \
|
|
162
|
+
ACP_PROFILE_REGISTRY_ROOT="$profile_registry_root" \
|
|
163
|
+
TEST_CAPTURE_DIR="$capture_dir" \
|
|
164
|
+
bash "$bin_dir/start-resident-issue-loop.sh" 440 >/dev/null
|
|
165
|
+
|
|
166
|
+
controller_dir="$agent_root/state/resident-workers/issues"
|
|
167
|
+
controller_file_441="$controller_dir/441/controller.env"
|
|
168
|
+
|
|
169
|
+
grep -q '^2$' "$capture_dir/start-count.txt"
|
|
170
|
+
grep -q '^RUNNING:440:no$' "$capture_dir/events.log"
|
|
171
|
+
grep -q '^START:440:1$' "$capture_dir/events.log"
|
|
172
|
+
grep -q '^RECONCILE:demo-issue-440$' "$capture_dir/events.log"
|
|
173
|
+
grep -q '^RUNNING:441:no$' "$capture_dir/events.log"
|
|
174
|
+
grep -q '^START:441:2$' "$capture_dir/events.log"
|
|
175
|
+
grep -q '^RECONCILE:demo-issue-441$' "$capture_dir/events.log"
|
|
176
|
+
test ! -f "$controller_dir/440/controller.env"
|
|
177
|
+
test -f "$controller_file_441"
|
|
178
|
+
grep -q '^ISSUE_ID=441$' "$controller_file_441"
|
|
179
|
+
grep -q '^CONTROLLER_LOOP_COUNT=1$' "$controller_file_441"
|
|
180
|
+
grep -q '^CONTROLLER_REASON=idle-timeout$' "$controller_file_441"
|
|
181
|
+
grep -q '^CONTROLLER_STATE=stopped$' "$controller_file_441"
|
|
182
|
+
test ! -f "$agent_root/state/pending-launches/issue-440.pid"
|
|
183
|
+
test ! -f "$agent_root/state/pending-launches/issue-441.pid"
|
|
184
|
+
|
|
185
|
+
echo "start resident issue loop adopts next recurring issue test passed"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
FLOW_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
5
|
+
REAL_LOOP="${FLOW_ROOT}/tools/bin/start-resident-issue-loop.sh"
|
|
6
|
+
REAL_CONFIG_LIB="${FLOW_ROOT}/tools/bin/flow-config-lib.sh"
|
|
7
|
+
REAL_SHELL_LIB="${FLOW_ROOT}/tools/bin/flow-shell-lib.sh"
|
|
8
|
+
REAL_RESIDENT_LIB="${FLOW_ROOT}/tools/bin/flow-resident-worker-lib.sh"
|
|
9
|
+
|
|
10
|
+
tmpdir="$(mktemp -d)"
|
|
11
|
+
cleanup() {
|
|
12
|
+
if [[ -n "${loop_pid:-}" ]]; then
|
|
13
|
+
kill "${loop_pid}" >/dev/null 2>&1 || true
|
|
14
|
+
wait "${loop_pid}" >/dev/null 2>&1 || true
|
|
15
|
+
fi
|
|
16
|
+
rm -rf "$tmpdir"
|
|
17
|
+
}
|
|
18
|
+
trap cleanup EXIT
|
|
19
|
+
|
|
20
|
+
skill_root="$tmpdir/skill"
|
|
21
|
+
bin_dir="$skill_root/tools/bin"
|
|
22
|
+
hooks_dir="$skill_root/hooks"
|
|
23
|
+
assets_dir="$skill_root/assets"
|
|
24
|
+
profile_registry_root="$tmpdir/profile-registry"
|
|
25
|
+
profile_dir="$profile_registry_root/demo"
|
|
26
|
+
shim_dir="$tmpdir/shim"
|
|
27
|
+
agent_root="$tmpdir/agent"
|
|
28
|
+
repo_root="$tmpdir/repo"
|
|
29
|
+
capture_dir="$tmpdir/capture"
|
|
30
|
+
|
|
31
|
+
mkdir -p "$bin_dir" "$hooks_dir" "$assets_dir" "$profile_dir" "$shim_dir" "$agent_root" "$repo_root" "$capture_dir"
|
|
32
|
+
cp "$REAL_LOOP" "$bin_dir/start-resident-issue-loop.sh"
|
|
33
|
+
cp "$REAL_CONFIG_LIB" "$bin_dir/flow-config-lib.sh"
|
|
34
|
+
cp "$REAL_SHELL_LIB" "$bin_dir/flow-shell-lib.sh"
|
|
35
|
+
cp "$REAL_RESIDENT_LIB" "$bin_dir/flow-resident-worker-lib.sh"
|
|
36
|
+
printf '{}\n' >"$assets_dir/workflow-catalog.json"
|
|
37
|
+
|
|
38
|
+
cat >"$profile_dir/control-plane.yaml" <<EOF
|
|
39
|
+
schema_version: "1"
|
|
40
|
+
id: "demo"
|
|
41
|
+
repo:
|
|
42
|
+
slug: "example/demo"
|
|
43
|
+
root: "$repo_root"
|
|
44
|
+
default_branch: "main"
|
|
45
|
+
runtime:
|
|
46
|
+
orchestrator_agent_root: "$agent_root"
|
|
47
|
+
worktree_root: "$tmpdir/worktrees"
|
|
48
|
+
agent_repo_root: "$repo_root"
|
|
49
|
+
runs_root: "$agent_root/runs"
|
|
50
|
+
state_root: "$agent_root/state"
|
|
51
|
+
history_root: "$agent_root/history"
|
|
52
|
+
retained_repo_root: "$repo_root"
|
|
53
|
+
vscode_workspace_file: "$tmpdir/demo.code-workspace"
|
|
54
|
+
session_naming:
|
|
55
|
+
issue_prefix: "demo-issue-"
|
|
56
|
+
pr_prefix: "demo-pr-"
|
|
57
|
+
execution:
|
|
58
|
+
coding_worker: "openclaw"
|
|
59
|
+
resident_workers:
|
|
60
|
+
issue_reuse_enabled: true
|
|
61
|
+
issue_controller_max_immediate_cycles: 1
|
|
62
|
+
controller_poll_seconds: 1
|
|
63
|
+
issue_controller_idle_timeout_seconds: 30
|
|
64
|
+
EOF
|
|
65
|
+
|
|
66
|
+
cat >"$hooks_dir/heartbeat-hooks.sh" <<'EOF'
|
|
67
|
+
#!/usr/bin/env bash
|
|
68
|
+
set -euo pipefail
|
|
69
|
+
heartbeat_open_agent_pr_issue_ids() { printf '[]\n'; }
|
|
70
|
+
heartbeat_issue_is_heavy() { printf 'no\n'; }
|
|
71
|
+
heartbeat_mark_issue_running() { :; }
|
|
72
|
+
heartbeat_issue_launch_failed() { :; }
|
|
73
|
+
EOF
|
|
74
|
+
chmod +x "$hooks_dir/heartbeat-hooks.sh"
|
|
75
|
+
|
|
76
|
+
cat >"$shim_dir/gh" <<'EOF'
|
|
77
|
+
#!/usr/bin/env bash
|
|
78
|
+
set -euo pipefail
|
|
79
|
+
|
|
80
|
+
if [[ "${1:-}" == "issue" && "${2:-}" == "view" ]]; then
|
|
81
|
+
issue_id="${3:-0}"
|
|
82
|
+
cat <<JSON
|
|
83
|
+
{"number":${issue_id},"state":"OPEN","title":"Scheduled issue ${issue_id}","body":"Agent schedule: every 5m","url":"https://example.test/issues/${issue_id}","labels":[{"name":"agent-scheduled"}],"comments":[]}
|
|
84
|
+
JSON
|
|
85
|
+
exit 0
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
if [[ "${1:-}" == "pr" && "${2:-}" == "list" ]]; then
|
|
89
|
+
printf '[]\n'
|
|
90
|
+
exit 0
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
exit 64
|
|
94
|
+
EOF
|
|
95
|
+
chmod +x "$shim_dir/gh"
|
|
96
|
+
|
|
97
|
+
cat >"$shim_dir/tmux" <<'EOF'
|
|
98
|
+
#!/usr/bin/env bash
|
|
99
|
+
set -euo pipefail
|
|
100
|
+
|
|
101
|
+
if [[ "${1:-}" == "has-session" ]]; then
|
|
102
|
+
pid_file="${TEST_CAPTURE_DIR:?}/tmux-session.pid"
|
|
103
|
+
if [[ -f "${pid_file}" ]]; then
|
|
104
|
+
pid="$(tr -d '[:space:]' <"${pid_file}" 2>/dev/null || true)"
|
|
105
|
+
if [[ -n "${pid}" ]] && kill -0 "${pid}" 2>/dev/null; then
|
|
106
|
+
exit 0
|
|
107
|
+
fi
|
|
108
|
+
rm -f "${pid_file}"
|
|
109
|
+
fi
|
|
110
|
+
exit 1
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
exit 1
|
|
114
|
+
EOF
|
|
115
|
+
chmod +x "$shim_dir/tmux"
|
|
116
|
+
|
|
117
|
+
cat >"$bin_dir/start-issue-worker.sh" <<'EOF'
|
|
118
|
+
#!/usr/bin/env bash
|
|
119
|
+
set -euo pipefail
|
|
120
|
+
(sleep 0.2) &
|
|
121
|
+
printf '%s\n' "$!" >"${TEST_CAPTURE_DIR:?}/tmux-session.pid"
|
|
122
|
+
EOF
|
|
123
|
+
chmod +x "$bin_dir/start-issue-worker.sh"
|
|
124
|
+
|
|
125
|
+
cat >"$bin_dir/reconcile-issue-worker.sh" <<'EOF'
|
|
126
|
+
#!/usr/bin/env bash
|
|
127
|
+
set -euo pipefail
|
|
128
|
+
exit 0
|
|
129
|
+
EOF
|
|
130
|
+
chmod +x "$bin_dir/reconcile-issue-worker.sh"
|
|
131
|
+
|
|
132
|
+
PATH="$shim_dir:$PATH" \
|
|
133
|
+
ACP_PROJECT_ID="demo" \
|
|
134
|
+
ACP_PROFILE_REGISTRY_ROOT="$profile_registry_root" \
|
|
135
|
+
TEST_CAPTURE_DIR="$capture_dir" \
|
|
136
|
+
bash "$bin_dir/start-resident-issue-loop.sh" 440 >/dev/null &
|
|
137
|
+
loop_pid="$!"
|
|
138
|
+
|
|
139
|
+
controller_file="$agent_root/state/resident-workers/issues/440/controller.env"
|
|
140
|
+
pending_file="$agent_root/state/pending-launches/issue-440.pid"
|
|
141
|
+
|
|
142
|
+
for _ in $(seq 1 100); do
|
|
143
|
+
if [[ -f "$controller_file" ]] && grep -q '^CONTROLLER_STATE=sleeping$' "$controller_file"; then
|
|
144
|
+
break
|
|
145
|
+
fi
|
|
146
|
+
sleep 0.1
|
|
147
|
+
done
|
|
148
|
+
|
|
149
|
+
grep -q '^CONTROLLER_STATE=sleeping$' "$controller_file"
|
|
150
|
+
test ! -f "$pending_file"
|
|
151
|
+
|
|
152
|
+
echo "start resident issue loop clears pending while sleeping test passed"
|