editorbrain 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/editorbrain.mjs +624 -231
- package/package.json +1 -1
- package/skill/editorbrain/AGENTS.md +9 -0
- package/skill/editorbrain/SKILL.md +37 -0
- package/skill/editorbrain/references/audio-production.md +22 -0
- package/skill/editorbrain/references/captions.md +6 -0
- package/skill/editorbrain/references/cloud-production.md +9 -0
- package/skill/editorbrain/references/mcp-studio-artifact.md +9 -0
- package/skill/editorbrain/references/memory-and-review.md +60 -1
- package/skill/editorbrain/references/onboarding.md +7 -0
- package/skill/editorbrain/references/personal-resources.md +59 -16
- package/skill/editorbrain/references/production-and-review.md +9 -0
- package/skill/editorbrain/references/production-continuity.md +12 -0
- package/skill/editorbrain/references/render-delivery.md +117 -0
- package/skill/editorbrain/references/storage-and-previews.md +9 -0
- package/skill/editorbrain/references/studio.md +1 -0
- package/skill/editorbrain/references/task-map.md +6 -0
- package/skill/editorbrain/references/workflow-evidence.md +9 -0
package/bin/editorbrain.mjs
CHANGED
|
@@ -3867,8 +3867,8 @@ var $ZodXor = /* @__PURE__ */ $constructor("$ZodXor", (inst, def) => {
|
|
|
3867
3867
|
});
|
|
3868
3868
|
};
|
|
3869
3869
|
});
|
|
3870
|
-
function getDiscriminatedOption(
|
|
3871
|
-
const internals =
|
|
3870
|
+
function getDiscriminatedOption(union3, value) {
|
|
3871
|
+
const internals = union3._zod;
|
|
3872
3872
|
let map2 = internals.bag.optionsMap;
|
|
3873
3873
|
if (!map2) {
|
|
3874
3874
|
map2 = discriminatorMap(internals.def);
|
|
@@ -15910,12 +15910,12 @@ function foldIntersection(json2) {
|
|
|
15910
15910
|
if (!unions.length) {
|
|
15911
15911
|
folded = foldObjects(allOf);
|
|
15912
15912
|
} else {
|
|
15913
|
-
const
|
|
15914
|
-
const keyword = UNION_KEYS.find((k) => Array.isArray(
|
|
15915
|
-
if (Object.keys(
|
|
15913
|
+
const union3 = unions[0];
|
|
15914
|
+
const keyword = UNION_KEYS.find((k) => Array.isArray(union3[k]));
|
|
15915
|
+
if (Object.keys(union3).length !== 1)
|
|
15916
15916
|
return;
|
|
15917
|
-
const rest = allOf.filter((m) => m !==
|
|
15918
|
-
const branches =
|
|
15917
|
+
const rest = allOf.filter((m) => m !== union3);
|
|
15918
|
+
const branches = union3[keyword].map((branch) => foldObjects([...rest, branch]));
|
|
15919
15919
|
if (branches.some((b) => !b))
|
|
15920
15920
|
return;
|
|
15921
15921
|
folded = { [keyword]: branches };
|
|
@@ -16214,8 +16214,8 @@ var contributors = {
|
|
|
16214
16214
|
function aggregateChecks(schema) {
|
|
16215
16215
|
const agg = {};
|
|
16216
16216
|
const def = schema._zod.def;
|
|
16217
|
-
const
|
|
16218
|
-
for (const ch of
|
|
16217
|
+
const list2 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
16218
|
+
for (const ch of list2)
|
|
16219
16219
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
16220
16220
|
const bag = schema._zod.bag;
|
|
16221
16221
|
if (bag.minimum !== void 0)
|
|
@@ -20124,6 +20124,49 @@ function validateStyleDecisions(value) {
|
|
|
20124
20124
|
return { schemaVersion: 1, projectId, decisions };
|
|
20125
20125
|
}
|
|
20126
20126
|
|
|
20127
|
+
// packages/core/src/preference-review.ts
|
|
20128
|
+
var interval = external_exports.tuple([external_exports.number().finite().min(0).max(86400), external_exports.number().finite().min(0).max(86400)]).refine((v) => v[1] > v[0]);
|
|
20129
|
+
var compositionEvidenceSchema = external_exports.object({
|
|
20130
|
+
schemaVersion: external_exports.literal(1),
|
|
20131
|
+
artifactSha256: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
20132
|
+
captions: external_exports.object({ speech: external_exports.array(interval).max(1e4), visible: external_exports.array(interval).max(1e4), treatment: external_exports.string().max(80).optional() }).strict().optional(),
|
|
20133
|
+
tokens: external_exports.record(external_exports.string().max(120), external_exports.union([external_exports.string().max(500), external_exports.number().finite(), external_exports.boolean()])).refine((v) => Object.keys(v).length <= 256).optional()
|
|
20134
|
+
}).strict();
|
|
20135
|
+
async function projectPreferenceChecks(resolved) {
|
|
20136
|
+
const captions = { enabled: resolved.mediaPreferences.captionsEnabled ?? null, treatment: resolved.mediaPreferences.editorialDelivery?.captionTreatment ?? null };
|
|
20137
|
+
return Promise.all([{ id: "editorbrain-captions", expected: captions }, { id: "editorbrain-brand-tokens", expected: { ...resolved.tokens } }].map(async (rule) => ({ ...rule, strength: "preferred", ruleSha256: await sha256(stableJson(rule)) })));
|
|
20138
|
+
}
|
|
20139
|
+
function union2(values) {
|
|
20140
|
+
const out = [];
|
|
20141
|
+
for (const [start3, end3] of [...values].sort((a, b) => a[0] - b[0])) {
|
|
20142
|
+
const last = out.at(-1);
|
|
20143
|
+
if (last && start3 <= last[1]) last[1] = Math.max(last[1], end3);
|
|
20144
|
+
else out.push([start3, end3]);
|
|
20145
|
+
}
|
|
20146
|
+
return out;
|
|
20147
|
+
}
|
|
20148
|
+
function covered(speech, visible) {
|
|
20149
|
+
const s = union2(speech), v = union2(visible), total = s.reduce((n, [a, b]) => n + b - a, 0);
|
|
20150
|
+
let overlap = 0;
|
|
20151
|
+
for (const [a, b] of s) for (const [c, d] of v) overlap += Math.max(0, Math.min(b, d) - Math.max(a, c));
|
|
20152
|
+
return { speechSeconds: total, captionedSpeechSeconds: overlap, ratio: total ? overlap / total : null };
|
|
20153
|
+
}
|
|
20154
|
+
async function reviewProjectPreferences(resolved, artifactSha256, input2) {
|
|
20155
|
+
const evidence = input2 === void 0 ? void 0 : compositionEvidenceSchema.parse(input2);
|
|
20156
|
+
if (evidence && evidence.artifactSha256 !== artifactSha256) throw new Error("Composition evidence must identify the exact verified artifact.");
|
|
20157
|
+
const checks = await projectPreferenceChecks(resolved);
|
|
20158
|
+
const results = checks.map((check2) => {
|
|
20159
|
+
const decision = resolved.styleDecisions?.decisions.find((d) => d.ruleId === check2.id && d.ruleSha256 === check2.ruleSha256);
|
|
20160
|
+
const caption = evidence?.captions, coverage = caption ? covered(caption.speech, caption.visible) : null;
|
|
20161
|
+
const differences = check2.id === "editorbrain-brand-tokens" && evidence?.tokens ? Object.entries(evidence.tokens).filter(([key, value]) => Object.hasOwn(resolved.tokens, key) && stableJson(value) !== stableJson(resolved.tokens[key])).map(([key]) => key) : [];
|
|
20162
|
+
const expected = resolved.mediaPreferences;
|
|
20163
|
+
const mismatch = check2.id === "editorbrain-captions" ? !!caption && (expected.captionsEnabled === false && caption.visible.length > 0 || expected.captionsEnabled === true && (coverage?.ratio !== null && coverage?.ratio !== void 0 && coverage.ratio < 0.9 || !!expected.editorialDelivery?.captionTreatment && caption.treatment !== expected.editorialDelivery.captionTreatment)) : differences.length > 0;
|
|
20164
|
+
const known = check2.id === "editorbrain-captions" ? !!caption && coverage?.ratio !== null : !!evidence?.tokens && Object.keys(evidence.tokens).some((key) => Object.hasOwn(resolved.tokens, key));
|
|
20165
|
+
return { ...check2, status: !known ? "not_evaluated" : mismatch ? decision ? "adaptation_recorded" : "decision_needed" : "consistent_with_declaration", ...check2.id === "editorbrain-captions" ? { coverage } : { differentTokens: differences }, ...decision ? { decision } : {}, evidence: "agent_declared_not_pixel_verified" };
|
|
20166
|
+
});
|
|
20167
|
+
return { results, decisionsPath: `videos/${resolved.project.id}/style-decisions.json`, automaticApproval: false, blocksDelivery: false, note: "Review the rendered result. Less than 90% declared speech coverage is a review hint, not a universal caption quota. Unknown is not pass. Record intentional adaptations with the displayed ruleId/ruleSha256; preserve explicit user constraints and creative judgment." };
|
|
20168
|
+
}
|
|
20169
|
+
|
|
20127
20170
|
// packages/core/src/style-policy.ts
|
|
20128
20171
|
async function projectStylePolicy(resolved) {
|
|
20129
20172
|
const document2 = resolved.styleProduction?.rules;
|
|
@@ -20142,6 +20185,7 @@ async function projectStylePolicy(resolved) {
|
|
|
20142
20185
|
styleId: resolved.project.style,
|
|
20143
20186
|
pinId: resolved.project.stylePin?.id ?? null,
|
|
20144
20187
|
contextSha256: await sha256(stableJson(resolved)),
|
|
20188
|
+
preferenceChecks: await projectPreferenceChecks(resolved),
|
|
20145
20189
|
rulesSha256: document2 ? await sha256(stableJson(document2)) : null,
|
|
20146
20190
|
hashBasis: "canonical_validated_document",
|
|
20147
20191
|
rules,
|
|
@@ -20792,7 +20836,7 @@ function parsePersonalResource(value) {
|
|
|
20792
20836
|
if (item.media !== null) {
|
|
20793
20837
|
const raw = object5(item.media, ["sha256", "mimeType", "bytes", "durationMs"]);
|
|
20794
20838
|
if (typeof raw.sha256 !== "string" || !hashPattern.test(raw.sha256) || typeof raw.mimeType !== "string" || !/^(video|audio|image)\/[a-z0-9.+-]{1,60}$/.test(raw.mimeType) || !Number.isSafeInteger(raw.bytes) || raw.bytes < 1 || raw.bytes > 100 * 1024 ** 3 || raw.durationMs !== null && (!Number.isSafeInteger(raw.durationMs) || raw.durationMs <= 0 || raw.durationMs > 36e6)) throw new Error("Invalid original media");
|
|
20795
|
-
media3 = raw;
|
|
20839
|
+
media3 = { sha256: raw.sha256, mimeType: raw.mimeType, bytes: raw.bytes, durationMs: raw.durationMs };
|
|
20796
20840
|
}
|
|
20797
20841
|
const sources = item.sources.map(source);
|
|
20798
20842
|
if (item.kind === "product-fact" && (!description || !sources.length || media3)) throw new Error("A product fact needs text and a source, not a media file");
|
|
@@ -21039,9 +21083,9 @@ function validateProjectCheckpoint(input2, projectId) {
|
|
|
21039
21083
|
throw new Error("Checkpoint updatedAt must be a valid ISO UTC timestamp.");
|
|
21040
21084
|
}
|
|
21041
21085
|
for (const key of ["done", "pending", "decisions"]) {
|
|
21042
|
-
const
|
|
21043
|
-
if (!Array.isArray(
|
|
21044
|
-
for (let index = 0; index <
|
|
21086
|
+
const list2 = value[key];
|
|
21087
|
+
if (!Array.isArray(list2) || list2.length > checkpointLimits.listItems) throw new Error(`Checkpoint ${key} must contain at most ${checkpointLimits.listItems} entries.`);
|
|
21088
|
+
for (let index = 0; index < list2.length; index++) text5(list2[index], checkpointLimits.textLength, `Checkpoint ${key} entry`);
|
|
21045
21089
|
}
|
|
21046
21090
|
if (value.next !== null) text5(value.next, checkpointLimits.nextLength, "Checkpoint next");
|
|
21047
21091
|
if (!Array.isArray(value.artifacts) || value.artifacts.length > checkpointLimits.artifacts) throw new Error(`Checkpoint artifacts must contain at most ${checkpointLimits.artifacts} files.`);
|
|
@@ -22190,7 +22234,8 @@ function getOnboardingGuide(intake) {
|
|
|
22190
22234
|
},
|
|
22191
22235
|
updates: "Omit a field to preserve its value. Use null to clear an optional profile field, an individual visualTaste/editorialDelivery field, a token, defaultLanguage or an audio preference. Use an empty string/list to clear an ordinary profile or identity field; identity.name must remain nonempty. Clearing is not disabling: use audio none, captions Sin subt\xEDtulos or ctaGoal none to exclude them. A new brand requires identity.name and identity.description.",
|
|
22192
22236
|
visualCatalog: "Use list_media_styles/get_media_style for the same image and animation choices as web. Product demos orient taste; inspect the edited-video library before editing.",
|
|
22193
|
-
advanced: "Existing references, pronunciation/glossary, assets and detailed audio/tool settings are preserved. They are not required onboarding questions. Configure with their dedicated editors/tools when requested."
|
|
22237
|
+
advanced: "Existing references, pronunciation/glossary, assets and detailed audio/tool settings are preserved. They are not required onboarding questions. Configure with their dedicated editors/tools when requested.",
|
|
22238
|
+
glossary: { optional: true, blocking: false, fields: ["language.glossary", "language.doNotTranslate"], suggestion: "Optional, never required for readiness: if the content names products, tools or people that speech recognition may misspell, offer once to list their exact spelling. Tempo sends these brand terms as transcription key terms. Skip in autonomous question mode; send the complete list, keeping existing entries." }
|
|
22194
22239
|
},
|
|
22195
22240
|
interactionPreview: { ...editingInteraction(intake?.profile?.questionMode ?? void 0, intake?.accountSetup?.reviewMode), basis: "draft-not-saved" },
|
|
22196
22241
|
consultation: { options: questionModeOptions, field: "profile.questionMode", ...resolveQuestionPolicy(intake?.profile?.questionMode ?? void 0) },
|
|
@@ -22319,6 +22364,39 @@ function checkSfxCues(audio, input2) {
|
|
|
22319
22364
|
return { passed: issues.length === 0, issues, warnings, policy, cueCount: cues.length, omissionReason, densityReview: policy.density === "none" && !cues.length ? "no_added_cues" : "editorial_review_required", scope: "Declared cue plan only; does not inspect or certify audio, rights, density fit or use of the selected files. Run production audio-check and listen to the final render." };
|
|
22320
22365
|
}
|
|
22321
22366
|
|
|
22367
|
+
// packages/core/src/memory-conflicts.ts
|
|
22368
|
+
var memoryPreferenceValues = {
|
|
22369
|
+
captionsEnabled: [true, false],
|
|
22370
|
+
captionTreatment: ["clean", "word-highlight", "karaoke", "boxed"],
|
|
22371
|
+
musicIntensity: ["none", "subtle", "present"],
|
|
22372
|
+
sfxDensity: ["none", "sparse", "moderate", "dense"],
|
|
22373
|
+
orientation: ["portrait", "landscape", "square"]
|
|
22374
|
+
};
|
|
22375
|
+
function memoryIntentIssues(value) {
|
|
22376
|
+
if (value === void 0) return [];
|
|
22377
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return ["Invalid memory preference intent"];
|
|
22378
|
+
const v = value;
|
|
22379
|
+
return Object.keys(v).some((k) => !["field", "value"].includes(k)) || !Object.hasOwn(memoryPreferenceValues, String(v.field)) || !memoryPreferenceValues[v.field].includes(v.value) ? ["Memory preferenceIntent requires a supported field and value"] : [];
|
|
22380
|
+
}
|
|
22381
|
+
function memoryPreferenceConflicts(entry, state) {
|
|
22382
|
+
const intent = entry.preferenceIntent;
|
|
22383
|
+
const conflicts = [];
|
|
22384
|
+
const add = (field, value, evidence) => {
|
|
22385
|
+
const current2 = state[field];
|
|
22386
|
+
if (current2 === void 0 || current2 === value) return;
|
|
22387
|
+
conflicts.push({ field, currentValue: current2, proposedValue: value, evidence, requiresUserConfirmation: true, next: "Show the conflict. Ask whether this is a project exception or an explicit preference update; never change saved preferences when accepting memory." });
|
|
22388
|
+
};
|
|
22389
|
+
if (intent && !memoryIntentIssues(intent).length) add(intent.field, intent.value, "explicit_intent");
|
|
22390
|
+
else {
|
|
22391
|
+
const text15 = entry.text.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").trim();
|
|
22392
|
+
if (/^(?:nada de|sin|no quiero) subtitulos[.!]?$/.test(text15)) add("captionsEnabled", false, "literal_rejection");
|
|
22393
|
+
if (state.captionTreatment === "karaoke" && /^(?:nada de|sin|no quiero|evita) (?:subtitulos )?(?:palabra (?:por|a) palabra|karaoke)[.!]?$/.test(text15)) add("captionTreatment", null, "literal_rejection");
|
|
22394
|
+
if (/^(?:nada de|sin|no quiero) musica[.!]?$/.test(text15)) add("musicIntensity", "none", "literal_rejection");
|
|
22395
|
+
if (/^(?:nada de|sin|no quiero) (?:efectos de sonido|sfx)[.!]?$/.test(text15)) add("sfxDensity", "none", "literal_rejection");
|
|
22396
|
+
}
|
|
22397
|
+
return conflicts;
|
|
22398
|
+
}
|
|
22399
|
+
|
|
22322
22400
|
// packages/core/src/memory.ts
|
|
22323
22401
|
function memoryEntries(doc) {
|
|
22324
22402
|
return [...doc.entries, ...doc.scopedEntries ?? []];
|
|
@@ -22342,13 +22420,13 @@ function memoryIssues(path, doc) {
|
|
|
22342
22420
|
if (!e || typeof e.id !== "string" || !/^[a-zA-Z0-9_-]{1,100}$/.test(e.id) || ids2.has(e.id) || typeof e.text !== "string" || !e.text.trim() || e.text.length > 800 || typeof e.conditions !== "string" || e.conditions.length > 400 || !["suggested", "confirmed", "disabled"].includes(e.status) || typeof e.source !== "string" || e.source.length > 400 || !["agent_reported", "user_saved", "weekly_proposal"].includes(e.provenance) || typeof e.updatedAt !== "string" || !Number.isFinite(Date.parse(e.updatedAt))) errors.push("Invalid or duplicate memory entry");
|
|
22343
22421
|
ids2.add(e?.id);
|
|
22344
22422
|
if (e) {
|
|
22345
|
-
errors.push(...applicabilityIssues(e.applicability), ...learningOriginIssues(e.learning));
|
|
22423
|
+
errors.push(...applicabilityIssues(e.applicability), ...learningOriginIssues(e.learning), ...memoryIntentIssues(e.preferenceIntent));
|
|
22346
22424
|
if (e.supersedes !== void 0 && (typeof e.supersedes !== "string" || !/^[a-zA-Z0-9_-]{1,100}$/.test(e.supersedes))) errors.push("Invalid superseded memory ID");
|
|
22347
22425
|
}
|
|
22348
22426
|
}
|
|
22349
22427
|
return errors;
|
|
22350
22428
|
}
|
|
22351
|
-
function resolveMemory(files, p) {
|
|
22429
|
+
function resolveMemory(files, p, preferences = {}) {
|
|
22352
22430
|
const context = p.memoryContext;
|
|
22353
22431
|
const entries = [["style", p.style], ["brand", p.brand], ["project", p.id]].flatMap(([scope, id4]) => {
|
|
22354
22432
|
const path = scope === "style" ? projectStylePath(p, "preferences.json") : memoryPath(scope, id4);
|
|
@@ -22362,8 +22440,10 @@ function resolveMemory(files, p) {
|
|
|
22362
22440
|
if (e.scope === "style" && !a) return false;
|
|
22363
22441
|
return !a || a.brandId === p.brand && (!a.formatId || a.formatId === context?.formatId) && (!a.seriesId || a.seriesId === context?.seriesId);
|
|
22364
22442
|
});
|
|
22365
|
-
const
|
|
22366
|
-
|
|
22443
|
+
const present = (e) => ({ ...e, conflictsWithPreference: memoryPreferenceConflicts(e, preferences) });
|
|
22444
|
+
const unscoped = context?.mode === "fresh" ? [] : entries.filter((e) => e.scope === "style" && !e.applicability && e.status !== "disabled").map((e) => ({ ...present(e), reason: "brand_required" }));
|
|
22445
|
+
const pending = [...applicable.filter((e) => e.status === "suggested").map(present), ...unscoped].sort((a, b) => Number(b.scope === "project") - Number(a.scope === "project") || b.updatedAt.localeCompare(a.updatedAt));
|
|
22446
|
+
return { confirmed: applicable.filter((e) => e.status === "confirmed"), preferenceConflicts: applicable.filter((e) => e.status === "confirmed").flatMap((e) => memoryPreferenceConflicts(e, preferences).map((conflict2) => ({ id: e.id, scope: e.scope, scopeId: e.scopeId, ...conflict2 }))), pending: pending.slice(0, 12), pendingCount: pending.length, pendingTruncated: pending.length > 12, pendingScopes: [...new Map(pending.map((e) => [e.path, { scope: e.scope, scopeId: e.scopeId, path: e.path }])).values()], guidance: "Show pending text and scope choices at delivery; defer questions in autonomous mode. Conflicts require a separate explicit preference decision, never an automatic settings change.", policy: "Memory is conditional guidance, not authorization or a substitute for required constraints. Current explicit request and project decisions precede confirmed selected style/series, then general brand preferences. Style memory requires an explicit matching brand; legacy unscoped notes stay pending until reviewed and assigned, never inferred from the active sidebar. Format learning only fills unspecified choices. Apply prose conditions only when relevant; do not guess a format or series to activate memory. Suggestions are not instructions. Fresh mode omits non-project memory, never required tokens or explicit source restrictions. Provenance is a claim, not proof of human confirmation." };
|
|
22367
22447
|
}
|
|
22368
22448
|
|
|
22369
22449
|
// packages/core/src/onboarding.ts
|
|
@@ -22972,10 +23052,10 @@ function validateProductionPlan(value) {
|
|
|
22972
23052
|
}
|
|
22973
23053
|
function mergeProductionIntervals(intervals) {
|
|
22974
23054
|
const merged = [];
|
|
22975
|
-
for (const
|
|
23055
|
+
for (const interval2 of [...intervals].sort((a, b) => a.startSeconds - b.startSeconds)) {
|
|
22976
23056
|
const last = merged.at(-1);
|
|
22977
|
-
if (last &&
|
|
22978
|
-
else merged.push({ ...
|
|
23057
|
+
if (last && interval2.startSeconds <= last.endSeconds) last.endSeconds = Math.max(last.endSeconds, interval2.endSeconds);
|
|
23058
|
+
else merged.push({ ...interval2 });
|
|
22979
23059
|
}
|
|
22980
23060
|
return merged;
|
|
22981
23061
|
}
|
|
@@ -23027,8 +23107,8 @@ function checkProductionPlan(inventory, value) {
|
|
|
23027
23107
|
const source2 = sources.get(use.sourceSha256);
|
|
23028
23108
|
const audioOnly = source2.streams?.some((s) => s.type === "audio") && !source2.streams.some((s) => s.type === "video" && !s.attachedPicture);
|
|
23029
23109
|
const inspected = mergeProductionIntervals(plan.inspections.filter((i) => i.sourceSha256 === source2.sha256 && (audioOnly ? i.modality === "audio" : i.modality === "visual" || i.modality === "motion")).flatMap((i) => i.intervals ?? []).filter((r) => inBounds(r.endSeconds, source2)));
|
|
23030
|
-
const
|
|
23031
|
-
const missing2 = use.source.endSeconds - use.source.startSeconds -
|
|
23110
|
+
const covered2 = inspected.reduce((sum, r) => sum + Math.max(0, Math.min(use.source.endSeconds, r.endSeconds) - Math.max(use.source.startSeconds, r.startSeconds)), 0);
|
|
23111
|
+
const missing2 = use.source.endSeconds - use.source.startSeconds - covered2;
|
|
23032
23112
|
if (missing2 > 1e-3) findings.push({ code: "USED_RANGE_COVERAGE_GAP", severity: source2.durationSeconds === null ? "info" : "warning", message: `${Math.round(missing2 * 1e3) / 1e3}s of this source use lack declared continuous ${audioOnly ? "audio" : "visual/motion"} inspection. Review relevant content when needed; snapshots do not establish interval coverage. This is not a requirement to inspect every unused source.`, sourceSha256: source2.sha256, useIds: [use.id], interval: use.source });
|
|
23033
23113
|
}
|
|
23034
23114
|
let repeatedPairs = 0;
|
|
@@ -203762,9 +203842,9 @@ var PUBLIC_TASK_ROUTES = [
|
|
|
203762
203842
|
title: "Revisar y corregir",
|
|
203763
203843
|
summary: "Inspeccionar el render y atender comentarios sobre su versi\xF3n concreta.",
|
|
203764
203844
|
aliases: ["revision", "revisar", "correccion", "corregir", "feedback"],
|
|
203765
|
-
cli: ["production verify", "production reviews", "production feedback", "production review-artifact"],
|
|
203766
|
-
mcp: ["prepare_review_artifact", "list_production_reviews", "list_production_feedback"],
|
|
203767
|
-
guides: ["references/production-and-review.md#check-text-against-social-ui", "references/production-continuity.md", "references/motion-review.md", "references/cloud-production.md"],
|
|
203845
|
+
cli: ["production delivery-check", "production verify", "production reviews", "production feedback", "feedback add", "production review-artifact"],
|
|
203846
|
+
mcp: ["check_render_delivery", "prepare_review_artifact", "list_production_reviews", "list_production_feedback", "save_editorial_feedback"],
|
|
203847
|
+
guides: ["references/memory-and-review.md", "references/production-and-review.md#check-text-against-social-ui", "references/production-continuity.md", "references/motion-review.md", "references/cloud-production.md"],
|
|
203768
203848
|
notes: ["verify local conserva los chequeos completos. Una capacidad de medios remota habilitada permite informes t\xE9cnicos y revisiones cloud; consulta s\xF3lo su gu\xEDa cuando la sesi\xF3n lo anuncie.", "Para texto/UI, consulta la gu\xEDa enlazada: production verify --ocr --platform reels combina OCR de reglas existentes con una gu\xEDa visual. Requiere runtime y layout.safeZone para hallar cruces; el muestreo no certifica todo el video ni rellena boxes de la hoja.", "Un pase t\xE9cnico no aprueba calidad creativa ni sustituye revisi\xF3n humana. Conserva lo aprobado y corrige s\xF3lo lo afectado."]
|
|
203769
203849
|
},
|
|
203770
203850
|
{
|
|
@@ -203774,8 +203854,8 @@ var PUBLIC_TASK_ROUTES = [
|
|
|
203774
203854
|
summary: "Mostrar el archivo revisable, conservar su versi\xF3n y registrar aceptaci\xF3n s\xF3lo cuando existe.",
|
|
203775
203855
|
aliases: ["entrega", "entregar", "finalizar", "muestra"],
|
|
203776
203856
|
cli: ["production review-artifact", "production submit", "production reviews", "projects complete"],
|
|
203777
|
-
mcp: ["prepare_review_artifact", "plan_production_submission", "submit_production_review", "list_production_reviews", "update_project_progress"],
|
|
203778
|
-
guides: ["references/mcp-studio-artifact.md", "references/production-continuity.md", "references/project-batches.md", "references/storage-and-previews.md"],
|
|
203857
|
+
mcp: ["check_render_delivery", "record_render_exception", "prepare_review_artifact", "plan_production_submission", "submit_production_review", "list_production_reviews", "update_project_progress"],
|
|
203858
|
+
guides: ["references/render-delivery.md", "references/mcp-studio-artifact.md", "references/production-continuity.md", "references/project-batches.md", "references/storage-and-previews.md"],
|
|
203779
203859
|
notes: ["Elige la superficie de revisi\xF3n solicitada; una muestra privada puede tener observaciones pendientes.", "La subida requiere autorizaci\xF3n y no aprueba el video; complete requiere aceptaci\xF3n expl\xEDcita del final. Conserva originales y masters."]
|
|
203780
203860
|
}
|
|
203781
203861
|
];
|
|
@@ -203885,7 +203965,7 @@ function parseReviewEvidence(input2) {
|
|
|
203885
203965
|
matches(item.revisionId, uuid5, "source.revisionId");
|
|
203886
203966
|
source2 = { kind: "revision", revisionId: item.revisionId };
|
|
203887
203967
|
} else {
|
|
203888
|
-
const item = fields2(value.source, ["kind", "artifactId", "sha256", "relativePath"], [], "Review evidence local source");
|
|
203968
|
+
const item = fields2(value.source, ["kind", "artifactId", "sha256", "relativePath"], ["mediaSha256"], "Review evidence local source");
|
|
203889
203969
|
if (item.kind !== "local") throw new Error("Review evidence source.kind must be revision or local.");
|
|
203890
203970
|
matches(item.artifactId, hash5, "source.artifactId");
|
|
203891
203971
|
matches(item.sha256, hash5, "source.sha256");
|
|
@@ -203895,7 +203975,8 @@ function parseReviewEvidence(input2) {
|
|
|
203895
203975
|
} catch {
|
|
203896
203976
|
throw new Error("Review evidence source.relativePath must be a safe portable relative file path, without absolute paths, URLs, credentials or traversal.");
|
|
203897
203977
|
}
|
|
203898
|
-
|
|
203978
|
+
if (item.mediaSha256 !== void 0) matches(item.mediaSha256, hash5, "source.mediaSha256");
|
|
203979
|
+
source2 = { ...typeof item.mediaSha256 === "string" ? { mediaSha256: item.mediaSha256 } : {}, kind: "local", artifactId: item.artifactId, sha256: item.sha256, relativePath: item.relativePath };
|
|
203899
203980
|
}
|
|
203900
203981
|
let decision;
|
|
203901
203982
|
if (Object.hasOwn(value, "decision")) {
|
|
@@ -205625,7 +205706,7 @@ async function resolveProject(files, projectId) {
|
|
|
205625
205706
|
...own5(files, `videos/${project.id}/resources.json`) ? { personalResources: parseResourceSelection(JSON.parse(files[`videos/${project.id}/resources.json`])) } : {},
|
|
205626
205707
|
questionPolicy: resolveQuestionPolicy(editorialProfile.questionMode, project.questionMode),
|
|
205627
205708
|
creativeDirection: resolveCreativeDirection(editorialProfile.creativeDirection, project.creativeDirection, editorialProfile.creativePreferencesReviewed, project.questionMode ?? editorialProfile.questionMode),
|
|
205628
|
-
memory: resolveMemory(files, project),
|
|
205709
|
+
memory: resolveMemory(files, project, { captionsEnabled: mediaPreferences.captionsEnabled, captionTreatment: mediaPreferences.editorialDelivery?.captionTreatment, musicIntensity: audioProduction?.music?.intensity ?? void 0, sfxDensity: audioProduction?.sfx?.density ?? void 0, orientation: output3.width === output3.height ? "square" : output3.width > output3.height ? "landscape" : "portrait" }),
|
|
205629
205710
|
mediaPreferences,
|
|
205630
205711
|
mediaAcquisition: mediaAcquisitionGuidance(mediaPreferences),
|
|
205631
205712
|
evidence: style.references ?? [],
|
|
@@ -206738,6 +206819,12 @@ import { posix as posix3 } from "node:path";
|
|
|
206738
206819
|
// packages/cli/src/client.ts
|
|
206739
206820
|
import { setTimeout as delay } from "node:timers/promises";
|
|
206740
206821
|
var searchErrors = {
|
|
206822
|
+
render_route_mismatch: { status: 409, code: "RENDER_ROUTE_MISMATCH", hint: "Read workflow check and production delivery-check for this exact final. Quote the required cloud render and obtain spending authorization, or register an actual user-requested local exception. Never infer permission from a failed render or changed style." },
|
|
206823
|
+
render_delivery_missing: { status: 409, code: "RENDER_DELIVERY_MISSING", hint: "Inspect the exact final storage and current review. Preserve the chosen retention and authorized upload policy; a preview copy is not delivery of the master. Do not change the saved destination to bypass this check." },
|
|
206824
|
+
presentation_required: { status: 409, code: "PRESENTATION_REQUIRED", hint: "Show the current video artifact, then use production present to record the actual presentation. Keep the checkpoint in_progress until then. Do not manufacture presentation or approval." },
|
|
206825
|
+
invalid_delivery_evidence: { status: 400, code: "INVALID_DELIVERY_EVIDENCE", hint: "Use the SHA-256 of the exact final video and this project in production delivery-check. A local HTML artifact has a separate hash." },
|
|
206826
|
+
invalid_render_override: { status: 400, code: "INVALID_RENDER_OVERRIDE", hint: "Use this project, current context and the exact artifact hash with the actual user-confirmed exception. Never invent the user\u2019s words or broaden permission." },
|
|
206827
|
+
render_exception_conflict: { status: 409, code: "RENDER_EXCEPTION_CONFLICT", hint: "An immutable exception already exists for this artifact and context. Reconcile it; do not overwrite it or create a new artifact merely to bypass the conflict." },
|
|
206741
206828
|
template_not_portable: { status: 422, code: "TEMPLATE_NOT_PORTABLE", hint: "Read styles share prepare output. Review and fix the named document/resource and declare required dependencies; never bypass privacy checks." },
|
|
206742
206829
|
template_private_resource: { status: 422, code: "TEMPLATE_PRIVATE_RESOURCE", hint: "Prepare a portable copy of the named resource without private paths or credentials. Never publish the original or suppress validation." },
|
|
206743
206830
|
template_changed: { status: 409, code: "TEMPLATE_CHANGED", hint: "Prepare or inspect the template again. Review the new version before publishing/importing. Do not silently approve changed files." },
|
|
@@ -206768,7 +206855,7 @@ var searchErrors = {
|
|
|
206768
206855
|
project_link_unavailable: { status: 503, code: "PROJECT_LINK_UNAVAILABLE", hint: "Keep the same project ID and contact EditorBrain support. Do not invent a localhost, public sharing or third-party upload link." },
|
|
206769
206856
|
render_uploads_disabled: { status: 409, code: "RENDER_UPLOADS_DISABLED", hint: "Your saved preference prohibits uploads. Continue locally or change that preference only after the user explicitly requests it. Do not infer upload permission from editing autonomy." },
|
|
206770
206857
|
render_workspace_policy: { status: 409, code: "RENDER_WORKSPACE_POLICY", hint: "The resolved execution or storage preference blocks this operation. Read render-cloud preferences and plan. Preserve the chosen destination unless the user requests a change." },
|
|
206771
|
-
render_engine_unavailable: { status: 503, code: "RENDER_ENGINE_UNAVAILABLE", hint: "Read editorbrain capabilities for enabled render engines.
|
|
206858
|
+
render_engine_unavailable: { status: 503, code: "RENDER_ENGINE_UNAVAILABLE", hint: "Read editorbrain capabilities for enabled render engines. Inspect the existing job before retrying. Local execution requires a local preference or explicit user exception. Do not rename Blender files, switch to CPU or create a replacement job automatically." },
|
|
206772
206859
|
render_engine_evidence: { status: 400, code: "RENDER_ENGINE_EVIDENCE", hint: "The requested engine and worker evidence do not match. Keep this job ID for support; do not certify or reuse this output." },
|
|
206773
206860
|
render_storage_unavailable: { status: 503, code: "RENDER_STORAGE_UNAVAILABLE", hint: "Cloud storage is not enabled in the current service. Keep the request and read capabilities; do not download media to bypass cloud-only mode." },
|
|
206774
206861
|
render_storage_full: { status: 409, code: "RENDER_STORAGE_FULL", hint: "Cloud storage is full. Review storage status and the same delivery, free unneeded media or choose a supported storage upgrade. Render credits do not add storage; never silently download to bypass cloud-only mode." },
|
|
@@ -207119,11 +207206,12 @@ var Client = class {
|
|
|
207119
207206
|
const retryAfterMs = retryDelay(response.headers.get("Retry-After"), this.runtime.now());
|
|
207120
207207
|
if (!response.ok) {
|
|
207121
207208
|
let errorBody;
|
|
207122
|
-
if ([401, 403].includes(response.status) || (/^\/v1\/(?:authored-motion|style-sources|sfx|team|studio|batches|render-cloud|resources)(?:\/|\?|$)/.test(path) || path.startsWith("/v1/documents/") || path === "/v1/search/brief" || path === "/v1/projects" || /^\/v1\/projects\/[^/]+\/(?:progress|intake|resolve|export|review-evidence(?:\/[a-f0-9-]{36})?|continuity(?:\?.*)?)$/.test(path)) && [400, 402, 403, 404, 409, 422, 429, 503].includes(response.status)) {
|
|
207209
|
+
if ([401, 403].includes(response.status) || (/^\/v1\/(?:authored-motion|style-sources|sfx|team|studio|batches|render-cloud|resources)(?:\/|\?|$)/.test(path) || path.startsWith("/v1/documents/") || path === "/v1/search/brief" || path === "/v1/projects" || /^\/v1\/projects\/[^/]+\/(?:progress|intake|resolve|export|review-evidence(?:\/[a-f0-9-]{36})?|(?:delivery-evidence|checkpoint-readiness|continuity)(?:\?.*)?)$/.test(path)) && [400, 402, 403, 404, 409, 422, 429, 503].includes(response.status)) {
|
|
207123
207210
|
try {
|
|
207124
207211
|
const parsed = await boundedJson(response, 16 * 1024);
|
|
207125
207212
|
const knownDiagnostic = searchDiagnostic(response.status, parsed);
|
|
207126
|
-
const
|
|
207213
|
+
const checkpointDiagnostic = /^\/v1\/documents\/videos\/[^/]+\/checkpoint\.json$/.test(path) && ["presentation_required", "final_not_approved", "render_route_mismatch", "render_delivery_missing"].includes(knownDiagnostic?.serviceCode ?? "");
|
|
207214
|
+
const diagnostic = path.startsWith("/v1/documents/") && !/^\/v1\/documents\/videos\/[^/]+\/project\.json$/.test(path) && !checkpointDiagnostic && !["brand_limit_reached", "workspace_denied", "account_login_required"].includes(knownDiagnostic?.serviceCode ?? "") ? void 0 : knownDiagnostic;
|
|
207127
207215
|
const voiceRevisionConflict = /^\/v1\/studio\/voice-selection(?:\?|$)/.test(path) && response.status === 409 && parsed?.error?.code === "revision_conflict";
|
|
207128
207216
|
errorBody = diagnostic ? { error: { code: diagnostic.serviceCode, ...safeDiagnosticDetails(parsed) } } : voiceRevisionConflict ? { error: { code: "revision_conflict" } } : path.startsWith("/v1/documents/") ? documentDiagnostic(parsed, path, response.status) : void 0;
|
|
207129
207217
|
} catch {
|
|
@@ -208518,7 +208606,7 @@ async function saveStyleDecisions(directory, projectId, file2, expectedHash) {
|
|
|
208518
208606
|
const policy = await inspectStylePolicy(root, projectId), doc = validateStyleDecisions(await readProductionJson(root, file2));
|
|
208519
208607
|
if (doc.projectId !== projectId) throw new Error("Decisions projectId must match --project.");
|
|
208520
208608
|
for (const decision of doc.decisions) {
|
|
208521
|
-
const rule = policy.rules.find((rule2) => rule2.id === decision.ruleId);
|
|
208609
|
+
const rule = [...policy.rules, ...policy.preferenceChecks].find((rule2) => rule2.id === decision.ruleId && rule2.ruleSha256 === decision.ruleSha256);
|
|
208522
208610
|
if (!rule || rule.ruleSha256 !== decision.ruleSha256) throw new Error(`Decision ${decision.ruleId}: rule is absent or changed. Run styles rules inspect --project ${projectId} and reconsider this choice.`);
|
|
208523
208611
|
if (rule.strength === "required") throw new Error(`Decision ${decision.ruleId}: cannot waive an explicit requirement. Resolve it with the user; private review is still allowed.`);
|
|
208524
208612
|
}
|
|
@@ -208996,12 +209084,17 @@ async function readProductionSnapshot(client, projectId) {
|
|
|
208996
209084
|
}
|
|
208997
209085
|
async function prepareProductionContext(root, projectId, client) {
|
|
208998
209086
|
const resolved = await resolveProject(await readProjectWorkspace(root, projectId), projectId);
|
|
208999
|
-
const
|
|
209087
|
+
const sourceHashes = await effectiveEditorialSourceHashes(resolved), sourceKey = stableJson(sourceHashes);
|
|
209000
209088
|
let contextVersion;
|
|
209001
209089
|
const remote = async () => {
|
|
209002
209090
|
const snapshot = await readProductionSnapshot(client, projectId);
|
|
209003
209091
|
const portableHashes = Object.fromEntries(Object.entries(snapshot.effectiveSourceHashes ?? snapshot.sourceHashes).filter(([path]) => path !== "personal-resources:live"));
|
|
209004
|
-
|
|
209092
|
+
const localHashes = snapshot.effectiveSourceHashes ? sourceHashes : resolved.lock.sourceHashes;
|
|
209093
|
+
if (stableJson(portableHashes) !== stableJson(localHashes)) {
|
|
209094
|
+
const changedSources = [.../* @__PURE__ */ new Set([...Object.keys(localHashes), ...Object.keys(portableHashes)])].filter((key) => localHashes[key] !== portableHashes[key]).sort();
|
|
209095
|
+
const memoryChanged = changedSources.includes("memory:effective");
|
|
209096
|
+
throw new CliError("PRODUCTION_CONTEXT_CONFLICT", memoryChanged ? "Confirmed editorial memory differs between this local workspace and the web." : "Local and web project preferences or material differ.", `Run editorbrain pull --project ${projectId} in this workspace to refresh project and dependent brand/style memory, inspect any local conflicts, then retry verification. Do not overwrite either side automatically.`, false, { changedSources, memorySyncRequired: memoryChanged });
|
|
209097
|
+
}
|
|
209005
209098
|
return snapshot.contextVersion;
|
|
209006
209099
|
};
|
|
209007
209100
|
if (client) contextVersion = await remote();
|
|
@@ -209577,6 +209670,9 @@ var SUPPORTED_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
209577
209670
|
]);
|
|
209578
209671
|
var PROTOCOLS = "file,pipe";
|
|
209579
209672
|
var FORMATS = "mov,matroska,webm,avi,mpeg,mpegts,ogg,wav,flac,mp3,aac,aiff,ac3,eac3,asf,jpeg_pipe,png_pipe,webp_pipe,bmp_pipe,tiff_pipe,gif,heif,avif";
|
|
209673
|
+
var STILL_IMAGE_FORMATS = `${FORMATS},image2`;
|
|
209674
|
+
var STILL_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png", ".webp", ".bmp", ".tif", ".tiff", ".gif", ".avif", ".heic", ".heif"]);
|
|
209675
|
+
var STILL_IMAGE_CODECS = /* @__PURE__ */ new Set(["mjpeg", "png", "webp", "bmp", "tiff", "gif", "jpegls", "jpeg2000"]);
|
|
209580
209676
|
var DEFAULT_TIMEOUT = 3e4;
|
|
209581
209677
|
var DEFAULT_OUTPUT_LIMIT = 2 * 1024 * 1024;
|
|
209582
209678
|
function resolveLocalMediaPath(value) {
|
|
@@ -209605,8 +209701,12 @@ async function assertLocalMediaFile(value) {
|
|
|
209605
209701
|
if (!SUPPORTED_MEDIA_EXTENSIONS.has(extname3(path).toLowerCase())) throw new MediaToolError("MEDIA_FORMAT_UNSUPPORTED", "This file extension is not supported for local media inspection.");
|
|
209606
209702
|
return path;
|
|
209607
209703
|
}
|
|
209704
|
+
function formatAllowlist(path) {
|
|
209705
|
+
return STILL_IMAGE_EXTENSIONS.has(extname3(path).toLowerCase()) && !path.includes("%") ? STILL_IMAGE_FORMATS : FORMATS;
|
|
209706
|
+
}
|
|
209608
209707
|
function localInputArgs(path) {
|
|
209609
|
-
|
|
209708
|
+
const resolved = resolveLocalMediaPath(path);
|
|
209709
|
+
return ["-protocol_whitelist", PROTOCOLS, "-format_whitelist", formatAllowlist(resolved), "-i", resolved];
|
|
209610
209710
|
}
|
|
209611
209711
|
async function runMediaTool(tool, args, options = {}) {
|
|
209612
209712
|
if (tool !== "ffmpeg" && tool !== "ffprobe") throw new MediaToolError("MEDIA_TOOL_INVALID", "Unsupported media executable.");
|
|
@@ -209623,12 +209723,12 @@ async function runMediaTool(tool, args, options = {}) {
|
|
|
209623
209723
|
if (/(?:^|[=,;\s])(?:https?|ftp|sftp|tcp|udp|rtsp|rtmp|smb|data|concat|subfile|crypto):/i.test(arg) || arg === "-safe" && args[i + 1] === "0" || arg === "-enable_drefs" && args[i + 1] !== "0") {
|
|
209624
209724
|
throw new MediaToolError("MEDIA_REMOTE_INPUT_FORBIDDEN", "Only self-contained local media inputs are allowed.");
|
|
209625
209725
|
}
|
|
209626
|
-
if (arg === "-protocol_whitelist" && args[i + 1] !== PROTOCOLS || arg === "-format_whitelist" && args[i + 1] !== FORMATS) {
|
|
209726
|
+
if (arg === "-protocol_whitelist" && args[i + 1] !== PROTOCOLS || arg === "-format_whitelist" && args[i + 1] !== FORMATS && args[i + 1] !== STILL_IMAGE_FORMATS) {
|
|
209627
209727
|
throw new MediaToolError("MEDIA_TOOL_ARGUMENTS_INVALID", "The local media allowlists cannot be widened.");
|
|
209628
209728
|
}
|
|
209629
209729
|
if (arg === "-i") {
|
|
209630
209730
|
await assertLocalMediaFile(args[i + 1] ?? "");
|
|
209631
|
-
if (args[i - 4] !== "-protocol_whitelist" || args[i - 3] !== PROTOCOLS || args[i - 2] !== "-format_whitelist" || args[i - 1] !==
|
|
209731
|
+
if (args[i - 4] !== "-protocol_whitelist" || args[i - 3] !== PROTOCOLS || args[i - 2] !== "-format_whitelist" || args[i - 1] !== formatAllowlist(resolveLocalMediaPath(args[i + 1]))) {
|
|
209632
209732
|
throw new MediaToolError("MEDIA_TOOL_ARGUMENTS_INVALID", "Every media input must use localInputArgs.");
|
|
209633
209733
|
}
|
|
209634
209734
|
}
|
|
@@ -209703,8 +209803,13 @@ async function probeLocalMedia(value) {
|
|
|
209703
209803
|
try {
|
|
209704
209804
|
const before = await handle.stat();
|
|
209705
209805
|
if (!before.isFile()) throw new MediaToolError("MEDIA_NOT_REGULAR", "The media input must be a regular local file.");
|
|
209706
|
-
const entries = "format=duration,start_time:stream=index,codec_type,codec_name,width,height,avg_frame_rate,sample_rate,channels,duration,color_transfer,sample_aspect_ratio,pix_fmt:stream_disposition=attached_pic:stream_side_data=side_data_type,rotation,displaymatrix:stream_tags=rotate";
|
|
209707
|
-
const { stdout } = await runMediaTool("ffprobe", ["-v", "error", "-show_entries", entries, "-of", "json", ...localInputArgs(path)])
|
|
209806
|
+
const entries = "format=duration,start_time,format_name:stream=index,codec_type,codec_name,width,height,avg_frame_rate,sample_rate,channels,duration,color_transfer,sample_aspect_ratio,pix_fmt:stream_disposition=attached_pic:stream_side_data=side_data_type,rotation,displaymatrix:stream_tags=rotate";
|
|
209807
|
+
const { stdout } = await runMediaTool("ffprobe", ["-v", "error", "-show_entries", entries, "-of", "json", ...localInputArgs(path)]).catch((error62) => {
|
|
209808
|
+
if (error62 instanceof MediaToolError && error62.code === "MEDIA_TOOL_FAILED" && formatAllowlist(path) === FORMATS && STILL_IMAGE_EXTENSIONS.has(extname3(path).toLowerCase())) {
|
|
209809
|
+
throw new MediaToolError("MEDIA_TOOL_FAILED", "This image could not be inspected. Its path contains %, which FFmpeg treats as an image-sequence pattern; copy it to a path without % and retry.");
|
|
209810
|
+
}
|
|
209811
|
+
throw error62;
|
|
209812
|
+
});
|
|
209708
209813
|
const hash13 = createHash9("sha256");
|
|
209709
209814
|
for await (const chunk of handle.createReadStream({ autoClose: false })) hash13.update(chunk);
|
|
209710
209815
|
const after = await handle.stat();
|
|
@@ -209731,6 +209836,9 @@ async function probeLocalMedia(value) {
|
|
|
209731
209836
|
...type === "audio" ? { sampleRate: nonnegative2(stream.sample_rate), channels: positiveInteger(stream.channels) ?? null } : {}
|
|
209732
209837
|
};
|
|
209733
209838
|
});
|
|
209839
|
+
if (raw.format?.format_name === "image2" && (streams.length !== 1 || streams[0].type !== "video" || !streams[0].codec || !STILL_IMAGE_CODECS.has(streams[0].codec))) {
|
|
209840
|
+
throw new MediaToolError("MEDIA_PROBE_INVALID", "An image file must contain exactly one still image.");
|
|
209841
|
+
}
|
|
209734
209842
|
return { path, sha256: hash13.digest("hex"), bytes: after.size, durationSeconds: nonnegative2(raw.format?.duration), startTimeSeconds: finite2(raw.format?.start_time), streams };
|
|
209735
209843
|
} finally {
|
|
209736
209844
|
await handle.close();
|
|
@@ -210131,7 +210239,7 @@ var introductions = {
|
|
|
210131
210239
|
checkpoint: "Usa --expected-checkpoint SHA256|none del \xFAltimo resume para proteger decisiones desde esa lectura. current toma el hash al iniciar este comando y detecta solo escrituras concurrentes durante esta invocaci\xF3n. --current-version, --primary-artifact, --dependency y --render-command conservan contexto t\xE9cnico portable; nunca ejecutan. Guarda el hito declarado y hashes en videos/ID/checkpoint.json. Las rutas son relativas a la carpeta registrada por rol o al workspace. Repite --done/--pending/--decision; sus listas reemplazan las anteriores. --primary-artifact y --dependency registran y verifican sus archivos sin repetir --artifact. --artifact reemplaza la lista base y a\xF1ade esas referencias expl\xEDcitas; omitirlo conserva los artefactos previos. Usa push expl\xEDcitamente para sincronizar el texto.",
|
|
210132
210240
|
projects: "find/list buscan por nombre/tema, --brand, --since y --before (UTC ISO), con paginaci\xF3n y actividad real; find --local consulta el registro privado; --dir lo limita a un workspace registrado, sin red ni escaneo. link/unlink administran carpetas privadas locales; where ID las consulta y resume ID recupera el hito. create crea el proyecto remoto y su baseline local sin sobrescribir cambios; pin-style fija sus documentos de estilo por hash; intake devuelve su material y enlace privado de subida. Conserva el mismo ID para retomarlo. No inicia edici\xF3n, render ni gasto; un enlace de subida requiere iniciar sesi\xF3n.",
|
|
210133
210241
|
styles: "share prepare revisa una plantilla; publish comparte solo lo aprobado. template inspect/import guarda una copia independiente sin editar proyectos ni ejecutar c\xF3digo. Ver references/style-sharing.md. Reglas preferred orientan decisiones por video; required expl\xEDcitas se verifican por separado. rules inspect muestra hashes, rules decisions guarda adaptaciones por proyecto. captions preview es local expl\xEDcito; export avisa p\xE9rdidas SRT/ASS. Estilos de edici\xF3n completos. list = biblioteca publicada; mine = estilos locales de este workspace. media styles son recetas visuales para generar im\xE1genes, no ediciones completas.",
|
|
210134
|
-
production: "present sin --file consulta evidencia/version; con --file registra solo una presentaci\xF3n que realmente entregaste al usuario: expectedVersion, evidenceId UUID, contextVersion, phase directions|review|delivery, presented:true y source revision o local. Un HTML local requiere el sidecar y medios verificados; nunca inferir aprobaci\xF3n por generar/abrir/subir. decision local requiere userConfirmed y direcci\xF3n elegida o approved:true; nube reutiliza la revisi\xF3n existente. withdraw retira evidencia solo tras instrucci\xF3n del usuario y conserva el historial. submit prepara y registra una muestra privada autorizada con recibo recuperable; --parent sustituye la pendiente anterior sin aprobar ni borrar comentarios. reviews devuelve revisions por compatibilidad. Un chequeo t\xE9cnico no aprueba la calidad creativa. verify mide el archivo final; los chequeos de cortes/caras requieren evidencia alineada al mismo render.",
|
|
210242
|
+
production: "present sin --file consulta evidencia/version; con --file registra solo una presentaci\xF3n que realmente entregaste al usuario: expectedVersion, evidenceId UUID, contextVersion, phase directions|review|delivery, presented:true y source revision o local. Un HTML local requiere el sidecar y medios verificados; nunca inferir aprobaci\xF3n por generar/abrir/subir. decision local requiere userConfirmed y direcci\xF3n elegida o approved:true; nube reutiliza la revisi\xF3n existente. withdraw retira evidencia solo tras instrucci\xF3n del usuario y conserva el historial. submit prepara y registra una muestra privada autorizada con recibo recuperable; --addresses guarda la correcci\xF3n real y una memoria sugerida del proyecto; --revision-kind alternative|technical|continuation distingue versiones sin feedback inventado; --parent sustituye la pendiente anterior sin aprobar ni borrar comentarios. reviews devuelve revisions por compatibilidad. Un chequeo t\xE9cnico no aprueba la calidad creativa. verify mide el archivo final; los chequeos de cortes/caras requieren evidencia alineada al mismo render.",
|
|
210135
210243
|
studio: "Herramientas de generaci\xF3n: catalog \u2192 quote \u2192 run \u2192 get. Una cotizaci\xF3n no gasta; run requiere presupuesto autorizado. Las capacidades dependen del proveedor y del plan.",
|
|
210136
210244
|
clean: "Primero inspecciona el disco. No elimina fuentes, masters ni recibos autom\xE1ticamente. --deduplicate usa copias independientes con bloques compartidos cuando el sistema lo admite.",
|
|
210137
210245
|
variants: "Variantes locales: reutilizan la edici\xF3n base y registran cambios de gancho/CTA sin duplicar medios ni modificar el proyecto original."
|
|
@@ -210490,9 +210598,17 @@ async function teamCommand(client, subcommand, flags) {
|
|
|
210490
210598
|
}
|
|
210491
210599
|
|
|
210492
210600
|
// packages/cli/src/personal-resources.ts
|
|
210493
|
-
import { basename as basename2, extname as extname4, resolve as resolve8 } from "node:path";
|
|
210601
|
+
import { basename as basename2, extname as extname4, join as join9, resolve as resolve8 } from "node:path";
|
|
210494
210602
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
210495
|
-
|
|
210603
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
210604
|
+
import { constants as constants11 } from "node:fs";
|
|
210605
|
+
import { mkdir as mkdir10, mkdtemp as mkdtemp4, open as open16, realpath as realpath4, rm as rm5 } from "node:fs/promises";
|
|
210606
|
+
import { homedir as homedir2, tmpdir as tmpdir4 } from "node:os";
|
|
210607
|
+
var mimeTypes = { ".mp4": "video/mp4", ".mov": "video/quicktime", ".webm": "video/webm", ".m4v": "video/mp4", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".gif": "image/gif", ".heic": "image/heic", ".heif": "image/heif", ".wav": "audio/wav", ".mp3": "audio/mpeg", ".m4a": "audio/mp4", ".flac": "audio/flac", ".ogg": "audio/ogg" };
|
|
210608
|
+
var uploadableTypes = /* @__PURE__ */ new Set(["video/mp4", "video/quicktime", "video/webm", "image/png", "image/jpeg", "image/webp", "audio/mpeg", "audio/wav", "audio/mp4", "audio/ogg"]);
|
|
210609
|
+
var heicTypes = /* @__PURE__ */ new Set(["image/heic", "image/heif"]);
|
|
210610
|
+
var maxUploadBytes = 90 * 1024 * 1024;
|
|
210611
|
+
var heicNote = "HEIC original: browsers and HTML renderers cannot read it. Make a local JPEG copy for those tools (macOS: sips -s format jpeg IN --out OUT).";
|
|
210496
210612
|
var fail = (message) => {
|
|
210497
210613
|
throw new CliError("INVALID_RESOURCE", message, "Read editorbrain help and references/personal-resources.md. No upload or paid analysis is automatic.");
|
|
210498
210614
|
};
|
|
@@ -210506,6 +210622,10 @@ function flag(flags, key, required2 = false) {
|
|
|
210506
210622
|
if (typeof value !== "string" || !value.trim()) fail(`--${key} requires a value.`);
|
|
210507
210623
|
return value;
|
|
210508
210624
|
}
|
|
210625
|
+
function list(flags, key) {
|
|
210626
|
+
const value = flag(flags, key);
|
|
210627
|
+
return value === void 0 ? void 0 : value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
210628
|
+
}
|
|
210509
210629
|
function revision(flags) {
|
|
210510
210630
|
const value = flag(flags, "expected-revision", true);
|
|
210511
210631
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) fail("--expected-revision requires a nonnegative safe integer.");
|
|
@@ -210516,12 +210636,112 @@ async function saveResource(client, id4, resource, expectedRevision, approvalCon
|
|
|
210516
210636
|
if (!confirmPersonalResourceSave(result2, id4, resource, expectedRevision)) throw new CliError("INVALID_RESPONSE", "The resource save could not be confirmed.", "Read resources get with this exact ID before retrying. Preserve the local draft; do not repeat an approval or create another resource automatically.", false, { outcome: "unknown", resourceId: id4 });
|
|
210517
210637
|
return result2;
|
|
210518
210638
|
}
|
|
210639
|
+
function machineConfigDir() {
|
|
210640
|
+
return process.env.EDITORBRAIN_CONFIG_DIR ?? process.env.EDITORHARNESS_CONFIG_DIR ?? join9(homedir2(), ".config", "editorbrain");
|
|
210641
|
+
}
|
|
210642
|
+
var legacyMapPath = (namespace, id4) => `.editorbrain-local/resources/${namespace}/${id4}.json`;
|
|
210643
|
+
async function mapScope(client) {
|
|
210644
|
+
const me = await client.request("/v1/me");
|
|
210645
|
+
return { workspaceId: me.workspaceId, namespace: (await sha256(client.url + "\n" + me.workspaceId)).slice(0, 32) };
|
|
210646
|
+
}
|
|
210647
|
+
async function writeMachineMap(namespace, id4, mapping) {
|
|
210648
|
+
const base = machineConfigDir();
|
|
210649
|
+
await mkdir10(join9(base, "resources", namespace), { recursive: true, mode: 448 });
|
|
210650
|
+
const root = await ensureRoot(base), path = `resources/${namespace}/${id4}.json`;
|
|
210651
|
+
await atomicWrite(root, path, JSON.stringify(mapping) + "\n", { document: false, mode: 384 });
|
|
210652
|
+
return join9(root, path);
|
|
210653
|
+
}
|
|
210654
|
+
async function readMachineMap(namespace, id4) {
|
|
210655
|
+
try {
|
|
210656
|
+
return JSON.parse(await readText(await ensureRoot(machineConfigDir()), `resources/${namespace}/${id4}.json`, false));
|
|
210657
|
+
} catch (error62) {
|
|
210658
|
+
if (error62.code === "ENOENT") return void 0;
|
|
210659
|
+
throw error62;
|
|
210660
|
+
}
|
|
210661
|
+
}
|
|
210662
|
+
async function readVerified(path, expected) {
|
|
210663
|
+
const handle = await open16(path, constants11.O_RDONLY | (constants11.O_NOFOLLOW ?? 0));
|
|
210664
|
+
let bytes;
|
|
210665
|
+
try {
|
|
210666
|
+
bytes = new Uint8Array(await handle.readFile());
|
|
210667
|
+
} finally {
|
|
210668
|
+
await handle.close();
|
|
210669
|
+
}
|
|
210670
|
+
if (await sha256(bytes) !== expected) throw new CliError("RESOURCE_SOURCE_CHANGED", "The file changed while it was being registered.", "Retry with a stable file. Nothing was uploaded.");
|
|
210671
|
+
return bytes;
|
|
210672
|
+
}
|
|
210673
|
+
var conversionFailed = () => new CliError("HEIC_CONVERSION_FAILED", "The HEIC photo could not be converted to a JPEG copy on this computer. Nothing was registered or uploaded.", "Convert it locally (macOS: sips -s format jpeg IN --out OUT.jpg) and register the JPEG, or register the HEIC without --upload to keep it local-only.");
|
|
210674
|
+
function runSips(source2, out) {
|
|
210675
|
+
return new Promise((done) => {
|
|
210676
|
+
const child = spawn2("sips", ["-s", "format", "jpeg", "-s", "formatOptions", "90", source2, "--out", out], { shell: false, stdio: "ignore" });
|
|
210677
|
+
const timer = setTimeout(() => child.kill("SIGKILL"), 12e4);
|
|
210678
|
+
child.on("error", () => {
|
|
210679
|
+
clearTimeout(timer);
|
|
210680
|
+
done(false);
|
|
210681
|
+
});
|
|
210682
|
+
child.on("close", (code) => {
|
|
210683
|
+
clearTimeout(timer);
|
|
210684
|
+
done(code === 0);
|
|
210685
|
+
});
|
|
210686
|
+
});
|
|
210687
|
+
}
|
|
210688
|
+
async function jpegCopy(source2) {
|
|
210689
|
+
const dir = await realpath4(await mkdtemp4(join9(tmpdir4(), "editorbrain-heic-")));
|
|
210690
|
+
try {
|
|
210691
|
+
const out = join9(dir, "copy.jpg");
|
|
210692
|
+
if (!(process.platform === "darwin" && await runSips(source2.path, out))) await runMediaTool("ffmpeg", ["-v", "error", "-n", ...localInputArgs(source2.path), "-frames:v", "1", "-q:v", "2", "-update", "1", out], { timeoutMs: 12e4 }).catch(() => {
|
|
210693
|
+
throw conversionFailed();
|
|
210694
|
+
});
|
|
210695
|
+
const copy = await probeLocalMedia(out).catch(() => {
|
|
210696
|
+
throw conversionFailed();
|
|
210697
|
+
}), video = copy.streams[0];
|
|
210698
|
+
if (copy.streams.length !== 1 || video?.codec !== "mjpeg" || !video.width || !video.height) throw conversionFailed();
|
|
210699
|
+
if (copy.bytes > maxUploadBytes) throw tooLarge();
|
|
210700
|
+
return { bytes: await readVerified(out, copy.sha256), sha256: copy.sha256 };
|
|
210701
|
+
} finally {
|
|
210702
|
+
await rm5(dir, { recursive: true, force: true });
|
|
210703
|
+
}
|
|
210704
|
+
}
|
|
210705
|
+
var tooLarge = () => new CliError("UPLOAD_TOO_LARGE", "The upload limit is 90 MiB. Nothing was registered or uploaded.", "Register without --upload to keep it local-only, or prepare a smaller copy and upload it with assets upload FILE --purpose preview --source-sha256 ORIGINAL_SHA256.");
|
|
210706
|
+
async function prepareUpload(client, probe2, mimeType, file2) {
|
|
210707
|
+
let prepared;
|
|
210708
|
+
if (heicTypes.has(mimeType)) {
|
|
210709
|
+
const copy = await jpegCopy(probe2);
|
|
210710
|
+
prepared = { sha256: copy.sha256, bytes: copy.bytes.byteLength, content: copy.bytes, mimeType: "image/jpeg", purpose: "preview", sourceSha256: probe2.sha256, name: basename2(file2, extname4(file2)) + ".jpg" };
|
|
210711
|
+
} else {
|
|
210712
|
+
if (!uploadableTypes.has(mimeType)) fail(`${mimeType} can be registered locally but not uploaded. Use MP4/MOV/WebM, JPEG/PNG/WebP/HEIC or MP3/WAV/M4A/OGG, or register without --upload.`);
|
|
210713
|
+
if (probe2.bytes > maxUploadBytes) throw tooLarge();
|
|
210714
|
+
prepared = { sha256: probe2.sha256, bytes: probe2.bytes, mimeType, purpose: "original", name: basename2(file2) };
|
|
210715
|
+
}
|
|
210716
|
+
let plan;
|
|
210717
|
+
try {
|
|
210718
|
+
plan = await client.request("/v1/resources/upload-plan?" + new URLSearchParams({ sha256: prepared.sha256, bytes: String(prepared.bytes) }));
|
|
210719
|
+
} catch (error62) {
|
|
210720
|
+
if (error62 instanceof ApiError && [400, 404, 405].includes(error62.status)) throw new CliError("UPLOAD_PLAN_UNAVAILABLE", "This EditorBrain service cannot check resource upload permission yet. Nothing was registered or uploaded.", "Register without --upload. Upload later with assets upload only after the user confirms uploads are allowed.");
|
|
210721
|
+
throw error62;
|
|
210722
|
+
}
|
|
210723
|
+
if (!plan || typeof plan.allowed !== "boolean" || plan.existingAsset && (plan.existingAsset.sha256 !== prepared.sha256 || plan.existingAsset.bytes !== prepared.bytes)) throw new CliError("INVALID_RESPONSE", "The upload check returned an unexpected answer. Nothing was registered or uploaded.", "Retry later; do not upload with another command meanwhile.");
|
|
210724
|
+
if (!plan.allowed && plan.reason === "render_uploads_disabled") throw new CliError("UPLOADS_DISABLED", "Your saved preferences do not allow uploads. Nothing was registered or uploaded.", "Run resources register without --upload to keep this resource local-only. Change the upload preference only if the user explicitly asks.", false, { reason: plan.reason });
|
|
210725
|
+
if (!plan.allowed) throw new CliError("STORAGE_FULL", "There is not enough cloud storage for this file. Nothing was registered or uploaded.", "Register without --upload to keep it local-only, or review storage with the user at https://editorbrain.com/app/files.", false, { reason: plan.reason });
|
|
210726
|
+
return { ...prepared, plan };
|
|
210727
|
+
}
|
|
210728
|
+
function registeredResource(input2) {
|
|
210729
|
+
try {
|
|
210730
|
+
return parsePersonalResource(input2);
|
|
210731
|
+
} catch (error62) {
|
|
210732
|
+
return fail(`Resource fields are invalid: ${error62.message}. Limits: title 160, description 10000, up to 24 tags of 60 characters, instructions 2000; no local paths or credentials.`);
|
|
210733
|
+
}
|
|
210734
|
+
}
|
|
210519
210735
|
async function registerLocalResource(client, root, file2, options = {}) {
|
|
210520
210736
|
if (options.shared === true ? options.brandId !== void 0 : !options.brandId) fail("Choose --brand ID, or --shared only when the user explicitly wants this resource available to every brand.");
|
|
210521
210737
|
if (options.brandId) assertIdentifier(options.brandId);
|
|
210522
|
-
const
|
|
210523
|
-
if (!mimeType) fail("This registration supports MP4, MOV, WebM, common
|
|
210524
|
-
const
|
|
210738
|
+
const mimeType = mimeTypes[extname4(file2).toLowerCase()];
|
|
210739
|
+
if (!mimeType) fail("This registration supports MP4, MOV, WebM, JPEG, PNG, WebP, GIF, HEIC and common audio files. Convert unsupported media locally first.");
|
|
210740
|
+
const unknownMoment = options.moments?.find((moment) => !resourceUsageMoments.includes(moment));
|
|
210741
|
+
if (unknownMoment !== void 0) fail(`Unknown --moments value "${unknownMoment}". Use: ${resourceUsageMoments.join(", ")}.`);
|
|
210742
|
+
const probe2 = await probeLocalMedia(resolve8(root, file2));
|
|
210743
|
+
const usage = options.moments !== void 0 || options.instructions !== void 0 ? { usage: { moments: options.moments ?? [], instructions: options.instructions ?? "" } } : {};
|
|
210744
|
+
const resource = registeredResource({ schemaVersion: 1, title: options.title ?? basename2(file2), description: options.description ?? "", tags: options.tags ?? [], kind: options.kind ?? (mimeType.startsWith("video/") ? "footage" : mimeType.startsWith("audio/") ? "audio" : "image"), state: "draft", brandId: options.brandId ?? null, media: { sha256: probe2.sha256, mimeType, bytes: probe2.bytes, durationMs: probe2.durationSeconds === null || !mimeType.startsWith("video/") && !mimeType.startsWith("audio/") ? null : Math.round(probe2.durationSeconds * 1e3) }, sources: [], validUntil: null, ...usage });
|
|
210525
210745
|
const existing = await findPersonalResourceByOriginal(probe2.sha256, resource.brandId, (query) => {
|
|
210526
210746
|
const params = new URLSearchParams({ sha256: query.sha256, limit: String(query.limit), state: query.state });
|
|
210527
210747
|
if (query.brandId) params.set("brand", query.brandId);
|
|
@@ -210531,39 +210751,81 @@ async function registerLocalResource(client, root, file2, options = {}) {
|
|
|
210531
210751
|
if (error62 instanceof CliError) throw error62;
|
|
210532
210752
|
throw new CliError("INVALID_RESOURCE_RESPONSE", "Resource discovery did not return a safe advancing page.", "Repeat the read later or inspect the exact existing resource. No new registration or upload was attempted.", false, { outcome: "read_failed" });
|
|
210533
210753
|
});
|
|
210534
|
-
const id4 = existing?.id ?? randomUUID6();
|
|
210535
|
-
const
|
|
210754
|
+
const id4 = existing?.id ?? randomUUID6(), current2 = existing ? await client.request("/v1/resources/" + id4) : void 0;
|
|
210755
|
+
const alreadyAvailable = !!current2 && (current2.availability === "cloud" || current2.availability === "preview" && heicTypes.has(mimeType));
|
|
210756
|
+
const upload = options.upload && !alreadyAvailable ? await prepareUpload(client, probe2, mimeType, file2) : void 0;
|
|
210757
|
+
const result2 = current2 ?? await saveResource(client, id4, resource, 0);
|
|
210536
210758
|
if (!result2 || result2.id !== id4 || !Number.isSafeInteger(result2.revision) || result2.revision < 1 || result2.resource?.brandId !== resource.brandId || result2.resource.media?.sha256 !== probe2.sha256 || result2.resource.media.bytes !== probe2.bytes) throw new CliError("INVALID_RESPONSE", "The original resource identity could not be verified.", "Read resources get with this exact ID before creating a local mapping.", false, { outcome: "read_failed", resourceId: id4 });
|
|
210537
|
-
const
|
|
210538
|
-
const
|
|
210539
|
-
|
|
210540
|
-
|
|
210541
|
-
|
|
210759
|
+
const { workspaceId, namespace } = await mapScope(client);
|
|
210760
|
+
const localMap = await writeMachineMap(namespace, id4, { schemaVersion: 1, endpoint: client.url, workspaceId, resourceId: id4, sourceSha256: probe2.sha256, path: probe2.path });
|
|
210761
|
+
let uploaded = options.upload && alreadyAvailable ? { reused: true } : null;
|
|
210762
|
+
if (upload) {
|
|
210763
|
+
if (!upload.plan.existingAsset) {
|
|
210764
|
+
const params = new URLSearchParams({ name: upload.name, purpose: upload.purpose });
|
|
210765
|
+
if (upload.sourceSha256) params.set("sourceSha256", upload.sourceSha256);
|
|
210766
|
+
const response = await client.media(`/v1/assets/${upload.sha256}?${params}`, { content: upload.content ?? await readVerified(probe2.path, probe2.sha256), mimeType: upload.mimeType });
|
|
210767
|
+
const body = await response.json().catch(() => null);
|
|
210768
|
+
if (body?.sha256 !== upload.sha256) throw new CliError("INVALID_RESPONSE", "The upload could not be confirmed. The resource is registered.", "Read resources get " + id4 + " for its availability before uploading again; repeating resources register --upload reuses the same resource.", false, { resourceId: id4, outcome: "unknown" });
|
|
210769
|
+
}
|
|
210770
|
+
uploaded = { sha256: upload.sha256, purpose: upload.purpose, mimeType: upload.mimeType, bytes: upload.bytes, reused: !!upload.plan.existingAsset };
|
|
210771
|
+
}
|
|
210772
|
+
const availability = (await client.request("/v1/resources/" + id4)).availability;
|
|
210773
|
+
const metadataRequested = ["description", "tags", "moments", "instructions", "title", "kind"].some((key) => options[key] !== void 0);
|
|
210774
|
+
return {
|
|
210775
|
+
id: id4,
|
|
210776
|
+
revision: result2.revision,
|
|
210777
|
+
reused: !!existing,
|
|
210778
|
+
availability,
|
|
210779
|
+
mediaUploaded: availability === "cloud",
|
|
210780
|
+
upload: uploaded,
|
|
210781
|
+
contentReviewed: false,
|
|
210782
|
+
localMap,
|
|
210783
|
+
localMapScope: "machine",
|
|
210784
|
+
...existing && metadataRequested ? { metadataApplied: false, notice: "This original was already registered; its title, tags, description and usage were not changed. Use resources get, then resources save to edit them." } : {},
|
|
210785
|
+
...heicTypes.has(mimeType) ? { note: heicNote } : {},
|
|
210786
|
+
next: availability === "not_uploaded" ? "Any folder on this computer can now find the original with resources locate. Add --upload (when the user allows uploads) to keep a private cloud copy for cloud renders, remote MCP agents and other computers. Registering does not transcribe, analyze or approve it; use resources get to check for an existing index." : "A private cloud copy is available (" + availability + "). Registering does not transcribe, analyze or approve it; use resources get to check for an existing index."
|
|
210787
|
+
};
|
|
210542
210788
|
}
|
|
210543
210789
|
async function locateLocalResource(client, root, id4) {
|
|
210544
210790
|
uuid8(id4);
|
|
210545
|
-
const [item,
|
|
210546
|
-
const
|
|
210547
|
-
|
|
210791
|
+
const [item, { workspaceId, namespace }] = await Promise.all([client.request("/v1/resources/" + id4), mapScope(client)]);
|
|
210792
|
+
const candidates = [];
|
|
210793
|
+
const machine = await readMachineMap(namespace, id4);
|
|
210794
|
+
if (machine) candidates.push({ scope: "machine", mapping: machine });
|
|
210548
210795
|
try {
|
|
210549
|
-
mapping
|
|
210796
|
+
candidates.push({ scope: "folder", mapping: await readProductionJson(root, legacyMapPath(namespace, id4)) });
|
|
210550
210797
|
} catch (error62) {
|
|
210551
|
-
if (error62.code
|
|
210552
|
-
throw error62;
|
|
210798
|
+
if (error62.code !== "ENOENT") throw error62;
|
|
210553
210799
|
}
|
|
210554
|
-
|
|
210555
|
-
const
|
|
210556
|
-
|
|
210557
|
-
|
|
210800
|
+
let changed2 = false;
|
|
210801
|
+
for (const { scope, mapping } of candidates) {
|
|
210802
|
+
if (mapping?.endpoint !== client.url || mapping.workspaceId !== workspaceId || mapping.resourceId !== id4 || mapping.sourceSha256 !== item.resource.media?.sha256 || typeof mapping.path !== "string") fail("Local mapping does not match this workspace and original.");
|
|
210803
|
+
let probe2;
|
|
210804
|
+
try {
|
|
210805
|
+
probe2 = await probeLocalMedia(mapping.path);
|
|
210806
|
+
} catch (error62) {
|
|
210807
|
+
if (error62.code === "ENOENT") continue;
|
|
210808
|
+
throw error62;
|
|
210809
|
+
}
|
|
210810
|
+
if (probe2.sha256 !== mapping.sourceSha256 || probe2.bytes !== item.resource.media?.bytes) {
|
|
210811
|
+
changed2 = true;
|
|
210812
|
+
continue;
|
|
210813
|
+
}
|
|
210814
|
+
if (scope === "folder") await writeMachineMap(namespace, id4, { schemaVersion: 1, endpoint: client.url, workspaceId, resourceId: id4, sourceSha256: probe2.sha256, path: probe2.path });
|
|
210815
|
+
return { id: id4, path: probe2.path, sourceSha256: probe2.sha256, verified: true, index: item.index, availability: item.availability, mediaUploaded: item.availability === "cloud", ...heicTypes.has(item.resource.media?.mimeType ?? "") ? { note: heicNote } : {} };
|
|
210816
|
+
}
|
|
210817
|
+
if (changed2) throw new CliError("RESOURCE_SOURCE_CHANGED", "The local original changed. Its cached index must not be reused.", "Register the changed file as a new resource; keep the old analysis attached to its original hash.");
|
|
210818
|
+
throw new CliError("RESOURCE_NOT_LOCAL", candidates.length ? "The registered original is no longer at its saved location on this computer." : "This resource has no verified original on this computer.", "If the file is on this computer, run resources register --file PATH with the same brand: identical bytes reuse this resource and save its location for every folder. If availability is cloud or preview, use that cloud copy. Otherwise upload it from the computer that has it with resources register --upload. Do not invent a path.", false, { resourceId: id4, availability: item.availability });
|
|
210558
210819
|
}
|
|
210559
210820
|
async function personalResourceCommand(client, root, command, arg, flags) {
|
|
210560
|
-
const allowed = { search: ["query", "brand", "kind", "state", "after", "limit"], get: [], register: ["file", "title", "kind", "brand", "shared"], locate: [], save: ["file", "expected-revision", "user-confirmed"], index: ["file", "expected-revision"], segments: ["offset", "limit", "revision"], attach: ["project"], tempo: ["job", "mapping", "expected-revision"] };
|
|
210821
|
+
const allowed = { search: ["query", "brand", "kind", "state", "after", "limit"], get: [], register: ["file", "title", "kind", "brand", "shared", "description", "tags", "moments", "instructions", "upload"], locate: [], save: ["file", "expected-revision", "user-confirmed"], index: ["file", "expected-revision"], segments: ["offset", "limit", "revision"], attach: ["project"], tempo: ["job", "mapping", "expected-revision"] };
|
|
210561
210822
|
if (!allowed[command]) fail("Use resources search/get/register/locate/save/index/segments/attach.");
|
|
210562
210823
|
for (const key of Object.keys(flags)) if (![...allowed[command], "url", "dir"].includes(key)) fail(`--${key} is not supported here.`);
|
|
210563
210824
|
if (["search", "register"].includes(command) && arg) fail("Use named flags for search/register.");
|
|
210564
210825
|
if (command === "register") {
|
|
210565
210826
|
if (flags.shared !== void 0 && flags.shared !== true) fail("--shared is a boolean flag; omit it for brand-specific resources.");
|
|
210566
|
-
|
|
210827
|
+
if (flags.upload !== void 0 && flags.upload !== true) fail("--upload is a boolean flag; omit it to keep the original local-only.");
|
|
210828
|
+
return registerLocalResource(client, root, flag(flags, "file", true), { title: flag(flags, "title"), kind: flag(flags, "kind"), brandId: flag(flags, "brand"), shared: flags.shared === true, description: flag(flags, "description"), tags: list(flags, "tags"), moments: list(flags, "moments"), instructions: flag(flags, "instructions"), upload: flags.upload === true });
|
|
210567
210829
|
}
|
|
210568
210830
|
if (command === "search") {
|
|
210569
210831
|
const params = new URLSearchParams();
|
|
@@ -210623,19 +210885,77 @@ async function personalResourceCommand(client, root, command, arg, flags) {
|
|
|
210623
210885
|
|
|
210624
210886
|
// packages/cli/src/update.ts
|
|
210625
210887
|
import { execFile as execFile2 } from "node:child_process";
|
|
210626
|
-
import { lstat as lstat18, readFile as readFile6, realpath as
|
|
210627
|
-
import { homedir as
|
|
210628
|
-
import { delimiter, dirname as dirname13, join as
|
|
210888
|
+
import { lstat as lstat18, readFile as readFile6, realpath as realpath5 } from "node:fs/promises";
|
|
210889
|
+
import { homedir as homedir4 } from "node:os";
|
|
210890
|
+
import { delimiter, dirname as dirname13, join as join11, resolve as resolve10 } from "node:path";
|
|
210629
210891
|
import { promisify as promisify2 } from "node:util";
|
|
210630
210892
|
|
|
210631
210893
|
// packages/cli/src/agent-guidance.ts
|
|
210632
210894
|
import { createHash as createHash14 } from "node:crypto";
|
|
210633
|
-
import { constants as
|
|
210634
|
-
import { lstat as lstat16, open as
|
|
210895
|
+
import { constants as constants12 } from "node:fs";
|
|
210896
|
+
import { lstat as lstat16, open as open17, readdir as readdir9, rename as rename4 } from "node:fs/promises";
|
|
210635
210897
|
import { fileURLToPath } from "node:url";
|
|
210636
210898
|
|
|
210637
210899
|
// packages/cli/src/agent-guidance-history.ts
|
|
210638
210900
|
var VERIFIED_GUIDANCE_RELEASES = [
|
|
210901
|
+
{
|
|
210902
|
+
"version": "0.50.0",
|
|
210903
|
+
"archiveSha256": "bdc4389041b62849f286155699593d9af6fb2ae8c643a7d5e128d0317984a75c",
|
|
210904
|
+
"files": {
|
|
210905
|
+
"editorbrain/AGENTS.md": "f6dfcd759e32701be842929124e6f1748a4d6b0553807688b6fc76bc4f5f540f",
|
|
210906
|
+
"editorbrain-formats/references/aspirational-list-demo.md": "e884ce44d15f4496812ed18120f7d4c49c4261e148fcefe05c77c110b589771c",
|
|
210907
|
+
"editorbrain/references/audio-production.md": "101206ec7c8222bc96dffb2f1b7a1a88946054bd5b4d2ddc83235c531e8d88c3",
|
|
210908
|
+
"editorbrain-motion/references/authored-scenes.md": "09310c25a4e96cb5c23ac6a5949d13099b1911c442efd58c6ed7b9ee6942fcbe",
|
|
210909
|
+
"editorbrain/references/captions.md": "83d54a77c108a3f295e5f969ab826b56198fcd442fd138f2521ec0883dbcb8a3",
|
|
210910
|
+
"editorbrain/references/chat-attachments.md": "11d954543a4238b14744aae217226f4a3c413f18fb4c2c2a4559c16bfdbc89c1",
|
|
210911
|
+
"editorbrain/references/cli-mcp.md": "2a9e2a71f35a0b3d3fc600e66d0102c0cb94a5bef324db07b309f4c193a88227",
|
|
210912
|
+
"editorbrain/references/cloud-production.md": "097b34f5a7dc5470f47146590f70be6d88cf2d0270035d9168b4c307bb86a26b",
|
|
210913
|
+
"editorbrain-motion/references/code-motion.md": "50382a797adc1e1596086e2408e81ee75ceb6730ca409be9c884646db643a7cd",
|
|
210914
|
+
"editorbrain-motion/references/component-library.md": "e88ed19d2ab9dca8d2ea02abe6c476021c03b9679bce99292cf7da52d65d2236",
|
|
210915
|
+
"editorbrain-formats/references/cumulative-tier-list.md": "7b7e8208687c6b925443e55d640ced6c1d09824377884244a09d7f3089d60aa5",
|
|
210916
|
+
"editorbrain/references/editorial-evidence.md": "79ed5bd90eb903014313c32a1e337822c5cb454e642bcfa852dcb77d30a9392e",
|
|
210917
|
+
"editorbrain/references/editorial-families.md": "b802ec6f02fd079e99df84d69a3c515d63ad058960b568c0c7b7dec1912495dd",
|
|
210918
|
+
"editorbrain/references/family-animated.md": "54a140d0a64b01147c52ea8cbaab4e4599bfe1af330f5a3ad6ef2a30351ab47d",
|
|
210919
|
+
"editorbrain/references/family-demonstration.md": "737334a8d9230682cde3a6ed11bfc02c4f9795c8f25a3b668be9d7393ec3e53d",
|
|
210920
|
+
"editorbrain/references/family-essay.md": "003f2cd450f33ba6641a9b1114cbc578c04cbb658b992c89c765d43198d1b4c2",
|
|
210921
|
+
"editorbrain/references/family-personal.md": "e93c304d7bc7d3eb31a3c9cb3be83f4f48d41319c2ac2e1e6f53f38576f5e644",
|
|
210922
|
+
"editorbrain/references/family-presenter.md": "76b8140b924930b306ce97772d6a7b683870bd14f19772b5339a490752b7de24",
|
|
210923
|
+
"editorbrain/references/first-edit.md": "60a076152150e70331de111067a38265a6aa757b66754a91d993b16cac2207ae",
|
|
210924
|
+
"editorbrain-motion/references/generated-motion.md": "a8d214b53c15f742658abd84f03b768fa2821f8cde94f50aab82a3759a30b36b",
|
|
210925
|
+
"editorbrain/references/integrations.md": "36f9c424f76435b0461846b96b56ab20ab081a51ba7b995e34d8e588135d0e2d",
|
|
210926
|
+
"editorbrain/references/local-production.md": "93f6bc8ea409a5f8a9b38338d49f6561ff1510060ba798de971e8f8e1d8eb4cd",
|
|
210927
|
+
"editorbrain/references/mcp-studio-artifact.md": "4acaf52b142d35477c81baf1e5def1b6fee182602b3f1076e74faa09660ec149",
|
|
210928
|
+
"editorbrain/references/media-preferences.md": "87e508a75cdb6f4644db767273bfb230fb79f182ed05ee0f6257c6c05ea4dc7a",
|
|
210929
|
+
"editorbrain/references/memory-and-review.md": "406589a18e9e86ad8ce7d71e0f5bf00f67dab42c05af7721482fdca1c25c7c1b",
|
|
210930
|
+
"editorbrain-motion/references/motion-craft.md": "dae520b0e641fc9c3bf937241936588a855bf3453358e239ccc3cc3a2bcf0825",
|
|
210931
|
+
"editorbrain/references/motion-review.md": "0fb09a2d61ecd13114ced5cca5daa4580a922cf7d7b3f8698077ceb0e96da6f0",
|
|
210932
|
+
"editorbrain-formats/references/numbered-tutorial.md": "95754ae7dbfaa678e11ddf1a2b84710dba83a16e2fa4055051bd4f5f4f868a5f",
|
|
210933
|
+
"editorbrain/references/onboarding.md": "4f374e06ebdad032750cedc25cac6e18fab60b524e2bae35a25296dbea11d720",
|
|
210934
|
+
"editorbrain/references/personal-resources.md": "92ce6f32191929bd946c97305452521f6048d6bb8ea371e9083536eff5ce9512",
|
|
210935
|
+
"editorbrain/references/production-and-review.md": "681db59c7d72cd601c2875d8512b2729948f52632fc8448251a9c03d3187ac66",
|
|
210936
|
+
"editorbrain/references/production-continuity.md": "a6dd62dba1e2da475e9a6bac6a2a1dbc234fb5fe7f2cc8e539dd76a7c7a037f9",
|
|
210937
|
+
"editorbrain/references/project-batches.md": "5d5b3429fd638d163c47367b9df45113d345b2414f4687070cc974769768244d",
|
|
210938
|
+
"editorbrain/references/real-media.md": "cfad1aa15198dfe5ecc1f1b67c96d43a7d2084e7f5119de93d1b360203694938",
|
|
210939
|
+
"editorbrain/references/search-brief.md": "1bd2514f961522675047910f001f33da035382e48e933bc5eadb9d7d01455a0d",
|
|
210940
|
+
"editorbrain/references/sfx-library.md": "af8833278ce74f52f9ddcb8a00fc0b8cb7b6c35066531f3c1ce5465a6dccd3d9",
|
|
210941
|
+
"editorbrain-formats/SKILL.md": "65ea59aae091ca9618b5e479befe0c76edf174df7091ed74d4307485a2252fcd",
|
|
210942
|
+
"editorbrain-motion/SKILL.md": "2e75525be4a176c5917d9f36baf328b827705593f7495622a79f29952eb9f8e7",
|
|
210943
|
+
"editorbrain/SKILL.md": "394c35761afe1bd50b4179c5d4d497de090e0ae72bdd6a9936c43e22c8c59c24",
|
|
210944
|
+
"editorbrain/references/starting-an-edit.md": "746094fc9893bb82aa938256313de5ccb412cb2c78864ea502e8515485ce8a3c",
|
|
210945
|
+
"editorbrain/references/storage-and-previews.md": "dce4deed9ce53a3a6fc01bf346dca453b4094bc5215e88a73e2a11bd13e7ee8d",
|
|
210946
|
+
"editorbrain/references/studio.md": "7051a5ec38628341a2286dae88a43b4849e0b01927afb9780de8f4c8799d6a08",
|
|
210947
|
+
"editorbrain/references/style-creator.md": "9de3b2528da9ce092ef0b16d03d8d6a79597f4ed4bd4901501dc79625122519a",
|
|
210948
|
+
"editorbrain/references/style-rules.md": "bdea1cda112ccf82dd500f21d3aac70e5aad462c89cb253c6896d834de1b6e02",
|
|
210949
|
+
"editorbrain/references/style-sharing.md": "11079572c54222fc708d5a85cadf4064b07ae6febff42d8c5fdf5719f934b3fc",
|
|
210950
|
+
"editorbrain/references/style-source.md": "418458a097287c91e7cda02a096743dfe62c3ad3d78a9f7133ba385b2eedd9e6",
|
|
210951
|
+
"editorbrain/references/task-map.md": "254d69a3895bab007d09c319d7f79fdf1f11aa8fb9ed6856350e20e733c8eceb",
|
|
210952
|
+
"editorbrain/references/user-guides.md": "47b49bff489ccd973badebf1a122d5d0e8acc451424afdb9ef19e1fe4c197f2a",
|
|
210953
|
+
"editorbrain/references/voice-cleanup.md": "75e06cef365306ffb84e550e4c720ddc5eae320b7ea5447d6887187b20691e40",
|
|
210954
|
+
"editorbrain/references/workflow-evidence.md": "d9f91dce1ff7e3dc56957ee4a6133fa67b7319264ad0f01f894c540635f95a46",
|
|
210955
|
+
"editorbrain/references/workspace-files.md": "6a3de5598f48b6d42a4c6410b9e94f8a8c58daa7b853242e5372c9cc874e8372",
|
|
210956
|
+
"editorbrain/scripts/deepfilter-cleanup.mjs": "e557a31bea16570c7ab16aaf54f883110bad8a42e28fac6282b0a1aa81de635e"
|
|
210957
|
+
}
|
|
210958
|
+
},
|
|
210639
210959
|
{
|
|
210640
210960
|
"version": "0.49.3",
|
|
210641
210961
|
"archiveSha256": "463a512f80c8227f51c906d53a9b9c06bd32216f71a9b7fa0ef76980c9cbde4a",
|
|
@@ -211880,7 +212200,7 @@ function bundledSkillDirectory(moduleUrl = import.meta.url, skillName = "editorb
|
|
|
211880
212200
|
async function readBytes(root, path) {
|
|
211881
212201
|
const target = await checkedPath(root, path, false);
|
|
211882
212202
|
if (!(await lstat16(target)).isFile()) throw new Error(`Not a regular file: ${path}`);
|
|
211883
|
-
const handle = await
|
|
212203
|
+
const handle = await open17(target, constants12.O_RDONLY | constants12.O_NOFOLLOW);
|
|
211884
212204
|
try {
|
|
211885
212205
|
if (!(await handle.stat()).isFile()) throw new Error(`Not a regular file: ${path}`);
|
|
211886
212206
|
return await handle.readFile();
|
|
@@ -212037,16 +212357,16 @@ async function installAgentGuidance(directory, agent = "both") {
|
|
|
212037
212357
|
// packages/cli/src/skill-installations.ts
|
|
212038
212358
|
import { createHash as createHash15, randomUUID as randomUUID7 } from "node:crypto";
|
|
212039
212359
|
import { readFile as readFile5, readdir as readdir10 } from "node:fs/promises";
|
|
212040
|
-
import { homedir as
|
|
212041
|
-
import { isAbsolute as isAbsolute2, join as
|
|
212360
|
+
import { homedir as homedir3 } from "node:os";
|
|
212361
|
+
import { isAbsolute as isAbsolute2, join as join10 } from "node:path";
|
|
212042
212362
|
|
|
212043
212363
|
// packages/cli/src/doctor.ts
|
|
212044
212364
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
212045
212365
|
import { resolve as resolve9 } from "node:path";
|
|
212046
212366
|
|
|
212047
212367
|
// packages/cli/src/integrations.ts
|
|
212048
|
-
import { constants as
|
|
212049
|
-
import { lstat as lstat17, open as
|
|
212368
|
+
import { constants as constants13 } from "node:fs";
|
|
212369
|
+
import { lstat as lstat17, open as open18 } from "node:fs/promises";
|
|
212050
212370
|
function object14(value) {
|
|
212051
212371
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
212052
212372
|
}
|
|
@@ -212082,7 +212402,7 @@ async function readIntegrationSettings(file2) {
|
|
|
212082
212402
|
const before = await lstat17(file2);
|
|
212083
212403
|
if (!before.isFile() || before.isSymbolicLink() || before.size > limit) throw invalidFile();
|
|
212084
212404
|
const unchanged2 = (info) => info.isFile() && !info.isSymbolicLink() && info.dev === before.dev && info.ino === before.ino && info.size === before.size && info.mtimeMs === before.mtimeMs && info.ctimeMs === before.ctimeMs;
|
|
212085
|
-
const handle = await
|
|
212405
|
+
const handle = await open18(file2, constants13.O_RDONLY | constants13.O_NOFOLLOW | constants13.O_NONBLOCK);
|
|
212086
212406
|
try {
|
|
212087
212407
|
const opened = await handle.stat();
|
|
212088
212408
|
const current2 = await lstat17(file2);
|
|
@@ -212303,7 +212623,7 @@ async function diagnose(options, fetcher = fetch, probeTool = probe) {
|
|
|
212303
212623
|
|
|
212304
212624
|
// packages/cli/src/skill-installations.ts
|
|
212305
212625
|
function installationRegistry() {
|
|
212306
|
-
return
|
|
212626
|
+
return join10(process.env.EDITORBRAIN_CONFIG_DIR ?? process.env.EDITORHARNESS_CONFIG_DIR ?? join10(homedir3(), ".config", "editorbrain"), "skill-installations");
|
|
212307
212627
|
}
|
|
212308
212628
|
function recordName(directory, scope) {
|
|
212309
212629
|
return createHash15("sha256").update(`${scope}\0${directory}`).digest("hex") + ".json";
|
|
@@ -212391,7 +212711,7 @@ async function pinGuidance(directory, pinned, registry2 = installationRegistry()
|
|
|
212391
212711
|
for (const agent of record15.agent === "both" ? ["codex", "claude"] : [record15.agent]) {
|
|
212392
212712
|
for (const skill of BUNDLED_SKILLS) for (const path of await bundledGuidanceFiles(skill)) {
|
|
212393
212713
|
const current2 = await readText(root, `${installedSkillDirectory(agent, skill)}/${path}`, false);
|
|
212394
|
-
const expected = await readFile5(
|
|
212714
|
+
const expected = await readFile5(join10(bundledSkillDirectory(void 0, skill), path), "utf8");
|
|
212395
212715
|
if (current2 !== expected) throw new Error("Project instructions differ from this release; resolve them before pinning.");
|
|
212396
212716
|
}
|
|
212397
212717
|
}
|
|
@@ -212437,11 +212757,11 @@ async function latestPublishedVersion(fetcher = fetch) {
|
|
|
212437
212757
|
}
|
|
212438
212758
|
}
|
|
212439
212759
|
async function npmEntrypoint(env = process.env) {
|
|
212440
|
-
const candidates = [env.npm_execpath,
|
|
212760
|
+
const candidates = [env.npm_execpath, join11(dirname13(process.execPath), "node_modules/npm/bin/npm-cli.js")];
|
|
212441
212761
|
for (const directory of (env.PATH ?? "").split(delimiter).filter(Boolean)) {
|
|
212442
|
-
candidates.push(
|
|
212762
|
+
candidates.push(join11(directory, "node_modules/npm/bin/npm-cli.js"));
|
|
212443
212763
|
try {
|
|
212444
|
-
candidates.push(await
|
|
212764
|
+
candidates.push(await realpath5(join11(directory, "npm")));
|
|
212445
212765
|
} catch {
|
|
212446
212766
|
}
|
|
212447
212767
|
}
|
|
@@ -212482,9 +212802,9 @@ async function installPublishedCli(version2, runner = exec) {
|
|
|
212482
212802
|
);
|
|
212483
212803
|
}
|
|
212484
212804
|
try {
|
|
212485
|
-
const metadata = JSON.parse(await readFile6(
|
|
212805
|
+
const metadata = JSON.parse(await readFile6(join11(root, "editorbrain/package.json"), "utf8"));
|
|
212486
212806
|
if (metadata.name !== "editorbrain" || metadata.version !== version2 || metadata.bin?.editorbrain !== "bin/editorbrain.mjs") throw new Error("Unexpected installed package");
|
|
212487
|
-
const executable =
|
|
212807
|
+
const executable = join11(root, "editorbrain/bin/editorbrain.mjs");
|
|
212488
212808
|
const result2 = JSON.parse((await runner(process.execPath, [executable, "version"], { timeout: 15e3, maxBuffer: 65536 })).stdout);
|
|
212489
212809
|
if (result2.version !== version2) throw new Error("Unexpected executable version");
|
|
212490
212810
|
return executable;
|
|
@@ -212533,7 +212853,7 @@ async function detectAgents(root) {
|
|
|
212533
212853
|
async function planUpdateTargets(options) {
|
|
212534
212854
|
if (options.all && (options.directory || options.global) || options.directory && options.global) throw new Error("Use update with --dir, --global, or --all, not a combination.");
|
|
212535
212855
|
const targets = /* @__PURE__ */ new Map();
|
|
212536
|
-
const home = await ensureRoot(options.home ??
|
|
212856
|
+
const home = await ensureRoot(options.home ?? homedir4());
|
|
212537
212857
|
const add = async (directory, scope, explicit = false) => {
|
|
212538
212858
|
const root = await ensureRoot(directory);
|
|
212539
212859
|
const record15 = await readInstallation(root, scope, options.registry);
|
|
@@ -212705,7 +213025,7 @@ async function projectProgressCommand(client, command, flags) {
|
|
|
212705
213025
|
}
|
|
212706
213026
|
|
|
212707
213027
|
// packages/cli/src/project-intake.ts
|
|
212708
|
-
import { join as
|
|
213028
|
+
import { join as join12 } from "node:path";
|
|
212709
213029
|
async function projectIntakeCommand(client, command, argument, flags) {
|
|
212710
213030
|
const fail4 = (message) => {
|
|
212711
213031
|
throw new CliError("INVALID_ARGUMENT", message, "Use projects create ID --brand ID --style ID --output-profile ID, or projects intake --project ID.");
|
|
@@ -212783,7 +213103,7 @@ async function projectIntakeCommand(client, command, argument, flags) {
|
|
|
212783
213103
|
remoteCreated: typeof result2?.created === "boolean" ? result2.created : null,
|
|
212784
213104
|
remoteProjectAvailable: result2?.workspaceId === me.workspaceId && result2?.project?.id === projectId,
|
|
212785
213105
|
local: { status: "recovery_required", directory: root, materialized, baselined, pending: paths2.filter((path) => !baselined.includes(path)), error: errorOutput(error62) },
|
|
212786
|
-
recovery: { projectId, inspect: ["editorbrain", "projects", "intake", "--project", projectId, "--dir", root], pull: ["editorbrain", "pull", "--project", projectId, "--dir",
|
|
213106
|
+
recovery: { projectId, inspect: ["editorbrain", "projects", "intake", "--project", projectId, "--dir", root], pull: ["editorbrain", "pull", "--project", projectId, "--dir", join12(root, ".editorbrain-local", "recovery", projectId)] },
|
|
212787
213107
|
next: "The remote creation completed. Preserve local edits; inspect the existing project, pull into the recovery directory (it must be empty), compare the documents and reconcile intentionally. Do not repeat create or delete the sync state to force an overwrite."
|
|
212788
213108
|
};
|
|
212789
213109
|
}
|
|
@@ -212791,10 +213111,10 @@ async function projectIntakeCommand(client, command, argument, flags) {
|
|
|
212791
213111
|
}
|
|
212792
213112
|
|
|
212793
213113
|
// packages/cli/src/project-resume.ts
|
|
212794
|
-
import { constants as
|
|
212795
|
-
import { lstat as lstat20, open as
|
|
213114
|
+
import { constants as constants15 } from "node:fs";
|
|
213115
|
+
import { lstat as lstat20, open as open20, readdir as readdir11 } from "node:fs/promises";
|
|
212796
213116
|
import { createHash as createHash17 } from "node:crypto";
|
|
212797
|
-
import { join as
|
|
213117
|
+
import { join as join13, resolve as resolve12 } from "node:path";
|
|
212798
213118
|
|
|
212799
213119
|
// packages/cli/src/project-continuity.ts
|
|
212800
213120
|
var hash8 = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
@@ -213004,8 +213324,8 @@ async function pullProject(client, root, local, options = {}) {
|
|
|
213004
213324
|
|
|
213005
213325
|
// packages/cli/src/verification-cache.ts
|
|
213006
213326
|
import { createHash as createHash16 } from "node:crypto";
|
|
213007
|
-
import { constants as
|
|
213008
|
-
import { lstat as lstat19, open as
|
|
213327
|
+
import { constants as constants14 } from "node:fs";
|
|
213328
|
+
import { lstat as lstat19, open as open19 } from "node:fs/promises";
|
|
213009
213329
|
import { isAbsolute as isAbsolute3, resolve as resolve11 } from "node:path";
|
|
213010
213330
|
var CACHE_FILE = "verification-cache.json";
|
|
213011
213331
|
var MAX_BYTES = 2 * 1024 * 1024;
|
|
@@ -213036,7 +213356,7 @@ async function readCache(directory) {
|
|
|
213036
213356
|
if (!directory) return { schemaVersion: 1, files: [] };
|
|
213037
213357
|
let handle;
|
|
213038
213358
|
try {
|
|
213039
|
-
handle = await
|
|
213359
|
+
handle = await open19(await checkedPath(directory, CACHE_FILE, false), constants14.O_RDONLY | constants14.O_NOFOLLOW | constants14.O_NONBLOCK);
|
|
213040
213360
|
} catch (error62) {
|
|
213041
213361
|
if (error62.code === "ENOENT") return { schemaVersion: 1, files: [] };
|
|
213042
213362
|
throw error62;
|
|
@@ -213069,7 +213389,7 @@ async function verifyLocalFile(options) {
|
|
|
213069
213389
|
} catch (error62) {
|
|
213070
213390
|
cacheWarning = warning(error62);
|
|
213071
213391
|
}
|
|
213072
|
-
const handle = await
|
|
213392
|
+
const handle = await open19(target, constants14.O_RDONLY | constants14.O_NOFOLLOW | constants14.O_NONBLOCK);
|
|
213073
213393
|
let entry, verification, checkedAt;
|
|
213074
213394
|
try {
|
|
213075
213395
|
const before = await handle.stat({ bigint: true });
|
|
@@ -213123,7 +213443,7 @@ var recovery = "Check editorbrain where ID and register the correct folder with
|
|
|
213123
213443
|
async function checkpointFileHash(root, path) {
|
|
213124
213444
|
if (await ensureRoot(root) !== root) throw new CliError("UNSAFE_LOCAL_PATH", "The artifact directory changed through a symlink.", recovery);
|
|
213125
213445
|
const target = await checkedPath(root, path, false);
|
|
213126
|
-
const handle = await
|
|
213446
|
+
const handle = await open20(target, constants15.O_RDONLY | constants15.O_NOFOLLOW | constants15.O_NONBLOCK);
|
|
213127
213447
|
try {
|
|
213128
213448
|
const before = await handle.stat();
|
|
213129
213449
|
if (!before.isFile()) throw new CliError("CHECKPOINT_ARTIFACT_INVALID", `Artifact ${path} must be a regular file.`, "Link its directory and select a concrete scene, render or source file.");
|
|
@@ -213236,6 +213556,7 @@ async function writeProjectCheckpoint(options) {
|
|
|
213236
213556
|
draft.artifacts = [...artifacts.values()];
|
|
213237
213557
|
}
|
|
213238
213558
|
const checkpoint = validateProjectCheckpoint(draft, options.projectId);
|
|
213559
|
+
if (options.validateMilestone) await options.validateMilestone();
|
|
213239
213560
|
const path = checkpointFile;
|
|
213240
213561
|
let current2;
|
|
213241
213562
|
try {
|
|
@@ -213287,8 +213608,8 @@ async function locateCheckpointArtifacts(root, checkpoint, folders, limits = art
|
|
|
213287
213608
|
const visited = /* @__PURE__ */ new Set();
|
|
213288
213609
|
const candidateRoots = [.../* @__PURE__ */ new Set([
|
|
213289
213610
|
...Object.values(folders),
|
|
213290
|
-
|
|
213291
|
-
|
|
213611
|
+
join13(root, "videos", checkpoint.projectId),
|
|
213612
|
+
join13(root, ".editorbrain-local", checkpoint.projectId)
|
|
213292
213613
|
])];
|
|
213293
213614
|
let stop = false;
|
|
213294
213615
|
async function walk(base, relativePath, depth) {
|
|
@@ -213495,8 +213816,8 @@ async function resumeProject(client, projectId, directory, limits = artifactSear
|
|
|
213495
213816
|
}
|
|
213496
213817
|
|
|
213497
213818
|
// packages/cli/src/event-mix.ts
|
|
213498
|
-
import { mkdir as
|
|
213499
|
-
import { dirname as dirname14, join as
|
|
213819
|
+
import { mkdir as mkdir11, readFile as readFile7, writeFile as writeFile2, unlink as unlink10 } from "node:fs/promises";
|
|
213820
|
+
import { dirname as dirname14, join as join14, resolve as resolve13 } from "node:path";
|
|
213500
213821
|
function validateEventCues(value, duration3) {
|
|
213501
213822
|
const v = value;
|
|
213502
213823
|
if (!v || v.schemaVersion !== 1 || v.clock !== "output_seconds" || !Array.isArray(v.cues) || v.cues.length > 300 || Object.keys(v).some((k) => !["schemaVersion", "clock", "cues"].includes(k))) throw new Error("Use schemaVersion 1, clock output_seconds and up to 300 explicit cues.");
|
|
@@ -213571,12 +213892,12 @@ async function mixEvents(options) {
|
|
|
213571
213892
|
sources.push(source2);
|
|
213572
213893
|
}
|
|
213573
213894
|
const directory = await productionOutputPath(options.root, options.out);
|
|
213574
|
-
await
|
|
213895
|
+
await mkdir11(dirname14(directory), { recursive: true, mode: 448 });
|
|
213575
213896
|
await productionOutputPath(options.root, options.out);
|
|
213576
|
-
await
|
|
213577
|
-
const mix = await decode3(voice.path,
|
|
213897
|
+
await mkdir11(directory, { mode: 448 });
|
|
213898
|
+
const mix = await decode3(voice.path, join14(directory, "voice.raw")), records2 = [];
|
|
213578
213899
|
for (let i = 0; i < cues.length; i++) {
|
|
213579
|
-
const effect = await decode3(sources[i].path,
|
|
213900
|
+
const effect = await decode3(sources[i].path, join14(directory, "effect.raw"));
|
|
213580
213901
|
records2.push({ ...cues[i], sourceSha256: sources[i].sha256, sampleFrames: effect.length / 2, ...addEventPcm(mix, effect, cues[i].time, cues[i].peak) });
|
|
213581
213902
|
}
|
|
213582
213903
|
const cuePlan = { durationSeconds: mix.length / 2 / 48e3, hookEndSeconds, cues: records2.map((c) => {
|
|
@@ -213593,16 +213914,16 @@ async function mixEvents(options) {
|
|
|
213593
213914
|
if (peak >= 0.99) throw new Error("Mix would clip: lower explicit cue levels or prepare voice gain first. No automatic voice normalization applied.");
|
|
213594
213915
|
for (const s of [voice, ...sources]) if ((await probeLocalMedia(s.path)).sha256 !== s.sha256) throw new Error("Audio source changed during mix.");
|
|
213595
213916
|
if (options.context && !await options.context.validateContext()) throw new Error("Project preferences changed during the mix. Refresh context; no final mix was written.");
|
|
213596
|
-
const path =
|
|
213917
|
+
const path = join14(directory, "mix.wav");
|
|
213597
213918
|
await writeFile2(path, wav(mix), { flag: "wx", mode: 384 });
|
|
213598
213919
|
const report = { schemaVersion: 1, kind: "editorbrain.event-mix", voiceSha256: voice.sha256, path, clock: "output_seconds", musicAdded: false, voiceGain: 1, cues: records2, peak, mediaUploaded: false, listening: "not_assessed", preferenceCheck, contextScope: options.context?.contextScope ?? "not_checked", contextHash: options.context?.contextVersion ?? null, note: "The SFX maximum peak is aligned to the event, not its file start. Inspect audible attack and sync; those can differ from the peak. Without --project, preferences are not checked; do not claim compliance." };
|
|
213599
|
-
await writeFile2(
|
|
213920
|
+
await writeFile2(join14(directory, "report.json"), JSON.stringify(report, null, 2), { flag: "wx", mode: 384 });
|
|
213600
213921
|
return report;
|
|
213601
213922
|
}
|
|
213602
213923
|
|
|
213603
213924
|
// packages/cli/src/production-sheet.ts
|
|
213604
|
-
import { mkdir as
|
|
213605
|
-
import { dirname as dirname15, join as
|
|
213925
|
+
import { mkdir as mkdir12, readFile as readFile8, writeFile as writeFile3, unlink as unlink11 } from "node:fs/promises";
|
|
213926
|
+
import { dirname as dirname15, join as join15 } from "node:path";
|
|
213606
213927
|
var esc2 = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
213607
213928
|
function freezeIntervals(log, duration3) {
|
|
213608
213929
|
const result2 = [];
|
|
@@ -213641,11 +213962,11 @@ async function createProductionSheet(options) {
|
|
|
213641
213962
|
if (options.platform && input2.platform && options.platform !== input2.platform) throw new Error("Platform flag conflicts with review profile.");
|
|
213642
213963
|
const platform = options.platform ?? input2.platform;
|
|
213643
213964
|
const directory = await productionOutputPath(options.root, options.out);
|
|
213644
|
-
await
|
|
213965
|
+
await mkdir12(dirname15(directory), { recursive: true, mode: 448 });
|
|
213645
213966
|
await productionOutputPath(options.root, options.out);
|
|
213646
|
-
await
|
|
213647
|
-
const raw =
|
|
213648
|
-
const result2 = await runMediaTool("ffmpeg", ["-v", "info", "-nostats", "-n", "-copyts", "-start_at_zero", ...localInputArgs(source2.path), "-filter_complex", `[0:${video[0].index}]split=2[a][b];[a]freezedetect=n=0.003:d=1,fps=fps=1:start_time=0:round=up,scale=240:240:force_original_aspect_ratio=decrease,setsar=1[thumb];[b]fps=fps=1:start_time=0:round=up,scale=96:96,format=gray[gray]`, "-map", "[thumb]", "-an", "-fps_mode", "passthrough", "-q:v", "3",
|
|
213967
|
+
await mkdir12(directory, { mode: 448 });
|
|
213968
|
+
const raw = join15(directory, "samples.gray");
|
|
213969
|
+
const result2 = await runMediaTool("ffmpeg", ["-v", "info", "-nostats", "-n", "-copyts", "-start_at_zero", ...localInputArgs(source2.path), "-filter_complex", `[0:${video[0].index}]split=2[a][b];[a]freezedetect=n=0.003:d=1,fps=fps=1:start_time=0:round=up,scale=240:240:force_original_aspect_ratio=decrease,setsar=1[thumb];[b]fps=fps=1:start_time=0:round=up,scale=96:96,format=gray[gray]`, "-map", "[thumb]", "-an", "-fps_mode", "passthrough", "-q:v", "3", join15(directory, "frame-%05d.jpg"), "-map", "[gray]", "-an", "-f", "rawvideo", raw], { timeoutMs: 6e5, maxOutputBytes: 8 * 1024 * 1024 });
|
|
213649
213970
|
const data = await readFile8(raw);
|
|
213650
213971
|
await unlink11(raw);
|
|
213651
213972
|
const count2 = data.length / (96 * 96);
|
|
@@ -213661,15 +213982,15 @@ async function createProductionSheet(options) {
|
|
|
213661
213982
|
return `<figure><div class="frame"><img loading="lazy" src="frame-${String(i + 1).padStart(5, "0")}.jpg" alt="${i} segundos">${p ? `<i class="bottom"></i><i class="right"></i>` : ""}</div><figcaption>${i}s ${esc2(warnings.join(" \xB7 "))}</figcaption></figure>`;
|
|
213662
213983
|
}).join("");
|
|
213663
213984
|
const html = `<!doctype html><html lang="es"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self' file:; style-src 'unsafe-inline'"><title>EditorBrain \xB7 revisi\xF3n completa</title><style>body{background:#171717;color:#eee;font:15px system-ui;margin:28px}main{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:15px}figure{margin:0}.frame{position:relative;display:table}img{display:block;max-width:100%;height:auto}i{position:absolute;background:#f4474760;pointer-events:none}.bottom{bottom:0;left:0;width:100%;height:${(p?.bottom ?? 0) * 100}%}.right{top:0;right:0;height:100%;width:${(p?.right ?? 0) * 100}%}figcaption{padding:8px 0;min-height:40px;color:#ffd280}p{max-width:850px}</style><h1>Revisi\xF3n del video completo</h1><p>${count2} cuadros \xB7 1 por segundo. ${esc2(platform ?? "Sin perfil social")} \xB7 rojo: riesgo de interfaz aproximado. Las pausas planeadas se excluyen de avisos de congelaci\xF3n. Geometr\xEDa: ${esc2(report.geometryStatus)}. Esto no aprueba la edici\xF3n.</p><p>Sin OCR ni detecci\xF3n autom\xE1tica de logos. Revisa la reproducci\xF3n y los cuadros adyacentes a cada aviso. Informe: report.json.</p><main>${cards}</main></html>`;
|
|
213664
|
-
await writeFile3(
|
|
213665
|
-
await writeFile3(
|
|
213666
|
-
return { kind: report.kind, complete: true, path:
|
|
213985
|
+
await writeFile3(join15(directory, "report.json"), JSON.stringify(report, null, 2), { flag: "wx", mode: 384 });
|
|
213986
|
+
await writeFile3(join15(directory, "index.html"), html, { flag: "wx", mode: 384 });
|
|
213987
|
+
return { kind: report.kind, complete: true, path: join15(directory, "index.html"), reportPath: join15(directory, "report.json"), sourceSha256: source2.sha256, frames: count2, candidates: { freezes: freezes.length, nearlyEmpty: flat.length, geometry: report.candidates.geometry.length }, geometryStatus: report.geometryStatus, creativeQuality: "not_assessed", mediaUploaded: false };
|
|
213667
213988
|
}
|
|
213668
213989
|
|
|
213669
213990
|
// packages/cli/src/presenter-matte.ts
|
|
213670
|
-
import { spawn as
|
|
213671
|
-
import { mkdir as
|
|
213672
|
-
import { dirname as dirname16, join as
|
|
213991
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
213992
|
+
import { mkdir as mkdir13, writeFile as writeFile4, rename as rename5, unlink as unlink12 } from "node:fs/promises";
|
|
213993
|
+
import { dirname as dirname16, join as join16 } from "node:path";
|
|
213673
213994
|
|
|
213674
213995
|
// packages/cli/src/presenter-matte-source.ts
|
|
213675
213996
|
var presenterMatteSource = 'import Foundation\nimport AVFoundation\nimport Vision\nimport CoreImage\nfunc fail(_ message: String) -> Never { fputs(message + "\\n", stderr); exit(1) }\nlet a = CommandLine.arguments\nif a.count != 5 { fail("Expected source, new output, width and height") }\nlet src = URL(fileURLWithPath:a[1]), dst = URL(fileURLWithPath:a[2])\nguard let w = Int(a[3]), let h = Int(a[4]), w > 0, h > 0 else { fail("Invalid dimensions") }\nif FileManager.default.fileExists(atPath:dst.path) { fail("Output already exists") }\nlet asset = AVURLAsset(url:src)\nguard let track = asset.tracks(withMediaType:.video).first else { fail("No video") }\nlet tr = track.preferredTransform\nif abs(tr.b) > 0.001 || abs(tr.c) > 0.001 || tr.a < 0 || tr.d < 0 { fail("Normalize orientation before segmentation") }\nlet reader = try AVAssetReader(asset:asset)\nlet output = AVAssetReaderTrackOutput(track:track,outputSettings:[kCVPixelBufferPixelFormatTypeKey as String:kCVPixelFormatType_32BGRA])\nreader.add(output)\nlet writer = try AVAssetWriter(outputURL:dst,fileType:.mov)\nlet input = AVAssetWriterInput(mediaType:.video,outputSettings:[AVVideoCodecKey:AVVideoCodecType.h264,AVVideoWidthKey:w,AVVideoHeightKey:h,AVVideoCompressionPropertiesKey:[AVVideoAverageBitRateKey:4000000]])\nlet adapter = AVAssetWriterInputPixelBufferAdaptor(assetWriterInput:input,sourcePixelBufferAttributes:[kCVPixelBufferPixelFormatTypeKey as String:kCVPixelFormatType_32BGRA,kCVPixelBufferWidthKey as String:w,kCVPixelBufferHeightKey as String:h,kCVPixelBufferIOSurfacePropertiesKey as String:[:]])\nwriter.add(input)\nif !writer.startWriting() || !reader.startReading() { fail("Cannot start media processing") }\nlet request = VNGeneratePersonSegmentationRequest()\nrequest.qualityLevel = .accurate\nrequest.outputPixelFormat = kCVPixelFormatType_OneComponent8\nlet context = CIContext(options:[.cacheIntermediates:false])\nvar count = 0\nvar origin: CMTime? = nil\nwhile let sb = output.copyNextSampleBuffer() {\n autoreleasepool {\n let sourcePTS = CMSampleBufferGetPresentationTimeStamp(sb)\n if origin == nil { origin = sourcePTS; writer.startSession(atSourceTime:.zero) }\n let pts = CMTimeSubtract(sourcePTS,origin!)\n guard let pb = CMSampleBufferGetImageBuffer(sb) else { fail("Missing input frame") }\n do { try VNImageRequestHandler(cvPixelBuffer:pb,orientation:.up).perform([request]) }\n catch { fail("Segmentation failed; no placeholder was inserted") }\n guard let mask = request.results?.first?.pixelBuffer else { fail("No segmentation result; no placeholder was inserted") }\n let ci = CIImage(cvPixelBuffer:mask)\n let scaled = ci.transformed(by:CGAffineTransform(scaleX:CGFloat(w)/ci.extent.width,y:CGFloat(h)/ci.extent.height))\n let deadline = Date().addingTimeInterval(30)\n while !input.isReadyForMoreMediaData {\n if writer.status == .failed || Date() > deadline { fail("Writer stalled") }\n Thread.sleep(forTimeInterval:0.002)\n }\n guard let pool = adapter.pixelBufferPool else { fail("No pixel buffer pool") }\n var buf:CVPixelBuffer?\n if CVPixelBufferPoolCreatePixelBuffer(nil,pool,&buf) != kCVReturnSuccess || buf == nil { fail("Cannot allocate output frame") }\n context.render(scaled,to:buf!)\n if !adapter.append(buf!,withPresentationTime:pts) { fail("Cannot append output frame") }\n count += 1\n }\n}\nif reader.status != .completed || count == 0 { fail("Incomplete source decode") }\ninput.markAsFinished()\nlet group = DispatchGroup(); group.enter(); writer.finishWriting { group.leave() }\nif group.wait(timeout:.now()+60) != .success || writer.status != .completed { fail("Incomplete output") }\nprint("{\\"frames\\":\\(count),\\"fullMontage\\":true}")\n';
|
|
@@ -213677,7 +213998,7 @@ var presenterMatteSource = 'import Foundation\nimport AVFoundation\nimport Visio
|
|
|
213677
213998
|
// packages/cli/src/presenter-matte.ts
|
|
213678
213999
|
function runLocal(executable, args, timeout) {
|
|
213679
214000
|
return new Promise((resolve21, reject) => {
|
|
213680
|
-
const child =
|
|
214001
|
+
const child = spawn3(executable, args, { shell: false, stdio: ["ignore", "ignore", "pipe"] });
|
|
213681
214002
|
let done = false, size = 0;
|
|
213682
214003
|
const finish2 = (error62) => {
|
|
213683
214004
|
if (done) return;
|
|
@@ -213731,10 +214052,10 @@ async function generatePresenterMatte(options) {
|
|
|
213731
214052
|
const video = videos[0], plan = planPresenterMatte(source2.durationSeconds, video.fps);
|
|
213732
214053
|
if (video.width > 2160 || video.height > 2160 || video.width % 2 || video.height % 2) throw new Error("Normalize montage dimensions: even width and height up to 2160.");
|
|
213733
214054
|
const dir = await productionOutputPath(options.root, options.out);
|
|
213734
|
-
await
|
|
214055
|
+
await mkdir13(dirname16(dir), { recursive: true, mode: 448 });
|
|
213735
214056
|
await productionOutputPath(options.root, options.out);
|
|
213736
|
-
await
|
|
213737
|
-
const swift =
|
|
214057
|
+
await mkdir13(dir, { mode: 448 });
|
|
214058
|
+
const swift = join16(dir, "matte.swift"), binary = join16(dir, "matte-tool"), result2 = join16(dir, "matte.partial.mov");
|
|
213738
214059
|
await writeFile4(swift, presenterMatteSource, { flag: "wx", mode: 384 });
|
|
213739
214060
|
try {
|
|
213740
214061
|
await runLocal("swiftc", ["-O", swift, "-o", binary], 12e4);
|
|
@@ -213742,11 +214063,11 @@ async function generatePresenterMatte(options) {
|
|
|
213742
214063
|
const [clock, matteClock, mask, after] = await Promise.all([readFrameClock(source2.path), readFrameClock(result2), probeLocalMedia(result2), probeLocalMedia(source2.path)]);
|
|
213743
214064
|
assertMatteClocks(clock, matteClock);
|
|
213744
214065
|
if (after.sha256 !== source2.sha256) throw new Error("Source changed during segmentation.");
|
|
213745
|
-
const finalPath =
|
|
214066
|
+
const finalPath = join16(dir, "matte.mov");
|
|
213746
214067
|
await rename5(result2, finalPath);
|
|
213747
214068
|
mask.path = finalPath;
|
|
213748
214069
|
const report = { ...plan, generated: true, engine: "apple-vision-local", source: source2, matte: mask, frames: clock.length, frameClockVerified: true, placeholderFramesInserted: 0, silhouetteQuality: "not_assessed", mediaUploaded: false, modelDownloads: false, note: "Run review-sheet --matte on the result and inspect silhouette edges in motion. A blank mask can mean no person or a missed detection." };
|
|
213749
|
-
await writeFile4(
|
|
214070
|
+
await writeFile4(join16(dir, "report.json"), JSON.stringify(report, null, 2), { flag: "wx", mode: 384 });
|
|
213750
214071
|
return report;
|
|
213751
214072
|
} finally {
|
|
213752
214073
|
await unlink12(binary).catch(() => {
|
|
@@ -213756,7 +214077,7 @@ async function generatePresenterMatte(options) {
|
|
|
213756
214077
|
|
|
213757
214078
|
// packages/cli/src/sfx.ts
|
|
213758
214079
|
import { readdir as readdir12, lstat as lstat21 } from "node:fs/promises";
|
|
213759
|
-
import { join as
|
|
214080
|
+
import { join as join17, extname as extname5, basename as basename3 } from "node:path";
|
|
213760
214081
|
var localPath2 = (id4) => {
|
|
213761
214082
|
sfxBankPath(id4);
|
|
213762
214083
|
return `.editorbrain-local/sfx/${id4}.json`;
|
|
@@ -213770,7 +214091,7 @@ async function indexSfx(directory, input2, bankId) {
|
|
|
213770
214091
|
if (selected.length > 100) throw new Error("Choose a folder with up to 100 audio files; split larger banks by purpose. No files were changed.");
|
|
213771
214092
|
for (const file2 of selected.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
213772
214093
|
try {
|
|
213773
|
-
const probe2 = await probeLocalMedia(
|
|
214094
|
+
const probe2 = await probeLocalMedia(join17(folder, file2.name));
|
|
213774
214095
|
if (!probe2.durationSeconds || probe2.durationSeconds > 600 || !probe2.streams.some((s) => s.type === "audio") || probe2.streams.some((s) => s.type === "video" && !s.attachedPicture)) throw new Error("Expected a measured audio effect up to 600 seconds.");
|
|
213775
214096
|
const id4 = "sfx-" + probe2.sha256.slice(0, 24);
|
|
213776
214097
|
if (paths2[id4]) continue;
|
|
@@ -213833,8 +214154,8 @@ async function remoteSfx(client, subcommand, params) {
|
|
|
213833
214154
|
}
|
|
213834
214155
|
|
|
213835
214156
|
// packages/cli/src/media-preview.ts
|
|
213836
|
-
import { chmod as chmod3, link as link4, mkdtemp as
|
|
213837
|
-
import { dirname as dirname17, join as
|
|
214157
|
+
import { chmod as chmod3, link as link4, mkdtemp as mkdtemp5, rm as rm6 } from "node:fs/promises";
|
|
214158
|
+
import { dirname as dirname17, join as join18 } from "node:path";
|
|
213838
214159
|
async function prepareMediaPreview(root, file2, out, quality = 480, audioStream) {
|
|
213839
214160
|
if (![480, 720, 1080].includes(quality) || !out.endsWith(".mp4")) throw new CliError("INVALID_ARGUMENT", "Use --quality 480, 720 or 1080 and a new .mp4 output.", "Previews belong under .editorbrain-local/.");
|
|
213840
214161
|
const source2 = await probeLocalMedia(await assertLocalMediaFile(file2));
|
|
@@ -213847,9 +214168,9 @@ async function prepareMediaPreview(root, file2, out, quality = 480, audioStream)
|
|
|
213847
214168
|
if (/^(yuva|gbrap|rgba|bgra|argb|abgr|ya)/.test(videos[0].pixelFormat ?? "")) throw new CliError("PREVIEW_ALPHA", "Transparent media needs an explicit background for review.", "Keep the alpha master and export a composited review copy first.");
|
|
213848
214169
|
const selected = audioStream === void 0 ? audio[0] : audio.find((s) => s.index === audioStream);
|
|
213849
214170
|
if (audioStream !== void 0 && !selected) throw new CliError("INVALID_ARGUMENT", "The selected audio stream does not exist.", "Inspect the material before selecting a track.");
|
|
213850
|
-
const target = await prepareSampleDirectory(root, out), temp = await
|
|
214171
|
+
const target = await prepareSampleDirectory(root, out), temp = await mkdtemp5(join18(dirname17(target), ".preview-"));
|
|
213851
214172
|
try {
|
|
213852
|
-
const prepared =
|
|
214173
|
+
const prepared = join18(temp, "preview.mp4"), edge = quality === 480 ? 854 : quality === 720 ? 1280 : 1920;
|
|
213853
214174
|
await runMediaTool("ffmpeg", ["-v", "error", "-n", "-copyts", "-start_at_zero", ...localInputArgs(source2.path), "-map", `0:${videos[0].index}`, ...selected ? ["-map", `0:${selected.index}`, "-c:a", "aac", "-b:a", "128k"] : ["-an"], "-sn", "-dn", "-map_metadata", "-1", "-vf", `scale=w='min(iw,${edge})':h='min(ih,${edge})':force_original_aspect_ratio=decrease:force_divisible_by=2,setsar=1`, "-c:v", "libx264", "-preset", "fast", "-crf", "23", "-pix_fmt", "yuv420p", "-movflags", "+faststart", prepared], { operation: "review-copy", timeoutMs: Math.min(216e5, Math.max(6e5, Math.ceil(source2.durationSeconds * 6e3))) });
|
|
213854
214175
|
const result2 = await probeLocalMedia(prepared);
|
|
213855
214176
|
if (result2.durationSeconds === null || Math.abs(result2.durationSeconds - source2.durationSeconds) > 0.25 || result2.streams.some((s) => s.type === "audio") !== !!selected) throw new CliError("PREVIEW_VERIFICATION", "Preview duration or audio does not match the source.", "No output was accepted. Inspect source timing in your editor.");
|
|
@@ -213858,13 +214179,13 @@ async function prepareMediaPreview(root, file2, out, quality = 480, audioStream)
|
|
|
213858
214179
|
await link4(prepared, target);
|
|
213859
214180
|
return { kind: "editorbrain.review-preview", path: target, sha256: result2.sha256, sourceSha256: source2.sha256, sourceBytes: source2.bytes, bytes: result2.bytes, durationSeconds: result2.durationSeconds, quality, originalPreserved: true, uploaded: false, uploadEligible: result2.bytes <= 90 * 1024 * 1024, savedPercent: Math.round((1 - result2.bytes / source2.bytes) * 100), purpose: "preview", note: "Review copy, not an export master. Inspect text, color and audio before sharing. Small sources may become larger; originals remain untouched." };
|
|
213860
214181
|
} finally {
|
|
213861
|
-
await
|
|
214182
|
+
await rm6(temp, { recursive: true, force: true });
|
|
213862
214183
|
}
|
|
213863
214184
|
}
|
|
213864
214185
|
|
|
213865
214186
|
// packages/cli/src/studio-audio.ts
|
|
213866
|
-
import { link as link5, mkdtemp as
|
|
213867
|
-
import { dirname as dirname18, join as
|
|
214187
|
+
import { link as link5, mkdtemp as mkdtemp6, readFile as readFile9, rm as rm7 } from "node:fs/promises";
|
|
214188
|
+
import { dirname as dirname18, join as join19 } from "node:path";
|
|
213868
214189
|
import { createHash as createHash18 } from "node:crypto";
|
|
213869
214190
|
async function prepareStudioAudio(root, file2, out, streamIndex) {
|
|
213870
214191
|
const source2 = await probeLocalMedia(await assertLocalMediaFile(file2));
|
|
@@ -213875,9 +214196,9 @@ async function prepareStudioAudio(root, file2, out, streamIndex) {
|
|
|
213875
214196
|
if (!selected) throw new CliError("INVALID_ARGUMENT", "The selected stream is not an audio track.", "Inspect media inventory before selecting a track.");
|
|
213876
214197
|
if (source2.durationSeconds === null || source2.durationSeconds > 1800) throw new CliError("AUDIO_DURATION_LIMIT", "Tempo preparation requires a known source duration up to 30 minutes.", "Split long recordings explicitly and preserve each segment offset; never silently truncate.");
|
|
213877
214198
|
if (!out.endsWith(".wav")) throw new CliError("INVALID_ARGUMENT", "The prepared output must be a .wav file.", "Use --out .editorbrain-local/studio/source.wav.");
|
|
213878
|
-
const target = await prepareSampleDirectory(root, out), temp = await
|
|
214199
|
+
const target = await prepareSampleDirectory(root, out), temp = await mkdtemp6(join19(dirname18(target), ".tempo-"));
|
|
213879
214200
|
try {
|
|
213880
|
-
const prepared =
|
|
214201
|
+
const prepared = join19(temp, "audio.wav");
|
|
213881
214202
|
await runMediaTool("ffmpeg", ["-v", "error", "-n", "-copyts", "-start_at_zero", ...localInputArgs(source2.path), "-map", `0:${selected.index}`, "-vn", "-sn", "-dn", "-map_metadata", "-1", "-af", "aresample=16000:async=1:first_pts=0", "-ac", "1", "-ar", "16000", "-c:a", "pcm_s16le", "-t", "1801", prepared], { timeoutMs: 6e5 });
|
|
213882
214203
|
const verified = await probeLocalMedia(prepared);
|
|
213883
214204
|
if (verified.durationSeconds === null || verified.durationSeconds > 1800 || verified.bytes > 90 * 1024 * 1024) throw new CliError("AUDIO_DURATION_LIMIT", "The decoded audio exceeds the supported duration.", "Inspect source timestamps; no file was uploaded.");
|
|
@@ -213886,7 +214207,7 @@ async function prepareStudioAudio(root, file2, out, streamIndex) {
|
|
|
213886
214207
|
await link5(prepared, target);
|
|
213887
214208
|
return { kind: "editorbrain.scribe-input", name: "Tempo", path: target, sha256: hash13, bytes: bytes.length, durationMs: Math.round(verified.durationSeconds * 1e3), mimeType: "audio/wav", sourceSha256: source2.sha256, sourcePath: source2.path, audioStream: selected.index, sourceStartTimeSeconds: source2.startTimeSeconds, timestampBasis: "milliseconds_from_container_start", silenceRemoved: false, uploaded: false, next: "Upload this WAV using assets upload, then quote Tempo with its assetId. Keep this source mapping locally; returned word times refer to this prepared audio." };
|
|
213888
214209
|
} finally {
|
|
213889
|
-
await
|
|
214210
|
+
await rm7(temp, { recursive: true, force: true });
|
|
213890
214211
|
}
|
|
213891
214212
|
}
|
|
213892
214213
|
|
|
@@ -213953,10 +214274,10 @@ async function studioCommand(client, root, command, argument, flags) {
|
|
|
213953
214274
|
}
|
|
213954
214275
|
|
|
213955
214276
|
// packages/cli/src/setup.ts
|
|
213956
|
-
import { spawn as
|
|
214277
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
213957
214278
|
import { resolve as resolve14 } from "node:path";
|
|
213958
214279
|
var runHost = (command, args, cwd, interactive = false) => new Promise((done, reject) => {
|
|
213959
|
-
const child =
|
|
214280
|
+
const child = spawn4(command, args, { cwd, shell: false, stdio: ["ignore", interactive ? 2 : "pipe", interactive ? 2 : "pipe"], windowsHide: !interactive });
|
|
213960
214281
|
let stdout = "", stderr = "", size = 0;
|
|
213961
214282
|
const collect = (kind2, data) => {
|
|
213962
214283
|
size += data.length;
|
|
@@ -214003,14 +214324,14 @@ async function configureMcp(agent, directory, url3, noBrowser, runner = runHost)
|
|
|
214003
214324
|
let exists3 = false;
|
|
214004
214325
|
if (agent === "codex") {
|
|
214005
214326
|
if (inspect.code !== 0) throw new CliError("MCP_INSPECTION_FAILED", "Could not inspect Codex MCP configuration.", "Inspect it manually; setup did not overwrite it.");
|
|
214006
|
-
let
|
|
214327
|
+
let list2;
|
|
214007
214328
|
try {
|
|
214008
|
-
|
|
214329
|
+
list2 = JSON.parse(inspect.stdout);
|
|
214009
214330
|
} catch {
|
|
214010
214331
|
throw new CliError("MCP_INSPECTION_FAILED", "Codex returned an unsupported configuration format.", "Inspect MCP configuration manually.");
|
|
214011
214332
|
}
|
|
214012
|
-
if (!Array.isArray(
|
|
214013
|
-
exists3 =
|
|
214333
|
+
if (!Array.isArray(list2)) throw new CliError("MCP_INSPECTION_FAILED", "Unsupported MCP configuration response.", "Inspect MCP configuration manually.");
|
|
214334
|
+
exists3 = list2.some((item) => item?.name === "editorbrain" || sameMcpEndpoint(item?.transport?.url, endpoint2));
|
|
214014
214335
|
} else {
|
|
214015
214336
|
exists3 = inspect.code === 0;
|
|
214016
214337
|
if (!exists3 && !/^No MCP server named "editorbrain"[.\s]/.test(inspect.stderr + inspect.stdout)) throw new CliError("MCP_INSPECTION_FAILED", "Could not inspect Claude MCP configuration.", "Inspect it manually; setup did not overwrite it.");
|
|
@@ -214089,8 +214410,8 @@ async function setup(options, runner = runHost) {
|
|
|
214089
214410
|
// packages/cli/src/onboarding.ts
|
|
214090
214411
|
import { createServer as createServer2 } from "node:http";
|
|
214091
214412
|
import { randomBytes, createHash as createHash19 } from "node:crypto";
|
|
214092
|
-
import { join as
|
|
214093
|
-
import { mkdir as
|
|
214413
|
+
import { join as join20, dirname as dirname19 } from "node:path";
|
|
214414
|
+
import { mkdir as mkdir14 } from "node:fs/promises";
|
|
214094
214415
|
|
|
214095
214416
|
// packages/core/src/onboarding-brand.ts
|
|
214096
214417
|
var onboardingWordmark = '<svg xmlns="http://www.w3.org/2000/svg"\n width="873" height="131" viewBox="0 0 873.000000 131.000000"\n preserveAspectRatio="xMidYMid meet">\n<!-- Traced from approved Thought Loop lettering, excluding residual background. -->\n<g transform="translate(0.000000,131.000000) scale(0.100000,-0.100000)"\nfill="#f3ede3" stroke="none">\n<path d="M2116 1290 c-41 -13 -63 -36 -82 -87 -14 -36 -15 -50 -6 -81 31 -102\n157 -139 231 -68 50 48 58 116 23 183 -25 46 -107 72 -166 53z"/>\n<path d="M7491 1282 c-69 -34 -97 -113 -68 -185 30 -71 133 -101 204 -57 94\n57 80 202 -24 246 -43 19 -71 18 -112 -4z"/>\n<path d="M4771 1268 c-37 -13 -41 -39 -41 -314 0 -502 11 -894 27 -910 10 -10\n39 -14 97 -14 87 0 116 13 116 53 0 22 12 21 43 -3 75 -60 226 -86 338 -60\n129 30 250 123 302 233 31 66 57 171 57 230 -1 171 -105 339 -257 414 -67 33\n-85 38 -169 41 -113 5 -170 -7 -246 -53 -31 -19 -60 -35 -65 -35 -4 0 -6 84\n-5 188 5 230 5 229 -105 234 -40 2 -81 0 -92 -4z m552 -578 c59 -29 83 -51\n112 -105 32 -61 35 -157 6 -213 -25 -48 -77 -97 -123 -116 -51 -22 -153 -20\n-203 3 -145 66 -185 260 -77 375 67 72 198 97 285 56z"/>\n<path d="M1699 1243 c-11 -13 -13 -56 -11 -205 2 -114 0 -188 -6 -188 -5 0\n-35 15 -67 34 -87 53 -175 67 -285 46 -210 -40 -360 -232 -360 -461 0 -256\n193 -459 436 -459 77 0 155 25 227 74 l52 34 6 -29 c11 -52 24 -59 113 -59 44\n0 86 4 92 8 33 22 36 52 29 330 -3 152 -7 412 -10 576 -3 233 -7 301 -17 307\n-7 5 -52 9 -99 9 -69 0 -89 -3 -100 -17z m-133 -569 c137 -84 153 -274 33\n-377 -121 -104 -299 -65 -377 83 -21 38 -17 151 6 197 65 124 221 170 338 97z"/>\n<path d="M2543 1168 c-4 -7 -10 -65 -13 -128 l-5 -115 -60 -3 c-32 -2 -65 -8\n-72 -14 -9 -7 -13 -38 -13 -94 0 -103 8 -114 90 -114 l58 0 4 -232 c3 -261 9\n-284 82 -366 101 -111 320 -117 422 -11 l29 30 -35 65 c-47 89 -62 99 -111 73\n-49 -24 -80 -24 -112 1 -39 31 -47 77 -47 267 l0 171 98 4 c128 4 132 7 132\n110 0 106 -3 108 -129 108 l-101 0 0 114 c0 146 0 146 -120 146 -60 0 -91 -4\n-97 -12z"/>\n<path d="M4515 941 c-49 -12 -108 -47 -144 -85 -43 -44 -51 -45 -51 -5 0 62\n-11 69 -108 69 -55 0 -95 -5 -105 -12 -16 -12 -17 -46 -15 -431 3 -489 -8\n-447 123 -447 118 0 113 -12 117 260 3 189 6 231 21 265 39 87 122 144 212\n145 75 0 78 5 83 113 5 119 -3 137 -61 136 -23 -1 -55 -4 -72 -8z"/>\n<path d="M6218 940 c-47 -14 -135 -69 -152 -95 -23 -36 -36 -31 -36 13 0 21\n-5 43 -12 50 -16 16 -180 16 -196 0 -9 -9 -12 -119 -12 -435 0 -489 -12 -443\n118 -443 116 0 112 -8 112 241 0 238 9 286 68 351 48 53 102 78 173 78 30 0\n60 5 67 12 8 8 12 48 12 113 0 65 -4 105 -12 113 -13 13 -89 15 -130 2z"/>\n<path d="M8259 940 c-54 -9 -133 -48 -172 -84 -33 -30 -47 -26 -47 13 0 15 -5\n32 -12 39 -14 14 -166 16 -188 2 -13 -8 -15 -67 -15 -428 0 -337 3 -423 14\n-436 10 -12 32 -16 97 -16 129 0 124 -11 124 273 0 129 5 249 10 269 43 154\n261 187 343 53 l27 -46 0 -253 c0 -309 -5 -296 125 -296 135 0 127 -21 123\n343 -3 290 -4 304 -26 352 -34 74 -68 118 -115 152 -75 54 -192 80 -288 63z"/>\n<path d="M350 926 c-102 -29 -192 -95 -249 -184 -97 -153 -97 -381 0 -534 89\n-139 233 -206 422 -195 76 4 99 10 163 41 72 36 174 124 174 151 0 16 -47 57\n-107 91 l-45 27 -26 -22 c-90 -72 -101 -76 -193 -76 -81 0 -90 2 -131 30 -43\n31 -88 95 -88 128 0 16 22 17 314 17 314 0 315 0 330 22 41 58 -8 274 -79 350\n-14 15 -25 30 -25 34 0 20 -128 100 -190 118 -64 19 -205 20 -270 2z m239\n-215 c44 -23 86 -72 96 -113 l7 -28 -211 0 c-171 0 -211 3 -211 14 0 17 45 84\n73 107 58 50 170 58 246 20z"/>\n<path d="M3401 924 c-244 -65 -390 -320 -326 -567 88 -338 502 -461 774 -230\n98 84 151 205 151 348 0 50 -7 111 -15 138 -46 153 -170 271 -328 313 -66 18\n-187 17 -256 -2z m239 -242 c62 -32 115 -100 125 -163 33 -194 -166 -341 -343\n-253 -51 26 -79 55 -115 123 -22 43 -16 134 13 190 60 117 205 164 320 103z"/>\n<path d="M6723 930 c-47 -10 -146 -55 -175 -79 -11 -9 -28 -23 -37 -31 -10 -8\n-38 -45 -63 -81 -61 -90 -82 -168 -76 -296 3 -88 7 -106 41 -176 77 -164 225\n-257 407 -257 64 0 167 33 218 70 51 37 62 37 62 4 0 -42 25 -53 117 -54 73 0\n83 2 97 22 14 19 16 76 16 418 0 298 -3 401 -13 420 -12 23 -18 25 -101 28\n-95 3 -116 -5 -116 -43 0 -35 -11 -37 -48 -9 -75 58 -223 87 -329 64z m243\n-256 c73 -45 107 -100 112 -180 6 -85 -16 -141 -73 -192 -109 -95 -276 -79\n-358 36 -27 37 -32 54 -35 116 -3 48 1 84 10 106 57 136 221 190 344 114z"/>\n<path d="M2065 896 c-14 -20 -15 -76 -13 -431 3 -476 -8 -435 125 -435 123 0\n115 -32 112 447 -1 331 -4 402 -17 420 -13 21 -22 23 -103 23 -82 0 -90 -2\n-104 -24z"/>\n<path d="M7459 903 c-11 -13 -14 -94 -14 -430 0 -483 -10 -443 115 -443 119 0\n110 -35 110 447 0 482 10 443 -117 443 -63 0 -84 -4 -94 -17z"/>\n</g>\n</svg>\n';
|
|
@@ -214963,14 +215284,14 @@ async function createOnboarding(options) {
|
|
|
214963
215284
|
const directory = options.out ?? `.editorbrain-local/onboarding/${brandId2}-${Date.now()}-${randomBytes(3).toString("hex")}`;
|
|
214964
215285
|
await productionOutputPath(root, `${directory}/session.json`);
|
|
214965
215286
|
const target = await checkedPath(root, directory, false);
|
|
214966
|
-
await
|
|
214967
|
-
await
|
|
215287
|
+
await mkdir14(dirname19(target), { recursive: true });
|
|
215288
|
+
await mkdir14(target);
|
|
214968
215289
|
const saved = await snapshots(root, brandId2, projectId), files = Object.fromEntries(Object.entries(saved).flatMap(([p, s]) => s ? [[p, s.content]] : []));
|
|
214969
215290
|
const intake = onboardingIntakeFromFiles(brandId2, files);
|
|
214970
215291
|
const session = { schemaVersion: 1, kind: "editorbrain.onboarding", brandId: brandId2, projectId, intake, snapshots: saved };
|
|
214971
215292
|
await atomicWrite(root, `${directory}/session.json`, stableJson(session), { document: false, overwrite: false, mode: 384 });
|
|
214972
215293
|
await atomicWrite(root, `${directory}/index.html`, renderOnboardingArtifact({ intake, requiresIdentity: saved[`.editorbrain/brands/${brandId2}/brand.md`] === null }), { document: false, overwrite: false, mode: 384 });
|
|
214973
|
-
return { schemaVersion: 1, brandId: brandId2, projectId, configuration: creativeConfiguration(intake.profile?.creativeDirection ?? void 0, intake.profile?.creativePreferencesReviewed ?? void 0), artifact:
|
|
215294
|
+
return { schemaVersion: 1, brandId: brandId2, projectId, configuration: creativeConfiguration(intake.profile?.creativeDirection ?? void 0, intake.profile?.creativePreferencesReviewed ?? void 0), artifact: join20(root, directory, "index.html"), session: `${directory}/session.json`, answers: `${directory}/answers.json`, savedToBrain: false, next: "Show the HTML artifact, or run onboarding serve --session <session>. Static artifacts download answers: put them in this workspace and run onboarding apply --session <session> --file <answers>. Never fill choices on the user\u2019s behalf." };
|
|
214974
215295
|
}
|
|
214975
215296
|
async function applyOnboarding(options) {
|
|
214976
215297
|
const root = await ensureRoot(options.directory);
|
|
@@ -215067,7 +215388,7 @@ async function serveOnboarding(options) {
|
|
|
215067
215388
|
await atomicWrite(root, answers, stableJson(intake), { document: false, overwrite: false, mode: 384 });
|
|
215068
215389
|
consumed = true;
|
|
215069
215390
|
send(200, { saved: true, path: answers });
|
|
215070
|
-
complete({ schemaVersion: 1, saved: true, answers:
|
|
215391
|
+
complete({ schemaVersion: 1, saved: true, answers: join20(root, answers), session: options.session, applied: false, next: "Review saved choices and run onboarding apply with this session and answers file." });
|
|
215071
215392
|
} catch (e) {
|
|
215072
215393
|
busy = false;
|
|
215073
215394
|
send(400, { error: e.message.slice(0, 300) });
|
|
@@ -215087,7 +215408,7 @@ async function serveOnboarding(options) {
|
|
|
215087
215408
|
process.once("SIGINT", stop);
|
|
215088
215409
|
process.once("SIGTERM", stop);
|
|
215089
215410
|
try {
|
|
215090
|
-
options.onReady?.({ url: `${origin}${prefix}/`, answers:
|
|
215411
|
+
options.onReady?.({ url: `${origin}${prefix}/`, answers: join20(root, answers) });
|
|
215091
215412
|
return await done;
|
|
215092
215413
|
} finally {
|
|
215093
215414
|
clearTimeout(timer);
|
|
@@ -215202,7 +215523,7 @@ async function acceptBrainProposal(client, input2) {
|
|
|
215202
215523
|
}
|
|
215203
215524
|
|
|
215204
215525
|
// packages/cli/src/device-auth.ts
|
|
215205
|
-
import { spawn as
|
|
215526
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
215206
215527
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
215207
215528
|
var DEFAULT_API_URL = "https://api.editorbrain.com";
|
|
215208
215529
|
var DeviceLoginError = class extends Error {
|
|
@@ -215221,7 +215542,7 @@ function browserCommand(url3, platform = process.platform) {
|
|
|
215221
215542
|
async function openSystemBrowser(url3) {
|
|
215222
215543
|
const { command, args } = browserCommand(url3);
|
|
215223
215544
|
await new Promise((resolve21, reject) => {
|
|
215224
|
-
const child =
|
|
215545
|
+
const child = spawn5(command, args, { shell: false, stdio: "ignore", detached: true, windowsHide: true });
|
|
215225
215546
|
child.once("error", reject);
|
|
215226
215547
|
child.once("spawn", () => {
|
|
215227
215548
|
child.unref();
|
|
@@ -215338,13 +215659,13 @@ async function loginWithDevice(options, overrides = {}) {
|
|
|
215338
215659
|
options.onBrowserUnavailable?.();
|
|
215339
215660
|
}
|
|
215340
215661
|
}
|
|
215341
|
-
let
|
|
215662
|
+
let interval2 = session.interval * 1e3;
|
|
215342
215663
|
for (; ; ) {
|
|
215343
215664
|
abortCheck(options.signal);
|
|
215344
215665
|
const remaining = deadline - runtime2.now();
|
|
215345
215666
|
if (remaining <= 0) throw expired();
|
|
215346
215667
|
try {
|
|
215347
|
-
await runtime2.sleep(Math.min(
|
|
215668
|
+
await runtime2.sleep(Math.min(interval2, remaining), options.signal);
|
|
215348
215669
|
} catch {
|
|
215349
215670
|
abortCheck(options.signal);
|
|
215350
215671
|
throw expired();
|
|
@@ -215364,7 +215685,7 @@ async function loginWithDevice(options, overrides = {}) {
|
|
|
215364
215685
|
if (response.status === 429) {
|
|
215365
215686
|
const retry = response.headers.get("Retry-After");
|
|
215366
215687
|
const seconds2 = retry && /^\d+$/.test(retry) ? Number(retry) : retry ? (Date.parse(retry) - runtime2.now()) / 1e3 : 0;
|
|
215367
|
-
|
|
215688
|
+
interval2 = Math.min(6e4, Math.max(interval2 + 5e3, Number.isFinite(seconds2) ? seconds2 * 1e3 : 0));
|
|
215368
215689
|
await response.body?.cancel();
|
|
215369
215690
|
continue;
|
|
215370
215691
|
}
|
|
@@ -215382,10 +215703,10 @@ async function loginWithDevice(options, overrides = {}) {
|
|
|
215382
215703
|
}
|
|
215383
215704
|
|
|
215384
215705
|
// packages/cli/src/index.ts
|
|
215385
|
-
import { chmod as chmod4, lstat as lstat26, mkdir as
|
|
215386
|
-
import { constants as
|
|
215387
|
-
import { homedir as
|
|
215388
|
-
import { basename as basename9, dirname as dirname25, extname as extname11, join as
|
|
215706
|
+
import { chmod as chmod4, lstat as lstat26, mkdir as mkdir21, open as open24 } from "node:fs/promises";
|
|
215707
|
+
import { constants as constants19 } from "node:fs";
|
|
215708
|
+
import { homedir as homedir5 } from "node:os";
|
|
215709
|
+
import { basename as basename9, dirname as dirname25, extname as extname11, join as join25, resolve as resolve20 } from "node:path";
|
|
215389
215710
|
|
|
215390
215711
|
// packages/cli/src/workspace-context.ts
|
|
215391
215712
|
async function workspaceContext(root, url3, explicit) {
|
|
@@ -215902,8 +216223,8 @@ async function searchMediaSources(options, dependencies = {}) {
|
|
|
215902
216223
|
|
|
215903
216224
|
// packages/cli/src/media-inventory.ts
|
|
215904
216225
|
import { createHash as createHash20 } from "node:crypto";
|
|
215905
|
-
import { link as link6, lstat as lstat22, mkdir as
|
|
215906
|
-
import { basename as basename4, dirname as dirname20, extname as extname6, join as
|
|
216226
|
+
import { link as link6, lstat as lstat22, mkdir as mkdir15, mkdtemp as mkdtemp7, opendir, readFile as readFile10, rm as rm8 } from "node:fs/promises";
|
|
216227
|
+
import { basename as basename4, dirname as dirname20, extname as extname6, join as join21 } from "node:path";
|
|
215907
216228
|
var GENERATED_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "out", "output", "outputs", "renders", "render", "cache", "caches", "proxies", "proxy", "samples", "thumbnails", "coverage", "venv", "__pycache__"]);
|
|
215908
216229
|
function mediaFailure(error62) {
|
|
215909
216230
|
if (error62 instanceof MediaToolError) return { code: error62.code, message: error62.message };
|
|
@@ -215955,7 +216276,7 @@ async function inventoryMedia(options) {
|
|
|
215955
216276
|
skip(path, "remaining_entries_not_scanned", true);
|
|
215956
216277
|
break;
|
|
215957
216278
|
}
|
|
215958
|
-
await visit2(
|
|
216279
|
+
await visit2(join21(path, entry.name), depth + 1);
|
|
215959
216280
|
}
|
|
215960
216281
|
} else if (!stat2.isFile()) {
|
|
215961
216282
|
if (explicit) throw new MediaToolError("MEDIA_NOT_REGULAR", "The explicit media input must be a regular local file or directory.");
|
|
@@ -215992,13 +216313,13 @@ async function sampleMedia(options) {
|
|
|
215992
216313
|
const outputDirectory = resolveLocalMediaPath(options.outputDirectory);
|
|
215993
216314
|
await assertNoMediaSymlinks(dirname20(outputDirectory));
|
|
215994
216315
|
try {
|
|
215995
|
-
await
|
|
216316
|
+
await mkdir15(outputDirectory);
|
|
215996
216317
|
} catch (error62) {
|
|
215997
216318
|
if (error62.code !== "EEXIST") throw error62;
|
|
215998
216319
|
}
|
|
215999
216320
|
await assertNoMediaSymlinks(outputDirectory);
|
|
216000
216321
|
if (!(await lstat22(outputDirectory)).isDirectory()) throw new MediaToolError("MEDIA_OUTPUT_DIRECTORY_INVALID", "Frame output must be a local directory.");
|
|
216001
|
-
const temp = await
|
|
216322
|
+
const temp = await mkdtemp7(join21(outputDirectory, ".editorbrain-samples-"));
|
|
216002
216323
|
const tempStat = await lstat22(temp);
|
|
216003
216324
|
const frames = [];
|
|
216004
216325
|
const created = [];
|
|
@@ -216006,7 +216327,7 @@ async function sampleMedia(options) {
|
|
|
216006
216327
|
for (let index = 0; index < options.times.length; index++) {
|
|
216007
216328
|
const time3 = options.times[index];
|
|
216008
216329
|
const filename = `${source2.sha256.slice(0, 12)}-${String(index + 1).padStart(2, "0")}-${Math.round(time3 * 1e3)}ms.jpg`;
|
|
216009
|
-
const temporary =
|
|
216330
|
+
const temporary = join21(temp, filename), output3 = join21(outputDirectory, filename);
|
|
216010
216331
|
await runMediaTool("ffmpeg", ["-v", "error", "-n", "-ss", String(time3), ...localInputArgs(file2), "-map", "0:v:0", "-frames:v", "1", "-an", "-sn", "-dn", "-vf", "scale=960:960:force_original_aspect_ratio=decrease", "-q:v", "3", "-update", "1", temporary], { timeoutMs: 6e4 });
|
|
216011
216332
|
const bytes = await readFile10(temporary);
|
|
216012
216333
|
if (!bytes.length) throw new MediaToolError("MEDIA_SAMPLE_EMPTY", "The requested frame did not produce a usable image.");
|
|
@@ -216028,7 +216349,7 @@ async function sampleMedia(options) {
|
|
|
216028
216349
|
try {
|
|
216029
216350
|
await assertNoMediaSymlinks(file3.path);
|
|
216030
216351
|
const current2 = await lstat22(file3.path);
|
|
216031
|
-
if (current2.ino === file3.ino && current2.dev === file3.dev && current2.size === file3.size && current2.mtimeMs === file3.mtimeMs && current2.ctimeMs === file3.ctimeMs) await
|
|
216352
|
+
if (current2.ino === file3.ino && current2.dev === file3.dev && current2.size === file3.size && current2.mtimeMs === file3.mtimeMs && current2.ctimeMs === file3.ctimeMs) await rm8(file3.path, { force: true });
|
|
216032
216353
|
} catch {
|
|
216033
216354
|
}
|
|
216034
216355
|
}
|
|
@@ -216037,7 +216358,7 @@ async function sampleMedia(options) {
|
|
|
216037
216358
|
try {
|
|
216038
216359
|
await assertNoMediaSymlinks(temp);
|
|
216039
216360
|
const current2 = await lstat22(temp);
|
|
216040
|
-
if (current2.ino === tempStat.ino && current2.dev === tempStat.dev) await
|
|
216361
|
+
if (current2.ino === tempStat.ino && current2.dev === tempStat.dev) await rm8(temp, { recursive: true, force: true });
|
|
216041
216362
|
} catch {
|
|
216042
216363
|
}
|
|
216043
216364
|
}
|
|
@@ -216309,8 +216630,8 @@ async function checkRender(options) {
|
|
|
216309
216630
|
|
|
216310
216631
|
// packages/cli/src/motion-components.ts
|
|
216311
216632
|
import { createHash as createHash21 } from "node:crypto";
|
|
216312
|
-
import { constants as
|
|
216313
|
-
import { lstat as lstat23, mkdir as
|
|
216633
|
+
import { constants as constants16 } from "node:fs";
|
|
216634
|
+
import { lstat as lstat23, mkdir as mkdir16, open as open21, rmdir as rmdir2, unlink as unlink13 } from "node:fs/promises";
|
|
216314
216635
|
import { dirname as dirname21, extname as extname7, resolve as resolve16 } from "node:path";
|
|
216315
216636
|
|
|
216316
216637
|
// packages/core/src/motion-editorial.ts
|
|
@@ -218145,7 +218466,7 @@ function inputPath(base, value) {
|
|
|
218145
218466
|
}
|
|
218146
218467
|
async function sourceFile(path, role2, max) {
|
|
218147
218468
|
await assertNoMediaSymlinks(path);
|
|
218148
|
-
const handle = await
|
|
218469
|
+
const handle = await open21(path, constants16.O_RDONLY | constants16.O_NOFOLLOW | constants16.O_NONBLOCK);
|
|
218149
218470
|
try {
|
|
218150
218471
|
const before = await handle.stat();
|
|
218151
218472
|
if (!before.isFile() || before.size === 0 || before.size > max) throw fail2(`${role2} must be a nonempty regular file of at most ${max} bytes.`);
|
|
@@ -218186,7 +218507,7 @@ async function makeParents(root, path, created) {
|
|
|
218186
218507
|
const relative4 = parts.slice(0, index).join("/");
|
|
218187
218508
|
const target = await checkedPath(root, relative4, false);
|
|
218188
218509
|
try {
|
|
218189
|
-
await
|
|
218510
|
+
await mkdir16(target, { mode: 448 });
|
|
218190
218511
|
const info = await lstat23(target);
|
|
218191
218512
|
created.push({ path: relative4, dev: info.dev, ino: info.ino, directory: true });
|
|
218192
218513
|
} catch (error62) {
|
|
@@ -218296,12 +218617,12 @@ Preparation is not a rendered video or a quality certification. Inspect text fit
|
|
|
218296
218617
|
const created = [];
|
|
218297
218618
|
try {
|
|
218298
218619
|
await makeParents(root, dirname21(options.outDirectory), created);
|
|
218299
|
-
await
|
|
218620
|
+
await mkdir16(await productionOutputPath(root, options.outDirectory), { mode: 448 });
|
|
218300
218621
|
const info = await lstat23(output3);
|
|
218301
218622
|
created.push({ path: options.outDirectory, dev: info.dev, ino: info.ino, directory: true });
|
|
218302
218623
|
for (const [name, content] of Object.entries(files)) {
|
|
218303
218624
|
const path = `${options.outDirectory}/${name}`;
|
|
218304
|
-
const handle = await
|
|
218625
|
+
const handle = await open21(await productionOutputPath(root, path), constants16.O_WRONLY | constants16.O_CREAT | constants16.O_EXCL | constants16.O_NOFOLLOW, 384);
|
|
218305
218626
|
try {
|
|
218306
218627
|
const stat2 = await handle.stat();
|
|
218307
218628
|
created.push({ path, dev: stat2.dev, ino: stat2.ino, directory: false });
|
|
@@ -218333,17 +218654,38 @@ Preparation is not a rendered video or a quality certification. Inspect text fit
|
|
|
218333
218654
|
}, { migrateLegacy: false });
|
|
218334
218655
|
}
|
|
218335
218656
|
|
|
218657
|
+
// packages/cli/src/render-delivery.ts
|
|
218658
|
+
async function readDeliveryCheck(client, projectId, sha2562) {
|
|
218659
|
+
const result2 = await client.request(`/v1/projects/${encodeURIComponent(projectId)}/delivery-evidence?sha256=${sha2562}`);
|
|
218660
|
+
if (result2?.schemaVersion !== 1 || result2.projectId !== projectId || result2.artifactSha256 !== sha2562 || !["ready", "blocked"].includes(result2.status) || typeof result2.ready !== "boolean" || result2.ready !== (result2.status === "ready") || !Array.isArray(result2.findings) || !/^[a-f0-9]{64}$/.test(result2.contextVersion)) throw new CliError("DELIVERY_EVIDENCE_INVALID", "The service did not return matching delivery evidence.", "Update the API and retry; never infer local permission from an unavailable policy.");
|
|
218661
|
+
return result2;
|
|
218662
|
+
}
|
|
218663
|
+
async function deliveryCommand(client, root, flags) {
|
|
218664
|
+
for (const k of Object.keys(flags)) if (!["project", "file", "render-override", "dir", "url"].includes(k)) throw new CliError("INVALID_ARGUMENT", `Unsupported --${k}.`, "Use production delivery-check --project ID --file final.mp4 [--render-override exception.json].");
|
|
218665
|
+
const projectId = flags.project, file2 = flags.file;
|
|
218666
|
+
if (typeof projectId !== "string" || typeof file2 !== "string") throw new CliError("INVALID_ARGUMENT", "--project and --file are required.", "Use the exact final file.");
|
|
218667
|
+
assertIdentifier(projectId);
|
|
218668
|
+
if (flags["render-override"] !== void 0 && typeof flags["render-override"] !== "string") throw new CliError("INVALID_ARGUMENT", "--render-override needs a JSON file.", "Use the actual user-requested exception, never implicit consent.");
|
|
218669
|
+
await checkedPath(root, file2, false);
|
|
218670
|
+
const fingerprint2 = await checkpointFileHash(root, file2);
|
|
218671
|
+
const before = await readDeliveryCheck(client, projectId, fingerprint2.sha256);
|
|
218672
|
+
if (typeof flags["render-override"] !== "string") return before;
|
|
218673
|
+
const renderOverride = JSON.parse(await readText(root, flags["render-override"], false));
|
|
218674
|
+
await client.request(`/v1/projects/${encodeURIComponent(projectId)}/delivery-evidence`, { method: "POST", body: { artifactSha256: fingerprint2.sha256, contextVersion: before.contextVersion, renderOverride } });
|
|
218675
|
+
return readDeliveryCheck(client, projectId, fingerprint2.sha256);
|
|
218676
|
+
}
|
|
218677
|
+
|
|
218336
218678
|
// packages/cli/src/production-verify.ts
|
|
218337
218679
|
import { createHash as createHash23, randomUUID as randomUUID9 } from "node:crypto";
|
|
218338
|
-
import { mkdir as
|
|
218339
|
-
import { dirname as dirname23, join as
|
|
218680
|
+
import { mkdir as mkdir18, readFile as readFile11 } from "node:fs/promises";
|
|
218681
|
+
import { dirname as dirname23, join as join23, resolve as resolve18 } from "node:path";
|
|
218340
218682
|
|
|
218341
218683
|
// packages/cli/src/style-rule-check.ts
|
|
218342
|
-
import { spawn as
|
|
218684
|
+
import { spawn as spawn6 } from "node:child_process";
|
|
218343
218685
|
import { createHash as createHash22, randomUUID as randomUUID8 } from "node:crypto";
|
|
218344
|
-
import { constants as
|
|
218345
|
-
import { mkdir as
|
|
218346
|
-
import { dirname as dirname22, join as
|
|
218686
|
+
import { constants as constants17 } from "node:fs";
|
|
218687
|
+
import { mkdir as mkdir17, lstat as lstat24, open as open22, writeFile as writeFile5 } from "node:fs/promises";
|
|
218688
|
+
import { dirname as dirname22, join as join22, resolve as resolve17 } from "node:path";
|
|
218347
218689
|
var digest5 = (value) => createHash22("sha256").update(value).digest("hex");
|
|
218348
218690
|
var HASH = /^[a-f0-9]{64}$/;
|
|
218349
218691
|
var MAX_FRAME_BYTES = 16 * 1024 * 1024;
|
|
@@ -218357,7 +218699,7 @@ function validateOptions(options) {
|
|
|
218357
218699
|
}
|
|
218358
218700
|
async function runTesseract(args, timeoutMs, input2) {
|
|
218359
218701
|
return new Promise((resolveResult, reject) => {
|
|
218360
|
-
const child =
|
|
218702
|
+
const child = spawn6("tesseract", args, { shell: false, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
|
|
218361
218703
|
const chunks = [];
|
|
218362
218704
|
let bytes = 0, done = false;
|
|
218363
218705
|
const fail4 = (code) => {
|
|
@@ -218412,7 +218754,7 @@ function recognizedLines(frame, caseSensitive = false) {
|
|
|
218412
218754
|
}
|
|
218413
218755
|
var errorCode2 = (e) => e instanceof CliError ? e.code : "STYLE_RULE_CHECK_FAILED";
|
|
218414
218756
|
async function readFrameBytes(path, maxBytes) {
|
|
218415
|
-
const handle = await
|
|
218757
|
+
const handle = await open22(path, constants17.O_RDONLY | (constants17.O_NOFOLLOW ?? 0) | (constants17.O_NONBLOCK ?? 0));
|
|
218416
218758
|
try {
|
|
218417
218759
|
const before = await handle.stat();
|
|
218418
218760
|
if (!before.isFile() || before.size < 1 || before.size > maxBytes) throw new CliError("STYLE_FRAME_INVALID", "Invalid bounded frame artifact.", "Repeat verification with stable local outputs.");
|
|
@@ -218439,7 +218781,7 @@ async function captureFrame2(file2, probe2, time3, directory, index, ocr, versio
|
|
|
218439
218781
|
if (!duration3 || time3 >= duration3) throw new CliError("STYLE_FRAME_OUT_OF_RANGE", "Requested frame is outside the final artifact.", "Correct the rule time.");
|
|
218440
218782
|
const timeoutMs = Math.min(3e4, deadline - Date.now());
|
|
218441
218783
|
if (timeoutMs < 1) throw new CliError("STYLE_CHECK_TIMEOUT", "Frame sampling exceeded its budget.", "Use fewer samples.");
|
|
218442
|
-
const imagePath =
|
|
218784
|
+
const imagePath = join22(directory, `frame-${index}.png`), grayPath = join22(directory, `frame-${index}.gray`);
|
|
218443
218785
|
const filters = `[0:${video.index}]select=gte(t\\,${time3}),showinfo,split[a][b];[a]scale='min(1920,iw)':'min(1920,ih)':force_original_aspect_ratio=decrease[pic];[b]scale=64:64,format=gray[pixels]`;
|
|
218444
218786
|
const output3 = await runMediaTool("ffmpeg", ["-loglevel", "info", "-nostats", "-n", "-copyts", "-start_at_zero", "-ss", String(Math.max(0, time3 - 2)), ...localInputArgs(file2), "-filter_complex", filters, "-map", "[pic]", "-frames:v", "1", "-fps_mode", "passthrough", "-update", "1", imagePath, "-map", "[pixels]", "-frames:v", "1", "-fps_mode", "passthrough", "-f", "rawvideo", grayPath], { timeoutMs, maxOutputBytes: 1024 * 1024 });
|
|
218445
218787
|
const png = await readFrameBytes(imagePath, MAX_FRAME_BYTES), pixels = await readFrameBytes(grayPath, 4096);
|
|
@@ -218563,9 +218905,9 @@ async function checkStyleRules(options) {
|
|
|
218563
218905
|
if (decisions && (!options.projectId || decisions.projectId !== options.projectId)) invalid9("Decisions belong to another project or lack project scope.");
|
|
218564
218906
|
const relative4 = options.outDirectory ?? `.editorbrain-local/style-rules-${randomUUID8()}`;
|
|
218565
218907
|
const directory = await productionOutputPath(options.root, relative4);
|
|
218566
|
-
await
|
|
218908
|
+
await mkdir17(dirname22(directory), { recursive: true, mode: 448 });
|
|
218567
218909
|
await productionOutputPath(options.root, relative4);
|
|
218568
|
-
await
|
|
218910
|
+
await mkdir17(directory, { mode: 448 });
|
|
218569
218911
|
const report = {
|
|
218570
218912
|
schemaVersion: 1,
|
|
218571
218913
|
kind: "editorbrain.style-rule-check",
|
|
@@ -218577,7 +218919,7 @@ async function checkStyleRules(options) {
|
|
|
218577
218919
|
frames: [],
|
|
218578
218920
|
results: rules.rules.map(resultFor),
|
|
218579
218921
|
readiness: styleRuleReadiness([]),
|
|
218580
|
-
reportPath:
|
|
218922
|
+
reportPath: join22(directory, "report.json"),
|
|
218581
218923
|
elapsedMs: 0,
|
|
218582
218924
|
mediaModified: false,
|
|
218583
218925
|
mediaUploaded: false,
|
|
@@ -218730,7 +219072,7 @@ async function sampleFinalArtifact(file2, probe2, directory, requested) {
|
|
|
218730
219072
|
result2.failures.push({ requestedTimeSeconds: time3, code: "MEDIA_SAMPLE_OUT_OF_RANGE" });
|
|
218731
219073
|
continue;
|
|
218732
219074
|
}
|
|
218733
|
-
const path =
|
|
219075
|
+
const path = join23(directory, `sample-${String(result2.items.length + result2.failures.length + 1).padStart(2, "0")}.png`);
|
|
218734
219076
|
try {
|
|
218735
219077
|
const output3 = await runMediaTool("ffmpeg", [
|
|
218736
219078
|
// Seek near the sample without resetting its observed presentation clock.
|
|
@@ -218793,6 +219135,9 @@ function summarizeProductionVerification(report) {
|
|
|
218793
219135
|
complete: report.complete,
|
|
218794
219136
|
technicalStatus: report.technicalStatus,
|
|
218795
219137
|
technicalPass: report.technicalPass,
|
|
219138
|
+
delivery: report.delivery,
|
|
219139
|
+
deliveryReady: report.deliveryReady,
|
|
219140
|
+
preferenceReview: report.preferenceReview ? { results: report.preferenceReview.results.map((r) => ({ id: r.id, status: r.status })), decisionsPath: report.preferenceReview.decisionsPath, blocksDelivery: false } : void 0,
|
|
218796
219141
|
...report.styleRules ? { requiredRuleEvidenceSatisfied: report.requiredRuleEvidenceSatisfied, styleRules: { rules: report.styleRules.rules, readiness: report.styleRules.readiness, results: report.styleRules.results.slice(0, 6).map((rule) => ({ id: rule.id, check: rule.check, strength: rule.strength, status: rule.status, reason: rule.reason.slice(0, 180), decisionStatus: rule.decisionStatus })), omitted: Math.max(0, report.styleRules.results.length - 6), reportPath: report.styleRules.reportPath } } : {},
|
|
218797
219142
|
perceptualPending: true,
|
|
218798
219143
|
creativeQuality: report.creativeQuality,
|
|
@@ -218808,7 +219153,7 @@ function summarizeProductionVerification(report) {
|
|
|
218808
219153
|
mediaReview: report.mediaReview,
|
|
218809
219154
|
editorialReview: report.editorialReview,
|
|
218810
219155
|
continuity: report.continuity,
|
|
218811
|
-
agentInstructions: report.
|
|
219156
|
+
agentInstructions: ["Read the full report, inspect the actual video and listen to its mix. Technical, preference and delivery evidence are separate; unknown is not pass. Preserve explicit constraints, scoped adaptations and human approval."],
|
|
218812
219157
|
mediaUploaded: false,
|
|
218813
219158
|
mediaModified: false,
|
|
218814
219159
|
modelCalls: 0
|
|
@@ -218828,10 +219173,10 @@ async function verifyProduction(options) {
|
|
|
218828
219173
|
if (options.sampleTimesSeconds !== void 0 && (!Array.isArray(options.sampleTimesSeconds) || options.sampleTimesSeconds.length < 1 || options.sampleTimesSeconds.length > 6 || Array.from(options.sampleTimesSeconds).some((time3) => typeof time3 !== "number" || !Number.isFinite(time3) || time3 < 0 || time3 > 86400))) throw new CliError("INVALID_SAMPLE_TIMES", "Provide one to six finite sample times between 0 and 86400 seconds.", "Select a few timestamps that answer a review question.");
|
|
218829
219174
|
const relativeDirectory = options.outDirectory ?? `.editorbrain-local/${options.resolved.project.id}/verify-${randomUUID9()}`;
|
|
218830
219175
|
const directory = await productionOutputPath(root, relativeDirectory);
|
|
218831
|
-
await
|
|
219176
|
+
await mkdir18(dirname23(directory), { recursive: true, mode: 448 });
|
|
218832
219177
|
await productionOutputPath(root, relativeDirectory);
|
|
218833
219178
|
try {
|
|
218834
|
-
await
|
|
219179
|
+
await mkdir18(directory, { mode: 448 });
|
|
218835
219180
|
} catch (error62) {
|
|
218836
219181
|
if (error62.code === "EEXIST") throw new CliError("PRODUCTION_OUTPUT_EXISTS", "Verification output already exists; nothing was overwritten.", "Choose a new directory under .editorbrain-local/.");
|
|
218837
219182
|
throw error62;
|
|
@@ -218845,6 +219190,8 @@ async function verifyProduction(options) {
|
|
|
218845
219190
|
context: { sha256: digest6(stableJson(options.resolved)), version: options.contextVersion ?? null, sourceHashes: { ...options.resolved.lock.sourceHashes }, validAtStart: null, validAtEnd: null },
|
|
218846
219191
|
artifact: { path: file2, sha256: null, bytes: null, stableAcrossVerification: null },
|
|
218847
219192
|
requirements,
|
|
219193
|
+
delivery: { status: "unknown", ready: false, reason: "No live execution/storage evidence. Technical checks alone do not establish delivery." },
|
|
219194
|
+
deliveryReady: false,
|
|
218848
219195
|
complete: false,
|
|
218849
219196
|
technicalStatus: "incomplete",
|
|
218850
219197
|
technicalPass: false,
|
|
@@ -218936,6 +219283,16 @@ async function verifyProduction(options) {
|
|
|
218936
219283
|
report.technicalPass = report.complete && !failed;
|
|
218937
219284
|
report.requiredRuleEvidenceSatisfied = report.technicalPass && (report.styleRules?.readiness.requiredReady ?? !styleRules?.rules.some((rule) => rule.strength === "required"));
|
|
218938
219285
|
if (report.styleRules && report.artifact.sha256 !== report.styleRules.artifact.sha256) report.requiredRuleEvidenceSatisfied = false;
|
|
219286
|
+
if (options.checkDelivery && report.artifact.sha256 && report.artifact.stableAcrossVerification) {
|
|
219287
|
+
try {
|
|
219288
|
+
report.delivery = await options.checkDelivery(report.artifact.sha256);
|
|
219289
|
+
if (report.delivery.artifactSha256 !== report.artifact.sha256 || report.delivery.projectId !== options.resolved.project.id || report.delivery.contextVersion !== options.contextVersion) throw new Error("Delivery identity changed");
|
|
219290
|
+
} catch {
|
|
219291
|
+
report.delivery = { status: "unknown", ready: false, reason: "The current delivery policy could not be verified. Re-read preferences; do not fall back to local or report final delivery." };
|
|
219292
|
+
}
|
|
219293
|
+
}
|
|
219294
|
+
if (report.artifact.sha256) report.preferenceReview = await reviewProjectPreferences(options.resolved, report.artifact.sha256, options.composition);
|
|
219295
|
+
report.deliveryReady = report.technicalPass && report.requiredRuleEvidenceSatisfied && report.delivery.ready;
|
|
218939
219296
|
const reportPath = await saveProductionReport(root, `${relativeDirectory}/report.json`, report);
|
|
218940
219297
|
const reportSha256 = digest6(stableJson(report));
|
|
218941
219298
|
return { report, summary: { ...summarizeProductionVerification(report), reportPath, reportSha256 }, reportPath, reportSha256 };
|
|
@@ -218994,6 +219351,10 @@ async function presentProduction(client, root, projectId, value) {
|
|
|
218994
219351
|
} else if (!hash10(data.video?.sha256) || !sidecar.media.some((entry) => entry.sha256 === data.video.sha256 && entry.uri === data.video.uri && ["video/mp4", "video/webm"].includes(entry.mimeType))) {
|
|
218995
219352
|
throw invalid10("A review or delivery requires its exact video medium.");
|
|
218996
219353
|
}
|
|
219354
|
+
if (evidence.phase === "delivery") {
|
|
219355
|
+
if (source2.mediaSha256 && source2.mediaSha256 !== data.video.sha256) throw invalid10("source.mediaSha256 must match the exact video in this artifact.");
|
|
219356
|
+
source2.mediaSha256 = data.video.sha256;
|
|
219357
|
+
}
|
|
218997
219358
|
for (const entry of sidecar.media) {
|
|
218998
219359
|
if (!entry || typeof entry.file !== "string" || !entry.file.startsWith(`${source2.relativePath}.media-`) || !hash10(entry.sha256)) throw invalid10("The local review contains an invalid media reference.");
|
|
218999
219360
|
const match = /^([a-f0-9-]{36})\/([a-f0-9]{64})\.(mp4|webm|png|jpg|jpeg|webp)$/.exec(entry.file.slice(`${source2.relativePath}.media-`.length));
|
|
@@ -219012,7 +219373,7 @@ async function presentProduction(client, root, projectId, value) {
|
|
|
219012
219373
|
const receipt = response.receipt?.evidence ?? (Array.isArray(response.evidence) ? response.evidence.find((fact) => fact?.evidence?.evidenceId === evidence.evidenceId)?.evidence : void 0);
|
|
219013
219374
|
let exact = false;
|
|
219014
219375
|
try {
|
|
219015
|
-
exact = JSON.stringify(parseReviewEvidence(receipt)) === JSON.stringify(evidence);
|
|
219376
|
+
exact = JSON.stringify(parseReviewEvidence(receipt)) === JSON.stringify(parseReviewEvidence(evidence));
|
|
219016
219377
|
} catch {
|
|
219017
219378
|
}
|
|
219018
219379
|
if (response.projectId !== projectId || !hash10(response.contextVersion) || !hash10(response.version) || !exact) throw new CliError("PRESENTATION_OUTCOME_UNKNOWN", "The presentation receipt could not be verified.", "Read production present --project ID --id EVIDENCE_ID before retrying. Never create another ID to conceal an uncertain write.", false, { evidenceId: evidence.evidenceId, outcome: "unknown" });
|
|
@@ -219031,7 +219392,7 @@ async function withdrawPresentation(client, projectId, evidenceId, expectedVersi
|
|
|
219031
219392
|
}
|
|
219032
219393
|
|
|
219033
219394
|
// packages/cli/src/review-artifact.ts
|
|
219034
|
-
import { lstat as lstat25, mkdir as
|
|
219395
|
+
import { lstat as lstat25, mkdir as mkdir19, link as link7, unlink as unlink14 } from "node:fs/promises";
|
|
219035
219396
|
import { basename as basename6, dirname as dirname24, extname as extname9, resolve as resolve19 } from "node:path";
|
|
219036
219397
|
import { createHash as createHash25, randomUUID as randomUUID10 } from "node:crypto";
|
|
219037
219398
|
|
|
@@ -219887,7 +220248,7 @@ async function prepareMedia(root, input2, kind2, mediaDir, entries) {
|
|
|
219887
220248
|
return { uri: `data:${mime2[extension]};base64,${bytes.toString("base64")}`, sha256: sha2562, mimeType: mime2[extension], ...meta3 };
|
|
219888
220249
|
}
|
|
219889
220250
|
const temporary = await productionOutputPath(root, `${mediaDir}/copy-${randomUUID10()}`);
|
|
219890
|
-
await
|
|
220251
|
+
await mkdir19(dirname24(temporary), { recursive: true });
|
|
219891
220252
|
try {
|
|
219892
220253
|
const { sha256: sha2562, bytes } = await copyReviewFile(path, temporary);
|
|
219893
220254
|
if (input2.sha256 && input2.sha256 !== sha2562) invalid11("Preview hash does not match this version.");
|
|
@@ -219927,7 +220288,7 @@ async function createReviewArtifact(root, value, out, mediaMode = "local") {
|
|
|
219927
220288
|
if (JSON.stringify(clean).length > 40 * 1024 * 1024) invalid11("Embedded previews exceed 40 MiB. Use smaller review copies.");
|
|
219928
220289
|
const artifactId = createHash25("sha256").update(JSON.stringify(clean)).digest("hex");
|
|
219929
220290
|
const html = renderReviewArtifact({ ...clean, artifactId }, onboardingWordmark);
|
|
219930
|
-
await
|
|
220291
|
+
await mkdir19(dirname24(target), { recursive: true });
|
|
219931
220292
|
await atomicWrite(root, out, html, { document: false, overwrite: false, mode: 384 });
|
|
219932
220293
|
if (mediaMode === "local") await atomicWrite(root, `${out}.review.json`, JSON.stringify({ schemaVersion: 1, kind: "editorbrain.local-review", artifactId, projectId: input2.projectId, stage: input2.stage, ...input2.contextVersion ? { contextVersion: input2.contextVersion } : {}, ...directions ? { directionIds: directions.map((direction) => direction.id), directionPreviews: Object.fromEntries(directions.filter((direction) => direction.preview).map((direction) => [direction.id, direction.preview.sha256])) } : {}, presented: false, html: { file: out, sha256: createHash25("sha256").update(html).digest("hex"), bytes: Buffer.byteLength(html) }, media: entries }), { document: false, overwrite: false, mode: 384 });
|
|
219933
220294
|
return { kind: "editorbrain.review-artifact", path: target, artifactId, projectId: input2.projectId, stage: input2.stage, videoSha256: video?.sha256 ?? null, mediaEmbedded: mediaMode === "embedded", htmlBytes: Buffer.byteLength(html), mediaBytes: entries.reduce((sum, item) => sum + item.bytes, 0), ...mediaMode === "local" ? { openCommand: { executable: "editorbrain", args: ["production", "review-open", "--file", out, "--dir", root] } } : {}, mediaUploaded: false, agentTriggered: false, reviewSurface: "computer", cloudStorageBytes: 0, next: mediaMode === "local" ? "Run openCommand as a persistent preview process. Open its verified URL in the Claude Code Desktop Browser pane or the host browser. Keep the process alive; verify video playback, seeking and comments before delivery. Do not attach this HTML alone or publish it as a native Claude artifact: its private media are separate. No upload. Clicks do not wake the agent." : "Standalone embedded export: inspect htmlBytes before attaching. Host size/playback limits vary; if rejected, regenerate with --media-mode local and use production review-open. Never paste the base64 file into model context. No upload or automatic agent wake-up." };
|
|
@@ -220186,10 +220547,10 @@ async function productionReviewCommand(client, root, command, flags) {
|
|
|
220186
220547
|
}
|
|
220187
220548
|
|
|
220188
220549
|
// packages/cli/src/production-submit.ts
|
|
220189
|
-
import { constants as
|
|
220190
|
-
import { open as
|
|
220550
|
+
import { constants as constants18 } from "node:fs";
|
|
220551
|
+
import { open as open23, mkdir as mkdir20 } from "node:fs/promises";
|
|
220191
220552
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
220192
|
-
import { basename as basename8, extname as extname10, join as
|
|
220553
|
+
import { basename as basename8, extname as extname10, join as join24 } from "node:path";
|
|
220193
220554
|
|
|
220194
220555
|
// packages/cli/src/production-parent.ts
|
|
220195
220556
|
var UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
@@ -220256,20 +220617,27 @@ async function verifyRegistered(value, receipt) {
|
|
|
220256
220617
|
if (!JSON.parse(value.media.content).assets.some((asset) => asset.id === receipt.preview.sha256)) throw new CliError("SUBMISSION_RESPONSE_INVALID", "The returned media document does not reference this submitted preview.", "Keep the receipt and inspect the registered submission before reconciling media.");
|
|
220257
220618
|
}
|
|
220258
220619
|
async function submitProduction(client, root, flags, runtime2 = { probe: probeLocalMedia, prepare: prepareMediaPreview }) {
|
|
220259
|
-
for (const key of Object.keys(flags)) if (!["project", "file", "title", "parent", "notes", "quality", "dir", "url"].includes(key)) invalid14(`--${key} is not supported for production submit.`);
|
|
220620
|
+
for (const key of Object.keys(flags)) if (!["project", "file", "title", "parent", "notes", "addresses", "revision-kind", "quality", "dir", "url"].includes(key)) invalid14(`--${key} is not supported for production submit.`);
|
|
220260
220621
|
const required2 = (key) => typeof flags[key] === "string" && flags[key].trim() ? flags[key] : invalid14(`--${key} is required.`);
|
|
220261
220622
|
const projectId = assertIdentifier(required2("project")), file2 = required2("file"), title = required2("title").trim();
|
|
220262
220623
|
const notes = flags.notes === void 0 ? void 0 : required2("notes").trim(), parentRevisionId = flags.parent === void 0 ? void 0 : required2("parent");
|
|
220624
|
+
const addresses = flags.addresses === void 0 ? void 0 : required2("addresses").trim();
|
|
220625
|
+
const revisionKind = flags["revision-kind"] === void 0 ? addresses ? "correction" : void 0 : required2("revision-kind");
|
|
220626
|
+
if (addresses && addresses.length > 800 || revisionKind && !["correction", "alternative", "technical", "continuation"].includes(revisionKind) || revisionKind === "correction" && !addresses || addresses && revisionKind !== "correction") invalid14("Use --addresses with the actual correction (up to 800 characters), or --revision-kind alternative|technical|continuation without invented feedback.");
|
|
220263
220627
|
if (title.length > 120 || notes !== void 0 && notes.length > 2e3 || parentRevisionId !== void 0 && parentRevisionId !== "latest" && !UUID2.test(parentRevisionId)) invalid14("Use a title up to 120 characters, notes up to 2000, and a parent UUID or latest.");
|
|
220264
|
-
|
|
220265
|
-
const quality = selectedQuality === 480 ? 480 : selectedQuality === 720 ? 720 : invalid14("--quality must be 480 or 720.");
|
|
220628
|
+
if (flags.quality !== void 0 && !["480", "720"].includes(required2("quality"))) invalid14("--quality must be 480 or 720.");
|
|
220266
220629
|
if (extname10(file2).toLowerCase() !== ".mp4") invalid14("--file must name a workspace-relative MP4.");
|
|
220267
|
-
const sourcePath = await checkedPath(root, file2, false)
|
|
220630
|
+
const sourcePath = await checkedPath(root, file2, false);
|
|
220631
|
+
const qualityPlan = await client.request(`/v1/projects/${encodeURIComponent(projectId)}/production-submissions/plan`);
|
|
220632
|
+
if (![480, 720].includes(qualityPlan.previewQuality ?? 0)) throw new CliError("SUBMISSION_PLAN_INVALID", "The server did not return the saved preview quality.", "Update the API before preparing a review; no preview was created or uploaded.");
|
|
220633
|
+
const selectedQuality = flags.quality === void 0 ? qualityPlan.previewQuality : Number(required2("quality"));
|
|
220634
|
+
const quality = selectedQuality === 480 ? 480 : selectedQuality === 720 ? 720 : invalid14("--quality must be 480 or 720.");
|
|
220635
|
+
const source2 = await runtime2.probe(sourcePath);
|
|
220268
220636
|
const me = await client.me();
|
|
220269
220637
|
await loadSyncState(root, client.url, me.workspaceId);
|
|
220270
|
-
const identity = { endpoint: client.url, workspaceId: me.workspaceId, projectId, sourceSha256: source2.sha256, quality, title, ...notes ? { notes } : {}, ...parentRevisionId === "latest" ? { parentSelector: "latest" } : parentRevisionId ? { parentRevisionId } : {} };
|
|
220638
|
+
const identity = { endpoint: client.url, workspaceId: me.workspaceId, projectId, sourceSha256: source2.sha256, quality, title, ...notes ? { notes } : {}, ...addresses ? { addresses } : {}, ...revisionKind ? { revisionKind } : {}, ...parentRevisionId === "latest" ? { parentSelector: "latest" } : parentRevisionId ? { parentRevisionId } : {} };
|
|
220271
220639
|
const fingerprint2 = await sha256(stableJson(identity)), directory = `.editorbrain-local/${projectId}/submissions`, receiptPath = `${directory}/${fingerprint2}.json`;
|
|
220272
|
-
await
|
|
220640
|
+
await mkdir20(await checkedPath(root, directory, false), { recursive: true });
|
|
220273
220641
|
const base = `/v1/projects/${encodeURIComponent(projectId)}/production-submissions`;
|
|
220274
220642
|
return withWorkspaceLock(await checkedPath(root, directory, false), async () => {
|
|
220275
220643
|
const save = async (receipt2) => atomicWrite(root, receiptPath, stableJson(receipt2), { document: false, mode: 384 });
|
|
@@ -220288,7 +220656,7 @@ async function submitProduction(client, root, flags, runtime2 = { probe: probeLo
|
|
|
220288
220656
|
} catch {
|
|
220289
220657
|
throw new CliError("SUBMISSION_RECEIPT_INVALID", "The local submission receipt is invalid JSON.", "Preserve the receipt and reconcile its submission ID; do not delete it to repeat an upload.");
|
|
220290
220658
|
}
|
|
220291
|
-
const actual = receipt && { endpoint: receipt.endpoint, workspaceId: receipt.workspaceId, projectId: receipt.projectId, sourceSha256: receipt.sourceSha256, quality: receipt.quality, title: receipt.title, ...receipt.notes ? { notes: receipt.notes } : {}, ...receipt.parentSelector === "latest" ? { parentSelector: "latest" } : receipt.parentRevisionId ? { parentRevisionId: receipt.parentRevisionId } : {} };
|
|
220659
|
+
const actual = receipt && { endpoint: receipt.endpoint, workspaceId: receipt.workspaceId, projectId: receipt.projectId, sourceSha256: receipt.sourceSha256, quality: receipt.quality, title: receipt.title, ...receipt.notes ? { notes: receipt.notes } : {}, ...receipt.addresses ? { addresses: receipt.addresses } : {}, ...receipt.revisionKind ? { revisionKind: receipt.revisionKind } : {}, ...receipt.parentSelector === "latest" ? { parentSelector: "latest" } : receipt.parentRevisionId ? { parentRevisionId: receipt.parentRevisionId } : {} };
|
|
220292
220660
|
if (receipt?.parentSelector !== void 0 && receipt.parentSelector !== "latest" || receipt?.parentSelector === "latest" && !UUID2.test(receipt.parentRevisionId ?? "") || receipt?.parentRevisionId !== void 0 && !UUID2.test(receipt.parentRevisionId)) throw new CliError("SUBMISSION_RECEIPT_INVALID", "The saved parent selection is invalid.", "Preserve the receipt and inspect its exact parent UUID. Do not resolve latest again.");
|
|
220293
220661
|
if (!receipt || receipt.schemaVersion !== 1 || receipt.fingerprint !== fingerprint2 || stableJson(actual) !== stableJson(identity) || !UUID2.test(receipt.submissionId) || !HASH2.test(receipt.contextVersion) || !Number.isSafeInteger(receipt.expectedMediaRevision) || receipt.expectedMediaRevision < 0 || !["prepared", "uploading", "uploaded", "submitting", "registered"].includes(receipt.state) || receipt.localMedia !== null && typeof receipt.localMedia !== "string" || receipt.baseline !== null && (!receipt.baseline || !Number.isSafeInteger(receipt.baseline.revision) || receipt.baseline.revision < 1 || !HASH2.test(receipt.baseline.sha256))) throw new CliError("SUBMISSION_RECEIPT_INVALID", "The local submission receipt does not match this project and input.", "Preserve it and reconcile the saved submission before starting another.");
|
|
220294
220662
|
if (receipt.preview && (!receipt.preview.path.startsWith(`${directory}/${fingerprint2}-`) || !receipt.preview.path.endsWith(".mp4") || !HASH2.test(receipt.preview.sha256) || !Number.isSafeInteger(receipt.preview.bytes) || receipt.preview.bytes < 1 || receipt.preview.bytes > MAX_BYTES2)) throw new CliError("SUBMISSION_RECEIPT_INVALID", "The saved preview metadata is invalid.", "Preserve the receipt and reconcile the saved submission.");
|
|
@@ -220336,7 +220704,7 @@ async function submitProduction(client, root, flags, runtime2 = { probe: probeLo
|
|
|
220336
220704
|
if (receipt.state === "prepared" || receipt.state === "uploading") {
|
|
220337
220705
|
const previewPath = await checkedPath(root, receipt.preview.path, false), preview = await runtime2.probe(previewPath);
|
|
220338
220706
|
if (preview.sha256 !== receipt.preview.sha256 || preview.bytes !== receipt.preview.bytes || preview.bytes > plan.upload.maxFileBytes) throw new CliError("SUBMISSION_PREVIEW_CHANGED", "The saved preview bytes changed.", "Preserve the submission receipt and restore its exact preview before retrying.");
|
|
220339
|
-
const handle = await
|
|
220707
|
+
const handle = await open23(previewPath, constants18.O_RDONLY | constants18.O_NOFOLLOW | constants18.O_NONBLOCK);
|
|
220340
220708
|
let bytes;
|
|
220341
220709
|
try {
|
|
220342
220710
|
const stat2 = await handle.stat();
|
|
@@ -220355,7 +220723,7 @@ async function submitProduction(client, root, flags, runtime2 = { probe: probeLo
|
|
|
220355
220723
|
receipt.state = "uploaded";
|
|
220356
220724
|
await save(receipt);
|
|
220357
220725
|
}
|
|
220358
|
-
const body = { submissionId: receipt.submissionId, assetId: receipt.preview.sha256, contextVersion: receipt.contextVersion, title, ...notes ? { notes } : {}, ...receipt.parentRevisionId ? { parentRevisionId: receipt.parentRevisionId, supersedeParent: true } : {}, expectedMediaRevision: receipt.expectedMediaRevision };
|
|
220726
|
+
const body = { submissionId: receipt.submissionId, assetId: receipt.preview.sha256, contextVersion: receipt.contextVersion, title, ...notes ? { notes } : {}, ...addresses ? { addresses } : {}, ...revisionKind ? { revisionKind } : {}, ...receipt.parentRevisionId ? { parentRevisionId: receipt.parentRevisionId, supersedeParent: true } : {}, expectedMediaRevision: receipt.expectedMediaRevision };
|
|
220359
220727
|
receipt.state = "submitting";
|
|
220360
220728
|
await save(receipt);
|
|
220361
220729
|
const registered2 = await client.request(base, { method: "POST", body });
|
|
@@ -220380,9 +220748,9 @@ async function submitProduction(client, root, flags, runtime2 = { probe: probeLo
|
|
|
220380
220748
|
} catch (error62) {
|
|
220381
220749
|
local = { status: "recovery_required", error: errorOutput(error62), remoteMedia: registered.media };
|
|
220382
220750
|
}
|
|
220383
|
-
return { ...registered, ...local.status === "recovery_required" ? { status: "partial", synced: false } : {}, ...receipt.parentSelector ? { parentSelection: { requested: receipt.parentSelector, revisionId: receipt.parentRevisionId } } : {}, receipt:
|
|
220751
|
+
return { ...registered, previewQuality: quality, warnings: quality !== qualityPlan.previewQuality ? [{ code: "preview_quality_override", saved: qualityPlan.previewQuality, requested: quality, message: "Explicit preview quality differs from the saved preference; account settings were not changed." }] : [], ...local.status === "recovery_required" ? { status: "partial", synced: false } : {}, ...receipt.parentSelector ? { parentSelection: { requested: receipt.parentSelector, revisionId: receipt.parentRevisionId } } : {}, receipt: join24(root, receiptPath), reused, local, approved: false, shared: false, originalPreserved: true, next: (registered.localSync ? `Run editorbrain pull --project ${projectId} in this workspace before continuing; preserve local conflicts. ` : "") + (local.status === "ready" ? "Review this exact private sample. Registration does not approve editorial quality." : "The private review is registered. Preserve local edits and reconcile the returned media document; retrying this command reads the same submission without another upload or revision.") };
|
|
220384
220752
|
} catch (error62) {
|
|
220385
|
-
const details = { ...receipt ? { submissionId: receipt.submissionId, submissionState: receipt.state, remoteRegistered: receipt.state === "registered" } : {}, receipt:
|
|
220753
|
+
const details = { ...receipt ? { submissionId: receipt.submissionId, submissionState: receipt.state, remoteRegistered: receipt.state === "registered" } : {}, receipt: join24(root, receiptPath) };
|
|
220386
220754
|
if (error62 instanceof CliError) {
|
|
220387
220755
|
error62.details = { ...error62.details, ...details };
|
|
220388
220756
|
throw error62;
|
|
@@ -220411,7 +220779,7 @@ editorbrain onboarding apply --session path --file answers.json [--dir folder] [
|
|
|
220411
220779
|
editorbrain onboarding sync --session path [--dir folder] [--dry-run]
|
|
220412
220780
|
editorbrain resources guide
|
|
220413
220781
|
editorbrain resources search [--query text] [--brand ID] [--kind logo|footage|product-fact] [--state draft|approved|archived] [--limit 20] [--after CURSOR]
|
|
220414
|
-
editorbrain resources register --file local-video.mp4 (--brand ID | --shared) [--title text] [--kind footage|broll|demo|logo|image|audio]
|
|
220782
|
+
editorbrain resources register --file local-video.mp4 (--brand ID | --shared) [--title text] [--kind footage|broll|demo|logo|image|audio] [--tags a,b] [--description text] [--moments identity,opening,explanation,demonstration,background,transition,closing] [--instructions text] [--upload]
|
|
220415
220783
|
editorbrain resources get UUID
|
|
220416
220784
|
editorbrain resources locate UUID [--dir folder]
|
|
220417
220785
|
editorbrain resources save UUID --file resource.json --expected-revision N [--user-confirmed]
|
|
@@ -220478,7 +220846,7 @@ editorbrain learning save --file learning.json [--dir folder] [--user-confirmed]
|
|
|
220478
220846
|
editorbrain learning promote --file promotion.json --user-confirmed [--dir folder]
|
|
220479
220847
|
editorbrain learning consent [--file consent.json --user-confirmed] [--dir folder]
|
|
220480
220848
|
editorbrain learning signal --file signal.json [--dir folder]
|
|
220481
|
-
editorbrain feedback add --project ID --text TEXT
|
|
220849
|
+
editorbrain feedback add --project ID --text TEXT [--capture-memory] [--category captions|cuts|layout|motion|media|sound|color|story|other] [--conditions TEXT] [--preference-field FIELD --preference-value VALUE]
|
|
220482
220850
|
editorbrain improvements list --brand ID
|
|
220483
220851
|
editorbrain improvements accept RUN --index N --expected-revision N
|
|
220484
220852
|
editorbrain review list --project ID
|
|
@@ -220563,7 +220931,8 @@ editorbrain production matte-check --file montage.mp4 --mask-file mask.mp4 [--di
|
|
|
220563
220931
|
editorbrain production matte --engine apple-vision --file montage.mp4 --out .editorbrain-local/new-matte [--dir folder]
|
|
220564
220932
|
editorbrain production matte-plan --file montage.mp4 [--dir folder]
|
|
220565
220933
|
editorbrain production check --file render [--profile local-profile.json] [--dir folder] [--out .editorbrain-local/report.json] [--details]
|
|
220566
|
-
editorbrain production
|
|
220934
|
+
editorbrain production delivery-check --project ID --file final.mp4 [--render-override exception.json] [--dir folder]
|
|
220935
|
+
editorbrain production verify --project ID --file final.mp4 [--composition evidence.json] [--ocr] [--ocr-language eng] [--audio-profile audio.json] [--review-inputs continuity.json] [--platform tiktok|reels|shorts] [--profile geometry.json] [--duration seconds] [--at 0,5,12] [--dir folder] [--out .editorbrain-local/new-check] [--offline] [--details]
|
|
220567
220936
|
editorbrain production review-artifact --file review.json --out .editorbrain-local/review-v1.html [--media-mode local|embedded] [--dir folder]
|
|
220568
220937
|
editorbrain production present --project ID [--file presentation.json | --id UUID] [--dir folder] [--url https://server]
|
|
220569
220938
|
editorbrain production withdraw --project ID --id UUID --expected-version HASH --user-confirmed [--url https://server]
|
|
@@ -220571,7 +220940,7 @@ editorbrain production review-open --file .editorbrain-local/review-v1.html [--p
|
|
|
220571
220940
|
editorbrain production reviews --project ID [--after UUID]
|
|
220572
220941
|
editorbrain production transcript --project ID --revision UUID
|
|
220573
220942
|
editorbrain production sample --project ID --file sample.json [--dir folder]
|
|
220574
|
-
editorbrain production submit --project ID --file relative.mp4 --title TEXT [--parent UUID|latest] [--notes TEXT] [--quality 480|720] [--dir folder]
|
|
220943
|
+
editorbrain production submit --project ID --file relative.mp4 --title TEXT [--parent UUID|latest] [--addresses TEXT | --revision-kind alternative|technical|continuation] [--notes TEXT] [--quality 480|720] [--dir folder]
|
|
220575
220944
|
editorbrain production approve --project ID --revision ID --context-version HASH --user-confirmed
|
|
220576
220945
|
editorbrain production change --project ID --revision ID --context-version HASH --text TEXT [--at start,end] [--id UUID]
|
|
220577
220946
|
editorbrain production feedback --project ID [--revision ID] [--status pending|resolved] [--after UUID]
|
|
@@ -220615,8 +220984,8 @@ function parseArgs(argv) {
|
|
|
220615
220984
|
const repeated = {};
|
|
220616
220985
|
const counts = /* @__PURE__ */ new Map();
|
|
220617
220986
|
const motionFilters = /* @__PURE__ */ new Map();
|
|
220618
|
-
const booleans = /* @__PURE__ */ new Set(["summary", "tasks", "ocr", "rehash", "deduplicate", "with-resources", "tresD", "remote", "global", "shared", "matte", "local", "include-unverified", "help", "version", "offline", "dry-run", "key-stdin", "invite-stdin", "no-browser", "skip-mcp", "all", "share-authorized", "details", "include-unknown", "reviewed", "user-confirmed", "confirm"]);
|
|
220619
|
-
const known = /* @__PURE__ */ new Set(["request-id", "expected-version", "render-override", "format", "demo-text", "video-out", "start", "browser-executable", "ocr-language", "previous-context", "output-profile", "review-inputs", "audio-profile", "from-project", "scene", "bindings", "parameters", "hook-end", "context-hash", "segment", "engine", "mask-file", "platform", "voice", "cues", "bank", "scene-role", "catalog-sha256", "quality", "purpose", "source-sha256", "ids", "max-credits", "audio-stream", "manifest", "query", "provider", "licenses", "input", "max-files", "at", "profile", "inventory", "plan", "dir", "brand", "style", "project", "topic", "goal", "name", "adapter", "out", "url", "document", "mime", "label", "role", "limit", "cursor", "timeout", "assets", "capabilities", "duration", "agent", "workspace", "prefix", "sha256", "kind", "channel", "epistemic-status", "event-offset", "relation-offset", "script", "video", "asset", "requirements", "mode", "review", "previous-version", "previous-context-version", "category", "style-version", "file", "revision", "expected-revision", "before", "scope", "id", "text", "conditions", "status", "index", "title", "days", ...booleans]);
|
|
220987
|
+
const booleans = /* @__PURE__ */ new Set(["capture-memory", "summary", "tasks", "ocr", "rehash", "deduplicate", "with-resources", "tresD", "remote", "global", "shared", "matte", "local", "include-unverified", "help", "version", "offline", "dry-run", "key-stdin", "invite-stdin", "no-browser", "skip-mcp", "all", "share-authorized", "details", "include-unknown", "reviewed", "user-confirmed", "confirm"]);
|
|
220988
|
+
const known = /* @__PURE__ */ new Set(["composition", "request-id", "expected-version", "render-override", "format", "demo-text", "video-out", "start", "browser-executable", "ocr-language", "previous-context", "output-profile", "review-inputs", "audio-profile", "from-project", "scene", "bindings", "parameters", "hook-end", "context-hash", "segment", "engine", "mask-file", "platform", "voice", "cues", "bank", "scene-role", "catalog-sha256", "quality", "purpose", "source-sha256", "ids", "max-credits", "audio-stream", "manifest", "query", "provider", "licenses", "input", "max-files", "at", "profile", "inventory", "plan", "dir", "brand", "style", "project", "topic", "goal", "name", "adapter", "out", "url", "document", "mime", "label", "role", "limit", "cursor", "timeout", "assets", "capabilities", "duration", "agent", "workspace", "prefix", "sha256", "kind", "channel", "epistemic-status", "event-offset", "relation-offset", "script", "video", "asset", "requirements", "mode", "review", "previous-version", "previous-context-version", "category", "style-version", "file", "revision", "expected-revision", "before", "scope", "id", "text", "conditions", "status", "index", "title", "days", ...booleans]);
|
|
220620
220989
|
for (const flag2 of ["path", "next", "done", "pending", "decision", "artifact", "dependency", "expected-checkpoint", "current-version", "primary-artifact", "render-command", "since", "sort"]) known.add(flag2);
|
|
220621
220990
|
known.add("material");
|
|
220622
220991
|
known.add("funcion");
|
|
@@ -220637,11 +221006,22 @@ function parseArgs(argv) {
|
|
|
220637
221006
|
known.add("expected-version");
|
|
220638
221007
|
known.add("lease-token");
|
|
220639
221008
|
known.add("batch-lease-token");
|
|
221009
|
+
known.add("addresses");
|
|
221010
|
+
known.add("revision-kind");
|
|
221011
|
+
known.add("preference-field");
|
|
221012
|
+
known.add("preference-value");
|
|
220640
221013
|
known.add("parent");
|
|
220641
221014
|
known.add("notes");
|
|
220642
221015
|
known.add("ignore-resource");
|
|
220643
221016
|
if (argv[0] === "render-cloud") for (const flag2 of ["browser-executable", "timeout-seconds", "max-cost-usd", "runtime-seconds", "quote-file", "grant", "bytes", "encoding", "frame-start"]) known.add(flag2);
|
|
220644
221017
|
if (argv[0] === "team") for (const flag2 of ["email", "user", "at-ms"]) known.add(flag2);
|
|
221018
|
+
if (argv[0] === "resources") {
|
|
221019
|
+
for (const flag2 of ["tags", "moments", "instructions", "description"]) known.add(flag2);
|
|
221020
|
+
if (argv[1] === "register") {
|
|
221021
|
+
known.add("upload");
|
|
221022
|
+
booleans.add("upload");
|
|
221023
|
+
}
|
|
221024
|
+
}
|
|
220645
221025
|
for (const flag2 of ["language", "accent", "gender"]) known.add(flag2);
|
|
220646
221026
|
for (let i = 0; i < argv.length; i++) {
|
|
220647
221027
|
const arg = argv[i];
|
|
@@ -220721,16 +221101,16 @@ function output2(value) {
|
|
|
220721
221101
|
if (value && typeof value === "object" && "status" in value && value.status === "partial" && "synced" in value && value.synced === false) process.exitCode = 2;
|
|
220722
221102
|
}
|
|
220723
221103
|
async function configRoot(create = false) {
|
|
220724
|
-
let path = process.env.EDITORBRAIN_CONFIG_DIR ?? process.env.EDITORHARNESS_CONFIG_DIR ??
|
|
221104
|
+
let path = process.env.EDITORBRAIN_CONFIG_DIR ?? process.env.EDITORHARNESS_CONFIG_DIR ?? join25(homedir5(), ".config", "editorbrain");
|
|
220725
221105
|
if (!create && !process.env.EDITORBRAIN_CONFIG_DIR && !process.env.EDITORHARNESS_CONFIG_DIR) {
|
|
220726
221106
|
try {
|
|
220727
221107
|
await lstat26(path);
|
|
220728
221108
|
} catch (error62) {
|
|
220729
221109
|
if (error62.code !== "ENOENT") throw error62;
|
|
220730
|
-
path =
|
|
221110
|
+
path = join25(homedir5(), ".config", "editorharness");
|
|
220731
221111
|
}
|
|
220732
221112
|
}
|
|
220733
|
-
if (create) await
|
|
221113
|
+
if (create) await mkdir21(path, { recursive: true, mode: 448 });
|
|
220734
221114
|
return ensureRoot(path);
|
|
220735
221115
|
}
|
|
220736
221116
|
async function loadConfig() {
|
|
@@ -220747,7 +221127,7 @@ async function loadConfig() {
|
|
|
220747
221127
|
async function saveConfig(config3) {
|
|
220748
221128
|
const root = await configRoot(true);
|
|
220749
221129
|
await atomicWrite(root, "config.json", stableJson(config3), { document: false, mode: 384 });
|
|
220750
|
-
await chmod4(
|
|
221130
|
+
await chmod4(join25(root, "config.json"), 384);
|
|
220751
221131
|
}
|
|
220752
221132
|
async function config2(args, requireKey = true) {
|
|
220753
221133
|
const stored = await loadConfig();
|
|
@@ -220798,7 +221178,7 @@ async function init(args) {
|
|
|
220798
221178
|
}
|
|
220799
221179
|
}
|
|
220800
221180
|
for (const [path, content] of Object.entries(files)) await atomicWrite(root, path, content, { overwrite: false });
|
|
220801
|
-
for (const path of directories) await
|
|
221181
|
+
for (const path of directories) await mkdir21(await checkedPath(root, path, false), { recursive: true });
|
|
220802
221182
|
const guidance2 = await installGuidance();
|
|
220803
221183
|
try {
|
|
220804
221184
|
await rememberGuidance(guidance2);
|
|
@@ -220898,7 +221278,11 @@ async function main() {
|
|
|
220898
221278
|
if (command === "checkpoint") {
|
|
220899
221279
|
const status = str(args, "status");
|
|
220900
221280
|
if (!status) throw new CliError("INVALID_ARGUMENT", "--status is required.", "Use not_started, in_progress, in_review, blocked or completed.");
|
|
220901
|
-
|
|
221281
|
+
const checkpointClient = ["in_review", "completed"].includes(status) ? new Client(await config2({ ...args, flags: { ...args.flags, dir: directory ?? (await locateProject(projectId)).root } })) : void 0;
|
|
221282
|
+
output2(await writeProjectCheckpoint({ projectId, directory, status, ...checkpointClient ? { validateMilestone: async () => {
|
|
221283
|
+
const check2 = await checkpointClient.request(`/v1/projects/${encodeURIComponent(projectId)}/checkpoint-readiness?status=${status}`);
|
|
221284
|
+
if (check2.ready !== true || check2.projectId !== projectId || check2.status !== status) throw new CliError("CHECKPOINT_EVIDENCE_UNAVAILABLE", "Milestone evidence is unavailable.", "Keep in_progress until the current artifact has been presented/accepted.");
|
|
221285
|
+
} } : {}, next: str(args, "next"), done: args.repeated.done, pending: args.repeated.pending, decisions: args.repeated.decision, artifacts: args.repeated.artifact, expectedCheckpoint: str(args, "expected-checkpoint"), currentVersion: str(args, "current-version"), primaryArtifact: str(args, "primary-artifact"), dependencies: args.repeated.dependency, renderCommand: str(args, "render-command") }));
|
|
220902
221286
|
return;
|
|
220903
221287
|
}
|
|
220904
221288
|
const role2 = str(args, "role");
|
|
@@ -221251,9 +221635,13 @@ async function main() {
|
|
|
221251
221635
|
}
|
|
221252
221636
|
return;
|
|
221253
221637
|
}
|
|
221638
|
+
if (command === "production" && subcommand === "delivery-check") {
|
|
221639
|
+
output2(await deliveryCommand(new Client(await config2(args)), await ensureRoot(str(args, "dir") ?? process.cwd()), args.flags));
|
|
221640
|
+
return;
|
|
221641
|
+
}
|
|
221254
221642
|
if (command === "production" && subcommand === "verify") {
|
|
221255
221643
|
if (argument) throw new CliError("INVALID_ARGUMENT", "Use named flags for production verify.", "Read editorbrain help.");
|
|
221256
|
-
const allowed = /* @__PURE__ */ new Set(["project", "file", "duration", "at", "dir", "out", "offline", "details", "url", "profile", "platform", "audio-profile", "review-inputs", "ocr", "ocr-language"]);
|
|
221644
|
+
const allowed = /* @__PURE__ */ new Set(["project", "file", "duration", "at", "dir", "out", "offline", "details", "url", "profile", "platform", "audio-profile", "review-inputs", "ocr", "ocr-language", "composition"]);
|
|
221257
221645
|
for (const flag2 of Object.keys(args.flags)) if (!allowed.has(flag2)) throw new CliError("INVALID_ARGUMENT", `--${flag2} is not supported for production verify.`, "Read editorbrain help.");
|
|
221258
221646
|
if (str(args, "ocr-language") && !args.flags.ocr) throw new Error("--ocr-language requires explicit --ocr.");
|
|
221259
221647
|
const projectId = str(args, "project"), file2 = str(args, "file");
|
|
@@ -221268,10 +221656,10 @@ async function main() {
|
|
|
221268
221656
|
const client = credentials?.apiKey ? new Client(credentials) : void 0;
|
|
221269
221657
|
await withWorkspaceLock(root2, async () => {
|
|
221270
221658
|
const context = await prepareProductionContext(root2, projectId, client);
|
|
221271
|
-
const result2 = await verifyProduction({ root: root2, file: file2, ...context, styleRuleOptions: { ocr: { enabled: !!args.flags.ocr, ...str(args, "ocr-language") ? { language: str(args, "ocr-language") } : {} } }, audioProfile: str(args, "audio-profile") ? await readProductionJson(root2, str(args, "audio-profile")) : void 0, reviewInputs: str(args, "review-inputs") ? await loadContinuityInput(root2, str(args, "review-inputs")) : void 0, platform: str(args, "platform"), visualProfile: str(args, "profile") ? await readProductionJson(root2, str(args, "profile")) : void 0, ...str(args, "out") ? { outDirectory: str(args, "out") } : {}, ...str(args, "duration") !== void 0 ? { expectedDurationSeconds: Number(str(args, "duration")) } : {}, ...times ? { sampleTimesSeconds: times.map(Number) } : {} });
|
|
221659
|
+
const result2 = await verifyProduction({ root: root2, file: file2, ...context, composition: str(args, "composition") ? await readProductionJson(root2, str(args, "composition")) : void 0, ...client ? { checkDelivery: (sha2562) => readDeliveryCheck(client, projectId, sha2562) } : {}, styleRuleOptions: { ocr: { enabled: !!args.flags.ocr, ...str(args, "ocr-language") ? { language: str(args, "ocr-language") } : {} } }, audioProfile: str(args, "audio-profile") ? await readProductionJson(root2, str(args, "audio-profile")) : void 0, reviewInputs: str(args, "review-inputs") ? await loadContinuityInput(root2, str(args, "review-inputs")) : void 0, platform: str(args, "platform"), visualProfile: str(args, "profile") ? await readProductionJson(root2, str(args, "profile")) : void 0, ...str(args, "out") ? { outDirectory: str(args, "out") } : {}, ...str(args, "duration") !== void 0 ? { expectedDurationSeconds: Number(str(args, "duration")) } : {}, ...times ? { sampleTimesSeconds: times.map(Number) } : {} });
|
|
221272
221660
|
output2({ ...args.flags.details ? result2.report : result2.summary, contextScope: context.contextScope, reportPath: result2.reportPath, reportSha256: result2.reportSha256 });
|
|
221273
221661
|
if (result2.report.technicalStatus === "fail") process.exitCode = 1;
|
|
221274
|
-
else if (!result2.report.complete || result2.report.requiredRuleEvidenceSatisfied === false) process.exitCode = 2;
|
|
221662
|
+
else if (!result2.report.complete || result2.report.requiredRuleEvidenceSatisfied === false || client && !result2.report.deliveryReady) process.exitCode = 2;
|
|
221275
221663
|
}, { migrateLegacy: false });
|
|
221276
221664
|
return;
|
|
221277
221665
|
}
|
|
@@ -221368,8 +221756,8 @@ async function main() {
|
|
|
221368
221756
|
return;
|
|
221369
221757
|
}
|
|
221370
221758
|
if (args.flags.global && str(args, "dir")) throw new Error("Use --global or --dir, not both.");
|
|
221371
|
-
const root2 = args.flags.global ?
|
|
221372
|
-
if (!args.flags.global && resolve20(root2) === resolve20(
|
|
221759
|
+
const root2 = args.flags.global ? homedir5() : str(args, "dir") ?? process.cwd();
|
|
221760
|
+
if (!args.flags.global && resolve20(root2) === resolve20(homedir5())) throw new Error("Use skill install --global for your home folder.");
|
|
221373
221761
|
const result2 = await installManagedGuidance(root2, str(args, "agent") ? parseAgentTarget(str(args, "agent")) : void 0, { global: !!args.flags.global });
|
|
221374
221762
|
output2(result2);
|
|
221375
221763
|
return;
|
|
@@ -221533,9 +221921,9 @@ async function main() {
|
|
|
221533
221921
|
if (!argument || !/^[a-z0-9][a-z0-9_-]{0,79}$/.test(argument) || !(command === "styles" && subcommand === "recommend" || command === "direction" && subcommand === "draft")) throw new Error("Use styles list, styles recommend <project-id>, or direction draft <project-id>.");
|
|
221534
221922
|
const contextCheck = await prepareDirectionContext(await ensureRoot(str(args, "dir") ?? process.cwd()), client, argument);
|
|
221535
221923
|
const parseTags = (name) => {
|
|
221536
|
-
const
|
|
221537
|
-
if (
|
|
221538
|
-
return
|
|
221924
|
+
const list2 = (str(args, name) ?? "").split(",").map((x) => x.trim()).filter(Boolean);
|
|
221925
|
+
if (list2.length > 30 || list2.some((x) => !/^[a-z][a-z0-9_-]{0,59}$/.test(x))) throw new Error(`--${name} needs comma-separated resource tags.`);
|
|
221926
|
+
return list2;
|
|
221539
221927
|
};
|
|
221540
221928
|
const duration3 = str(args, "duration");
|
|
221541
221929
|
if (duration3 !== void 0 && (!Number.isFinite(Number(duration3)) || Number(duration3) <= 0 || Number(duration3) > 3600)) throw new Error("--duration must be 1\u20133600 seconds.");
|
|
@@ -221575,7 +221963,7 @@ async function main() {
|
|
|
221575
221963
|
if (!/^[a-zA-Z0-9_-]{1,100}$/.test(result2.id) || typeof result2.apiKey !== "string") throw new Error("Invalid key response");
|
|
221576
221964
|
const file2 = `keys/${result2.id}.json`;
|
|
221577
221965
|
await atomicWrite(root2, file2, stableJson({ url: client.url, apiKey: result2.apiKey, id: result2.id, label, role: role2 }), { document: false, mode: 384, overwrite: false });
|
|
221578
|
-
output2({ id: result2.id, label, role: role2, credentialFile:
|
|
221966
|
+
output2({ id: result2.id, label, role: role2, credentialFile: join25(root2, file2) });
|
|
221579
221967
|
return;
|
|
221580
221968
|
}
|
|
221581
221969
|
if (subcommand === "revoke" && argument) {
|
|
@@ -221674,7 +222062,12 @@ async function main() {
|
|
|
221674
222062
|
return;
|
|
221675
222063
|
}
|
|
221676
222064
|
if (command === "feedback" && subcommand === "add") {
|
|
221677
|
-
|
|
222065
|
+
const field = str(args, "preference-field"), rawValue = str(args, "preference-value");
|
|
222066
|
+
if (field === "captionsEnabled" && !["true", "false"].includes(rawValue ?? "")) throw new CliError("INVALID_ARGS", "captionsEnabled expects --preference-value true or false.", "Use a literal boolean; no feedback was sent.");
|
|
222067
|
+
const value = field === "captionsEnabled" ? rawValue === "true" : rawValue;
|
|
222068
|
+
if (!!field !== !!rawValue) throw new CliError("INVALID_ARGS", "--preference-field and --preference-value must be supplied together.", "Use --capture-memory with an explicit field/value pair, or omit both. No feedback was sent.");
|
|
222069
|
+
if (!args.flags["capture-memory"] && ["category", "conditions", "preference-field", "preference-value"].some((key) => args.flags[key] !== void 0)) throw new CliError("INVALID_ARGS", "Memory metadata requires --capture-memory.", "Add --capture-memory to save a suggested project memory, or omit its metadata to save only a feedback note.");
|
|
222070
|
+
output2(await client.request("/v1/feedback", { method: "POST", body: { projectId: str(args, "project"), text: str(args, "text"), ...args.flags["capture-memory"] ? { captureMemory: true, ...str(args, "category") ? { category: str(args, "category") } : {}, ...str(args, "conditions") ? { conditions: str(args, "conditions") } : {}, ...field ? { preferenceIntent: { field, value } } : {} } : {} } }));
|
|
221678
222071
|
return;
|
|
221679
222072
|
}
|
|
221680
222073
|
if (command === "improvements" && subcommand === "list") {
|
|
@@ -221716,7 +222109,7 @@ async function main() {
|
|
|
221716
222109
|
}
|
|
221717
222110
|
if (subcommand === "upload" && argument) {
|
|
221718
222111
|
const target = resolve20(str(args, "dir") ?? process.cwd(), argument);
|
|
221719
|
-
const handle = await
|
|
222112
|
+
const handle = await open24(target, constants19.O_RDONLY | constants19.O_NOFOLLOW);
|
|
221720
222113
|
let bytes;
|
|
221721
222114
|
try {
|
|
221722
222115
|
const info = await handle.stat();
|
|
@@ -221827,7 +222220,7 @@ async function main() {
|
|
|
221827
222220
|
if (command === "search" && subcommand === "brief") {
|
|
221828
222221
|
const path = str(args, "file");
|
|
221829
222222
|
if (!path) throw new Error("Provide --file with the editorial brief JSON after inspecting the actual material.");
|
|
221830
|
-
const handle = await
|
|
222223
|
+
const handle = await open24(resolve20(path), constants19.O_RDONLY | constants19.O_NOFOLLOW);
|
|
221831
222224
|
let brief;
|
|
221832
222225
|
try {
|
|
221833
222226
|
const stat2 = await handle.stat();
|
|
@@ -221849,7 +222242,7 @@ async function main() {
|
|
|
221849
222242
|
const scriptPath = str(args, "script"), videoPath = str(args, "video");
|
|
221850
222243
|
let script, assetId = str(args, "asset");
|
|
221851
222244
|
const readInput = async (path, max) => {
|
|
221852
|
-
const handle = await
|
|
222245
|
+
const handle = await open24(resolve20(path), constants19.O_RDONLY | constants19.O_NOFOLLOW);
|
|
221853
222246
|
try {
|
|
221854
222247
|
const stat2 = await handle.stat();
|
|
221855
222248
|
if (!stat2.isFile() || stat2.size < 1 || stat2.size > max) throw new Error(`Input must be a regular file of at most ${max} bytes.`);
|