@writepanda/cli 1.272.0 → 1.276.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/bin/pandastudio.mjs +26 -6
- package/package.json +1 -1
package/bin/pandastudio.mjs
CHANGED
|
@@ -40,7 +40,7 @@ for (const stream of [process.stdout, process.stderr]) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const VERSION = "1.
|
|
43
|
+
const VERSION = "1.276.0";
|
|
44
44
|
|
|
45
45
|
function configDir() {
|
|
46
46
|
// PANDASTUDIO_CONFIG_DIR mirrors the override the main process
|
|
@@ -356,7 +356,20 @@ function parseScalar(value) {
|
|
|
356
356
|
return value;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
+
/** Access handed over in the environment. Inside PandaStudio's own agent
|
|
360
|
+
* shell sandbox the token and port files can't be read, so the shell wrapper
|
|
361
|
+
* passes the same values this way (see electron/agent/shellSandbox.ts). */
|
|
362
|
+
function envCredentials() {
|
|
363
|
+
const token = (process.env.PANDASTUDIO_AUTOMATION_TOKEN ?? "").trim();
|
|
364
|
+
const port = Number((process.env.PANDASTUDIO_AUTOMATION_PORT ?? "").trim());
|
|
365
|
+
return token && Number.isInteger(port) && port > 0 ? { port, token } : null;
|
|
366
|
+
}
|
|
367
|
+
|
|
359
368
|
async function readCredentials(opts) {
|
|
369
|
+
if (opts.portOverride === undefined && opts.tokenOverride === undefined) {
|
|
370
|
+
const fromEnv = envCredentials();
|
|
371
|
+
if (fromEnv) return fromEnv;
|
|
372
|
+
}
|
|
360
373
|
const port = opts.portOverride ?? Number((await fs.readFile(PORT_FILE, "utf-8")).trim());
|
|
361
374
|
const token = opts.tokenOverride ?? (await fs.readFile(TOKEN_FILE, "utf-8")).trim();
|
|
362
375
|
if (!Number.isInteger(port) || port <= 0) throw new Error(`invalid port in ${PORT_FILE}`);
|
|
@@ -551,8 +564,11 @@ async function lastLaunchAgeMs() {
|
|
|
551
564
|
|
|
552
565
|
async function recordLaunch() {
|
|
553
566
|
try {
|
|
554
|
-
await fs.mkdir(configDir(), { recursive: true });
|
|
555
|
-
await fs.writeFile(path.join(configDir(), "launch-requested"), String(Date.now()),
|
|
567
|
+
await fs.mkdir(configDir(), { recursive: true, mode: 0o700 });
|
|
568
|
+
await fs.writeFile(path.join(configDir(), "launch-requested"), String(Date.now()), {
|
|
569
|
+
encoding: "utf-8",
|
|
570
|
+
mode: 0o600,
|
|
571
|
+
});
|
|
556
572
|
} catch {
|
|
557
573
|
/* best-effort */
|
|
558
574
|
}
|
|
@@ -630,7 +646,7 @@ async function autoLaunchAndWait(opts, log) {
|
|
|
630
646
|
}
|
|
631
647
|
if (last.alive) {
|
|
632
648
|
throw new Error(
|
|
633
|
-
`PandaStudio is running but its automation server didn't answer within ${secs}s. In PandaStudio open Settings →
|
|
649
|
+
`PandaStudio is running but its automation server didn't answer within ${secs}s. In PandaStudio open Settings → Other AI apps and make sure Local automation is on.`,
|
|
634
650
|
);
|
|
635
651
|
}
|
|
636
652
|
if (last.preferred === "up") {
|
|
@@ -639,7 +655,7 @@ async function autoLaunchAndWait(opts, log) {
|
|
|
639
655
|
);
|
|
640
656
|
}
|
|
641
657
|
throw new Error(
|
|
642
|
-
`PandaStudio did not become ready within ${secs}s. Open PandaStudio, go to Settings →
|
|
658
|
+
`PandaStudio did not become ready within ${secs}s. Open PandaStudio, go to Settings → Other AI apps and turn on Local automation.`,
|
|
643
659
|
);
|
|
644
660
|
}
|
|
645
661
|
|
|
@@ -782,7 +798,7 @@ async function main() {
|
|
|
782
798
|
if (!alive) {
|
|
783
799
|
if (opts.noLaunch) {
|
|
784
800
|
process.stderr.write(
|
|
785
|
-
"error: PandaStudio is not reachable and --no-launch was set.\n Open PandaStudio, go to Settings →
|
|
801
|
+
"error: PandaStudio is not reachable and --no-launch was set.\n Open PandaStudio, go to Settings → Other AI apps and turn on Local automation.\n",
|
|
786
802
|
);
|
|
787
803
|
return 3;
|
|
788
804
|
}
|
|
@@ -805,6 +821,10 @@ async function main() {
|
|
|
805
821
|
headers: {
|
|
806
822
|
"Content-Type": "application/json",
|
|
807
823
|
Authorization: `Bearer ${c.token}`,
|
|
824
|
+
// Run from the in-app agent's shell: confirmations show in its chat.
|
|
825
|
+
...(process.env.PANDASTUDIO_CALLER === "in-app"
|
|
826
|
+
? { "X-PandaStudio-Caller": "in-app" }
|
|
827
|
+
: {}),
|
|
808
828
|
},
|
|
809
829
|
body: JSON.stringify(callBody),
|
|
810
830
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@writepanda/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.276.0",
|
|
4
4
|
"description": "Drive PandaStudio (a desktop video editor for YouTube creators) from the command line. Talks to a localhost HTTP API the desktop app exposes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pandastudio",
|