Move AI to Codex CLI + ChatGPT browser workers with a durable post queue
Text generation now runs through a PM2 automation worker (codex exec) and images through the ChatGPT Chrome extension, replacing the Anthropic API. generateStructured keeps its signature; results are Zod-validated on the web side and the worker is reached with a bearer secret. - AI image assistant in the post editor: editable prompt step, then image (square or 3:2 only, since Instagram rejects 2:3), stored via putBlob - Full-post queue (PostGenerationJob + migration): enqueue returns 202, FIFO claim under an advisory lock, heartbeat, stale-job failure, per-user request key, cancel while QUEUED; output is always a DRAFT with audit rows - Separate 10 images/page/day quota; text quota excludes images - Worker reports Codex usage-limit as 429 with a clear Thai message - Docs: AI-AUTOMATION.md, ARCHITECTURE/README/.env.example updated Known gap: the live FIFO queue check (scripts/check-post-queue.mjs) has not passed yet; the last run hit the Codex account usage limit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@ import { roleAtLeast } from "@/lib/auth/roles";
|
||||
import { bkkMidnight } from "@/lib/board";
|
||||
import { Icon } from "./Icon";
|
||||
import { CaptionAssistant } from "./CaptionAssistant";
|
||||
import { ImageAssistant } from "./ImageAssistant";
|
||||
import { PostGenerationQueue } from "./PostGenerationQueue";
|
||||
import { PostCheck } from "./PostCheck";
|
||||
import { PageAvatar } from "./PageAvatar";
|
||||
import { formatDateTime, Notice, StatusPill } from "./ui";
|
||||
@@ -264,6 +266,8 @@ export function PostEditor({
|
||||
<small className="text-ink-3">เว้นว่างเพื่อเลือกวันภายหลัง · อนุมัติก่อน แล้วเลือกเวลาเผยแพร่</small>
|
||||
</label>}
|
||||
|
||||
{!post && canEdit && pageId && <PostGenerationQueue key={pageId} pageId={pageId} targets={targets} plannedDay={plannedDay} initialTopic={initialDraft?.topic || title} />}
|
||||
|
||||
{canEdit && pageId && (
|
||||
<CaptionAssistant
|
||||
pageId={pageId}
|
||||
@@ -307,6 +311,9 @@ export function PostEditor({
|
||||
{busy === "upload" ? "กำลังอัปโหลด…" : "เลือกรูป"}
|
||||
</button>
|
||||
)}
|
||||
{canEdit && pageId && (
|
||||
<ImageAssistant key={pageId} pageId={pageId} initialIdea={title || caption} hasImage={Boolean(imageUrl)} onUse={(url) => { setImageUrl(url); setAiAssisted(true); }} />
|
||||
)}
|
||||
<input
|
||||
ref={fileRef}
|
||||
type="file"
|
||||
|
||||
Reference in New Issue
Block a user