clawborrator-cli 0.0.5 → 0.0.7

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.
@@ -6868,12 +6868,23 @@ var GREEN = "\x1B[32m";
6868
6868
  function ts() {
6869
6869
  return (/* @__PURE__ */ new Date()).toLocaleTimeString();
6870
6870
  }
6871
- var sessionAttach = new Command("attach").description("open a TUI on a session \u2014 see the chat stream, post op-messages").argument("<sessionId>", "session UUID").action(async (sessionId) => {
6871
+ var sessionAttach = new Command("attach").description("open a TUI on a session \u2014 see the chat stream, post op-messages").argument("<ref>", "session UUID or @routingName (e.g. @driver)").action(async (ref) => {
6872
6872
  const cfg = loadConfig();
6873
6873
  if (!cfg.pat) {
6874
6874
  console.error("error: not logged in. run `claw login`.");
6875
6875
  process.exit(2);
6876
6876
  }
6877
+ let sessionId = ref;
6878
+ if (sessionId.startsWith("@")) {
6879
+ const wanted = sessionId.slice(1);
6880
+ const data = await api.get("/api/v1/sessions");
6881
+ const match = data.items.find((s) => s.routingName === wanted);
6882
+ if (!match) {
6883
+ console.error(`error: no session with routing name @${wanted} (run \`claw session list\` to see what's available)`);
6884
+ process.exit(2);
6885
+ }
6886
+ sessionId = match.id;
6887
+ }
6877
6888
  const wsUrl = cfg.hubUrl.replace(/^http/i, "ws") + "/cli";
6878
6889
  const ws = new wrapper_default(wsUrl, {
6879
6890
  headers: { Authorization: `Bearer ${cfg.pat}` }
@@ -7208,7 +7219,7 @@ var sessionInit = new Command("init").description("install clawborrator hooks in
7208
7219
  if (alreadyPresent > 0) console.log(` (${alreadyPresent} already up-to-date, untouched)`);
7209
7220
  console.log("");
7210
7221
  console.log("next: drop a .mcp.json with your channel token (`claw token mint --kind=channel");
7211
- console.log(" --name=<label> --mcp-snippet > .mcp.json`), then start CC with:");
7222
+ console.log(" --name=<label> --mcp-snippet --out=.mcp.json`), then start CC with:");
7212
7223
  console.log(" claude --dangerously-load-development-channels server:clawborrator");
7213
7224
  console.log(" events will flow as you prompt; watch via `claw session attach <id>`.");
7214
7225
  });
@@ -7267,6 +7278,18 @@ function fmtDuration(ms) {
7267
7278
  function fmtAgo(iso) {
7268
7279
  return fmtDuration(Date.now() - new Date(iso).getTime());
7269
7280
  }
7281
+ async function resolveSessionId(idOrName) {
7282
+ if (!idOrName.startsWith("@")) return idOrName;
7283
+ const wanted = idOrName.slice(1);
7284
+ const data = await api.get("/api/v1/sessions");
7285
+ const match = data.items.find((s) => s.routingName === wanted);
7286
+ if (!match) {
7287
+ const err = new Error(`no session with routing name @${wanted} (run \`claw session list\` to see what's available)`);
7288
+ err.code = "CLW_NO_ROUTING_MATCH";
7289
+ throw err;
7290
+ }
7291
+ return match.id;
7292
+ }
7270
7293
  var sessionList = new Command("list").alias("ls").description("list sessions you can see").option("--connected", "only sessions whose channel WS is currently open").option("--all", "include archived sessions").action(async (opts) => {
7271
7294
  const qs = new URLSearchParams();
7272
7295
  if (opts.connected) qs.set("connected", "true");
@@ -7286,9 +7309,15 @@ var sessionList = new Command("list").alias("ls").description("list sessions you
7286
7309
  const seen = s.connected ? "online" : `offline \xB7 ${fmtAgo(s.lastSeenAt)}`;
7287
7310
  const arch = s.archivedAt ? " \xB7 ARCHIVED" : "";
7288
7311
  console.log(`${dot} ${route.padEnd(20)} ${role} @${s.startedByLogin}${where} [${seen}]${arch}`);
7312
+ console.log(` id: ${s.id}`);
7289
7313
  }
7314
+ console.log("");
7315
+ console.log(" use: claw session attach @<routing> OR claw session attach <id>");
7316
+ console.log(" claw session events <ref> \u2014 recent hook/chat events");
7317
+ console.log(" claw session messages <ref> \u2014 operator-to-operator chat");
7290
7318
  });
7291
- var sessionInfo = new Command("info").description("show metadata for a single session").argument("<id>", "session UUID").action(async (id) => {
7319
+ var sessionInfo = new Command("info").description("show metadata for a single session").argument("<ref>", "session UUID or @routingName").action(async (ref) => {
7320
+ const id = await resolveSessionId(ref);
7292
7321
  const s = await api.get(`/api/v1/sessions/${encodeURIComponent(id)}`);
7293
7322
  console.log(`session : ${s.id}`);
7294
7323
  console.log(`routing : ${s.routingName ?? "(none)"}`);
@@ -7301,11 +7330,12 @@ var sessionInfo = new Command("info").description("show metadata for a single se
7301
7330
  console.log(`last seen: ${s.lastSeenAt}`);
7302
7331
  console.log(`status : ${s.connected ? "connected" : "offline"}${s.archivedAt ? " \xB7 ARCHIVED" : ""}`);
7303
7332
  });
7304
- var sessionEvents = new Command("events").description("dump recent events for a session (history; non-TUI)").argument("<id>", "session UUID").option("--limit <n>", "max events to return (default 200, max 1000)", "200").option("--after <id>", "forward pagination: events with id > given").option("--before <id>", "backward pagination: events with id < given").option("--kind <k>", "filter to chat or tail").option("--type <t>", "filter by type (e.g. PreToolUse, reply)").option("--json", "emit one JSON object per line instead of human-readable").action(async (id, opts) => {
7333
+ var sessionEvents = new Command("events").description("dump recent events for a session (history; non-TUI)").argument("<ref>", "session UUID or @routingName").option("--limit <n>", "max events to return (default 200, max 1000)", "200").option("--after <id>", "forward pagination: events with id > given").option("--before <id>", "backward pagination: events with id < given").option("--kind <k>", "filter to chat or tail").option("--type <t>", "filter by type (e.g. PreToolUse, reply)").option("--json", "emit one JSON object per line instead of human-readable").action(async (ref, opts) => {
7305
7334
  if (opts.after && opts.before) {
7306
7335
  console.error("error: use --after OR --before, not both");
7307
7336
  process.exit(2);
7308
7337
  }
7338
+ const id = await resolveSessionId(ref);
7309
7339
  const qs = new URLSearchParams({ limit: opts.limit ?? "200" });
7310
7340
  if (opts.after) qs.set("after", opts.after);
7311
7341
  if (opts.before) qs.set("before", opts.before);
@@ -7332,11 +7362,12 @@ var sessionEvents = new Command("events").description("dump recent events for a
7332
7362
  console.log(`(more \u2014 older: --before ${data.firstId} \xB7 newer: --after ${data.lastId})`);
7333
7363
  }
7334
7364
  });
7335
- var sessionMessages = new Command("messages").alias("msgs").description("dump operator-to-operator chat for a session (op-messages history)").argument("<id>", "session UUID").option("--limit <n>", "max messages to return (default 100, max 500)", "100").option("--after <id>", "forward pagination").option("--before <id>", "backward pagination").option("--json", "emit one JSON object per line").action(async (id, opts) => {
7365
+ var sessionMessages = new Command("messages").alias("msgs").description("dump operator-to-operator chat for a session (op-messages history)").argument("<ref>", "session UUID or @routingName").option("--limit <n>", "max messages to return (default 100, max 500)", "100").option("--after <id>", "forward pagination").option("--before <id>", "backward pagination").option("--json", "emit one JSON object per line").action(async (ref, opts) => {
7336
7366
  if (opts.after && opts.before) {
7337
7367
  console.error("error: use --after OR --before, not both");
7338
7368
  process.exit(2);
7339
7369
  }
7370
+ const id = await resolveSessionId(ref);
7340
7371
  const qs = new URLSearchParams({ limit: opts.limit ?? "100" });
7341
7372
  if (opts.after) qs.set("after", opts.after);
7342
7373
  if (opts.before) qs.set("before", opts.before);
@@ -7362,6 +7393,10 @@ var sessionMessages = new Command("messages").alias("msgs").description("dump op
7362
7393
  });
7363
7394
  var sessionCmd = new Command("session").description("manage Claude Code sessions registered with this hub").addCommand(sessionList).addCommand(sessionInfo).addCommand(sessionAttach).addCommand(sessionInit).addCommand(sessionEvents).addCommand(sessionMessages);
7364
7395
 
7396
+ // src/commands/token.ts
7397
+ var import_node_fs3 = require("node:fs");
7398
+ var import_node_path3 = require("node:path");
7399
+
7365
7400
  // ../shared/dist/scopes.js
7366
7401
  var ALL_SCOPES = [
7367
7402
  "me:read",
@@ -7393,17 +7428,18 @@ var CLI_DEFAULT_SCOPES = [
7393
7428
  ];
7394
7429
 
7395
7430
  // src/commands/token.ts
7396
- var tokenMint = new Command("mint").description("create a new token").requiredOption("--kind <kind>", "channel | pat").requiredOption("--name <name>", 'human-readable label (e.g. "alice-laptop")').option("--scopes <csv>", "comma-separated scopes (PAT only); default = sensible CLI set").option("--app <name>", "pin the PAT to a specific app (display only)").option("--mcp-snippet", "after minting a channel token, print ONLY the .mcp.json block to stdout (prose to stderr) so you can pipe it: `... --mcp-snippet > .mcp.json`").action(async (opts) => {
7431
+ var tokenMint = new Command("mint").description("create a new token").requiredOption("--kind <kind>", "channel | pat").requiredOption("--name <name>", 'human-readable label (e.g. "alice-laptop")').option("--scopes <csv>", "comma-separated scopes (PAT only); default = sensible CLI set").option("--app <name>", "pin the PAT to a specific app (display only)").option("--mcp-snippet", "after minting a channel token, also produce a ready-to-use .mcp.json block. By default writes to stdout (prose to stderr); pair with --out=<path> to write the file directly (recommended on Windows \u2014 `>` redirection in PowerShell encodes as UTF-16 w/ BOM, which CC rejects).").option("--out <path>", "when used with --mcp-snippet, write the JSON to <path> (UTF-8, no BOM) instead of stdout. Pass `.mcp.json` for the canonical project location.").action(async (opts) => {
7397
7432
  if (opts.kind === "channel") {
7398
7433
  const out = await api.post("/api/v1/tokens/channel", { name: opts.name });
7399
- const prose = opts.mcpSnippet ? console.error : console.log;
7434
+ const proseToStderr = opts.mcpSnippet && !opts.out;
7435
+ const prose = proseToStderr ? console.error : console.log;
7400
7436
  prose(`\u2713 channel token minted: ${out.name}`);
7401
7437
  prose(` ${out.token}`);
7402
7438
  prose(" (shown ONCE \u2014 store it now)");
7403
7439
  if (opts.mcpSnippet) {
7404
7440
  const cfg = loadConfig();
7405
7441
  const wsUrl = cfg.hubUrl.replace(/^http(s?):\/\//, "ws$1://");
7406
- process.stdout.write(JSON.stringify({
7442
+ const json = JSON.stringify({
7407
7443
  mcpServers: {
7408
7444
  clawborrator: {
7409
7445
  command: "npx",
@@ -7414,7 +7450,15 @@ var tokenMint = new Command("mint").description("create a new token").requiredOp
7414
7450
  }
7415
7451
  }
7416
7452
  }
7417
- }, null, 2) + "\n");
7453
+ }, null, 2) + "\n";
7454
+ if (opts.out) {
7455
+ const target = (0, import_node_path3.resolve)(opts.out);
7456
+ (0, import_node_fs3.writeFileSync)(target, json, "utf8");
7457
+ prose("");
7458
+ prose(`\u2713 wrote ${target}`);
7459
+ } else {
7460
+ process.stdout.write(json);
7461
+ }
7418
7462
  prose("");
7419
7463
  prose(" next: launch CC with the clawborrator channel enabled \u2014");
7420
7464
  prose(" claude --dangerously-load-development-channels server:clawborrator");
@@ -7555,7 +7599,7 @@ var webhookCmd = new Command("webhook").description("manage webhook subscription
7555
7599
 
7556
7600
  // src/index.ts
7557
7601
  var program2 = new Command();
7558
- program2.name("claw").description("clawborrator CLI \u2014 control your Claude Code sessions from the terminal").version("0.0.5");
7602
+ program2.name("claw").description("clawborrator CLI \u2014 control your Claude Code sessions from the terminal").version("0.0.7");
7559
7603
  program2.addCommand(loginCmd);
7560
7604
  program2.addCommand(logoutCmd);
7561
7605
  program2.addCommand(whoamiCmd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawborrator-cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "description": "claw — command-line client for clawborrator hub_v1. Manages PATs, channel tokens, sessions, cross-session routing, and webhooks; ships an inline TUI for live multi-operator session attach.",
6
6
  "license": "MIT",