@gobi-ai/cli 0.3.3 → 0.3.4

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.
@@ -47,15 +47,33 @@ export function registerBrainCommand(program) {
47
47
  .description("Ask a brain a question. Creates a targeted session (1:1 conversation).")
48
48
  .requiredOption("--vault-slug <vaultSlug>", "Slug of the brain/vault to ask")
49
49
  .requiredOption("--space-slug <spaceSlug>", "Space slug where the brain belongs")
50
- .requiredOption("--question <question>", "The question to ask (markdown supported)")
50
+ .option("--question <question>", "The question to ask (markdown supported)")
51
+ .option("--rich-text <richText>", "Rich-text JSON array (e.g. [{\"type\":\"text\",\"text\":\"hello\"}])")
51
52
  .option("--mode <mode>", 'Session mode: "auto" or "manual"')
52
53
  .action(async (opts) => {
54
+ if (!opts.question && !opts.richText) {
55
+ throw new Error("Provide either --question or --rich-text.");
56
+ }
57
+ if (opts.question && opts.richText) {
58
+ throw new Error("--question and --rich-text are mutually exclusive.");
59
+ }
53
60
  const spaceSlug = opts.spaceSlug;
54
61
  const body = {
55
62
  vaultSlug: opts.vaultSlug,
56
63
  spaceSlug,
57
- question: opts.question,
58
64
  };
65
+ if (opts.question != null)
66
+ body.question = opts.question;
67
+ if (opts.richText != null) {
68
+ let parsed;
69
+ try {
70
+ parsed = JSON.parse(opts.richText);
71
+ }
72
+ catch {
73
+ throw new Error("Invalid --rich-text JSON.");
74
+ }
75
+ body.richText = parsed;
76
+ }
59
77
  if (opts.mode != null)
60
78
  body.mode = opts.mode;
61
79
  const resp = (await apiPost(`/session/targeted`, body));
@@ -1,9 +1,9 @@
1
- import { apiGet, apiPost, apiPatch } from "../client.js";
1
+ import { apiGet, apiPost } from "../client.js";
2
2
  import { isJsonMode, jsonOut, unwrapResp } from "./utils.js";
3
3
  export function registerSessionsCommand(program) {
4
4
  const sessions = program
5
5
  .command("session")
6
- .description("Session commands (get, list, reply, update).");
6
+ .description("Session commands (get, list, reply).");
7
7
  // ── Get ──
8
8
  sessions
9
9
  .command("get <sessionId>")
@@ -95,11 +95,30 @@ export function registerSessionsCommand(program) {
95
95
  sessions
96
96
  .command("reply <sessionId>")
97
97
  .description("Send a human reply to a session you are a member of.")
98
- .requiredOption("--content <content>", "Reply content (markdown supported)")
98
+ .option("--content <content>", "Reply content (markdown supported)")
99
+ .option("--rich-text <richText>", "Rich-text JSON array (e.g. [{\"type\":\"text\",\"text\":\"hello\"}])")
99
100
  .action(async (sessionId, opts) => {
100
- const resp = (await apiPost(`/session/${sessionId}/reply`, {
101
- content: opts.content,
102
- }));
101
+ if (!opts.content && !opts.richText) {
102
+ throw new Error("Provide either --content or --rich-text.");
103
+ }
104
+ if (opts.content && opts.richText) {
105
+ throw new Error("--content and --rich-text are mutually exclusive.");
106
+ }
107
+ const body = {};
108
+ if (opts.richText != null) {
109
+ let parsed;
110
+ try {
111
+ parsed = JSON.parse(opts.richText);
112
+ }
113
+ catch {
114
+ throw new Error("Invalid --rich-text JSON.");
115
+ }
116
+ body.richText = parsed;
117
+ }
118
+ else {
119
+ body.content = opts.content;
120
+ }
121
+ const resp = (await apiPost(`/session/${sessionId}/reply`, body));
103
122
  const msg = unwrapResp(resp);
104
123
  if (isJsonMode(sessions)) {
105
124
  jsonOut(msg);
@@ -110,31 +129,4 @@ export function registerSessionsCommand(program) {
110
129
  ` Source: ${msg.source}\n` +
111
130
  ` Created: ${msg.createdAt}`);
112
131
  });
113
- // ── Update ──
114
- sessions
115
- .command("update <sessionId>")
116
- .description('Update a session. "auto" lets the AI respond automatically; "manual" requires human replies.')
117
- .option("--mode <mode>", 'Session mode: "auto" or "manual"')
118
- .action(async (sessionId, opts) => {
119
- if (!opts.mode) {
120
- throw new Error("Provide at least one option to update (e.g. --mode).");
121
- }
122
- const body = {};
123
- if (opts.mode != null) {
124
- if (opts.mode !== "auto" && opts.mode !== "manual") {
125
- throw new Error('Invalid mode. Must be "auto" or "manual".');
126
- }
127
- body.mode = opts.mode;
128
- }
129
- const resp = (await apiPatch(`/session/${sessionId}`, body));
130
- const data = unwrapResp(resp);
131
- if (isJsonMode(sessions)) {
132
- jsonOut(data);
133
- return;
134
- }
135
- const session = (data.session || data);
136
- console.log(`Session updated!\n` +
137
- ` ID: ${session.id}\n` +
138
- ` Mode: ${session.mode}`);
139
- });
140
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobi-ai/cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "CLI client for the Gobi collaborative knowledge platform",
5
5
  "license": "MIT",
6
6
  "type": "module",