@petercjl/topazlabscli 0.1.1 → 0.2.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 CHANGED
@@ -15,6 +15,8 @@ npm install --global @petercjl/topazlabscli
15
15
  topazlabscli skill install --agent all
16
16
  ```
17
17
 
18
+ The CLI checks npm for a newer stable release before operational commands, at most once every six hours. When an update is available it upgrades itself, refreshes installed Agent Skills, and then resumes the original command. A temporary npm outage does not block video processing. `topazlabscli update` forces an immediate manual update.
19
+
18
20
  ## Configure a target
19
21
 
20
22
  Use one or more SSH endpoints in priority order. A LAN-only user configures only the LAN entry.
@@ -56,9 +58,11 @@ The worker uses a global Windows mutex and one queue consumer, so jobs from mult
56
58
  ## Process a video
57
59
 
58
60
  ```powershell
59
- topazlabscli process .\input.mp4 --output .\output-1080p.mp4 --json
61
+ topazlabscli process .\input.mp4 --json
60
62
  ```
61
63
 
64
+ Without `--output`, the CLI writes `input-topaz-1080p.mp4` beside the source video. An explicit `--output` remains available for automation.
65
+
62
66
  Asynchronous form:
63
67
 
64
68
  ```powershell
@@ -68,7 +72,7 @@ topazlabscli job wait JOB_ID --json
68
72
  topazlabscli job download JOB_ID --output .\output-1080p.mp4 --json
69
73
  ```
70
74
 
71
- Version 0.1 includes one preset: `seedance-human-1080p`, using Proteus v4 (`prob-4`), source FPS, aspect-preserving 1080p output, and NVIDIA H.264 encoding.
75
+ Version 0.2 includes one preset: `seedance-human-1080p`, using Proteus v4 (`prob-4`), source FPS, aspect-preserving 1080p output, and NVIDIA H.264 encoding.
72
76
 
73
77
  ## Configuration
74
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petercjl/topazlabscli",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Cross-Agent CLI and portable Skill for queued remote Topaz Video AI processing",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "scripts": {
21
21
  "test": "node --test",
22
- "check": "node --check bin/topazlabscli.mjs && node --check src/cli.mjs && npm test"
22
+ "check": "node --check bin/topazlabscli.mjs && node --check src/cli.mjs && node --check src/update.mjs && npm test"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public",
@@ -9,7 +9,7 @@ Use the CLI as the single execution surface. Do not reproduce SSH, SFTP, queue,
9
9
 
10
10
  ## Input → Strategy → Output
11
11
 
12
- - Input: a local video path or a job identifier, the user's requested action, and an already configured target.
12
+ - Input: a local video path or a job identifier, the user's requested action, and an already configured target. A processing request needs only the input path.
13
13
  - Strategy: inspect capabilities and health, select the configured reachable endpoint, submit one deterministic preset to the serialized Windows queue, observe terminal state, and download only when requested.
14
14
  - Output: structured CLI evidence, a job identifier and state, and for completed processing an explicitly requested local output file.
15
15
 
@@ -17,28 +17,30 @@ Use the CLI as the single execution surface. Do not reproduce SSH, SFTP, queue,
17
17
 
18
18
  1. Run `topazlabscli capabilities --json` when the live contract is not already known.
19
19
  2. Run `topazlabscli doctor --json` before the first job in a conversation or after a connection/model failure.
20
- 3. For a processing request, confirm the input exists and the output path is authorized.
21
- 4. Prefer `topazlabscli process INPUT --output OUTPUT --json` for submit, wait, and download as one operation. Use separate `job` commands when the user wants asynchronous control.
20
+ 3. For a processing request, confirm the input exists. When the user does not name an output, let the CLI create `INPUT-BASENAME-topaz-1080p.EXT` beside the source.
21
+ 4. Prefer `topazlabscli process INPUT --json` for submit, wait, and download as one operation. Add `--output OUTPUT` only when the user explicitly requests another destination. Use separate `job` commands when the user wants asynchronous control.
22
22
  5. Inspect the final JSON. Completion requires `state=completed`, a successful download result, and a real local output file.
23
23
  6. Report the selected target/endpoint, job ID, output path, preset/model, dimensions, and any warning or failure.
24
24
 
25
25
  ## Preset Boundary
26
26
 
27
- `seedance-human-1080p` is the only built-in preset in version 0.1. It uses Proteus v4 (`prob-4`), preserves source FPS and aspect ratio, targets a 1080-pixel short edge, and relies on the remote queue's single concurrency slot. Do not silently substitute another model, frame interpolation, stabilization, motion deblur, or 4K output.
27
+ `seedance-human-1080p` is the only built-in preset in version 0.2. It uses Proteus v4 (`prob-4`), preserves source FPS and aspect ratio, targets a 1080-pixel short edge, and relies on the remote queue's single concurrency slot. Do not silently substitute another model, frame interpolation, stabilization, motion deblur, or 4K output.
28
28
 
29
29
  ## Branches
30
30
 
31
31
  - Connection failure: report `CONNECTION_FAILED` and the endpoint attempts. The CLI does not start, reconfigure, or grant access to a VPN.
32
32
  - Worker/model not ready: run `worker status` or `model status`; stop with the returned dependency error. Installing/licensing Topaz and downloading models remain GUI administration tasks.
33
33
  - Long-running work: use `job submit`, return the job ID, then `job wait` when the user asks to remain attached. Do not resubmit merely because a wait timed out.
34
- - Cancellation: queued work may cancel immediately. A running task records a cancellation request but is not forcibly killed in version 0.1.
34
+ - Cancellation: queued work may cancel immediately. A running task records a cancellation request but is not forcibly killed in version 0.2.
35
35
  - Missing capability: return `CAPABILITY_UNAVAILABLE` or the CLI's structured error. Do not invent a platform-specific workaround.
36
36
 
37
37
  ## Configuration and Safety
38
38
 
39
39
  Configuration, hostnames, addresses, usernames, SSH identities, VPN details, media, Topaz binaries, models, and credentials are external to this Skill and npm package. Installation does not grant access to a workstation. Treat the configured server and Topaz license as user-managed resources.
40
40
 
41
- Do not overwrite a local output unless the user has authorized that exact existing target. The remote worker retains job inputs, outputs, status, and logs for operator review; cleanup is an administrative action outside version 0.1.
41
+ Before operational commands, the CLI performs a cached npm update check. A newer stable package is installed automatically, installed Agent Skills are refreshed, and the original command resumes under the new version. Registry failures produce a warning and continue with the installed version.
42
+
43
+ Do not overwrite a local output unless the user has authorized that exact existing target. The remote worker retains job inputs, outputs, status, and logs for operator review; cleanup is an administrative action outside version 0.2.
42
44
 
43
45
  ## Skill Management
44
46
 
@@ -8,7 +8,7 @@
8
8
  "implementation": { "kind": "cli", "command": "topazlabscli" },
9
9
  "features": ["local-process", "stdout-json", "exit-code"],
10
10
  "status": "implemented",
11
- "configuration": ["topazlabscli must resolve from PATH"],
11
+ "configuration": ["topazlabscli must resolve from PATH", "The bundled topazlabscli Skill must be installed through the CLI"],
12
12
  "permissions": ["local process execution", "network access to configured SSH target"],
13
13
  "normalization": "Invoke with --json and consume {ok,data,error}."
14
14
  },
@@ -6,13 +6,13 @@
6
6
  "capabilities": [
7
7
  {
8
8
  "id": "command.execute",
9
- "purpose": "Run the stable topazlabscli executable and parse JSON results.",
9
+ "purpose": "Run the stable, self-updating topazlabscli executable and parse JSON results.",
10
10
  "required": true,
11
11
  "required_features": ["local-process", "stdout-json", "exit-code"],
12
12
  "input_fields": ["argv"],
13
13
  "output_fields": ["ok", "data", "error"],
14
14
  "side_effects": {
15
- "external_mutation": "May upload videos and enqueue remote processing only when the user requests processing.",
15
+ "external_mutation": "May update the installed npm package and Agent Skill before a command; may upload videos and enqueue remote processing only when the user requests processing.",
16
16
  "may_cost_money": false,
17
17
  "authorization": "Requires the user's configured SSH access and an explicit processing request."
18
18
  },
package/src/cli.mjs CHANGED
@@ -8,6 +8,7 @@ import { CliError, requireValue } from "./errors.mjs";
8
8
  import { run } from "./process.mjs";
9
9
  import { psLiteral, runPowerShell, selectEndpoint, sftpGet, sftpPut, startPowerShellDetached } from "./ssh.mjs";
10
10
  import { skillInstall, skillSource, skillStatus } from "./skill.mjs";
11
+ import { maybeAutoUpdate } from "./update.mjs";
11
12
 
12
13
  const require = createRequire(import.meta.url);
13
14
  const pkg = require("../package.json");
@@ -17,7 +18,8 @@ const CAPABILITIES = {
17
18
  schema_version: 1,
18
19
  package: pkg.name,
19
20
  version: pkg.version,
20
- commands: ["version", "capabilities", "doctor", "target", "connection", "worker", "model", "job", "process", "skill", "update"],
21
+ commands: ["version", "capabilities", "doctor", "settings", "target", "connection", "worker", "model", "job", "process", "skill", "update"],
22
+ automatic_updates: { enabled_by_default: true, registry_check_hours: 6, refreshes_installed_skills: true },
21
23
  presets: [{ id: PRESET, model: "prob-4", output: "aspect-preserving 1080p", fps: "source", concurrency: 1 }],
22
24
  agents: { codex: "tested", sealseek: "implemented" },
23
25
  worker_os: ["windows"],
@@ -58,6 +60,7 @@ function help() {
58
60
  return `topazlabscli ${pkg.version}\n\n` +
59
61
  `Commands:\n` +
60
62
  ` version | capabilities | doctor\n` +
63
+ ` settings show | set auto-update <on|off> | set update-check-hours <hours>\n` +
61
64
  ` target add <name> --endpoint <label=host>... --user <user> [--identity <path>] [--workspace <windows-path>] [--default]\n` +
62
65
  ` target list\n` +
63
66
  ` connection check [--target <name>]\n` +
@@ -66,7 +69,7 @@ function help() {
66
69
  ` job submit <video> [--target <name>] [--preset ${PRESET}]\n` +
67
70
  ` job list [--target <name>]\n` +
68
71
  ` job status|wait|download|cancel <job-id> [--target <name>] [--output <path>]\n` +
69
- ` process <video> --output <path> [--target <name>]\n` +
72
+ ` process <video> [--output <path>] [--target <name>]\n` +
70
73
  ` skill source|status|install|update [--agent codex|sealseek|all] [--copy]\n` +
71
74
  ` update\n\nUse --json for machine-readable output.`;
72
75
  }
@@ -143,6 +146,12 @@ async function downloadJob(id, requestedTarget, outputPath) {
143
146
  return { id, target: target.name, endpoint: endpoint.name, output: destination };
144
147
  }
145
148
 
149
+ export function defaultOutputPath(inputPath) {
150
+ const resolved = path.resolve(inputPath);
151
+ const extension = path.extname(resolved) || ".mp4";
152
+ return path.join(path.dirname(resolved), `${path.basename(resolved, path.extname(resolved))}-topaz-1080p${extension}`);
153
+ }
154
+
146
155
  async function doctor(requestedTarget) {
147
156
  const checks = [];
148
157
  for (const command of ["ssh", "sftp", "node", "npm"]) {
@@ -177,6 +186,37 @@ export async function main(rawArgs) {
177
186
  const command = args.shift();
178
187
  if (command === "version" || command === "--version" || command === "-V") return output(pkg.version, json);
179
188
  if (command === "capabilities") return output(CAPABILITIES, json);
189
+
190
+ if (!["update", "settings"].includes(command)) {
191
+ const update = await maybeAutoUpdate(rawArgs, pkg);
192
+ if (update.warning) process.stderr.write(`[AUTO_UPDATE_WARNING] ${update.warning}\n`);
193
+ if (update.reexecuted) {
194
+ process.exitCode = update.exitCode;
195
+ return;
196
+ }
197
+ }
198
+
199
+ if (command === "settings") {
200
+ const action = args.shift() || "show";
201
+ const config = loadConfig();
202
+ if (action === "show") return output(config.settings, json);
203
+ if (action === "set") {
204
+ const name = requireValue(args.shift(), "SETTING_REQUIRED", "settings set requires a setting name.");
205
+ const value = requireValue(args.shift(), "VALUE_REQUIRED", `settings set ${name} requires a value.`);
206
+ if (name === "auto-update") {
207
+ if (!["on", "off"].includes(value)) throw new CliError("SETTING_INVALID", "auto-update must be on or off.");
208
+ config.settings.auto_update = value === "on";
209
+ } else if (name === "update-check-hours") {
210
+ const hours = Number(value);
211
+ if (!Number.isFinite(hours) || hours < 0) throw new CliError("SETTING_INVALID", "update-check-hours must be zero or a positive number.");
212
+ config.settings.update_check_hours = hours;
213
+ } else throw new CliError("SETTING_UNKNOWN", `Unknown setting: ${name}`);
214
+ const saved = saveConfig(config);
215
+ return output({ path: saved, settings: config.settings }, json);
216
+ }
217
+ throw new CliError("COMMAND_UNKNOWN", `Unknown settings action: ${action}`);
218
+ }
219
+
180
220
  if (command === "doctor") return output(await doctor(option(args, "--target")), json);
181
221
 
182
222
  if (command === "target") {
@@ -253,7 +293,7 @@ export async function main(rawArgs) {
253
293
 
254
294
  if (command === "process") {
255
295
  const input = requireValue(args.shift(), "INPUT_REQUIRED", "process requires a video.");
256
- const destination = requireValue(option(args, "--output"), "OUTPUT_REQUIRED", "process requires --output.");
296
+ const destination = option(args, "--output") || defaultOutputPath(input);
257
297
  const requested = option(args, "--target");
258
298
  const submitted = await submitJob(input, requested, option(args, "--preset") || PRESET);
259
299
  const finished = await waitJob(submitted.id, requested, Number(option(args, "--interval") || 10), Number(option(args, "--timeout") || 86400));
package/src/config.mjs CHANGED
@@ -4,7 +4,12 @@ import { configPath } from "./paths.mjs";
4
4
  import { CliError } from "./errors.mjs";
5
5
 
6
6
  export function emptyConfig() {
7
- return { schema_version: 1, default_target: null, targets: {} };
7
+ return {
8
+ schema_version: 1,
9
+ default_target: null,
10
+ targets: {},
11
+ settings: { auto_update: true, update_check_hours: 6 }
12
+ };
8
13
  }
9
14
 
10
15
  export function loadConfig({ required = false } = {}) {
@@ -18,7 +23,15 @@ export function loadConfig({ required = false } = {}) {
18
23
  if (parsed.schema_version !== 1 || typeof parsed.targets !== "object") {
19
24
  throw new Error("unsupported configuration schema");
20
25
  }
21
- return parsed;
26
+ return {
27
+ ...parsed,
28
+ settings: {
29
+ auto_update: parsed.settings?.auto_update !== false,
30
+ update_check_hours: Number.isFinite(parsed.settings?.update_check_hours)
31
+ ? parsed.settings.update_check_hours
32
+ : 6
33
+ }
34
+ };
22
35
  } catch (error) {
23
36
  throw new CliError("CONFIG_INVALID", `Cannot read configuration: ${error.message}`, { path: filename });
24
37
  }
package/src/paths.mjs CHANGED
@@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url";
4
4
 
5
5
  const here = path.dirname(fileURLToPath(import.meta.url));
6
6
  export const packageRoot = path.resolve(here, "..");
7
+ export const binScript = path.join(packageRoot, "bin", "topazlabscli.mjs");
7
8
  export const bundledSkill = path.join(packageRoot, "skill", "topazlabscli");
8
9
  export const workerScript = path.join(packageRoot, "worker", "windows", "topazlabs-worker.ps1");
9
10
 
@@ -15,6 +16,11 @@ export function configPath() {
15
16
  return path.join(base, "topazlabscli", "config.json");
16
17
  }
17
18
 
19
+ export function updateStatePath() {
20
+ if (process.env.TOPAZLABSCLI_UPDATE_STATE) return path.resolve(process.env.TOPAZLABSCLI_UPDATE_STATE);
21
+ return path.join(path.dirname(configPath()), "update-state.json");
22
+ }
23
+
18
24
  export function skillTarget(agent) {
19
25
  const home = os.homedir();
20
26
  if (agent === "codex") {
package/src/process.mjs CHANGED
@@ -19,3 +19,16 @@ export function run(command, args, options = {}) {
19
19
  }
20
20
  });
21
21
  }
22
+
23
+ export function runInherited(command, args, options = {}) {
24
+ return new Promise((resolve, reject) => {
25
+ const child = spawn(command, args, {
26
+ cwd: options.cwd,
27
+ env: options.env || process.env,
28
+ stdio: "inherit",
29
+ windowsHide: true
30
+ });
31
+ child.on("error", reject);
32
+ child.on("close", (code, signal) => resolve({ code, signal }));
33
+ });
34
+ }
package/src/update.mjs ADDED
@@ -0,0 +1,88 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { loadConfig } from "./config.mjs";
4
+ import { binScript, updateStatePath } from "./paths.mjs";
5
+ import { run, runInherited } from "./process.mjs";
6
+ import { skillInstall, skillStatus } from "./skill.mjs";
7
+
8
+ const DEFAULT_INTERVAL_HOURS = 6;
9
+ const UPDATE_GUARD = "TOPAZLABSCLI_AUTO_UPDATE_GUARD";
10
+
11
+ function numericParts(version) {
12
+ return String(version).replace(/^v/, "").split(/[.+-]/).slice(0, 3).map((part) => Number(part) || 0);
13
+ }
14
+
15
+ export function isNewerVersion(candidate, current) {
16
+ const left = numericParts(candidate);
17
+ const right = numericParts(current);
18
+ for (let index = 0; index < 3; index += 1) {
19
+ if (left[index] !== right[index]) return left[index] > right[index];
20
+ }
21
+ return false;
22
+ }
23
+
24
+ function readState(filename) {
25
+ try { return JSON.parse(fs.readFileSync(filename, "utf8")); }
26
+ catch { return {}; }
27
+ }
28
+
29
+ function writeState(filename, value) {
30
+ fs.mkdirSync(path.dirname(filename), { recursive: true, mode: 0o700 });
31
+ const temporary = `${filename}.${process.pid}.tmp`;
32
+ fs.writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
33
+ fs.renameSync(temporary, filename);
34
+ try { fs.chmodSync(filename, 0o600); } catch {}
35
+ }
36
+
37
+ function automaticUpdateEnabled(config, env) {
38
+ const override = env.TOPAZLABSCLI_AUTO_UPDATE?.toLowerCase();
39
+ if (["0", "false", "off", "no"].includes(override)) return false;
40
+ if (["1", "true", "on", "yes"].includes(override)) return true;
41
+ return config.settings?.auto_update !== false;
42
+ }
43
+
44
+ export async function maybeAutoUpdate(rawArgs, pkg, dependencies = {}) {
45
+ const env = dependencies.env || process.env;
46
+ if (env[UPDATE_GUARD] === "1") return { checked: false, reason: "guard" };
47
+
48
+ const config = (dependencies.loadConfig || loadConfig)();
49
+ if (!automaticUpdateEnabled(config, env)) return { checked: false, reason: "disabled" };
50
+
51
+ const stateFile = dependencies.stateFile || updateStatePath();
52
+ const now = dependencies.now?.() || Date.now();
53
+ const intervalHours = Number(config.settings?.update_check_hours ?? DEFAULT_INTERVAL_HOURS);
54
+ const intervalMs = Math.max(0, intervalHours) * 60 * 60 * 1000;
55
+ const state = readState(stateFile);
56
+ if (intervalMs > 0 && Number.isFinite(state.last_checked_at) && now - state.last_checked_at < intervalMs) {
57
+ return { checked: false, reason: "fresh", latest: state.latest || null };
58
+ }
59
+
60
+ const execute = dependencies.run || run;
61
+ const query = await execute("npm", ["view", pkg.name, "version", "--json"], {
62
+ env: { ...env, npm_config_fetch_timeout: env.npm_config_fetch_timeout || "5000", npm_config_fetch_retries: "0" }
63
+ });
64
+ if (query.code !== 0) {
65
+ return { checked: true, warning: query.stderr.trim() || "Unable to check npm for updates." };
66
+ }
67
+
68
+ let latest;
69
+ try { latest = JSON.parse(query.stdout.trim()); }
70
+ catch { latest = query.stdout.trim().replace(/^"|"$/g, ""); }
71
+ writeState(stateFile, { last_checked_at: now, latest, current: pkg.version });
72
+ if (!isNewerVersion(latest, pkg.version)) return { checked: true, updated: false, latest };
73
+
74
+ const getSkillStatus = dependencies.skillStatus || skillStatus;
75
+ const installSkill = dependencies.skillInstall || skillInstall;
76
+ const installedSkills = getSkillStatus("all").filter((item) => item.installed);
77
+ const install = await execute("npm", ["install", "--global", `${pkg.name}@latest`], { env });
78
+ if (install.code !== 0) {
79
+ return { checked: true, warning: install.stderr.trim() || "Automatic npm update failed.", latest };
80
+ }
81
+ for (const item of installedSkills) installSkill(item.agent, item.mode || "link", true);
82
+
83
+ const reexecute = dependencies.runInherited || runInherited;
84
+ const child = await reexecute(process.execPath, [binScript, ...rawArgs], {
85
+ env: { ...env, [UPDATE_GUARD]: "1" }
86
+ });
87
+ return { checked: true, updated: true, latest, reexecuted: true, exitCode: child.code ?? 1 };
88
+ }