Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.
Shell agent-teamsai-agentai-automationanthropicautonomous-agentawsbusiness-operationsclaudeclaude-codeclaude-code-plugindevopsecommerceinbox-zeroklaviyomarketingmcpmorning-briefingpr-automationshopifyterminal
Fix account-rotation bugs: SMS phone config, pwd URL order, --capture --to, paths, drift cleanup
Cursor Agent8d2e46579ed9
diff --git a/claude-ops/scripts/account-rotation/config.example.json b/claude-ops/scripts/account-rotation/config.example.jsonindex 6d409d8f..5eab5e2a 100644--- a/claude-ops/scripts/account-rotation/config.example.json+++ b/claude-ops/scripts/account-rotation/config.example.json@@ -8,6 +8,7 @@"orgUuid": "optional-workspace-uuid","dashlaneTokenPath": "dl://[email protected]/password","dashlaneGooglePath": null,+ "googleSmsPhone": "+1234567890","extraUsageEnabled": false,"capacityMultiplier": 1.0},diff --git a/claude-ops/scripts/account-rotation/daemon.mjs b/claude-ops/scripts/account-rotation/daemon.mjsindex 4e8ade1b..455b0c03 100644--- a/claude-ops/scripts/account-rotation/daemon.mjs+++ b/claude-ops/scripts/account-rotation/daemon.mjs@@ -559,47 +559,6 @@ async function doRotation(reason) {}}-// ── Auto-sync: detect if live auth drifted from state ────────────────────────--function syncDriftedState(state, config, lastRotatedAt = 0) {- // After a rotation, `claude auth status` still returns the OLD session's email- // until the user restarts Claude Code. Don't undo the rotation by "correcting"- // state back to the stale live email — wait for the blackout to pass.- // Use the shared state.lastRotation (written by rotate.mjs) so duplicate daemon- // instances both respect the blackout, even if one of them didn't do the rotation.- const stateLastRotation = state.lastRotation- ? new Date(state.lastRotation).getTime()- : 0;- const effectiveLastRotation = Math.max(lastRotatedAt, stateLastRotation);- if (- effectiveLastRotation &&- Date.now() - effectiveLastRotation < POST_ROTATION_BLACKOUT- )- return false;-- try {- const liveAuth = execSync("claude auth status 2>&1", {- timeout: 5_000,- }).toString();- const liveEmail = JSON.parse(liveAuth)?.email;- if (!liveEmail) return false;-- const liveKey = config.accounts.find((a) => a.email === liveEmail);- if (!liveKey) return false;-- const liveAccountKey = accountKey(liveKey);- if (state.activeAccount !== liveAccountKey) {- log(- `⚠️ DRIFT DETECTED: state says ${state.activeAccount || "none"}, live auth is ${liveAccountKey} — syncing state`,- );- state.activeAccount = liveAccountKey;- writeFileSync(STATE_PATH, JSON.stringify(state, null, 2));- return true; // Drift was corrected- }- } catch {}- return false;-}-// ── Dynamic token refresh ────────────────────────────────────────────────────// Instead of a fixed hourly launchd job refreshing all accounts, refresh// on-demand: when utilization is climbing (50%+), pre-refresh candidate@@ -761,8 +720,9 @@ async function mainLoop() {// Post-rotation blackout: ALL rotation triggers are suppressed for 90s// after any rotation. `claude auth status` returns stale data during this// window, which causes drift detection → re-rotation thrashing loops.- const stateLastRotation = readState().lastRotation- ? new Date(readState().lastRotation).getTime()+ const stateForBlackout = readState();+ const stateLastRotation = stateForBlackout.lastRotation+ ? new Date(stateForBlackout.lastRotation).getTime(): 0;const effectiveLastRotated = Math.max(lastRotatedAt, stateLastRotation);const inBlackout =diff --git a/claude-ops/scripts/account-rotation/force-rotate.sh b/claude-ops/scripts/account-rotation/force-rotate.shindex ca49ea33..407deab6 100755--- a/claude-ops/scripts/account-rotation/force-rotate.sh+++ b/claude-ops/scripts/account-rotation/force-rotate.sh@@ -43,7 +43,7 @@## Recovery from stuck state:# pkill -9 -f "rotate\.mjs"-# rm -f ~/.claude/scripts/account-rotation/.rotating+# rm -f ~/.claude/plugins/data/ops/account-rotation/.rotating# launchctl kickstart -k gui/$(id -u)/com.claude-ops.account-rotation## Behavior: --force kills any stuck competing rotate.mjs and bypasses the lock.@@ -52,7 +52,9 @@# by a watchdog so the rotation can never hang indefinitely.set -u-DIR="$HOME/.claude/scripts/account-rotation"+DEFAULT_ROT_DIR="${HOME}/.claude/plugins/data/ops/account-rotation"+DIR="${CLAUDE_ROTATION_DATA_DIR:-${CLAUDE_PLUGIN_DATA_DIR:-${HOME}/.claude/plugins/data/ops}/account-rotation}"+[ -d "$DIR" ] || DIR="$DEFAULT_ROT_DIR"WATCHDOG_SECONDS="${FORCE_ROTATE_TIMEOUT:-360}"echo "🔄 Force-rotating Claude account..."diff --git a/claude-ops/scripts/account-rotation/rotate.mjs b/claude-ops/scripts/account-rotation/rotate.mjsindex 5f18698f..c4671df6 100644--- a/claude-ops/scripts/account-rotation/rotate.mjs+++ b/claude-ops/scripts/account-rotation/rotate.mjs@@ -517,6 +517,7 @@ function fetchGoogleCreds(account) {return {password: match.password || null,otpSecret: match.otpSecret || null,+ phone: match.phone || match.phoneNumber || null,};} catch {return null;@@ -1588,11 +1589,15 @@ async function runAuthFlow(driver, account) {const creds = fetchGoogleCreds(account) || {};const googlePassword = creds.password || fetchGooglePassword(account);const googleOtpSecret = creds.otpSecret || null;+ const googleSmsPhone =+ (process.env.CLAUDE_ROTATION_GOOGLE_SMS_PHONE || "").trim() ||+ (account.googleSmsPhone || "").trim() ||+ (creds.phone || "").trim() ||+ null;if (googlePassword)log(`dcli Google password available for ${account.email}${googleOtpSecret ? " (+TOTP)" : ""}`,);- const PHONE_NUMBER = "+10000000000";// AI-brain stall detector: when the URL doesn't advance for N consecutive// steps, hand the page to Claude to decide what to do. Kept separate from@@ -1797,8 +1802,17 @@ async function runAuthFlow(driver, account) {url.includes("accounts.google.com") &&url.includes("challenge/ipp/collect")) {- log(`SMS phone collect — entering ${PHONE_NUMBER} and clicking Send`);- await driver.fillInput('#phoneNumberId, input[type="tel"]', PHONE_NUMBER);+ if (!googleSmsPhone) {+ log(+ `SMS phone collect page — no phone (set CLAUDE_ROTATION_GOOGLE_SMS_PHONE, account.googleSmsPhone, or dcli phone on google.com cred)`,+ );+ return false;+ }+ log(`SMS phone collect — entering configured number and clicking Send`);+ await driver.fillInput(+ '#phoneNumberId, input[type="tel"]',+ googleSmsPhone,+ );await sleep(500);await driver.findAndClick(["Send", "Next", "Verstuur"]);await sleep(4000);@@ -1869,6 +1883,17 @@ async function runAuthFlow(driver, account) {continue;}+ // Google password prompt (standalone /challenge/pwd — must run BEFORE the+ // broad accounts.google.com account-chooser branch below).+ if (url.includes("accounts.google.com") && url.includes("challenge/pwd")) {+ if (googlePassword) {+ await driver.fillInput('input[type="password"]', googlePassword);+ await sleep(500);+ await driver.findAndClick(["Next", "#passwordNext button"]);+ continue;+ }+ }+// Google account chooser — click the target accountif (url.includes("accounts.google.com")) {// Detect "Signed out" next to the target account (needs re-login)@@ -1914,16 +1939,6 @@ async function runAuthFlow(driver, account) {continue;}- // Google password prompt (standalone page, no account chooser)- if (url.includes("accounts.google.com") && url.includes("challenge/pwd")) {- if (googlePassword) {- await driver.fillInput('input[type="password"]', googlePassword);- await sleep(500);- await driver.findAndClick(["Next", "#passwordNext button"]);- continue;- }- }-// Claude organization/workspace chooser (Workspace accounts on a custom domain)// Shown between Google OAuth return and /oauth/authorize. Pick Personal unless// the account metadata specifies a team/organization name.@@ -3395,16 +3410,28 @@ function showStatus() {// ── --capture: print current token for Dashlane ───────────────────────────────-function captureCmd() {+function captureCmd(targetEmail = null) {const state = readState();const config = readConfig();- const activeKey = state.activeAccount;- const account =- config.accounts.find((a) => accountKey(a) === activeKey) ||- config.accounts.find((a) => a.email === activeKey);- if (!account) {- console.error(`Active account ${activeKey} not in config`);- process.exit(1);+ let account;+ if (targetEmail) {+ const needle = String(targetEmail).trim().toLowerCase();+ account = config.accounts.find(+ (a) => a.email.toLowerCase() === needle,+ );+ if (!account) {+ console.error(`No account in config matching --to ${targetEmail}`);+ process.exit(1);+ }+ } else {+ const activeKey = state.activeAccount;+ account =+ config.accounts.find((a) => accountKey(a) === activeKey) ||+ config.accounts.find((a) => a.email === activeKey);+ if (!account) {+ console.error(`Active account ${activeKey} not in config`);+ process.exit(1);+ }}try {@@ -3521,7 +3548,10 @@ if (args.includes("--setup")) {} else if (args.includes("--status")) {showStatus();} else if (args.includes("--capture")) {- captureCmd();+ const capToIdx = args.indexOf("--to");+ const captureTo =+ capToIdx !== -1 && args[capToIdx + 1] ? args[capToIdx + 1] : null;+ captureCmd(captureTo);} else {const toIdx = args.indexOf("--to");const target = toIdx !== -1 ? args[toIdx + 1] : null;