@rome-os/node 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/dist/entry.js CHANGED
@@ -211,8 +211,8 @@ async function main() {
211
211
  const [, command, deviceId, action] = positionals;
212
212
  const listing = positionals.length === 1;
213
213
  if (!listing &&
214
- !(command === "describe" && positionals.length === 3) &&
215
- !(command === "run" && positionals.length === 4))
214
+ !(["describe", "remove"].includes(command) && positionals.length === 3) &&
215
+ !(["run", "rename"].includes(command) && positionals.length === 4))
216
216
  throw new Error("Invalid device command. Run rome-node --help.");
217
217
  if (!listing && !validId(deviceId))
218
218
  throw new Error("Invalid device ID.");
@@ -231,6 +231,14 @@ async function main() {
231
231
  process.stdout.write(`${JSON.stringify(await client.listDevices())}\n`);
232
232
  return;
233
233
  }
234
+ if (command === "rename" || command === "remove") {
235
+ if (command === "rename")
236
+ await client.renameDevice(deviceId, action);
237
+ else
238
+ await client.removeDevice(deviceId);
239
+ process.stdout.write(`${JSON.stringify({ type: "response", ok: true, result: {} })}\n`);
240
+ return;
241
+ }
234
242
  if (values.input !== undefined || values.output !== undefined) {
235
243
  const output = values.output ?? "-";
236
244
  const input = values.input === undefined ? undefined : await readInput(values.input);
package/dist/help.js CHANGED
@@ -11,6 +11,8 @@ Commands:
11
11
  device List authorized devices (they may be offline).
12
12
  device describe Query a device's platform and supported actions.
13
13
  device run Execute an action on a device.
14
+ device rename Rename a device in the account.
15
+ device remove Revoke a device and delete it from the account.
14
16
  cp Copy a file to or from a device.
15
17
  watch Stream caller connection snapshots and changes as JSON lines.
16
18
  daemon Manage the caller's background connection.
@@ -97,11 +99,14 @@ The token is never printed.
97
99
  rome-node device
98
100
  rome-node device describe <device-id>
99
101
  rome-node device run <device-id> <action> [--args <json>] [--input <file|->] [--output <file|->]
102
+ rome-node device rename <device-id> <name>
103
+ rome-node device remove <device-id>
100
104
 
101
105
  With no subcommand, list authorized devices as {"items":[...]}.
102
106
  Use an item's id for subsequent commands. Listed devices may be offline.
103
107
  describe queries the target's current platform and actions through Gateway.
104
108
  run invokes one of those actions. The caller daemon starts automatically.
109
+ rename and remove change the account's device list in Rome Cloud.
105
110
 
106
111
  Examples:
107
112
  rome-node device
@@ -115,10 +120,38 @@ The result includes name, platform, and actions. Platform-specific commands and
115
120
  paths must match the target computer, which may differ from the caller.
116
121
 
117
122
  Example result:
118
- {"type":"response","ok":true,"result":{"name":"My computer","platform":"macos","actions":["system.info","exec"]}}
123
+ {"type":"response","ok":true,"result":{"name":"My computer","platform":"macos","actions":["system.info","exec","fs.list"]}}
119
124
 
120
125
  Failures return {"type":"response","ok":false,"error":{"code":"...","message":"..."}}.
121
126
  The local exit status is 0 on success or 1 on failure.
127
+ `,
128
+ "device rename": `Usage: rome-node device rename <device-id> <name>
129
+
130
+ Rename a device in the account. Use an ID from rome-node device. The device can
131
+ be offline. Rome Cloud trims the name and accepts 1 to 80 characters without
132
+ control characters. Names need not be unique; routing uses the ID.
133
+
134
+ Example:
135
+ rome-node device rename <device-id> "Build server"
136
+
137
+ Prints {"type":"response","ok":true,"result":{}} on success. Failures print
138
+ {"type":"response","ok":false,"error":{"code":"...","message":"..."}} with code
139
+ device_not_found, invalid_device_name, invalid_device_session, or cloud_unavailable.
140
+ The local exit status is 0 on success or 1 on failure.
141
+ `,
142
+ "device remove": `Usage: rome-node device remove <device-id>
143
+
144
+ Revoke a device and delete it from the account. Use an ID from rome-node device.
145
+ The device can be offline. A connected device is disconnected and must run
146
+ rome-node connect and be approved again to come back.
147
+
148
+ Rome Cloud keeps a revoked device listed until the Gateway confirms the
149
+ revocation. Until then remove fails with code revocation_pending: the device is
150
+ already revoked, and running remove again later deletes it. Other failure codes
151
+ are device_not_found, invalid_device_session, and cloud_unavailable.
152
+
153
+ Prints {"type":"response","ok":true,"result":{}} on success. The local exit
154
+ status is 0 on success or 1 on failure.
122
155
  `,
123
156
  "device run": `Usage:
124
157
  rome-node device run <device-id> <action> [--args <json>]
@@ -130,16 +163,25 @@ Use an ID from rome-node device. Run device describe first to discover actions.
130
163
  Computer actions:
131
164
  system.info No arguments. Returns name, platform, and actions.
132
165
  exec Run a program on the target computer.
166
+ fs.list List one folder. Read-only. Older targets return unsupported_action.
133
167
 
134
168
  exec arguments:
135
169
  command Required nonempty executable name or path.
136
170
  args Optional array of string arguments (default: []).
137
171
  cwd Optional working directory on the target (default: executor cwd).
138
172
 
173
+ fs.list arguments:
174
+ path Optional folder (default: the target user's home). Relative paths
175
+ start at home. ~ is not expanded.
176
+ Result: {path, parent, entries: [{name, type}], truncated}. path is the real
177
+ path; parent is null at the root; type is dir, file, symlink, or other.
178
+ At most 1000 entries, folders first.
179
+
139
180
  Programs receive no stdin unless --input is given. No shell is added automatically.
140
181
  Invoke a shell explicitly for pipelines, redirection, or shell builtins.
141
182
  Examples below use POSIX caller-shell quoting:
142
183
  rome-node device run <device-id> system.info
184
+ rome-node device run <device-id> fs.list --args '{"path":"/workspace"}'
143
185
  rome-node device run <device-id> exec --args '{"command":"git","args":["status"],"cwd":"/workspace"}'
144
186
  rome-node device run <device-id> exec --args '{"command":"cat","args":["/workspace/README.md"]}'
145
187
  rome-node device run <device-id> exec --args '{"command":"sh","args":["-c","ls /workspace | head"]}'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rome-os/node",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Standalone CLI for Rome remote devices",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@rome-os/node-core": "^0.1.3"
25
+ "@rome-os/node-core": "^0.1.5"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@rstest/core": "^0.11.11",