feat: initial commit - Jhonny Editor

- Adicionado estrutura completa do projeto
- Configurado MCP server para Premiere Pro
- Adicionado documentação e skills
- Configurado Gitignore para o projeto
This commit is contained in:
João Henrique
2026-09-08 09:59:31 -04:00
commit b541f502ba
1507 changed files with 387650 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<ExtensionList>
<Extension Id="com.mcp.premiere.bridge.panel">
<HostList>
<Host Name="PPRO" Port="8088"/>
</HostList>
</Extension>
</ExtensionList>
+70
View File
@@ -0,0 +1,70 @@
/**************************************************************************************************
* ADOBE SYSTEMS INCORPORATED
* Copyright 2013 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
* terms of the Adobe license agreement accompanying it. If you have received this file from a
* source other than Adobe, then your use, modification, or distribution of it requires the prior
* written permission of Adobe.
*
* CSInterface.js - v12.0.0 (minimal shim for MCP Bridge)
* Download the full version from: https://github.com/nicscott9/CSInterface
**************************************************************************************************/
/**
* CSInterface class for Adobe CEP extensions.
* This is a minimal implementation. For production use, download the full
* CSInterface.js from Adobe's GitHub repository.
*/
function CSInterface() {}
/**
* Evaluates an ExtendScript in the host application.
* @param {string} script - The ExtendScript to evaluate.
* @param {function} callback - Callback with the result string.
*/
CSInterface.prototype.evalScript = function (script, callback) {
if (typeof __adobe_cep__ !== "undefined") {
// CEP 9+ requires the callback to be passed directly to __adobe_cep__.evalScript.
// Calling it without a callback causes the result to be silently discarded,
// making every command return null/undefined.
__adobe_cep__.evalScript(script, callback || function () {});
} else {
// Running outside CEP (for testing)
console.warn("[CSInterface] Not running in CEP environment");
if (callback) callback("EvalScript Error: Not in CEP environment");
}
};
/**
* Get the host environment.
*/
CSInterface.prototype.getHostEnvironment = function () {
if (typeof __adobe_cep__ !== "undefined") {
try {
return JSON.parse(__adobe_cep__.getHostEnvironment());
} catch (e) {
return null;
}
}
return null;
};
/**
* Get the system path.
* @param {string} pathType - The path type constant.
*/
CSInterface.prototype.getSystemPath = function (pathType) {
if (typeof __adobe_cep__ !== "undefined") {
return __adobe_cep__.getSystemPath(pathType);
}
return "";
};
// System path constants
CSInterface.prototype.EXTENSION_ID = "extensionId";
// Note: This is a minimal shim. For the full CSInterface.js, download from:
// https://github.com/nicscott9/CSInterface
// and replace this file with the appropriate version for your CEP target.
+79
View File
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<ExtensionManifest Version="7.0" ExtensionBundleId="com.mcp.premiere.bridge" ExtensionBundleVersion="1.14.9" ExtensionBundleName="MCP for Adobe Premiere Pro">
<ExtensionList>
<Extension Id="com.mcp.premiere.bridge.panel" Version="1.14.9"/>
<Extension Id="com.mcp.premiere.bridge.headless" Version="1.14.9"/>
</ExtensionList>
<ExecutionEnvironment>
<HostList>
<Host Name="PPRO" Version="14.0"/>
</HostList>
<LocaleList>
<Locale Code="All"/>
</LocaleList>
<RequiredRuntimeList>
<RequiredRuntime Name="CSXS" Version="9.0"/>
</RequiredRuntimeList>
</ExecutionEnvironment>
<DispatchInfoList>
<Extension Id="com.mcp.premiere.bridge.panel">
<DispatchInfo>
<Resources>
<MainPath>./index.html</MainPath>
<ScriptPath>./host.jsx</ScriptPath>
<CEFCommandLine>
<Parameter>--allow-file-access-from-files</Parameter>
<Parameter>--enable-nodejs</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>true</AutoVisible>
</Lifecycle>
<UI>
<Type>Panel</Type>
<Menu>MCP for Adobe Premiere Pro</Menu>
<Geometry>
<Size>
<Height>300</Height>
<Width>400</Width>
</Size>
<MinSize>
<Height>200</Height>
<Width>300</Width>
</MinSize>
</Geometry>
<Icons/>
</UI>
</DispatchInfo>
</Extension>
<Extension Id="com.mcp.premiere.bridge.headless">
<DispatchInfo>
<Resources>
<MainPath>./index.html</MainPath>
<ScriptPath>./host.jsx</ScriptPath>
<CEFCommandLine>
<Parameter>--allow-file-access-from-files</Parameter>
<Parameter>--enable-nodejs</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>false</AutoVisible>
<StartOn>
<Event>com.adobe.csxs.events.ApplicationActivate</Event>
<Event>applicationActivate</Event>
</StartOn>
</Lifecycle>
<UI>
<Type>Custom</Type>
<Geometry>
<Size>
<Height>1</Height>
<Width>1</Width>
</Size>
</Geometry>
<Icons/>
</UI>
</DispatchInfo>
</Extension>
</DispatchInfoList>
</ExtensionManifest>
+7
View File
@@ -0,0 +1,7 @@
// Host-side ExtendScript (runs in Premiere Pro's ExtendScript engine)
// This file can contain ExtendScript helper functions that are always available.
// The main execution happens dynamically via CSInterface.evalScript() from main.js.
function mcpBridgePing() {
return "pong";
}
+108
View File
@@ -0,0 +1,108 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MCP for Adobe Premiere Pro</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<main class="panel-shell">
<header class="panel-header">
<div class="brand-mark" aria-hidden="true"><span>M</span></div>
<div class="brand-copy">
<h1>MCP for Adobe Premiere Pro</h1>
<p>Local Premiere connection</p>
</div>
<div class="auto-start"><span></span>Auto-start</div>
</header>
<section class="status-panel" role="status" aria-live="polite" aria-atomic="true">
<div class="status-indicator" aria-hidden="true">
<div class="status-ring"><div class="status-dot waiting" id="statusDot"></div></div>
</div>
<div class="status-copy">
<span class="section-label">Bridge status</span>
<strong id="statusText">Starting connector…</strong>
<span id="statusDetail">Checking Premiere Pro</span>
</div>
<div class="command-stat">
<strong id="cmdCount">0</strong>
<span>commands</span>
</div>
</section>
<section class="connection-center" aria-labelledby="connectionCenterTitle">
<div class="section-heading">
<div>
<span class="section-label">Connection Center</span>
<h2 id="connectionCenterTitle">Ready-to-edit check</h2>
</div>
<button class="save-link" type="button" onclick="refreshConnectionCenter()" aria-controls="connectionChecks">Refresh</button>
</div>
<p class="connection-intro">This panel only checks Premiere. In your AI assistant, run <strong>Verify Premiere connection</strong> for the complete safe check.</p>
<ul class="connection-checks" id="connectionChecks">
<li id="checkConnector" data-state="waiting"><span class="check-dot" aria-hidden="true"></span><span><strong>Connector</strong><small>Starting…</small></span></li>
<li id="checkProject" data-state="waiting"><span class="check-dot" aria-hidden="true"></span><span><strong>Project</strong><small>Checking…</small></span></li>
<li id="checkSequence" data-state="waiting"><span class="check-dot" aria-hidden="true"></span><span><strong>Active sequence</strong><small>Checking…</small></span></li>
</ul>
</section>
<section class="config-section">
<div class="section-heading">
<div>
<span class="section-label">Configuration</span>
<h2>Bridge directory</h2>
</div>
<button class="save-link" id="btnSave" onclick="saveTempDir()" type="button" title="Save bridge directory">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 3.5h9.4L16.5 6v10.5h-13v-13Z"/><path d="M6.5 3.5v5h7v-5M6.5 16.5v-5h7v5"/></svg>
Save
</button>
</div>
<label class="sr-only" for="tempDir">Temporary bridge directory</label>
<div class="path-field">
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M2.5 5.5h5l1.5 2h8.5v8h-15v-10Z"/></svg>
<input type="text" id="tempDir" value="" spellcheck="false" autocomplete="off" aria-describedby="tempDirHelp">
</div>
<p class="field-help" id="tempDirHelp">Commands and responses are exchanged through this local folder.</p>
</section>
<div class="action-row">
<button id="btnStart" class="button button-primary" onclick="startBridge()" type="button" aria-controls="log">
<svg viewBox="0 0 20 20" aria-hidden="true"><path class="fill-icon" d="m7 5 8 5-8 5V5Z"/></svg>
Start Bridge
</button>
<button id="btnStop" class="button button-stop" onclick="stopBridge()" type="button" aria-controls="log" disabled>
<svg viewBox="0 0 20 20" aria-hidden="true"><rect class="fill-icon" x="6" y="6" width="8" height="8" rx="1"/></svg>
Stop
</button>
</div>
<section class="update-section" aria-live="polite">
<div class="update-copy">
<span class="section-label">MCP updates</span>
<strong id="updateTitle">Version 1.14.9</strong>
<span id="updateDetail">Checking the global MCP server and connector release…</span>
</div>
<button id="btnUpdate" class="button button-update" onclick="handleUpdateClick()" type="button" aria-describedby="updateDetail" disabled>
Check again
</button>
</section>
<section class="activity-section">
<div class="section-heading activity-heading">
<div>
<span class="section-label">Live monitor</span>
<h2>Activity</h2>
</div>
<span class="activity-state"><span></span>Listening</span>
</div>
<div id="log" role="log" aria-live="polite" aria-relevant="additions" tabindex="0" aria-label="Bridge activity log"></div>
</section>
</main>
<script src="CSInterface.js"></script>
<script src="updater.cjs"></script>
<script src="main.js"></script>
</body>
</html>
+676
View File
@@ -0,0 +1,676 @@
/* MCP for Adobe Premiere Pro - CEP Plugin Main Script
* Polls a temp directory for command files (.jsx), executes them
* in Premiere Pro's ExtendScript engine, and writes results back. */
var cs = new CSInterface();
var bridgeRunning = false;
var pollInterval = null;
var commandCount = 0;
var tempDir = "";
var POLL_MS = 200;
var HEARTBEAT_MS = 1000;
var heartbeatInterval = null;
// ---- Logging ----
function log(msg, cls) {
var el = document.getElementById("log");
var entry = document.createElement("div");
entry.className = "log-entry " + (cls || "");
var ts = new Date().toLocaleTimeString();
entry.textContent = "[" + ts + "] " + msg;
el.appendChild(entry);
el.scrollTop = el.scrollHeight;
// Keep max 100 entries
while (el.children.length > 100) el.removeChild(el.firstChild);
}
// ---- Status ----
function setStatus(state, text) {
var dot = document.getElementById("statusDot");
dot.className = "status-dot " + state;
var statusText = document.getElementById("statusText");
statusText.textContent = text;
statusText.setAttribute("data-state", state || "stopped");
var detail = document.getElementById("statusDetail");
if (detail) {
if (state === "connected") detail.textContent = "Premiere Pro link is active";
else if (state === "waiting") detail.textContent = "Ready for an AI assistant connection";
else if (state === "error") detail.textContent = "Bridge needs attention";
else detail.textContent = "Waiting for Premiere Pro";
}
}
function setConnectionCheck(id, state, detail) {
var el = document.getElementById(id);
if (!el) return;
el.setAttribute("data-state", state);
var text = el.getElementsByTagName("small")[0];
if (text) text.textContent = detail;
}
// This reads only boolean Premiere state. Do not put project names, paths, or
// media information in the panel: the MCP safe-check uses the same boundary.
function refreshConnectionCenter() {
if (!bridgeRunning) {
setConnectionCheck("checkConnector", "waiting", "Start the connector first");
setConnectionCheck("checkProject", "waiting", "Waiting for the connector");
setConnectionCheck("checkSequence", "waiting", "Waiting for the connector");
return;
}
setConnectionCheck("checkConnector", "ready", "Running in Premiere Pro");
setConnectionCheck("checkProject", "waiting", "Checking…");
setConnectionCheck("checkSequence", "waiting", "Checking…");
cs.evalScript(
'(function(){var p=app&&app.project;return "mcpstate:"+(p&&typeof p.name!=="undefined"?"1":"0")+","+(p&&p.activeSequence?"1":"0");}())',
function (raw) {
var match = /^mcpstate:([01]),([01])$/.exec(String(raw || ""));
if (!match) {
setConnectionCheck("checkProject", "needs-attention", "Could not read Premiere state");
setConnectionCheck("checkSequence", "needs-attention", "Could not read Premiere state");
return;
}
var projectOpen = match[1] === "1";
var sequenceOpen = match[2] === "1";
setConnectionCheck("checkProject", projectOpen ? "ready" : "needs-attention", projectOpen ? "Project open" : "Open a project in Premiere Pro");
setConnectionCheck("checkSequence", sequenceOpen ? "ready" : "needs-attention", sequenceOpen ? "Active sequence open" : "Open a sequence in Premiere Pro");
}
);
}
// ---- File I/O via Node.js (CEP has access to Node) ----
// --enable-nodejs puts `require` in the global scope on most hosts, but on some it
// lands on cep_node instead. Try both, and fail loudly rather than letting fs come
// back undefined and surface later as "Cannot read properties of undefined".
function nodeRequire(moduleName) {
if (typeof require !== "undefined") return require(moduleName);
var cepNode = typeof cep_node !== "undefined" ? cep_node : typeof window !== "undefined" ? window.cep_node : null;
if (cepNode && typeof cepNode.require === "function") return cepNode.require(moduleName);
throw new Error(
'Node.js is not available in this CEP panel, so "' + moduleName + '" could not be loaded. ' +
"Check that CSXS/manifest.xml has <Parameter>--enable-nodejs</Parameter>, then fully quit and reopen Premiere Pro."
);
}
var fs = nodeRequire("fs");
var path = nodeRequire("path");
var os = nodeRequire("os");
var https = nodeRequire("https");
function defaultBridgeDirectory() {
try {
var nodeProcess = nodeRequire("process");
var configured = nodeProcess && nodeProcess.env && nodeProcess.env.PREMIERE_TEMP_DIR;
if (typeof configured === "string" && configured.trim()) return configured.trim();
} catch (e) {
// The panel still has a safe OS temporary-directory fallback.
}
return path.join(os.tmpdir(), "premiere-mcp-bridge");
}
tempDir = defaultBridgeDirectory();
var latestUpdate = null;
var UPDATE_STATUS_STORAGE_KEY = "mcp_bridge_desktop_update_status_path";
var MAX_UPDATE_RESPONSE_BYTES = 64 * 1024;
function getPerUserGlobalInstall() {
try {
var nodeProcess = nodeRequire("process");
var appData = nodeProcess && nodeProcess.env && nodeProcess.env.APPDATA;
if (typeof appData !== "string" || !appData.trim()) return null;
var npmDirectory = path.resolve(appData, "npm");
var commandPath = path.resolve(npmDirectory, "premiere-pro-mcp.cmd");
var packagePath = path.resolve(npmDirectory, "node_modules", "premiere-pro-mcp", "package.json");
var relative = path.relative(npmDirectory, commandPath);
var packageRelative = path.relative(npmDirectory, packagePath);
if (
!relative ||
!packageRelative ||
relative.indexOf(".." + path.sep) === 0 ||
packageRelative.indexOf(".." + path.sep) === 0 ||
path.isAbsolute(relative) ||
path.isAbsolute(packageRelative) ||
!fs.existsSync(commandPath) ||
!fs.existsSync(packagePath)
) return null;
var packageMetadata = JSON.parse(fs.readFileSync(packagePath, "utf-8"));
var serverVersion = MCPBridgeUpdater.normalizeVersion(packageMetadata && packageMetadata.version);
if (!serverVersion) return null;
return { commandPath: commandPath, serverVersion: serverVersion };
} catch (e) {
return null;
}
}
function getPerUserGlobalCommand() {
var install = getPerUserGlobalInstall();
return install ? install.commandPath : null;
}
function saveUpdateStatusPath(statusPath) {
try {
localStorage.setItem(UPDATE_STATUS_STORAGE_KEY, statusPath);
} catch (e) {}
}
function readScheduledUpdateStatus() {
var statusPath = "";
try {
statusPath = localStorage.getItem(UPDATE_STATUS_STORAGE_KEY) || "";
} catch (e) {
return null;
}
if (!statusPath || !path.isAbsolute(statusPath) || !fs.existsSync(statusPath)) return null;
try {
var status = JSON.parse(fs.readFileSync(statusPath, "utf-8"));
var validStates = ["waiting_for_premiere", "updating", "complete", "failed"];
if (
!status ||
status.schemaVersion !== "premiere-pro-mcp.desktop-update.v1" ||
validStates.indexOf(status.state) === -1
) return null;
return status;
} catch (e) {
return null;
}
}
function ensureDir(dir) {
try {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
}
} catch (e) {
log("Error creating dir: " + e.message, "err");
}
}
function listCommandFiles() {
try {
if (!fs.existsSync(tempDir)) return [];
var files = fs.readdirSync(tempDir);
return files
.filter(function (f) { return f.indexOf("cmd_") === 0 && f.slice(-4) === ".jsx"; })
.sort(); // process in order
} catch (e) {
return [];
}
}
function readFile(filePath) {
try {
return fs.readFileSync(filePath, "utf-8");
} catch (e) {
return null;
}
}
function writeFile(filePath, content) {
try {
fs.writeFileSync(filePath, content, "utf-8");
return true;
} catch (e) {
log("Error writing " + filePath + ": " + e.message, "err");
return false;
}
}
// Publish responses atomically so the MCP process never sees a partially-written
// JSON file. The staging suffix is not a response filename the server will read.
function writeResponseFile(filePath, content) {
var stagedPath = filePath + ".staged";
try {
fs.writeFileSync(stagedPath, content, "utf-8");
fs.renameSync(stagedPath, filePath);
return true;
} catch (e) {
deleteFile(stagedPath);
log("Error publishing " + filePath + ": " + e.message, "err");
return false;
}
}
function deleteFile(filePath) {
try {
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
} catch (e) {}
}
// The heartbeat carries only protocol state. It is published by rename so a
// server never observes partial JSON, and an older server can ignore it.
function writeBridgeHeartbeat() {
if (!tempDir) return;
var heartbeatPath = path.join(tempDir, "bridge-heartbeat.json");
var stagedPath = heartbeatPath + "." + ENGINE_ID + ".staged";
try {
fs.writeFileSync(stagedPath, JSON.stringify({
protocolVersion: 1,
state: bridgeRunning ? "running" : "waiting"
}), "utf-8");
fs.renameSync(stagedPath, heartbeatPath);
} catch (e) {
deleteFile(stagedPath);
}
}
function startBridgeHeartbeat() {
if (heartbeatInterval) clearInterval(heartbeatInterval);
writeBridgeHeartbeat();
heartbeatInterval = setInterval(writeBridgeHeartbeat, HEARTBEAT_MS);
}
function stopBridgeHeartbeat() {
if (heartbeatInterval) clearInterval(heartbeatInterval);
heartbeatInterval = null;
// Keep the last heartbeat in place. Its age lets newer servers diagnose a
// stopped connector, while concurrent visible/headless panels stay isolated.
}
// ---- Script Execution ----
function executeScript(script, callback) {
// Script is already wrapped in an IIFE by the MCP server's buildScript(),
// so we pass it directly to avoid double-wrapping.
cs.evalScript(script, function (result) {
callback(result);
});
}
// ---- Command Processing ----
function processCommands() {
if (commandInFlight) return;
var cmdFiles = listCommandFiles();
// Premiere's scripting engine is stateful. Starting every discovered command
// at once lets overlapping edits race each other and overload the host. The
// atomic claim below still prevents duplicate work across the visible and
// headless panels, while this panel dispatches strictly one command at a time.
if (cmdFiles.length > 0) processOneCommand(cmdFiles[0]);
}
// Both the visible panel and the headless auto-start instance run this file.
// A rename is atomic on the same volume, so whichever engine renames first owns
// the command; the loser's rename throws and it skips the file.
var ENGINE_ID = Math.random().toString(36).slice(2, 8);
var commandInFlight = false;
function processOneCommand(cmdFileName) {
var cmdFilePath = path.join(tempDir, cmdFileName);
var claimPath = cmdFilePath + "." + ENGINE_ID + ".claimed";
try {
fs.renameSync(cmdFilePath, claimPath);
} catch (e) {
return; // another engine claimed this command
}
var script = readFile(claimPath);
deleteFile(claimPath);
if (!script) {
log("Failed to read: " + cmdFileName, "err");
return;
}
commandInFlight = true;
// Derive response filename: cmd_12345.jsx -> res_12345.json
var id = cmdFileName.replace("cmd_", "").replace(".jsx", "");
var resFilePath = path.join(tempDir, "res_" + id + ".json");
log("Executing: " + cmdFileName + " (" + script.length + " chars)", "cmd");
// While evalScript is in flight, heartbeat a busy file so the MCP server can
// tell "script still running (modal dialog?)" apart from "plugin not running".
// Only starts after 2s, so fast commands never touch the extra file.
var busyFilePath = path.join(tempDir, "busy_" + id + ".json");
var startedAt = new Date().getTime();
var busyTimer = setInterval(function () {
writeFile(busyFilePath, '{"id":"' + id + '","elapsedMs":' + (new Date().getTime() - startedAt) + "}");
}, 2000);
executeScript(script, function (result) {
clearInterval(busyTimer);
deleteFile(busyFilePath);
commandCount++;
document.getElementById("cmdCount").textContent = commandCount;
var response;
try {
// ExtendScript returns a string; try to parse it as JSON
if (result && result !== "undefined" && result !== "null") {
// Check if it's already valid JSON
var parsed = JSON.parse(result);
response = JSON.stringify(parsed);
log("Result: OK", "ok");
} else {
// An empty result means evalScript gave us nothing back. That is a bridge
// failure, not a successful command with no data — reporting it as "OK" is
// what made this so hard to diagnose. Say so.
response = JSON.stringify({
success: false,
error:
"The bridge received an empty result from evalScript (got " +
(typeof result) +
"). The script may not have run. If every command does this, the CEP panel is stale — " +
"close and reopen it (a reload is not enough), or reinstall the extension.",
});
log("Result: EMPTY — evalScript returned nothing (see response file)", "err");
}
} catch (e) {
// If result isn't JSON, wrap it
if (result && result.indexOf("Error") === 0) {
response = JSON.stringify({ success: false, error: result });
log("Result: " + result, "err");
} else {
response = JSON.stringify({ success: true, data: result });
log("Result: OK (raw)", "ok");
}
}
writeResponseFile(resFilePath, response);
commandInFlight = false;
// Continue without waiting for the next poll interval, preserving FIFO
// ordering while minimizing queue handoff latency.
if (bridgeRunning) processCommands();
});
}
// ---- Bridge Control ----
function startBridge() {
tempDir = document.getElementById("tempDir").value.trim();
if (!tempDir) {
log("Please set a temp directory", "err");
document.getElementById("tempDir").focus();
return;
}
ensureDir(tempDir);
bridgeRunning = true;
startBridgeHeartbeat();
setStatus("waiting", "Connector running");
log("Connector started and ready for safe checks.", "ok");
document.getElementById("btnStart").disabled = true;
document.getElementById("btnStop").disabled = false;
refreshConnectionCenter();
pollInterval = setInterval(function () {
if (bridgeRunning) processCommands();
}, POLL_MS);
}
function stopBridge() {
bridgeRunning = false;
writeBridgeHeartbeat();
stopBridgeHeartbeat();
if (pollInterval) clearInterval(pollInterval);
pollInterval = null;
setStatus("", "Stopped");
refreshConnectionCenter();
log("Bridge stopped");
document.getElementById("btnStart").disabled = false;
document.getElementById("btnStop").disabled = true;
}
function saveTempDir() {
tempDir = document.getElementById("tempDir").value.trim();
log("Temp directory saved: " + tempDir);
// Persist via localStorage
try {
localStorage.setItem("mcp_bridge_temp_dir", tempDir);
} catch (e) {}
}
// ---- Connector Updates ----
function setUpdateUI(title, detail, buttonText, disabled) {
document.getElementById("updateTitle").textContent = title;
document.getElementById("updateDetail").textContent = detail;
var button = document.getElementById("btnUpdate");
button.textContent = buttonText;
button.disabled = !!disabled;
}
function updateInstructionUrl() {
return MCPBridgeUpdater.RELEASES_URL;
}
function openTrustedUpdateInstructions() {
var url = updateInstructionUrl();
if (!MCPBridgeUpdater.isTrustedDownloadUrl(url)) {
showUpdateCheckError("The update instructions link was not trusted.");
return;
}
try {
var childProcess = nodeRequire("child_process");
var command =
os.platform() === "win32"
? ["cmd.exe", ["/d", "/s", "/c", "start", "", url]]
: ["open", [url]];
var child = childProcess.spawn(command[0], command[1], {
detached: true,
stdio: "ignore",
});
child.unref();
} catch (e) {
showUpdateCheckError("Could not open the update instructions. Try again.");
}
}
function restoreScheduledUpdateStatus() {
var status = readScheduledUpdateStatus();
if (!status) return false;
if (status.state === "complete") {
setUpdateUI(
"Update complete",
"Restart your MCP client, then use Verify Premiere connection before editing.",
"Check again",
false
);
return true;
}
if (status.state === "failed") {
setUpdateUI(
"Update needs attention",
"Nothing was changed in your projects. Check the update command or retry after Premiere closes.",
"Check again",
false
);
return true;
}
setUpdateUI(
"Update scheduled",
status.state === "updating"
? "The global MCP server and connector are being updated. Keep Premiere closed."
: "Quit Premiere Pro. The updater will begin after it fully closes.",
"Scheduled",
true
);
return true;
}
function checkForUpdates() {
latestUpdate = null;
var globalInstall = os.platform() === "win32" ? getPerUserGlobalInstall() : null;
var responseTooLarge = false;
setUpdateUI(
"Version " + MCPBridgeUpdater.CURRENT_VERSION,
"Checking for updates…",
"Checking…",
true
);
var request = https.get(
MCPBridgeUpdater.LATEST_PACKAGE_API,
{
headers: {
Accept: "application/vnd.npm.install-v1+json",
"User-Agent": "premiere-pro-mcp-connector/" + MCPBridgeUpdater.CURRENT_VERSION,
},
},
function (response) {
var body = "";
response.setEncoding("utf8");
response.on("data", function (chunk) {
if (body.length + chunk.length > MAX_UPDATE_RESPONSE_BYTES) {
responseTooLarge = true;
request.destroy(new Error("npm registry update record was unexpectedly large."));
return;
}
body += chunk;
});
response.on("end", function () {
if (responseTooLarge) return;
if (response.statusCode !== 200) {
showUpdateCheckError("Could not check npm (HTTP " + response.statusCode + ").");
return;
}
try {
var update = MCPBridgeUpdater.updateStateFromPackageRecord(
MCPBridgeUpdater.CURRENT_VERSION,
JSON.parse(body)
);
var serverUpdateAvailable = Boolean(
globalInstall &&
MCPBridgeUpdater.compareVersions(update.latestVersion, globalInstall.serverVersion) > 0
);
var needsUpdate = update.updateAvailable || serverUpdateAvailable;
if (needsUpdate) {
latestUpdate = {
version: update.latestVersion,
};
if (os.platform() === "win32" && globalInstall) {
var versionSummary =
"Server " + globalInstall.serverVersion + ", connector " + MCPBridgeUpdater.CURRENT_VERSION + ". ";
setUpdateUI(
"Version " + update.latestVersion + " is available",
versionSummary + "Update both together after you close Premiere.",
"Update after quit",
false
);
} else if (os.platform() === "win32") {
setUpdateUI(
"Version " + update.latestVersion + " is available",
"A global npm install was not found. This panel will not modify a source checkout.",
"Open instructions",
false
);
} else {
setUpdateUI(
"Version " + update.latestVersion + " is available",
"Open the matching release, then update your local server using the documented install path.",
"Open instructions",
false
);
}
} else {
var currentDetail = globalInstall
? "Server " + globalInstall.serverVersion + " and connector " + MCPBridgeUpdater.CURRENT_VERSION + " are current."
: "Your connector release is current. This check does not alter your projects or MCP client configuration.";
setUpdateUI(
"Version " + MCPBridgeUpdater.CURRENT_VERSION,
currentDetail,
"Check again",
false
);
}
} catch (e) {
showUpdateCheckError("npm returned an unreadable package record.");
}
});
}
);
request.setTimeout(10000, function () {
request.destroy(new Error("Update check timed out"));
});
request.on("error", function () {
showUpdateCheckError(
responseTooLarge ? "npm returned an unexpectedly large package record." : "Unable to check while offline."
);
});
}
function showUpdateCheckError(message) {
setUpdateUI(
"Version " + MCPBridgeUpdater.CURRENT_VERSION,
message,
"Check again",
false
);
}
function handleUpdateClick() {
if (!latestUpdate) {
checkForUpdates();
return;
}
if (os.platform() !== "win32") {
openTrustedUpdateInstructions();
return;
}
var cliPath = getPerUserGlobalCommand();
if (!cliPath) {
openTrustedUpdateInstructions();
return;
}
var confirmation =
"Update Premiere MCP to " + latestUpdate.version + " after Premiere Pro fully closes?\n\n" +
"This updates only the per-user global MCP server and its connector. " +
"It does not change your projects or MCP client configuration, and it will not force Premiere to close.";
if (typeof window.confirm === "function" && !window.confirm(confirmation)) return;
try {
var childProcess = nodeRequire("child_process");
var nodeCrypto = nodeRequire("crypto");
var scheduled = MCPBridgeUpdater.scheduleWindowsGlobalUpdate({
cliPath: cliPath,
runtime: {
fs: fs,
path: path,
os: os,
childProcess: childProcess,
crypto: nodeCrypto,
},
});
saveUpdateStatusPath(scheduled.statusPath);
setUpdateUI(
"Update scheduled",
"Quit Premiere Pro. The updater will refresh the global server and connector after it fully closes.",
"Scheduled",
true
);
} catch (e) {
showUpdateCheckError("Could not schedule the local update. No files were changed.");
}
}
// ---- Init ----
(function init() {
// Set the default temp dir in the input field
document.getElementById("tempDir").value = tempDir;
// Restore saved temp dir
try {
var saved = localStorage.getItem("mcp_bridge_temp_dir");
if (saved) {
tempDir = saved;
document.getElementById("tempDir").value = tempDir;
}
} catch (e) {}
log("MCP for Adobe Premiere Pro CEP connector loaded");
setStatus("waiting", "Ready — click Start Bridge");
// Always auto-start. The headless instance (StartOn ApplicationActivate) has no
// one to click Start, and macOS periodically purges the temp dir — so create it
// rather than gating auto-start on its existence.
ensureDir(tempDir);
startBridgeHeartbeat();
log("Auto-starting bridge...");
setTimeout(startBridge, 500);
if (!restoreScheduledUpdateStatus()) setTimeout(checkForUpdates, 1200);
})();
+284
View File
@@ -0,0 +1,284 @@
:root {
--bg: #151516;
--surface: #1c1c1f;
--surface-raised: #222226;
--surface-deep: #111113;
--border: #35353a;
--border-strong: #494950;
--text: #f2f1f4;
--text-secondary: #adabb3;
--text-muted: #74727b;
--violet: #9b6cff;
--violet-hover: #ad87ff;
--violet-soft: rgba(155, 108, 255, 0.12);
--green: #70d987;
--green-soft: rgba(112, 217, 135, 0.1);
--red: #ff6565;
--amber: #e9b85d;
--radius: 7px;
--font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
--font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-width: 280px; height: 100%; margin: 0; }
body {
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: var(--font-ui);
font-size: 12px;
-webkit-font-smoothing: antialiased;
user-select: none;
}
button, input { font: inherit; }
button { -webkit-appearance: none; }
.panel-shell {
display: flex;
flex-direction: column;
height: 100%;
min-height: 420px;
padding: 0 14px 14px;
}
.panel-header {
display: flex;
align-items: center;
min-height: 66px;
margin: 0 -14px 14px;
padding: 12px 14px;
border-bottom: 1px solid var(--border);
background: #19191b;
}
.brand-mark {
display: flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
margin-right: 10px;
border: 1px solid #aa83ff;
border-radius: 8px;
background: var(--violet-soft);
color: #cbb8ff;
font-size: 15px;
font-weight: 750;
letter-spacing: -0.04em;
}
.brand-copy { min-width: 0; }
.brand-copy h1 { margin: 0; font-size: 14px; line-height: 1.25; font-weight: 650; letter-spacing: .01em; }
.brand-copy p { margin: 3px 0 0; color: var(--text-muted); font-size: 10px; }
.auto-start {
display: flex;
align-items: center;
gap: 6px;
margin-left: auto;
color: var(--text-muted);
font-size: 10px;
}
.auto-start > span { width: 5px; height: 5px; border-radius: 50%; background: var(--violet); }
.status-panel {
display: grid;
grid-template-columns: 44px minmax(0, 1fr) auto;
align-items: center;
min-height: 88px;
padding: 14px;
border: 1px solid var(--border);
border-radius: var(--radius);
background: var(--surface);
}
.status-indicator { display: flex; align-items: center; }
.status-ring {
display: flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
border: 1px solid var(--border-strong);
border-radius: 50%;
background: var(--surface-deep);
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); transition: background .2s, box-shadow .2s; }
.status-dot.connected { background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); animation: breathe 2.4s ease-in-out infinite; }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 5px rgba(255, 101, 101, .1); }
.status-dot.waiting { background: var(--amber); box-shadow: 0 0 0 5px rgba(233, 184, 93, .1); }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 4px var(--green-soft); } 50% { box-shadow: 0 0 0 7px rgba(112, 217, 135, .04); } }
.section-label { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: 9px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.status-copy { min-width: 0; }
.status-copy strong { display: block; overflow: hidden; color: var(--text); font-size: 14px; font-weight: 650; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.status-copy strong::before { content: "■ "; color: var(--text-muted); }
.status-copy strong[data-state="connected"]::before { content: "✓ "; color: var(--green); }
.status-copy strong[data-state="waiting"]::before { content: "… "; color: var(--amber); }
.status-copy strong[data-state="error"]::before { content: "! "; color: var(--red); }
.status-copy #statusDetail { display: block; overflow: hidden; margin-top: 3px; color: var(--text-secondary); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.command-stat { padding-left: 14px; text-align: right; }
.command-stat strong { display: block; font: 600 20px/1 var(--font-mono); }
.command-stat span { display: block; margin-top: 5px; color: var(--text-muted); font-size: 9px; }
.config-section { padding: 19px 0 15px; border-bottom: 1px solid var(--border); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 9px; }
.section-heading h2 { margin: 0; font-size: 12px; font-weight: 600; }
.save-link {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 4px 0 4px 8px;
border: 0;
background: transparent;
color: var(--violet);
cursor: pointer;
font-size: 10px;
}
.save-link svg, .path-field svg, .button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.save-link:hover { color: var(--violet-hover); }
.path-field { position: relative; display: flex; align-items: center; }
.path-field > svg { position: absolute; left: 10px; color: var(--text-muted); pointer-events: none; }
.path-field input {
width: 100%;
height: 36px;
padding: 0 10px 0 32px;
border: 1px solid var(--border);
border-radius: 5px;
outline: none;
background: var(--surface-deep);
color: var(--text-secondary);
font: 10px var(--font-mono);
user-select: text;
transition: border-color .15s, background .15s;
}
.path-field input:hover { border-color: var(--border-strong); }
.path-field input:focus { border-color: var(--violet); background: #141318; color: var(--text); box-shadow: 0 0 0 2px var(--violet-soft); }
.field-help { margin: 7px 0 0; color: var(--text-muted); font-size: 9px; line-height: 1.45; }
.action-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(84px, .65fr); gap: 8px; padding: 14px 0; }
.button {
display: flex;
align-items: center;
justify-content: center;
gap: 7px;
min-width: 0;
height: 34px;
border: 1px solid transparent;
border-radius: 5px;
color: var(--text);
cursor: pointer;
font-size: 11px;
font-weight: 600;
transition: background .15s, border-color .15s, color .15s;
}
.button svg .fill-icon { fill: currentColor; stroke: none; }
.button-primary { background: var(--violet); color: #110d19; }
.button-primary:hover { background: var(--violet-hover); }
.button-stop { border-color: #6b3c3f; background: transparent; color: #ff8b8b; }
.button-stop:hover { border-color: var(--red); background: rgba(255, 101, 101, .08); }
.button:disabled { border-color: var(--border); background: var(--surface); color: #5f5e65; cursor: default; }
.update-section {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 14px;
padding: 11px 12px;
border: 1px solid var(--border);
border-radius: var(--radius);
background: var(--surface);
}
.connection-center {
margin: 0 0 14px;
padding: 12px;
border: 1px solid var(--border);
border-radius: var(--radius);
background: var(--surface);
}
.connection-center .section-heading { margin-bottom: 8px; }
.connection-center h2 { font-size: 12px; }
.connection-intro { margin: 0 0 10px; color: var(--text-muted); font-size: 9px; line-height: 1.45; }
.connection-intro strong { color: var(--text-secondary); font-weight: 600; }
.connection-checks { display: grid; gap: 6px; padding: 0; margin: 0; list-style: none; }
.connection-checks li { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-deep); }
.connection-checks li > span:last-child { min-width: 0; }
.connection-checks strong, .connection-checks small { display: block; }
.connection-checks strong { color: var(--text-secondary); font-size: 10px; font-weight: 600; }
.connection-checks small { margin-top: 2px; color: var(--text-muted); font-size: 9px; }
.check-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--text-muted); }
.connection-checks li[data-state="ready"] .check-dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.connection-checks li[data-state="needs-attention"] .check-dot { background: var(--amber); }
.update-copy { min-width: 0; flex: 1; }
.update-copy strong, .update-copy > span:last-child { display: block; }
.update-copy strong { font-size: 11px; font-weight: 600; }
.update-copy > span:last-child { margin-top: 3px; color: var(--text-muted); font-size: 9px; line-height: 1.4; }
.button-update {
width: auto;
min-width: 92px;
height: 30px;
padding: 0 10px;
border-color: var(--border-strong);
background: var(--surface-raised);
color: var(--violet-hover);
white-space: nowrap;
}
.button-update:hover { border-color: var(--violet); background: var(--violet-soft); }
.activity-section { display: flex; flex: 1; min-height: 120px; flex-direction: column; }
.activity-heading { align-items: center; margin: 2px 0 8px; }
.activity-state { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 9px; }
.activity-state > span { width: 5px; height: 5px; border-radius: 50%; background: var(--violet); }
#log {
flex: 1;
min-height: 100px;
overflow-y: auto;
padding: 10px 11px;
border: 1px solid var(--border);
border-radius: 5px;
background: var(--surface-deep);
font: 10px/1.65 var(--font-mono);
user-select: text;
}
#log:empty::before { content: "Waiting for activity..."; color: var(--text-muted); }
#log::-webkit-scrollbar { width: 5px; }
#log::-webkit-scrollbar-thumb { border-radius: 3px; background: var(--border-strong); }
.log-entry { color: var(--text-muted); animation: log-in .18s ease-out; }
.log-entry.cmd { color: #b89cff; }
.log-entry.ok { color: var(--green); }
.log-entry.err { color: #ff8585; }
@keyframes log-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
button:focus-visible, input:focus-visible, #log:focus-visible { outline: 2px solid var(--violet-hover); outline-offset: 2px; }
@media (max-width: 330px) {
.panel-shell { padding-right: 10px; padding-left: 10px; }
.panel-header { margin-right: -10px; margin-left: -10px; padding-right: 10px; padding-left: 10px; }
.auto-start { display: none; }
.status-panel { grid-template-columns: 38px minmax(0, 1fr); padding: 12px; }
.command-stat { grid-column: 2; padding: 8px 0 0; text-align: left; }
.command-stat strong, .command-stat span { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
@media (forced-colors: active) {
.status-dot, .auto-start > span, .activity-state > span { forced-color-adjust: none; border: 1px solid CanvasText; }
.button, .path-field input, #log, .status-panel { border-color: CanvasText; }
.status-copy strong::before { color: CanvasText !important; }
}
+204
View File
@@ -0,0 +1,204 @@
/* MCP Bridge update helpers. Kept dependency-free for the older Chromium
* runtime embedded in CEP. */
(function (root, factory) {
var api = factory();
if (typeof module === "object" && module.exports) module.exports = api;
root.MCPBridgeUpdater = api;
})(this, function () {
"use strict";
var CURRENT_VERSION = "1.14.9";
var PACKAGE_NAME = "premiere-pro-mcp";
var LATEST_PACKAGE_API = "https://registry.npmjs.org/" + PACKAGE_NAME;
var LATEST_RELEASE_API =
"https://api.github.com/repos/leancoderkavy/premiere-pro-mcp/releases/latest";
var RELEASES_URL =
"https://github.com/leancoderkavy/premiere-pro-mcp/releases/latest";
function normalizeVersion(value) {
return String(value || "")
.trim()
.replace(/^v/i, "")
.split("-")[0];
}
function compareVersions(left, right) {
var a = normalizeVersion(left).split(".");
var b = normalizeVersion(right).split(".");
var length = Math.max(a.length, b.length);
for (var i = 0; i < length; i++) {
var aPart = parseInt(a[i] || "0", 10);
var bPart = parseInt(b[i] || "0", 10);
if (aPart > bPart) return 1;
if (aPart < bPart) return -1;
}
return 0;
}
function latestPackageVersion(record) {
if (!record || typeof record !== "object") {
throw new Error("The npm registry returned an invalid package record.");
}
var tags = record["dist-tags"];
var latest = tags && tags.latest;
var version = normalizeVersion(latest);
if (!version || !/^\d+\.\d+\.\d+$/.test(version)) {
throw new Error("The npm registry did not provide a valid latest version.");
}
return version;
}
function updateStateFromPackageRecord(currentVersion, record) {
var current = normalizeVersion(currentVersion);
if (!current || !/^\d+\.\d+\.\d+$/.test(current)) {
throw new Error("The installed connector version is invalid.");
}
var latest = latestPackageVersion(record);
return {
currentVersion: current,
latestVersion: latest,
updateAvailable: compareVersions(latest, current) > 0,
};
}
function chooseDownloadUrl(release) {
var assets = release && release.assets ? release.assets : [];
var preferredNames = [
/^MCPBridgeCEP(?:-[\w.-]+)?\.zxp$/i,
/premiere.*(?:connector|bridge).*\.zxp$/i,
/\.zxp$/i,
/premiere.*(?:connector|bridge).*\.(?:zip|dmg|exe)$/i,
];
for (var p = 0; p < preferredNames.length; p++) {
for (var i = 0; i < assets.length; i++) {
if (
preferredNames[p].test(assets[i].name || "") &&
isTrustedDownloadUrl(assets[i].browser_download_url)
) {
return assets[i].browser_download_url;
}
}
}
return isTrustedDownloadUrl(release && release.html_url)
? release.html_url
: RELEASES_URL;
}
function isTrustedDownloadUrl(value) {
return /^https:\/\/(?:github\.com|api\.github\.com|objects\.githubusercontent\.com)\//i.test(
String(value || "")
);
}
function powerShellLiteral(value) {
return "'" + String(value).replace(/'/g, "''") + "'";
}
function randomSuffix(runtime) {
if (runtime.crypto && typeof runtime.crypto.randomBytes === "function") {
return runtime.crypto.randomBytes(12).toString("hex");
}
return String(new Date().getTime()) + "-" + String(Math.random()).slice(2);
}
/**
* The CEP panel cannot replace its own files safely while Premiere is running.
* This small, detached helper waits for Premiere to close, then invokes the
* already-installed per-user npm command. It does not receive project data,
* MCP configuration, or credentials, and it never force-quits Premiere.
*/
function buildWindowsGlobalUpdateScript(cliPath, statusPath, scriptPath) {
return [
"$ErrorActionPreference = 'Stop'",
"$cliPath = " + powerShellLiteral(cliPath),
"$statusPath = " + powerShellLiteral(statusPath),
"$scriptPath = " + powerShellLiteral(scriptPath),
"function Write-UpdateStatus([string]$state) {",
" $payload = @{ schemaVersion = 'premiere-pro-mcp.desktop-update.v1'; state = $state; updatedAt = [DateTime]::UtcNow.ToString('o') } | ConvertTo-Json -Compress",
" [System.IO.File]::WriteAllText($statusPath, $payload, [System.Text.UTF8Encoding]::new($false))",
"}",
"try {",
" Write-UpdateStatus 'waiting_for_premiere'",
" $premiereProcesses = @('Adobe Premiere Pro', 'Adobe Premiere Pro Beta')",
" while (Get-Process -Name $premiereProcesses -ErrorAction SilentlyContinue) { Start-Sleep -Seconds 2 }",
" Write-UpdateStatus 'updating'",
" $npmCommand = (Get-Command npm.cmd -ErrorAction Stop).Source",
" & $npmCommand install --global 'premiere-pro-mcp@latest'",
" if ($LASTEXITCODE -ne 0) { throw 'npm could not install the latest Premiere MCP package.' }",
" & $cliPath --install-cep",
" if ($LASTEXITCODE -ne 0) { throw 'The refreshed Premiere MCP package could not install its connector.' }",
" Write-UpdateStatus 'complete'",
"} catch {",
" Write-UpdateStatus 'failed'",
" exit 1",
"} finally {",
" Remove-Item -LiteralPath $scriptPath -Force -ErrorAction SilentlyContinue",
"}",
"",
].join("\r\n");
}
function scheduleWindowsGlobalUpdate(options) {
if (!options || !options.runtime) throw new Error("A local updater runtime is required.");
var runtime = options.runtime;
var fs = runtime.fs;
var path = runtime.path;
var os = runtime.os;
var childProcess = runtime.childProcess;
if (!fs || !path || !os || !childProcess) {
throw new Error("The local updater runtime is unavailable.");
}
var cliPath = String(options.cliPath || "");
if (!cliPath || typeof path.isAbsolute !== "function" || !path.isAbsolute(cliPath)) {
throw new Error("The per-user Premiere MCP command could not be resolved.");
}
if (typeof fs.existsSync === "function" && !fs.existsSync(cliPath)) {
throw new Error("The per-user Premiere MCP command is not installed.");
}
var updateDirectory = String(options.updateDirectory || os.tmpdir());
if (!updateDirectory || typeof path.isAbsolute !== "function" || !path.isAbsolute(updateDirectory)) {
throw new Error("The local update directory is unavailable.");
}
if (typeof fs.mkdirSync === "function") fs.mkdirSync(updateDirectory, { recursive: true, mode: 0o700 });
var suffix = randomSuffix(runtime);
var statusPath = path.join(updateDirectory, "premiere-pro-mcp-update-" + suffix + ".json");
var scriptPath = path.join(updateDirectory, "premiere-pro-mcp-update-" + suffix + ".ps1");
var script = buildWindowsGlobalUpdateScript(cliPath, statusPath, scriptPath);
fs.writeFileSync(scriptPath, script, { encoding: "utf8", mode: 0o600, flag: "wx" });
try {
var child = childProcess.spawn(
"powershell.exe",
["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", scriptPath],
{ detached: true, windowsHide: true, stdio: "ignore" }
);
if (!child || typeof child.unref !== "function") {
throw new Error("The local updater could not be started.");
}
child.unref();
return { statusPath: statusPath };
} catch (error) {
try { fs.unlinkSync(scriptPath); } catch (cleanupError) {}
throw error;
}
}
return {
CURRENT_VERSION: CURRENT_VERSION,
PACKAGE_NAME: PACKAGE_NAME,
LATEST_PACKAGE_API: LATEST_PACKAGE_API,
LATEST_RELEASE_API: LATEST_RELEASE_API,
RELEASES_URL: RELEASES_URL,
normalizeVersion: normalizeVersion,
compareVersions: compareVersions,
latestPackageVersion: latestPackageVersion,
updateStateFromPackageRecord: updateStateFromPackageRecord,
chooseDownloadUrl: chooseDownloadUrl,
isTrustedDownloadUrl: isTrustedDownloadUrl,
buildWindowsGlobalUpdateScript: buildWindowsGlobalUpdateScript,
scheduleWindowsGlobalUpdate: scheduleWindowsGlobalUpdate,
};
});