@leg3ndy/otto-bridge 0.1.1 → 0.1.2

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
@@ -24,13 +24,14 @@ O pacote ja esta estruturado para install via CLI:
24
24
  ```bash
25
25
  npm install -g @leg3ndy/otto-bridge
26
26
  otto-bridge status
27
+ otto-bridge version
27
28
  ```
28
29
 
29
30
  Enquanto o pacote nao estiver publicado, voce pode gerar um tarball local:
30
31
 
31
32
  ```bash
32
33
  npm pack
33
- npm install -g ./leg3ndy-otto-bridge-0.1.1.tgz
34
+ npm install -g ./leg3ndy-otto-bridge-0.1.2.tgz
34
35
  ```
35
36
 
36
37
  ## Publicacao
@@ -55,6 +56,13 @@ npm_config_cache=/tmp/otto-npm-cache npm publish --access public
55
56
 
56
57
  ## Comandos
57
58
 
59
+ ### Listar ajuda
60
+
61
+ ```bash
62
+ otto-bridge help
63
+ otto-bridge --help
64
+ ```
65
+
58
66
  ### Parear o dispositivo
59
67
 
60
68
  ```bash
@@ -84,6 +92,33 @@ Se o executor estiver salvo no `config.json`, o `run` usa essa configuracao por
84
92
  otto-bridge status
85
93
  ```
86
94
 
95
+ ### Ver versao instalada
96
+
97
+ ```bash
98
+ otto-bridge version
99
+ otto-bridge --version
100
+ ```
101
+
102
+ ### Atualizar o pacote
103
+
104
+ Atualizacao automatica via npm:
105
+
106
+ ```bash
107
+ otto-bridge update
108
+ ```
109
+
110
+ Para apenas ver qual comando sera executado:
111
+
112
+ ```bash
113
+ otto-bridge update --dry-run
114
+ ```
115
+
116
+ Para instalar manualmente:
117
+
118
+ ```bash
119
+ npm install -g @leg3ndy/otto-bridge@latest
120
+ ```
121
+
87
122
  ### Remover pareamento local
88
123
 
89
124
  ```bash
package/dist/main.js CHANGED
@@ -1,11 +1,18 @@
1
1
  #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
2
3
  import process from "node:process";
3
4
  import { clearBridgeConfig, getBridgeConfigPath, loadBridgeConfig, resolveApiBaseUrl, resolveExecutorConfig, } from "./config.js";
4
5
  import { pairDevice } from "./pairing.js";
5
6
  import { BridgeRuntime } from "./runtime.js";
6
- import { DEFAULT_PAIR_TIMEOUT_SECONDS, DEFAULT_POLL_INTERVAL_MS, } from "./types.js";
7
+ import { BRIDGE_PACKAGE_NAME, BRIDGE_VERSION, DEFAULT_PAIR_TIMEOUT_SECONDS, DEFAULT_POLL_INTERVAL_MS, } from "./types.js";
7
8
  function parseArgs(argv) {
8
9
  const [maybeCommand, ...rest] = argv;
10
+ if (maybeCommand === "--help" || maybeCommand === "-h") {
11
+ return { command: "help", options: new Map() };
12
+ }
13
+ if (maybeCommand === "--version" || maybeCommand === "-v") {
14
+ return { command: "version", options: new Map() };
15
+ }
9
16
  const command = maybeCommand && !maybeCommand.startsWith("--") ? maybeCommand : "run";
10
17
  const tokens = command === "run" && maybeCommand?.startsWith("--") ? argv : rest;
11
18
  const options = new Map();
@@ -49,7 +56,38 @@ function printUsage() {
49
56
  otto-bridge pair --api http://localhost:8000 --code ABC123 [--name "Meu PC"] [--executor mock|clawd-cursor]
50
57
  otto-bridge run [--executor mock|clawd-cursor] [--clawd-url http://127.0.0.1:3847]
51
58
  otto-bridge status
52
- otto-bridge unpair`);
59
+ otto-bridge version
60
+ otto-bridge update [--tag latest|next] [--dry-run]
61
+ otto-bridge unpair
62
+
63
+ Examples:
64
+ otto-bridge pair --api https://api.leg3ndy.com.br --code ABC123 --executor clawd-cursor --clawd-url http://127.0.0.1:3847
65
+ otto-bridge run
66
+ otto-bridge version
67
+ otto-bridge update
68
+ otto-bridge update --dry-run
69
+ otto-bridge --version`);
70
+ }
71
+ function printVersion() {
72
+ console.log(`${BRIDGE_PACKAGE_NAME} ${BRIDGE_VERSION}`);
73
+ }
74
+ function runChildCommand(command, args) {
75
+ return new Promise((resolve, reject) => {
76
+ const child = spawn(command, args, {
77
+ stdio: "inherit",
78
+ env: process.env,
79
+ });
80
+ child.on("error", (error) => {
81
+ reject(error);
82
+ });
83
+ child.on("exit", (code) => {
84
+ if (code === 0) {
85
+ resolve();
86
+ return;
87
+ }
88
+ reject(new Error(`${command} exited with code ${code ?? "unknown"}`));
89
+ });
90
+ });
53
91
  }
54
92
  async function runPairCommand(args) {
55
93
  const code = option(args, "code");
@@ -106,6 +144,23 @@ async function runUnpairCommand() {
106
144
  await clearBridgeConfig();
107
145
  console.log("[otto-bridge] local pairing cleared");
108
146
  }
147
+ async function runUpdateCommand(args) {
148
+ const tag = option(args, "tag") || "latest";
149
+ const packageSpec = `${BRIDGE_PACKAGE_NAME}@${tag}`;
150
+ const command = process.platform === "win32" ? "npm.cmd" : "npm";
151
+ const commandArgs = ["install", "-g", packageSpec];
152
+ const commandString = `${command} ${commandArgs.join(" ")}`;
153
+ if (args.options.has("dry-run") || args.options.has("check")) {
154
+ console.log(`[otto-bridge] current=${BRIDGE_VERSION}`);
155
+ console.log(`[otto-bridge] update command: ${commandString}`);
156
+ return;
157
+ }
158
+ console.log(`[otto-bridge] current=${BRIDGE_VERSION}`);
159
+ console.log(`[otto-bridge] updating with: ${commandString}`);
160
+ await runChildCommand(command, commandArgs);
161
+ console.log("[otto-bridge] update completed");
162
+ console.log("[otto-bridge] run `otto-bridge version` to confirm the installed version");
163
+ }
109
164
  async function main() {
110
165
  const args = parseArgs(process.argv.slice(2));
111
166
  switch (args.command) {
@@ -118,6 +173,16 @@ async function main() {
118
173
  case "status":
119
174
  await runStatusCommand();
120
175
  return;
176
+ case "version":
177
+ printVersion();
178
+ return;
179
+ case "--version":
180
+ case "-v":
181
+ printVersion();
182
+ return;
183
+ case "update":
184
+ await runUpdateCommand(args);
185
+ return;
121
186
  case "unpair":
122
187
  await runUnpairCommand();
123
188
  return;
package/dist/types.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export const BRIDGE_CONFIG_VERSION = 1;
2
- export const BRIDGE_VERSION = "0.1.1";
2
+ export const BRIDGE_VERSION = "0.1.2";
3
+ export const BRIDGE_PACKAGE_NAME = "@leg3ndy/otto-bridge";
3
4
  export const DEFAULT_API_BASE_URL = "http://localhost:8000";
4
5
  export const DEFAULT_POLL_INTERVAL_MS = 3000;
5
6
  export const DEFAULT_PAIR_TIMEOUT_SECONDS = 600;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leg3ndy/otto-bridge",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Local companion for Otto Bridge device pairing and WebSocket runtime.",
@@ -38,6 +38,8 @@
38
38
  "pair": "node dist/main.js pair",
39
39
  "run": "node dist/main.js run",
40
40
  "status": "node dist/main.js status",
41
+ "version:cli": "node dist/main.js version",
42
+ "update:cli": "node dist/main.js update --dry-run",
41
43
  "unpair": "node dist/main.js unpair"
42
44
  },
43
45
  "publishConfig": {