@genfeedai/cli 0.2.1 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +57 -30
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -29515,6 +29515,13 @@ async function setActiveBrand(brandId, profileName) {
29515
29515
  async function clearActiveBrand(profileName) {
29516
29516
  await setProfileField("activeBrand", undefined, profileName);
29517
29517
  }
29518
+ async function getOrganizationId() {
29519
+ const { profile } = await getActiveProfile();
29520
+ return profile.organizationId;
29521
+ }
29522
+ async function setOrganizationId(organizationId, profileName) {
29523
+ await setProfileField("organizationId", organizationId, profileName);
29524
+ }
29518
29525
  async function setRole(role, profileName) {
29519
29526
  await setProfileField("role", role, profileName);
29520
29527
  }
@@ -29672,8 +29679,8 @@ async function requireAuth() {
29672
29679
  }
29673
29680
 
29674
29681
  // src/api/brands.ts
29675
- async function listBrands() {
29676
- const response = await get("/brands");
29682
+ async function listBrands(organizationId) {
29683
+ const response = await get(`/organizations/${organizationId}/brands`);
29677
29684
  return response.data;
29678
29685
  }
29679
29686
  async function getBrand(id) {
@@ -29727,8 +29734,12 @@ function printJson(data) {
29727
29734
  var brandsCommand = new Command("brands").description("Manage brands").option("--json", "Output as JSON").action(async (options) => {
29728
29735
  try {
29729
29736
  await requireAuth();
29737
+ const orgId = await getOrganizationId();
29738
+ if (!orgId) {
29739
+ throw new GenfeedError("No organization found", "Re-authenticate with `gf login` to link your organization");
29740
+ }
29730
29741
  const spinner = ora("Fetching brands...").start();
29731
- const brands = await listBrands();
29742
+ const brands = await listBrands(orgId);
29732
29743
  spinner.stop();
29733
29744
  const activeBrandId = await getActiveBrand();
29734
29745
  if (options.json) {
@@ -29769,8 +29780,12 @@ var brandsCommand = new Command("brands").description("Manage brands").option("-
29769
29780
  brandsCommand.command("select").description("Select the active brand").action(async () => {
29770
29781
  try {
29771
29782
  await requireAuth();
29783
+ const orgId = await getOrganizationId();
29784
+ if (!orgId) {
29785
+ throw new GenfeedError("No organization found", "Re-authenticate with `gf login` to link your organization");
29786
+ }
29772
29787
  const spinner = ora("Fetching brands...").start();
29773
- const brands = await listBrands();
29788
+ const brands = await listBrands(orgId);
29774
29789
  spinner.stop();
29775
29790
  if (brands.length === 0) {
29776
29791
  throw new GenfeedError("No brands found", "Create a brand at https://app.genfeed.ai");
@@ -30008,7 +30023,7 @@ var chatCommand = new Command("chat").description("Start an interactive agent ch
30008
30023
  if (!conversationId) {
30009
30024
  const spinner = ora("Starting new conversation...").start();
30010
30025
  try {
30011
- const conversation = await post("/v1/agent-conversations", {
30026
+ const conversation = await post("/agent/conversations", {
30012
30027
  source: "cli",
30013
30028
  title: "CLI Chat"
30014
30029
  });
@@ -30029,7 +30044,7 @@ var chatCommand = new Command("chat").description("Start an interactive agent ch
30029
30044
  continue;
30030
30045
  const spinner = ora("Thinking...").start();
30031
30046
  try {
30032
- const response = await post(`/v1/agent-conversations/${conversationId}/messages`, { content: message, role: "user" });
30047
+ const response = await post(`/agent/conversations/${conversationId}/messages`, { content: message, role: "user" });
30033
30048
  spinner.stop();
30034
30049
  const messages = response.messages ?? [];
30035
30050
  const lastMessage = messages[messages.length - 1];
@@ -33485,7 +33500,7 @@ var libraryCommand = new Command("library").description("Browse content library"
33485
33500
  if (options.type)
33486
33501
  params.set("category", options.type);
33487
33502
  params.set("limit", options.limit);
33488
- const response = await get(`/v1/ingredients?${params.toString()}`);
33503
+ const response = await get(`/ingredients?${params.toString()}`);
33489
33504
  spinner.stop();
33490
33505
  const items = response.data ?? [];
33491
33506
  if (items.length === 0) {
@@ -33567,8 +33582,15 @@ function waitForOAuthCallback() {
33567
33582
  }, CALLBACK_TIMEOUT);
33568
33583
  function cleanup() {
33569
33584
  clearTimeout(timeout);
33585
+ process.removeListener("SIGINT", onSigint);
33570
33586
  server.close();
33571
33587
  }
33588
+ function onSigint() {
33589
+ cleanup();
33590
+ reject(new GenfeedError("Authentication cancelled"));
33591
+ process.exit(130);
33592
+ }
33593
+ process.on("SIGINT", onSigint);
33572
33594
  server.listen(0, "127.0.0.1", () => {
33573
33595
  const addr = server.address();
33574
33596
  if (addr && typeof addr === "object") {
@@ -33627,6 +33649,7 @@ async function completeLogin(apiKey) {
33627
33649
  try {
33628
33650
  const whoamiData = await validateApiKey();
33629
33651
  spinner.succeed();
33652
+ await setOrganizationId(whoamiData.organization.id);
33630
33653
  print();
33631
33654
  print(formatSuccess(`Logged in as ${source_default.bold(whoamiData.organization.name)}`));
33632
33655
  print(formatLabel("Email", whoamiData.user.email));
@@ -33636,25 +33659,29 @@ async function completeLogin(apiKey) {
33636
33659
  print(formatLabel("Role", source_default.green("admin")));
33637
33660
  }
33638
33661
  print();
33639
- const brands = await listBrands();
33640
- if (brands.length === 0) {
33641
- print(formatWarning("No brands found. Create one at https://app.genfeed.ai"));
33642
- } else if (brands.length === 1) {
33643
- await setActiveBrand(brands[0].id);
33644
- print(formatSuccess(`Active brand: ${source_default.bold(brands[0].name)}`));
33645
- } else {
33646
- const selected = await dist_default5({
33647
- choices: brands.map((brand) => ({
33648
- description: brand.description,
33649
- name: brand.name,
33650
- value: brand.id
33651
- })),
33652
- message: "Select a brand:"
33653
- });
33654
- await setActiveBrand(selected);
33655
- const selectedBrand = brands.find((b) => b.id === selected);
33656
- print();
33657
- print(formatSuccess(`Active brand: ${source_default.bold(selectedBrand?.name)}`));
33662
+ try {
33663
+ const brands = await listBrands(whoamiData.organization.id);
33664
+ if (brands.length === 0) {
33665
+ print(formatWarning("No brands found. Create one at https://app.genfeed.ai"));
33666
+ } else if (brands.length === 1) {
33667
+ await setActiveBrand(brands[0].id);
33668
+ print(formatSuccess(`Active brand: ${source_default.bold(brands[0].name)}`));
33669
+ } else {
33670
+ const selected = await dist_default5({
33671
+ choices: brands.map((brand) => ({
33672
+ description: brand.description,
33673
+ name: brand.name,
33674
+ value: brand.id
33675
+ })),
33676
+ message: "Select a brand:"
33677
+ });
33678
+ await setActiveBrand(selected);
33679
+ const selectedBrand = brands.find((b) => b.id === selected);
33680
+ print();
33681
+ print(formatSuccess(`Active brand: ${source_default.bold(selectedBrand?.name)}`));
33682
+ }
33683
+ } catch {
33684
+ print(formatWarning("Could not fetch brands. Set one later with `gf brands`"));
33658
33685
  }
33659
33686
  } catch (error49) {
33660
33687
  spinner.fail("Invalid API key");
@@ -33897,7 +33924,7 @@ var publishCommand = new Command("publish").description("Publish content to soci
33897
33924
  }
33898
33925
  const spinner = ora(`Publishing to ${platforms.join(", ")}...`).start();
33899
33926
  try {
33900
- await post("/v1/posts", {
33927
+ await post("/posts", {
33901
33928
  caption,
33902
33929
  ingredientId,
33903
33930
  platforms
@@ -34196,7 +34223,7 @@ var workflowCommand = new Command("workflow").description("Manage and execute wo
34196
34223
  await requireAuth();
34197
34224
  const spinner = ora("Fetching workflows...").start();
34198
34225
  try {
34199
- const response = await get("/v1/workflows");
34226
+ const response = await get("/workflows");
34200
34227
  spinner.stop();
34201
34228
  const workflows = response.data ?? [];
34202
34229
  if (workflows.length === 0) {
@@ -34229,7 +34256,7 @@ Workflows:
34229
34256
  await requireAuth();
34230
34257
  const spinner = ora("Executing workflow...").start();
34231
34258
  try {
34232
- const response = await post("/v1/workflow-executions", {
34259
+ const response = await post("/workflow-executions", {
34233
34260
  workflowId: id
34234
34261
  });
34235
34262
  spinner.succeed("Workflow execution started");
@@ -34252,7 +34279,7 @@ var BANNER = source_default.hex("#7C3AED").bold(`
34252
34279
  ██████ ██
34253
34280
  `);
34254
34281
  var program2 = new Command;
34255
- program2.name("gf").description("Unified CLI for Genfeed.ai").version("0.2.0").addCommand(loginCommand).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(brandsCommand).addCommand(generateCommand).addCommand(statusCommand).addCommand(chatCommand).addCommand(workflowCommand).addCommand(publishCommand).addCommand(libraryCommand).addCommand(profileCommand);
34282
+ program2.name("gf").description("Unified CLI for Genfeed.ai").version("0.3.0").addCommand(loginCommand).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(brandsCommand).addCommand(generateCommand).addCommand(statusCommand).addCommand(chatCommand).addCommand(workflowCommand).addCommand(publishCommand).addCommand(libraryCommand).addCommand(profileCommand);
34256
34283
  program2.addCommand(darkroomCommand).addCommand(trainCommand).addCommand(personasCommand).addCommand(captionCommand).addCommand(datasetCommand);
34257
34284
  program2.exitOverride();
34258
34285
  async function printBanner() {
package/package.json CHANGED
@@ -71,5 +71,5 @@
71
71
  "typecheck": "tsc --noEmit"
72
72
  },
73
73
  "type": "module",
74
- "version": "0.2.1"
74
+ "version": "0.3.0"
75
75
  }