@neta-art/cohub-cli 10.23.0 → 10.24.0

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
@@ -256,10 +256,16 @@ cohub -s <spaceId> spaces sessions create "<title>" --json
256
256
  cohub -s <spaceId> spaces sessions get <sessionId> --json
257
257
  cohub -s <spaceId> spaces sessions files <sessionId> --json
258
258
  cohub -s <spaceId> spaces sessions rename <sessionId> "<new title>"
259
+ cohub -s <spaceId> spaces sessions archive <sessionId...>
260
+ cohub -s <spaceId> spaces sessions unarchive <sessionId...>
261
+ cohub -s <spaceId> spaces sessions ls --archived # --all includes archived Chats
259
262
  ```
260
263
 
261
264
  Use `spaces prompt --session <sessionId>` to send to a Chat.
262
265
 
266
+ Archiving hides a Chat for every member and frees its runtime files after a
267
+ short grace period. Sending a message to an archived Chat restores it.
268
+
263
269
  ## Space turns
264
270
 
265
271
  List recent turns across all visible Sessions in a Space:
@@ -300,15 +306,22 @@ cohub -s <spaceId> spaces activity 365 --json
300
306
 
301
307
  ```bash
302
308
  cohub -s <spaceId> spaces wallet balance
303
- cohub -s <spaceId> spaces wallet catalog
304
- cohub -s <spaceId> spaces wallet recharge <productKey> --request-id <uuid>
309
+ cohub -s <spaceId> spaces wallet funding
310
+ cohub -s <spaceId> spaces wallet transfer 50
311
+ cohub -s <spaceId> spaces wallet transfer-status <requestId>
312
+ cohub -s <spaceId> spaces wallet recharge <productKey>
305
313
  cohub -s <spaceId> spaces wallet confirm <orderId>
314
+ cohub -s <spaceId> spaces wallet public-funding on
306
315
  cohub -s <spaceId> spaces wallet activity --page 1 --json
307
316
  ```
308
317
 
309
- Recharge prints a payment URL. Reuse the request UUID when retrying the same
310
- recharge. Any signed-in user with access to the Space may contribute; payment
311
- does not grant additional permissions. Transfers and withdrawals are not supported.
318
+ `transfer` moves purchased personal balance (whole USD) into the wallet;
319
+ `recharge` prints a payment URL for a funding tier. Request IDs are generated
320
+ automatically; when a result is uncertain the CLI prints a retry command with
321
+ `--request-id` that continues the same transfer or order. Viewers of the Space
322
+ can always fund it; with public funding on, anyone signed in can. Funding does
323
+ not grant access, and wallet funds cannot be withdrawn. Transfers require a
324
+ personal session, not an agent execution token.
312
325
 
313
326
  ## Boards
314
327
 
package/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"commit":"a26ba39"}
1
+ {"commit":"d44f824"}
@@ -1,6 +1,6 @@
1
1
  import { createClient } from "../client.js";
2
2
  import { formatLocalDateTime, handleHttp, json as outJson, jsonRequested, table } from "../output.js";
3
- import { SESSION_STATUS_COLUMN } from "../session-status.js";
3
+ import { SESSION_STATUS_COLUMN, sessionArchiveFilter } from "../session-status.js";
4
4
  function parseInteger(value, name, min) {
5
5
  const parsed = Number.parseInt(value, 10);
6
6
  if (!Number.isSafeInteger(parsed) || parsed < min) {
@@ -14,9 +14,11 @@ export function registerMe(program) {
14
14
  meCmd
15
15
  .command("sessions")
16
16
  .alias("list-sessions")
17
- .description("List sessions you created across all spaces")
17
+ .description("List sessions you created across all spaces (archived sessions are hidden by default)")
18
18
  .option("--limit <n>", "Maximum number of sessions (default 20)")
19
19
  .option("--cursor <cursor>", "Pagination cursor from a previous result")
20
+ .option("--archived", "List only archived sessions")
21
+ .option("--all", "Include archived sessions")
20
22
  .option("--json", "Output as JSON")
21
23
  .action(async (opts) => {
22
24
  const client = createClient();
@@ -24,6 +26,7 @@ export function registerMe(program) {
24
26
  const result = await client.user.listSessions({
25
27
  limit: opts.limit ? parseInteger(opts.limit, "limit", 1) : undefined,
26
28
  cursor: opts.cursor ?? null,
29
+ archived: sessionArchiveFilter(opts),
27
30
  });
28
31
  if (jsonRequested(opts))
29
32
  return outJson(result);
@@ -1,11 +1,21 @@
1
+ import { randomUUID } from "node:crypto";
1
2
  import { createClient } from "../client.js";
2
- import { handleHttp, json as outJson, jsonRequested, table } from "../output.js";
3
+ import { handleHttp, json as outJson, jsonRequested, ok, table, warn } from "../output.js";
3
4
  import { resolveSpace } from "../space.js";
5
+ const usd = (value) => `$${value.toFixed(2)}`;
6
+ const uncertain = (cause) => {
7
+ const status = cause.status;
8
+ return !status || status >= 500;
9
+ };
10
+ function retryHint(command, requestId) {
11
+ warn(`Result unknown. Retry with: ${command} --request-id ${requestId}`);
12
+ }
4
13
  export function registerSpaceWallet(spaces) {
5
- const wallet = spaces.command("wallet").description("Space wallet balance, recharge, and activity");
14
+ const wallet = spaces.command("wallet").description("Space wallet balance, funding, and activity");
15
+ const space = async () => createClient().space(await resolveSpace(spaces)).wallet;
6
16
  wallet.command("balance").option("--json", "Output as JSON").action(async (opts) => {
7
17
  try {
8
- const value = await createClient().space(await resolveSpace(spaces)).wallet.get();
18
+ const value = await (await space()).get();
9
19
  if (jsonRequested(opts))
10
20
  return outJson(value);
11
21
  table([{ balance: `$${value.balanceUsd.toFixed(8)}`, usable: value.usable }], [{ key: "balance", label: "Balance" }, { key: "usable", label: "Usable" }]);
@@ -14,12 +24,26 @@ export function registerSpaceWallet(spaces) {
14
24
  handleHttp(cause);
15
25
  }
16
26
  });
17
- wallet.command("catalog").option("--json", "Output as JSON").action(async (opts) => {
27
+ wallet.command("funding").description("Funding tiers and your transferable balance").option("--json", "Output as JSON").action(async (opts) => {
18
28
  try {
19
- const value = await createClient().space(await resolveSpace(spaces)).wallet.catalog();
29
+ const value = await (await space()).funding();
20
30
  if (jsonRequested(opts))
21
31
  return outJson(value);
22
- table(value.products.map((product) => ({ key: product.key, name: product.name, price: product.pricing.amountUsd })), [{ key: "key", label: "Product" }, { key: "name", label: "Name" }, { key: "price", label: "Price (USD)" }]);
32
+ table(value.tiers.map((tier) => ({ product: tier.productKey, amount: usd(tier.amountUsd), price: usd(tier.priceUsd) })), [{ key: "product", label: "Product" }, { key: "amount", label: "Credits" }, { key: "price", label: "Price" }]);
33
+ console.log(`Public funding: ${value.publicFunding ? "on" : "off"}`);
34
+ if (value.transfer)
35
+ console.log(`Transferable balance: ${usd(value.transfer.allowanceUsd)} (whole dollars, ${usd(value.transfer.minUsd)}–${usd(value.transfer.maxUsd)})`);
36
+ }
37
+ catch (cause) {
38
+ handleHttp(cause);
39
+ }
40
+ });
41
+ wallet.command("public-funding <state>").description("Let anyone signed in fund this wallet (on|off)").action(async (state) => {
42
+ try {
43
+ if (state !== "on" && state !== "off")
44
+ throw new Error("State must be on or off");
45
+ await createClient().space(await resolveSpace(spaces)).profile({ fundingEnabled: state === "on" });
46
+ ok(`Public funding ${state}`);
23
47
  }
24
48
  catch (cause) {
25
49
  handleHttp(cause);
@@ -30,7 +54,7 @@ export function registerSpaceWallet(spaces) {
30
54
  const page = Number(opts.page);
31
55
  if (!Number.isInteger(page) || page < 1 || page > 10_000)
32
56
  throw new Error("Page must be an integer between 1 and 10000");
33
- const value = await createClient().space(await resolveSpace(spaces)).wallet.activities(page);
57
+ const value = await (await space()).activities(page);
34
58
  if (jsonRequested(opts))
35
59
  return outJson(value);
36
60
  table(value.items, [{ key: "title", label: "Activity" }, { key: "amountUsd", label: "Amount (USD)" }, { key: "actorUserId", label: "User" }, { key: "createdAt", label: "Date" }]);
@@ -39,23 +63,76 @@ export function registerSpaceWallet(spaces) {
39
63
  handleHttp(cause);
40
64
  }
41
65
  });
42
- wallet.command("recharge <product>").requiredOption("--request-id <uuid>", "Stable UUID; reuse when retrying this recharge").option("--json", "Output as JSON").action(async (productKey, opts) => {
66
+ wallet.command("transfer <amount>").description("Move purchased personal balance into the wallet (whole USD)").option("--request-id <uuid>", "Continue an earlier uncertain transfer").option("--json", "Output as JSON").action(async (amount, opts) => {
67
+ const id = opts.requestId ?? randomUUID();
68
+ let sent = false;
43
69
  try {
44
- const value = await createClient().space(await resolveSpace(spaces)).wallet.createOrder({ id: opts.requestId, productKey });
70
+ const amountUsd = Number(amount);
71
+ if (!Number.isInteger(amountUsd) || amountUsd < 1)
72
+ throw new Error("Amount must be a whole number of USD");
73
+ const api = await space();
74
+ sent = true;
75
+ const value = await api.transfer({ id, amountUsd });
76
+ if (jsonRequested(opts))
77
+ return outJson(value);
78
+ if (value.state === "completed")
79
+ ok(`Added ${usd(value.creditedUsd)} to the Space wallet`);
80
+ else if (value.state === "refunded")
81
+ warn(`Returned ${usd(value.refundedUsd)} to your balance`);
82
+ else
83
+ console.log(`Processing. Check with: cohub spaces wallet transfer-status ${id}`);
84
+ }
85
+ catch (cause) {
86
+ if (sent && uncertain(cause))
87
+ retryHint(`cohub spaces wallet transfer ${amount}`, id);
88
+ handleHttp(cause);
89
+ }
90
+ });
91
+ wallet.command("transfer-status <id>").option("--json", "Output as JSON").action(async (id, opts) => {
92
+ try {
93
+ const value = await (await space()).getTransfer(id);
94
+ if (jsonRequested(opts))
95
+ return outJson(value);
96
+ table([{ state: value.state, amount: usd(value.amountUsd), credited: usd(value.creditedUsd), refunded: usd(value.refundedUsd) }], [{ key: "state", label: "State" }, { key: "amount", label: "Amount" }, { key: "credited", label: "Credited" }, { key: "refunded", label: "Refunded" }]);
97
+ }
98
+ catch (cause) {
99
+ handleHttp(cause);
100
+ }
101
+ });
102
+ wallet.command("recharge <product>").description("Open checkout for a funding tier").option("--request-id <uuid>", "Continue an earlier uncertain checkout").option("--json", "Output as JSON").action(async (productKey, opts) => {
103
+ const id = opts.requestId ?? randomUUID();
104
+ let sent = false;
105
+ try {
106
+ const api = await space();
107
+ sent = true;
108
+ const value = await api.createOrder({ id, productKey });
45
109
  if (jsonRequested(opts))
46
110
  return outJson(value);
47
111
  if (!value.checkout.checkoutUsable || !value.checkout.checkoutUrl)
48
112
  throw new Error(value.checkout.message ?? "Checkout is unavailable");
49
113
  console.log(value.checkout.checkoutUrl);
50
- console.log(`Order: ${value.orderId}`);
114
+ console.log(`After paying: cohub spaces wallet confirm ${value.orderId}`);
51
115
  }
52
116
  catch (cause) {
117
+ if (sent && uncertain(cause))
118
+ retryHint(`cohub spaces wallet recharge ${productKey}`, id);
53
119
  handleHttp(cause);
54
120
  }
55
121
  });
56
122
  wallet.command("confirm <order>").action(async (orderId) => {
57
123
  try {
58
- outJson(await createClient().space(await resolveSpace(spaces)).wallet.confirmOrder(orderId));
124
+ outJson(await (await space()).confirmOrder(orderId));
125
+ }
126
+ catch (cause) {
127
+ handleHttp(cause);
128
+ }
129
+ });
130
+ wallet.command("catalog").option("--json", "Output as JSON").action(async (opts) => {
131
+ try {
132
+ const value = await (await space()).catalog();
133
+ if (jsonRequested(opts))
134
+ return outJson(value);
135
+ table(value.products.map((product) => ({ key: product.key, name: product.name, price: product.pricing.amountUsd })), [{ key: "key", label: "Product" }, { key: "name", label: "Name" }, { key: "price", label: "Price (USD)" }]);
59
136
  }
60
137
  catch (cause) {
61
138
  handleHttp(cause);
@@ -5,7 +5,7 @@ import { uploadAvatarAsset, uploadChatImageAsset, uploadLikeStickerAsset } from
5
5
  import { createClient } from "../client.js";
6
6
  import { collectOption, readPromptContent } from "../command-input.js";
7
7
  import { table, json as outJson, jsonRequested, ok, error, handleHttp, formatEpochMs, truncateText } from "../output.js";
8
- import { SESSION_STATUS_COLUMN } from "../session-status.js";
8
+ import { SESSION_STATUS_COLUMN, sessionArchiveFilter } from "../session-status.js";
9
9
  import { resolveSpace } from "../space.js";
10
10
  import { uploadLocalFiles } from "../space-files/upload.js";
11
11
  import { registerDecisionCommand } from "./decision.js";
@@ -1419,13 +1419,15 @@ function registerSessions(spacesCmd) {
1419
1419
  sessionsCmd
1420
1420
  .command("ls")
1421
1421
  .alias("list")
1422
- .description("List sessions")
1422
+ .description("List sessions (archived sessions are hidden by default)")
1423
+ .option("--archived", "List only archived sessions")
1424
+ .option("--all", "Include archived sessions")
1423
1425
  .option("--json", "Output as JSON")
1424
1426
  .action(async (opts) => {
1425
1427
  const spaceId = await resolveSpace(spacesCmd);
1426
1428
  const client = createClient();
1427
1429
  try {
1428
- const result = await client.space(spaceId).sessions.list();
1430
+ const result = await client.space(spaceId).sessions.list({ archived: sessionArchiveFilter(opts) });
1429
1431
  if (jsonRequested(opts))
1430
1432
  return outJson(result);
1431
1433
  if (result.sessions.length === 0) {
@@ -1576,6 +1578,35 @@ function registerSessions(spacesCmd) {
1576
1578
  handleHttp(e);
1577
1579
  }
1578
1580
  });
1581
+ for (const archived of [true, false]) {
1582
+ const verb = archived ? "archive" : "unarchive";
1583
+ const done = archived ? "archived" : "restored";
1584
+ sessionsCmd
1585
+ .command(`${verb} <ids...>`)
1586
+ .description(archived
1587
+ ? "Archive sessions for every member; a new message restores them"
1588
+ : "Restore archived sessions to the active list")
1589
+ .option("--json", "Output as JSON")
1590
+ .action(async (ids, opts) => {
1591
+ const spaceId = await resolveSpace(spacesCmd);
1592
+ const client = createClient();
1593
+ const sessions = [];
1594
+ for (const id of ids) {
1595
+ try {
1596
+ const session = client.space(spaceId).session(id.trim());
1597
+ sessions.push((await (archived ? session.archive() : session.unarchive())).session);
1598
+ }
1599
+ catch (e) {
1600
+ if (sessions.length > 0)
1601
+ process.stderr.write(`\n ${sessions.length} of ${ids.length} sessions ${done} before ${id}\n`);
1602
+ handleHttp(e);
1603
+ }
1604
+ }
1605
+ if (jsonRequested(opts))
1606
+ return outJson({ sessions });
1607
+ ok(ids.length === 1 ? `Session ${done}` : `${ids.length} sessions ${done}`);
1608
+ });
1609
+ }
1579
1610
  // ── sessions tail ──
1580
1611
  sessionsCmd
1581
1612
  .command("tail <id>")
@@ -1,6 +1,10 @@
1
- import type { SessionRecord } from "@neta-art/cohub";
1
+ import type { SessionArchiveFilter, SessionRecord } from "@neta-art/cohub";
2
2
  import type { Column } from "./output.js";
3
- type SessionStatusFields = Pick<SessionRecord, "activeTurn" | "lastTurnIssue">;
3
+ type SessionStatusFields = Pick<SessionRecord, "activeTurn" | "lastTurnIssue" | "archivedAt">;
4
4
  export declare function sessionStatusText(session: Partial<SessionStatusFields>): string;
5
5
  export declare const SESSION_STATUS_COLUMN: Column;
6
+ export declare function sessionArchiveFilter(opts: {
7
+ archived?: boolean;
8
+ all?: boolean;
9
+ }): SessionArchiveFilter | undefined;
6
10
  export {};
@@ -2,6 +2,8 @@ export function sessionStatusText(session) {
2
2
  const turn = session.activeTurn;
3
3
  if (turn)
4
4
  return turn.status === "abort_requested" ? "stopping" : turn.status;
5
+ if (session.archivedAt)
6
+ return "archived";
5
7
  const issue = session.lastTurnIssue;
6
8
  if (issue?.status === "failed")
7
9
  return "failed";
@@ -14,3 +16,10 @@ export const SESSION_STATUS_COLUMN = {
14
16
  label: "Status",
15
17
  format: (_value, row) => sessionStatusText(row),
16
18
  };
19
+ export function sessionArchiveFilter(opts) {
20
+ if (opts.archived && opts.all) {
21
+ process.stderr.write("\n ✗ Use either --archived or --all\n\n");
22
+ process.exit(1);
23
+ }
24
+ return opts.archived ? "only" : opts.all ? "include" : undefined;
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "10.23.0",
3
+ "version": "10.24.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -24,7 +24,7 @@
24
24
  "NOTICE"
25
25
  ],
26
26
  "dependencies": {
27
- "@neta-art/cohub": "13.14.0",
27
+ "@neta-art/cohub": "13.15.0",
28
28
  "@neta-art/generation": "0.2.15",
29
29
  "commander": "^15.0.0",
30
30
  "sharp": "^0.35.4",