@neta-art/cohub-cli 1.19.0 → 1.20.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.
@@ -24,6 +24,23 @@ function parseJsonObject(value, name) {
24
24
  function compactObject(input) {
25
25
  return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined));
26
26
  }
27
+ function withCohubBarMeta(input) {
28
+ if (!input.hideCohubBar && !input.showCohubBar)
29
+ return input.meta;
30
+ const meta = input.meta ? { ...input.meta } : {};
31
+ const presentation = meta.presentation && typeof meta.presentation === "object" && !Array.isArray(meta.presentation)
32
+ ? { ...meta.presentation }
33
+ : {};
34
+ if (input.hideCohubBar)
35
+ presentation.hideCohubBar = true;
36
+ if (input.showCohubBar)
37
+ delete presentation.hideCohubBar;
38
+ if (Object.keys(presentation).length > 0)
39
+ meta.presentation = presentation;
40
+ else
41
+ delete meta.presentation;
42
+ return Object.keys(meta).length > 0 ? meta : null;
43
+ }
27
44
  function resolveTarget(opts) {
28
45
  const targets = [
29
46
  opts.file ? { targetType: "file", targetRef: opts.file } : null,
@@ -148,14 +165,23 @@ export function registerWorks(program) {
148
165
  .option("--work-scope <scope>", "Scope granted to the work runtime (space.view, session.view, file.view, taskrun.view)", collectOption, [])
149
166
  .option("--viewer-scope <scope>", "Scope viewers may request (session.prompt.readonly, session.prompt.fullaccess, generation.create, user.space.list, user.session.list, user.usage.read)", collectOption, [])
150
167
  .option("--meta <json>", "Work metadata as a JSON object")
168
+ .option("--hide-cohub-bar", "Hide the Cohub footer bar on the public work page")
169
+ .option("--show-cohub-bar", "Show the Cohub footer bar on the public work page")
151
170
  .option("--json", "Output as JSON")
152
171
  .action(async (slug, opts) => {
172
+ if (opts.hideCohubBar && opts.showCohubBar)
173
+ return error("Conflicting Cohub bar options", "Use either --hide-cohub-bar or --show-cohub-bar.");
153
174
  const target = resolveTarget(opts);
154
175
  if (!target)
155
176
  return error("Missing target", "Use one of --file, --dir, or --port.");
156
177
  const spaceId = resolveSpace(worksCmd);
157
178
  const client = createClient();
158
179
  const status = resolveStatus(opts);
180
+ const meta = withCohubBarMeta({
181
+ meta: parseJsonObject(opts.meta, "meta"),
182
+ hideCohubBar: opts.hideCohubBar,
183
+ showCohubBar: opts.showCohubBar,
184
+ });
159
185
  const input = {
160
186
  spaceId,
161
187
  slug,
@@ -164,7 +190,7 @@ export function registerWorks(program) {
164
190
  targetRef: target.targetRef,
165
191
  workScopes: opts.workScope,
166
192
  allowedViewerScopes: opts.viewerScope,
167
- meta: parseJsonObject(opts.meta, "meta"),
193
+ meta,
168
194
  };
169
195
  try {
170
196
  const result = await client.works.create(input);
@@ -193,13 +219,36 @@ export function registerWorks(program) {
193
219
  .option("--clear-work-scopes", "Clear work runtime scopes")
194
220
  .option("--clear-viewer-scopes", "Clear viewer-requestable scopes")
195
221
  .option("--meta <json>", "Work metadata as a JSON object")
222
+ .option("--hide-cohub-bar", "Hide the Cohub footer bar on the public work page")
223
+ .option("--show-cohub-bar", "Show the Cohub footer bar on the public work page")
196
224
  .option("--json", "Output as JSON")
197
225
  .action(async (id, opts) => {
226
+ if (opts.hideCohubBar && opts.showCohubBar)
227
+ return error("Conflicting Cohub bar options", "Use either --hide-cohub-bar or --show-cohub-bar.");
198
228
  const target = resolveTarget(opts);
199
229
  if (opts.clearWorkScopes && opts.workScope?.length)
200
230
  return error("Conflicting work scopes", "Use either --work-scope or --clear-work-scopes.");
201
231
  if (opts.clearViewerScopes && opts.viewerScope?.length)
202
232
  return error("Conflicting viewer scopes", "Use either --viewer-scope or --clear-viewer-scopes.");
233
+ const hasMetaUpdate = opts.meta !== undefined || opts.hideCohubBar || opts.showCohubBar;
234
+ const client = createClient();
235
+ let meta;
236
+ if (hasMetaUpdate) {
237
+ let baseMeta = opts.meta !== undefined ? parseJsonObject(opts.meta, "meta") ?? null : undefined;
238
+ if (baseMeta === undefined && (opts.hideCohubBar || opts.showCohubBar)) {
239
+ try {
240
+ baseMeta = (await client.works.get(id)).work.meta;
241
+ }
242
+ catch (e) {
243
+ handleHttp(e);
244
+ }
245
+ }
246
+ meta = withCohubBarMeta({
247
+ meta: baseMeta,
248
+ hideCohubBar: opts.hideCohubBar,
249
+ showCohubBar: opts.showCohubBar,
250
+ });
251
+ }
203
252
  const input = compactObject({
204
253
  slug: opts.slug,
205
254
  status: opts.status || opts.draft || opts.disabled ? resolveStatus(opts) : undefined,
@@ -208,11 +257,10 @@ export function registerWorks(program) {
208
257
  publishVersion: opts.publishVersion || undefined,
209
258
  workScopes: opts.clearWorkScopes ? [] : opts.workScope?.length ? opts.workScope : undefined,
210
259
  allowedViewerScopes: opts.clearViewerScopes ? [] : opts.viewerScope?.length ? opts.viewerScope : undefined,
211
- meta: opts.meta !== undefined ? parseJsonObject(opts.meta, "meta") ?? null : undefined,
260
+ meta,
212
261
  });
213
262
  if (Object.keys(input).length === 0)
214
- return error("Nothing to update", "Pass --slug, --file, --dir, --port, --status, --publish-version, --work-scope, --viewer-scope, --clear-work-scopes, --clear-viewer-scopes, or --meta.");
215
- const client = createClient();
263
+ return error("Nothing to update", "Pass --slug, --file, --dir, --port, --status, --publish-version, --work-scope, --viewer-scope, --clear-work-scopes, --clear-viewer-scopes, --meta, --hide-cohub-bar, or --show-cohub-bar.");
216
264
  try {
217
265
  const result = await client.works.update(id, input);
218
266
  if (jsonRequested(opts))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -13,10 +13,10 @@
13
13
  "README.md"
14
14
  ],
15
15
  "dependencies": {
16
- "@neta-art/generation": "^0.1.5",
16
+ "@neta-art/generation": "^0.1.7",
17
17
  "commander": "^14.0.3",
18
18
  "sharp": "^0.34.5",
19
- "@neta-art/cohub": "1.30.0"
19
+ "@neta-art/cohub": "1.31.0"
20
20
  },
21
21
  "publishConfig": {
22
22
  "access": "public"