Show it a video you love. Get a new video in the same style. An AI crew (Claude Code or Codex) plans, builds and reviews it with you.
JavaScript 2d-animationai-agentsai-videoanimationclaude-codecodexmulti-agentstyle-transfervideo-generation
Show AI account usage limits as the error cause; error card understands English error text
許元豪97db3914f5e3
diff --git a/app/server/agents/index.mjs b/app/server/agents/index.mjsindex 4ad0338..141e39c 100644--- a/app/server/agents/index.mjs+++ b/app/server/agents/index.mjs@@ -78,7 +78,8 @@ function parseCodex(obj, emit, st) {export function runAgent({ kind, cwd, prompt, sessionId, onEvent = () => {}, signal }) {return new Promise((resolve) => {- const st = { sessionId, text: '', ok: false, cost: null };+ const st = { sessionId, text: '', ok: false, cost: null, lastError: '' };+ const emit = (e) => { if (e.type === 'error') st.lastError = e.text; onEvent(e); }; // keep the last error for the job's error cardconst isClaude = kind === 'claude';const cmd = isClaude ? 'claude' : CODEX_BIN;const args = isClaude ? claudeArgs(sessionId) : codexArgs(sessionId, cwd);@@ -87,16 +88,16 @@ export function runAgent({ kind, cwd, prompt, sessionId, onEvent = () => {}, sigif (signal) signal.addEventListener('abort', () => { try { IS_WIN ? spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F']) : child.kill('SIGTERM'); } catch {} });lines(child.stdout, (l) => {let obj; try { obj = JSON.parse(l); } catch { return; }- (isClaude ? parseClaude : parseCodex)(obj, onEvent, st);+ (isClaude ? parseClaude : parseCodex)(obj, emit, st);});let err = '';- lines(child.stderr, (l) => { err += l + '\n'; if (!/^\s*$/.test(l) && !/DeprecationWarning|ExperimentalWarning/.test(l)) onEvent({ type: 'error', text: short(l, 400) }); });- child.on('error', (e) => { onEvent({ type: 'error', text: `${cmd} failed to start: ${e.message}` }); });+ lines(child.stderr, (l) => { err += l + '\n'; if (!/^\s*$/.test(l) && !/DeprecationWarning|ExperimentalWarning/.test(l)) emit({ type: 'error', text: short(l, 400) }); });+ child.on('error', (e) => { emit({ type: 'error', text: `${cmd} failed to start: ${e.message}` }); });child.on('close', (code) => {if (code !== 0) st.ok = false;else if (!isClaude && st.ok === false && !err) st.ok = true;onEvent({ type: 'done', ok: st.ok, text: st.text, cost: st.cost });- resolve({ sessionId: st.sessionId, text: st.text, ok: st.ok, code, stderr: err.slice(-2000) });+ resolve({ sessionId: st.sessionId, text: st.text, ok: st.ok, code, stderr: err.slice(-2000), lastError: st.lastError });});child.stdin.end(prompt, 'utf8');});diff --git a/app/server/jobs.mjs b/app/server/jobs.mjsindex a2f7eba..73acc46 100644--- a/app/server/jobs.mjs+++ b/app/server/jobs.mjs@@ -206,9 +206,15 @@ async function turn(id, phase, vars, must, { session = 'director', who } = {}) {if (missing.length && r.ok && load(id).retryPending) missing = missing.filter((f) => !existsSync(join(d, f)));if (load(id).retryPending) update(id, (x) => { delete x.retryPending; });if (r.text) chat(id, session === 'fresh' ? 'critic' : session === 'director' ? 'agent' : 'builder', r.text, { phase, who: label });- return { ok: r.ok && !missing.length, text: r.text, missing, stderr: r.stderr };+ return { ok: r.ok && !missing.length, text: r.text, missing, stderr: r.stderr, lastError: r.lastError };}function fail(id, stageName, res) {+ // an account limit is the real cause, even when it also left outputs missing: say so plainly+ const limit = [res.lastError, res.text, res.stderr].find((t) => t && /usage limit|rate limit|hit your limit|limit reached|quota|credit balance/i.test(t));+ if (limit && !res.aborted) {+ setStage(id, 'error', { failed: stageName, error: L(id, `AI 帳號的用量到上限了,等額度恢復或換另一個 AI 導演再按「重試這一步」。原始訊息:${limit.slice(-300)}`, `Your AI account hit its usage limit. Wait until it resets (or switch to the other AI director), then click “Retry this step”. Message: ${limit.slice(-300)}`) });+ return false;+ }setStage(id, 'error', { failed: stageName, error: res.aborted ? L(id, '已取消', 'Cancelled') : !res.missing?.length ? L(id, `agent 回合失敗 ${res.stderr ? ':' + res.stderr.slice(-300) : ''}`, `The agent turn failed${res.stderr ? ': ' + res.stderr.slice(-300) : ''}`) : L(id, `缺少輸出:${res.missing.join(', ')}`, `Missing output: ${res.missing.join(', ')}`) });return false;}diff --git a/app/web/src/Project.jsx b/app/web/src/Project.jsxindex 68f08d8..d2a6220 100644--- a/app/web/src/Project.jsx+++ b/app/web/src/Project.jsx@@ -278,10 +278,11 @@ function Approve({ id, open }) {const STEP_NAME = { analyzing: '拆解參考片', styling: '判斷風格', planning: '寫企劃', replanning: '修改企劃', producing: '生產', revising: '修改成片', critiquing: '評審' };function ErrorCard({ id, job }) {const [busy, setBusy] = useState(false), [open, setOpen] = useState(false);- const e = job.error || '', cancelled = /取消/.test(e), restarted = /重新啟動/.test(e);- const missing = e.match(/缺少輸出:(.+)/)?.[1];- const title = cancelled ? `你停止了「${STEP_NAME[job.failed] || job.failed}」` : restarted ? `「${STEP_NAME[job.failed] || job.failed}」被伺服器重啟打斷` : `「${STEP_NAME[job.failed] || job.failed}」沒有完成`;- const why = cancelled ? '檔案保留在停下來的地方,可以從這裡繼續。' : restarted ? '做到一半的檔案都還在,繼續會從目前的檔案接著做。' : missing ? `AI 這一輪結束了,但沒有產出應有的檔案(${missing})。通常再跑一次就會好;也可以在右邊說明要怎麼處理。` : 'AI 這一輪出錯了。可以再跑一次,或在右邊說明要怎麼處理。';+ // the server writes errors in the project's language: match both+ const e = job.error || '', cancelled = /取消|^Cancelled/.test(e), restarted = /重新啟動|server restarted/i.test(e), limited = /用量到上限|usage limit/i.test(e);+ const missing = e.match(/(?:缺少輸出:|Missing output: )(.+)/)?.[1];+ const title = cancelled ? `你停止了「${STEP_NAME[job.failed] || job.failed}」` : restarted ? `「${STEP_NAME[job.failed] || job.failed}」被伺服器重啟打斷` : limited ? 'AI 帳號的用量到上限了' : `「${STEP_NAME[job.failed] || job.failed}」沒有完成`;+ const why = cancelled ? '檔案保留在停下來的地方,可以從這裡繼續。' : restarted ? '做到一半的檔案都還在,繼續會從目前的檔案接著做。' : limited ? '等額度恢復,或換另一個 AI 導演,再從這裡繼續;做到一半的檔案都還在。' : missing ? `AI 這一輪結束了,但沒有產出應有的檔案(${missing})。通常再跑一次就會好;也可以在右邊說明要怎麼處理。` : 'AI 這一輪出錯了。可以再跑一次,或在右邊說明要怎麼處理。';const go = async () => { setBusy(true); try { await api.retry(id); } finally { setBusy(false); } };return (<div className={`banner ${cancelled || restarted ? 'warn' : 'bad'} fade-in`}>@@ -290,7 +291,7 @@ function ErrorCard({ id, job }) {<h3>{title}</h3><div className="small muted">{why}</div><div className="row" style={{ marginTop: 12 }}>- <button className="btn sm primary" disabled={busy} onClick={go}>{busy ? <span className="spin-ring" /> : <I n="play" />}{cancelled || restarted ? '從這裡繼續' : '再試一次'}</button>+ <button className="btn sm primary" disabled={busy} onClick={go}>{busy ? <span className="spin-ring" /> : <I n="play" />}{cancelled || restarted || limited ? '從這裡繼續' : '再試一次'}</button>{!cancelled && !restarted && e && <button className="btn sm plain" onClick={() => setOpen(!open)}>技術細節<I n="chev" className={`chev ${open ? 'open' : ''}`} /></button>}</div>{open && <pre>{e}</pre>}diff --git a/app/web/src/i18n.js b/app/web/src/i18n.jsindex a886cf2..882ea87 100644--- a/app/web/src/i18n.js+++ b/app/web/src/i18n.js@@ -89,7 +89,7 @@ const EN = {'對企劃提意見,例如:S3 的轉場想更誇張…': 'Comment on the plan, e.g. make the S3 transition bigger…','對成片提意見,例如:12 秒那裡太快看不懂…': 'Comment on the film, e.g. too fast to follow at 12 s…','告訴導演怎麼處理,或補充說明…': 'Tell the director what to do, or add details…', '說明要怎麼處理這個問題…': 'Explain how to handle this…',- '企劃還在寫,可以先補充想法,導演會一併放進企劃…': 'The plan is still being written — add ideas now and the director will fold them in…', '網站已更新,點這裡重新整理': 'ReelMimic was updated — click to refresh', '請上傳參考影片或貼上影片連結': 'Upload a reference video or paste a link', 'agent 正在工作中,請等這一輪完成': 'The agent is working — wait for this turn to finish', '請貼上歌詞文字': 'Paste the lyrics text', '需求文字編碼錯誤(請用 UTF-8 送出)': 'The text encoding is wrong (send it as UTF-8)', 'AI 工作中,這一輪完成後就可以說話': 'The AI is working — you can talk once this turn finishes',+ '企劃還在寫,可以先補充想法,導演會一併放進企劃…': 'The plan is still being written — add ideas now and the director will fold them in…', '網站已更新,點這裡重新整理': 'ReelMimic was updated — click to refresh', '請上傳參考影片或貼上影片連結': 'Upload a reference video or paste a link', 'agent 正在工作中,請等這一輪完成': 'The agent is working — wait for this turn to finish', '請貼上歌詞文字': 'Paste the lyrics text', '需求文字編碼錯誤(請用 UTF-8 送出)': 'The text encoding is wrong (send it as UTF-8)', 'AI 帳號的用量到上限了': 'Your AI account hit its usage limit', '等額度恢復,或換另一個 AI 導演,再從這裡繼續;做到一半的檔案都還在。': 'Wait until it resets, or switch to the other AI director, then continue from here. Work in progress is kept.', 'AI 工作中,這一輪完成後就可以說話': 'The AI is working — you can talk once this turn finishes','Enter 送出 · Shift+Enter 換行 · 圖片可以直接貼上或拖進來': 'Enter to send · Shift+Enter for a new line · paste or drop images','附加檔案': 'Attach files', '附加圖片或檔案(也可以直接貼上或拖進來)': 'Attach images or files (you can also paste or drop them)', '送出': 'Send','全部 agent': 'All agents', '搜尋紀錄': 'Search log', '下載紀錄': 'Download log', '沒有紀錄': 'No log entries', '完整紀錄在': 'full log in',