Skip to content

feat(server): send a page to the CMS for an agent run without a browser session (00444) - #1970

Merged
gkhngyk merged 4 commits into
ansvisor:mainfrom
cihan-gyk:feature/server-go-live-send
Nov 2, 2026
Merged

gkhngyk merged 4 commits into
ansvisor:mainfrom
cihan-gyk:feature/server-go-live-send

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

AUTONOMOUS-GO-LIVE PR 4: the server sends a page to the CMS for an agent run, without a browser session, after checking every condition again (§5.4). Stacked on #1967. Migration 00444. Nothing calls it yet; PR 5's engine step will.

What changes

  • 00444: content_draft_deliveries.agent_run_id → chat_agent_runs, on delete set null. The Library and the ship event will read "sent by the agent on its own" from it. sent_by stays the person the run acted as.
  • POST /api/internal/chat/go-live/send (CRON_SECRET, routes/internal-chat-go-live.js).
    • Re-checks from the database, so a fault in the web's precedence alone can't put anything live:
      • Chat is on;
      • Full auto's plan rule (Growth and up, paid, active; self-hosted is open);
      • the Admins' switch (auto_go_live_groups has publishing);
      • the agent run is the workspace's, running, and acts as actingUserId;
      • the agent's permission matches the run's version (chat_agent_go_live);
      • the person is still an Admin or a Manager, and publishing isn't off for Managers;
      • brand access; not the demo brand;
      • the step's reservation is reserved for this run, draft, target and kind. A send again within 24 hours reuses the slot it had. A page taken down never goes again on its own.
    • Then it sends as a person's Send to CMS does (sendContentPages, now with agentRunId), and finishes the step: done, or failed with why (which frees its slot).
    • A refusal (403 with a code) sends nothing and frees only this step's own slot, never another's. It is never retried.
    • v1 takes kind: 'cms_draft' to Webflow, WordPress, Framer or Wix. Publishing live comes with PR 9, webhooks with PR 11.

Related issue

None. AUTONOMOUS-GO-LIVE spec, PR 4.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

Server unit tests:

  • internal-chat-go-live (21):
    • a send as the run's person, with the step marked done;
    • every refusal code;
    • Manager and self-hosted;
    • 404s;
    • slots that aren't the step's are never used or freed;
    • a re-send within 24 hours;
    • CMS refusal, the daily cap and a network failure.
  • content-delivery: the agent run is kept on the delivery before the page goes.

No visible change, no Help article, no AI call.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes
  • yarn typecheck passes
  • yarn format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

CI passed on this branch (21a6a17), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41358856335): schema is up to date; web format:check, lint, typecheck, all tests and yarn build pass; server lint, format:check and all tests pass.

🤖 Generated with Claude Code

cihan-gyk and others added 3 commits November 1, 2026 23:56
…permission

AUTONOMOUS-GO-LIVE PR 1 (migration 00443), with nothing reading it yet:
chat_settings gains the workspace switch (auto_go_live_groups, who turned
it on, when, under which terms); chat_agent_go_live keeps an agent's
permission for the version it was given on, with its daily limit (1-20,
5 unless set); chat_agent_go_live_events keeps each step an agent takes
live on its own, read by brand access. reserve_agent_go_live and
finish_agent_go_live (service role) hold the daily limit under a lock per
agent, once per (draft, target); a failed step frees its slot. Types,
schema.sql, and the brand-access and demo coverage lists follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er session

AUTONOMOUS-GO-LIVE PR 4 (migration 00444). POST
/api/internal/chat/go-live/send (CRON_SECRET) is how the web's engine will
send an agent's page on its own: it checks everything again from the
database (Chat on, Full auto's plan, the Admins' switch, the run running
as the person, the agent's permission for the run's version, the person's
role and the Managers' publishing switch, brand access, not the demo
brand, and the step's own reservation), then sends as a person's Send to
CMS does, with the agent run kept on the delivery
(content_draft_deliveries.agent_run_id). The step is finished done, or
failed with why, which frees its slot; a refusal frees only this step's
own slot. Never retried. v1 takes CMS drafts only. Nothing calls it yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
gkhngyk previously approved these changes Nov 2, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

# Conflicts:
#	server/src/lib/brand-access-policies.test.js
#	supabase/schema.sql

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@gkhngyk
gkhngyk merged commit c7bbe87 into ansvisor:main Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants