Skip to content

Add autonomous agent manager, agent API, business generation helpers, and CSV hardening#5

Draft
bry92 wants to merge 2 commits into
mainfrom
codex/review-code-in-repository
Draft

Add autonomous agent manager, agent API, business generation helpers, and CSV hardening#5
bry92 wants to merge 2 commits into
mainfrom
codex/review-code-in-repository

Conversation

@bry92
Copy link
Copy Markdown
Owner

@bry92 bry92 commented Apr 17, 2026

Motivation

  • Introduce an autonomous business agent to run periodic automation steps for businesses and expose control endpoints.
  • Factor out LLM-driven business generators from the business router to improve reuse and testability.
  • Harden CSV export to properly quote cells and neutralize spreadsheet formula injection payloads.

Description

  • Add AIBusinessAgentManager (server/_core/aiBusinessAgent.ts) implementing start/stop/runNow, state tracking, logs, and a singleton aiBusinessAgentManager for runtime agent orchestration.
  • Add tests for the agent manager (server/_core/aiBusinessAgent.test.ts) that exercise start, runNow, and stop flows.
  • Add an agent router (server/routers/agent.ts) with start, stop, status, and runNow endpoints that use executeAutonomousStep to generate or optimize business assets via existing database helpers and the LLM.
  • Extract LLM-driven generation logic into server/routers/businessGenerators.ts providing generateBrandingForBusiness, generateWebsiteForBusiness, generatePricingForBusiness, and generateLeadsForBusiness, and update businessRouter to call these helpers instead of embedding LLM prompts.
  • Register agentRouter in server/routers.ts.
  • Improve CSV export (server/export.ts) by introducing escapeCsvCell and makeCsvRow to always quote cells and prefix suspicious values that start with =,+,-,@,\t,\r with a single quote to neutralize formula injection.
  • Update CSV tests in server/export.test.ts to expect quoted headers/cells and to check that formula injection payloads are neutralized.

Testing

  • Ran unit tests with vitest including server/_core/aiBusinessAgent.test.ts and the updated server/export.test.ts.
  • The new agent unit test executed start, manual runNow, and stop flows and passed.
  • The updated export tests validating quoting, escaping, and formula-neutralization ran and passed.

Codex Task

@bry92 bry92 marked this pull request as ready for review April 17, 2026 09:17
@bry92 bry92 marked this pull request as draft April 17, 2026 09:17
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a03e477896

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +89 to +92
const existingTimer = this.timers.get(key);
if (existingTimer) {
clearInterval(existingTimer);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent overlapping cycles when restarting an active agent

Calling start on an already-running agent only clears the interval timer, but it does not cancel or gate an in-flight runCycle before immediately launching a new one. If a user triggers start twice in quick succession (or retries after a timeout), two executions for the same business can run concurrently, which can duplicate LLM calls and race the read-then-insert generation steps (get*Result + create*Result) into duplicate records.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant