teamclaws 2.0.14 → 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 CHANGED
@@ -209,6 +209,7 @@ 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
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>
@@ -281,6 +282,20 @@ requires the workspace to acknowledge the saved sudo selection before reporting
281
282
  a new sudo invitation as successful. Existing members and pending invitations
282
283
  remain unchanged even when the flag is supplied.
283
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
+
284
299
  ### Inspect users and invitation status
285
300
 
286
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,6 +261,13 @@ 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();
@@ -548,5 +567,5 @@ function usageError() {
548
567
  });
549
568
  }
550
569
  export function helpText() {
551
- 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 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`;
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`;
552
571
  }
package/dist/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const PACKAGE_NAME = "teamclaws";
2
- export const PACKAGE_VERSION = "2.0.13";
2
+ export const PACKAGE_VERSION = "2.0.15";
3
3
  export const CLIENT_NAME = "teamclaws-cli";
4
4
  export const CONTRACT_VERSION = 1;
5
5
  export const OUTPUT_SCHEMA_VERSION = 1;
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamclaws",
3
- "version": "2.0.14",
3
+ "version": "2.0.15",
4
4
  "description": "Official TeamClaws command-line client and agent skills",
5
5
  "license": "PolyForm-Shield-1.0.0",
6
6
  "homepage": "https://teamclaws.com",