@crievo/omni 0.1.4 → 0.1.6
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/package.json +5 -3
- package/reference/learnings.md +12 -0
- package/reference/studio.md +10 -5
- package/studio/api/services/queue.ts +2 -0
- package/studio/api/services/root.ts +2 -3
- package/studio/runner/runner.ts +1 -1
- package/studio/studio.ts +5 -3
- package/studio/web/lib/studio-offline.ts +31 -7
- package/tools/job-queue.mjs +25 -7
- package/tools/job_queue.py +100 -24
- package/tools/lib/deps.mjs +21 -10
- package/tools/lib/oauth-client.mjs +18 -45
- package/tools/lib/platform.mjs +102 -0
- package/tools/lib/service-run.mjs +124 -0
- package/tools/lib/service-windows.mjs +240 -0
- package/tools/lib/service.mjs +74 -4
- package/tools/lib/up.mjs +32 -17
- package/tools/lib/vault.mjs +116 -0
- package/tools/metrics.mjs +7 -2
- package/tools/omni.mjs +6 -8
- package/tools/omnichat.mjs +28 -10
- package/tools/package.mjs +4 -3
- package/tools/publish.mjs +13 -7
- package/tools/runner.mjs +6 -6
package/tools/publish.mjs
CHANGED
|
@@ -149,6 +149,7 @@ import {
|
|
|
149
149
|
attemptOutcome,
|
|
150
150
|
} from "./lib/schedule/schedule.mjs";
|
|
151
151
|
import { CODE_ROOT, homeEnvPlist, DATA_ROOT as ROOT } from "./lib/paths.mjs";
|
|
152
|
+
import { localAgents, noLocalAgent, openUrl, pickPython } from "./lib/platform.mjs";
|
|
152
153
|
|
|
153
154
|
const CFG = JSON.parse(readFileSync(join(ROOT, "omnivideo.config.json"), "utf8"));
|
|
154
155
|
const P = publishConfig(CFG.publish ?? {});
|
|
@@ -211,7 +212,7 @@ async function localLogin({ name, who, path = "/", buildUrl }) {
|
|
|
211
212
|
);
|
|
212
213
|
else {
|
|
213
214
|
console.log(`abrindo o login ${who} ${app ? `no ${app}` : "no navegador"}…`);
|
|
214
|
-
const p =
|
|
215
|
+
const p = openUrl(url, { app });
|
|
215
216
|
if (p.status !== 0)
|
|
216
217
|
console.log(`não abriu${app ? ` o ${app}` : ""}: ${(p.stderr || "").trim()}. Cole o link à mão.`);
|
|
217
218
|
}
|
|
@@ -457,7 +458,7 @@ async function status() {
|
|
|
457
458
|
` automático: ${P.auto.approved ? `ligado (${P.auto.platforms.join(", ")})` : "desligado (publish.auto.approved)"}`,
|
|
458
459
|
);
|
|
459
460
|
console.log(
|
|
460
|
-
` agenda: ${r.scheduler
|
|
461
|
+
` agenda: ${agentWords(r.scheduler, "agente ligado, confere a cada minuto", "agente desligado (node tools/publish.mjs scheduler install)")}`,
|
|
461
462
|
);
|
|
462
463
|
if (r.youtube.ready && !P.youtube.audited)
|
|
463
464
|
console.log(
|
|
@@ -581,9 +582,7 @@ function checkAuto(dir) {
|
|
|
581
582
|
for (const n of [...PLATFORMS, "privacy", "tiktok-privacy", "again", "confirm"]) {
|
|
582
583
|
if (has(n)) fail(`--auto usa as plataformas e a privacidade da config; não combina com --${n}`);
|
|
583
584
|
}
|
|
584
|
-
const py =
|
|
585
|
-
[join(CODE_ROOT, ".venv", "bin", "python"), CFG.voicestudio?.python ?? ""].find(p => p && existsSync(p)) ??
|
|
586
|
-
"python3";
|
|
585
|
+
const py = pickPython(CODE_ROOT, [CFG.voicestudio?.python ?? ""]);
|
|
587
586
|
const r = spawnSync(py, [join(CODE_ROOT, "tools", "omnivideo.py"), "status", dir, "--json"], { encoding: "utf8" });
|
|
588
587
|
if (r.status !== 0) fail(`status do vídeo: ${(r.stderr || r.stdout).slice(-400)}`);
|
|
589
588
|
const st = JSON.parse(r.stdout);
|
|
@@ -952,7 +951,7 @@ async function schedule(dir) {
|
|
|
952
951
|
writeFileSync(INDEX_FILE, JSON.stringify([...index], null, 2) + "\n");
|
|
953
952
|
}
|
|
954
953
|
console.log(`agendado: ${platforms.join(", ")} em ${dayTime(when)}`);
|
|
955
|
-
if (!agentStatus().loaded)
|
|
954
|
+
if (localAgents() && !agentStatus().loaded)
|
|
956
955
|
console.log(
|
|
957
956
|
"aviso: o agente da agenda está desligado e nada sobe na hora: node tools/publish.mjs scheduler install",
|
|
958
957
|
);
|
|
@@ -1137,7 +1136,7 @@ function listSchedule() {
|
|
|
1137
1136
|
return;
|
|
1138
1137
|
}
|
|
1139
1138
|
console.log(
|
|
1140
|
-
`agente: ${agent
|
|
1139
|
+
`agente: ${agentWords(agent, "ligado, confere a cada minuto", "desligado (scheduler install)")}${agent.installed && !agent.node_ok ? " · o node do agente sumiu: rode scheduler install de novo" : ""}`,
|
|
1141
1140
|
);
|
|
1142
1141
|
if (!items.length) console.log("nada agendado");
|
|
1143
1142
|
for (const i of items) {
|
|
@@ -1267,8 +1266,13 @@ function runOne(dir) {
|
|
|
1267
1266
|
launchd starts with a minimal PATH, without ffprobe or claude. */
|
|
1268
1267
|
const domain = () => `gui/${process.getuid()}`;
|
|
1269
1268
|
const launchctl = (...a) => spawnSync("launchctl", a, { encoding: "utf8" });
|
|
1269
|
+
/* what a status line says about the agent: on, off, or (Windows, Linux) that the cloud does the work */
|
|
1270
|
+
const agentWords = (a, on, off) =>
|
|
1271
|
+
a.supported === false ? "sem agente local aqui (a agenda é da cloud: cloud.schedule)" : a.loaded ? on : off;
|
|
1270
1272
|
|
|
1271
1273
|
function agentStatus() {
|
|
1274
|
+
/* no launchd, no agent: on Windows and Linux the cloud keeps the schedule (cloud.schedule) */
|
|
1275
|
+
if (!localAgents()) return { installed: false, loaded: false, node_ok: false, supported: false, log: LOG_FILE };
|
|
1272
1276
|
const installed = existsSync(PLIST);
|
|
1273
1277
|
let node = null;
|
|
1274
1278
|
if (installed) {
|
|
@@ -1289,6 +1293,7 @@ function agentStatus() {
|
|
|
1289
1293
|
}
|
|
1290
1294
|
|
|
1291
1295
|
function installAgent() {
|
|
1296
|
+
if (!localAgents()) return console.log(noLocalAgent("a agenda de publicação", "schedule"));
|
|
1292
1297
|
const x = s => String(s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1293
1298
|
const path = [
|
|
1294
1299
|
...new Set([
|
|
@@ -1346,6 +1351,7 @@ function installAgent() {
|
|
|
1346
1351
|
}
|
|
1347
1352
|
|
|
1348
1353
|
function uninstallAgent() {
|
|
1354
|
+
if (!localAgents()) return console.log(noLocalAgent("a agenda de publicação", "schedule"));
|
|
1349
1355
|
launchctl("bootout", `${domain()}/${AGENT}`);
|
|
1350
1356
|
try {
|
|
1351
1357
|
unlinkSync(PLIST);
|
package/tools/runner.mjs
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
pairs this Mac: shows a code, opens the approval page, waits
|
|
11
11
|
node tools/runner.mjs status [--json] paired? which Mac? connected now? the service on?
|
|
12
12
|
node tools/runner.mjs logout deletes this Mac's key in the cloud and here
|
|
13
|
-
node tools/runner.mjs service install the studio as a
|
|
14
|
-
stops, no terminal
|
|
13
|
+
node tools/runner.mjs service install the studio as a service (launchd on macOS, a scheduled task on
|
|
14
|
+
Windows): starts at login, restarts if it stops, no terminal
|
|
15
|
+
(log in .runner/studio.log)
|
|
15
16
|
node tools/runner.mjs service uninstall | restart | status
|
|
16
17
|
|
|
17
18
|
Pairing is the device authorization flow (RFC 8628) of the studio's Better Auth: the code lasts
|
|
@@ -20,8 +21,8 @@
|
|
|
20
21
|
============================================================================ */
|
|
21
22
|
|
|
22
23
|
import { hostname } from "node:os";
|
|
23
|
-
import { spawn } from "node:child_process";
|
|
24
24
|
import { finishPairing, startPairing } from "./lib/pairing.mjs";
|
|
25
|
+
import { openUrl } from "./lib/platform.mjs";
|
|
25
26
|
import { cloudSettings, env, runnerStatus, writeEnv } from "./platforms.mjs";
|
|
26
27
|
import { service, serviceInstall, serviceRestart, serviceUninstall } from "./lib/service.mjs";
|
|
27
28
|
|
|
@@ -61,8 +62,7 @@ async function login() {
|
|
|
61
62
|
console.log(`Código do pareamento: ${code.user_code}`);
|
|
62
63
|
console.log(`Aprove em: ${code.verification_uri_complete}`);
|
|
63
64
|
console.log(`(vale ${Math.round(code.expires_in / 60)} min; confira se o código na página é o mesmo)`);
|
|
64
|
-
if (!args.includes("--no-open")
|
|
65
|
-
spawn("open", [code.verification_uri_complete], { stdio: "ignore", detached: true }).unref();
|
|
65
|
+
if (!args.includes("--no-open")) openUrl(code.verification_uri_complete);
|
|
66
66
|
const paired = await finishPairing(url, code, name).catch(e =>
|
|
67
67
|
fail(`${e.message}; rode de novo node tools/runner.mjs login`),
|
|
68
68
|
);
|
|
@@ -75,7 +75,7 @@ async function login() {
|
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
/* --- the service: the studio kept on by launchd (tools/lib/service.mjs)
|
|
78
|
+
/* --- the service: the studio kept on by launchd or a scheduled task (tools/lib/service.mjs) ---- */
|
|
79
79
|
function install() {
|
|
80
80
|
try {
|
|
81
81
|
serviceInstall({ log: line => console.log(line) });
|