Add autonomous agent manager, agent API, business generation helpers, and CSV hardening#5
Add autonomous agent manager, agent API, business generation helpers, and CSV hardening#5bry92 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 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".
| const existingTimer = this.timers.get(key); | ||
| if (existingTimer) { | ||
| clearInterval(existingTimer); | ||
| } |
There was a problem hiding this comment.
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 👍 / 👎.
Motivation
Description
AIBusinessAgentManager(server/_core/aiBusinessAgent.ts) implementing start/stop/runNow, state tracking, logs, and a singletonaiBusinessAgentManagerfor runtime agent orchestration.server/_core/aiBusinessAgent.test.ts) that exercise start,runNow, and stop flows.agentrouter (server/routers/agent.ts) withstart,stop,status, andrunNowendpoints that useexecuteAutonomousStepto generate or optimize business assets via existing database helpers and the LLM.server/routers/businessGenerators.tsprovidinggenerateBrandingForBusiness,generateWebsiteForBusiness,generatePricingForBusiness, andgenerateLeadsForBusiness, and updatebusinessRouterto call these helpers instead of embedding LLM prompts.agentRouterinserver/routers.ts.server/export.ts) by introducingescapeCsvCellandmakeCsvRowto always quote cells and prefix suspicious values that start with=,+,-,@,\t,\rwith a single quote to neutralize formula injection.server/export.test.tsto expect quoted headers/cells and to check that formula injection payloads are neutralized.Testing
vitestincludingserver/_core/aiBusinessAgent.test.tsand the updatedserver/export.test.ts.runNow, and stop flows and passed.Codex Task