@diafunc/cli 0.8.1 → 0.9.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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-GIWRWVU6.js";
3
+ } from "./chunk-GQBGVUCT.js";
4
4
 
5
5
  // src/index.ts
6
6
  import { Command } from "commander";
@@ -411,91 +411,194 @@ function createAdminService(client) {
411
411
  path: `/api-tokens/${encodeURIComponent(tokenId)}`
412
412
  });
413
413
  },
414
- // Groups
415
- async getGroups() {
414
+ // Teams
415
+ async listMyTeams() {
416
416
  return client.request({
417
417
  method: "GET",
418
418
  service: SERVICE,
419
- path: "/groups/"
419
+ path: "/me/teams"
420
420
  });
421
421
  },
422
- async getAllGroups() {
422
+ async getTeam(teamId) {
423
423
  return client.request({
424
424
  method: "GET",
425
425
  service: SERVICE,
426
- path: "/groups/all"
426
+ path: `/teams/${encodeURIComponent(teamId)}`
427
427
  });
428
428
  },
429
- async getGroup(groupId) {
429
+ async setActiveTeam(teamId) {
430
430
  return client.request({
431
- method: "GET",
431
+ method: "POST",
432
432
  service: SERVICE,
433
- path: `/groups/${encodeURIComponent(groupId)}`
433
+ path: `/me/active-team/${encodeURIComponent(teamId)}`
434
434
  });
435
435
  },
436
- async createGroup(group) {
436
+ async startTeamCheckout(request) {
437
437
  return client.request({
438
438
  method: "POST",
439
439
  service: SERVICE,
440
- path: "/groups/",
441
- body: group
440
+ path: "/teams/checkout",
441
+ body: request
442
442
  });
443
443
  },
444
- async updateGroup(group) {
444
+ async createTeamPortalSession(teamId, returnUrl) {
445
445
  return client.request({
446
- method: "PUT",
446
+ method: "POST",
447
447
  service: SERVICE,
448
- path: "/groups/",
449
- body: group
448
+ path: `/teams/${encodeURIComponent(teamId)}/portal-session`,
449
+ body: { returnUrl }
450
450
  });
451
451
  },
452
- async deleteGroup(groupId) {
452
+ async cancelTeam(teamId) {
453
453
  return client.request({
454
454
  method: "DELETE",
455
455
  service: SERVICE,
456
- path: `/groups/${encodeURIComponent(groupId)}`
456
+ path: `/teams/${encodeURIComponent(teamId)}`
457
+ });
458
+ },
459
+ async getTeamUsage(teamId) {
460
+ return client.request({
461
+ method: "GET",
462
+ service: SERVICE,
463
+ path: `/teams/${encodeURIComponent(teamId)}/usage`
457
464
  });
458
465
  },
459
- async getGroupMembers(groupId) {
466
+ // Team members
467
+ async listTeamMembers(teamId) {
460
468
  return client.request({
461
469
  method: "GET",
462
470
  service: SERVICE,
463
- path: `/groups/members/${encodeURIComponent(groupId)}`
471
+ path: `/teams/${encodeURIComponent(teamId)}/members`
464
472
  });
465
473
  },
466
- async inviteGroupMember(groupId, userId, role) {
474
+ async inviteTeamMember(teamId, email, role) {
467
475
  return client.request({
468
476
  method: "POST",
469
477
  service: SERVICE,
470
- path: `/groups/members/invitations/${encodeURIComponent(groupId)}/${encodeURIComponent(userId)}/${encodeURIComponent(role)}`
478
+ path: `/teams/${encodeURIComponent(teamId)}/members/invite`,
479
+ body: { email, role }
471
480
  });
472
481
  },
473
- async removeGroupMember(groupId, userId) {
482
+ async removeTeamMember(teamId, userId) {
474
483
  return client.request({
475
484
  method: "DELETE",
476
485
  service: SERVICE,
477
- path: `/groups/members/${encodeURIComponent(groupId)}/${encodeURIComponent(userId)}`
486
+ path: `/teams/${encodeURIComponent(teamId)}/members/${encodeURIComponent(userId)}`
478
487
  });
479
488
  },
480
- async getGroupProjects(groupId) {
489
+ async leaveTeam(teamId) {
490
+ return client.request({
491
+ method: "DELETE",
492
+ service: SERVICE,
493
+ path: `/me/teams/${encodeURIComponent(teamId)}`
494
+ });
495
+ },
496
+ // Team invitations
497
+ async listTeamInvitations(teamId) {
481
498
  return client.request({
482
499
  method: "GET",
483
500
  service: SERVICE,
484
- path: `/groups/projects/${encodeURIComponent(groupId)}`
501
+ path: `/teams/${encodeURIComponent(teamId)}/invitations`
502
+ });
503
+ },
504
+ async revokeTeamInvitation(teamId, invitationId) {
505
+ return client.request({
506
+ method: "DELETE",
507
+ service: SERVICE,
508
+ path: `/teams/${encodeURIComponent(teamId)}/invitations/${encodeURIComponent(invitationId)}`
509
+ });
510
+ },
511
+ async resendTeamInvitation(teamId, invitationId) {
512
+ return client.request({
513
+ method: "POST",
514
+ service: SERVICE,
515
+ path: `/teams/${encodeURIComponent(teamId)}/invitations/${encodeURIComponent(invitationId)}/resend`
516
+ });
517
+ },
518
+ async acceptTeamInvitation(token) {
519
+ return client.request({
520
+ method: "POST",
521
+ service: SERVICE,
522
+ path: `/invitations/${encodeURIComponent(token)}/accept`
523
+ });
524
+ },
525
+ // Seats and extension packs
526
+ async previewTeamSeatCount(teamId, seatCount) {
527
+ return client.request({
528
+ method: "POST",
529
+ service: SERVICE,
530
+ path: `/teams/${encodeURIComponent(teamId)}/seat-count/preview`,
531
+ body: { seatCount }
532
+ });
533
+ },
534
+ async updateTeamSeatCount(teamId, seatCount) {
535
+ return client.request({
536
+ method: "POST",
537
+ service: SERVICE,
538
+ path: `/teams/${encodeURIComponent(teamId)}/seat-count`,
539
+ body: { seatCount }
485
540
  });
486
541
  },
487
- async addGroupProject(groupId, projectId) {
542
+ async previewTeamPackCount(teamId, packCount) {
488
543
  return client.request({
489
544
  method: "POST",
490
545
  service: SERVICE,
491
- path: `/groups/projects/${encodeURIComponent(groupId)}/${encodeURIComponent(projectId)}`
546
+ path: `/teams/${encodeURIComponent(teamId)}/pack-count/preview`,
547
+ body: { packCount }
492
548
  });
493
549
  },
494
- async removeGroupProject(groupId, projectId) {
550
+ async updateTeamPackCount(teamId, packCount) {
551
+ return client.request({
552
+ method: "POST",
553
+ service: SERVICE,
554
+ path: `/teams/${encodeURIComponent(teamId)}/pack-count`,
555
+ body: { packCount }
556
+ });
557
+ },
558
+ // Ownership transfer
559
+ async initiateOwnershipTransfer(teamId, newOwnerUserId) {
560
+ return client.request({
561
+ method: "POST",
562
+ service: SERVICE,
563
+ path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`,
564
+ body: { newOwnerUserId }
565
+ });
566
+ },
567
+ async getOwnershipTransfer(teamId) {
568
+ return client.request({
569
+ method: "GET",
570
+ service: SERVICE,
571
+ path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`
572
+ });
573
+ },
574
+ async acceptOwnershipTransfer(teamId) {
575
+ return client.request({
576
+ method: "POST",
577
+ service: SERVICE,
578
+ path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer/accept`
579
+ });
580
+ },
581
+ async cancelOwnershipTransfer(teamId) {
495
582
  return client.request({
496
583
  method: "DELETE",
497
584
  service: SERVICE,
498
- path: `/groups/projects/${encodeURIComponent(groupId)}/${encodeURIComponent(projectId)}`
585
+ path: `/teams/${encodeURIComponent(teamId)}/ownership-transfer`
586
+ });
587
+ },
588
+ // Team contracts (super-admin only)
589
+ async issueTeamContract(teamId, request) {
590
+ return client.request({
591
+ method: "POST",
592
+ service: SERVICE,
593
+ path: `/teams/${encodeURIComponent(teamId)}/contract`,
594
+ body: request
595
+ });
596
+ },
597
+ async getTeamContract(teamId) {
598
+ return client.request({
599
+ method: "GET",
600
+ service: SERVICE,
601
+ path: `/teams/${encodeURIComponent(teamId)}/contract`
499
602
  });
500
603
  },
501
604
  // Settings
@@ -774,6 +877,9 @@ function registerLogoutCommand(parent) {
774
877
  }
775
878
 
776
879
  // src/commands/auth/status.ts
880
+ import chalk6 from "chalk";
881
+
882
+ // src/output/formatter.ts
777
883
  import chalk5 from "chalk";
778
884
 
779
885
  // src/output/human.ts
@@ -855,6 +961,13 @@ function format(data, options) {
855
961
  break;
856
962
  }
857
963
  }
964
+ function formatMessage(message, options) {
965
+ if (options.format === "json") {
966
+ formatJson({ message });
967
+ } else {
968
+ console.log(chalk5.green(message));
969
+ }
970
+ }
858
971
 
859
972
  // src/commands/auth/status.ts
860
973
  function registerStatusCommand(parent) {
@@ -868,7 +981,7 @@ function registerStatusCommand(parent) {
868
981
  if (outputFormat === "json") {
869
982
  console.log(JSON.stringify({ authenticated: false, profile: config.currentProfile }));
870
983
  } else {
871
- console.log(chalk5.yellow("Not authenticated."), `Run 'diafunc auth login' to configure credentials.`);
984
+ console.log(chalk6.yellow("Not authenticated."), `Run 'diafunc auth login' to configure credentials.`);
872
985
  console.log(` Profile: ${config.currentProfile}`);
873
986
  console.log(` Endpoint: ${profile?.endpoint ?? "not configured"}`);
874
987
  }
@@ -896,7 +1009,7 @@ function registerStatusCommand(parent) {
896
1009
  }
897
1010
 
898
1011
  // src/commands/auth/token.ts
899
- import chalk6 from "chalk";
1012
+ import chalk7 from "chalk";
900
1013
 
901
1014
  // src/client/services/analysis.ts
902
1015
  var SERVICE2 = "analyses";
@@ -2152,6 +2265,7 @@ function createApiClient(options = {}) {
2152
2265
  }
2153
2266
 
2154
2267
  // src/commands/auth/token.ts
2268
+ var VALID_RESOURCE_TYPES = ["project", "team"];
2155
2269
  var VALID_SCOPES = [
2156
2270
  "project:read",
2157
2271
  "project:write",
@@ -2162,15 +2276,23 @@ var VALID_SCOPES = [
2162
2276
  ];
2163
2277
  function registerTokenCommands(parent) {
2164
2278
  const token = parent.command("token").description("Manage API tokens");
2165
- token.command("create").description("Create a new API token").requiredOption("--name <name>", "Token name").requiredOption("--resource <id>", "Resource ID (project or group)").requiredOption("--scopes <scopes>", `Comma-separated scopes: ${VALID_SCOPES.join(", ")}`).option("--resource-type <type>", "Resource type (project or group)", "project").option("--days <days>", "Validity in days (default: 365)", "365").action(async (options, cmd) => {
2279
+ token.command("create").description("Create a new API token").requiredOption("--name <name>", "Token name").requiredOption("--resource <id>", "Resource ID (project or team)").requiredOption("--scopes <scopes>", `Comma-separated scopes: ${VALID_SCOPES.join(", ")}`).option("--resource-type <type>", `Resource type: ${VALID_RESOURCE_TYPES.join(", ")}`, "project").option("--days <days>", "Validity in days (default: 365)", "365").action(async (options, cmd) => {
2166
2280
  try {
2167
2281
  const config = loadConfig();
2168
2282
  const globalOpts = cmd.optsWithGlobals();
2169
2283
  const outputFormat = globalOpts.output ?? config.defaults.output ?? "human";
2284
+ const resourceType = options.resourceType.trim().toLowerCase();
2285
+ if (!VALID_RESOURCE_TYPES.includes(resourceType)) {
2286
+ console.error(
2287
+ chalk7.red(`Invalid resource type: "${options.resourceType}".`),
2288
+ `Valid resource types: ${VALID_RESOURCE_TYPES.join(", ")}`
2289
+ );
2290
+ process.exit(1);
2291
+ }
2170
2292
  const scopes = options.scopes.split(",").map((s) => s.trim());
2171
2293
  for (const scope of scopes) {
2172
2294
  if (!VALID_SCOPES.includes(scope)) {
2173
- console.error(chalk6.red(`Invalid scope: "${scope}".`), `Valid scopes: ${VALID_SCOPES.join(", ")}`);
2295
+ console.error(chalk7.red(`Invalid scope: "${scope}".`), `Valid scopes: ${VALID_SCOPES.join(", ")}`);
2174
2296
  process.exit(1);
2175
2297
  }
2176
2298
  }
@@ -2178,19 +2300,19 @@ function registerTokenCommands(parent) {
2178
2300
  const result = await api.admin.createApiToken({
2179
2301
  name: options.name,
2180
2302
  resourceId: options.resource,
2181
- resourceType: options.resourceType,
2303
+ resourceType,
2182
2304
  scopes,
2183
2305
  validityDays: parseInt(options.days, 10)
2184
2306
  });
2185
2307
  if (outputFormat === "human") {
2186
- console.log(chalk6.green("API token created successfully."));
2308
+ console.log(chalk7.green("API token created successfully."));
2187
2309
  console.log();
2188
- console.log(` Token: ${chalk6.bold(result.token)}`);
2310
+ console.log(` Token: ${chalk7.bold(result.token)}`);
2189
2311
  console.log(` Token ID: ${result.tokenId}`);
2190
2312
  console.log(` Name: ${result.name}`);
2191
2313
  console.log(` Expires: ${result.expiresAt}`);
2192
2314
  console.log();
2193
- console.log(chalk6.yellow("Save this token \u2014 it will not be shown again."));
2315
+ console.log(chalk7.yellow("Save this token \u2014 it will not be shown again."));
2194
2316
  } else {
2195
2317
  format(result, { format: outputFormat });
2196
2318
  }
@@ -2217,7 +2339,7 @@ function registerTokenCommands(parent) {
2217
2339
  try {
2218
2340
  const api = createApiClient();
2219
2341
  await api.admin.revokeApiToken(tokenId);
2220
- console.log(chalk6.green(`Token ${tokenId} revoked.`));
2342
+ console.log(chalk7.green(`Token ${tokenId} revoked.`));
2221
2343
  } catch (error) {
2222
2344
  handleError(error);
2223
2345
  }
@@ -2234,20 +2356,20 @@ function registerAuthCommands(program) {
2234
2356
  }
2235
2357
 
2236
2358
  // src/commands/config/index.ts
2237
- import chalk7 from "chalk";
2359
+ import chalk8 from "chalk";
2238
2360
  function registerConfigCommands(program) {
2239
2361
  const config = program.command("config").description("Manage CLI configuration");
2240
2362
  config.command("set").description("Set a configuration value").argument("<key>", "Config key (e.g., defaults.project, defaults.branch, defaults.output)").argument("<value>", "Config value").action((key, value) => {
2241
2363
  const cfg = loadConfig();
2242
2364
  setNestedValue(cfg, key, value);
2243
2365
  saveConfig(cfg);
2244
- console.log(chalk7.green(`Set ${key} = ${value}`));
2366
+ console.log(chalk8.green(`Set ${key} = ${value}`));
2245
2367
  });
2246
2368
  config.command("get").description("Get a configuration value").argument("<key>", "Config key").action((key) => {
2247
2369
  const cfg = loadConfig();
2248
2370
  const value = getNestedValue(cfg, key);
2249
2371
  if (value === void 0) {
2250
- console.log(chalk7.dim("(not set)"));
2372
+ console.log(chalk8.dim("(not set)"));
2251
2373
  } else {
2252
2374
  console.log(String(value));
2253
2375
  }
@@ -2257,20 +2379,20 @@ function registerConfigCommands(program) {
2257
2379
  const globalOpts = cmd.optsWithGlobals();
2258
2380
  const outputFormat = globalOpts.output ?? "human";
2259
2381
  if (outputFormat === "human") {
2260
- console.log(chalk7.bold("Config file:"), CONFIG_FILE);
2261
- console.log(chalk7.bold("Active profile:"), cfg.currentProfile);
2382
+ console.log(chalk8.bold("Config file:"), CONFIG_FILE);
2383
+ console.log(chalk8.bold("Active profile:"), cfg.currentProfile);
2262
2384
  console.log();
2263
- console.log(chalk7.bold("Profiles:"));
2385
+ console.log(chalk8.bold("Profiles:"));
2264
2386
  for (const [name, profile2] of Object.entries(cfg.profiles)) {
2265
- const active = name === cfg.currentProfile ? chalk7.green(" (active)") : "";
2387
+ const active = name === cfg.currentProfile ? chalk8.green(" (active)") : "";
2266
2388
  const authType = profile2.auth?.type ?? "none";
2267
- console.log(` ${chalk7.bold(name)}${active}`);
2389
+ console.log(` ${chalk8.bold(name)}${active}`);
2268
2390
  console.log(` Endpoint: ${profile2.endpoint}`);
2269
2391
  console.log(` Auth: ${authType}`);
2270
2392
  }
2271
2393
  if (Object.keys(cfg.defaults).length > 0) {
2272
2394
  console.log();
2273
- console.log(chalk7.bold("Defaults:"));
2395
+ console.log(chalk8.bold("Defaults:"));
2274
2396
  for (const [key, value] of Object.entries(cfg.defaults)) {
2275
2397
  console.log(` ${key}: ${value}`);
2276
2398
  }
@@ -2283,7 +2405,7 @@ function registerConfigCommands(program) {
2283
2405
  profile.command("add").description("Add a new profile").argument("<name>", "Profile name").option("--endpoint <url>", "API endpoint URL", "https://diafunc.com").option("--token <token>", "API token to store").action((name, options) => {
2284
2406
  const cfg = loadConfig();
2285
2407
  if (cfg.profiles[name]) {
2286
- console.error(chalk7.red(`Profile "${name}" already exists. Use 'diafunc config profile use' to switch to it.`));
2408
+ console.error(chalk8.red(`Profile "${name}" already exists. Use 'diafunc config profile use' to switch to it.`));
2287
2409
  process.exit(1);
2288
2410
  }
2289
2411
  cfg.profiles[name] = {
@@ -2291,18 +2413,18 @@ function registerConfigCommands(program) {
2291
2413
  ...options.token ? { auth: { type: "api-token", token: options.token } } : {}
2292
2414
  };
2293
2415
  saveConfig(cfg);
2294
- console.log(chalk7.green(`Profile "${name}" added.`));
2416
+ console.log(chalk8.green(`Profile "${name}" added.`));
2295
2417
  });
2296
2418
  profile.command("use").description("Switch to a profile").argument("<name>", "Profile name").action((name) => {
2297
2419
  const cfg = loadConfig();
2298
2420
  if (!cfg.profiles[name]) {
2299
- console.error(chalk7.red(`Profile "${name}" not found.`));
2421
+ console.error(chalk8.red(`Profile "${name}" not found.`));
2300
2422
  console.log(`Available profiles: ${Object.keys(cfg.profiles).join(", ")}`);
2301
2423
  process.exit(1);
2302
2424
  }
2303
2425
  cfg.currentProfile = name;
2304
2426
  saveConfig(cfg);
2305
- console.log(chalk7.green(`Switched to profile "${name}".`));
2427
+ console.log(chalk8.green(`Switched to profile "${name}".`));
2306
2428
  });
2307
2429
  profile.command("list").description("List all profiles").action((_options, cmd) => {
2308
2430
  const cfg = loadConfig();
@@ -2322,16 +2444,16 @@ function registerConfigCommands(program) {
2322
2444
  profile.command("remove").description("Remove a profile").argument("<name>", "Profile name").action((name) => {
2323
2445
  const cfg = loadConfig();
2324
2446
  if (!cfg.profiles[name]) {
2325
- console.error(chalk7.red(`Profile "${name}" not found.`));
2447
+ console.error(chalk8.red(`Profile "${name}" not found.`));
2326
2448
  process.exit(1);
2327
2449
  }
2328
2450
  if (name === cfg.currentProfile) {
2329
- console.error(chalk7.red(`Cannot remove the active profile. Switch to another profile first.`));
2451
+ console.error(chalk8.red(`Cannot remove the active profile. Switch to another profile first.`));
2330
2452
  process.exit(1);
2331
2453
  }
2332
2454
  delete cfg.profiles[name];
2333
2455
  saveConfig(cfg);
2334
- console.log(chalk7.green(`Profile "${name}" removed.`));
2456
+ console.log(chalk8.green(`Profile "${name}" removed.`));
2335
2457
  });
2336
2458
  }
2337
2459
  function setNestedValue(obj, path11, value) {
@@ -2359,7 +2481,7 @@ function getNestedValue(obj, path11) {
2359
2481
  }
2360
2482
 
2361
2483
  // src/commands/project/index.ts
2362
- import chalk9 from "chalk";
2484
+ import chalk10 from "chalk";
2363
2485
 
2364
2486
  // src/util/references.ts
2365
2487
  function parseEntityReference(ref, overrides) {
@@ -2444,7 +2566,7 @@ function parseProjectReference(ref, overrides) {
2444
2566
  }
2445
2567
 
2446
2568
  // src/commands/bundle-helpers.ts
2447
- import chalk8 from "chalk";
2569
+ import chalk9 from "chalk";
2448
2570
  import * as fs2 from "fs";
2449
2571
  import * as path2 from "path";
2450
2572
  async function streamResponseToFile(response, outFile) {
@@ -2454,19 +2576,19 @@ async function streamResponseToFile(response, outFile) {
2454
2576
  }
2455
2577
  function printLossiness(notes) {
2456
2578
  if (notes && notes.length > 0) {
2457
- console.log(chalk8.yellow("Lossiness:"));
2579
+ console.log(chalk9.yellow("Lossiness:"));
2458
2580
  for (const note of notes) {
2459
- console.log(chalk8.yellow(` - ${note}`));
2581
+ console.log(chalk9.yellow(` - ${note}`));
2460
2582
  }
2461
2583
  }
2462
2584
  }
2463
2585
  function printImportPreview(preview) {
2464
- console.log(chalk8.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
2586
+ console.log(chalk9.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
2465
2587
  if (preview.projectName) {
2466
- console.log(chalk8.dim(preview.projectName));
2588
+ console.log(chalk9.dim(preview.projectName));
2467
2589
  }
2468
2590
  if (preview.sourceProjectId) {
2469
- console.log(chalk8.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
2591
+ console.log(chalk9.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
2470
2592
  }
2471
2593
  const counts = /* @__PURE__ */ new Map();
2472
2594
  for (const e of preview.entities ?? []) {
@@ -2487,7 +2609,7 @@ function printImportPreview(preview) {
2487
2609
  printLossiness(preview.lossinessNotes);
2488
2610
  }
2489
2611
  function printImportResult(result) {
2490
- console.log(chalk8.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
2612
+ console.log(chalk9.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
2491
2613
  if (result.skeletonCount) {
2492
2614
  console.log(`Skeletons: ${result.skeletonCount}`);
2493
2615
  }
@@ -2558,7 +2680,7 @@ function registerProjectCommands(program) {
2558
2680
  const projects = options.all ? await api.admin.getAllProjects() : await api.admin.getProjects();
2559
2681
  format(projects, {
2560
2682
  format: outputFormat,
2561
- columns: ["projectId", "groupId", "visibility", "language", "active", "locked"]
2683
+ columns: ["projectId", "teamName", "visibility", "language", "active", "locked"]
2562
2684
  });
2563
2685
  } catch (error) {
2564
2686
  handleError(error);
@@ -2584,8 +2706,8 @@ function registerProjectCommands(program) {
2584
2706
  active: true
2585
2707
  });
2586
2708
  if (outputFormat === "human") {
2587
- console.log(chalk9.green("Project created."));
2588
- console.log(` Project ID: ${chalk9.bold(p.projectId)}`);
2709
+ console.log(chalk10.green("Project created."));
2710
+ console.log(` Project ID: ${chalk10.bold(p.projectId)}`);
2589
2711
  console.log(` Visibility: ${p.visibility}`);
2590
2712
  console.log(` Language: ${p.language}`);
2591
2713
  } else {
@@ -2595,7 +2717,7 @@ function registerProjectCommands(program) {
2595
2717
  handleError(error);
2596
2718
  }
2597
2719
  });
2598
- project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--group <groupId>", "Group ID (empty string to unset)").option("--active <bool>", "Whether the project is active (true/false)").action(async (projectId, options) => {
2720
+ project.command("update").description("Update a project").argument("<projectId>", "Project ID").option("--visibility <visibility>", "PRIVATE or PUBLIC").option("--language <language>", "Project language").option("--active <bool>", "Whether the project is active (true/false)").action(async (projectId, options) => {
2599
2721
  try {
2600
2722
  const api = createApiClient();
2601
2723
  const current = await api.admin.getProject(projectId);
@@ -2603,11 +2725,10 @@ function registerProjectCommands(program) {
2603
2725
  ...current,
2604
2726
  ...options.visibility ? { visibility: options.visibility.toUpperCase() } : {},
2605
2727
  ...options.language ? { language: options.language } : {},
2606
- ...options.group !== void 0 ? { groupId: options.group || null } : {},
2607
2728
  ...options.active !== void 0 ? { active: options.active === "true" } : {}
2608
2729
  };
2609
2730
  await api.admin.updateProject(updated);
2610
- console.log(chalk9.green(`Project "${projectId}" updated.`));
2731
+ console.log(chalk10.green(`Project "${projectId}" updated.`));
2611
2732
  } catch (error) {
2612
2733
  handleError(error);
2613
2734
  }
@@ -2629,7 +2750,7 @@ function registerProjectCommands(program) {
2629
2750
  try {
2630
2751
  const api = createApiClient();
2631
2752
  await api.admin.deleteProject(projectId);
2632
- console.log(chalk9.green(`Project "${projectId}" deleted.`));
2753
+ console.log(chalk10.green(`Project "${projectId}" deleted.`));
2633
2754
  } catch (error) {
2634
2755
  handleError(error);
2635
2756
  }
@@ -2638,7 +2759,7 @@ function registerProjectCommands(program) {
2638
2759
  try {
2639
2760
  const api = createApiClient();
2640
2761
  await api.admin.lockProject(projectId);
2641
- console.log(chalk9.green(`Project "${projectId}" locked.`));
2762
+ console.log(chalk10.green(`Project "${projectId}" locked.`));
2642
2763
  } catch (error) {
2643
2764
  handleError(error);
2644
2765
  }
@@ -2647,7 +2768,7 @@ function registerProjectCommands(program) {
2647
2768
  try {
2648
2769
  const api = createApiClient();
2649
2770
  await api.admin.unlockProject(projectId);
2650
- console.log(chalk9.green(`Project "${projectId}" unlocked.`));
2771
+ console.log(chalk10.green(`Project "${projectId}" unlocked.`));
2651
2772
  } catch (error) {
2652
2773
  handleError(error);
2653
2774
  }
@@ -2670,7 +2791,7 @@ function registerProjectCommands(program) {
2670
2791
  try {
2671
2792
  const api = createApiClient();
2672
2793
  await api.admin.inviteProjectMember(projectId, userId, role.toUpperCase());
2673
- console.log(chalk9.green(`Invited ${userId} to "${projectId}" as ${role.toUpperCase()}.`));
2794
+ console.log(chalk10.green(`Invited ${userId} to "${projectId}" as ${role.toUpperCase()}.`));
2674
2795
  } catch (error) {
2675
2796
  handleError(error);
2676
2797
  }
@@ -2679,7 +2800,7 @@ function registerProjectCommands(program) {
2679
2800
  try {
2680
2801
  const api = createApiClient();
2681
2802
  await api.admin.joinProject(projectId, userId);
2682
- console.log(chalk9.green(`Joined project "${projectId}".`));
2803
+ console.log(chalk10.green(`Joined project "${projectId}".`));
2683
2804
  } catch (error) {
2684
2805
  handleError(error);
2685
2806
  }
@@ -2688,7 +2809,7 @@ function registerProjectCommands(program) {
2688
2809
  try {
2689
2810
  const api = createApiClient();
2690
2811
  await api.admin.removeProjectMember(projectId, userId);
2691
- console.log(chalk9.green(`Removed ${userId} from "${projectId}".`));
2812
+ console.log(chalk10.green(`Removed ${userId} from "${projectId}".`));
2692
2813
  } catch (error) {
2693
2814
  handleError(error);
2694
2815
  }
@@ -2700,16 +2821,16 @@ function registerProjectCommands(program) {
2700
2821
  const api = createApiClient();
2701
2822
  const bundleId = await api.storage.exportProjectBundle(ref.projectId, ref.projectBranch);
2702
2823
  if (options.async) {
2703
- console.log(chalk9.green(`Project export queued (bundle ID: ${bundleId}).`));
2824
+ console.log(chalk10.green(`Project export queued (bundle ID: ${bundleId}).`));
2704
2825
  console.log(`Poll progress: diafunc notebook bundles ${project2}`);
2705
2826
  return;
2706
2827
  }
2707
- console.log(chalk9.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
2828
+ console.log(chalk10.dim(`Project export queued (bundle ID: ${bundleId}); waiting for it to finish\u2026`));
2708
2829
  const job = await pollUntilFinished(api.storage, ref.projectId, ref.projectBranch, bundleId);
2709
2830
  const response = await api.storage.getBundleContent(ref.projectId, ref.projectBranch, bundleId, job.filename);
2710
2831
  const outFile = options.out ?? "project.dfproj";
2711
2832
  const bytes = await streamResponseToFile(response, outFile);
2712
- console.log(chalk9.green(`Bundle written to ${outFile} (${bytes} bytes, ${job.entityCount ?? "?"} entities).`));
2833
+ console.log(chalk10.green(`Bundle written to ${outFile} (${bytes} bytes, ${job.entityCount ?? "?"} entities).`));
2713
2834
  } catch (error) {
2714
2835
  handleError(error);
2715
2836
  }
@@ -2720,7 +2841,388 @@ function registerProjectCommands(program) {
2720
2841
  const overrides = getOverrides(cmd);
2721
2842
  const ref = parseProjectReference(project2, overrides);
2722
2843
  const api = createApiClient();
2723
- await runBundleImport(api.storage, ref.projectId, ref.projectBranch, file, options, outputFormat);
2844
+ await runBundleImport(api.storage, ref.projectId, ref.projectBranch, file, options, outputFormat);
2845
+ } catch (error) {
2846
+ handleError(error);
2847
+ }
2848
+ });
2849
+ }
2850
+
2851
+ // src/commands/team/index.ts
2852
+ import chalk12 from "chalk";
2853
+
2854
+ // src/util/confirm.ts
2855
+ import * as readline from "readline";
2856
+ import chalk11 from "chalk";
2857
+ async function confirmDestructive(message, opts = {}) {
2858
+ if (!process.stdin.isTTY || opts.yes) return;
2859
+ const expected = opts.resourceId ?? "yes";
2860
+ const hint = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
2861
+ console.log(chalk11.yellow(`! ${message}`));
2862
+ const answer = await new Promise((resolve) => {
2863
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
2864
+ rl.question(` Type ${hint} to confirm: `, (ans) => {
2865
+ rl.close();
2866
+ resolve(ans);
2867
+ });
2868
+ });
2869
+ if (answer.trim() !== expected) {
2870
+ console.log(chalk11.dim("Aborted."));
2871
+ process.exit(1);
2872
+ }
2873
+ }
2874
+
2875
+ // src/commands/team/index.ts
2876
+ var ROLES = ["OWNER", "ADMIN", "MEMBER"];
2877
+ var INTERVALS = ["MONTHLY", "YEARLY"];
2878
+ function getOutputFormat2(cmd) {
2879
+ const config = loadConfig();
2880
+ const globalOpts = cmd.optsWithGlobals();
2881
+ return globalOpts.output ?? config.defaults.output ?? "human";
2882
+ }
2883
+ function parseRole(value) {
2884
+ const role = value.trim().toUpperCase();
2885
+ if (!ROLES.includes(role)) {
2886
+ throw new Error(`Invalid role "${value}". Expected one of: ${ROLES.join(", ")}.`);
2887
+ }
2888
+ return role;
2889
+ }
2890
+ function parseInterval(value) {
2891
+ const interval = value.trim().toUpperCase();
2892
+ if (!INTERVALS.includes(interval)) {
2893
+ throw new Error(`Invalid billing interval "${value}". Expected one of: ${INTERVALS.join(", ")}.`);
2894
+ }
2895
+ return interval;
2896
+ }
2897
+ function parseCount(value, label) {
2898
+ const count = Number(value);
2899
+ if (!Number.isInteger(count) || count < 0) {
2900
+ throw new Error(`Invalid ${label} "${value}". Expected a non-negative whole number.`);
2901
+ }
2902
+ return count;
2903
+ }
2904
+ function registerTeamCommands(program) {
2905
+ const team = program.command("team").description("Manage teams: membership, invitations, seats, billing, and ownership");
2906
+ team.command("list", { isDefault: true }).description("List the teams you belong to").action(async (_options, cmd) => {
2907
+ try {
2908
+ const api = createApiClient();
2909
+ const teams = await api.admin.listMyTeams();
2910
+ format(teams, {
2911
+ format: getOutputFormat2(cmd),
2912
+ columns: ["id", "name", "planId", "seatCount", "packCount", "renewal"]
2913
+ });
2914
+ } catch (error) {
2915
+ handleError(error);
2916
+ }
2917
+ });
2918
+ team.command("get").description("Show a team").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
2919
+ try {
2920
+ const api = createApiClient();
2921
+ format(await api.admin.getTeam(teamId), { format: getOutputFormat2(cmd) });
2922
+ } catch (error) {
2923
+ handleError(error);
2924
+ }
2925
+ });
2926
+ team.command("use").description("Set your active team (new projects are created under it)").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
2927
+ try {
2928
+ const api = createApiClient();
2929
+ await api.admin.setActiveTeam(teamId);
2930
+ formatMessage(`Active team set to "${teamId}".`, { format: getOutputFormat2(cmd) });
2931
+ } catch (error) {
2932
+ handleError(error);
2933
+ }
2934
+ });
2935
+ team.command("usage").description("Show credit usage for a team, broken down by member").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
2936
+ try {
2937
+ const outputFormat = getOutputFormat2(cmd);
2938
+ const api = createApiClient();
2939
+ const usage = await api.admin.getTeamUsage(teamId);
2940
+ if (outputFormat === "json") {
2941
+ format(usage, { format: outputFormat });
2942
+ return;
2943
+ }
2944
+ console.log(
2945
+ `${usage.year}-${String(usage.month).padStart(2, "0")} ${usage.totalCredits} credits used of ${usage.baselineCredits} included`
2946
+ );
2947
+ format(usage.members, {
2948
+ format: outputFormat,
2949
+ columns: ["userId", "name", "email", "credits"]
2950
+ });
2951
+ } catch (error) {
2952
+ handleError(error);
2953
+ }
2954
+ });
2955
+ team.command("create").description("Start checkout for a new team and print the URL to complete it in a browser").requiredOption("--name <name>", "Team name").requiredOption("--plan <planId>", "Plan ID").requiredOption("--seats <count>", "Number of seats").option("--interval <interval>", "Billing interval (MONTHLY, YEARLY)", "MONTHLY").option("--packs <count>", "Number of credit extension packs").option("--currency <currency>", "Billing currency (e.g. EUR, USD)").action(async (options, cmd) => {
2956
+ try {
2957
+ const api = createApiClient();
2958
+ const session = await api.admin.startTeamCheckout({
2959
+ name: options.name,
2960
+ planId: options.plan,
2961
+ billingInterval: parseInterval(options.interval),
2962
+ seatCount: parseCount(options.seats, "seat count"),
2963
+ ...options.packs !== void 0 ? { packCount: parseCount(options.packs, "pack count") } : {},
2964
+ ...options.currency !== void 0 ? { currency: options.currency.toUpperCase() } : {}
2965
+ });
2966
+ const outputFormat = getOutputFormat2(cmd);
2967
+ if (outputFormat === "json") {
2968
+ format(session, { format: outputFormat });
2969
+ return;
2970
+ }
2971
+ console.log("Open this URL to complete checkout:");
2972
+ console.log(chalk12.cyan(session.url));
2973
+ } catch (error) {
2974
+ handleError(error);
2975
+ }
2976
+ });
2977
+ team.command("portal").description("Open the billing portal for a team and print the URL").argument("<teamId>", "Team ID").option("--return-url <url>", "Where the portal returns to when done", "https://diafunc.com/team").action(async (teamId, options, cmd) => {
2978
+ try {
2979
+ const api = createApiClient();
2980
+ const session = await api.admin.createTeamPortalSession(teamId, options.returnUrl);
2981
+ const outputFormat = getOutputFormat2(cmd);
2982
+ if (outputFormat === "json") {
2983
+ format(session, { format: outputFormat });
2984
+ return;
2985
+ }
2986
+ console.log("Open this URL to manage billing:");
2987
+ console.log(chalk12.cyan(session.url));
2988
+ } catch (error) {
2989
+ handleError(error);
2990
+ }
2991
+ });
2992
+ team.command("cancel").description("Cancel a team's subscription at the end of the current period").argument("<teamId>", "Team ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
2993
+ try {
2994
+ await confirmDestructive(
2995
+ `This will cancel team "${teamId}" at the end of the current billing period.`,
2996
+ { yes: options.yes, resourceId: teamId }
2997
+ );
2998
+ const api = createApiClient();
2999
+ const response = await api.admin.cancelTeam(teamId);
3000
+ formatMessage(
3001
+ `Team "${teamId}" cancelled. Access ends ${response.endsAt ?? "at the end of the period"}.`,
3002
+ { format: getOutputFormat2(cmd) }
3003
+ );
3004
+ } catch (error) {
3005
+ handleError(error);
3006
+ }
3007
+ });
3008
+ team.command("leave").description("Leave a team you are a member of").argument("<teamId>", "Team ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
3009
+ try {
3010
+ await confirmDestructive(`This will remove you from team "${teamId}".`, {
3011
+ yes: options.yes,
3012
+ resourceId: teamId
3013
+ });
3014
+ const api = createApiClient();
3015
+ await api.admin.leaveTeam(teamId);
3016
+ formatMessage(`Left team "${teamId}".`, { format: getOutputFormat2(cmd) });
3017
+ } catch (error) {
3018
+ handleError(error);
3019
+ }
3020
+ });
3021
+ registerMemberCommands(team);
3022
+ registerInvitationCommands(team);
3023
+ registerSeatCommands(team);
3024
+ registerPackCommands(team);
3025
+ registerOwnershipCommands(team);
3026
+ }
3027
+ function registerMemberCommands(team) {
3028
+ const members = team.command("members").description("Manage team members");
3029
+ members.command("list", { isDefault: true }).description("List team members").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3030
+ try {
3031
+ const api = createApiClient();
3032
+ format(await api.admin.listTeamMembers(teamId), {
3033
+ format: getOutputFormat2(cmd),
3034
+ columns: ["userId", "name", "email", "role", "joinedAt"]
3035
+ });
3036
+ } catch (error) {
3037
+ handleError(error);
3038
+ }
3039
+ });
3040
+ members.command("invite").description("Invite someone to the team by email").argument("<teamId>", "Team ID").argument("<email>", "Email address to invite").option("--role <role>", "Team role (OWNER, ADMIN, MEMBER)", "MEMBER").action(async (teamId, email, options, cmd) => {
3041
+ try {
3042
+ const role = parseRole(options.role);
3043
+ const api = createApiClient();
3044
+ await api.admin.inviteTeamMember(teamId, email, role);
3045
+ formatMessage(`Invited ${email} to team "${teamId}" as ${role}.`, {
3046
+ format: getOutputFormat2(cmd)
3047
+ });
3048
+ } catch (error) {
3049
+ handleError(error);
3050
+ }
3051
+ });
3052
+ members.command("remove").description("Remove a member from the team").argument("<teamId>", "Team ID").argument("<userId>", "User ID to remove").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, userId, options, cmd) => {
3053
+ try {
3054
+ await confirmDestructive(`This will remove ${userId} from team "${teamId}".`, {
3055
+ yes: options.yes,
3056
+ resourceId: userId
3057
+ });
3058
+ const api = createApiClient();
3059
+ await api.admin.removeTeamMember(teamId, userId);
3060
+ formatMessage(`Removed ${userId} from team "${teamId}".`, {
3061
+ format: getOutputFormat2(cmd)
3062
+ });
3063
+ } catch (error) {
3064
+ handleError(error);
3065
+ }
3066
+ });
3067
+ }
3068
+ function registerInvitationCommands(team) {
3069
+ const invitations = team.command("invitations").description("Manage pending team invitations");
3070
+ invitations.command("list", { isDefault: true }).description("List pending invitations").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3071
+ try {
3072
+ const api = createApiClient();
3073
+ format(await api.admin.listTeamInvitations(teamId), {
3074
+ format: getOutputFormat2(cmd),
3075
+ columns: ["invitationId", "email", "role", "invitedBy", "expiresAt"]
3076
+ });
3077
+ } catch (error) {
3078
+ handleError(error);
3079
+ }
3080
+ });
3081
+ invitations.command("revoke").description("Revoke a pending invitation").argument("<teamId>", "Team ID").argument("<invitationId>", "Invitation ID").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, invitationId, options, cmd) => {
3082
+ try {
3083
+ await confirmDestructive(`This will revoke invitation "${invitationId}".`, {
3084
+ yes: options.yes,
3085
+ resourceId: invitationId
3086
+ });
3087
+ const api = createApiClient();
3088
+ await api.admin.revokeTeamInvitation(teamId, invitationId);
3089
+ formatMessage(`Revoked invitation "${invitationId}".`, {
3090
+ format: getOutputFormat2(cmd)
3091
+ });
3092
+ } catch (error) {
3093
+ handleError(error);
3094
+ }
3095
+ });
3096
+ invitations.command("resend").description("Resend a pending invitation email").argument("<teamId>", "Team ID").argument("<invitationId>", "Invitation ID").action(async (teamId, invitationId, _options, cmd) => {
3097
+ try {
3098
+ const api = createApiClient();
3099
+ await api.admin.resendTeamInvitation(teamId, invitationId);
3100
+ formatMessage(`Resent invitation "${invitationId}".`, {
3101
+ format: getOutputFormat2(cmd)
3102
+ });
3103
+ } catch (error) {
3104
+ handleError(error);
3105
+ }
3106
+ });
3107
+ invitations.command("accept").description("Accept a team invitation you received by email").argument("<token>", "Invitation token from the email link").action(async (token, _options, cmd) => {
3108
+ try {
3109
+ const api = createApiClient();
3110
+ const member = await api.admin.acceptTeamInvitation(token);
3111
+ formatMessage(`Joined the team as ${member.role}.`, {
3112
+ format: getOutputFormat2(cmd)
3113
+ });
3114
+ } catch (error) {
3115
+ handleError(error);
3116
+ }
3117
+ });
3118
+ }
3119
+ function registerSeatCommands(team) {
3120
+ const seats = team.command("seats").description("Change a team's seat count");
3121
+ seats.command("preview").description("Preview the invoice for a seat-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New seat count").action(async (teamId, count, _options, cmd) => {
3122
+ try {
3123
+ const api = createApiClient();
3124
+ format(await api.admin.previewTeamSeatCount(teamId, parseCount(count, "seat count")), {
3125
+ format: getOutputFormat2(cmd)
3126
+ });
3127
+ } catch (error) {
3128
+ handleError(error);
3129
+ }
3130
+ });
3131
+ seats.command("set").description("Change the seat count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New seat count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, count, options, cmd) => {
3132
+ try {
3133
+ const seatCount = parseCount(count, "seat count");
3134
+ await confirmDestructive(
3135
+ `This will change the seat count of team "${teamId}" to ${seatCount} and adjust billing.`,
3136
+ { yes: options.yes, resourceId: teamId }
3137
+ );
3138
+ const api = createApiClient();
3139
+ const change = await api.admin.updateTeamSeatCount(teamId, seatCount);
3140
+ formatMessage(`Seats changed from ${change.oldSeatCount} to ${change.newSeatCount}.`, {
3141
+ format: getOutputFormat2(cmd)
3142
+ });
3143
+ } catch (error) {
3144
+ handleError(error);
3145
+ }
3146
+ });
3147
+ }
3148
+ function registerPackCommands(team) {
3149
+ const packs = team.command("packs").description("Change a team's credit extension packs");
3150
+ packs.command("preview").description("Preview the invoice for a pack-count change without applying it").argument("<teamId>", "Team ID").argument("<count>", "New pack count").action(async (teamId, count, _options, cmd) => {
3151
+ try {
3152
+ const api = createApiClient();
3153
+ format(await api.admin.previewTeamPackCount(teamId, parseCount(count, "pack count")), {
3154
+ format: getOutputFormat2(cmd)
3155
+ });
3156
+ } catch (error) {
3157
+ handleError(error);
3158
+ }
3159
+ });
3160
+ packs.command("set").description("Change the pack count and bill the difference").argument("<teamId>", "Team ID").argument("<count>", "New pack count").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, count, options, cmd) => {
3161
+ try {
3162
+ const packCount = parseCount(count, "pack count");
3163
+ await confirmDestructive(
3164
+ `This will change the extension packs of team "${teamId}" to ${packCount} and adjust billing.`,
3165
+ { yes: options.yes, resourceId: teamId }
3166
+ );
3167
+ const api = createApiClient();
3168
+ const change = await api.admin.updateTeamPackCount(teamId, packCount);
3169
+ formatMessage(`Packs changed from ${change.oldPackCount} to ${change.newPackCount}.`, {
3170
+ format: getOutputFormat2(cmd)
3171
+ });
3172
+ } catch (error) {
3173
+ handleError(error);
3174
+ }
3175
+ });
3176
+ }
3177
+ function registerOwnershipCommands(team) {
3178
+ const transfer = team.command("transfer").description("Transfer ownership of a team to another member");
3179
+ transfer.command("start").description("Offer ownership to another member").argument("<teamId>", "Team ID").argument("<userId>", "User ID of the new owner").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, userId, options, cmd) => {
3180
+ try {
3181
+ await confirmDestructive(
3182
+ `This will offer ownership of team "${teamId}" to ${userId}.`,
3183
+ { yes: options.yes, resourceId: teamId }
3184
+ );
3185
+ const api = createApiClient();
3186
+ format(await api.admin.initiateOwnershipTransfer(teamId, userId), {
3187
+ format: getOutputFormat2(cmd)
3188
+ });
3189
+ } catch (error) {
3190
+ handleError(error);
3191
+ }
3192
+ });
3193
+ transfer.command("status", { isDefault: true }).description("Show the pending ownership transfer").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3194
+ try {
3195
+ const api = createApiClient();
3196
+ format(await api.admin.getOwnershipTransfer(teamId), { format: getOutputFormat2(cmd) });
3197
+ } catch (error) {
3198
+ handleError(error);
3199
+ }
3200
+ });
3201
+ transfer.command("accept").description("Accept an ownership transfer offered to you").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3202
+ try {
3203
+ const api = createApiClient();
3204
+ const response = await api.admin.acceptOwnershipTransfer(teamId);
3205
+ const outputFormat = getOutputFormat2(cmd);
3206
+ if (outputFormat === "json") {
3207
+ format(response, { format: outputFormat });
3208
+ return;
3209
+ }
3210
+ console.log(chalk12.green(`Ownership transfer ${response.status}.`));
3211
+ if (response.checkoutUrl) {
3212
+ console.log("Open this URL to complete the billing handover:");
3213
+ console.log(chalk12.cyan(response.checkoutUrl));
3214
+ }
3215
+ } catch (error) {
3216
+ handleError(error);
3217
+ }
3218
+ });
3219
+ transfer.command("cancel").description("Cancel a pending ownership transfer").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
3220
+ try {
3221
+ const api = createApiClient();
3222
+ await api.admin.cancelOwnershipTransfer(teamId);
3223
+ formatMessage(`Cancelled the ownership transfer for team "${teamId}".`, {
3224
+ format: getOutputFormat2(cmd)
3225
+ });
2724
3226
  } catch (error) {
2725
3227
  handleError(error);
2726
3228
  }
@@ -2728,32 +3230,9 @@ function registerProjectCommands(program) {
2728
3230
  }
2729
3231
 
2730
3232
  // src/commands/entity/index.ts
2731
- import chalk11 from "chalk";
3233
+ import chalk13 from "chalk";
2732
3234
  import * as fs3 from "fs";
2733
-
2734
- // src/util/confirm.ts
2735
- import * as readline from "readline";
2736
- import chalk10 from "chalk";
2737
- async function confirmDestructive(message, opts = {}) {
2738
- if (!process.stdin.isTTY || opts.yes) return;
2739
- const expected = opts.resourceId ?? "yes";
2740
- const hint = opts.resourceId ? `"${opts.resourceId}"` : '"yes"';
2741
- console.log(chalk10.yellow(`! ${message}`));
2742
- const answer = await new Promise((resolve) => {
2743
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
2744
- rl.question(` Type ${hint} to confirm: `, (ans) => {
2745
- rl.close();
2746
- resolve(ans);
2747
- });
2748
- });
2749
- if (answer.trim() !== expected) {
2750
- console.log(chalk10.dim("Aborted."));
2751
- process.exit(1);
2752
- }
2753
- }
2754
-
2755
- // src/commands/entity/index.ts
2756
- function getOutputFormat2(cmd) {
3235
+ function getOutputFormat3(cmd) {
2757
3236
  const config = loadConfig();
2758
3237
  const globalOpts = cmd.optsWithGlobals();
2759
3238
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -2766,7 +3245,7 @@ function registerEntityCommands(program) {
2766
3245
  const entity = program.command("entity").description("Manage entities");
2767
3246
  entity.command("list").description("List entities in a project (via linked entities from project root)").argument("<projectRef>", "Project reference (projectId or projectId/branch)").action(async (projectRef, _options, cmd) => {
2768
3247
  try {
2769
- const outputFormat = getOutputFormat2(cmd);
3248
+ const outputFormat = getOutputFormat3(cmd);
2770
3249
  const overrides = getOverrides2(cmd);
2771
3250
  const ref = parseEntityReference(projectRef + "/" + projectRef, overrides);
2772
3251
  const api = createApiClient();
@@ -2793,7 +3272,7 @@ function registerEntityCommands(program) {
2793
3272
  });
2794
3273
  entity.command("get").description("Get entity metadata").argument("<ref>", "Entity reference").option("--content", "Include content").action(async (ref, options, cmd) => {
2795
3274
  try {
2796
- const outputFormat = getOutputFormat2(cmd);
3275
+ const outputFormat = getOutputFormat3(cmd);
2797
3276
  const overrides = getOverrides2(cmd);
2798
3277
  const resolved = parseEntityReference(ref, overrides);
2799
3278
  const api = createApiClient();
@@ -2829,14 +3308,14 @@ function registerEntityCommands(program) {
2829
3308
  const resolved = parseEntityReference(ref, overrides);
2830
3309
  const api = createApiClient();
2831
3310
  await api.storage.deleteEntity(resolved);
2832
- console.log(chalk11.green(`Entity "${resolved.entityId}" deleted.`));
3311
+ console.log(chalk13.green(`Entity "${resolved.entityId}" deleted.`));
2833
3312
  } catch (error) {
2834
3313
  handleError(error);
2835
3314
  }
2836
3315
  });
2837
3316
  entity.command("history").description("Get entity version history").argument("<ref>", "Entity reference").option("--from <version>", "From version").option("--to <version>", "To version").action(async (ref, options, cmd) => {
2838
3317
  try {
2839
- const outputFormat = getOutputFormat2(cmd);
3318
+ const outputFormat = getOutputFormat3(cmd);
2840
3319
  const overrides = getOverrides2(cmd);
2841
3320
  const resolved = parseEntityReference(ref, overrides);
2842
3321
  const api = createApiClient();
@@ -2870,7 +3349,7 @@ function registerEntityCommands(program) {
2870
3349
  const resolved = parseEntityReference(ref, overrides);
2871
3350
  const api = createApiClient();
2872
3351
  await api.storage.revertEntity(resolved, parseInt(version, 10));
2873
- console.log(chalk11.green(`Entity "${resolved.entityId}" reverted to version ${version}.`));
3352
+ console.log(chalk13.green(`Entity "${resolved.entityId}" reverted to version ${version}.`));
2874
3353
  } catch (error) {
2875
3354
  handleError(error);
2876
3355
  }
@@ -2881,7 +3360,7 @@ function registerEntityCommands(program) {
2881
3360
  const resolved = parseEntityReference(ref, overrides);
2882
3361
  const api = createApiClient();
2883
3362
  await api.storage.renameEntity(resolved, newId);
2884
- console.log(chalk11.green(`Entity renamed from "${resolved.entityId}" to "${newId}".`));
3363
+ console.log(chalk13.green(`Entity renamed from "${resolved.entityId}" to "${newId}".`));
2885
3364
  } catch (error) {
2886
3365
  handleError(error);
2887
3366
  }
@@ -2896,7 +3375,7 @@ function registerEntityCommands(program) {
2896
3375
  if (options.out) {
2897
3376
  const buffer = Buffer.from(await response.arrayBuffer());
2898
3377
  fs3.writeFileSync(options.out, buffer);
2899
- console.log(chalk11.green(`Content saved to ${options.out}`));
3378
+ console.log(chalk13.green(`Content saved to ${options.out}`));
2900
3379
  } else {
2901
3380
  const text = await response.text();
2902
3381
  process.stdout.write(text);
@@ -2913,7 +3392,7 @@ function registerEntityCommands(program) {
2913
3392
  const fileBuffer = fs3.readFileSync(file);
2914
3393
  const base64 = fileBuffer.toString("base64");
2915
3394
  await api.storage.saveEntityContentBase64(resolved, base64);
2916
- console.log(chalk11.green(`Content uploaded from "${file}" to entity "${resolved.entityId}".`));
3395
+ console.log(chalk13.green(`Content uploaded from "${file}" to entity "${resolved.entityId}".`));
2917
3396
  } catch (error) {
2918
3397
  handleError(error);
2919
3398
  }
@@ -2925,7 +3404,7 @@ function registerEntityCommands(program) {
2925
3404
  const resolved = parseEntityReference(ref, overrides);
2926
3405
  const api = createApiClient();
2927
3406
  await api.storage.deleteEntityContent(resolved);
2928
- console.log(chalk11.green(`Content deleted from entity "${resolved.entityId}".`));
3407
+ console.log(chalk13.green(`Content deleted from entity "${resolved.entityId}".`));
2929
3408
  } catch (error) {
2930
3409
  handleError(error);
2931
3410
  }
@@ -2938,21 +3417,21 @@ function registerEntityCommands(program) {
2938
3417
  const request = { rootEntityIds: entityIds, dataFormat: options.data };
2939
3418
  if (options.async) {
2940
3419
  const bundleId = await api.storage.exportEntitySubset(ref.projectId, ref.projectBranch, request);
2941
- console.log(chalk11.green(`Export queued (bundle ID: ${bundleId}).`));
3420
+ console.log(chalk13.green(`Export queued (bundle ID: ${bundleId}).`));
2942
3421
  console.log(`Poll progress: diafunc notebook bundles ${project}`);
2943
3422
  return;
2944
3423
  }
2945
3424
  const response = await api.storage.streamEntitySubset(ref.projectId, ref.projectBranch, request);
2946
3425
  const outFile = options.out ?? "entities.dfset";
2947
3426
  const bytes = await streamResponseToFile(response, outFile);
2948
- console.log(chalk11.green(`Bundle written to ${outFile} (${bytes} bytes, ${entityIds.length} entity(ies)).`));
3427
+ console.log(chalk13.green(`Bundle written to ${outFile} (${bytes} bytes, ${entityIds.length} entity(ies)).`));
2949
3428
  } catch (error) {
2950
3429
  handleError(error);
2951
3430
  }
2952
3431
  });
2953
3432
  entity.command("import").description("Import a .dfset (or any) bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the bundle").option("--on-conflict <policy>", "copy (default), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
2954
3433
  try {
2955
- const outputFormat = getOutputFormat2(cmd);
3434
+ const outputFormat = getOutputFormat3(cmd);
2956
3435
  const overrides = getOverrides2(cmd);
2957
3436
  const ref = parseProjectReference(project, overrides);
2958
3437
  const api = createApiClient();
@@ -2964,8 +3443,8 @@ function registerEntityCommands(program) {
2964
3443
  }
2965
3444
 
2966
3445
  // src/commands/link/index.ts
2967
- import chalk12 from "chalk";
2968
- function getOutputFormat3(cmd) {
3446
+ import chalk14 from "chalk";
3447
+ function getOutputFormat4(cmd) {
2969
3448
  const config = loadConfig();
2970
3449
  const globalOpts = cmd.optsWithGlobals();
2971
3450
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -2978,7 +3457,7 @@ function registerLinkCommands(program) {
2978
3457
  const link = program.command("link").description("Manage links between entities");
2979
3458
  link.command("list").description("List links for an entity").argument("<ref>", "Source entity reference").option("--direction <dir>", "Link direction: FORWARD or BACKWARD", "FORWARD").action(async (ref, options, cmd) => {
2980
3459
  try {
2981
- const outputFormat = getOutputFormat3(cmd);
3460
+ const outputFormat = getOutputFormat4(cmd);
2982
3461
  const overrides = getOverrides3(cmd);
2983
3462
  const resolved = parseEntityReference(ref, overrides);
2984
3463
  const api = createApiClient();
@@ -3014,7 +3493,7 @@ function registerLinkCommands(program) {
3014
3493
  target.entityId,
3015
3494
  target.entityBranch
3016
3495
  );
3017
- console.log(chalk12.green(`Link "${linkId}" created: ${source.entityId} \u2192 ${target.entityId}`));
3496
+ console.log(chalk14.green(`Link "${linkId}" created: ${source.entityId} \u2192 ${target.entityId}`));
3018
3497
  } catch (error) {
3019
3498
  handleError(error);
3020
3499
  }
@@ -3035,7 +3514,7 @@ function registerLinkCommands(program) {
3035
3514
  target.entityId,
3036
3515
  target.entityBranch
3037
3516
  );
3038
- console.log(chalk12.green(`Link "${linkId}" deleted: ${source.entityId} \u2192 ${target.entityId}`));
3517
+ console.log(chalk14.green(`Link "${linkId}" deleted: ${source.entityId} \u2192 ${target.entityId}`));
3039
3518
  } else {
3040
3519
  await api.storage.deleteLink(
3041
3520
  source.projectId,
@@ -3044,7 +3523,7 @@ function registerLinkCommands(program) {
3044
3523
  source.entityBranch,
3045
3524
  linkId
3046
3525
  );
3047
- console.log(chalk12.green(`All links with ID "${linkId}" from "${source.entityId}" deleted.`));
3526
+ console.log(chalk14.green(`All links with ID "${linkId}" from "${source.entityId}" deleted.`));
3048
3527
  }
3049
3528
  } catch (error) {
3050
3529
  handleError(error);
@@ -3053,8 +3532,8 @@ function registerLinkCommands(program) {
3053
3532
  }
3054
3533
 
3055
3534
  // src/commands/event/index.ts
3056
- import chalk13 from "chalk";
3057
- function getOutputFormat4(cmd) {
3535
+ import chalk15 from "chalk";
3536
+ function getOutputFormat5(cmd) {
3058
3537
  const config = loadConfig();
3059
3538
  const globalOpts = cmd.optsWithGlobals();
3060
3539
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3067,7 +3546,7 @@ function registerEventCommands(program) {
3067
3546
  const event = program.command("event").description("Manage events");
3068
3547
  event.command("list").description("List events for an entity").argument("<ref>", "Entity reference").action(async (ref, _options, cmd) => {
3069
3548
  try {
3070
- const outputFormat = getOutputFormat4(cmd);
3549
+ const outputFormat = getOutputFormat5(cmd);
3071
3550
  const overrides = getOverrides4(cmd);
3072
3551
  const resolved = parseEntityReference(ref, overrides);
3073
3552
  const api = createApiClient();
@@ -3089,7 +3568,7 @@ function registerEventCommands(program) {
3089
3568
  });
3090
3569
  event.command("get").description("Get a specific event").argument("<ref>", "Entity reference").argument("<eventId>", "Event ID").argument("<occurrenceId>", "Occurrence ID").action(async (ref, eventId, occurrenceId, _options, cmd) => {
3091
3570
  try {
3092
- const outputFormat = getOutputFormat4(cmd);
3571
+ const outputFormat = getOutputFormat5(cmd);
3093
3572
  const overrides = getOverrides4(cmd);
3094
3573
  const resolved = parseEntityReference(ref, overrides);
3095
3574
  const api = createApiClient();
@@ -3115,7 +3594,7 @@ function registerEventCommands(program) {
3115
3594
  const api = createApiClient();
3116
3595
  const arr = Array.isArray(events) ? events : [events];
3117
3596
  await api.storage.createEvents(arr);
3118
- console.log(chalk13.green(`${arr.length} event(s) created.`));
3597
+ console.log(chalk15.green(`${arr.length} event(s) created.`));
3119
3598
  } catch (error) {
3120
3599
  handleError(error);
3121
3600
  }
@@ -3142,7 +3621,7 @@ function registerEventCommands(program) {
3142
3621
  const resolved = parseEntityReference(ref, overrides);
3143
3622
  const api = createApiClient();
3144
3623
  await api.storage.deleteEvent(resolved, eventId, occurrenceId);
3145
- console.log(chalk13.green(`Event "${eventId}/${occurrenceId}" deleted.`));
3624
+ console.log(chalk15.green(`Event "${eventId}/${occurrenceId}" deleted.`));
3146
3625
  } catch (error) {
3147
3626
  handleError(error);
3148
3627
  }
@@ -3150,8 +3629,8 @@ function registerEventCommands(program) {
3150
3629
  }
3151
3630
 
3152
3631
  // src/commands/branch/index.ts
3153
- import chalk14 from "chalk";
3154
- function getOutputFormat5(cmd) {
3632
+ import chalk16 from "chalk";
3633
+ function getOutputFormat6(cmd) {
3155
3634
  const config = loadConfig();
3156
3635
  const globalOpts = cmd.optsWithGlobals();
3157
3636
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3164,12 +3643,12 @@ function registerBranchCommands(program) {
3164
3643
  const branch = program.command("branch").description("Manage branches");
3165
3644
  branch.command("list").description("List branches for a project").argument("[projectId]", "Project ID (uses default if omitted)").action(async (projectId, _options, cmd) => {
3166
3645
  try {
3167
- const outputFormat = getOutputFormat5(cmd);
3646
+ const outputFormat = getOutputFormat6(cmd);
3168
3647
  const overrides = getOverrides5(cmd);
3169
3648
  const config = loadConfig();
3170
3649
  const pid = projectId ?? overrides.project ?? config.defaults.project;
3171
3650
  if (!pid) {
3172
- console.error(chalk14.red("No project specified. Pass a project ID or set defaults.project."));
3651
+ console.error(chalk16.red("No project specified. Pass a project ID or set defaults.project."));
3173
3652
  process.exit(1);
3174
3653
  }
3175
3654
  const api = createApiClient();
@@ -3193,7 +3672,7 @@ function registerBranchCommands(program) {
3193
3672
  sourceProjectBranch: options.source,
3194
3673
  targetProjectBranch: branchName
3195
3674
  });
3196
- console.log(chalk14.green(`Branch "${branchName}" created in project "${projectId}" from "${options.source}".`));
3675
+ console.log(chalk16.green(`Branch "${branchName}" created in project "${projectId}" from "${options.source}".`));
3197
3676
  } catch (error) {
3198
3677
  handleError(error);
3199
3678
  }
@@ -3202,7 +3681,7 @@ function registerBranchCommands(program) {
3202
3681
  try {
3203
3682
  const api = createApiClient();
3204
3683
  await api.storage.deleteProjectBranch(projectId, branchName);
3205
- console.log(chalk14.green(`Branch "${branchName}" deleted from project "${projectId}".`));
3684
+ console.log(chalk16.green(`Branch "${branchName}" deleted from project "${projectId}".`));
3206
3685
  } catch (error) {
3207
3686
  handleError(error);
3208
3687
  }
@@ -3223,7 +3702,7 @@ function registerBranchCommands(program) {
3223
3702
  linkId: options.linkId,
3224
3703
  deepMerge: options.deep
3225
3704
  });
3226
- console.log(chalk14.green("Merge completed."));
3705
+ console.log(chalk16.green("Merge completed."));
3227
3706
  } catch (error) {
3228
3707
  handleError(error);
3229
3708
  }
@@ -3238,7 +3717,7 @@ function registerBranchCommands(program) {
3238
3717
  forkProjectName: options.name ?? forkProjectId,
3239
3718
  forkProjectDescription: options.description
3240
3719
  });
3241
- console.log(chalk14.green(`Project "${projectId}" forked to "${forkProjectId}".`));
3720
+ console.log(chalk16.green(`Project "${projectId}" forked to "${forkProjectId}".`));
3242
3721
  } catch (error) {
3243
3722
  handleError(error);
3244
3723
  }
@@ -3246,10 +3725,10 @@ function registerBranchCommands(program) {
3246
3725
  }
3247
3726
 
3248
3727
  // src/commands/table/index.ts
3249
- import chalk15 from "chalk";
3728
+ import chalk17 from "chalk";
3250
3729
  import * as fs4 from "fs";
3251
3730
  import * as path3 from "path";
3252
- function getOutputFormat6(cmd) {
3731
+ function getOutputFormat7(cmd) {
3253
3732
  const config = loadConfig();
3254
3733
  const globalOpts = cmd.optsWithGlobals();
3255
3734
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3275,7 +3754,7 @@ function registerTableCommands(program) {
3275
3754
  const table = program.command("table").description("Manage tables");
3276
3755
  table.command("view").description("View table data").argument("<ref>", "Table entity reference").option("--rows <range>", "Row range (e.g., 0:10)").option("--cols <range>", "Column range (e.g., 0:5)").action(async (ref, options, cmd) => {
3277
3756
  try {
3278
- const outputFormat = getOutputFormat6(cmd);
3757
+ const outputFormat = getOutputFormat7(cmd);
3279
3758
  const overrides = getOverrides6(cmd);
3280
3759
  const resolved = parseEntityReference(ref, overrides);
3281
3760
  const api = createApiClient();
@@ -3316,7 +3795,7 @@ function registerTableCommands(program) {
3316
3795
  console.log(colNames.map((c) => row2[c] ?? "").join(" "));
3317
3796
  }
3318
3797
  } else {
3319
- console.log(chalk15.dim(`${snapshot.rows.length} rows \xD7 ${snapshot.columns.length} columns`));
3798
+ console.log(chalk17.dim(`${snapshot.rows.length} rows \xD7 ${snapshot.columns.length} columns`));
3320
3799
  format(tableData, { format: outputFormat, columns: colNames });
3321
3800
  }
3322
3801
  } catch (error) {
@@ -3328,7 +3807,7 @@ function registerTableCommands(program) {
3328
3807
  const overrides = getOverrides6(cmd);
3329
3808
  const resolved = parseEntityReference(ref, overrides);
3330
3809
  if (!fs4.existsSync(file)) {
3331
- console.error(chalk15.red(`File not found: ${file}`));
3810
+ console.error(chalk17.red(`File not found: ${file}`));
3332
3811
  process.exit(1);
3333
3812
  }
3334
3813
  const api = createApiClient();
@@ -3346,22 +3825,22 @@ function registerTableCommands(program) {
3346
3825
  const imp = await api.storage.getImport(resolved, importId);
3347
3826
  if (imp.finished !== null) {
3348
3827
  if (imp.succeeded) {
3349
- console.log(chalk15.green(`Import completed successfully (${imp.duration}ms).`));
3828
+ console.log(chalk17.green(`Import completed successfully (${imp.duration}ms).`));
3350
3829
  } else {
3351
- console.error(chalk15.red(`Import failed: ${imp.error}`));
3830
+ console.error(chalk17.red(`Import failed: ${imp.error}`));
3352
3831
  process.exit(1);
3353
3832
  }
3354
3833
  return;
3355
3834
  }
3356
3835
  }
3357
- console.error(chalk15.yellow("Import still in progress. Check status later."));
3836
+ console.error(chalk17.yellow("Import still in progress. Check status later."));
3358
3837
  } catch (error) {
3359
3838
  handleError(error);
3360
3839
  }
3361
3840
  });
3362
3841
  table.command("import-formats").description("List supported import formats").action(async (_options, cmd) => {
3363
3842
  try {
3364
- const outputFormat = getOutputFormat6(cmd);
3843
+ const outputFormat = getOutputFormat7(cmd);
3365
3844
  const api = createApiClient();
3366
3845
  const response = await api.storage.getSupportedImportFormats();
3367
3846
  if (outputFormat === "json") {
@@ -3390,15 +3869,15 @@ function registerTableCommands(program) {
3390
3869
  const formats = await api.storage.getSupportedExportFormats();
3391
3870
  const format2 = formats.formats.find((f) => f.id.toLowerCase() === fmt.toLowerCase());
3392
3871
  if (!format2) {
3393
- console.error(chalk15.red(`Unknown format: "${fmt}". Run \`diafunc table export-formats\` to see the catalogue.`));
3872
+ console.error(chalk17.red(`Unknown format: "${fmt}". Run \`diafunc table export-formats\` to see the catalogue.`));
3394
3873
  process.exit(1);
3395
3874
  }
3396
3875
  if (options.compression && !formats.compressionAlgorithms.includes(options.compression)) {
3397
- console.error(chalk15.red(`Unknown compression: "${options.compression}". Use one of ${formats.compressionAlgorithms.join(", ")}.`));
3876
+ console.error(chalk17.red(`Unknown compression: "${options.compression}". Use one of ${formats.compressionAlgorithms.join(", ")}.`));
3398
3877
  process.exit(1);
3399
3878
  }
3400
3879
  if (options.archive && !formats.archiveAlgorithms.includes(options.archive)) {
3401
- console.error(chalk15.red(`Unknown archive: "${options.archive}". Use one of ${formats.archiveAlgorithms.join(", ")}.`));
3880
+ console.error(chalk17.red(`Unknown archive: "${options.archive}". Use one of ${formats.archiveAlgorithms.join(", ")}.`));
3402
3881
  process.exit(1);
3403
3882
  }
3404
3883
  const exportOptions = {
@@ -3428,10 +3907,10 @@ function registerTableCommands(program) {
3428
3907
  const outFile = options.out ?? deriveOutFile(resolved.entityId, format2.extension, options.archive, options.compression);
3429
3908
  const buffer = Buffer.from(await response.arrayBuffer());
3430
3909
  fs4.writeFileSync(outFile, buffer);
3431
- console.log(chalk15.green(`Table streamed to ${outFile}`));
3910
+ console.log(chalk17.green(`Table streamed to ${outFile}`));
3432
3911
  } else {
3433
3912
  const exportId = await api.storage.exportTable(resolved, format2.id, exportOptions);
3434
- console.log(chalk15.green(`Export queued (ID: ${exportId}).`));
3913
+ console.log(chalk17.green(`Export queued (ID: ${exportId}).`));
3435
3914
  console.log(`Poll progress: diafunc table exports get ${exportId} --ref ${ref}`);
3436
3915
  }
3437
3916
  } catch (error) {
@@ -3440,7 +3919,7 @@ function registerTableCommands(program) {
3440
3919
  });
3441
3920
  table.command("export-formats").description("List supported export formats").action(async (_options, cmd) => {
3442
3921
  try {
3443
- const outputFormat = getOutputFormat6(cmd);
3922
+ const outputFormat = getOutputFormat7(cmd);
3444
3923
  const api = createApiClient();
3445
3924
  const response = await api.storage.getSupportedExportFormats();
3446
3925
  if (outputFormat === "json") {
@@ -3456,8 +3935,8 @@ function registerTableCommands(program) {
3456
3935
  knownLimitations: f.knownLimitations.join(" / ")
3457
3936
  }));
3458
3937
  format(rows, { format: outputFormat, columns: ["id", "displayName", "category", "extension", "mimeType", "knownLimitations"] });
3459
- console.log(chalk15.dim(`Compression: ${response.compressionAlgorithms.join(", ")}`));
3460
- console.log(chalk15.dim(`Archive: ${response.archiveAlgorithms.join(", ")}`));
3938
+ console.log(chalk17.dim(`Compression: ${response.compressionAlgorithms.join(", ")}`));
3939
+ console.log(chalk17.dim(`Archive: ${response.archiveAlgorithms.join(", ")}`));
3461
3940
  } catch (error) {
3462
3941
  handleError(error);
3463
3942
  }
@@ -3465,7 +3944,7 @@ function registerTableCommands(program) {
3465
3944
  const exportsCmd = table.command("exports").description("Track and download async table exports");
3466
3945
  exportsCmd.command("list").description("List async exports for a table entity").argument("<ref>", "Table entity reference").action(async (ref, _options, cmd) => {
3467
3946
  try {
3468
- const outputFormat = getOutputFormat6(cmd);
3947
+ const outputFormat = getOutputFormat7(cmd);
3469
3948
  const overrides = getOverrides6(cmd);
3470
3949
  const resolved = parseEntityReference(ref, overrides);
3471
3950
  const api = createApiClient();
@@ -3475,7 +3954,7 @@ function registerTableCommands(program) {
3475
3954
  return;
3476
3955
  }
3477
3956
  if (exports.length === 0) {
3478
- console.log(chalk15.dim("No exports found."));
3957
+ console.log(chalk17.dim("No exports found."));
3479
3958
  return;
3480
3959
  }
3481
3960
  const rows = exports.map((e) => ({
@@ -3493,14 +3972,14 @@ function registerTableCommands(program) {
3493
3972
  });
3494
3973
  exportsCmd.command("get").description("Get async export status; download the file once the export has succeeded").argument("<exportId>", "Export ID returned by `table export --async`").requiredOption("--ref <ref>", "Table entity reference").option("--out <file>", "Output file path (defaults to the original export filename)").action(async (exportId, options, cmd) => {
3495
3974
  try {
3496
- const outputFormat = getOutputFormat6(cmd);
3975
+ const outputFormat = getOutputFormat7(cmd);
3497
3976
  const overrides = getOverrides6(cmd);
3498
3977
  const resolved = parseEntityReference(options.ref, overrides);
3499
3978
  const api = createApiClient();
3500
3979
  const exports = await api.storage.listExports(resolved);
3501
3980
  const exp = exports.find((e) => e.exportId === exportId);
3502
3981
  if (!exp) {
3503
- console.error(chalk15.red(`Export ${exportId} not found for ref ${options.ref}.`));
3982
+ console.error(chalk17.red(`Export ${exportId} not found for ref ${options.ref}.`));
3504
3983
  process.exit(1);
3505
3984
  }
3506
3985
  if (outputFormat === "json") {
@@ -3509,11 +3988,11 @@ function registerTableCommands(program) {
3509
3988
  }
3510
3989
  if (exp.finished === null) {
3511
3990
  const pct = Math.round((exp.progress ?? 0) * 100);
3512
- console.log(chalk15.dim(`Export in progress: ${pct}% \u2014 check again later.`));
3991
+ console.log(chalk17.dim(`Export in progress: ${pct}% \u2014 check again later.`));
3513
3992
  return;
3514
3993
  }
3515
3994
  if (!exp.succeeded) {
3516
- console.error(chalk15.red(`Export failed: ${exp.error}`));
3995
+ console.error(chalk17.red(`Export failed: ${exp.error}`));
3517
3996
  process.exit(1);
3518
3997
  }
3519
3998
  const outFile = options.out ?? exp.filename;
@@ -3521,7 +4000,7 @@ function registerTableCommands(program) {
3521
4000
  const response = await api.storage.downloadExport(resolved, exportId, exp.filename);
3522
4001
  const buffer = Buffer.from(await response.arrayBuffer());
3523
4002
  fs4.writeFileSync(outFile, buffer);
3524
- console.log(chalk15.green(`Export saved to ${outFile}`));
4003
+ console.log(chalk17.green(`Export saved to ${outFile}`));
3525
4004
  } catch (error) {
3526
4005
  handleError(error);
3527
4006
  }
@@ -3533,7 +4012,7 @@ function registerTableCommands(program) {
3533
4012
  const resolved = parseEntityReference(ref, overrides);
3534
4013
  const api = createApiClient();
3535
4014
  await api.storage.appendRow(resolved);
3536
- console.log(chalk15.green("Row appended."));
4015
+ console.log(chalk17.green("Row appended."));
3537
4016
  } catch (error) {
3538
4017
  handleError(error);
3539
4018
  }
@@ -3544,7 +4023,7 @@ function registerTableCommands(program) {
3544
4023
  const resolved = parseEntityReference(ref, overrides);
3545
4024
  const api = createApiClient();
3546
4025
  await api.storage.insertRow(resolved, parseInt(index, 10));
3547
- console.log(chalk15.green(`Row inserted at index ${index}.`));
4026
+ console.log(chalk17.green(`Row inserted at index ${index}.`));
3548
4027
  } catch (error) {
3549
4028
  handleError(error);
3550
4029
  }
@@ -3555,7 +4034,7 @@ function registerTableCommands(program) {
3555
4034
  const resolved = parseEntityReference(ref, overrides);
3556
4035
  const api = createApiClient();
3557
4036
  await api.storage.removeRow(resolved, parseInt(index, 10));
3558
- console.log(chalk15.green(`Row ${index} removed.`));
4037
+ console.log(chalk17.green(`Row ${index} removed.`));
3559
4038
  } catch (error) {
3560
4039
  handleError(error);
3561
4040
  }
@@ -3566,7 +4045,7 @@ function registerTableCommands(program) {
3566
4045
  const resolved = parseEntityReference(ref, overrides);
3567
4046
  const api = createApiClient();
3568
4047
  await api.storage.deleteRow(resolved, parseInt(index, 10));
3569
- console.log(chalk15.green(`Row ${index} deleted.`));
4048
+ console.log(chalk17.green(`Row ${index} deleted.`));
3570
4049
  } catch (error) {
3571
4050
  handleError(error);
3572
4051
  }
@@ -3578,7 +4057,7 @@ function registerTableCommands(program) {
3578
4057
  const resolved = parseEntityReference(ref, overrides);
3579
4058
  const api = createApiClient();
3580
4059
  await api.storage.appendColumn(resolved);
3581
- console.log(chalk15.green("Column appended."));
4060
+ console.log(chalk17.green("Column appended."));
3582
4061
  } catch (error) {
3583
4062
  handleError(error);
3584
4063
  }
@@ -3589,7 +4068,7 @@ function registerTableCommands(program) {
3589
4068
  const resolved = parseEntityReference(ref, overrides);
3590
4069
  const api = createApiClient();
3591
4070
  await api.storage.insertColumn(resolved, parseInt(index, 10));
3592
- console.log(chalk15.green(`Column inserted at index ${index}.`));
4071
+ console.log(chalk17.green(`Column inserted at index ${index}.`));
3593
4072
  } catch (error) {
3594
4073
  handleError(error);
3595
4074
  }
@@ -3600,7 +4079,7 @@ function registerTableCommands(program) {
3600
4079
  const resolved = parseEntityReference(ref, overrides);
3601
4080
  const api = createApiClient();
3602
4081
  await api.storage.removeColumn(resolved, parseInt(index, 10));
3603
- console.log(chalk15.green(`Column ${index} removed.`));
4082
+ console.log(chalk17.green(`Column ${index} removed.`));
3604
4083
  } catch (error) {
3605
4084
  handleError(error);
3606
4085
  }
@@ -3611,7 +4090,7 @@ function registerTableCommands(program) {
3611
4090
  const resolved = parseEntityReference(ref, overrides);
3612
4091
  const api = createApiClient();
3613
4092
  await api.storage.deleteColumn(resolved, parseInt(index, 10));
3614
- console.log(chalk15.green(`Column ${index} deleted.`));
4093
+ console.log(chalk17.green(`Column ${index} deleted.`));
3615
4094
  } catch (error) {
3616
4095
  handleError(error);
3617
4096
  }
@@ -3628,7 +4107,7 @@ function registerTableCommands(program) {
3628
4107
  value,
3629
4108
  type: "text"
3630
4109
  }]);
3631
- console.log(chalk15.green(`Cell [${row2}, ${col}] set to "${value}".`));
4110
+ console.log(chalk17.green(`Cell [${row2}, ${col}] set to "${value}".`));
3632
4111
  } catch (error) {
3633
4112
  handleError(error);
3634
4113
  }
@@ -3639,7 +4118,7 @@ function registerTableCommands(program) {
3639
4118
  const resolved = parseEntityReference(ref, overrides);
3640
4119
  const api = createApiClient();
3641
4120
  await api.storage.removeCell(resolved, parseInt(row2, 10), parseInt(col, 10));
3642
- console.log(chalk15.green(`Cell [${row2}, ${col}] deleted.`));
4121
+ console.log(chalk17.green(`Cell [${row2}, ${col}] deleted.`));
3643
4122
  } catch (error) {
3644
4123
  handleError(error);
3645
4124
  }
@@ -3651,7 +4130,7 @@ function registerTableCommands(program) {
3651
4130
  const resolved = parseEntityReference(ref, overrides);
3652
4131
  const api = createApiClient();
3653
4132
  await api.storage.clearTable(resolved);
3654
- console.log(chalk15.green("Table cleared."));
4133
+ console.log(chalk17.green("Table cleared."));
3655
4134
  } catch (error) {
3656
4135
  handleError(error);
3657
4136
  }
@@ -3659,10 +4138,10 @@ function registerTableCommands(program) {
3659
4138
  }
3660
4139
 
3661
4140
  // src/commands/notebook/index.ts
3662
- import chalk16 from "chalk";
4141
+ import chalk18 from "chalk";
3663
4142
  import * as fs5 from "fs";
3664
4143
  import * as path4 from "path";
3665
- function getOutputFormat7(cmd) {
4144
+ function getOutputFormat8(cmd) {
3666
4145
  const config = loadConfig();
3667
4146
  const globalOpts = cmd.optsWithGlobals();
3668
4147
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3681,7 +4160,7 @@ function registerNotebookCommands(program) {
3681
4160
  const request = { rootEntityIds: notebookIds, dataFormat: options.data };
3682
4161
  if (options.async) {
3683
4162
  const bundleId = await api.storage.exportBundle(ref.projectId, ref.projectBranch, request);
3684
- console.log(chalk16.green(`Export queued (bundle ID: ${bundleId}).`));
4163
+ console.log(chalk18.green(`Export queued (bundle ID: ${bundleId}).`));
3685
4164
  console.log(`Poll progress: diafunc notebook bundles ${project}`);
3686
4165
  return;
3687
4166
  }
@@ -3689,14 +4168,14 @@ function registerNotebookCommands(program) {
3689
4168
  const outFile = options.out ?? "notebooks.dfnb";
3690
4169
  const buffer = Buffer.from(await response.arrayBuffer());
3691
4170
  fs5.writeFileSync(outFile, buffer);
3692
- console.log(chalk16.green(`Bundle written to ${outFile} (${buffer.length} bytes, ${notebookIds.length} notebook(s)).`));
4171
+ console.log(chalk18.green(`Bundle written to ${outFile} (${buffer.length} bytes, ${notebookIds.length} notebook(s)).`));
3693
4172
  } catch (error) {
3694
4173
  handleError(error);
3695
4174
  }
3696
4175
  });
3697
4176
  notebook.command("import").description("Import a .dfnb bundle into a project").argument("<project>", "Target project reference (projectId or projectId/branch)").argument("<file>", "Path to the .dfnb bundle").option("--on-conflict <policy>", "copy (default), overwrite, or skip", "copy").option("--preview", "Show the bundle inventory without importing").action(async (project, file, options, cmd) => {
3698
4177
  try {
3699
- const outputFormat = getOutputFormat7(cmd);
4178
+ const outputFormat = getOutputFormat8(cmd);
3700
4179
  const overrides = getOverrides7(cmd);
3701
4180
  const ref = parseProjectReference(project, overrides);
3702
4181
  const api = createApiClient();
@@ -3710,9 +4189,9 @@ function registerNotebookCommands(program) {
3710
4189
  format(preview, { format: outputFormat });
3711
4190
  return;
3712
4191
  }
3713
- console.log(chalk16.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
4192
+ console.log(chalk18.bold(`${preview.kind} bundle \xB7 ${preview.entityCount} entities`));
3714
4193
  if (preview.sourceProjectId) {
3715
- console.log(chalk16.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
4194
+ console.log(chalk18.dim(`from ${preview.sourceProjectId}/${preview.sourceProjectBranch}` + (preview.createdBy ? ` \xB7 by ${preview.createdBy}` : "")));
3716
4195
  }
3717
4196
  const counts = /* @__PURE__ */ new Map();
3718
4197
  for (const e of preview.entities ?? []) {
@@ -3722,9 +4201,9 @@ function registerNotebookCommands(program) {
3722
4201
  console.log(` ${type}: ${count}`);
3723
4202
  }
3724
4203
  if (preview.lossinessNotes && preview.lossinessNotes.length > 0) {
3725
- console.log(chalk16.yellow("Lossiness:"));
4204
+ console.log(chalk18.yellow("Lossiness:"));
3726
4205
  for (const note of preview.lossinessNotes) {
3727
- console.log(chalk16.yellow(` - ${note}`));
4206
+ console.log(chalk18.yellow(` - ${note}`));
3728
4207
  }
3729
4208
  }
3730
4209
  return;
@@ -3734,7 +4213,7 @@ function registerNotebookCommands(program) {
3734
4213
  format(result, { format: outputFormat });
3735
4214
  return;
3736
4215
  }
3737
- console.log(chalk16.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
4216
+ console.log(chalk18.green(`Imported ${result.entityCount} entities, ${result.linkCount} links.`));
3738
4217
  console.log(`Notebook id(s): ${result.rootEntityIds.join(", ")}`);
3739
4218
  } catch (error) {
3740
4219
  handleError(error);
@@ -3742,7 +4221,7 @@ function registerNotebookCommands(program) {
3742
4221
  });
3743
4222
  notebook.command("bundles").description("List notebook-bundle export jobs for a project").argument("<project>", "Project reference (projectId or projectId/branch)").action(async (project, _options, cmd) => {
3744
4223
  try {
3745
- const outputFormat = getOutputFormat7(cmd);
4224
+ const outputFormat = getOutputFormat8(cmd);
3746
4225
  const overrides = getOverrides7(cmd);
3747
4226
  const ref = parseProjectReference(project, overrides);
3748
4227
  const api = createApiClient();
@@ -3771,7 +4250,7 @@ function registerNotebookCommands(program) {
3771
4250
  }
3772
4251
 
3773
4252
  // src/commands/function/index.ts
3774
- import chalk17 from "chalk";
4253
+ import chalk19 from "chalk";
3775
4254
  import * as fs6 from "fs";
3776
4255
  import * as os2 from "os";
3777
4256
  import * as path5 from "path";
@@ -3827,7 +4306,7 @@ function buildFunctionEntity(args) {
3827
4306
  }
3828
4307
 
3829
4308
  // src/commands/function/index.ts
3830
- function getOutputFormat8(cmd) {
4309
+ function getOutputFormat9(cmd) {
3831
4310
  const config = loadConfig();
3832
4311
  const globalOpts = cmd.optsWithGlobals();
3833
4312
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -3850,7 +4329,7 @@ function registerFunctionCommands(program) {
3850
4329
  const fn = program.command("function").description("Execute and manage functions");
3851
4330
  fn.command("call").description("Execute a function").argument("<ref>", "Function entity reference").option("--async", "Execute asynchronously").option("--args <json>", "Arguments as JSON object").option("--target <ref>", "Target entity reference").action(async (ref, options, cmd) => {
3852
4331
  try {
3853
- const outputFormat = getOutputFormat8(cmd);
4332
+ const outputFormat = getOutputFormat9(cmd);
3854
4333
  const overrides = getOverrides8(cmd);
3855
4334
  const resolved = parseEntityReference(ref, overrides);
3856
4335
  const api = createApiClient();
@@ -3893,7 +4372,7 @@ function registerFunctionCommands(program) {
3893
4372
  }, isAsync);
3894
4373
  if (isAsync) {
3895
4374
  if (outputFormat === "human") {
3896
- console.log(chalk17.green("Function launched."));
4375
+ console.log(chalk19.green("Function launched."));
3897
4376
  console.log(` Evaluation ID: ${result.evaluationId}`);
3898
4377
  } else {
3899
4378
  format({ evaluationId: result.evaluationId }, { format: outputFormat });
@@ -3901,14 +4380,14 @@ function registerFunctionCommands(program) {
3901
4380
  } else {
3902
4381
  if (outputFormat === "human") {
3903
4382
  if (result.successful) {
3904
- console.log(chalk17.green("Function completed successfully."));
4383
+ console.log(chalk19.green("Function completed successfully."));
3905
4384
  if (result.result) {
3906
4385
  console.log(` Result: ${result.result}`);
3907
4386
  }
3908
4387
  const duration = result.completed - result.started;
3909
4388
  console.log(` Duration: ${duration}ms`);
3910
4389
  } else {
3911
- console.log(chalk17.red("Function failed."));
4390
+ console.log(chalk19.red("Function failed."));
3912
4391
  console.log(` Error: ${result.error}`);
3913
4392
  if (result.lineNumber > 0) {
3914
4393
  console.log(` Line: ${result.lineNumber}, Column: ${result.columnNumber}`);
@@ -3916,7 +4395,7 @@ function registerFunctionCommands(program) {
3916
4395
  }
3917
4396
  if (result.outputs?.length) {
3918
4397
  console.log();
3919
- console.log(chalk17.bold("Outputs:"));
4398
+ console.log(chalk19.bold("Outputs:"));
3920
4399
  for (const out of result.outputs) {
3921
4400
  console.log(` [${out.type}] ${out.output}`);
3922
4401
  }
@@ -3931,7 +4410,7 @@ function registerFunctionCommands(program) {
3931
4410
  });
3932
4411
  fn.command("evaluations").description("List evaluations for a function").argument("<ref>", "Function entity reference").requiredOption("--date <date>", "Date and hour (YYYY-MM-DD-HH in UTC)").action(async (ref, options, cmd) => {
3933
4412
  try {
3934
- const outputFormat = getOutputFormat8(cmd);
4413
+ const outputFormat = getOutputFormat9(cmd);
3935
4414
  const overrides = getOverrides8(cmd);
3936
4415
  const resolved = parseEntityReference(ref, overrides);
3937
4416
  const api = createApiClient();
@@ -3965,16 +4444,16 @@ function registerFunctionCommands(program) {
3965
4444
  });
3966
4445
  fn.command("outputs").description("Get outputs for an evaluation").argument("<projectId>", "Project ID").argument("<evaluationId>", "Evaluation ID").action(async (projectId, evaluationId, _options, cmd) => {
3967
4446
  try {
3968
- const outputFormat = getOutputFormat8(cmd);
4447
+ const outputFormat = getOutputFormat9(cmd);
3969
4448
  const api = createApiClient();
3970
4449
  const outputs = await api.evaluation.getOutputs(projectId, evaluationId);
3971
4450
  if (outputFormat === "human") {
3972
4451
  if (outputs.length === 0) {
3973
- console.log(chalk17.dim("No outputs."));
4452
+ console.log(chalk19.dim("No outputs."));
3974
4453
  }
3975
4454
  for (const out of outputs) {
3976
4455
  const time = new Date(out.timestamp).toISOString();
3977
- console.log(`${chalk17.dim(time)} [${out.type}] ${out.output}`);
4456
+ console.log(`${chalk19.dim(time)} [${out.type}] ${out.output}`);
3978
4457
  }
3979
4458
  } else {
3980
4459
  format(outputs, { format: outputFormat });
@@ -3985,7 +4464,7 @@ function registerFunctionCommands(program) {
3985
4464
  });
3986
4465
  fn.command("logs").description("Get logs for a function evaluation").argument("<ref>", "Function entity reference").requiredOption("--date <date>", "Date and hour (YYYY-MM-DD-HH in UTC)").action(async (ref, options, cmd) => {
3987
4466
  try {
3988
- const outputFormat = getOutputFormat8(cmd);
4467
+ const outputFormat = getOutputFormat9(cmd);
3989
4468
  const overrides = getOverrides8(cmd);
3990
4469
  const resolved = parseEntityReference(ref, overrides);
3991
4470
  const api = createApiClient();
@@ -4024,14 +4503,14 @@ function registerFunctionCommands(program) {
4024
4503
  hour,
4025
4504
  evaluationId
4026
4505
  );
4027
- console.log(chalk17.green(`Evaluation ${evaluationId} stopped.`));
4506
+ console.log(chalk19.green(`Evaluation ${evaluationId} stopped.`));
4028
4507
  } catch (error) {
4029
4508
  handleError(error);
4030
4509
  }
4031
4510
  });
4032
4511
  fn.command("engines").description("List available engines").action(async (_options, cmd) => {
4033
4512
  try {
4034
- const outputFormat = getOutputFormat8(cmd);
4513
+ const outputFormat = getOutputFormat9(cmd);
4035
4514
  const api = createApiClient();
4036
4515
  const engines = await api.evaluation.getEngines();
4037
4516
  format(engines, { format: outputFormat });
@@ -4041,7 +4520,7 @@ function registerFunctionCommands(program) {
4041
4520
  });
4042
4521
  fn.command("last-evaluation").description("Show the most recent evaluation of a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
4043
4522
  try {
4044
- const outputFormat = getOutputFormat8(cmd);
4523
+ const outputFormat = getOutputFormat9(cmd);
4045
4524
  const overrides = getOverrides8(cmd);
4046
4525
  const resolved = parseEntityReference(ref, overrides);
4047
4526
  const api = createApiClient();
@@ -4072,7 +4551,7 @@ function registerFunctionCommands(program) {
4072
4551
  sourceCode
4073
4552
  });
4074
4553
  await api.storage.saveEntities([entity]);
4075
- console.log(chalk17.green(`Function "${resolved.entityId}" created (${options.language}).`));
4554
+ console.log(chalk19.green(`Function "${resolved.entityId}" created (${options.language}).`));
4076
4555
  } catch (error) {
4077
4556
  handleError(error);
4078
4557
  }
@@ -4087,7 +4566,7 @@ function registerFunctionCommands(program) {
4087
4566
  const sourceCode = decodeFunctionSource(entity);
4088
4567
  if (options.out) {
4089
4568
  fs6.writeFileSync(options.out, sourceCode);
4090
- console.log(chalk17.green(`Source written to ${options.out}`));
4569
+ console.log(chalk19.green(`Source written to ${options.out}`));
4091
4570
  } else {
4092
4571
  process.stdout.write(sourceCode);
4093
4572
  if (!sourceCode.endsWith("\n")) process.stdout.write("\n");
@@ -4111,7 +4590,7 @@ function registerFunctionCommands(program) {
4111
4590
  process.stdin.on("error", reject);
4112
4591
  });
4113
4592
  await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(sourceCode));
4114
- console.log(chalk17.green(`Source updated for "${resolved.entityId}".`));
4593
+ console.log(chalk19.green(`Source updated for "${resolved.entityId}".`));
4115
4594
  } catch (error) {
4116
4595
  handleError(error);
4117
4596
  }
@@ -4136,11 +4615,11 @@ function registerFunctionCommands(program) {
4136
4615
  const newSource = fs6.readFileSync(tmpFile, "utf-8");
4137
4616
  fs6.unlinkSync(tmpFile);
4138
4617
  if (newSource === currentSource) {
4139
- console.log(chalk17.dim("No changes."));
4618
+ console.log(chalk19.dim("No changes."));
4140
4619
  return;
4141
4620
  }
4142
4621
  await api.storage.saveEntityContentBase64(resolved, encodeFunctionSource(newSource));
4143
- console.log(chalk17.green(`Source updated for "${resolved.entityId}".`));
4622
+ console.log(chalk19.green(`Source updated for "${resolved.entityId}".`));
4144
4623
  } catch (error) {
4145
4624
  handleError(error);
4146
4625
  }
@@ -4157,8 +4636,8 @@ function extensionFor(language) {
4157
4636
  }
4158
4637
 
4159
4638
  // src/commands/trigger/index.ts
4160
- import chalk18 from "chalk";
4161
- function getOutputFormat9(cmd) {
4639
+ import chalk20 from "chalk";
4640
+ function getOutputFormat10(cmd) {
4162
4641
  const config = loadConfig();
4163
4642
  const globalOpts = cmd.optsWithGlobals();
4164
4643
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4171,7 +4650,7 @@ function registerTriggerCommands(program) {
4171
4650
  const trigger = program.command("trigger").description("Manage function triggers");
4172
4651
  trigger.command("list").description("List triggers for a function").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
4173
4652
  try {
4174
- const outputFormat = getOutputFormat9(cmd);
4653
+ const outputFormat = getOutputFormat10(cmd);
4175
4654
  const overrides = getOverrides9(cmd);
4176
4655
  const resolved = parseEntityReference(ref, overrides);
4177
4656
  const api = createApiClient();
@@ -4199,7 +4678,7 @@ function registerTriggerCommands(program) {
4199
4678
  });
4200
4679
  trigger.command("get").description("Get a specific trigger").argument("<ref>", "Function entity reference").argument("<triggerId>", "Trigger ID").action(async (ref, triggerId, _options, cmd) => {
4201
4680
  try {
4202
- const outputFormat = getOutputFormat9(cmd);
4681
+ const outputFormat = getOutputFormat10(cmd);
4203
4682
  const overrides = getOverrides9(cmd);
4204
4683
  const resolved = parseEntityReference(ref, overrides);
4205
4684
  const api = createApiClient();
@@ -4227,7 +4706,7 @@ function registerTriggerCommands(program) {
4227
4706
  resolved.entityBranch,
4228
4707
  triggerId
4229
4708
  );
4230
- console.log(chalk18.green(`Trigger "${triggerId}" deleted.`));
4709
+ console.log(chalk20.green(`Trigger "${triggerId}" deleted.`));
4231
4710
  } catch (error) {
4232
4711
  handleError(error);
4233
4712
  }
@@ -4275,7 +4754,7 @@ function registerTriggerCommands(program) {
4275
4754
  scheduler: null,
4276
4755
  heartbeat: null
4277
4756
  });
4278
- console.log(chalk18.green("Trigger saved."));
4757
+ console.log(chalk20.green("Trigger saved."));
4279
4758
  } catch (error) {
4280
4759
  handleError(error);
4281
4760
  }
@@ -4283,9 +4762,9 @@ function registerTriggerCommands(program) {
4283
4762
  }
4284
4763
 
4285
4764
  // src/commands/schedule/index.ts
4286
- import chalk19 from "chalk";
4765
+ import chalk21 from "chalk";
4287
4766
  import { randomUUID as randomUUID2 } from "crypto";
4288
- function getOutputFormat10(cmd) {
4767
+ function getOutputFormat11(cmd) {
4289
4768
  const config = loadConfig();
4290
4769
  const globalOpts = cmd.optsWithGlobals();
4291
4770
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4298,7 +4777,7 @@ function registerScheduleCommands(program) {
4298
4777
  const schedule = program.command("schedule").description("Schedule function execution");
4299
4778
  schedule.command("call").description("Schedule a function call").argument("<ref>", "Function entity reference").option("--args <json>", "Arguments as JSON object").option("--target <ref>", "Target entity reference").action(async (ref, options, cmd) => {
4300
4779
  try {
4301
- const outputFormat = getOutputFormat10(cmd);
4780
+ const outputFormat = getOutputFormat11(cmd);
4302
4781
  const overrides = getOverrides10(cmd);
4303
4782
  const resolved = parseEntityReference(ref, overrides);
4304
4783
  const api = createApiClient();
@@ -4335,7 +4814,7 @@ function registerScheduleCommands(program) {
4335
4814
  removeFunction: false
4336
4815
  });
4337
4816
  if (outputFormat === "human") {
4338
- console.log(chalk19.green("Function scheduled."));
4817
+ console.log(chalk21.green("Function scheduled."));
4339
4818
  } else {
4340
4819
  format(result, { format: outputFormat });
4341
4820
  }
@@ -4360,14 +4839,14 @@ function registerScheduleCommands(program) {
4360
4839
  hour,
4361
4840
  evaluationId
4362
4841
  );
4363
- console.log(chalk19.green(`Scheduled evaluation ${evaluationId} stopped.`));
4842
+ console.log(chalk21.green(`Scheduled evaluation ${evaluationId} stopped.`));
4364
4843
  } catch (error) {
4365
4844
  handleError(error);
4366
4845
  }
4367
4846
  });
4368
4847
  schedule.command("list").description("List persistent triggers (scheduled functions are modeled as triggers)").argument("<ref>", "Function entity reference").action(async (ref, _options, cmd) => {
4369
4848
  try {
4370
- const outputFormat = getOutputFormat10(cmd);
4849
+ const outputFormat = getOutputFormat11(cmd);
4371
4850
  const overrides = getOverrides10(cmd);
4372
4851
  const resolved = parseEntityReference(ref, overrides);
4373
4852
  const api = createApiClient();
@@ -4397,10 +4876,10 @@ function registerScheduleCommands(program) {
4397
4876
  }
4398
4877
 
4399
4878
  // src/commands/chat/index.ts
4400
- import chalk20 from "chalk";
4879
+ import chalk22 from "chalk";
4401
4880
  import * as fs7 from "fs";
4402
4881
  import * as path6 from "path";
4403
- function getOutputFormat11(cmd) {
4882
+ function getOutputFormat12(cmd) {
4404
4883
  const config = loadConfig();
4405
4884
  const globalOpts = cmd.optsWithGlobals();
4406
4885
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4438,7 +4917,7 @@ async function streamOneTurn(message, sessionId, projectId, branch) {
4438
4917
  input = event.inputTokens;
4439
4918
  output = event.outputTokens;
4440
4919
  } else if (event.type === "error") {
4441
- console.error(chalk20.red(`
4920
+ console.error(chalk22.red(`
4442
4921
  Error: ${event.content}`));
4443
4922
  }
4444
4923
  } catch {
@@ -4449,19 +4928,19 @@ Error: ${event.content}`));
4449
4928
  }
4450
4929
  async function runChatRepl(options) {
4451
4930
  const { input: promptInput } = await import("@inquirer/prompts");
4452
- const { getUpdateNotice } = await import("./update-check-2X2AIL52.js");
4931
+ const { getUpdateNotice } = await import("./update-check-UOHMHDN6.js");
4453
4932
  let sessionId = options.session;
4454
- console.log(chalk20.bold("Diafunc chat") + chalk20.dim(" \xB7 /help for commands, /quit to exit"));
4933
+ console.log(chalk22.bold("Diafunc chat") + chalk22.dim(" \xB7 /help for commands, /quit to exit"));
4455
4934
  if (sessionId) {
4456
- console.log(chalk20.dim(`Continuing session ${sessionId}`));
4935
+ console.log(chalk22.dim(`Continuing session ${sessionId}`));
4457
4936
  }
4458
4937
  const notice = await getUpdateNotice();
4459
- if (notice) console.log(chalk20.dim(notice));
4938
+ if (notice) console.log(chalk22.dim(notice));
4460
4939
  console.log();
4461
4940
  for (; ; ) {
4462
4941
  let line;
4463
4942
  try {
4464
- line = await promptInput({ message: chalk20.cyan.bold("you >") });
4943
+ line = await promptInput({ message: chalk22.cyan.bold("you >") });
4465
4944
  } catch {
4466
4945
  console.log();
4467
4946
  return;
@@ -4478,37 +4957,37 @@ async function runChatRepl(options) {
4478
4957
  return;
4479
4958
  case "new":
4480
4959
  sessionId = void 0;
4481
- console.log(chalk20.dim("Started a new session."));
4960
+ console.log(chalk22.dim("Started a new session."));
4482
4961
  continue;
4483
4962
  case "session":
4484
4963
  if (!arg) {
4485
- console.log(chalk20.dim(`Current session: ${sessionId ?? "(new)"}`));
4964
+ console.log(chalk22.dim(`Current session: ${sessionId ?? "(new)"}`));
4486
4965
  } else {
4487
4966
  sessionId = arg;
4488
- console.log(chalk20.dim(`Switched to session ${sessionId}`));
4967
+ console.log(chalk22.dim(`Switched to session ${sessionId}`));
4489
4968
  }
4490
4969
  continue;
4491
4970
  case "help":
4492
4971
  case "h":
4493
4972
  case "?":
4494
- console.log(chalk20.dim(" /new start a new session"));
4495
- console.log(chalk20.dim(" /session [id] switch to a session (no id = show current)"));
4496
- console.log(chalk20.dim(" /quit exit the REPL"));
4973
+ console.log(chalk22.dim(" /new start a new session"));
4974
+ console.log(chalk22.dim(" /session [id] switch to a session (no id = show current)"));
4975
+ console.log(chalk22.dim(" /quit exit the REPL"));
4497
4976
  continue;
4498
4977
  default:
4499
- console.log(chalk20.dim(`Unknown command: /${cmd}. Try /help.`));
4978
+ console.log(chalk22.dim(`Unknown command: /${cmd}. Try /help.`));
4500
4979
  continue;
4501
4980
  }
4502
4981
  }
4503
- process.stdout.write(chalk20.magenta.bold("diafunc > "));
4982
+ process.stdout.write(chalk22.magenta.bold("diafunc > "));
4504
4983
  try {
4505
4984
  const result = await streamOneTurn(trimmed, sessionId, options.project, options.branch);
4506
4985
  sessionId = result.sessionId || sessionId;
4507
4986
  console.log();
4508
- console.log(chalk20.dim(`[session ${sessionId} \xB7 ${result.input} in / ${result.output} out]`));
4987
+ console.log(chalk22.dim(`[session ${sessionId} \xB7 ${result.input} in / ${result.output} out]`));
4509
4988
  console.log();
4510
4989
  } catch (error) {
4511
- console.error(chalk20.red(`
4990
+ console.error(chalk22.red(`
4512
4991
  Request failed: ${error.message}`));
4513
4992
  }
4514
4993
  }
@@ -4524,7 +5003,7 @@ function registerChatCommands(program) {
4524
5003
  });
4525
5004
  chat.command("send").description("Send a chat message (blocking)").argument("<message>", "Message to send").option("--project <id>", "Project context").option("--branch <branch>", "Project branch", "main").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
4526
5005
  try {
4527
- const outputFormat = getOutputFormat11(cmd);
5006
+ const outputFormat = getOutputFormat12(cmd);
4528
5007
  const api = createApiClient();
4529
5008
  const response = await api.language.chat({
4530
5009
  message,
@@ -4535,7 +5014,7 @@ function registerChatCommands(program) {
4535
5014
  if (outputFormat === "human") {
4536
5015
  console.log(response.content);
4537
5016
  console.log();
4538
- console.log(chalk20.dim(`Session: ${response.sessionId} | Tokens: ${response.inputTokens} in, ${response.outputTokens} out`));
5017
+ console.log(chalk22.dim(`Session: ${response.sessionId} | Tokens: ${response.inputTokens} in, ${response.outputTokens} out`));
4539
5018
  } else {
4540
5019
  format(response, { format: outputFormat });
4541
5020
  }
@@ -4545,7 +5024,7 @@ function registerChatCommands(program) {
4545
5024
  });
4546
5025
  chat.command("stream").description("Send a chat message (streaming)").argument("<message>", "Message to send").option("--project <id>", "Project context").option("--branch <branch>", "Project branch", "main").option("--session <id>", "Session ID to continue").action(async (message, options, cmd) => {
4547
5026
  try {
4548
- const outputFormat = getOutputFormat11(cmd);
5027
+ const outputFormat = getOutputFormat12(cmd);
4549
5028
  const api = createApiClient();
4550
5029
  const response = await api.language.chatStream({
4551
5030
  message,
@@ -4600,9 +5079,9 @@ function registerChatCommands(program) {
4600
5079
  sessionId = event.sessionId ?? "";
4601
5080
  console.log();
4602
5081
  console.log();
4603
- console.log(chalk20.dim(`Session: ${sessionId} | Tokens: ${event.inputTokens} in, ${event.outputTokens} out`));
5082
+ console.log(chalk22.dim(`Session: ${sessionId} | Tokens: ${event.inputTokens} in, ${event.outputTokens} out`));
4604
5083
  } else if (event.type === "error") {
4605
- console.error(chalk20.red(`
5084
+ console.error(chalk22.red(`
4606
5085
  Error: ${event.content}`));
4607
5086
  }
4608
5087
  } catch {
@@ -4618,7 +5097,7 @@ Error: ${event.content}`));
4618
5097
  chat.command("upload").description("Upload a file for chat context").argument("<file>", "File to upload").action(async (file) => {
4619
5098
  try {
4620
5099
  if (!fs7.existsSync(file)) {
4621
- console.error(chalk20.red(`File not found: ${file}`));
5100
+ console.error(chalk22.red(`File not found: ${file}`));
4622
5101
  process.exit(1);
4623
5102
  }
4624
5103
  const api = createApiClient();
@@ -4627,7 +5106,7 @@ Error: ${event.content}`));
4627
5106
  const formData = new FormData();
4628
5107
  formData.append("file", blob, path6.basename(file));
4629
5108
  const result = await api.language.upload(formData);
4630
- console.log(chalk20.green(`File uploaded: ${result}`));
5109
+ console.log(chalk22.green(`File uploaded: ${result}`));
4631
5110
  } catch (error) {
4632
5111
  handleError(error);
4633
5112
  }
@@ -4635,7 +5114,7 @@ Error: ${event.content}`));
4635
5114
  const session = chat.command("session").description("Manage chat sessions");
4636
5115
  session.command("list").description("List chat sessions").action(async (_options, cmd) => {
4637
5116
  try {
4638
- const outputFormat = getOutputFormat11(cmd);
5117
+ const outputFormat = getOutputFormat12(cmd);
4639
5118
  const api = createApiClient();
4640
5119
  const sessions = await api.language.getSessions();
4641
5120
  format(sessions, {
@@ -4650,22 +5129,22 @@ Error: ${event.content}`));
4650
5129
  try {
4651
5130
  const api = createApiClient();
4652
5131
  await api.language.deleteSession(sessionId);
4653
- console.log(chalk20.green(`Session "${sessionId}" deleted.`));
5132
+ console.log(chalk22.green(`Session "${sessionId}" deleted.`));
4654
5133
  } catch (error) {
4655
5134
  handleError(error);
4656
5135
  }
4657
5136
  });
4658
5137
  session.command("show").description("Show the message history of a chat session").argument("<sessionId>", "Session ID").action(async (sessionId, _options, cmd) => {
4659
5138
  try {
4660
- const outputFormat = getOutputFormat11(cmd);
5139
+ const outputFormat = getOutputFormat12(cmd);
4661
5140
  const api = createApiClient();
4662
5141
  const detail = await api.language.getSession(sessionId);
4663
5142
  if (outputFormat === "human") {
4664
- console.log(chalk20.bold(detail.title) + chalk20.dim(` (${detail.sessionId})`));
5143
+ console.log(chalk22.bold(detail.title) + chalk22.dim(` (${detail.sessionId})`));
4665
5144
  console.log();
4666
5145
  for (const msg of detail.messages) {
4667
- const role = msg.role === "user" ? chalk20.cyan.bold("You") : chalk20.magenta.bold("Diafunc");
4668
- console.log(`${role} ${chalk20.dim(msg.created)}`);
5146
+ const role = msg.role === "user" ? chalk22.cyan.bold("You") : chalk22.magenta.bold("Diafunc");
5147
+ console.log(`${role} ${chalk22.dim(msg.created)}`);
4669
5148
  console.log(msg.content);
4670
5149
  console.log();
4671
5150
  }
@@ -4680,14 +5159,14 @@ Error: ${event.content}`));
4680
5159
  try {
4681
5160
  const api = createApiClient();
4682
5161
  await api.language.renameSession(sessionId, title);
4683
- console.log(chalk20.green(`Session "${sessionId}" renamed to "${title}".`));
5162
+ console.log(chalk22.green(`Session "${sessionId}" renamed to "${title}".`));
4684
5163
  } catch (error) {
4685
5164
  handleError(error);
4686
5165
  }
4687
5166
  });
4688
5167
  chat.command("usage").description("Show token usage").action(async (_options, cmd) => {
4689
5168
  try {
4690
- const outputFormat = getOutputFormat11(cmd);
5169
+ const outputFormat = getOutputFormat12(cmd);
4691
5170
  const api = createApiClient();
4692
5171
  const usage = await api.language.getUsage();
4693
5172
  format(usage, { format: outputFormat });
@@ -4698,7 +5177,7 @@ Error: ${event.content}`));
4698
5177
  }
4699
5178
 
4700
5179
  // src/commands/search/index.ts
4701
- function getOutputFormat12(cmd) {
5180
+ function getOutputFormat13(cmd) {
4702
5181
  const config = loadConfig();
4703
5182
  const globalOpts = cmd.optsWithGlobals();
4704
5183
  return globalOpts.output ?? config.defaults.output ?? "human";
@@ -4706,7 +5185,7 @@ function getOutputFormat12(cmd) {
4706
5185
  function registerSearchCommands(program) {
4707
5186
  program.command("search").description("Search entities across projects").argument("<query>", "Search query").option("--project <id>", "Limit search to a project").option("--branch <branch>", "Project branch", "main").action(async (query, options, cmd) => {
4708
5187
  try {
4709
- const outputFormat = getOutputFormat12(cmd);
5188
+ const outputFormat = getOutputFormat13(cmd);
4710
5189
  const api = createApiClient();
4711
5190
  if (options.project) {
4712
5191
  const results = await api.storage.searchProject(
@@ -4736,124 +5215,9 @@ function registerSearchCommands(program) {
4736
5215
  });
4737
5216
  }
4738
5217
 
4739
- // src/commands/group/index.ts
4740
- import chalk21 from "chalk";
4741
- function getOutputFormat13(cmd) {
4742
- const config = loadConfig();
4743
- const globalOpts = cmd.optsWithGlobals();
4744
- return globalOpts.output ?? config.defaults.output ?? "human";
4745
- }
4746
- function registerGroupCommands(program) {
4747
- const group = program.command("group").description("Manage groups");
4748
- group.command("list").description("List groups").option("--all", "List all groups (admin)").action(async (options, cmd) => {
4749
- try {
4750
- const outputFormat = getOutputFormat13(cmd);
4751
- const api = createApiClient();
4752
- const groups = options.all ? await api.admin.getAllGroups() : await api.admin.getGroups();
4753
- format(groups, { format: outputFormat, columns: ["groupId", "name"] });
4754
- } catch (error) {
4755
- handleError(error);
4756
- }
4757
- });
4758
- group.command("get").description("Get group details").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
4759
- try {
4760
- const outputFormat = getOutputFormat13(cmd);
4761
- const api = createApiClient();
4762
- const g = await api.admin.getGroup(groupId);
4763
- format(g, { format: outputFormat });
4764
- } catch (error) {
4765
- handleError(error);
4766
- }
4767
- });
4768
- group.command("create").description("Create a new group").argument("<groupId>", "Group ID").option("--name <name>", "Group name").action(async (groupId, options) => {
4769
- try {
4770
- const api = createApiClient();
4771
- await api.admin.createGroup({ groupId, name: options.name ?? groupId });
4772
- console.log(chalk21.green(`Group "${groupId}" created.`));
4773
- } catch (error) {
4774
- handleError(error);
4775
- }
4776
- });
4777
- group.command("update").description("Update a group").argument("<groupId>", "Group ID").requiredOption("--name <name>", "New group name").action(async (groupId, options) => {
4778
- try {
4779
- const api = createApiClient();
4780
- await api.admin.updateGroup({ groupId, name: options.name });
4781
- console.log(chalk21.green(`Group "${groupId}" updated.`));
4782
- } catch (error) {
4783
- handleError(error);
4784
- }
4785
- });
4786
- group.command("delete").description("Delete a group").argument("<groupId>", "Group ID").action(async (groupId) => {
4787
- try {
4788
- const api = createApiClient();
4789
- await api.admin.deleteGroup(groupId);
4790
- console.log(chalk21.green(`Group "${groupId}" deleted.`));
4791
- } catch (error) {
4792
- handleError(error);
4793
- }
4794
- });
4795
- const members = group.command("members").description("Manage group members");
4796
- members.command("list").description("List group members").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
4797
- try {
4798
- const outputFormat = getOutputFormat13(cmd);
4799
- const api = createApiClient();
4800
- const memberList = await api.admin.getGroupMembers(groupId);
4801
- format(memberList, { format: outputFormat, columns: ["userId", "role", "joined"] });
4802
- } catch (error) {
4803
- handleError(error);
4804
- }
4805
- });
4806
- members.command("invite").description("Invite a user to a group").argument("<groupId>", "Group ID").argument("<userId>", "User ID").argument("<role>", "Role").action(async (groupId, userId, role) => {
4807
- try {
4808
- const api = createApiClient();
4809
- await api.admin.inviteGroupMember(groupId, userId, role.toUpperCase());
4810
- console.log(chalk21.green(`Invited ${userId} to group "${groupId}" as ${role.toUpperCase()}.`));
4811
- } catch (error) {
4812
- handleError(error);
4813
- }
4814
- });
4815
- members.command("remove").description("Remove a member from a group").argument("<groupId>", "Group ID").argument("<userId>", "User ID").action(async (groupId, userId) => {
4816
- try {
4817
- const api = createApiClient();
4818
- await api.admin.removeGroupMember(groupId, userId);
4819
- console.log(chalk21.green(`Removed ${userId} from group "${groupId}".`));
4820
- } catch (error) {
4821
- handleError(error);
4822
- }
4823
- });
4824
- const projects = group.command("projects").description("Manage group projects");
4825
- projects.command("list").description("List group projects").argument("<groupId>", "Group ID").action(async (groupId, _options, cmd) => {
4826
- try {
4827
- const outputFormat = getOutputFormat13(cmd);
4828
- const api = createApiClient();
4829
- const projectList = await api.admin.getGroupProjects(groupId);
4830
- format(projectList, { format: outputFormat, columns: ["projectId", "visibility", "language"] });
4831
- } catch (error) {
4832
- handleError(error);
4833
- }
4834
- });
4835
- projects.command("add").description("Add a project to a group").argument("<groupId>", "Group ID").argument("<projectId>", "Project ID").action(async (groupId, projectId) => {
4836
- try {
4837
- const api = createApiClient();
4838
- await api.admin.addGroupProject(groupId, projectId);
4839
- console.log(chalk21.green(`Project "${projectId}" added to group "${groupId}".`));
4840
- } catch (error) {
4841
- handleError(error);
4842
- }
4843
- });
4844
- projects.command("remove").description("Remove a project from a group").argument("<groupId>", "Group ID").argument("<projectId>", "Project ID").action(async (groupId, projectId) => {
4845
- try {
4846
- const api = createApiClient();
4847
- await api.admin.removeGroupProject(groupId, projectId);
4848
- console.log(chalk21.green(`Project "${projectId}" removed from group "${groupId}".`));
4849
- } catch (error) {
4850
- handleError(error);
4851
- }
4852
- });
4853
- }
4854
-
4855
5218
  // src/commands/admin/index.ts
4856
- import chalk22 from "chalk";
5219
+ import { readFile } from "fs/promises";
5220
+ import chalk23 from "chalk";
4857
5221
  function getOutputFormat14(cmd) {
4858
5222
  const config = loadConfig();
4859
5223
  const globalOpts = cmd.optsWithGlobals();
@@ -4917,7 +5281,7 @@ function registerAdminCommands(program) {
4917
5281
  try {
4918
5282
  const api = createApiClient();
4919
5283
  await api.admin.mergeSetting({ [key]: value });
4920
- console.log(chalk22.green(`Setting "${key}" updated.`));
5284
+ console.log(chalk23.green(`Setting "${key}" updated.`));
4921
5285
  } catch (error) {
4922
5286
  handleError(error);
4923
5287
  }
@@ -4928,10 +5292,10 @@ function registerAdminCommands(program) {
4928
5292
  const api = createApiClient();
4929
5293
  if (options.longTerm) {
4930
5294
  await api.storage.createLongTermFullBackup();
4931
- console.log(chalk22.green("Full long-term backup initiated."));
5295
+ console.log(chalk23.green("Full long-term backup initiated."));
4932
5296
  } else {
4933
5297
  await api.storage.createShortTermFullBackup();
4934
- console.log(chalk22.green("Full short-term backup initiated."));
5298
+ console.log(chalk23.green("Full short-term backup initiated."));
4935
5299
  }
4936
5300
  } catch (error) {
4937
5301
  handleError(error);
@@ -4942,10 +5306,10 @@ function registerAdminCommands(program) {
4942
5306
  const api = createApiClient();
4943
5307
  if (options.longTerm) {
4944
5308
  await api.storage.createLongTermProjectBackup();
4945
- console.log(chalk22.green("Project long-term backup initiated."));
5309
+ console.log(chalk23.green("Project long-term backup initiated."));
4946
5310
  } else {
4947
5311
  await api.storage.createShortTermProjectBackup();
4948
- console.log(chalk22.green("Project short-term backup initiated."));
5312
+ console.log(chalk23.green("Project short-term backup initiated."));
4949
5313
  }
4950
5314
  } catch (error) {
4951
5315
  handleError(error);
@@ -4959,7 +5323,7 @@ function registerAdminCommands(program) {
4959
5323
  );
4960
5324
  const api = createApiClient();
4961
5325
  await api.storage.restoreProjectBackup({ projectId, projectBranch, bucketName, objectName });
4962
- console.log(chalk22.green(`Restore initiated for ${projectId}/${projectBranch} from ${bucketName}/${objectName}.`));
5326
+ console.log(chalk23.green(`Restore initiated for ${projectId}/${projectBranch} from ${bucketName}/${objectName}.`));
4963
5327
  } catch (error) {
4964
5328
  handleError(error);
4965
5329
  }
@@ -4972,7 +5336,7 @@ function registerAdminCommands(program) {
4972
5336
  );
4973
5337
  const api = createApiClient();
4974
5338
  await api.storage.restoreFullBackup({ bucketName, objectName });
4975
- console.log(chalk22.green(`Full restore initiated from ${bucketName}/${objectName}.`));
5339
+ console.log(chalk23.green(`Full restore initiated from ${bucketName}/${objectName}.`));
4976
5340
  } catch (error) {
4977
5341
  handleError(error);
4978
5342
  }
@@ -4982,10 +5346,10 @@ function registerAdminCommands(program) {
4982
5346
  const api = createApiClient();
4983
5347
  if (options.project) {
4984
5348
  await api.index.rebuildProject(options.project);
4985
- console.log(chalk22.green(`Index rebuild initiated for project "${options.project}".`));
5349
+ console.log(chalk23.green(`Index rebuild initiated for project "${options.project}".`));
4986
5350
  } else {
4987
5351
  await api.index.rebuildAll();
4988
- console.log(chalk22.green("Index rebuild initiated for all projects."));
5352
+ console.log(chalk23.green("Index rebuild initiated for all projects."));
4989
5353
  }
4990
5354
  } catch (error) {
4991
5355
  handleError(error);
@@ -5001,10 +5365,33 @@ function registerAdminCommands(program) {
5001
5365
  handleError(error);
5002
5366
  }
5003
5367
  });
5368
+ const team = admin.command("team").description("Team administration");
5369
+ const contract = team.command("contract").description("Issue and inspect negotiated team contracts");
5370
+ contract.command("get", { isDefault: true }).description("Show a team's contract").argument("<teamId>", "Team ID").action(async (teamId, _options, cmd) => {
5371
+ try {
5372
+ const api = createApiClient();
5373
+ format(await api.admin.getTeamContract(teamId), { format: getOutputFormat14(cmd) });
5374
+ } catch (error) {
5375
+ handleError(error);
5376
+ }
5377
+ });
5378
+ contract.command("issue").description("Issue or replace a negotiated contract for a team").argument("<teamId>", "Team ID").requiredOption("--file <path>", "JSON file holding the contract request").option("-y, --yes", "Skip the confirmation prompt").action(async (teamId, options, cmd) => {
5379
+ try {
5380
+ const request = JSON.parse(await readFile(options.file, "utf8"));
5381
+ await confirmDestructive(
5382
+ `This will replace the contract of team "${teamId}" with the terms in ${options.file}.`,
5383
+ { yes: options.yes, resourceId: teamId }
5384
+ );
5385
+ const api = createApiClient();
5386
+ format(await api.admin.issueTeamContract(teamId, request), { format: getOutputFormat14(cmd) });
5387
+ } catch (error) {
5388
+ handleError(error);
5389
+ }
5390
+ });
5004
5391
  }
5005
5392
 
5006
5393
  // src/commands/status/summary.ts
5007
- import chalk23 from "chalk";
5394
+ import chalk24 from "chalk";
5008
5395
 
5009
5396
  // src/client/services/status.ts
5010
5397
  function createStatusService() {
@@ -5030,24 +5417,24 @@ function createStatusService() {
5030
5417
 
5031
5418
  // src/commands/status/summary.ts
5032
5419
  var STATE_COLORS = {
5033
- UP: chalk23.green,
5034
- DEGRADED: chalk23.yellow,
5035
- DOWN: chalk23.red,
5036
- UNKNOWN: chalk23.gray
5420
+ UP: chalk24.green,
5421
+ DEGRADED: chalk24.yellow,
5422
+ DOWN: chalk24.red,
5423
+ UNKNOWN: chalk24.gray
5037
5424
  };
5038
5425
  function stateColor(state) {
5039
- return STATE_COLORS[state] ?? chalk23.gray;
5426
+ return STATE_COLORS[state] ?? chalk24.gray;
5040
5427
  }
5041
5428
  function stateSymbol(state) {
5042
5429
  switch (state) {
5043
5430
  case "UP":
5044
- return chalk23.green("\u25CF");
5431
+ return chalk24.green("\u25CF");
5045
5432
  case "DEGRADED":
5046
- return chalk23.yellow("\u25CF");
5433
+ return chalk24.yellow("\u25CF");
5047
5434
  case "DOWN":
5048
- return chalk23.red("\u25CF");
5435
+ return chalk24.red("\u25CF");
5049
5436
  default:
5050
- return chalk23.gray("\u25CB");
5437
+ return chalk24.gray("\u25CB");
5051
5438
  }
5052
5439
  }
5053
5440
  function registerSummaryCommand(parent) {
@@ -5074,11 +5461,11 @@ function registerSummaryCommand(parent) {
5074
5461
  }
5075
5462
  console.log();
5076
5463
  if (summary.openIncidents > 0) {
5077
- console.log(chalk23.yellow(` ${summary.openIncidents} active incident(s)`));
5464
+ console.log(chalk24.yellow(` ${summary.openIncidents} active incident(s)`));
5078
5465
  } else {
5079
- console.log(chalk23.dim(" No active incidents"));
5466
+ console.log(chalk24.dim(" No active incidents"));
5080
5467
  }
5081
- console.log(chalk23.dim(`
5468
+ console.log(chalk24.dim(`
5082
5469
  Platform v${version.platformVersion} \u2022 ${new Date(summary.timestamp).toLocaleString()}`));
5083
5470
  console.log();
5084
5471
  } catch (error) {
@@ -5088,17 +5475,17 @@ function registerSummaryCommand(parent) {
5088
5475
  }
5089
5476
 
5090
5477
  // src/commands/status/component.ts
5091
- import chalk24 from "chalk";
5478
+ import chalk25 from "chalk";
5092
5479
  function stateSymbol2(state) {
5093
5480
  switch (state) {
5094
5481
  case "UP":
5095
- return chalk24.green("\u25CF");
5482
+ return chalk25.green("\u25CF");
5096
5483
  case "DEGRADED":
5097
- return chalk24.yellow("\u25CF");
5484
+ return chalk25.yellow("\u25CF");
5098
5485
  case "DOWN":
5099
- return chalk24.red("\u25CF");
5486
+ return chalk25.red("\u25CF");
5100
5487
  default:
5101
- return chalk24.gray("\u25CB");
5488
+ return chalk25.gray("\u25CB");
5102
5489
  }
5103
5490
  }
5104
5491
  function registerComponentCommand(parent) {
@@ -5111,7 +5498,7 @@ function registerComponentCommand(parent) {
5111
5498
  const match = components.find((c) => c.id === id || c.id === id + "-service");
5112
5499
  if (!match) {
5113
5500
  const available = components.map((c) => c.id).join(", ");
5114
- console.error(chalk24.red(`Component "${id}" not found. Available: ${available}`));
5501
+ console.error(chalk25.red(`Component "${id}" not found. Available: ${available}`));
5115
5502
  process.exit(1);
5116
5503
  }
5117
5504
  if (outputFormat !== "human") {
@@ -5119,7 +5506,7 @@ function registerComponentCommand(parent) {
5119
5506
  return;
5120
5507
  }
5121
5508
  console.log();
5122
- console.log(` ${stateSymbol2(match.state)} ${chalk24.bold(match.id)} ${match.version ? chalk24.dim("v" + match.version) : ""}`);
5509
+ console.log(` ${stateSymbol2(match.state)} ${chalk25.bold(match.id)} ${match.version ? chalk25.dim("v" + match.version) : ""}`);
5123
5510
  console.log(` State: ${match.state}`);
5124
5511
  if (match.lastCheckAt) {
5125
5512
  console.log(` Last check: ${new Date(match.lastCheckAt).toLocaleString()}`);
@@ -5128,7 +5515,7 @@ function registerComponentCommand(parent) {
5128
5515
  console.log();
5129
5516
  console.log(" Checks:");
5130
5517
  for (const check of match.checks) {
5131
- const cat = check.category ? chalk24.dim(` (${check.category})`) : "";
5518
+ const cat = check.category ? chalk25.dim(` (${check.category})`) : "";
5132
5519
  console.log(` ${stateSymbol2(check.state)} ${check.name}${cat}`);
5133
5520
  }
5134
5521
  }
@@ -5140,12 +5527,12 @@ function registerComponentCommand(parent) {
5140
5527
  }
5141
5528
 
5142
5529
  // src/commands/status/incidents.ts
5143
- import chalk25 from "chalk";
5530
+ import chalk26 from "chalk";
5144
5531
  var SEVERITY_COLORS = {
5145
- ERROR: chalk25.red,
5146
- WARNING: chalk25.yellow,
5147
- INFO: chalk25.blue,
5148
- MAINTENANCE: chalk25.cyan
5532
+ ERROR: chalk26.red,
5533
+ WARNING: chalk26.yellow,
5534
+ INFO: chalk26.blue,
5535
+ MAINTENANCE: chalk26.cyan
5149
5536
  };
5150
5537
  function registerIncidentsCommand(parent) {
5151
5538
  parent.command("incidents").description("List recent incidents").option("-w, --window <window>", "Time window (e.g. 24h, 48h)", "24h").action(async (options, cmd) => {
@@ -5159,22 +5546,22 @@ function registerIncidentsCommand(parent) {
5159
5546
  return;
5160
5547
  }
5161
5548
  if (incidents.length === 0) {
5162
- console.log(chalk25.dim(`
5549
+ console.log(chalk26.dim(`
5163
5550
  No incidents in the last ${options.window}.
5164
5551
  `));
5165
5552
  return;
5166
5553
  }
5167
5554
  console.log();
5168
5555
  for (const incident of incidents) {
5169
- const color = SEVERITY_COLORS[incident.severity] ?? chalk25.gray;
5556
+ const color = SEVERITY_COLORS[incident.severity] ?? chalk26.gray;
5170
5557
  const severity = color(incident.severity.padEnd(8));
5171
5558
  const time = incident.startedAt ? new Date(incident.startedAt).toLocaleString() : "";
5172
- const resolved = incident.resolvedAt ? chalk25.green(" [resolved]") : chalk25.yellow(" [open]");
5559
+ const resolved = incident.resolvedAt ? chalk26.green(" [resolved]") : chalk26.yellow(" [open]");
5173
5560
  console.log(` ${severity} ${incident.summary}${resolved}`);
5174
- console.log(chalk25.dim(` ${time}`));
5561
+ console.log(chalk26.dim(` ${time}`));
5175
5562
  for (const update of incident.updates) {
5176
5563
  const updateTime = new Date(update.at).toLocaleTimeString();
5177
- console.log(chalk25.dim(` ${updateTime} ${update.status} ${update.message}`));
5564
+ console.log(chalk26.dim(` ${updateTime} ${update.status} ${update.message}`));
5178
5565
  }
5179
5566
  console.log();
5180
5567
  }
@@ -5193,7 +5580,7 @@ function registerStatusCommands(program) {
5193
5580
  }
5194
5581
 
5195
5582
  // src/commands/analyze/index.ts
5196
- import chalk26 from "chalk";
5583
+ import chalk27 from "chalk";
5197
5584
  import * as fs8 from "fs";
5198
5585
  import * as path7 from "path";
5199
5586
  import { spawn as spawn2 } from "child_process";
@@ -5238,14 +5625,14 @@ function multipartFromFile(file) {
5238
5625
  }
5239
5626
  async function runAnalysis(file, options, cmd) {
5240
5627
  if (!fs8.existsSync(file)) {
5241
- console.error(chalk26.red(`File not found: ${file}`));
5628
+ console.error(chalk27.red(`File not found: ${file}`));
5242
5629
  process.exit(1);
5243
5630
  }
5244
5631
  if (options.preset) {
5245
5632
  const api2 = createApiClient();
5246
5633
  const opt = await api2.analysis.getPreset(options.preset);
5247
5634
  if (!opt.preset) {
5248
- console.error(chalk26.red(`Preset not found: ${options.preset}`));
5635
+ console.error(chalk27.red(`Preset not found: ${options.preset}`));
5249
5636
  process.exit(1);
5250
5637
  }
5251
5638
  const p = opt.preset;
@@ -5273,15 +5660,15 @@ async function runAnalysis(file, options, cmd) {
5273
5660
  };
5274
5661
  process.stdout.write(`Creating analysis "${name}" ...`);
5275
5662
  const created = await api.analysis.create(request);
5276
- console.log(chalk26.green(" done"));
5277
- console.log(chalk26.dim(` analysisId: ${created.analysisId}`));
5663
+ console.log(chalk27.green(" done"));
5664
+ console.log(chalk27.dim(` analysisId: ${created.analysisId}`));
5278
5665
  process.stdout.write(`Uploading ${path7.basename(file)} ...`);
5279
5666
  await api.analysis.uploadDataMultipart(created.analysisId, multipartFromFile(file));
5280
- console.log(chalk26.green(" done"));
5667
+ console.log(chalk27.green(" done"));
5281
5668
  process.stdout.write("Queuing analysis run ...");
5282
5669
  const run = await api.analysis.runAnalysis(created.analysisId);
5283
- console.log(chalk26.green(" done"));
5284
- console.log(chalk26.dim(` runId: ${run.runId}`));
5670
+ console.log(chalk27.green(" done"));
5671
+ console.log(chalk27.dim(` runId: ${run.runId}`));
5285
5672
  console.log();
5286
5673
  await monitorRun(api, created.analysisId, run.runId, parseFloat(hours), cmd);
5287
5674
  }
@@ -5306,7 +5693,7 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5306
5693
  if (!seenOutputIds.has(out.outputId)) {
5307
5694
  seenOutputIds.add(out.outputId);
5308
5695
  if (outputFormat === "human") {
5309
- console.log(` ${chalk26.dim("Output:")} ${out.output}`);
5696
+ console.log(` ${chalk27.dim("Output:")} ${out.output}`);
5310
5697
  } else {
5311
5698
  process.stdout.write(
5312
5699
  JSON.stringify({ type: "output", outputId: out.outputId, output: out.output }) + "\n"
@@ -5323,7 +5710,7 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5323
5710
  const durationStr = formatDuration(duration);
5324
5711
  if (run.state === "COMPLETED") {
5325
5712
  if (outputFormat === "human") {
5326
- console.log(chalk26.green(`Analysis complete! (${durationStr})`));
5713
+ console.log(chalk27.green(`Analysis complete! (${durationStr})`));
5327
5714
  try {
5328
5715
  const nav = await api.analysis.getNavigation(analysisId);
5329
5716
  const endpoint = config.profiles[config.currentProfile]?.endpoint ?? "https://diafunc.com";
@@ -5335,13 +5722,13 @@ async function monitorRun(api, analysisId, runId, hoursForProgress, cmd) {
5335
5722
  }
5336
5723
  } else if (run.state === "CANCELLED") {
5337
5724
  if (outputFormat === "human") {
5338
- console.log(chalk26.yellow("Analysis cancelled."));
5725
+ console.log(chalk27.yellow("Analysis cancelled."));
5339
5726
  } else {
5340
5727
  format({ status: "cancelled", runId, analysisId }, { format: outputFormat });
5341
5728
  }
5342
5729
  } else {
5343
5730
  if (outputFormat === "human") {
5344
- console.log(chalk26.red("Analysis failed."));
5731
+ console.log(chalk27.red("Analysis failed."));
5345
5732
  if (run.errorMessage) console.log(` Error: ${run.errorMessage}`);
5346
5733
  } else {
5347
5734
  format({ status: "failed", runId, analysisId, error: run.errorMessage }, { format: outputFormat });
@@ -5383,7 +5770,7 @@ async function getAnalysisDetails(analysisId, cmd) {
5383
5770
  const api = createApiClient();
5384
5771
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5385
5772
  if (!result.analysis) {
5386
- console.log(chalk26.dim("No analysis found."));
5773
+ console.log(chalk27.dim("No analysis found."));
5387
5774
  return;
5388
5775
  }
5389
5776
  format(result.analysis, { format: outputFormat });
@@ -5392,18 +5779,18 @@ async function watchAnalysis(analysisId, cmd) {
5392
5779
  const api = createApiClient();
5393
5780
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5394
5781
  if (!result.analysis) {
5395
- console.log(chalk26.dim("No analysis found."));
5782
+ console.log(chalk27.dim("No analysis found."));
5396
5783
  return;
5397
5784
  }
5398
5785
  const recipe = result.analysis;
5399
5786
  const runs = await api.analysis.getRunsForAnalysis(recipe.analysisId, 1);
5400
5787
  if (runs.length === 0) {
5401
- console.log(chalk26.dim("No runs for this analysis."));
5788
+ console.log(chalk27.dim("No runs for this analysis."));
5402
5789
  return;
5403
5790
  }
5404
5791
  const latest = runs[0];
5405
5792
  if (isTerminalState(latest.state)) {
5406
- console.log(chalk26.green(`Latest run already in terminal state: ${latest.state}`));
5793
+ console.log(chalk27.green(`Latest run already in terminal state: ${latest.state}`));
5407
5794
  try {
5408
5795
  const nav = await api.analysis.getNavigation(recipe.analysisId);
5409
5796
  const config = loadConfig();
@@ -5419,16 +5806,16 @@ async function watchAnalysis(analysisId, cmd) {
5419
5806
  async function rerunAnalysis(analysisId) {
5420
5807
  const api = createApiClient();
5421
5808
  const run = await api.analysis.runAnalysis(analysisId);
5422
- console.log(chalk26.green(`\u2713 Queued new run ${run.runId} for analysis ${analysisId}`));
5423
- console.log(chalk26.dim(` State: ${run.state}`));
5809
+ console.log(chalk27.green(`\u2713 Queued new run ${run.runId} for analysis ${analysisId}`));
5810
+ console.log(chalk27.dim(` State: ${run.state}`));
5424
5811
  console.log();
5425
- console.log(chalk26.dim("Track progress: diafunc analyze watch " + analysisId));
5812
+ console.log(chalk27.dim("Track progress: diafunc analyze watch " + analysisId));
5426
5813
  }
5427
5814
  async function openAnalysis(analysisId) {
5428
5815
  const api = createApiClient();
5429
5816
  const result = analysisId ? await api.analysis.get(analysisId) : await api.analysis.getLast();
5430
5817
  if (!result.analysis) {
5431
- console.log(chalk26.dim("No analysis found."));
5818
+ console.log(chalk27.dim("No analysis found."));
5432
5819
  return;
5433
5820
  }
5434
5821
  const config = loadConfig();
@@ -5439,7 +5826,7 @@ async function openAnalysis(analysisId) {
5439
5826
  console.log(`Opening ${url} ...`);
5440
5827
  openUrl(url);
5441
5828
  } catch {
5442
- console.log(chalk26.dim("Notebook not yet provisioned \u2014 run the analysis first."));
5829
+ console.log(chalk27.dim("Notebook not yet provisioned \u2014 run the analysis first."));
5443
5830
  }
5444
5831
  }
5445
5832
  async function createRecipe(options, cmd) {
@@ -5463,14 +5850,14 @@ async function createRecipe(options, cmd) {
5463
5850
  async function deleteAnalysis(analysisId) {
5464
5851
  const api = createApiClient();
5465
5852
  await api.analysis.delete(analysisId);
5466
- console.log(chalk26.green(`\u2713 Deleted analysis ${analysisId}`));
5853
+ console.log(chalk27.green(`\u2713 Deleted analysis ${analysisId}`));
5467
5854
  }
5468
5855
  async function patchAndPrint(analysisId, value, handler, successLabel, cmd) {
5469
5856
  const outputFormat = getOutputFormat15(cmd);
5470
5857
  const api = createApiClient();
5471
5858
  const updated = await handler(api, analysisId, value);
5472
5859
  if (outputFormat === "human") {
5473
- console.log(chalk26.green(`\u2713 ${successLabel} updated for analysis ${analysisId}`));
5860
+ console.log(chalk27.green(`\u2713 ${successLabel} updated for analysis ${analysisId}`));
5474
5861
  } else {
5475
5862
  format(updated, { format: outputFormat });
5476
5863
  }
@@ -5479,32 +5866,32 @@ async function uploadData(analysisId, file, options) {
5479
5866
  const api = createApiClient();
5480
5867
  if (options.url) {
5481
5868
  if (file) {
5482
- console.error(chalk26.red("Provide either a file or --url, not both."));
5869
+ console.error(chalk27.red("Provide either a file or --url, not both."));
5483
5870
  process.exit(1);
5484
5871
  }
5485
5872
  process.stdout.write(`Uploading from ${options.url} ...`);
5486
5873
  await api.analysis.uploadDataUrl(analysisId, { dataUrl: options.url });
5487
- console.log(chalk26.green(" done"));
5874
+ console.log(chalk27.green(" done"));
5488
5875
  return;
5489
5876
  }
5490
5877
  if (!file) {
5491
- console.error(chalk26.red("Provide a file path or --url <URL>."));
5878
+ console.error(chalk27.red("Provide a file path or --url <URL>."));
5492
5879
  process.exit(1);
5493
5880
  }
5494
5881
  if (!fs8.existsSync(file)) {
5495
- console.error(chalk26.red(`File not found: ${file}`));
5882
+ console.error(chalk27.red(`File not found: ${file}`));
5496
5883
  process.exit(1);
5497
5884
  }
5498
5885
  process.stdout.write(`Uploading ${path7.basename(file)} ...`);
5499
5886
  await api.analysis.uploadDataMultipart(analysisId, multipartFromFile(file));
5500
- console.log(chalk26.green(" done"));
5887
+ console.log(chalk27.green(" done"));
5501
5888
  }
5502
5889
  async function listColumns(analysisId, cmd) {
5503
5890
  const outputFormat = getOutputFormat15(cmd);
5504
5891
  const api = createApiClient();
5505
5892
  const columns = await api.analysis.getColumns(analysisId);
5506
5893
  if (columns.length === 0) {
5507
- console.log(chalk26.dim("No columns yet \u2014 upload data first."));
5894
+ console.log(chalk27.dim("No columns yet \u2014 upload data first."));
5508
5895
  return;
5509
5896
  }
5510
5897
  format(columns, { format: outputFormat, columns: ["name", "valueType"] });
@@ -5530,7 +5917,7 @@ async function cancelRun(runId, cmd) {
5530
5917
  const api = createApiClient();
5531
5918
  const run = await api.analysis.cancelRun(runId);
5532
5919
  if (outputFormat === "human") {
5533
- console.log(chalk26.green(`\u2713 Run ${run.runId} state: ${run.state}`));
5920
+ console.log(chalk27.green(`\u2713 Run ${run.runId} state: ${run.state}`));
5534
5921
  } else {
5535
5922
  format(run, { format: outputFormat });
5536
5923
  }
@@ -5557,7 +5944,7 @@ async function getPreset(presetId, cmd) {
5557
5944
  const api = createApiClient();
5558
5945
  const opt = await api.analysis.getPreset(presetId);
5559
5946
  if (!opt.preset) {
5560
- console.log(chalk26.dim("Preset not found."));
5947
+ console.log(chalk27.dim("Preset not found."));
5561
5948
  return;
5562
5949
  }
5563
5950
  format(opt.preset, { format: outputFormat });
@@ -5580,7 +5967,7 @@ async function savePreset(options, cmd) {
5580
5967
  async function deletePreset(presetId) {
5581
5968
  const api = createApiClient();
5582
5969
  await api.analysis.deletePreset(presetId);
5583
- console.log(chalk26.green(`\u2713 Deleted preset ${presetId}`));
5970
+ console.log(chalk27.green(`\u2713 Deleted preset ${presetId}`));
5584
5971
  }
5585
5972
  async function listTriggers(analysisId, cmd) {
5586
5973
  const outputFormat = getOutputFormat15(cmd);
@@ -5601,7 +5988,7 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
5601
5988
  const outputFormat = getOutputFormat15(cmd);
5602
5989
  const upper = kind.toUpperCase();
5603
5990
  if (upper !== "ONCE" && upper !== "CRON") {
5604
- console.error(chalk26.red(`Invalid kind "${kind}" \u2014 must be ONCE or CRON.`));
5991
+ console.error(chalk27.red(`Invalid kind "${kind}" \u2014 must be ONCE or CRON.`));
5605
5992
  process.exit(1);
5606
5993
  }
5607
5994
  const api = createApiClient();
@@ -5614,7 +6001,7 @@ async function createTrigger(analysisId, kind, schedule, cmd) {
5614
6001
  async function deleteTrigger(triggerId) {
5615
6002
  const api = createApiClient();
5616
6003
  await api.analysis.deleteTrigger(triggerId);
5617
- console.log(chalk26.green(`\u2713 Deleted trigger ${triggerId}`));
6004
+ console.log(chalk27.green(`\u2713 Deleted trigger ${triggerId}`));
5618
6005
  }
5619
6006
  async function updateTriggerCmd(triggerId, options, cmd) {
5620
6007
  const outputFormat = getOutputFormat15(cmd);
@@ -5622,13 +6009,13 @@ async function updateTriggerCmd(triggerId, options, cmd) {
5622
6009
  if (options.active !== void 0) {
5623
6010
  const lc = options.active.toLowerCase();
5624
6011
  if (lc !== "true" && lc !== "false") {
5625
- console.error(chalk26.red(`Invalid --active value "${options.active}" \u2014 must be true or false.`));
6012
+ console.error(chalk27.red(`Invalid --active value "${options.active}" \u2014 must be true or false.`));
5626
6013
  process.exit(1);
5627
6014
  }
5628
6015
  activeFlag = lc === "true";
5629
6016
  }
5630
6017
  if (activeFlag === void 0 && !options.schedule) {
5631
- console.error(chalk26.red("Pass at least one of --active or --schedule."));
6018
+ console.error(chalk27.red("Pass at least one of --active or --schedule."));
5632
6019
  process.exit(1);
5633
6020
  }
5634
6021
  const api = createApiClient();
@@ -5912,7 +6299,7 @@ function registerAnalyzeCommand(program) {
5912
6299
  }
5913
6300
 
5914
6301
  // src/commands/data-sources/index.ts
5915
- import chalk27 from "chalk";
6302
+ import chalk28 from "chalk";
5916
6303
  function getOutputFormat16(cmd) {
5917
6304
  const config = loadConfig();
5918
6305
  const globalOpts = cmd.optsWithGlobals();
@@ -6006,7 +6393,7 @@ async function listDataSources(projectId, cmd) {
6006
6393
  const api = createApiClient();
6007
6394
  const sources = await api.storage.listDataSources(projectId);
6008
6395
  if (outputFormat === "human" && sources.length === 0) {
6009
- console.log(chalk27.dim("No data sources found."));
6396
+ console.log(chalk28.dim("No data sources found."));
6010
6397
  return;
6011
6398
  }
6012
6399
  format(sources.map(dataSourceTableRow), {
@@ -6029,11 +6416,11 @@ async function showDashboard(projectId, cmd) {
6029
6416
  return;
6030
6417
  }
6031
6418
  const r = dashboard.rollup;
6032
- let line = chalk27.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
6419
+ let line = chalk28.bold(`DataSources in ${projectId}: `) + `${r.totalSources} total, ${r.scheduledSources} scheduled, ${r.sourcesWithRecentFailure} failing recently`;
6033
6420
  if (r.lastActivityAt) line += `, last activity ${r.lastActivityAt}`;
6034
6421
  console.log(line);
6035
6422
  if (dashboard.sources.length === 0) {
6036
- console.log(chalk27.dim("No data sources."));
6423
+ console.log(chalk28.dim("No data sources."));
6037
6424
  return;
6038
6425
  }
6039
6426
  format(dashboard.sources.map(dashboardTableRow), {
@@ -6056,9 +6443,9 @@ async function createDataSource(options, cmd) {
6056
6443
  };
6057
6444
  const ds = await api.storage.createDataSource(request);
6058
6445
  if (outputFormat === "human") {
6059
- console.log(chalk27.green(`\u2713 Created data source ${ds.id}`));
6060
- console.log(chalk27.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
6061
- if (ds.lastRunError) console.log(chalk27.dim(` Error: ${ds.lastRunError}`));
6446
+ console.log(chalk28.green(`\u2713 Created data source ${ds.id}`));
6447
+ console.log(chalk28.dim(` Last run: ${ds.lastRunStatus ?? "\u2014"}`));
6448
+ if (ds.lastRunError) console.log(chalk28.dim(` Error: ${ds.lastRunError}`));
6062
6449
  } else {
6063
6450
  format(ds, { format: outputFormat });
6064
6451
  }
@@ -6088,7 +6475,7 @@ async function updateDataSource(id, options, cmd) {
6088
6475
  const api = createApiClient();
6089
6476
  const ds = await api.storage.updateDataSource(id, request);
6090
6477
  if (outputFormat === "human") {
6091
- console.log(chalk27.green(`\u2713 Updated data source ${ds.id}`));
6478
+ console.log(chalk28.green(`\u2713 Updated data source ${ds.id}`));
6092
6479
  } else {
6093
6480
  format(ds, { format: outputFormat });
6094
6481
  }
@@ -6096,15 +6483,15 @@ async function updateDataSource(id, options, cmd) {
6096
6483
  async function deleteDataSource(id) {
6097
6484
  const api = createApiClient();
6098
6485
  await api.storage.deleteDataSource(id);
6099
- console.log(chalk27.green(`\u2713 Deleted data source ${id}`));
6486
+ console.log(chalk28.green(`\u2713 Deleted data source ${id}`));
6100
6487
  }
6101
6488
  async function refreshDataSource(id, cmd) {
6102
6489
  const outputFormat = getOutputFormat16(cmd);
6103
6490
  const api = createApiClient();
6104
6491
  const run = await api.storage.refreshDataSource(id);
6105
6492
  if (outputFormat === "human") {
6106
- console.log(chalk27.green(`\u2713 Refresh queued \u2014 run ${run.runId}, status ${run.status}`));
6107
- if (run.errorMessage) console.log(chalk27.red(` Error: ${run.errorMessage}`));
6493
+ console.log(chalk28.green(`\u2713 Refresh queued \u2014 run ${run.runId}, status ${run.status}`));
6494
+ if (run.errorMessage) console.log(chalk28.red(` Error: ${run.errorMessage}`));
6108
6495
  } else {
6109
6496
  format(run, { format: outputFormat });
6110
6497
  }
@@ -6114,7 +6501,7 @@ async function listRuns2(id, limit, cmd) {
6114
6501
  const api = createApiClient();
6115
6502
  const runs = await api.storage.listDataSourceRuns(id, limit);
6116
6503
  if (outputFormat === "human" && runs.length === 0) {
6117
- console.log(chalk27.dim("No runs yet."));
6504
+ console.log(chalk28.dim("No runs yet."));
6118
6505
  return;
6119
6506
  }
6120
6507
  format(runs.map(runTableRow), {
@@ -6134,7 +6521,7 @@ async function listConnectorTypes(cmd) {
6134
6521
  const types = await api.storage.listDataSourceConnectorTypes();
6135
6522
  if (outputFormat === "human") {
6136
6523
  if (types.length === 0) {
6137
- console.log(chalk27.dim("No connector types registered."));
6524
+ console.log(chalk28.dim("No connector types registered."));
6138
6525
  return;
6139
6526
  }
6140
6527
  for (const t of types) console.log(t);
@@ -6218,7 +6605,7 @@ function registerDataSourcesCommands(program) {
6218
6605
  }
6219
6606
 
6220
6607
  // src/commands/table-exporters/index.ts
6221
- import chalk28 from "chalk";
6608
+ import chalk29 from "chalk";
6222
6609
  function getOutputFormat17(cmd) {
6223
6610
  const config = loadConfig();
6224
6611
  const globalOpts = cmd.optsWithGlobals();
@@ -6249,7 +6636,7 @@ function registerTableExportersCommands(program) {
6249
6636
  format: outputFormat,
6250
6637
  columns: ["id", "name", "format", "extension", "mimeType", "priority", "function", "createdBy"]
6251
6638
  });
6252
- console.log(chalk28.dim(`${list.length} exporter(s)`));
6639
+ console.log(chalk29.dim(`${list.length} exporter(s)`));
6253
6640
  } catch (error) {
6254
6641
  handleError(error);
6255
6642
  }
@@ -6261,7 +6648,7 @@ function registerTableExportersCommands(program) {
6261
6648
  const list = await api.storage.listUserDefinedExporters();
6262
6649
  const exporter = list.find((e) => e.id === id);
6263
6650
  if (!exporter) {
6264
- console.error(chalk28.red(`No exporter with id="${id}".`));
6651
+ console.error(chalk29.red(`No exporter with id="${id}".`));
6265
6652
  process.exit(1);
6266
6653
  }
6267
6654
  format(exporter, { format: outputFormat });
@@ -6290,7 +6677,7 @@ function registerTableExportersCommands(program) {
6290
6677
  format(created, { format: outputFormat });
6291
6678
  return;
6292
6679
  }
6293
- console.log(chalk28.green(`Registered exporter "${created.name}" (id=${created.id}, format=${created.format})`));
6680
+ console.log(chalk29.green(`Registered exporter "${created.name}" (id=${created.id}, format=${created.format})`));
6294
6681
  } catch (error) {
6295
6682
  handleError(error);
6296
6683
  }
@@ -6299,7 +6686,7 @@ function registerTableExportersCommands(program) {
6299
6686
  try {
6300
6687
  const api = createApiClient();
6301
6688
  await api.storage.deleteUserDefinedExporter(id);
6302
- console.log(chalk28.green(`Deleted exporter id=${id}`));
6689
+ console.log(chalk29.green(`Deleted exporter id=${id}`));
6303
6690
  } catch (error) {
6304
6691
  handleError(error);
6305
6692
  }
@@ -6307,7 +6694,7 @@ function registerTableExportersCommands(program) {
6307
6694
  }
6308
6695
 
6309
6696
  // src/commands/skeleton/index.ts
6310
- import chalk29 from "chalk";
6697
+ import chalk30 from "chalk";
6311
6698
  import * as fs9 from "fs";
6312
6699
  function getOutputFormat18(cmd) {
6313
6700
  const config = loadConfig();
@@ -6373,11 +6760,11 @@ async function createSkeleton(options, cmd) {
6373
6760
  const api = createApiClient();
6374
6761
  const skeleton = await api.storage.createSkeleton(request);
6375
6762
  if (outputFormat === "human") {
6376
- console.log(chalk29.green(`\u2713 Created skeleton ${skeleton.id}`));
6377
- console.log(chalk29.dim(` name: ${skeleton.name}`));
6378
- console.log(chalk29.dim(` template: ${skeleton.template}`));
6379
- console.log(chalk29.dim(` paramCount: ${skeleton.paramCount}`));
6380
- console.log(chalk29.dim(` weight: ${skeleton.weight}`));
6763
+ console.log(chalk30.green(`\u2713 Created skeleton ${skeleton.id}`));
6764
+ console.log(chalk30.dim(` name: ${skeleton.name}`));
6765
+ console.log(chalk30.dim(` template: ${skeleton.template}`));
6766
+ console.log(chalk30.dim(` paramCount: ${skeleton.paramCount}`));
6767
+ console.log(chalk30.dim(` weight: ${skeleton.weight}`));
6381
6768
  } else {
6382
6769
  format(skeleton, { format: outputFormat });
6383
6770
  }
@@ -6388,7 +6775,7 @@ async function listSkeletons(localProject, cmd) {
6388
6775
  const api = createApiClient();
6389
6776
  const skeletons = await api.storage.listSkeletons(projectId);
6390
6777
  if (outputFormat === "human" && skeletons.length === 0) {
6391
- console.log(chalk29.dim(`No skeletons in project ${projectId}.`));
6778
+ console.log(chalk30.dim(`No skeletons in project ${projectId}.`));
6392
6779
  return;
6393
6780
  }
6394
6781
  format(skeletons.map(skeletonTableRow), {
@@ -6415,11 +6802,11 @@ async function updateSkeleton(id, options, cmd) {
6415
6802
  const api = createApiClient();
6416
6803
  const skeleton = await api.storage.updateSkeleton(id, request);
6417
6804
  if (outputFormat === "human") {
6418
- console.log(chalk29.green(`\u2713 Updated skeleton ${skeleton.id}`));
6419
- console.log(chalk29.dim(` name: ${skeleton.name}`));
6420
- console.log(chalk29.dim(` template: ${skeleton.template}`));
6421
- console.log(chalk29.dim(` paramCount: ${skeleton.paramCount}`));
6422
- console.log(chalk29.dim(` weight: ${skeleton.weight}`));
6805
+ console.log(chalk30.green(`\u2713 Updated skeleton ${skeleton.id}`));
6806
+ console.log(chalk30.dim(` name: ${skeleton.name}`));
6807
+ console.log(chalk30.dim(` template: ${skeleton.template}`));
6808
+ console.log(chalk30.dim(` paramCount: ${skeleton.paramCount}`));
6809
+ console.log(chalk30.dim(` weight: ${skeleton.weight}`));
6423
6810
  } else {
6424
6811
  format(skeleton, { format: outputFormat });
6425
6812
  }
@@ -6427,7 +6814,7 @@ async function updateSkeleton(id, options, cmd) {
6427
6814
  async function deleteSkeleton(id) {
6428
6815
  const api = createApiClient();
6429
6816
  await api.storage.deleteSkeleton(id);
6430
- console.log(chalk29.green(`\u2713 Deleted skeleton ${id}`));
6817
+ console.log(chalk30.green(`\u2713 Deleted skeleton ${id}`));
6431
6818
  }
6432
6819
  function registerSkeletonCommands(program) {
6433
6820
  const skeleton = program.command("skeleton").description("Manage user-provided skeleton templates (project-scoped, capped at 100/project)");
@@ -6479,7 +6866,7 @@ _diafunc_completions() {
6479
6866
  cur="\${COMP_WORDS[COMP_CWORD]}"
6480
6867
  prev="\${COMP_WORDS[COMP_CWORD-1]}"
6481
6868
 
6482
- commands="auth config project entity link event branch table function trigger schedule chat search group admin analyze help"
6869
+ commands="auth config project team entity link event branch table function trigger schedule chat search admin analyze help"
6483
6870
 
6484
6871
  case "\${COMP_WORDS[1]}" in
6485
6872
  auth)
@@ -6549,11 +6936,13 @@ _diafunc_completions() {
6549
6936
  COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}"))
6550
6937
  fi
6551
6938
  ;;
6552
- group)
6553
- subcommands="list get create delete members projects"
6939
+ team)
6940
+ subcommands="list get use usage create portal cancel leave members invitations seats packs transfer"
6554
6941
  case "\${COMP_WORDS[2]}" in
6555
6942
  members) COMPREPLY=($(compgen -W "list invite remove" -- "\${cur}")) ;;
6556
- projects) COMPREPLY=($(compgen -W "list add remove" -- "\${cur}")) ;;
6943
+ invitations) COMPREPLY=($(compgen -W "list revoke resend accept" -- "\${cur}")) ;;
6944
+ seats|packs) COMPREPLY=($(compgen -W "preview set" -- "\${cur}")) ;;
6945
+ transfer) COMPREPLY=($(compgen -W "start status accept cancel" -- "\${cur}")) ;;
6557
6946
  *) COMPREPLY=($(compgen -W "\${subcommands}" -- "\${cur}")) ;;
6558
6947
  esac
6559
6948
  ;;
@@ -6580,6 +6969,7 @@ _diafunc() {
6580
6969
  'auth:Authentication and credential management'
6581
6970
  'config:Manage CLI configuration'
6582
6971
  'project:Manage projects'
6972
+ 'team:Manage teams'
6583
6973
  'entity:Manage entities'
6584
6974
  'link:Manage links between entities'
6585
6975
  'event:Manage events'
@@ -6590,7 +6980,6 @@ _diafunc() {
6590
6980
  'schedule:Schedule function execution'
6591
6981
  'chat:AI chat'
6592
6982
  'search:Search entities across projects'
6593
- 'group:Manage groups'
6594
6983
  'admin:Administration commands'
6595
6984
  'analyze:Run an automatic analysis on a data file'
6596
6985
  )
@@ -6614,6 +7003,7 @@ _diafunc() {
6614
7003
  auth) _diafunc_auth ;;
6615
7004
  config) _diafunc_config ;;
6616
7005
  project) _diafunc_project ;;
7006
+ team) _diafunc_team ;;
6617
7007
  entity) _diafunc_entity ;;
6618
7008
  link) _values 'subcommand' list create delete ;;
6619
7009
  event) _values 'subcommand' list get delete ;;
@@ -6623,7 +7013,6 @@ _diafunc() {
6623
7013
  trigger) _values 'subcommand' list get delete ;;
6624
7014
  schedule) _values 'subcommand' call ;;
6625
7015
  chat) _diafunc_chat ;;
6626
- group) _diafunc_group ;;
6627
7016
  admin) _diafunc_admin ;;
6628
7017
  analyze) _files '*.csv' '*.xlsx' '*.xls' ;;
6629
7018
  esac
@@ -6634,15 +7023,15 @@ _diafunc() {
6634
7023
  _diafunc_auth() { _values 'subcommand' login logout status token; }
6635
7024
  _diafunc_config() { _values 'subcommand' set get list profile; }
6636
7025
  _diafunc_project() { _values 'subcommand' list get create delete lock unlock members; }
7026
+ _diafunc_team() { _values 'subcommand' list get use usage create portal cancel leave members invitations seats packs transfer; }
6637
7027
  _diafunc_entity() { _values 'subcommand' list get delete history revert rename content; }
6638
7028
  _diafunc_table() { _values 'subcommand' view import export row column cell clear; }
6639
7029
  _diafunc_chat() { _values 'subcommand' send stream upload session usage; }
6640
- _diafunc_group() { _values 'subcommand' list get create delete members projects; }
6641
7030
  _diafunc_admin() { _values 'subcommand' users subscription settings backup; }
6642
7031
 
6643
7032
  _diafunc "$@"`;
6644
7033
  var FISH_COMPLETION = `# Fish completions for diafunc
6645
- set -l commands auth config project entity link event branch table function trigger schedule chat search group admin analyze
7034
+ set -l commands auth config project team entity link event branch table function trigger schedule chat search admin analyze
6646
7035
 
6647
7036
  # Disable file completions by default
6648
7037
  complete -c diafunc -f
@@ -6651,6 +7040,7 @@ complete -c diafunc -f
6651
7040
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a auth -d "Authentication and credential management"
6652
7041
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a config -d "Manage CLI configuration"
6653
7042
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a project -d "Manage projects"
7043
+ complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a team -d "Manage teams"
6654
7044
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a entity -d "Manage entities"
6655
7045
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a link -d "Manage links between entities"
6656
7046
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a event -d "Manage events"
@@ -6661,7 +7051,6 @@ complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a trigger -d
6661
7051
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a schedule -d "Schedule function execution"
6662
7052
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a chat -d "AI chat"
6663
7053
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a search -d "Search entities"
6664
- complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a group -d "Manage groups"
6665
7054
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a admin -d "Administration commands"
6666
7055
  complete -c diafunc -n "not __fish_seen_subcommand_from $commands" -a analyze -d "Run automatic analysis"
6667
7056
 
@@ -6698,8 +7087,11 @@ complete -c diafunc -n "__fish_seen_subcommand_from function; and not __fish_see
6698
7087
  # chat
6699
7088
  complete -c diafunc -n "__fish_seen_subcommand_from chat; and not __fish_seen_subcommand_from send stream upload session usage" -a "send stream upload session usage"
6700
7089
 
6701
- # group
6702
- complete -c diafunc -n "__fish_seen_subcommand_from group; and not __fish_seen_subcommand_from list get create delete members projects" -a "list get create delete members projects"
7090
+ # team
7091
+ complete -c diafunc -n "__fish_seen_subcommand_from team; and not __fish_seen_subcommand_from list get use usage create portal cancel leave members invitations seats packs transfer" -a "list get use usage create portal cancel leave members invitations seats packs transfer"
7092
+ complete -c diafunc -n "__fish_seen_subcommand_from invitations; and not __fish_seen_subcommand_from list revoke resend accept" -a "list revoke resend accept"
7093
+ complete -c diafunc -n "__fish_seen_subcommand_from seats packs; and not __fish_seen_subcommand_from preview set" -a "preview set"
7094
+ complete -c diafunc -n "__fish_seen_subcommand_from transfer; and not __fish_seen_subcommand_from start status accept cancel" -a "start status accept cancel"
6703
7095
 
6704
7096
  # admin
6705
7097
  complete -c diafunc -n "__fish_seen_subcommand_from admin; and not __fish_seen_subcommand_from users subscription settings backup" -a "users subscription settings backup"
@@ -6726,7 +7118,7 @@ function registerCompletionCommand(program) {
6726
7118
  }
6727
7119
 
6728
7120
  // src/commands/whoami/index.ts
6729
- import chalk30 from "chalk";
7121
+ import chalk31 from "chalk";
6730
7122
  function registerWhoamiCommand(program) {
6731
7123
  program.command("whoami").description("Show the currently authenticated user").action(async (_options, cmd) => {
6732
7124
  try {
@@ -6736,8 +7128,8 @@ function registerWhoamiCommand(program) {
6736
7128
  const api = createApiClient();
6737
7129
  const user = await api.admin.getMyUser();
6738
7130
  if (outputFormat === "human") {
6739
- console.log(chalk30.bold(user.name) + chalk30.dim(` <${user.email}>`));
6740
- console.log(chalk30.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
7131
+ console.log(chalk31.bold(user.name) + chalk31.dim(` <${user.email}>`));
7132
+ console.log(chalk31.dim(` Role: ${user.role} \xB7 Remaining credits: ${user.remainingCredits} \xB7 Profile: ${config.currentProfile}`));
6741
7133
  } else {
6742
7134
  format(user, { format: outputFormat });
6743
7135
  }
@@ -6748,7 +7140,7 @@ function registerWhoamiCommand(program) {
6748
7140
  }
6749
7141
 
6750
7142
  // src/commands/utilization/index.ts
6751
- import chalk31 from "chalk";
7143
+ import chalk32 from "chalk";
6752
7144
  function getOutputFormat19(cmd) {
6753
7145
  const config = loadConfig();
6754
7146
  const globalOpts = cmd.optsWithGlobals();
@@ -6757,21 +7149,21 @@ function getOutputFormat19(cmd) {
6757
7149
  function printUtilizationHuman(u, label) {
6758
7150
  const when = u.day !== null && u.day !== void 0 ? `${u.year}-${String(u.month).padStart(2, "0")}-${String(u.day).padStart(2, "0")}` : `${u.year}-${String(u.month).padStart(2, "0")}`;
6759
7151
  if (label) {
6760
- console.log(chalk31.bold(label) + " " + chalk31.dim(when));
7152
+ console.log(chalk32.bold(label) + " " + chalk32.dim(when));
6761
7153
  } else {
6762
- console.log(chalk31.bold(when));
7154
+ console.log(chalk32.bold(when));
6763
7155
  }
6764
7156
  if (u.types.length === 0) {
6765
- console.log(chalk31.dim(" (no usage)"));
7157
+ console.log(chalk32.dim(" (no usage)"));
6766
7158
  return;
6767
7159
  }
6768
7160
  for (const t of u.types) {
6769
7161
  console.log(
6770
- ` ${t.type.padEnd(24)} ${chalk31.cyan(String(t.quantity).padStart(10))} ${chalk31.dim("credits:")} ${t.credits.toFixed(2)}`
7162
+ ` ${t.type.padEnd(24)} ${chalk32.cyan(String(t.quantity).padStart(10))} ${chalk32.dim("credits:")} ${t.credits.toFixed(2)}`
6771
7163
  );
6772
7164
  }
6773
7165
  const total = u.totalCredits ?? u.types.reduce((s, t) => s + t.credits, 0);
6774
- console.log(chalk31.bold(` Total credits: ${total.toFixed(2)}`));
7166
+ console.log(chalk32.bold(` Total credits: ${total.toFixed(2)}`));
6775
7167
  }
6776
7168
  function registerUtilizationCommand(program) {
6777
7169
  const util = program.command("utilization").description("Show credit utilization");
@@ -6796,7 +7188,7 @@ function registerUtilizationCommand(program) {
6796
7188
  const history = await api.admin.getUtilizationHistory();
6797
7189
  if (outputFormat === "human") {
6798
7190
  if (history.length === 0) {
6799
- console.log(chalk31.dim("No usage recorded."));
7191
+ console.log(chalk32.dim("No usage recorded."));
6800
7192
  return;
6801
7193
  }
6802
7194
  for (const u of history) {
@@ -6813,7 +7205,7 @@ function registerUtilizationCommand(program) {
6813
7205
  }
6814
7206
 
6815
7207
  // src/commands/entity-branch/index.ts
6816
- import chalk32 from "chalk";
7208
+ import chalk33 from "chalk";
6817
7209
  function getOutputFormat20(cmd) {
6818
7210
  const config = loadConfig();
6819
7211
  const globalOpts = cmd.optsWithGlobals();
@@ -6857,7 +7249,7 @@ function registerEntityBranchCommands(program) {
6857
7249
  sourceEntityBranch: resolved.entityBranch,
6858
7250
  targetEntityBranch: targetBranch
6859
7251
  });
6860
- console.log(chalk32.green(`Entity branch "${targetBranch}" created from "${resolved.entityBranch}".`));
7252
+ console.log(chalk33.green(`Entity branch "${targetBranch}" created from "${resolved.entityBranch}".`));
6861
7253
  } catch (error) {
6862
7254
  handleError(error);
6863
7255
  }
@@ -6902,7 +7294,7 @@ function registerSubscriptionCommand(program) {
6902
7294
  }
6903
7295
 
6904
7296
  // src/commands/invoice/index.ts
6905
- import chalk33 from "chalk";
7297
+ import chalk34 from "chalk";
6906
7298
  import * as fs10 from "fs";
6907
7299
  function getOutputFormat22(cmd) {
6908
7300
  const config = loadConfig();
@@ -6930,7 +7322,7 @@ function registerInvoiceCommand(program) {
6930
7322
  const buffer = Buffer.from(await response.arrayBuffer());
6931
7323
  const outPath = options.out ?? fileName;
6932
7324
  fs10.writeFileSync(outPath, buffer);
6933
- console.log(chalk33.green(`Invoice saved to ${outPath}`));
7325
+ console.log(chalk34.green(`Invoice saved to ${outPath}`));
6934
7326
  } catch (error) {
6935
7327
  handleError(error);
6936
7328
  }
@@ -6938,7 +7330,7 @@ function registerInvoiceCommand(program) {
6938
7330
  }
6939
7331
 
6940
7332
  // src/commands/shell/index.ts
6941
- import chalk34 from "chalk";
7333
+ import chalk35 from "chalk";
6942
7334
  import * as fs11 from "fs";
6943
7335
  import * as os3 from "os";
6944
7336
  import * as path8 from "path";
@@ -7004,21 +7396,21 @@ async function evaluate(api, fnRef, language, sourceCode) {
7004
7396
  }, false);
7005
7397
  if (result.outputs?.length) {
7006
7398
  for (const out of result.outputs) {
7007
- console.log(chalk34.dim(` [${out.type}]`) + " " + out.output);
7399
+ console.log(chalk35.dim(` [${out.type}]`) + " " + out.output);
7008
7400
  }
7009
7401
  }
7010
7402
  if (result.successful) {
7011
7403
  if (result.result) {
7012
- console.log(chalk34.green("=> ") + result.result);
7404
+ console.log(chalk35.green("=> ") + result.result);
7013
7405
  } else {
7014
- console.log(chalk34.dim("=> (no value)"));
7406
+ console.log(chalk35.dim("=> (no value)"));
7015
7407
  }
7016
7408
  const duration = result.completed - result.started;
7017
- console.log(chalk34.dim(` [${duration}ms \xB7 ${evaluationId}]`));
7409
+ console.log(chalk35.dim(` [${duration}ms \xB7 ${evaluationId}]`));
7018
7410
  } else {
7019
- console.log(chalk34.red("error: ") + result.error);
7411
+ console.log(chalk35.red("error: ") + result.error);
7020
7412
  if (result.lineNumber > 0) {
7021
- console.log(chalk34.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
7413
+ console.log(chalk35.dim(` at line ${result.lineNumber}, col ${result.columnNumber}`));
7022
7414
  }
7023
7415
  }
7024
7416
  }
@@ -7026,9 +7418,9 @@ function registerShellCommand(program) {
7026
7418
  program.command("shell").description("Interactive REPL for function code evaluation").option("--function <ref>", "Function entity reference to use as scratch (required)").option("--language <lang>", "Source language", "JavaScript").action(async (options, cmd) => {
7027
7419
  try {
7028
7420
  if (!options.function) {
7029
- console.error(chalk34.red("Missing --function <ref>."));
7030
- console.error(chalk34.dim("Pass an existing or new function entity reference to use as the shell target."));
7031
- console.error(chalk34.dim("Example: diafunc shell --function my-project/main/scratch/main --language JavaScript"));
7421
+ console.error(chalk35.red("Missing --function <ref>."));
7422
+ console.error(chalk35.dim("Pass an existing or new function entity reference to use as the shell target."));
7423
+ console.error(chalk35.dim("Example: diafunc shell --function my-project/main/scratch/main --language JavaScript"));
7032
7424
  process.exit(1);
7033
7425
  }
7034
7426
  const config = loadConfig();
@@ -7039,18 +7431,18 @@ function registerShellCommand(program) {
7039
7431
  });
7040
7432
  const api = createApiClient();
7041
7433
  const { input: promptInput } = await import("@inquirer/prompts");
7042
- const { getUpdateNotice } = await import("./update-check-2X2AIL52.js");
7043
- console.log(chalk34.bold("Diafunc shell") + chalk34.dim(` \xB7 function ${fnRef.entityId} \xB7 ${options.language}`));
7044
- console.log(chalk34.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
7045
- console.log(chalk34.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
7434
+ const { getUpdateNotice } = await import("./update-check-UOHMHDN6.js");
7435
+ console.log(chalk35.bold("Diafunc shell") + chalk35.dim(` \xB7 function ${fnRef.entityId} \xB7 ${options.language}`));
7436
+ console.log(chalk35.dim(`Endpoint: ${config.profiles[config.currentProfile]?.endpoint}`));
7437
+ console.log(chalk35.dim("Commands: /edit (multi-line in $EDITOR), /lang <name>, /file <path>, /help, /quit"));
7046
7438
  const notice = await getUpdateNotice();
7047
- if (notice) console.log(chalk34.dim(notice));
7439
+ if (notice) console.log(chalk35.dim(notice));
7048
7440
  console.log();
7049
7441
  let language = options.language;
7050
7442
  for (; ; ) {
7051
7443
  let line;
7052
7444
  try {
7053
- line = await promptInput({ message: chalk34.cyan.bold(`${language} >`) });
7445
+ line = await promptInput({ message: chalk35.cyan.bold(`${language} >`) });
7054
7446
  } catch {
7055
7447
  console.log();
7056
7448
  return;
@@ -7068,54 +7460,54 @@ function registerShellCommand(program) {
7068
7460
  case "help":
7069
7461
  case "h":
7070
7462
  case "?":
7071
- console.log(chalk34.dim(" /edit open $EDITOR for multi-line code"));
7072
- console.log(chalk34.dim(" /file <path> evaluate the contents of a file"));
7073
- console.log(chalk34.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
7074
- console.log(chalk34.dim(" /quit exit the shell"));
7463
+ console.log(chalk35.dim(" /edit open $EDITOR for multi-line code"));
7464
+ console.log(chalk35.dim(" /file <path> evaluate the contents of a file"));
7465
+ console.log(chalk35.dim(" /lang <name> switch language (Java, JavaScript, Kotlin, Python, Scala)"));
7466
+ console.log(chalk35.dim(" /quit exit the shell"));
7075
7467
  continue;
7076
7468
  case "lang":
7077
7469
  if (arg) language = arg;
7078
- console.log(chalk34.dim(`Language: ${language}`));
7470
+ console.log(chalk35.dim(`Language: ${language}`));
7079
7471
  continue;
7080
7472
  case "edit": {
7081
7473
  const sourceCode = await openInEditor("", extensionFor2(language));
7082
7474
  if (!sourceCode.trim()) {
7083
- console.log(chalk34.dim("(empty \u2014 not evaluated)"));
7475
+ console.log(chalk35.dim("(empty \u2014 not evaluated)"));
7084
7476
  continue;
7085
7477
  }
7086
7478
  try {
7087
7479
  await evaluate(api, fnRef, language, sourceCode);
7088
7480
  } catch (e) {
7089
- console.error(chalk34.red(e.message));
7481
+ console.error(chalk35.red(e.message));
7090
7482
  }
7091
7483
  continue;
7092
7484
  }
7093
7485
  case "file": {
7094
7486
  if (!arg) {
7095
- console.log(chalk34.dim("usage: /file <path>"));
7487
+ console.log(chalk35.dim("usage: /file <path>"));
7096
7488
  continue;
7097
7489
  }
7098
7490
  if (!fs11.existsSync(arg)) {
7099
- console.log(chalk34.red(`file not found: ${arg}`));
7491
+ console.log(chalk35.red(`file not found: ${arg}`));
7100
7492
  continue;
7101
7493
  }
7102
7494
  const sourceCode = fs11.readFileSync(arg, "utf-8");
7103
7495
  try {
7104
7496
  await evaluate(api, fnRef, language, sourceCode);
7105
7497
  } catch (e) {
7106
- console.error(chalk34.red(e.message));
7498
+ console.error(chalk35.red(e.message));
7107
7499
  }
7108
7500
  continue;
7109
7501
  }
7110
7502
  default:
7111
- console.log(chalk34.dim(`Unknown command: /${cmd2}. Try /help.`));
7503
+ console.log(chalk35.dim(`Unknown command: /${cmd2}. Try /help.`));
7112
7504
  continue;
7113
7505
  }
7114
7506
  }
7115
7507
  try {
7116
7508
  await evaluate(api, fnRef, language, trimmed);
7117
7509
  } catch (e) {
7118
- console.error(chalk34.red(e.message));
7510
+ console.error(chalk35.red(e.message));
7119
7511
  }
7120
7512
  }
7121
7513
  } catch (error) {
@@ -7125,7 +7517,7 @@ function registerShellCommand(program) {
7125
7517
  }
7126
7518
 
7127
7519
  // src/commands/update/index.ts
7128
- import chalk35 from "chalk";
7520
+ import chalk36 from "chalk";
7129
7521
  import * as path9 from "path";
7130
7522
  import { spawn as spawn4 } from "child_process";
7131
7523
 
@@ -7171,14 +7563,14 @@ function registerUpdateCommand(program) {
7171
7563
  const install = detectInstall();
7172
7564
  const latest = await fetchLatestVersion();
7173
7565
  if (latest === package_default.version) {
7174
- console.log(chalk35.dim(`diafunc is already at the latest version (${package_default.version}).`));
7566
+ console.log(chalk36.dim(`diafunc is already at the latest version (${package_default.version}).`));
7175
7567
  return;
7176
7568
  }
7177
- console.log(chalk35.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
7569
+ console.log(chalk36.dim(`Current: ${package_default.version} \u2192 Available: ${latest}`));
7178
7570
  if (install.method === "npm") {
7179
7571
  console.log();
7180
7572
  console.log("Installed via npm. Upgrade with:");
7181
- console.log(chalk35.bold(` npm install -g @diafunc/cli@${latest}`));
7573
+ console.log(chalk36.bold(` npm install -g @diafunc/cli@${latest}`));
7182
7574
  return;
7183
7575
  }
7184
7576
  const installDir = path9.dirname(install.binaryPath);
@@ -7192,7 +7584,7 @@ function registerUpdateCommand(program) {
7192
7584
  }
7193
7585
 
7194
7586
  // src/commands/uninstall/index.ts
7195
- import chalk36 from "chalk";
7587
+ import chalk37 from "chalk";
7196
7588
  import { spawn as spawn5 } from "child_process";
7197
7589
  import * as fs13 from "fs";
7198
7590
  import * as os4 from "os";
@@ -7204,11 +7596,11 @@ function registerUninstallCommand(program) {
7204
7596
  const configDir = path10.join(os4.homedir(), ".diafunc");
7205
7597
  if (install.method === "npm") {
7206
7598
  console.log("Installed via npm. Remove with:");
7207
- console.log(chalk36.bold(" npm uninstall -g @diafunc/cli"));
7599
+ console.log(chalk37.bold(" npm uninstall -g @diafunc/cli"));
7208
7600
  if (fs13.existsSync(configDir)) {
7209
7601
  console.log();
7210
7602
  console.log(`Config + credentials live at ${configDir} \u2014 remove manually with:`);
7211
- console.log(chalk36.bold(` rm -rf ${configDir}`));
7603
+ console.log(chalk37.bold(` rm -rf ${configDir}`));
7212
7604
  }
7213
7605
  return;
7214
7606
  }
@@ -7218,7 +7610,7 @@ function registerUninstallCommand(program) {
7218
7610
  default: false
7219
7611
  });
7220
7612
  if (!removeBinary) {
7221
- console.log(chalk36.dim("Aborted."));
7613
+ console.log(chalk37.dim("Aborted."));
7222
7614
  return;
7223
7615
  }
7224
7616
  let removeConfig = options.purge ?? false;
@@ -7230,7 +7622,7 @@ function registerUninstallCommand(program) {
7230
7622
  }
7231
7623
  if (removeConfig && fs13.existsSync(configDir)) {
7232
7624
  fs13.rmSync(configDir, { recursive: true, force: true });
7233
- console.log(chalk36.dim(`Removed ${configDir}`));
7625
+ console.log(chalk37.dim(`Removed ${configDir}`));
7234
7626
  }
7235
7627
  if (process.platform === "win32") {
7236
7628
  const cmd = `timeout /t 2 /nobreak >nul & del /f /q "${install.binaryPath}"`;
@@ -7240,13 +7632,13 @@ function registerUninstallCommand(program) {
7240
7632
  windowsHide: true
7241
7633
  });
7242
7634
  child.unref();
7243
- console.log(chalk36.dim(`Removing ${install.binaryPath} on exit...`));
7635
+ console.log(chalk37.dim(`Removing ${install.binaryPath} on exit...`));
7244
7636
  console.log();
7245
7637
  console.log("diafunc uninstalled.");
7246
7638
  return;
7247
7639
  }
7248
7640
  fs13.rmSync(install.binaryPath, { force: true });
7249
- console.log(chalk36.dim(`Removed ${install.binaryPath}`));
7641
+ console.log(chalk37.dim(`Removed ${install.binaryPath}`));
7250
7642
  console.log();
7251
7643
  console.log("diafunc uninstalled.");
7252
7644
  } catch (error) {
@@ -7267,6 +7659,7 @@ function createProgram() {
7267
7659
  registerAuthCommands(program);
7268
7660
  registerConfigCommands(program);
7269
7661
  registerProjectCommands(program);
7662
+ registerTeamCommands(program);
7270
7663
  registerEntityCommands(program);
7271
7664
  registerLinkCommands(program);
7272
7665
  registerEventCommands(program);
@@ -7278,7 +7671,6 @@ function createProgram() {
7278
7671
  registerScheduleCommands(program);
7279
7672
  registerChatCommands(program);
7280
7673
  registerSearchCommands(program);
7281
- registerGroupCommands(program);
7282
7674
  registerAdminCommands(program);
7283
7675
  registerStatusCommands(program);
7284
7676
  registerAnalyzeCommand(program);
@@ -7300,4 +7692,4 @@ function createProgram() {
7300
7692
  export {
7301
7693
  createProgram
7302
7694
  };
7303
- //# sourceMappingURL=chunk-WHWVHDRF.js.map
7695
+ //# sourceMappingURL=chunk-LTQLKVDU.js.map