teamclaws 2.0.13 → 2.0.15
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 +23 -7
- package/dist/app.js +24 -9
- package/dist/constants.js +1 -1
- package/dist/output.js +11 -0
- package/dist/users.js +56 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -208,7 +208,8 @@ npx teamclaws pair status <server-identifier-or-canonical-workspace-address>
|
|
|
208
208
|
npx teamclaws pair
|
|
209
209
|
npx teamclaws pair <server-identifier-or-canonical-workspace-address> [--no-open]
|
|
210
210
|
npx teamclaws shell <target> --command <text> [--json]
|
|
211
|
-
npx teamclaws users add <target> <email>
|
|
211
|
+
npx teamclaws users add <target> <email> [--sudo] [--json]
|
|
212
|
+
npx teamclaws users remove <target> <email> [--json]
|
|
212
213
|
npx teamclaws chat start <target> --message <text>
|
|
213
214
|
npx teamclaws chat send <target> --session-id <uuid> --message <text>
|
|
214
215
|
npx teamclaws chat watch <target> --session-id <uuid> --request-id <uuid>
|
|
@@ -253,9 +254,11 @@ monitoring without creating another turn.
|
|
|
253
254
|
|
|
254
255
|
## Add a workspace user directly
|
|
255
256
|
|
|
256
|
-
`teamclaws users add <target> <email> --
|
|
257
|
-
using the saved paired machine credential and its bound authorization.
|
|
258
|
-
|
|
257
|
+
`teamclaws users add <target> <email> --json` sends a direct request
|
|
258
|
+
using the saved paired machine credential and its bound authorization.
|
|
259
|
+
CLI additions always request workspace Superuser access. Role selection is
|
|
260
|
+
intentionally unavailable for now because CLI additions are admin-only.
|
|
261
|
+
Sudo remains a separate opt-in. The server
|
|
259
262
|
verifies current owner authority and the shared six-calendar-month machine
|
|
260
263
|
authorization deadline. Initial CLI login and pairing remain the normal setup.
|
|
261
264
|
|
|
@@ -271,15 +274,28 @@ The owner can include `--sudo` when inviting a `superuser` to grant full sudo
|
|
|
271
274
|
access after acceptance:
|
|
272
275
|
|
|
273
276
|
```text
|
|
274
|
-
teamclaws users add <target> <email> --
|
|
277
|
+
teamclaws users add <target> <email> --sudo
|
|
275
278
|
```
|
|
276
279
|
|
|
277
|
-
Omitting `--sudo` requests no sudo grant.
|
|
278
|
-
`staff` roles. Sudo follows the existing access-group membership. The CLI
|
|
280
|
+
Omitting `--sudo` requests no sudo grant. Sudo follows the existing access-group membership. The CLI
|
|
279
281
|
requires the workspace to acknowledge the saved sudo selection before reporting
|
|
280
282
|
a new sudo invitation as successful. Existing members and pending invitations
|
|
281
283
|
remain unchanged even when the flag is supplied.
|
|
282
284
|
|
|
285
|
+
### Remove a workspace user
|
|
286
|
+
|
|
287
|
+
```text
|
|
288
|
+
teamclaws users remove <target> <email> --json
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Only the current machine owner can remove a member or revoke a pending
|
|
292
|
+
invitation. This removes access across all machines sharing the access group;
|
|
293
|
+
it does not delete the person's TeamClaws account. Machine and access-group
|
|
294
|
+
owners cannot be removed. No matching member or invitation returns an error.
|
|
295
|
+
The command uses the saved paired authorization without opening a browser or
|
|
296
|
+
starting a shell or chat. If the outcome is uncertain, inspect user and
|
|
297
|
+
invitation status before retrying; removal does not blindly retry.
|
|
298
|
+
|
|
283
299
|
### Inspect users and invitation status
|
|
284
300
|
|
|
285
301
|
```text
|
package/dist/app.js
CHANGED
|
@@ -11,7 +11,7 @@ import { CredentialStore } from "./storage.js";
|
|
|
11
11
|
import { TargetAuthorization } from "./target-authorization.js";
|
|
12
12
|
import { installRelease } from "./update.js";
|
|
13
13
|
import { normalizeUuid, parsePairingTarget } from "./validation.js";
|
|
14
|
-
import { runUsersAdd, runUsersList } from "./users.js";
|
|
14
|
+
import { runUsersAdd, runUsersList, runUsersRemove } from "./users.js";
|
|
15
15
|
export async function run(arguments_, dependencies = {}, signal) {
|
|
16
16
|
let parsed;
|
|
17
17
|
try {
|
|
@@ -96,6 +96,18 @@ export async function run(arguments_, dependencies = {}, signal) {
|
|
|
96
96
|
return safe.exitCode;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
if (parsed.action === "users_remove") {
|
|
100
|
+
try {
|
|
101
|
+
await targetAuthorization.requireGrant();
|
|
102
|
+
output.usersRemoveResult(await runUsersRemove(store, dependencies.fetcher ?? fetch, parsed.target, parsed.email, targetAuthorization, signal));
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const safe = safeError(error);
|
|
107
|
+
output.error(safe);
|
|
108
|
+
return safe.exitCode;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
99
111
|
const auth = new AuthService({
|
|
100
112
|
store,
|
|
101
113
|
output,
|
|
@@ -249,25 +261,28 @@ export function parseArguments(arguments_) {
|
|
|
249
261
|
json,
|
|
250
262
|
target: parsePairingTarget(requiredPositional(args, 2)),
|
|
251
263
|
};
|
|
264
|
+
if (args[0] === "users" && args[1] === "remove" && args.length === 4) {
|
|
265
|
+
const target = parsePairingTarget(requiredPositional(args, 2));
|
|
266
|
+
const email = requiredPositional(args, 3).trim().toLowerCase();
|
|
267
|
+
if (!email || email.length > 254)
|
|
268
|
+
throw usageError();
|
|
269
|
+
return { action: "users_remove", json, target, email };
|
|
270
|
+
}
|
|
252
271
|
if (args[0] === "users" && args[1] === "add") {
|
|
253
272
|
const target = parsePairingTarget(requiredPositional(args, 2));
|
|
254
273
|
const email = requiredPositional(args, 3).trim().toLowerCase();
|
|
255
274
|
const options = parseNamedOptions(args.slice(4), {
|
|
256
|
-
values: [
|
|
275
|
+
values: [],
|
|
257
276
|
booleans: ["--sudo"],
|
|
258
277
|
});
|
|
259
|
-
|
|
260
|
-
if (!email ||
|
|
261
|
-
email.length > 254 ||
|
|
262
|
-
!["user", "staff", "superuser"].includes(role ?? "") ||
|
|
263
|
-
(options.flags.has("--sudo") && role !== "superuser"))
|
|
278
|
+
if (!email || email.length > 254)
|
|
264
279
|
throw usageError();
|
|
265
280
|
return {
|
|
266
281
|
action: "users_add",
|
|
267
282
|
json,
|
|
268
283
|
target,
|
|
269
284
|
email,
|
|
270
|
-
role:
|
|
285
|
+
role: "superuser",
|
|
271
286
|
sudoEnabled: options.flags.has("--sudo"),
|
|
272
287
|
};
|
|
273
288
|
}
|
|
@@ -552,5 +567,5 @@ function usageError() {
|
|
|
552
567
|
});
|
|
553
568
|
}
|
|
554
569
|
export function helpText() {
|
|
555
|
-
return `TeamClaws ${PACKAGE_VERSION}\n\nUsage:\n teamclaws update [--json]\n teamclaws shell <target> --command <text> [--json]\n teamclaws users add <target> <email> --
|
|
570
|
+
return `TeamClaws ${PACKAGE_VERSION}\n\nUsage:\n teamclaws update [--json]\n teamclaws shell <target> --command <text> [--json]\n teamclaws users add <target> <email> [--sudo] [--json]\n teamclaws users remove <target> <email> [--json]\n teamclaws users list <target> [--json]\n teamclaws login <email> [--json]\n teamclaws auth status [--json]\n teamclaws logout [--revoke] [--json]\n teamclaws servers list [--json]\n teamclaws servers update <server-id> [--name <text>] [--description <text>] [--json]\n teamclaws pair status <server-identifier-or-canonical-workspace-address> [--json]\n teamclaws pair [server-identifier-or-canonical-workspace-address] [--no-open] [--json]\n teamclaws chat list <target> [--json]\n teamclaws chat history <target> [--json]\n teamclaws chat messages <target> --chat-id <uuid> [--after-message-id <n>] [--json]\n teamclaws chat capabilities <target> [--json]\n teamclaws chat start <target> --message <text> [selection options] [--json]\n teamclaws chat send <target> --session-id <uuid> --message <text> [--json]\n teamclaws chat watch <target> --session-id <uuid> --request-id <uuid> [resume cursors] [--json]\n\nPair status performs one bounded direct verification and stops. Pairing grants the standard host-issued credential. Chat commands use that credential directly against the selected workspace.\n`;
|
|
556
571
|
}
|
package/dist/constants.js
CHANGED
package/dist/output.js
CHANGED
|
@@ -446,6 +446,17 @@ export class Output {
|
|
|
446
446
|
this.stdout.write(`${messages[result.code]}\n`);
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
+
usersRemoveResult(result) {
|
|
450
|
+
this.event({
|
|
451
|
+
schema_version: OUTPUT_SCHEMA_VERSION,
|
|
452
|
+
event: "users_remove_result",
|
|
453
|
+
...result,
|
|
454
|
+
});
|
|
455
|
+
if (!this.json)
|
|
456
|
+
this.stdout.write(result.code === "removed"
|
|
457
|
+
? "User removed from the workspace access group.\n"
|
|
458
|
+
: "Pending invitation revoked.\n");
|
|
459
|
+
}
|
|
449
460
|
usersListResult(result) {
|
|
450
461
|
this.event({
|
|
451
462
|
schema_version: OUTPUT_SCHEMA_VERSION,
|
package/dist/users.js
CHANGED
|
@@ -165,3 +165,59 @@ export async function runUsersAdd(store, fetcher, target, email, role, sudoEnabl
|
|
|
165
165
|
: {}),
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
+
export async function runUsersRemove(store, fetcher, target, email, authorization, signal) {
|
|
169
|
+
const credential = await store.findWorkspace(target);
|
|
170
|
+
if (!credential)
|
|
171
|
+
throw new TeamClawsError("re_pair_required", "No saved pairing was found for this workspace. Pair it first.", { exitCode: 3 });
|
|
172
|
+
const messages = {
|
|
173
|
+
...failureMessages,
|
|
174
|
+
owner_required: "Only the current machine owner can remove users.",
|
|
175
|
+
forbidden: "The paired identity is not authorized to remove users.",
|
|
176
|
+
mfa_required: "The owner must meet the existing MFA policy before removing users.",
|
|
177
|
+
target_proof_expired: "The request proof expired before user removal.",
|
|
178
|
+
owner_removal_forbidden: "The machine owner cannot be removed.",
|
|
179
|
+
member_not_removable: "The access-group owner cannot be removed.",
|
|
180
|
+
membership_not_found: "No matching membership or pending invitation was found.",
|
|
181
|
+
access_group_missing: "This machine has no access group to remove users from.",
|
|
182
|
+
invalid_request: "The workspace rejected the remove-user request.",
|
|
183
|
+
outcome_unverified: "The removal outcome could not be verified. Check user and invitation status before retrying.",
|
|
184
|
+
};
|
|
185
|
+
let response;
|
|
186
|
+
try {
|
|
187
|
+
response = await requestTargetJson(fetcher, authorization, `${credential.origin}/teamclaws-admin/api/device-users/v1/remove/`, credential, { method: "POST", body: { email }, ...(signal ? { signal } : {}) });
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
if (error instanceof TeamClawsError &&
|
|
191
|
+
["network_error", "network_timeout"].includes(error.code))
|
|
192
|
+
throw new TeamClawsError("outcome_unverified", messages.outcome_unverified);
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
const body = response.body;
|
|
196
|
+
if (response.status !== 200 || (isObject(body) && body.ok === false)) {
|
|
197
|
+
const rawCode = isObject(body)
|
|
198
|
+
? (body.code ?? (isObject(body.error) ? body.error.code : body.error))
|
|
199
|
+
: undefined;
|
|
200
|
+
const code = typeof rawCode === "string" && Object.hasOwn(messages, rawCode)
|
|
201
|
+
? rawCode
|
|
202
|
+
: [404, 405].includes(response.status)
|
|
203
|
+
? "users_remove_unavailable"
|
|
204
|
+
: "outcome_unverified";
|
|
205
|
+
throw new TeamClawsError(code, messages[code] ?? "Direct user removal is unavailable on this workspace.", {
|
|
206
|
+
exitCode: response.status === 401 ? 3 : response.status === 429 ? 5 : 1,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (!isObject(body) ||
|
|
210
|
+
body.ok !== true ||
|
|
211
|
+
body.action !== "remove" ||
|
|
212
|
+
body.scope !== "access_group" ||
|
|
213
|
+
body.email !== email ||
|
|
214
|
+
!["removed", "revoked"].includes(String(body.code)))
|
|
215
|
+
throw new TeamClawsError("invalid_response", "The workspace returned an invalid remove-user result. Check user and invitation status before retrying.", { exitCode: 9 });
|
|
216
|
+
return {
|
|
217
|
+
ok: true,
|
|
218
|
+
code: body.code,
|
|
219
|
+
action: "remove",
|
|
220
|
+
scope: "access_group",
|
|
221
|
+
email,
|
|
222
|
+
};
|
|
223
|
+
}
|