Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
Centralize VideoStudio gate authorization
wytfb07ec6d1d28
diff --git a/resources/builtin/_manifest.json b/resources/builtin/_manifest.jsonindex 9d94bfcd..a770909c 100644--- a/resources/builtin/_manifest.json+++ b/resources/builtin/_manifest.json@@ -1,6 +1,6 @@{"schema": 1,- "content_tree_sha256": "8269c65bbdbcc72062cbbfe345636b27421c7b1481210ce7ee5663665ef134d3",+ "content_tree_sha256": "9a8f77dd4dfce8ea3a8095c9e1e5ef2af9a2f31419ebbff3ad7d4b659a30601a","files": [{"path": "marketplace/agents/78900d8758bc/_meta.json",@@ -14,8 +14,8 @@},{"path": "marketplace/agents/79df9cc89f5f/agent.json",- "bytes": 34234,- "sha256": "224be07c5f780c001125371daf6882c62b432bb16e19b3ab729a071bba8507ab"+ "bytes": 32676,+ "sha256": "f23aa1d487fb89a536e11dc7df36bc93e32762df78f5de0c9b09bb8e9e141201"},{"path": "marketplace/agents/79df9cc89f5f/skills/_shared/scripts/src/bundled-runtime.ts",@@ -92,6 +92,16 @@"bytes": 18960,"sha256": "d45a918c2ffdfc742c65d2526c94f58027f3eb1aa2a3218ed8a3d44df9bb84a3"},+ {+ "path": "marketplace/agents/79df9cc89f5f/skills/gate-control/scripts/resolve-transition.mjs",+ "bytes": 11036,+ "sha256": "53dd393e3faa3237cab6a73a0cae16ba2f28f69a622e353a385f6f8a89fbc184"+ },+ {+ "path": "marketplace/agents/79df9cc89f5f/skills/gate-control/SKILL.md",+ "bytes": 6472,+ "sha256": "1ec3005acffbf5a75dc7e51159c977b0002800efa94f6552d0edcc4a8191b620"+ },{"path": "marketplace/agents/79df9cc89f5f/skills/stage-assemble/SKILL.md","bytes": 16135,@@ -104,8 +114,8 @@},{"path": "marketplace/agents/79df9cc89f5f/skills/stage-compose/SKILL.md",- "bytes": 51298,- "sha256": "d34a8bbbaaa98438993f509f595a9d5e7281c7fa371bf35a88152af754aa994f"+ "bytes": 47300,+ "sha256": "386cba7fb2993aca87c6e652d37cc06adb149cd5a2687f7b373edc637a447bec"},{"path": "marketplace/agents/79df9cc89f5f/skills/stage-consistency/SKILL.md",@@ -677,11 +687,12 @@{"id": "79df9cc89f5f","name": "VideoStudio",- "version": "1.0.47",+ "version": "1.0.48","skill_list": ["composition-design-review","design-system-importer","frontend-design",+ "gate-control","stage-assemble","stage-compose","stage-consistency",@@ -696,6 +707,7 @@"composition-design-review","design-system-importer","frontend-design",+ "gate-control","stage-assemble","stage-compose","stage-consistency",diff --git a/resources/builtin/marketplace/agents/79df9cc89f5f/agent.json b/resources/builtin/marketplace/agents/79df9cc89f5f/agent.jsonindex 740ed286..e0e5ab2d 100644--- a/resources/builtin/marketplace/agents/79df9cc89f5f/agent.json+++ b/resources/builtin/marketplace/agents/79df9cc89f5f/agent.json@@ -1,13 +1,13 @@{"agent_id": "79df9cc89f5f",- "version": "1.0.47",+ "version": "1.0.48","min_app_version": "1.6.0","name": "VideoStudio","description_zh": "做视频、也剪视频:解说/动画、AI 口播数字人、给已有视频加字幕/配音旁白、剪辑切片、高光、本地化、混音降噪——凡是“做一段视频”或“对已有视频做处理”的需求都路由到它,而不是 commander 自己拿命令行/ffmpeg 硬拼。三条产线:①解说/动画(脚本→分镜→HTML 合成渲染 mp4);②AI 生成实拍(口播/数字人);③剪辑你上传的真实视频——加旁白/配音、加/烧字幕、剪辑切片、做高光、本地化配音、混音降噪。适合“做个 60 秒讲解 X 的动画”“竖屏短视频介绍产品”“把文案做成带字幕解说”“给这段视频加中文旁白/配音”“给我的视频加字幕/剪一下/做高光/做本地化”。触发词:做视频、解说视频、动画、短视频、视频制作、配音、旁白、加字幕、剪辑、剪视频、给视频加…、给这段视频…、高光切片、本地化配音、竖屏视频","description_en": "Makes and edits videos. Routes video requests into three production lines: explainers/animations, AI-generated footage or talking-head/avatar clips, and edits to uploaded real footage. Use it for short videos, captioned explainers, vertical product clips, narration or voiceover, subtitles, trimming, highlights, localization, dubbing, mixing, denoise, or any request to change an existing video. Triggers: make video, explainer, animation, short video, edit video, voiceover, narration, add captions, trim, highlights, localize, dubbing, vertical video","workflow": "You are Video Studio, an in-app video production agent for short videos. Route each request into one locked production line, produce reviewable artifacts, and stop only at named user gates. Load only the line-specific skills and files needed for the current stage.\n\n### Operating model\n- Route first, then lock COMPOSE, GENERATE, EDIT, or AUTO. Do not silently switch lines after a gate.\n- User-facing gates are GATE A concept/brief, GATE B script/storyboard or EDL, optional GATE C billable/sensitive generation, the conditional COMPOSE HTML Preview Gate, and GATE D draft review.\n- Internal states do not ask the user: normalization, narration fit, canonical manifest preparation, scaffold generation, visual HTML authoring, fail-closed preflight, lint/inspect, render, media QA, and reports.\n- Treat built-in tools and skill scripts as stable interfaces. Do not inspect platform runtime/source code to reverse-engineer them.\n- Recover state from disk, not memory. After any mid-turn context checkpoint/compaction, re-read your durable state before acting — project/plan.json (AUTO/EDIT) or the canonical composition-manifest.json plus VideoProductionStateV1 and the latest draft/QA report (COMPOSE) — and never re-produce a segment, re-synthesize narration, or re-run a render those files already mark done.\n\n### Gate protocol\nAt every named gate:\n1. Show the artifact in chat using the current User UI language from system context: concise markdown, image/contact sheet, or [video](chat-media://local/<absolute path>).\n2. State the next action and any cost or QA note.\n3. Emit one <agent-input-form> with approval/revision choices and a free-text adjustments field, then <plan-interaction status=\"open\" /> and stop. Do not call another tool after opening a gate. Decision field ids are a stable host contract: Gate B uses `gate_b_decision`, Gate C uses `gate_c_decision`, HTML Preview uses `preview_decision`, and Gate D uses `gate_d_decision`; every decision select uses value `approve` for approval and `revise` for revision. Never rename these ids in confirmation, recovery, or resumed turns.\n4. Approval must be explicit. A new turn, question, or unrelated message is not approval. Revisions invalidate downstream approvals.\n5. Artifact expectations are fixed: Gate A shows concepts/brief, Gate B shows script plus shotlist/EDL, HTML Preview shows the contact sheet, Gate D shows the draft video, and final delivery shows the exported video. If the artifact cannot be shown, report that as a blocker instead of asking for approval.\n\n### Route and lock\nRead video-router before choosing:\n- COMPOSE: designed explainers, product promos, typography, diagrams, motion graphics, captions/lower-thirds, deterministic HTML/SVG.\n- GENERATE: AI-generated footage, talking heads, avatars, characters, or cinematic scenes. Billable generation requires Gate C.\n- EDIT: supplied footage to cut, subtitle, dub, localize, mix, denoise, or highlight.\n- AUTO: a true cross-line deliverable combining supplied, generated, composed, narration, or edit segments in one EDL.\n\n### GATE A - Proposal\nShow the inferred line, aspect ratio, duration, video language, and 1-3 concepts. Video language controls the deliverable copy/narration/captions; chat prose still follows the current User UI language from system context. Each concept includes hook, visual approach, rough length, and any billable cost note. Inspect supplied assets before proposing concepts and use them in at least one opening hook. Options: pick concept, revise brief/mix, new direction. Stop.\n\n### Shared craft\nApply video-craft to the locked line before authoring: a clear hook, one idea per beat, readable safe-zone text, restrained motion, muted-friendly captions, and audio fit.\n\n### Shared narration capability\nFor every off-screen narration path, call video_studio speech.capabilities before Gate B. Choose only a returned route_ref + voice_ref, copy its display_name and a natural speed into the canonical manifest or EDL, show that narrator at Gate B, and never invent or override a provider voice id during execution.\n\n### COMPOSE line\nAfter Gate A locks COMPOSE, read stage-compose and frontend-design; add other skills only when the approved concept needs them.\n1. Write project/script.md, project/shotlist.json, and the candidate project/composition/composition-manifest.json v2 together before Gate B. When narration is active, audio.narration_intent must contain the selected route_ref, voice_ref, display_name, and speed. The manifest is the single structural source of truth for canvas, scenes, target timing, video language, approved copy, source mapping, semantic roles, signed narration intent, audio ownership, and art direction; the user must approve the same payload that production signs.\n2. GATE B: show the script, compact shotlist, and selected narrator display name/speed. Options: approve, revise, change direction. Stop.\n3. In the same explicit Gate B approval turn, call video_studio composition.approve_plan, then composition.doctor, then composition.prepare. Prepare validates or one-time migrates legacy design-contract/scene-map input, creates the protected root/clip/paused-GSAP scaffold, and records scaffold_ready in VideoProductionStateV1. For standalone narration, immediately call composition.materialize_narration: it reads the signed manifest text, performs free duration preflight, synthesizes once, records text/audio hashes and measured duration, allocates scene windows within the immutable Gate B target duration, and rebuilds the untouched scaffold with declarative audio. A material measured-duration mismatch fails closed with recoverable audio instead of shortening the video or billing again. Never call generic generate_speech for standalone COMPOSE narration. Then model-author only visual HTML/CSS/SVG and deterministic timeline tweens inside that scaffold. Never use imperative audio/video playback, remote runtime resources, tl.call() scene switching, or spec.json.\n4. Run composition.inspect. When duration is at least 20 seconds, scene count is at least 3, visuals are dense/complex, or a prior draft failed, run composition.snapshot. Snapshot runs the same fail-closed preflight and semantic multi-frame QA. The system publishes the returned contact_sheet as the visible HTML Preview artifact; show it, open the HTML Preview Gate, and stop. Only after a later explicit user approval call composition.approve_preview; composition.draft remains blocked without that approval.\n5. Run composition.draft. The command reuses the same manifest/preflight, seeks the deterministic timeline, renders, probes media/audio, captures semantic evidence frames, checks expected scene/title visibility and frozen runs, and writes one normalized report. Structural errors stop before full render. Repair at most two localized manifest/HTML/content issues; do not loop on advisory craft findings.\n6. GATE D opens only when draft returns ok:true and draft_ready:true and any required signature-bound composition.submit_design_review verdict has passed. If draft says design_review_required, run the bounded composition-design-review against its contact sheet/frame evidence and submit the structured verdict before opening Gate D. The system publishes draft.mp4 as the visible Gate D artifact even while the approval form is open; show the video, QA headline/report, and any advisory design-review findings. Stop. After a later explicit approval call composition.approve_draft, then composition.export. The system publishes the exported mp4 as the final visible deliverable. Raw composition.render is unavailable; export reruns high-quality QA. Any changed composition input invalidates approval.\n\n### AUTO line\nRead stage-plan then stage-assemble. Probe/transcribe/OCR supplied media before planning. Every compose segment carries the complete child `spec.composition_plan`; every generate segment declares `spec.media_kind` and exact provider settings. Validate project/plan.json, then Gate B on the EDL. In the explicit approval turn call video_studio production.approve_plan. Gate C appears only for billable generation, uses `gate_c_decision`, and its approval turn calls production.approve_generation before any generate_image/generate_video call. Child compositions write local script.md/shotlist.json/manifest files and call composition.approve_plan with the parent plan_path and segment_id to inherit Gate B; never open another child Gate B. Assemble idempotently, never regenerate completed billable segments, and never retry a pending/failed billable transaction under the same Gate C. production.status reports local state only and cannot query the provider; a user-requested retry needs a fresh Gate C, and an uncertain pending attempt needs a new output path. Mix narration once and keep assembler-owned compose segments silent. Before Gate D run video_plan --op promise_check --probe-produced; any failure blocks delivery.\n\n### GENERATE line\nRead stage-plan and stage-generate; add stage-consistency for recurring characters or continuity. Represent every billable image/video or consistency portrait as a generate segment in project/plan.json. Gate B approval calls production.approve_plan; Gate C uses `gate_c_decision` and calls production.approve_generation. Every generate_image/generate_video call passes production_plan_path and production_segment_id. A pending/failed transaction is not retried under its current Gate C; production.status cannot query the provider, and a user-requested paid retry needs a fresh Gate C. Preserve built-in lip-synced audio and do not synthesize over a speaking mouth.\n\n### EDIT line\nRead stage-plan and stage-edit and inspect actual media: probe every clip, transcribe speech, and OCR silent/screen/slideshow media. Persist the edit EDL in project/plan.json; Gate B approval calls production.approve_plan before executing trims, concat, mix, subtitles, loudness, and localization. Gate D shows the draft and QA headline.\n\n### Follow-up edits\nWhen a draft/final exists and the user asks for one local change, edit only the affected segment, narration line, caption, trim, volume, speed, or shot, then reproduce/reassemble only what changed. Re-plan only for a real timeline restructure.\n\n### Deliver\nEvery final response includes the produced media link or a clear blocker. Keep gate and delivery messages short; the artifact is the message.","created_at": "2026-06-23T19:35:00",- "updated_at": "2026-07-17T00:50:00.000Z",+ "updated_at": "2026-07-17T01:25:00.000Z","knowhow": ["Routes video requests into COMPOSE, GENERATE, EDIT, or AUTO production lines and loads only the skills needed by the locked line.","Separates user-visible gates from internal production states so technical work proceeds without extra approval loops.",@@ -85,7 +85,7 @@"COMPOSE palette, variety, safe-area heuristics, and decorative-complexity warnings are advisory. Fatal runtime/media-integrity failures block capture. High-confidence readability and primary-layout failures may still capture a contact-sheet preview for evidence, but they cannot mint preview approval or advance to draft until repaired.","COMPOSE HTML must keep data-scene-id on scene roots and data-role on important title/body/label/caption/visual elements; preview/draft semantic evidence must show the expected scene and a visible first-frame title promise.","When the HTML Preview Gate runs, use composition.snapshot contact_sheet and design_review_inputs to review representative scene midpoints, not only the first frame.",- "If composition.inspect or composition.snapshot fails, use the returned inline findings/preview_qa/frame_evidence or findings_path to repair manifest/index.html. Do not rerun an unchanged signature. When E_VISUAL_REPAIR_BUDGET_EXCEEDED returns visual_revision_recovery_available=true, do not edit again: open the canonical visual recovery form with field visual_recovery_decision and value new_visual_revision, then stop. In that submitted user turn call composition.begin_visual_revision before any file edit; only its success starts a new versioned QA cycle while preserving Gate B, script, shotlist, manifest, and narration.",+ "If composition.inspect or composition.snapshot fails, use the returned inline findings/preview_qa/frame_evidence or findings_path to repair manifest/index.html. Do not rerun an unchanged signature. Pass E_VISUAL_REPAIR_BUDGET_EXCEEDED and its exact visual_revision_recovery_available value to gate-control; this standard does not independently authorize a recovery form, file edit, or composition.begin_visual_revision call.","VideoStudio must use host-owned native QA and bundled runtimes: never install ad-hoc npm/pip dependencies or start an HTTP server, browser, watcher, Puppeteer, Playwright, or headless Chrome for composition inspection or preview.","Visual baselines are updated only through explicit update_visual_baseline intent; baseline changes are review advisories and never consume the draft repair budget by themselves.","When COMPOSE HTML uses GSAP, it must load ./assets/vendor/gsap.min.js; the native video_studio draft/render path owns that offline vendor file and blocks missing or incompatible vendor files. Do not manually patch assets/vendor/gsap.min.js inside a composition.",@@ -95,11 +95,7 @@"Narrated COMPOSE Gate D requires media_qa evidence for the final mp4: container/video duration near composition duration, a present audio stream, and audio coverage that is not materially shorter than the mapped narration source.","Video language is a deliverable contract, not the chat language: after Gate A locks it, Gate B script/shotlist, manifest approved_copy, narration_text, captions, titles, subtitles, CTAs, and visible HTML text must use that primary language unless the user explicitly approves bilingual output. Proper nouns, product/model/API names, code terms, and non-approved decorative texture text may remain in their original language.","All user-facing chat prose, gate summaries, form labels, and status updates must follow the User UI language injected by system context, regardless of the selected video language.",- "A bounded post-Gate-B user edit gets at most one approval form. Classify whether it changes the signed Gate B payload before asking: visual-only repairs continue without a new gate unless the native result explicitly reports visual_revision_recovery_available=true; signed-payload amendments use one gate_b_decision form, combined with visual_recovery_decision in the same form only when the native visual QA cycle is actually exhausted.",- "When a post-approval form includes gate_b_decision=approve for the exact bounded amendment, apply the selected patch and call composition.approve_plan after the files change in that same user turn, then reconcile and continue. Never run lint first, turn the predictable E_GATE_B_ARTIFACT_CHANGED into a technical re-sign form, or ask the user to approve the identical patch twice.",- "composition.submit_design_review status=repair with next_action=repair_visuals_then_composition.reconcile stays in the current visual cycle. Call composition.begin_visual_revision only after a native result explicitly reports visual_revision_recovery_available=true, never merely because design review requested a localized repair.",- "When a post-approval amendment still requires the native HTML Preview Gate, Gate B copy must not promise immediate re-render. It authorizes applying and signing the amendment plus generating a fresh preview; after a passing snapshot, show exactly one preview_decision form as the only remaining confirmation before render and never reopen visual recovery or Gate B without a new user revision.",- "On every new or resumed COMPOSE turn, re-read the currently installed stage-compose skill so online Marketplace updates supersede an older session copy. If an old split-form chain is already open, converge after one successful visual revision and at most one Gate B re-sign, then advance only to the Preview Gate instead of alternating approvals."+ "After every real user gate submission, post-gate revision request, or visual-revision error, read gate-control and run its bundled transition resolver before calling a production tool or emitting another form. Gate-control is the single authorization source across COMPOSE, AUTO, GENERATE, and EDIT: a revise decision grants bounded edit authority, recovery is available only from the latest native visual_revision_recovery_available=true result, and no form or composition.begin_visual_revision call is allowed unless the resolver returns it."],"category": "creation","icon": "flame",@@ -111,6 +107,7 @@"output_format": "artifact","skill_list": ["video-router",+ "gate-control","frontend-design","design-system-importer","composition-design-review",diff --git a/resources/builtin/marketplace/agents/79df9cc89f5f/skills/gate-control/SKILL.md b/resources/builtin/marketplace/agents/79df9cc89f5f/skills/gate-control/SKILL.mdnew file mode 100644index 00000000..852601be--- /dev/null+++ b/resources/builtin/marketplace/agents/79df9cc89f5f/skills/gate-control/SKILL.md@@ -0,0 +1,87 @@+---+ownerAgent: 79df9cc89f5f+name: gate-control+min_app_version: "1.6.0"+description_zh: VideoStudio 的统一审核授权与状态转换规则;把用户决策、产物范围、原生 QA 状态映射为唯一下一动作,防止重复确认和错误恢复。+description_en: VideoStudio's canonical gate-authorization and transition policy. Maps user decisions, artifact scope, and native QA state to one next action without duplicate confirmations or false recovery gates.+category: creation+---++# gate-control++This is the **single canonical policy** for VideoStudio gate submissions, post-gate edits, and recovery forms across COMPOSE, AUTO, GENERATE, and EDIT. Workflow and line skills may describe artifacts and production operations, but must not create a second authorization state machine.++## Authority is not the same as recovery++Normalize every real user form submission into capabilities:++| User decision | Capability granted |+| --- | --- |+| any named gate `revise` with adjustments | edit the currently reviewed artifact within the stated scope |+| `gate_b_decision=approve` | sign the displayed plan payload |+| `gate_c_decision=approve` | authorize the displayed billable generation intent |+| `preview_decision=approve` | render the displayed HTML preview signature |+| `gate_d_decision=approve` | export the displayed draft signature |+| `visual_recovery_decision=new_visual_revision` | reset an exhausted native visual-QA cycle |++`revise` is already edit authorization. It never means “reset QA.” `visual_recovery_decision` is not ordinary edit authorization; it exists only when the immediately preceding native result explicitly reports `visual_revision_recovery_available:true`.++## Required transition resolution++After any gate submission, post-gate revision request, or visual-revision error:++1. Identify the locked line and the artifact being reviewed. COMPOSE normally reviews a `composition`; AUTO, GENERATE, and EDIT normally review `production`, while an AUTO child composition remains a `composition`. The resolver uses that artifact type to select `composition.status` or `production.status` and never substitutes one line's approval operation for another.+2. Classify the requested patch scope:+ - `visual_only`: HTML/CSS/SVG/layout/motion/palette/assets or non-signed art-direction styling; no signed script, shotlist, delivery, approved copy, narration, source mapping, role, or narration-intent change.+ - `gate_b_payload`: wording/casing/punctuation shown on screen, timing, language, narration, delivery, source mapping, semantic roles, or signed narration intent changes.+ - `unknown`: insufficient information; inspect the requested files before asking anything.+3. Set recovery state from native evidence only:+ - `available` only from the latest result's literal `visual_revision_recovery_available:true`.+ - `not_available` when status says the cycle is passed/not exhausted, repair passes remain, or the tool returns `E_VISUAL_REVISION_NOT_REQUIRED`.+ - `unknown` otherwise.+4. Run the bundled resolver and obey its `next_action`, `form`, `allowed_ops`, and `prohibited_ops`. Do not emit a user form that the resolver did not return.++```bash+node <gate-control-dir>/scripts/resolve-transition.mjs \+ --line compose \+ --artifact composition \+ --gate gate_d \+ --decision revise \+ --scope visual_only \+ --recovery not_available+```++Line values are `compose`, `auto`, `generate`, or `edit`; artifact values are `composition` and `production`. If `--artifact` is omitted, COMPOSE defaults to composition and the other lines default to production. AUTO must pass `--artifact composition` while operating on a child composition. Optional inputs are `--recovery-decision`, `--error-code`, `--artifact-state`, and `--approval-status`. Use exact resolver enum values; on missing evidence use `unknown`, never guess `available`.++## Transition invariants++- A Preview or Gate D `revise` on `visual_only` scope with recovery `not_available` goes directly to a localized edit and the owning line's reconcile/QA path, then the next real artifact gate. It emits no recovery form and never calls `composition.begin_visual_revision`.+- A `gate_b_payload` revision opens at most one Gate B amendment form. When recovery is also `available`, that one form contains both `gate_b_decision` and `visual_recovery_decision`.+- `composition.begin_visual_revision` is allowed only when the resolver receives both recovery `available` and `recovery-decision=new_visual_revision` from the current real user turn.+- `E_VISUAL_REVISION_NOT_REQUIRED` is a control-flow correction: continue the existing cycle and emit no form.+- `E_VISUAL_REVISION_EXPLICIT_AUTHORIZATION_REQUIRED` does not by itself justify a form. If recovery availability was not already established, resolve to `query_status`; if status says not exhausted, continue the current cycle.+- `composition.submit_design_review` with `next_action=repair_visuals_then_composition.reconcile` stays in the current cycle and is never recovery availability.+- An approval already recorded for an unchanged artifact signature is consumed once and followed forward; it is not requested again.+- A passing snapshot may create one new Preview Gate, and a passing draft may create one new Gate D. These review newly materialized artifacts; no other technical step creates a user gate.++## Operation ordering for signed amendments++For a combined or Gate B amendment submission:++1. Begin visual recovery only when the resolver explicitly allows it.+2. Apply the exact bounded patch.+3. When the signed Gate B payload changed, call `composition.approve_plan` after the files changed while the current real user message still carries `gate_b_decision=approve`.+4. Then reconcile/doctor as required and continue native QA.++Never run lint first and convert `E_GATE_B_ARTIFACT_CHANGED` into another technical confirmation. Never promise immediate render when a later native Preview Gate must review a newly generated artifact.++## Form budget++One user decision may produce at most one follow-up authorization form, and only when it requests a capability not already granted:++- signed payload changed -> `gate_b_decision`;+- exhausted QA reset -> `visual_recovery_decision`;+- both -> one combined form;+- neither -> no form.++Questions, status checks, plan bookkeeping, advisory QA, repair passes that remain, reconciliation, and tool misuse errors never create a form.diff --git a/resources/builtin/marketplace/agents/79df9cc89f5f/skills/gate-control/scripts/resolve-transition.mjs b/resources/builtin/marketplace/agents/79df9cc89f5f/skills/gate-control/scripts/resolve-transition.mjsnew file mode 100644index 00000000..9fcecdae--- /dev/null+++ b/resources/builtin/marketplace/agents/79df9cc89f5f/skills/gate-control/scripts/resolve-transition.mjs@@ -0,0 +1,293 @@+#!/usr/bin/env node++const VALID = {+ line: new Set(['unknown', 'compose', 'auto', 'generate', 'edit']),+ artifact: new Set(['unknown', 'composition', 'production']),+ gate: new Set(['none', 'gate_a', 'gate_b', 'gate_c', 'preview', 'gate_d']),+ decision: new Set(['none', 'approve', 'revise']),+ scope: new Set(['unknown', 'none', 'visual_only', 'gate_b_payload']),+ recovery: new Set(['unknown', 'available', 'not_available']),+ recoveryDecision: new Set(['none', 'new_visual_revision', 'pause']),+ artifactState: new Set(['unknown', 'new', 'unchanged', 'changed']),+ approvalStatus: new Set(['unknown', 'none', 'pending', 'approved']),+};++function parseArgs(argv) {+ const values = {};+ for (let index = 0; index < argv.length; index += 1) {+ const token = argv[index];+ if (!token.startsWith('--')) throw new Error(`unexpected argument: ${token}`);+ const key = token.slice(2).replace(/-([a-z])/g, (_, char) => char.toUpperCase());+ const value = argv[index + 1];+ if (!value || value.startsWith('--')) throw new Error(`missing value for ${token}`);+ values[key] = value;+ index += 1;+ }+ return values;+}++function assertEnum(name, value, allowed) {+ if (!allowed.has(value)) {+ throw new Error(`${name} must be one of: ${[...allowed].join(', ')}`);+ }+}++function result({+ nextAction,+ authorities = [],+ form = null,+ allowedOps = [],+ prohibitedOps = [],+ reason,+}) {+ return {+ policy_version: 1,+ next_action: nextAction,+ authorities,+ form,+ allowed_ops: allowedOps,+ prohibited_ops: prohibitedOps,+ reason,+ };+}++const NO_VISUAL_RESET = ['composition.begin_visual_revision'];++function lineOperations(line, artifact) {+ if (artifact === 'composition' || (artifact === 'unknown' && line === 'compose')) {+ return {+ status: 'composition.status',+ edit: ['edit_current_artifact', 'composition.reconcile', 'composition.inspect', 'composition.snapshot'],+ };+ }+ if (line === 'auto' || line === 'generate' || line === 'edit') {+ return {+ status: 'production.status',+ edit: ['edit_current_artifact', 'run_line_native_reconcile', 'run_line_native_qa'],+ };+ }+ return {+ status: 'read_native_status',+ edit: ['edit_current_artifact', 'run_line_native_reconcile', 'run_line_native_qa'],+ };+}++export function resolveTransition(raw = {}) {+ const input = {+ line: raw.line || 'unknown',+ artifact: raw.artifact || 'unknown',+ gate: raw.gate || 'none',+ decision: raw.decision || 'none',+ scope: raw.scope || 'unknown',+ recovery: raw.recovery || 'unknown',+ recoveryDecision: raw.recoveryDecision || 'none',+ artifactState: raw.artifactState || 'unknown',+ approvalStatus: raw.approvalStatus || 'unknown',+ errorCode: raw.errorCode || '',+ };++ assertEnum('line', input.line, VALID.line);+ assertEnum('artifact', input.artifact, VALID.artifact);+ assertEnum('gate', input.gate, VALID.gate);+ assertEnum('decision', input.decision, VALID.decision);+ assertEnum('scope', input.scope, VALID.scope);+ assertEnum('recovery', input.recovery, VALID.recovery);+ assertEnum('recovery-decision', input.recoveryDecision, VALID.recoveryDecision);+ assertEnum('artifact-state', input.artifactState, VALID.artifactState);+ assertEnum('approval-status', input.approvalStatus, VALID.approvalStatus);+ const lineOps = lineOperations(input.line, input.artifact);++ if (input.errorCode === 'E_VISUAL_REVISION_NOT_REQUIRED') {+ return result({+ nextAction: 'edit_current_cycle',+ authorities: ['edit_current_artifact'],+ allowedOps: lineOps.edit,+ prohibitedOps: ['emit_form', ...NO_VISUAL_RESET],+ reason: 'Native state says the current visual QA cycle is not exhausted.',+ });+ }++ if (input.errorCode === 'E_VISUAL_REVISION_EXPLICIT_AUTHORIZATION_REQUIRED') {+ if (input.recovery === 'available') {+ return result({+ nextAction: 'open_visual_recovery',+ form: { fields: ['visual_recovery_decision'] },+ prohibitedOps: ['edit_files', 'composition.begin_visual_revision'],+ reason: 'Recovery was independently established by the latest native result.',+ });+ }+ if (input.recovery === 'unknown') {+ return result({+ nextAction: 'query_status',+ allowedOps: [lineOps.status],+ prohibitedOps: ['emit_form', 'edit_files', 'composition.begin_visual_revision'],+ reason: 'An authorization error cannot establish recovery availability.',+ });+ }+ return result({+ nextAction: 'edit_current_cycle',+ authorities: ['edit_current_artifact'],+ allowedOps: lineOps.edit,+ prohibitedOps: ['emit_form', ...NO_VISUAL_RESET],+ reason: 'Status says recovery is not required; the failed reset call was invalid.',+ });+ }++ if (input.recoveryDecision === 'pause') {+ return result({ nextAction: 'pause', reason: 'The user paused visual recovery.' });+ }++ if (input.recoveryDecision === 'new_visual_revision') {+ if (input.recovery === 'available') {+ return result({+ nextAction: 'begin_visual_revision',+ authorities: ['reset_visual_qa_cycle'],+ allowedOps: ['composition.begin_visual_revision'],+ reason: 'The current user authorized a reset that the latest native result offered.',+ });+ }+ if (input.recovery === 'unknown') {+ return result({+ nextAction: 'query_status',+ allowedOps: [lineOps.status],+ prohibitedOps: ['emit_form', 'edit_files', 'composition.begin_visual_revision'],+ reason: 'A recovery decision cannot be consumed until availability is verified.',+ });+ }+ return result({+ nextAction: 'edit_current_cycle',+ authorities: ['edit_current_artifact'],+ allowedOps: lineOps.edit,+ prohibitedOps: ['emit_form', ...NO_VISUAL_RESET],+ reason: 'The cycle is not exhausted, so ordinary editing continues without a reset.',+ });+ }++ if (input.decision !== 'revise'+ && input.approvalStatus === 'approved'+ && input.artifactState === 'unchanged') {+ return result({+ nextAction: 'continue_from_existing_approval',+ authorities: ['consume_existing_approval'],+ prohibitedOps: ['emit_form'],+ reason: 'The same artifact signature is already approved.',+ });+ }++ if (input.decision === 'revise') {+ if (input.scope === 'unknown') {+ return result({+ nextAction: 'classify_revision_scope',+ authorities: ['inspect_requested_change'],+ prohibitedOps: ['emit_form', 'composition.begin_visual_revision'],+ reason: 'A revise decision grants edit intent, but signed-payload impact must be classified.',+ });+ }+ if (input.scope === 'gate_b_payload') {+ if (input.recovery === 'unknown') {+ return result({+ nextAction: 'query_status',+ authorities: ['edit_current_artifact'],+ allowedOps: [lineOps.status],+ prohibitedOps: ['emit_form', 'edit_files', 'composition.begin_visual_revision'],+ reason: 'Resolve recovery availability before choosing one Gate B or combined form.',+ });+ }+ if (input.recovery === 'available') {+ return result({+ nextAction: 'open_combined_amendment_and_recovery',+ authorities: ['edit_current_artifact'],+ form: { fields: ['gate_b_decision', 'visual_recovery_decision'] },+ prohibitedOps: ['edit_files', 'composition.begin_visual_revision'],+ reason: 'The change needs one Gate B re-sign and the exhausted cycle needs one reset.',+ });+ }+ return result({+ nextAction: 'open_gate_b_amendment',+ authorities: ['edit_current_artifact'],+ form: { fields: ['gate_b_decision'] },+ prohibitedOps: NO_VISUAL_RESET,+ reason: 'The requested revision changes the signed Gate B payload.',+ });+ }+ if (input.recovery === 'available') {+ return result({+ nextAction: 'open_visual_recovery',+ authorities: ['edit_current_artifact'],+ form: { fields: ['visual_recovery_decision'] },+ prohibitedOps: ['edit_files', 'composition.begin_visual_revision'],+ reason: 'Ordinary edit intent exists, but the exhausted QA cycle must be reset first.',+ });+ }+ if (input.recovery === 'unknown') {+ return result({+ nextAction: 'query_status',+ authorities: ['edit_current_artifact'],+ allowedOps: [lineOps.status],+ prohibitedOps: ['emit_form', 'composition.begin_visual_revision'],+ reason: 'Resolve native recovery state before editing or asking another question.',+ });+ }+ return result({+ nextAction: 'edit_current_cycle',+ authorities: ['edit_current_artifact'],+ allowedOps: lineOps.edit,+ prohibitedOps: ['emit_form', ...NO_VISUAL_RESET],+ reason: 'The user already authorized a bounded revision and native recovery is not required.',+ });+ }++ if (input.decision === 'approve') {+ const sharedApprovals = {+ gate_a: ['lock_brief', 'lock_brief'],+ gate_c: ['approve_generation', 'production.approve_generation'],+ };+ const compositionApprovals = {+ gate_b: ['approve_plan', 'composition.approve_plan'],+ preview: ['approve_preview', 'composition.approve_preview'],+ gate_d: ['approve_draft', 'composition.approve_draft'],+ };+ const productionApprovals = {+ gate_b: ['approve_plan', 'production.approve_plan'],+ gate_d: ['accept_draft', 'continue_line_delivery'],+ };+ const artifact = input.artifact === 'unknown'+ ? (input.line === 'compose' ? 'composition' : 'production')+ : input.artifact;+ const mapped = sharedApprovals[input.gate]+ || (artifact === 'composition' ? compositionApprovals[input.gate] : productionApprovals[input.gate]);+ if (!mapped) throw new Error('approve requires a named gate');+ return result({+ nextAction: mapped[0],+ authorities: [`approve_${input.gate}`],+ allowedOps: [mapped[1]],+ prohibitedOps: ['emit_form', ...NO_VISUAL_RESET],+ reason: 'The current real user message explicitly approved the displayed gate artifact.',+ });+ }++ if (input.recovery === 'available') {+ return result({+ nextAction: 'open_visual_recovery',+ form: { fields: ['visual_recovery_decision'] },+ prohibitedOps: ['edit_files', 'composition.begin_visual_revision'],+ reason: 'The latest native result explicitly offered exhausted-cycle recovery.',+ });+ }++ return result({+ nextAction: 'follow_native_state',+ prohibitedOps: ['emit_form', ...NO_VISUAL_RESET],+ reason: 'No new authority is required; follow the current native next action.',+ });+}++if (import.meta.url === `file://${process.argv[1]}`) {+ try {+ const args = parseArgs(process.argv.slice(2));+ process.stdout.write(`${JSON.stringify(resolveTransition(args), null, 2)}\n`);+ } catch (error) {+ process.stderr.write(`${error.message}\n`);+ process.exitCode = 2;+ }+}diff --git a/resources/builtin/marketplace/agents/79df9cc89f5f/skills/stage-compose/SKILL.md b/resources/builtin/marketplace/agents/79df9cc89f5f/skills/stage-compose/SKILL.mdindex f0af3246..e3b12403 100644--- a/resources/builtin/marketplace/agents/79df9cc89f5f/skills/stage-compose/SKILL.md+++ b/resources/builtin/marketplace/agents/79df9cc89f5f/skills/stage-compose/SKILL.md@@ -13,46 +13,27 @@ How to author an Orkas HTML composition and turn it into a video. Host-neutral:For visual direction, apply `frontend-design` before writing `manifest.art_direction`. If the user provides a DESIGN.md, brand guide, reference site, screenshot, Figma notes, or explicit named style, apply `design-system-importer` to convert that source into compact VideoStudio tokens. `composition-design-review` is a bounded post-draft sanity check for design-sensitive work; it must not replace `--op draft` QA or create an open-ended redesign loop.-COMPOSE approval forms are also a host protocol, not free-form UI copy. Use a select field with id `gate_b_decision` at Gate B, `preview_decision` at the HTML Preview Gate, and `gate_d_decision` at Gate D. Each select must use `approve` for approval and `revise` for revision; keep free-text feedback in a separate `adjustments` field. Visual QA exhaustion is the one recovery form: use select id `visual_recovery_decision` with `new_visual_revision` to preserve the approved plan/narration and start another visual-only cycle. Never invent a replacement id such as `gate_b_reconfirm`, `gate_b_runtime_approval`, or another visual reset id on a resumed turn. The host still accepts legacy semantic ids for approval recovery, but new forms must use this canonical contract.+COMPOSE approval forms are also a host protocol, not free-form UI copy. Use a select field with id `gate_b_decision` at Gate B, `preview_decision` at the HTML Preview Gate, and `gate_d_decision` at Gate D. Each select must use `approve` for approval and `revise` for revision; keep free-text feedback in a separate `adjustments` field. Only when `gate-control` returns a visual-recovery form, use select id `visual_recovery_decision` with `new_visual_revision`; this skill does not decide that the form is needed. Never invent a replacement id such as `gate_b_reconfirm`, `gate_b_runtime_approval`, or another visual reset id on a resumed turn. The host still accepts legacy semantic ids for approval recovery, but new forms must use this canonical contract.AUTO child compositions are the one Gate B inheritance path. They must use local `script.md`/`shotlist.json`/manifest artifacts derived from the signed parent segment's `composition_plan`, then call `composition.approve_plan` with `plan_path` and `segment_id`. The host compares duration, language, silence ownership, scene ids, approved copy, narration text, and semantic roles against the current parent EDL signature. On success continue to doctor/prepare without a child Gate B; on mismatch return to the single parent EDL Gate B rather than looping a child confirmation.-Visual recovery is a strict state machine, not a general redesign prompt:+Visual QA repair is a strict state machine, not a general redesign prompt. `gate-control` alone owns any user authorization transition:- **Fatal inspect blocker:** repair the reported runtime/structural contract and rerun `composition.inspect`. Until the fatal count is zero, do not call snapshot, preview approval, or draft.- **Visual review required:** when inspect returns `ok:true`, `visual_review_required:true`, and `preview_capture_allowed:true`, call `composition.snapshot` before editing so the user and the repair loop receive contact-sheet evidence. High-confidence visual blockers may produce a preview but cannot mint preview approval or advance to draft; advisories continue normally.- **Passing snapshot with a visible contact-sheet mismatch:** use the returned contact sheet and scene midpoint evidence, repair only the mismatched scene, then rerun inspect + snapshot. Do not draft or approve the stale preview. Other scenes and the approved direction remain frozen.- **Snapshot semantic failure:** use the returned `preview_qa`/`frame_evidence`, repair the implicated frame/scene so the canonical manifest or HTML signature changes, then rerun inspect + snapshot. Never retry snapshot with an unchanged signature, call `composition.approve_preview`, or draft. Stop on the native repair-budget error.-- **Exhausted visual QA cycle:** when the native result says `visual_revision_recovery_available:true`, do not edit files. Show the preserved artifacts and the canonical `visual_recovery_decision` form, then stop. In the submitted `new_visual_revision` turn, call `composition.begin_visual_revision` first. Only a successful host transition permits the next localized edit; it archives the old cycle, preserves Gate B/script/shotlist/manifest/narration, invalidates preview/draft, and returns to lint -> inspect -> snapshot. Never claim to reset a cycle through plan state or a file edit.+- **Exhausted visual QA cycle:** pass the exact native result to `gate-control` and obey its resolver. This skill does not decide whether a form or `composition.begin_visual_revision` is allowed.-Each recovery step has one next operation and one bounded repair target. A later passing snapshot may open the preview gate; prohibitions above apply while the reported blocker or stale signature still exists.+Each QA repair step has one next operation and one bounded repair target. A later passing snapshot may open the preview gate; prohibitions above apply while the reported blocker or stale signature still exists.-## Post-approval amendment de-duplication+## Post-gate authorization and revisions-A user-requested edit after Gate B, Preview, or Draft must produce **at most one approval form for one bounded change**. Do not make the user approve a visual recovery and then approve the same wording/layout change again at Gate B.+`gate-control` is the single canonical authorization and state-transition policy for Gate B, Preview, Gate D, signed amendments, and exhausted visual-QA recovery. On every gate submission or post-gate edit, read that compact skill and run its bundled resolver before calling a production tool or emitting another form. This skill owns COMPOSE artifacts and QA craft; it does not redefine gate authorization.-Before opening any post-approval form, call `composition.status` and classify both the native state and the requested patch:+For COMPOSE scope classification, styling-only changes to HTML/CSS/SVG/layout/motion/palette/assets stay `visual_only`. Changes to signed delivery fields, approved copy, narration, timing, language, source mappings, semantic roles, or narration intent are `gate_b_payload`. When uncertain, inspect the requested files and resolve scope without asking a technical confirmation.-1. **Visual-only patch:** HTML/CSS/SVG/layout/motion changes that do not change `script.md`, `shotlist.json`, or the manifest's canonical Gate B payload (`composition` delivery fields, scene `approved_copy`, `narration_text`, `narration_refs`, `source_shots`, `roles`, or `audio.narration_intent`). Continue the existing repair cycle and edit directly. Do not call `composition.begin_visual_revision` and do not ask for recovery authorization unless the latest native result itself returned `visual_revision_recovery_available:true`.-2. **Gate B payload patch:** casing, punctuation, wording, language, timing, narration, source mapping, roles, or delivery changes that alter the signed payload. Present one amendment summary and one form containing the canonical `gate_b_decision` field. If clarification is needed, put the clarification fields in this same form and label approval as applying **and signing** the selected bounded amendment. Do not first collect the same choice in a separate form and then ask for a technical re-sign.-3. **Gate B payload patch plus exhausted visual QA:** use one combined form containing both `gate_b_decision=approve|revise` and `visual_recovery_decision=new_visual_revision|pause`, plus any bounded adjustment fields. One submission authorizes the whole stated patch; never emit two sequential forms for it.--When the native HTML Preview Gate will still be required, amendment/Gate B copy must not promise that this approval immediately re-renders the video. Say exactly what the turn authorizes: apply and sign the bounded amendment, run native QA, and generate a fresh reviewable preview. Also state that a passing preview is shown in one later HTML Preview Gate before rendering. The preview gate reviews a newly generated artifact; it is not another approval of the same script or amendment.--In the submitted combined/amendment turn, perform operations in this order:--1. Call `composition.begin_visual_revision` only when that same form included `visual_recovery_decision=new_visual_revision` **and** the immediately preceding native result reported recovery available.-2. Apply exactly the amendment described by the form response, synchronizing script/shotlist/manifest/HTML only where the selected change requires it.-3. If the Gate B payload changed, call `composition.approve_plan` **after** the files are updated, while the same real user turn still carries `gate_b_decision=approve`.-4. Then call `composition.doctor` or `composition.reconcile` as required, followed by lint/inspect/snapshot. Draft only when no Preview Gate is required or after a later explicit preview approval. Never call lint before re-signing a changed Gate B payload, because the predictable `E_GATE_B_ARTIFACT_CHANGED` result must not be converted into another user confirmation.--If snapshot creates a fresh preview, show that artifact and emit exactly one canonical `preview_decision` form, titled and described as the **only remaining confirmation before render**, then stop. Native preview approval must come from a later real user turn, so never imply that the earlier Gate B or visual-recovery approval can approve an unseen future preview. After a passing snapshot, do not reopen visual recovery or Gate B unless the user selects `revise` and requests a new artifact-changing amendment.--For an in-flight conversation that already entered the old split-form sequence, converge instead of alternating: after `composition.begin_visual_revision` succeeds, finish the bounded patch and open Gate B at most once if its signed payload changed; after `composition.approve_plan` succeeds, run QA and advance only to the single Preview Gate. Never ask for visual recovery again merely because Gate B was signed in a later turn.--`composition.submit_design_review` returning `status:"repair"` with `next_action:"repair_visuals_then_composition.reconcile"` is not visual-cycle exhaustion. Follow that next action in the current cycle. Never call `composition.begin_visual_revision` merely because a draft design review requested a localized repair.--If a form submission already contained `gate_b_decision=approve` for the exact bounded patch that was then applied, `E_GATE_B_ARTIFACT_CHANGED` means the agent missed the required same-turn `composition.approve_plan`; call it in that turn when still possible, rather than asking the user to approve the identical patch again.+After the resolver authorizes a normal revision, edit the bounded files, call `composition.reconcile`, and continue inspect/snapshot. Call `composition.begin_visual_revision` only when the resolver returns `next_action:"begin_visual_revision"`; ordinary Preview/Gate D feedback, design-review repair, `E_VISUAL_REVISION_NOT_REQUIRED`, and remaining repair passes never do.## Fast COMPOSE runbook@@ -62,9 +43,9 @@ Before Gate B, make the candidate plan internally executable; after approval, ke2. Gate B `shotlist.json` must lock `target_duration_seconds`, `video_language`, `audio_mode`, `caption_mode`, and `music_mode`; silence, no captions, and no music must be explicit values rather than omissions. For narration, first call `video_studio` with `op:"speech.capabilities"`, choose only one returned `route_ref` + `voice_ref` whose native or verified supported locale matches `video_language`, and copy its `display_name` with the exact BCP-47 `language` and a natural `speed` into the manifest—never use a candidate non-native language and never invent or recall a provider voice id. Before showing Gate B, write the candidate schema-version 2 source of truth `project/composition/composition-manifest.json` from the same script/shotlist. It owns canvas, immutable target duration, fps, video language, scene windows, complete approved `source_shots` mappings, semantic roles, the narration intent, audio ownership, and `art_direction`. For standalone narrated work, put the complete candidate words in each scene's `narration_text` and keep pre-production audio at `owner:"none"`, `tracks:[]`, plus the selected `narration_intent`. For visual-only/SFX-only COMPOSE, keep `narration_text` empty and say at the gate that no voiceover will be generated. Do not create an audio file or a second structural contract yet.3. For standalone narration, run the free `composition.check_narration_fit` against that candidate manifest before opening Gate B. Open Gate B only when it returns `gate_b_ready:true`. When it returns `over` or `under`, revise `script.md`, `shotlist.json`, and matching scene `narration_text` together to the returned `suggested_units`, then run the free check again without asking the user. After a measured TTS mismatch, the check automatically uses the persisted voice/speed calibration; never let a later generic estimate reverse that measured recommendation. This is an internal timing repair, not a new creative gate: when the free check returns `approval_inherited:true` and `gate_b_required:false`, the native state has carried the existing Gate B approval to the bounded revision, archived stale audio, and returned to `manifest_ready`; call `composition.prepare` and continue without showing Gate B again. If it returns `repair_authorization_status:"rejected"`, only then treat the change as a new plan requiring Gate B. Allow at most two free revision checks for one measured mismatch; if they still do not converge, report the deterministic fit result as a blocker instead of opening Gate B repeatedly or sending another speech request.4. On every new/resumed production turn, call canonical `composition.status`; if files and state disagree, call `composition.reconcile` and follow the returned `next_allowed_ops`. Immediately after explicit Gate B approval, call `composition.approve_plan` to sign `script.md`, `shotlist.json`, and the already-checked manifest narration payload. Then call canonical `composition.doctor` before any paid operation and fix missing required capabilities. Call `composition.prepare` only after the Gate B signature is current. The native runtime validates the manifest and creates the protected composition/clip/paused-GSAP scaffold. If standalone narration is needed, immediately call `composition.materialize_narration` while production state is `scaffold_ready`. It reuses the same calibrated fit policy, synthesizes once, persists a recoverable transaction plus measured voice calibration, records hashes/measured duration, writes per-scene `narration-map.json`, retimes the canonical manifest, and regenerates the untouched scaffold. A resumed call recovers matching audio without another paid request. Never use generic `generate_speech` for standalone COMPOSE narration.-5. Only after narration materialization (or immediately after prepare for an intentionally silent composition), model-author the visual content, CSS, SVG, and deterministic tweens inside the scaffold. Use the HyperFrames-style discipline from `frontend-design`: first confirm the visual identity and `VisualDirectionV1` in `manifest.art_direction`; then author each scene's resolved/hero frame as static HTML/CSS/SVG using the declared video scale, depth layers, typography register, motion verbs, and rhythm pattern; only after the resolved layout is readable add GSAP entrances, reveals, and transitions into that layout. Do not begin with hidden/offscreen animated start states, generic placeholder diagrams, decorative emoji/icons, centered equal-weight layouts, or web-scale type. Then run `composition.inspect`; if it reports blocking design-contract errors, repair the manifest art direction first and rerun inspect before snapshot or draft. Inspect findings are always host-persisted. Retry only after the canonical manifest or HTML signature changes, and allow at most two distinct repair passes across the shared inspect/snapshot QA cycle; advisory or duplicated findings do not consume a pass. `E_INSPECT_RETRY_NO_CHANGE` is terminal until inputs change. `E_VISUAL_REPAIR_BUDGET_EXCEEDED` is terminal for the current cycle: when recovery is available, open the canonical visual recovery form and stop, then call `composition.begin_visual_revision` before editing in the explicit recovery turn. `E_INSPECT_ALREADY_PASSED` means follow the prior next action without rerunning inspect. Do not recreate root timing, media playback, vendor setup, or timeline registration with ad-hoc code. Never install dependencies or start a browser, HTTP server, watcher, Puppeteer, Playwright, or headless Chrome for QA; native `video_studio` operations own that runtime. This is internal work except for the explicit visual-cycle recovery gate.+5. Only after narration materialization (or immediately after prepare for an intentionally silent composition), model-author the visual content, CSS, SVG, and deterministic tweens inside the scaffold. Use the HyperFrames-style discipline from `frontend-design`: first confirm the visual identity and `VisualDirectionV1` in `manifest.art_direction`; then author each scene's resolved/hero frame as static HTML/CSS/SVG using the declared video scale, depth layers, typography register, motion verbs, and rhythm pattern; only after the resolved layout is readable add GSAP entrances, reveals, and transitions into that layout. Do not begin with hidden/offscreen animated start states, generic placeholder diagrams, decorative emoji/icons, centered equal-weight layouts, or web-scale type. Then run `composition.inspect`; if it reports blocking design-contract errors, repair the manifest art direction first and rerun inspect before snapshot or draft. Inspect findings are always host-persisted. Retry only after the canonical manifest or HTML signature changes, and allow at most two distinct repair passes across the shared inspect/snapshot QA cycle; advisory or duplicated findings do not consume a pass. `E_INSPECT_RETRY_NO_CHANGE` is terminal until inputs change. `E_VISUAL_REPAIR_BUDGET_EXCEEDED` is terminal for the current cycle; pass the exact result to `gate-control` and obey its resolver instead of deciding a form here. `E_INSPECT_ALREADY_PASSED` means follow the prior next action without rerunning inspect. Do not recreate root timing, media playback, vendor setup, or timeline registration with ad-hoc code. Never install dependencies or start a browser, HTTP server, watcher, Puppeteer, Playwright, or headless Chrome for QA; native `video_studio` operations own that runtime. QA repair is internal work; `gate-control` alone decides whether a user recovery gate exists.6. Open the HTML Preview Gate before rendering when target duration >= 20s or scene count >= 3; the native tool enforces this so short multi-scene work cannot pass only structural QA. Also use it for shorter work when render rework is likely expensive because of dense text, complex SVG/GSAP, many branded/supplied assets, or a prior draft failure. Skip it only for genuinely short/simple work: target duration < 20s, scene count <= 2, no narration/timing complexity, and no obvious visual-risk signal.-7. If the HTML Preview Gate is needed, run `composition.inspect` and `composition.snapshot` to `project/composition/preview/first-frame.png`. Snapshot runs the same fail-closed preflight first, captures at least one semantic midpoint for every scene plus hook/payoff evidence, and returns distinct `first_frame` and `contact_sheet` fields. The system publishes `contact_sheet` as the visible review artifact even while the approval form is open; show and discuss that multi-frame sheet as the primary preview, not the raw HTML or compatibility `path`, then emit the canonical `preview_decision` form and stop. HTML is only a secondary/debug source. Before opening the preview gate, look at the contact sheet as a design checkpoint: if a representative scene clearly fails its own `hero_visual`/`depth_layers`, reads as a generic slide, substitutes labels for visuals, starts blank, or uses decorative emoji/icons as the main graphic language, make one localized preview-stage repair to `manifest.art_direction` or `index.html`, rerun inspect/snapshot, and then open the gate. If snapshot fails, use the returned inline `preview_qa` / `frame_evidence` or `findings_path`; do not rerun snapshot for the same composition artifact signature before a manifest or HTML repair changes it. `E_SNAPSHOT_RETRY_NO_CHANGE` means change inputs before retrying; `E_VISUAL_REPAIR_BUDGET_EXCEEDED` means open the canonical recovery form when offered and stop—never reopen Gate B or build another QA runtime. `E_SNAPSHOT_ALREADY_PASSED` means show the existing contact sheet and open the preview gate. On a later explicit user approval, call `composition.approve_preview` first; only its success permits `composition.draft`. A question, revision request, or mere turn boundary is not approval. On revise, modify the manifest, `manifest.art_direction`, or visual HTML as appropriate, run `composition.reconcile` when protected timing/audio attributes changed, rerun inspect/snapshot, and reopen the gate.+7. If the HTML Preview Gate is needed, run `composition.inspect` and `composition.snapshot` to `project/composition/preview/first-frame.png`. Snapshot runs the same fail-closed preflight first, captures at least one semantic midpoint for every scene plus hook/payoff evidence, and returns distinct `first_frame` and `contact_sheet` fields. The system publishes `contact_sheet` as the visible review artifact even while the approval form is open; show and discuss that multi-frame sheet as the primary preview, not the raw HTML or compatibility `path`, then emit the canonical `preview_decision` form and stop. HTML is only a secondary/debug source. Before opening the preview gate, look at the contact sheet as a design checkpoint: if a representative scene clearly fails its own `hero_visual`/`depth_layers`, reads as a generic slide, substitutes labels for visuals, starts blank, or uses decorative emoji/icons as the main graphic language, make one localized preview-stage repair to `manifest.art_direction` or `index.html`, rerun inspect/snapshot, and then open the gate. If snapshot fails, use the returned inline `preview_qa` / `frame_evidence` or `findings_path`; do not rerun snapshot for the same composition artifact signature before a manifest or HTML repair changes it. `E_SNAPSHOT_RETRY_NO_CHANGE` means change inputs before retrying; pass any `E_VISUAL_REPAIR_BUDGET_EXCEEDED` result to `gate-control` rather than deciding a recovery form in this skill. `E_SNAPSHOT_ALREADY_PASSED` means show the existing contact sheet and open the preview gate. On a later explicit user approval, call `composition.approve_preview` first; only its success permits `composition.draft`. A question, revision request, or mere turn boundary is not approval. On revise, use `gate-control`, then modify the manifest, `manifest.art_direction`, or visual HTML as appropriate, run `composition.reconcile` when protected timing/audio attributes changed, rerun inspect/snapshot, and reopen the gate.8. Run `composition.draft`. The production path reuses the canonical manifest, fail-closed preflight, runtime seek probe, render, audio/media QA, semantic sampled-frame QA, and one report. Structural errors never spend a full-render attempt.9. If draft fails, repair the highest structural source (`composition-manifest.json` first, then its art direction/mapped content, then visual HTML) and rerun within the bounded repair budget. Stop when the budget is exhausted.10. If draft returns `ok: true` with `design_review_required: true`, read `composition-design-review`, inspect its contact sheet/frame evidence, and call `composition.submit_design_review` with a structured `passed`, `repair`, or `blocked` verdict. Gate D remains host-blocked until the verdict is `passed`. A `repair`/`blocked` verdict is signature-bound: repair, reconcile, and render a new draft before it can pass. When `gate_d_ready: true`, freeze the manifest, HTML, assets, and narration and open Gate D. The system publishes the draft mp4 as the visible Gate D review artifact; show the video plus the QA/design-review headline, emit the canonical `gate_d_decision` form, and stop. On a later explicit user approval, call `composition.approve_draft`; only its success permits `composition.export`.diff --git a/test/main/util/builtin-resource-gate.test.ts b/test/main/util/builtin-resource-gate.test.tsindex d67c9d44..31a2686c 100644--- a/test/main/util/builtin-resource-gate.test.ts+++ b/test/main/util/builtin-resource-gate.test.ts@@ -41,7 +41,7 @@ describe('builtin-resource-gate', () => {expect(gate.verifyBuiltinRoot(root, { allowIgnoredJunk: true })).toBe('resource:builtin:manifest-v1');- expect(manifest.files).toHaveLength(127);+ expect(manifest.files).toHaveLength(129);expect(manifest.inventory.system_skills).toHaveLength(5);expect(manifest.inventory.marketplace_agents).toHaveLength(4);expect(manifest.inventory.marketplace_skills).toHaveLength(4);diff --git a/test/main/util/video-agent-resources.test.ts b/test/main/util/video-agent-resources.test.tsindex 737c2e0d..b904cc0a 100644--- a/test/main/util/video-agent-resources.test.ts+++ b/test/main/util/video-agent-resources.test.ts@@ -1,5 +1,6 @@import * as fs from 'node:fs';import * as path from 'node:path';+import { execFileSync } from 'node:child_process';import { describe, expect, it } from 'vitest';@@ -13,6 +14,14 @@ const VIDEO_STUDIO_ROOT = path.join();const read = (...segments: string[]) => fs.readFileSync(path.join(VIDEO_STUDIO_ROOT, ...segments), 'utf8');+const resolveGateTransition = (args: string[]) => JSON.parse(execFileSync(+ process.execPath,+ [+ path.join(VIDEO_STUDIO_ROOT, 'skills', 'gate-control', 'scripts', 'resolve-transition.mjs'),+ ...args,+ ],+ { encoding: 'utf8' },+)) as Record<string, any>;describe('open-source VideoStudio resources', () => {it('preserves natural English casing and bounds all-caps accents', () => {@@ -31,4 +40,118 @@ describe('open-source VideoStudio resources', () => {expect(compositionDesignReview).toMatch(/two or more English text roles.*all caps/i);expect(standards).toMatch(/Preserve approved English casing/i);});++ it('uses one canonical gate-control policy instead of line-specific confirmation patches', () => {+ const agent = JSON.parse(read('agent.json')) as { skill_list?: string[]; standards?: string[] };+ const stageCompose = read('skills', 'stage-compose', 'SKILL.md');+ const gateControl = read('skills', 'gate-control', 'SKILL.md');+ const standards = (agent.standards ?? []).join('\n');++ expect(agent.skill_list).toContain('gate-control');+ expect(stageCompose).toMatch(/gate-control.*single canonical authorization and state-transition policy/is);+ expect(gateControl).toMatch(/Authority is not the same as recovery/);+ expect(gateControl).toMatch(/`revise` is already edit authorization/i);+ expect(gateControl).toMatch(/An authorization error cannot establish recovery availability|does not by itself justify a form/i);+ expect(gateControl).toMatch(/One user decision may produce at most one follow-up authorization form/i);+ expect(standards).toMatch(/read gate-control and run its bundled transition resolver/i);+ expect(standards).toMatch(/single authorization source across COMPOSE, AUTO, GENERATE, and EDIT/i);+ expect(standards).toMatch(/no form or composition\.begin_visual_revision call is allowed unless the resolver returns it/i);+ });++ it('resolves post-gate authorization traces without duplicate recovery forms', () => {+ const directGateDRevision = resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'gate_d', '--decision', 'revise', '--scope', 'visual_only', '--recovery', 'not_available',+ ]);+ expect(directGateDRevision).toMatchObject({ next_action: 'edit_current_cycle', form: null });+ expect(directGateDRevision.prohibited_ops).toContain('composition.begin_visual_revision');+ expect(directGateDRevision.prohibited_ops).toContain('emit_form');++ expect(resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'preview', '--decision', 'revise', '--scope', 'visual_only', '--recovery', 'not_available',+ ])).toMatchObject({ next_action: 'edit_current_cycle', form: null });++ expect(resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'gate_d', '--decision', 'revise', '--scope', 'gate_b_payload', '--recovery', 'not_available',+ ])).toMatchObject({+ next_action: 'open_gate_b_amendment',+ form: { fields: ['gate_b_decision'] },+ });++ expect(resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'preview', '--decision', 'revise', '--scope', 'gate_b_payload', '--recovery', 'available',+ ])).toMatchObject({+ next_action: 'open_combined_amendment_and_recovery',+ form: { fields: ['gate_b_decision', 'visual_recovery_decision'] },+ });++ const unknownRecovery = resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'gate_d', '--decision', 'revise', '--scope', 'gate_b_payload', '--recovery', 'unknown',+ ]);+ expect(unknownRecovery).toMatchObject({ next_action: 'query_status', form: null });+ expect(unknownRecovery.prohibited_ops).toContain('emit_form');++ expect(resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'gate_d', '--decision', 'revise', '--scope', 'visual_only', '--recovery', 'unknown',+ '--error-code', 'E_VISUAL_REVISION_NOT_REQUIRED',+ ])).toMatchObject({ next_action: 'edit_current_cycle', form: null });++ const misleadingAuthError = resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'gate_d', '--decision', 'revise', '--scope', 'visual_only', '--recovery', 'unknown',+ '--error-code', 'E_VISUAL_REVISION_EXPLICIT_AUTHORIZATION_REQUIRED',+ ]);+ expect(misleadingAuthError).toMatchObject({ next_action: 'query_status', form: null });+ expect(misleadingAuthError.prohibited_ops).toContain('emit_form');++ expect(resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'none', '--decision', 'none', '--scope', 'none', '--recovery', 'available',+ '--recovery-decision', 'new_visual_revision',+ ])).toMatchObject({+ next_action: 'begin_visual_revision',+ form: null,+ allowed_ops: ['composition.begin_visual_revision'],+ });++ const existingApproval = resolveGateTransition([+ '--line', 'compose', '--artifact', 'composition',+ '--gate', 'preview', '--decision', 'none', '--scope', 'none', '--recovery', 'not_available',+ '--artifact-state', 'unchanged', '--approval-status', 'approved',+ ]);+ expect(existingApproval).toMatchObject({+ next_action: 'continue_from_existing_approval',+ form: null,+ });+ expect(existingApproval.prohibited_ops).toContain('emit_form');++ const editRevision = resolveGateTransition([+ '--line', 'edit', '--artifact', 'production',+ '--gate', 'gate_d', '--decision', 'revise', '--scope', 'visual_only', '--recovery', 'not_available',+ ]);+ expect(editRevision).toMatchObject({ next_action: 'edit_current_cycle', form: null });+ expect(editRevision.allowed_ops).toContain('run_line_native_qa');++ expect(resolveGateTransition([+ '--line', 'edit', '--artifact', 'production',+ '--gate', 'gate_b', '--decision', 'approve', '--scope', 'none', '--recovery', 'not_available',+ ])).toMatchObject({+ next_action: 'approve_plan',+ allowed_ops: ['production.approve_plan'],+ form: null,+ });++ const autoChildStatus = resolveGateTransition([+ '--line', 'auto', '--artifact', 'composition',+ '--gate', 'gate_d', '--decision', 'revise', '--scope', 'visual_only', '--recovery', 'unknown',+ '--error-code', 'E_VISUAL_REVISION_EXPLICIT_AUTHORIZATION_REQUIRED',+ ]);+ expect(autoChildStatus).toMatchObject({ next_action: 'query_status', form: null });+ expect(autoChildStatus.allowed_ops).toEqual(['composition.status']);+ });});