@neta-art/cohub-cli 1.0.0 → 1.0.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
@@ -1,6 +1,6 @@
1
1
  # @neta-art/cohub-cli
2
2
 
3
- CLI for [Cohub](https://cohub.neta.art) — spaces, sessions, and agent collaboration.
3
+ CLI for [Cohub](https://cohub.run) — spaces, sessions, and agent collaboration.
4
4
 
5
5
  ## Installation
6
6
 
@@ -13,3 +13,26 @@ npm install -g @neta-art/cohub-cli
13
13
  ```bash
14
14
  cohub --help
15
15
  ```
16
+
17
+ ## Environment
18
+
19
+ The CLI connects to production by default:
20
+
21
+ - API: `https://api.cohub.run`
22
+ - WebSocket: `wss://gateway.cohub.run/ws`
23
+
24
+ Use the development environment with `ENV=dev`:
25
+
26
+ ```bash
27
+ ENV=dev cohub spaces ls
28
+ ```
29
+
30
+ Development uses:
31
+
32
+ - API: `https://api-dev.cohub.run`
33
+ - WebSocket: `wss://gateway-dev.cohub.run/ws`
34
+
35
+ Auth tokens are stored per environment:
36
+
37
+ - prod: `~/.config/cohub/token`
38
+ - dev: `~/.config/cohub/token.dev`
package/dist/auth.d.ts CHANGED
@@ -1,7 +1,10 @@
1
+ export declare const getTokenPath: () => string;
1
2
  /**
2
3
  * Resolve auth token with priority:
3
4
  * 1. COHUB_EXECUTION_TOKEN environment variable
4
- * 2. ~/.config/cohub/token file
5
+ * 2. current environment token file
6
+ * - prod: ~/.config/cohub/token
7
+ * - dev: ~/.config/cohub/token.dev
5
8
  */
6
9
  export declare function resolveToken(): string | null;
7
10
  export declare function saveToken(token: string): void;
package/dist/auth.js CHANGED
@@ -1,35 +1,43 @@
1
+ import { resolveCohubEnvironment } from "@neta-art/cohub";
1
2
  import { readFileSync, existsSync, mkdirSync, writeFileSync, rmSync } from "node:fs";
2
3
  import { homedir } from "node:os";
3
4
  import { join } from "node:path";
4
5
  const TOKEN_DIR = join(homedir(), ".config", "cohub");
5
- const TOKEN_PATH = join(TOKEN_DIR, "token");
6
+ export const getTokenPath = () => join(TOKEN_DIR, resolveCohubEnvironment() === "dev" ? "token.dev" : "token");
6
7
  /**
7
8
  * Resolve auth token with priority:
8
9
  * 1. COHUB_EXECUTION_TOKEN environment variable
9
- * 2. ~/.config/cohub/token file
10
+ * 2. current environment token file
11
+ * - prod: ~/.config/cohub/token
12
+ * - dev: ~/.config/cohub/token.dev
10
13
  */
11
14
  export function resolveToken() {
12
15
  if (process.env.COHUB_EXECUTION_TOKEN) {
13
16
  return process.env.COHUB_EXECUTION_TOKEN.trim();
14
17
  }
15
- if (existsSync(TOKEN_PATH)) {
16
- return readFileSync(TOKEN_PATH, "utf-8").trim();
18
+ const path = getTokenPath();
19
+ if (existsSync(path)) {
20
+ return readFileSync(path, "utf-8").trim();
17
21
  }
18
22
  return null;
19
23
  }
20
24
  export function saveToken(token) {
25
+ const trimmed = token.trim();
26
+ if (!trimmed)
27
+ throw new Error("Token cannot be empty");
21
28
  mkdirSync(TOKEN_DIR, { recursive: true });
22
- writeFileSync(TOKEN_PATH, token.trim());
29
+ writeFileSync(getTokenPath(), trimmed);
23
30
  }
24
31
  export function clearToken() {
25
- if (existsSync(TOKEN_PATH)) {
26
- rmSync(TOKEN_PATH);
32
+ const path = getTokenPath();
33
+ if (existsSync(path)) {
34
+ rmSync(path);
27
35
  }
28
36
  }
29
37
  export function tokenSource() {
30
38
  if (process.env.COHUB_EXECUTION_TOKEN)
31
39
  return "env";
32
- if (existsSync(TOKEN_PATH))
40
+ if (existsSync(getTokenPath()))
33
41
  return "file";
34
42
  return null;
35
43
  }
package/dist/client.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { CohubHttpClient } from "@neta-art/cohub/http";
2
- export declare function createClient(token: string, baseUrl?: string): CohubHttpClient;
1
+ import { CohubHttpClient } from "@neta-art/cohub";
2
+ export declare function createClient(token: string): CohubHttpClient;
package/dist/client.js CHANGED
@@ -1,7 +1,6 @@
1
- import { CohubHttpClient } from "@neta-art/cohub/http";
2
- export function createClient(token, baseUrl) {
1
+ import { CohubHttpClient } from "@neta-art/cohub";
2
+ export function createClient(token) {
3
3
  return new CohubHttpClient({
4
- baseUrl,
5
4
  getAccessToken: () => token,
6
5
  });
7
6
  }
@@ -1,14 +1,19 @@
1
- import { resolveToken, saveToken, clearToken, tokenSource } from "../auth.js";
1
+ import { resolveToken, saveToken, clearToken, tokenSource, getTokenPath } from "../auth.js";
2
2
  import { createClient } from "../client.js";
3
3
  import { table, json as outJson, ok, error, spinner, handleHttp } from "../output.js";
4
4
  export function registerAuth(program) {
5
5
  const auth = program.command("auth").description("Authentication management");
6
6
  auth
7
7
  .command("login <token>")
8
- .description("Set auth token")
8
+ .description("Set auth token for the current environment")
9
9
  .action((token) => {
10
- saveToken(token);
11
- ok("Token saved to ~/.config/cohub/token");
10
+ try {
11
+ saveToken(token);
12
+ ok(`Token saved to ${getTokenPath()}`);
13
+ }
14
+ catch (e) {
15
+ return error(e instanceof Error ? e.message : String(e));
16
+ }
12
17
  });
13
18
  auth
14
19
  .command("whoami")
@@ -381,15 +381,27 @@ function registerSessions(spacesCmd) {
381
381
  const client = createClient(token);
382
382
  const session = client.space(spaceId).session(id);
383
383
  process.stdout.write(" Listening for events...\n\n");
384
- session.on("turn.progress", (e) => {
384
+ let lastAppendPath = null;
385
+ session.on("turn.patch", (e) => {
385
386
  if (opts.json) {
386
387
  console.log(JSON.stringify(e));
387
388
  }
388
389
  else {
389
- const blocks = e.payload?.content;
390
- const text = blocks?.find((b) => b.type === "text")?.text;
391
- if (text)
392
- process.stdout.write(text);
390
+ const ops = e.payload?.ops;
391
+ for (const op of ops ?? []) {
392
+ if (op.o === "append" && typeof op.v === "string" && op.p?.endsWith("/text")) {
393
+ lastAppendPath = op.p;
394
+ process.stdout.write(op.v);
395
+ continue;
396
+ }
397
+ if (op.o === "append" && typeof op.p === "string") {
398
+ lastAppendPath = op.p;
399
+ continue;
400
+ }
401
+ if (!op.o && !op.p && typeof op.v === "string" && lastAppendPath?.endsWith("/text")) {
402
+ process.stdout.write(op.v);
403
+ }
404
+ }
393
405
  }
394
406
  });
395
407
  session.on("turn.final", () => {
@@ -399,7 +411,7 @@ function registerSessions(spacesCmd) {
399
411
  session.on("turn.error", (e) => {
400
412
  process.stderr.write(`\n ✗ Error\n`);
401
413
  if (opts.json)
402
- process.stderr.write(JSON.stringify(e) + "\n");
414
+ process.stderr.write(`${JSON.stringify(e)}\n`);
403
415
  process.exit(1);
404
416
  });
405
417
  });
package/dist/index.js CHANGED
@@ -24,7 +24,6 @@ program
24
24
  .description("CLI for Cohub — spaces, sessions, and agent collaboration.")
25
25
  .option("-s, --space <id>", "Target space ID")
26
26
  .option("--json", "Output as JSON")
27
- .option("--env <name>", "Cohub environment (default: production)", "production")
28
27
  .helpOption("-h, --help", "Show help");
29
28
  registerAuth(program);
30
29
  registerSpaces(program);
package/dist/output.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type Row = Record<string, unknown>;
1
+ export type Row = Record<string, unknown>;
2
2
  export declare function table(rows: Row[], columns: {
3
3
  key: string;
4
4
  label: string;
@@ -11,4 +11,3 @@ export declare function spinner(): {
11
11
  start(msg: string): void;
12
12
  stop(msg: string): void;
13
13
  };
14
- export {};
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
+ "license": "UNLICENSED",
6
7
  "bin": {
7
8
  "cohub": "./bin/cohub.js"
8
9
  },
@@ -13,7 +14,7 @@
13
14
  ],
14
15
  "dependencies": {
15
16
  "commander": "^13.1.0",
16
- "@neta-art/cohub": "1.1.0"
17
+ "@neta-art/cohub": "1.2.1"
17
18
  },
18
19
  "publishConfig": {
19
20
  "access": "public"