@inkeep/agents-cli 0.13.0 → 0.14.1

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 +489 -371
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -41,6 +41,25 @@ var init_esm_shims = __esm({
41
41
  }
42
42
  });
43
43
 
44
+ // ../packages/agents-core/src/api-client/base-client.ts
45
+ async function apiFetch(url, options = {}) {
46
+ const headers = {
47
+ "Content-Type": "application/json",
48
+ Accept: "application/json",
49
+ ...options.headers || {}
50
+ };
51
+ return fetch(url, {
52
+ ...options,
53
+ headers
54
+ });
55
+ }
56
+ var init_base_client = __esm({
57
+ "../packages/agents-core/src/api-client/base-client.ts"() {
58
+ "use strict";
59
+ init_esm_shims();
60
+ }
61
+ });
62
+
44
63
  // ../packages/agents-core/src/utils/logger.ts
45
64
  import pino from "pino";
46
65
  import pinoPretty from "pino-pretty";
@@ -2690,6 +2709,8 @@ var init_schemas = __esm({
2690
2709
  ExternalAgentApiInsertSchema.extend({ type: z.literal("external") })
2691
2710
  ])
2692
2711
  ),
2712
+ contextConfig: z.optional(ContextConfigApiInsertSchema),
2713
+ statusUpdates: z.optional(StatusUpdateSchema),
2693
2714
  models: ModelSchema.optional(),
2694
2715
  stopWhen: GraphStopWhenSchema.optional(),
2695
2716
  graphPrompt: z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
@@ -2729,7 +2750,6 @@ var init_schemas = __esm({
2729
2750
  tools: z.record(z.string(), ToolApiInsertSchema),
2730
2751
  dataComponents: z.record(z.string(), DataComponentApiInsertSchema).optional(),
2731
2752
  artifactComponents: z.record(z.string(), ArtifactComponentApiInsertSchema).optional(),
2732
- contextConfig: z.record(z.string(), ContextConfigApiInsertSchema).optional(),
2733
2753
  statusUpdates: z.optional(StatusUpdateSchema),
2734
2754
  credentialReferences: z.record(z.string(), CredentialReferenceApiInsertSchema).optional(),
2735
2755
  createdAt: z.string().optional(),
@@ -20514,6 +20534,7 @@ var init_src = __esm({
20514
20534
  "../packages/agents-core/src/index.ts"() {
20515
20535
  "use strict";
20516
20536
  init_esm_shims();
20537
+ init_base_client();
20517
20538
  init_context5();
20518
20539
  init_credential_stores();
20519
20540
  init_credential_stuffer();
@@ -20568,15 +20589,25 @@ var init_tsx_loader = __esm({
20568
20589
  // src/utils/config.ts
20569
20590
  var config_exports = {};
20570
20591
  __export(config_exports, {
20571
- getAgentsManageApiUrl: () => getAgentsManageApiUrl,
20572
- getAgentsRunApiUrl: () => getAgentsRunApiUrl,
20573
- getProjectId: () => getProjectId,
20574
- getTenantId: () => getTenantId,
20592
+ findConfigFile: () => findConfigFile,
20575
20593
  loadConfig: () => loadConfig,
20594
+ loadConfigFromFile: () => loadConfigFromFile,
20595
+ maskSensitiveConfig: () => maskSensitiveConfig,
20576
20596
  validateConfiguration: () => validateConfiguration
20577
20597
  });
20578
20598
  import { existsSync as existsSync4 } from "fs";
20579
20599
  import { dirname as dirname3, join as join4, resolve as resolve2 } from "path";
20600
+ function maskSensitiveConfig(config) {
20601
+ if (!config) return config;
20602
+ const masked = { ...config };
20603
+ if (masked.agentsManageApiKey) {
20604
+ masked.agentsManageApiKey = "***" + masked.agentsManageApiKey.slice(-4);
20605
+ }
20606
+ if (masked.agentsRunApiKey) {
20607
+ masked.agentsRunApiKey = "***" + masked.agentsRunApiKey.slice(-4);
20608
+ }
20609
+ return masked;
20610
+ }
20580
20611
  function isNestedConfig(config) {
20581
20612
  return config && (config.agentsManageApi !== void 0 || config.agentsRunApi !== void 0);
20582
20613
  }
@@ -20641,7 +20672,7 @@ async function loadConfigFromFile(configPath) {
20641
20672
  throw new Error(`No config exported from ${resolvedPath}`);
20642
20673
  }
20643
20674
  const config = normalizeConfig(rawConfig);
20644
- logger12.info({ config }, `Loaded config values`);
20675
+ logger12.info({ config: maskSensitiveConfig(config) }, `Loaded config values`);
20645
20676
  return config;
20646
20677
  } catch (error) {
20647
20678
  console.warn(`Warning: Failed to load config file ${resolvedPath}:`, error);
@@ -20649,67 +20680,32 @@ async function loadConfigFromFile(configPath) {
20649
20680
  }
20650
20681
  }
20651
20682
  async function loadConfig(configPath) {
20652
- let config = {
20683
+ const config = {
20653
20684
  agentsManageApiUrl: "http://localhost:3002",
20654
20685
  agentsRunApiUrl: "http://localhost:3003",
20655
20686
  manageUiUrl: "http://localhost:3000"
20656
20687
  };
20657
20688
  const fileConfig = await loadConfigFromFile(configPath);
20658
20689
  if (fileConfig) {
20659
- config = {
20660
- ...config,
20661
- ...fileConfig
20662
- };
20663
- logger12.info({ mergedConfig: config }, `Config loaded from file`);
20690
+ Object.keys(fileConfig).forEach((key) => {
20691
+ const value = fileConfig[key];
20692
+ if (value !== void 0) {
20693
+ config[key] = value;
20694
+ }
20695
+ });
20696
+ logger12.info({ mergedConfig: maskSensitiveConfig(config) }, `Config loaded from file`);
20664
20697
  } else {
20665
- logger12.info({ config }, `Using default config (no config file found)`);
20698
+ logger12.info(
20699
+ { config: maskSensitiveConfig(config) },
20700
+ `Using default config (no config file found)`
20701
+ );
20666
20702
  }
20667
20703
  return config;
20668
20704
  }
20669
- async function getTenantId(configPath) {
20670
- const config = await loadConfig(configPath);
20671
- return config.tenantId;
20672
- }
20673
- async function getProjectId(_configPath) {
20674
- return "default";
20675
- }
20676
- async function getAgentsManageApiUrl(overrideUrl, configPath) {
20677
- if (overrideUrl) {
20678
- return overrideUrl;
20679
- }
20680
- const config = await loadConfig(configPath);
20681
- return config.agentsManageApiUrl || "http://localhost:3002";
20682
- }
20683
- async function getAgentsRunApiUrl(overrideUrl, configPath) {
20684
- if (overrideUrl) {
20685
- return overrideUrl;
20686
- }
20687
- const config = await loadConfig(configPath);
20688
- return config.agentsRunApiUrl || "http://localhost:3003";
20689
- }
20690
- async function validateConfiguration(tenantIdFlag, agentsManageApiUrlFlag, agentsRunApiUrlFlag, configPath) {
20705
+ async function validateConfiguration(configPath) {
20691
20706
  const config = await loadConfig(configPath);
20692
- const tenantId = tenantIdFlag || config.tenantId;
20693
- const agentsManageApiUrl = agentsManageApiUrlFlag || config.agentsManageApiUrl;
20694
- const agentsRunApiUrl = agentsRunApiUrlFlag || config.agentsRunApiUrl;
20695
20707
  const actualConfigFile = configPath || findConfigFile();
20696
- if (tenantIdFlag && agentsManageApiUrlFlag && agentsRunApiUrlFlag) {
20697
- const sources2 = {
20698
- tenantId: "command-line flag (--tenant-id)",
20699
- agentsManageApiUrl: "command-line flag (--agents-manage-api-url)",
20700
- agentsRunApiUrl: "command-line flag (--agents-run-api-url)"
20701
- };
20702
- return {
20703
- tenantId: tenantIdFlag,
20704
- agentsManageApiUrl: agentsManageApiUrlFlag,
20705
- agentsRunApiUrl: agentsRunApiUrlFlag,
20706
- agentsManageApiKey: config.agentsManageApiKey,
20707
- agentsRunApiKey: config.agentsRunApiKey,
20708
- manageUiUrl: config.manageUiUrl,
20709
- sources: sources2
20710
- };
20711
- }
20712
- if (!tenantId) {
20708
+ if (!config.tenantId) {
20713
20709
  if (actualConfigFile) {
20714
20710
  throw new Error(
20715
20711
  `Tenant ID is missing from configuration file: ${actualConfigFile}
@@ -20717,32 +20713,34 @@ Please ensure your config file exports a valid configuration with tenantId.`
20717
20713
  );
20718
20714
  } else {
20719
20715
  throw new Error(
20720
- 'No configuration found. Please use one of:\n 1. Create "inkeep.config.ts" by running "inkeep init"\n 2. Provide --config to specify a config file\n 3. Provide --tenant-id, --agents-manage-api-url and --agents-run-api-url flags'
20716
+ 'No configuration found. Please:\n 1. Create "inkeep.config.ts" by running "inkeep init"\n 2. Or provide --config to specify a config file path'
20721
20717
  );
20722
20718
  }
20723
20719
  }
20724
- if (!agentsManageApiUrl) {
20720
+ if (!config.agentsManageApiUrl) {
20725
20721
  throw new Error(
20726
- "Agents Management API URL is missing. Please either:\n 1. Provide --agents-manage-api-url flag\n 2. Add agentsManageApiUrl to your configuration file"
20722
+ `Agents Management API URL is missing from config file${actualConfigFile ? `: ${actualConfigFile}` : ""}
20723
+ Please add agentsManageApiUrl to your configuration file`
20727
20724
  );
20728
20725
  }
20729
- if (!agentsRunApiUrl) {
20726
+ if (!config.agentsRunApiUrl) {
20730
20727
  throw new Error(
20731
- "Agents Run API URL is missing. Please either:\n 1. Provide --agents-run-api-url flag\n 2. Add agentsRunApiUrl to your configuration file"
20728
+ `Agents Run API URL is missing from config file${actualConfigFile ? `: ${actualConfigFile}` : ""}
20729
+ Please add agentsRunApiUrl to your configuration file`
20732
20730
  );
20733
20731
  }
20734
20732
  const sources = {
20735
- tenantId: tenantIdFlag ? "command-line flag (--tenant-id)" : actualConfigFile ? `config file (${actualConfigFile})` : "default",
20736
- agentsManageApiUrl: agentsManageApiUrlFlag ? "command-line flag (--agents-manage-api-url)" : actualConfigFile ? `config file (${actualConfigFile})` : "default value",
20737
- agentsRunApiUrl: agentsRunApiUrlFlag ? "command-line flag (--agents-run-api-url)" : actualConfigFile ? `config file (${actualConfigFile})` : "default value"
20733
+ tenantId: actualConfigFile ? `config file (${actualConfigFile})` : "default",
20734
+ agentsManageApiUrl: actualConfigFile ? `config file (${actualConfigFile})` : "default value",
20735
+ agentsRunApiUrl: actualConfigFile ? `config file (${actualConfigFile})` : "default value"
20738
20736
  };
20739
20737
  if (actualConfigFile) {
20740
20738
  sources.configFile = actualConfigFile;
20741
20739
  }
20742
20740
  return {
20743
- tenantId,
20744
- agentsManageApiUrl,
20745
- agentsRunApiUrl,
20741
+ tenantId: config.tenantId,
20742
+ agentsManageApiUrl: config.agentsManageApiUrl,
20743
+ agentsRunApiUrl: config.agentsRunApiUrl,
20746
20744
  agentsManageApiKey: config.agentsManageApiKey,
20747
20745
  agentsRunApiKey: config.agentsRunApiKey,
20748
20746
  manageUiUrl: config.manageUiUrl,
@@ -20766,7 +20764,7 @@ var init_api = __esm({
20766
20764
  "src/api.ts"() {
20767
20765
  "use strict";
20768
20766
  init_esm_shims();
20769
- init_config();
20767
+ init_src();
20770
20768
  BaseApiClient = class {
20771
20769
  apiUrl;
20772
20770
  tenantId;
@@ -20784,6 +20782,21 @@ var init_api = __esm({
20784
20782
  }
20785
20783
  return this.tenantId;
20786
20784
  }
20785
+ /**
20786
+ * Wrapper around fetch that automatically includes Authorization header if API key is present
20787
+ */
20788
+ async authenticatedFetch(url, options = {}) {
20789
+ const headers = {
20790
+ ...options.headers || {}
20791
+ };
20792
+ if (this.apiKey) {
20793
+ headers.Authorization = `Bearer ${this.apiKey}`;
20794
+ }
20795
+ return apiFetch(url, {
20796
+ ...options,
20797
+ headers
20798
+ });
20799
+ }
20787
20800
  getTenantId() {
20788
20801
  return this.tenantId;
20789
20802
  }
@@ -20799,26 +20812,20 @@ var init_api = __esm({
20799
20812
  super(apiUrl, tenantId, projectId, apiKey);
20800
20813
  }
20801
20814
  static async create(apiUrl, configPath, tenantIdOverride, projectIdOverride) {
20802
- const resolvedApiUrl = await getAgentsManageApiUrl(apiUrl, configPath);
20803
- const tenantId = tenantIdOverride || await getTenantId(configPath);
20804
- const projectId = projectIdOverride || await getProjectId(configPath);
20805
20815
  const { validateConfiguration: validateConfiguration2 } = await Promise.resolve().then(() => (init_config(), config_exports));
20806
- const config = await validateConfiguration2(tenantIdOverride, apiUrl, void 0, configPath);
20816
+ const config = await validateConfiguration2(configPath);
20817
+ const resolvedApiUrl = apiUrl || config.agentsManageApiUrl;
20818
+ const tenantId = tenantIdOverride || config.tenantId;
20819
+ const projectId = projectIdOverride || "";
20807
20820
  return new _ManagementApiClient(resolvedApiUrl, tenantId, projectId, config.agentsManageApiKey);
20808
20821
  }
20809
20822
  async listGraphs() {
20810
20823
  const tenantId = this.checkTenantId();
20811
20824
  const projectId = this.getProjectId();
20812
- const response = await fetch(
20825
+ const response = await this.authenticatedFetch(
20813
20826
  `${this.apiUrl}/tenants/${tenantId}/projects/${projectId}/agent-graphs`,
20814
20827
  {
20815
- method: "GET",
20816
- headers: {
20817
- "Content-Type": "application/json",
20818
- ...this.apiKey && {
20819
- Authorization: `Bearer ${this.apiKey}`
20820
- }
20821
- }
20828
+ method: "GET"
20822
20829
  }
20823
20830
  );
20824
20831
  if (!response.ok) {
@@ -20840,16 +20847,10 @@ var init_api = __esm({
20840
20847
  if (!graphId) {
20841
20848
  throw new Error("Graph must have an id property");
20842
20849
  }
20843
- const response = await fetch(
20850
+ const response = await this.authenticatedFetch(
20844
20851
  `${this.apiUrl}/tenants/${tenantId}/projects/${projectId}/graph/${graphId}`,
20845
20852
  {
20846
20853
  method: "PUT",
20847
- headers: {
20848
- "Content-Type": "application/json",
20849
- ...this.apiKey && {
20850
- Authorization: `Bearer ${this.apiKey}`
20851
- }
20852
- },
20853
20854
  body: JSON.stringify(graphDefinition)
20854
20855
  }
20855
20856
  );
@@ -20861,28 +20862,47 @@ ${errorText}`);
20861
20862
  const data = await response.json();
20862
20863
  return data.data;
20863
20864
  }
20865
+ /**
20866
+ * Fetch full project data including all graphs, tools, and components
20867
+ */
20868
+ async getFullProject(projectId) {
20869
+ const tenantId = this.checkTenantId();
20870
+ const response = await this.authenticatedFetch(
20871
+ `${this.apiUrl}/tenants/${tenantId}/project-full/${projectId}`,
20872
+ {
20873
+ method: "GET"
20874
+ }
20875
+ );
20876
+ if (!response.ok) {
20877
+ if (response.status === 404) {
20878
+ throw new Error(`Project "${projectId}" not found`);
20879
+ }
20880
+ if (response.status === 401) {
20881
+ throw new Error("Unauthorized - check your API key");
20882
+ }
20883
+ throw new Error(`Failed to fetch project: ${response.statusText}`);
20884
+ }
20885
+ const responseData = await response.json();
20886
+ return responseData.data;
20887
+ }
20864
20888
  };
20865
20889
  ExecutionApiClient = class _ExecutionApiClient extends BaseApiClient {
20866
20890
  constructor(apiUrl, tenantId, projectId, apiKey) {
20867
20891
  super(apiUrl, tenantId, projectId, apiKey);
20868
20892
  }
20869
20893
  static async create(apiUrl, configPath, tenantIdOverride, projectIdOverride) {
20870
- const resolvedApiUrl = await getAgentsRunApiUrl(apiUrl, configPath);
20871
- const tenantId = tenantIdOverride || await getTenantId(configPath);
20872
- const projectId = projectIdOverride || await getProjectId(configPath);
20873
20894
  const { validateConfiguration: validateConfiguration2 } = await Promise.resolve().then(() => (init_config(), config_exports));
20874
- const config = await validateConfiguration2(tenantIdOverride, void 0, apiUrl, configPath);
20895
+ const config = await validateConfiguration2(configPath);
20896
+ const resolvedApiUrl = apiUrl || config.agentsRunApiUrl;
20897
+ const tenantId = tenantIdOverride || config.tenantId;
20898
+ const projectId = projectIdOverride || "";
20875
20899
  return new _ExecutionApiClient(resolvedApiUrl, tenantId, projectId, config.agentsRunApiKey);
20876
20900
  }
20877
20901
  async chatCompletion(graphId, messages2, conversationId) {
20878
- const response = await fetch(`${this.apiUrl}/v1/chat/completions`, {
20902
+ const response = await this.authenticatedFetch(`${this.apiUrl}/v1/chat/completions`, {
20879
20903
  method: "POST",
20880
20904
  headers: {
20881
- "Content-Type": "application/json",
20882
20905
  Accept: "text/event-stream",
20883
- ...this.apiKey && {
20884
- Authorization: `Bearer ${this.apiKey}`
20885
- },
20886
20906
  "x-inkeep-tenant-id": this.tenantId || "test-tenant-id",
20887
20907
  "x-inkeep-project-id": this.projectId,
20888
20908
  "x-inkeep-graph-id": graphId
@@ -20915,35 +20935,77 @@ ${errorText}`);
20915
20935
  }
20916
20936
  });
20917
20937
 
20938
+ // src/utils/cli-pipeline.ts
20939
+ import chalk5 from "chalk";
20940
+ import ora3 from "ora";
20941
+ async function initializeCommand(options = {}) {
20942
+ const {
20943
+ configPath,
20944
+ showSpinner = false,
20945
+ spinnerText = "Loading configuration...",
20946
+ logConfig = true
20947
+ } = options;
20948
+ const spinner = showSpinner ? ora3(spinnerText).start() : void 0;
20949
+ try {
20950
+ const config = await validateConfiguration(configPath);
20951
+ if (spinner) {
20952
+ spinner.succeed("Configuration loaded");
20953
+ }
20954
+ if (logConfig) {
20955
+ console.log(chalk5.gray("Configuration:"));
20956
+ console.log(chalk5.gray(` \u2022 Tenant ID: ${config.tenantId}`));
20957
+ console.log(chalk5.gray(` \u2022 Manage API URL: ${config.agentsManageApiUrl}`));
20958
+ console.log(chalk5.gray(` \u2022 Run API URL: ${config.agentsRunApiUrl}`));
20959
+ if (config.sources.configFile) {
20960
+ console.log(chalk5.gray(` \u2022 Config file: ${config.sources.configFile}`));
20961
+ }
20962
+ }
20963
+ return { config, spinner };
20964
+ } catch (error) {
20965
+ if (spinner) {
20966
+ spinner.fail("Configuration failed");
20967
+ }
20968
+ console.error(chalk5.red("Error:"), error.message);
20969
+ if (error.message.includes("No configuration found")) {
20970
+ console.log(chalk5.yellow("\nHint: Create a configuration file by running:"));
20971
+ console.log(chalk5.gray(" inkeep init"));
20972
+ } else if (error.message.includes("Config file not found")) {
20973
+ console.log(chalk5.yellow("\nHint: Check that your config file path is correct"));
20974
+ } else if (error.message.includes("tenantId") || error.message.includes("API URL")) {
20975
+ console.log(chalk5.yellow("\nHint: Ensure your inkeep.config.ts has all required fields:"));
20976
+ console.log(chalk5.gray(" - tenantId"));
20977
+ console.log(chalk5.gray(" - agentsManageApiUrl (or agentsManageApi.url)"));
20978
+ console.log(chalk5.gray(" - agentsRunApiUrl (or agentsRunApi.url)"));
20979
+ }
20980
+ process.exit(1);
20981
+ }
20982
+ }
20983
+ var init_cli_pipeline = __esm({
20984
+ "src/utils/cli-pipeline.ts"() {
20985
+ "use strict";
20986
+ init_esm_shims();
20987
+ init_config();
20988
+ }
20989
+ });
20990
+
20918
20991
  // src/commands/chat-enhanced.ts
20919
20992
  var chat_enhanced_exports = {};
20920
20993
  __export(chat_enhanced_exports, {
20921
20994
  chatCommandEnhanced: () => chatCommandEnhanced
20922
20995
  });
20923
20996
  import * as readline from "readline";
20924
- import chalk8 from "chalk";
20997
+ import chalk9 from "chalk";
20925
20998
  import inquirer2 from "inquirer";
20926
- import ora6 from "ora";
20999
+ import ora7 from "ora";
20927
21000
  async function chatCommandEnhanced(graphIdInput, options) {
20928
- let config;
20929
- try {
20930
- const configPath2 = options?.config || options?.configFilePath;
20931
- config = await validateConfiguration(
20932
- options?.tenantId,
20933
- options?.agentsManageApiUrl,
20934
- options?.agentsRunApiUrl,
20935
- configPath2
20936
- );
20937
- } catch (error) {
20938
- console.error(chalk8.red(error.message));
20939
- process.exit(1);
20940
- }
20941
- console.log(chalk8.gray("Using configuration:"));
20942
- console.log(chalk8.gray(` \u2022 Tenant ID: ${config.sources.tenantId}`));
20943
- console.log(chalk8.gray(` \u2022 Management API: ${config.sources.agentsManageApiUrl}`));
20944
- console.log(chalk8.gray(` \u2022 Execution API: ${config.sources.agentsRunApiUrl}`));
20945
- console.log();
21001
+ console.log(chalk9.cyan("\u{1F916} Inkeep Chat Interface\n"));
20946
21002
  const configPath = options?.config || options?.configFilePath;
21003
+ const { config } = await initializeCommand({
21004
+ configPath,
21005
+ showSpinner: false,
21006
+ logConfig: true
21007
+ });
21008
+ console.log();
20947
21009
  const managementApi = await ManagementApiClient.create(
20948
21010
  config.agentsManageApiUrl,
20949
21011
  configPath,
@@ -20956,18 +21018,18 @@ async function chatCommandEnhanced(graphIdInput, options) {
20956
21018
  );
20957
21019
  let graphId = graphIdInput;
20958
21020
  if (!graphId) {
20959
- const spinner2 = ora6("Fetching available graphs...").start();
21021
+ const spinner2 = ora7("Fetching available graphs...").start();
20960
21022
  try {
20961
21023
  const graphs = await managementApi.listGraphs();
20962
21024
  spinner2.stop();
20963
21025
  if (graphs.length === 0) {
20964
21026
  console.error(
20965
- chalk8.red("No graphs available. Define graphs in your project and run: inkeep push")
21027
+ chalk9.red("No graphs available. Define graphs in your project and run: inkeep push")
20966
21028
  );
20967
21029
  process.exit(1);
20968
21030
  }
20969
21031
  const graphChoices = graphs.map((g) => ({
20970
- name: `${chalk8.cyan(g.id)} - ${g.name || "Unnamed Graph"}`,
21032
+ name: `${chalk9.cyan(g.id)} - ${g.name || "Unnamed Graph"}`,
20971
21033
  value: g.id,
20972
21034
  short: g.id,
20973
21035
  searchText: `${g.id} ${g.name || ""}`.toLowerCase()
@@ -20984,11 +21046,11 @@ async function chatCommandEnhanced(graphIdInput, options) {
20984
21046
  graphId = answer.graphId;
20985
21047
  } catch (error) {
20986
21048
  spinner2.fail("Failed to fetch graphs");
20987
- console.error(chalk8.red("Error:"), error instanceof Error ? error.message : error);
21049
+ console.error(chalk9.red("Error:"), error instanceof Error ? error.message : error);
20988
21050
  process.exit(1);
20989
21051
  }
20990
21052
  }
20991
- const spinner = ora6("Connecting to graph...").start();
21053
+ const spinner = ora7("Connecting to graph...").start();
20992
21054
  try {
20993
21055
  if (!graphId) {
20994
21056
  throw new Error("No graph selected");
@@ -20998,38 +21060,38 @@ async function chatCommandEnhanced(graphIdInput, options) {
20998
21060
  spinner.fail(`Graph "${graphId}" not found`);
20999
21061
  const graphs = await managementApi.listGraphs();
21000
21062
  if (graphs.length > 0) {
21001
- console.log(chalk8.yellow("\nAvailable graphs:"));
21063
+ console.log(chalk9.yellow("\nAvailable graphs:"));
21002
21064
  graphs.forEach((g) => {
21003
- console.log(chalk8.gray(` \u2022 ${g.id} - ${g.name || "Unnamed"}`));
21065
+ console.log(chalk9.gray(` \u2022 ${g.id} - ${g.name || "Unnamed"}`));
21004
21066
  });
21005
- console.log(chalk8.gray('\nRun "inkeep chat" without arguments for interactive selection'));
21067
+ console.log(chalk9.gray('\nRun "inkeep chat" without arguments for interactive selection'));
21006
21068
  } else {
21007
- console.log(chalk8.yellow("\nNo graphs found. Please define graphs and push your project."));
21069
+ console.log(chalk9.yellow("\nNo graphs found. Please define graphs and push your project."));
21008
21070
  }
21009
21071
  process.exit(1);
21010
21072
  }
21011
- spinner.succeed(`Connected to graph: ${chalk8.green(graph.name || graphId)}`);
21073
+ spinner.succeed(`Connected to graph: ${chalk9.green(graph.name || graphId)}`);
21012
21074
  if (graph.description) {
21013
- console.log(chalk8.gray(`Description: ${graph.description}`));
21075
+ console.log(chalk9.gray(`Description: ${graph.description}`));
21014
21076
  }
21015
21077
  if (graph.defaultAgentId || graph.default_agent_id) {
21016
- console.log(chalk8.gray(`Default Agent: ${graph.defaultAgentId || graph.default_agent_id}`));
21078
+ console.log(chalk9.gray(`Default Agent: ${graph.defaultAgentId || graph.default_agent_id}`));
21017
21079
  }
21018
21080
  } catch (error) {
21019
21081
  spinner.fail("Failed to connect to graph");
21020
- console.error(chalk8.red("Error:"), error instanceof Error ? error.message : error);
21082
+ console.error(chalk9.red("Error:"), error instanceof Error ? error.message : error);
21021
21083
  process.exit(1);
21022
21084
  }
21023
21085
  const rl = readline.createInterface({
21024
21086
  input: process.stdin,
21025
21087
  output: process.stdout,
21026
- prompt: chalk8.cyan("You> ")
21088
+ prompt: chalk9.cyan("You> ")
21027
21089
  });
21028
21090
  const conversationId = `cli-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
21029
21091
  const messages2 = [];
21030
21092
  let debugMode = false;
21031
- console.log(chalk8.gray('\n\u{1F4AC} Chat session started. Type "exit" or press Ctrl+C to quit.'));
21032
- console.log(chalk8.gray("Commands: help, clear, history, reset, debug\n"));
21093
+ console.log(chalk9.gray('\n\u{1F4AC} Chat session started. Type "exit" or press Ctrl+C to quit.'));
21094
+ console.log(chalk9.gray("Commands: help, clear, history, reset, debug\n"));
21033
21095
  async function handleStreamingResponse(stream, showDebug = false) {
21034
21096
  const decoder = new TextDecoder();
21035
21097
  const reader = stream.getReader();
@@ -21085,12 +21147,12 @@ async function chatCommandEnhanced(graphIdInput, options) {
21085
21147
  if (opType === "completion" && hasStartedResponse) {
21086
21148
  console.log("");
21087
21149
  }
21088
- console.log(chalk8.gray(` [${opType}] ${ctxDisplay}`));
21150
+ console.log(chalk9.gray(` [${opType}] ${ctxDisplay}`));
21089
21151
  }
21090
21152
  currentPos = jsonEnd;
21091
21153
  } catch {
21092
21154
  if (!hasStartedResponse) {
21093
- process.stdout.write(chalk8.green("Assistant> "));
21155
+ process.stdout.write(chalk9.green("Assistant> "));
21094
21156
  hasStartedResponse = true;
21095
21157
  }
21096
21158
  process.stdout.write(content[currentPos]);
@@ -21099,7 +21161,7 @@ async function chatCommandEnhanced(graphIdInput, options) {
21099
21161
  }
21100
21162
  } else {
21101
21163
  if (!hasStartedResponse) {
21102
- process.stdout.write(chalk8.green("Assistant> "));
21164
+ process.stdout.write(chalk9.green("Assistant> "));
21103
21165
  hasStartedResponse = true;
21104
21166
  }
21105
21167
  process.stdout.write(content[currentPos]);
@@ -21119,7 +21181,7 @@ async function chatCommandEnhanced(graphIdInput, options) {
21119
21181
  if (hasStartedResponse) {
21120
21182
  console.log("\n");
21121
21183
  } else {
21122
- console.log(`${chalk8.green("Assistant> ") + chalk8.gray("(no response)")}
21184
+ console.log(`${chalk9.green("Assistant> ") + chalk9.gray("(no response)")}
21123
21185
  `);
21124
21186
  }
21125
21187
  return responseContent;
@@ -21128,47 +21190,47 @@ async function chatCommandEnhanced(graphIdInput, options) {
21128
21190
  const trimmedInput = input.trim();
21129
21191
  const command = trimmedInput.toLowerCase().replace(/^\//, "");
21130
21192
  if (command === "exit") {
21131
- console.log(chalk8.gray("Goodbye! \u{1F44B}"));
21193
+ console.log(chalk9.gray("Goodbye! \u{1F44B}"));
21132
21194
  rl.close();
21133
21195
  process.exit(0);
21134
21196
  }
21135
21197
  if (command === "clear") {
21136
21198
  console.clear();
21137
- console.log(chalk8.gray("Screen cleared. Conversation context preserved.\n"));
21199
+ console.log(chalk9.gray("Screen cleared. Conversation context preserved.\n"));
21138
21200
  rl.prompt();
21139
21201
  return;
21140
21202
  }
21141
21203
  if (command === "help") {
21142
- console.log(chalk8.cyan("\n\u{1F4DA} Available commands:"));
21143
- console.log(chalk8.gray(" \u2022 exit - End the chat session"));
21144
- console.log(chalk8.gray(" \u2022 clear - Clear the screen (preserves context)"));
21145
- console.log(chalk8.gray(" \u2022 history - Show conversation history"));
21146
- console.log(chalk8.gray(" \u2022 reset - Reset conversation context"));
21147
- console.log(chalk8.gray(" \u2022 debug - Toggle debug mode (show/hide data operations)"));
21148
- console.log(chalk8.gray(" \u2022 help - Show this help message"));
21149
- console.log(chalk8.gray("\n Commands can be prefixed with / (e.g., /help)\n"));
21204
+ console.log(chalk9.cyan("\n\u{1F4DA} Available commands:"));
21205
+ console.log(chalk9.gray(" \u2022 exit - End the chat session"));
21206
+ console.log(chalk9.gray(" \u2022 clear - Clear the screen (preserves context)"));
21207
+ console.log(chalk9.gray(" \u2022 history - Show conversation history"));
21208
+ console.log(chalk9.gray(" \u2022 reset - Reset conversation context"));
21209
+ console.log(chalk9.gray(" \u2022 debug - Toggle debug mode (show/hide data operations)"));
21210
+ console.log(chalk9.gray(" \u2022 help - Show this help message"));
21211
+ console.log(chalk9.gray("\n Commands can be prefixed with / (e.g., /help)\n"));
21150
21212
  rl.prompt();
21151
21213
  return;
21152
21214
  }
21153
21215
  if (command === "debug") {
21154
21216
  debugMode = !debugMode;
21155
- console.log(chalk8.yellow(`
21217
+ console.log(chalk9.yellow(`
21156
21218
  \u{1F527} Debug mode: ${debugMode ? "ON" : "OFF"}`));
21157
21219
  if (debugMode) {
21158
- console.log(chalk8.gray("Data operations will be shown during responses.\n"));
21220
+ console.log(chalk9.gray("Data operations will be shown during responses.\n"));
21159
21221
  } else {
21160
- console.log(chalk8.gray("Data operations are hidden.\n"));
21222
+ console.log(chalk9.gray("Data operations are hidden.\n"));
21161
21223
  }
21162
21224
  rl.prompt();
21163
21225
  return;
21164
21226
  }
21165
21227
  if (command === "history") {
21166
- console.log(chalk8.cyan("\n\u{1F4DC} Conversation History:"));
21228
+ console.log(chalk9.cyan("\n\u{1F4DC} Conversation History:"));
21167
21229
  if (messages2.length === 0) {
21168
- console.log(chalk8.gray(" (No messages yet)\n"));
21230
+ console.log(chalk9.gray(" (No messages yet)\n"));
21169
21231
  } else {
21170
21232
  messages2.forEach((msg, idx) => {
21171
- const role = msg.role === "user" ? chalk8.blue("You") : chalk8.green("Assistant");
21233
+ const role = msg.role === "user" ? chalk9.blue("You") : chalk9.green("Assistant");
21172
21234
  const preview = msg.content.substring(0, 100);
21173
21235
  const suffix = msg.content.length > 100 ? "..." : "";
21174
21236
  console.log(` ${idx + 1}. ${role}: ${preview}${suffix}`);
@@ -21180,7 +21242,7 @@ async function chatCommandEnhanced(graphIdInput, options) {
21180
21242
  }
21181
21243
  if (command === "reset") {
21182
21244
  messages2.length = 0;
21183
- console.log(chalk8.yellow("\u26A0\uFE0F Conversation context has been reset.\n"));
21245
+ console.log(chalk9.yellow("\u26A0\uFE0F Conversation context has been reset.\n"));
21184
21246
  rl.prompt();
21185
21247
  return;
21186
21248
  }
@@ -21194,23 +21256,23 @@ async function chatCommandEnhanced(graphIdInput, options) {
21194
21256
  const response = await executionApi.chatCompletion(graphId, messages2, conversationId);
21195
21257
  let assistantResponse;
21196
21258
  if (typeof response === "string") {
21197
- console.log(chalk8.green("Assistant>"), response);
21259
+ console.log(chalk9.green("Assistant>"), response);
21198
21260
  assistantResponse = response;
21199
21261
  } else {
21200
21262
  assistantResponse = await handleStreamingResponse(response, debugMode);
21201
21263
  }
21202
21264
  messages2.push({ role: "assistant", content: assistantResponse });
21203
21265
  } catch (error) {
21204
- console.error(chalk8.red("Error:"), error instanceof Error ? error.message : error);
21266
+ console.error(chalk9.red("Error:"), error instanceof Error ? error.message : error);
21205
21267
  }
21206
21268
  rl.prompt();
21207
21269
  });
21208
21270
  rl.on("close", () => {
21209
- console.log(chalk8.gray("\n\u{1F4CA} Session Summary:"));
21210
- console.log(chalk8.gray(` \u2022 Graph: ${graphId}`));
21211
- console.log(chalk8.gray(` \u2022 Messages: ${messages2.length}`));
21212
- console.log(chalk8.gray(` \u2022 Duration: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`));
21213
- console.log(chalk8.gray("\nChat session ended."));
21271
+ console.log(chalk9.gray("\n\u{1F4CA} Session Summary:"));
21272
+ console.log(chalk9.gray(` \u2022 Graph: ${graphId}`));
21273
+ console.log(chalk9.gray(` \u2022 Messages: ${messages2.length}`));
21274
+ console.log(chalk9.gray(` \u2022 Duration: ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`));
21275
+ console.log(chalk9.gray("\nChat session ended."));
21214
21276
  process.exit(0);
21215
21277
  });
21216
21278
  rl.prompt();
@@ -21220,7 +21282,7 @@ var init_chat_enhanced = __esm({
21220
21282
  "use strict";
21221
21283
  init_esm_shims();
21222
21284
  init_api();
21223
- init_config();
21285
+ init_cli_pipeline();
21224
21286
  }
21225
21287
  });
21226
21288
 
@@ -21814,30 +21876,18 @@ Note: Config file created in ${configDir}`));
21814
21876
  // src/commands/list-graphs.ts
21815
21877
  init_esm_shims();
21816
21878
  init_api();
21817
- init_config();
21818
- import chalk5 from "chalk";
21879
+ init_cli_pipeline();
21880
+ import chalk6 from "chalk";
21819
21881
  import Table from "cli-table3";
21820
- import ora3 from "ora";
21882
+ import ora4 from "ora";
21821
21883
  async function listGraphsCommand(options) {
21822
- let config;
21823
- try {
21824
- const configPath2 = options.config || options.configFilePath;
21825
- config = await validateConfiguration(
21826
- options.tenantId,
21827
- options.agentsManageApiUrl,
21828
- void 0,
21829
- // agentsRunApiUrl not needed for list-graphs
21830
- configPath2
21831
- );
21832
- } catch (error) {
21833
- console.error(chalk5.red(error.message));
21834
- process.exit(1);
21835
- }
21836
- console.log(chalk5.gray("Using configuration:"));
21837
- console.log(chalk5.gray(` \u2022 Tenant ID: ${config.sources.tenantId}`));
21838
- console.log(chalk5.gray(` \u2022 API URL: ${config.sources.agentsManageApiUrl}`));
21839
- console.log();
21840
21884
  const configPath = options.config || options.configFilePath;
21885
+ const { config } = await initializeCommand({
21886
+ configPath,
21887
+ showSpinner: false,
21888
+ logConfig: true
21889
+ });
21890
+ console.log();
21841
21891
  const api = await ManagementApiClient.create(
21842
21892
  config.agentsManageApiUrl,
21843
21893
  configPath,
@@ -21845,22 +21895,24 @@ async function listGraphsCommand(options) {
21845
21895
  options.project
21846
21896
  // pass project ID as projectIdOverride
21847
21897
  );
21848
- const spinner = ora3("Fetching graphs...").start();
21898
+ const spinner = ora4("Fetching graphs...").start();
21849
21899
  try {
21850
21900
  const graphs = await api.listGraphs();
21851
21901
  spinner.succeed(`Found ${graphs.length} graph(s) in project "${options.project}"`);
21852
21902
  if (graphs.length === 0) {
21853
21903
  console.log(
21854
- chalk5.gray(`No graphs found in project "${options.project}". Define graphs in your project and run: inkeep push`)
21904
+ chalk6.gray(
21905
+ `No graphs found in project "${options.project}". Define graphs in your project and run: inkeep push`
21906
+ )
21855
21907
  );
21856
21908
  return;
21857
21909
  }
21858
21910
  const table = new Table({
21859
21911
  head: [
21860
- chalk5.cyan("Graph ID"),
21861
- chalk5.cyan("Name"),
21862
- chalk5.cyan("Default Agent"),
21863
- chalk5.cyan("Created")
21912
+ chalk6.cyan("Graph ID"),
21913
+ chalk6.cyan("Name"),
21914
+ chalk6.cyan("Default Agent"),
21915
+ chalk6.cyan("Created")
21864
21916
  ],
21865
21917
  style: {
21866
21918
  head: [],
@@ -21872,7 +21924,7 @@ async function listGraphsCommand(options) {
21872
21924
  table.push([
21873
21925
  graph.id || "",
21874
21926
  graph.name || graph.id || "",
21875
- graph.defaultAgentId || chalk5.gray("None"),
21927
+ graph.defaultAgentId || chalk6.gray("None"),
21876
21928
  createdDate
21877
21929
  ]);
21878
21930
  }
@@ -21880,19 +21932,20 @@ async function listGraphsCommand(options) {
21880
21932
  ${table.toString()}`);
21881
21933
  } catch (error) {
21882
21934
  spinner.fail("Failed to fetch graphs");
21883
- console.error(chalk5.red("Error:"), error instanceof Error ? error.message : error);
21935
+ console.error(chalk6.red("Error:"), error instanceof Error ? error.message : error);
21884
21936
  process.exit(1);
21885
21937
  }
21886
21938
  }
21887
21939
 
21888
21940
  // src/commands/pull.ts
21889
21941
  init_esm_shims();
21942
+ init_api();
21890
21943
  import { existsSync as existsSync6, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync4 } from "fs";
21891
21944
  import { dirname as dirname4, join as join7, resolve as resolve4 } from "path";
21892
- import chalk6 from "chalk";
21893
- import ora4 from "ora";
21945
+ import chalk7 from "chalk";
21946
+ import ora5 from "ora";
21894
21947
  import prompts from "prompts";
21895
- init_tsx_loader();
21948
+ init_config();
21896
21949
 
21897
21950
  // src/utils/project-directory.ts
21898
21951
  init_esm_shims();
@@ -21927,6 +21980,9 @@ async function findProjectDirectory(projectId, configPath) {
21927
21980
  return null;
21928
21981
  }
21929
21982
 
21983
+ // src/commands/pull.ts
21984
+ init_tsx_loader();
21985
+
21930
21986
  // src/commands/pull.llm-generate.ts
21931
21987
  init_esm_shims();
21932
21988
  import { writeFileSync as writeFileSync3 } from "fs";
@@ -22709,7 +22765,7 @@ export { ${exportStatement} };
22709
22765
  }
22710
22766
 
22711
22767
  // src/commands/pull.ts
22712
- async function verifyGeneratedFiles(projectDir, originalProjectData, debug = false, config) {
22768
+ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = false) {
22713
22769
  const errors = [];
22714
22770
  const warnings = [];
22715
22771
  try {
@@ -22745,20 +22801,32 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
22745
22801
  try {
22746
22802
  const generatedProjectData = await project.toFullProjectDefinition();
22747
22803
  if (debug) {
22748
- console.log(chalk6.gray("\n\u{1F4CB} Generated project successfully"));
22749
- console.log(chalk6.gray(` \u2022 Has tools: ${!!generatedProjectData.tools}`));
22750
- console.log(chalk6.gray(` \u2022 Tools count: ${Object.keys(generatedProjectData.tools || {}).length}`));
22751
- console.log(chalk6.gray(` \u2022 Has credentials: ${!!generatedProjectData.credentialReferences}`));
22752
- console.log(chalk6.gray(` \u2022 Credentials count: ${Object.keys(generatedProjectData.credentialReferences || {}).length}`));
22804
+ console.log(chalk7.gray("\n\u{1F4CB} Generated project successfully"));
22805
+ console.log(chalk7.gray(` \u2022 Has tools: ${!!generatedProjectData.tools}`));
22806
+ console.log(
22807
+ chalk7.gray(` \u2022 Tools count: ${Object.keys(generatedProjectData.tools || {}).length}`)
22808
+ );
22809
+ console.log(
22810
+ chalk7.gray(` \u2022 Has credentials: ${!!generatedProjectData.credentialReferences}`)
22811
+ );
22812
+ console.log(
22813
+ chalk7.gray(
22814
+ ` \u2022 Credentials count: ${Object.keys(generatedProjectData.credentialReferences || {}).length}`
22815
+ )
22816
+ );
22753
22817
  }
22754
22818
  if (!generatedProjectData) {
22755
22819
  structuralErrors.push("Generated project definition is empty");
22756
22820
  }
22757
22821
  } catch (projectDefError) {
22758
22822
  if (debug) {
22759
- console.log(chalk6.yellow(` Project definition generation warning: ${projectDefError.message}`));
22823
+ console.log(
22824
+ chalk7.yellow(` Project definition generation warning: ${projectDefError.message}`)
22825
+ );
22760
22826
  }
22761
- structuralWarnings.push(`Project definition generation had issues: ${projectDefError.message}`);
22827
+ structuralWarnings.push(
22828
+ `Project definition generation had issues: ${projectDefError.message}`
22829
+ );
22762
22830
  }
22763
22831
  }
22764
22832
  const toolPath = join7(projectDir, "tools", "inkeep_facts.ts");
@@ -22772,12 +22840,20 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
22772
22840
  structuralErrors.push("Tool file missing required serverUrl property");
22773
22841
  }
22774
22842
  if (toolContent.includes("config:")) {
22775
- structuralWarnings.push("Tool file contains invalid config property (should use individual properties)");
22843
+ structuralWarnings.push(
22844
+ "Tool file contains invalid config property (should use individual properties)"
22845
+ );
22776
22846
  }
22777
22847
  if (debug) {
22778
- console.log(chalk6.gray(` \u2022 Tool file has serverUrl: ${toolContent.includes("serverUrl:")}`));
22779
- console.log(chalk6.gray(` \u2022 Tool file has credential: ${toolContent.includes("credential:")}`));
22780
- console.log(chalk6.gray(` \u2022 Tool file has invalid config: ${toolContent.includes("config:")}`));
22848
+ console.log(
22849
+ chalk7.gray(` \u2022 Tool file has serverUrl: ${toolContent.includes("serverUrl:")}`)
22850
+ );
22851
+ console.log(
22852
+ chalk7.gray(` \u2022 Tool file has credential: ${toolContent.includes("credential:")}`)
22853
+ );
22854
+ console.log(
22855
+ chalk7.gray(` \u2022 Tool file has invalid config: ${toolContent.includes("config:")}`)
22856
+ );
22781
22857
  }
22782
22858
  } else {
22783
22859
  structuralErrors.push("Tool file inkeep_facts.ts not found");
@@ -22788,7 +22864,11 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
22788
22864
  structuralWarnings.push("Environment file may be missing credential definition");
22789
22865
  }
22790
22866
  if (debug) {
22791
- console.log(chalk6.gray(` \u2022 Environment file has credential: ${envContent.includes("inkeep_api_credential")}`));
22867
+ console.log(
22868
+ chalk7.gray(
22869
+ ` \u2022 Environment file has credential: ${envContent.includes("inkeep_api_credential")}`
22870
+ )
22871
+ );
22792
22872
  }
22793
22873
  } else {
22794
22874
  structuralErrors.push("Environment file development.env.ts not found");
@@ -22799,11 +22879,19 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
22799
22879
  errors.push(...structuralErrors);
22800
22880
  warnings.push(...structuralWarnings);
22801
22881
  if (debug) {
22802
- console.log(chalk6.gray("\n\u{1F50D} Structural Verification Summary:"));
22803
- console.log(chalk6.gray(` \u2022 Project loaded successfully: ${!!project}`));
22804
- console.log(chalk6.gray(` \u2022 Expected graphs: ${Object.keys(originalProjectData.graphs || {}).length}`));
22805
- console.log(chalk6.gray(` \u2022 Expected tools: ${Object.keys(originalProjectData.tools || {}).length}`));
22806
- console.log(chalk6.gray(` \u2022 Expected credentials: ${Object.keys(originalProjectData.credentialReferences || {}).length}`));
22882
+ console.log(chalk7.gray("\n\u{1F50D} Structural Verification Summary:"));
22883
+ console.log(chalk7.gray(` \u2022 Project loaded successfully: ${!!project}`));
22884
+ console.log(
22885
+ chalk7.gray(` \u2022 Expected graphs: ${Object.keys(originalProjectData.graphs || {}).length}`)
22886
+ );
22887
+ console.log(
22888
+ chalk7.gray(` \u2022 Expected tools: ${Object.keys(originalProjectData.tools || {}).length}`)
22889
+ );
22890
+ console.log(
22891
+ chalk7.gray(
22892
+ ` \u2022 Expected credentials: ${Object.keys(originalProjectData.credentialReferences || {}).length}`
22893
+ )
22894
+ );
22807
22895
  }
22808
22896
  return { success: errors.length === 0, errors, warnings };
22809
22897
  } catch (error) {
@@ -22817,39 +22905,26 @@ async function loadProjectConfig(projectDir, configPathOverride) {
22817
22905
  throw new Error(`Configuration file not found: ${configPath}`);
22818
22906
  }
22819
22907
  try {
22820
- const configModule = await importWithTypeScriptSupport(configPath);
22821
- const config = configModule.default || configModule.config;
22822
- if (!config) {
22823
- throw new Error("No configuration found in inkeep.config.ts");
22824
- }
22908
+ const config = await loadConfig(configPath);
22825
22909
  if (!config.tenantId) {
22826
22910
  throw new Error("tenantId is required in inkeep.config.ts");
22827
22911
  }
22828
22912
  return {
22829
22913
  tenantId: config.tenantId,
22830
- agentsManageApiUrl: config.agentsManageApiUrl || "http://localhost:3002",
22914
+ agentsManageApi: {
22915
+ url: config.agentsManageApiUrl || "http://localhost:3002",
22916
+ ...config.agentsManageApiKey && { apiKey: config.agentsManageApiKey }
22917
+ },
22918
+ agentsRunApi: {
22919
+ url: config.agentsRunApiUrl || "http://localhost:3003",
22920
+ ...config.agentsRunApiKey && { apiKey: config.agentsRunApiKey }
22921
+ },
22831
22922
  outputDirectory: config.outputDirectory
22832
22923
  };
22833
22924
  } catch (error) {
22834
22925
  throw new Error(`Failed to load configuration: ${error.message}`);
22835
22926
  }
22836
22927
  }
22837
- async function fetchProjectData(tenantId, projectId, apiUrl) {
22838
- const response = await fetch(`${apiUrl}/tenants/${tenantId}/project-full/${projectId}`, {
22839
- method: "GET",
22840
- headers: {
22841
- Accept: "application/json"
22842
- }
22843
- });
22844
- if (!response.ok) {
22845
- if (response.status === 404) {
22846
- throw new Error(`Project "${projectId}" not found`);
22847
- }
22848
- throw new Error(`Failed to fetch project: ${response.statusText}`);
22849
- }
22850
- const responseData = await response.json();
22851
- return responseData.data;
22852
- }
22853
22928
  function ensureDirectoryExists(dirPath) {
22854
22929
  if (!existsSync6(dirPath)) {
22855
22930
  mkdirSync(dirPath, { recursive: true });
@@ -22902,49 +22977,60 @@ async function generateProjectFiles(dirs, projectData, modelSettings, environmen
22902
22977
  if (dataComponents2 && Object.keys(dataComponents2).length > 0) {
22903
22978
  for (const [componentId, componentData] of Object.entries(dataComponents2)) {
22904
22979
  const componentPath = join7(dirs.dataComponentsDir, `${componentId}.ts`);
22905
- generationTasks.push(generateDataComponentFile(componentData, componentId, componentPath, modelSettings));
22980
+ generationTasks.push(
22981
+ generateDataComponentFile(componentData, componentId, componentPath, modelSettings)
22982
+ );
22906
22983
  fileInfo.push({ type: "dataComponent", name: `${componentId}.ts` });
22907
22984
  }
22908
22985
  }
22909
22986
  if (artifactComponents2 && Object.keys(artifactComponents2).length > 0) {
22910
22987
  for (const [componentId, componentData] of Object.entries(artifactComponents2)) {
22911
22988
  const componentPath = join7(dirs.artifactComponentsDir, `${componentId}.ts`);
22912
- generationTasks.push(generateArtifactComponentFile(componentData, componentId, componentPath, modelSettings));
22989
+ generationTasks.push(
22990
+ generateArtifactComponentFile(componentData, componentId, componentPath, modelSettings)
22991
+ );
22913
22992
  fileInfo.push({ type: "artifactComponent", name: `${componentId}.ts` });
22914
22993
  }
22915
22994
  }
22916
22995
  const targetEnvironment = environment;
22917
- generationTasks.push(generateEnvironmentFiles(dirs.environmentsDir, credentialReferences2, targetEnvironment));
22996
+ generationTasks.push(
22997
+ generateEnvironmentFiles(dirs.environmentsDir, credentialReferences2, targetEnvironment)
22998
+ );
22918
22999
  fileInfo.push({ type: "env", name: `index.ts, ${targetEnvironment}.env.ts` });
22919
- console.log(chalk6.cyan(" \u{1F4DD} Generating files in parallel:"));
22920
- const filesByType = fileInfo.reduce((acc, file) => {
22921
- if (!acc[file.type]) acc[file.type] = [];
22922
- acc[file.type].push(file.name);
22923
- return acc;
22924
- }, {});
23000
+ console.log(chalk7.cyan(" \u{1F4DD} Generating files in parallel:"));
23001
+ const filesByType = fileInfo.reduce(
23002
+ (acc, file) => {
23003
+ if (!acc[file.type]) acc[file.type] = [];
23004
+ acc[file.type].push(file.name);
23005
+ return acc;
23006
+ },
23007
+ {}
23008
+ );
22925
23009
  if (filesByType.config) {
22926
- console.log(chalk6.gray(` \u2022 Config files: ${filesByType.config.join(", ")}`));
23010
+ console.log(chalk7.gray(` \u2022 Config files: ${filesByType.config.join(", ")}`));
22927
23011
  }
22928
23012
  if (filesByType.graph) {
22929
- console.log(chalk6.gray(` \u2022 Graphs: ${filesByType.graph.join(", ")}`));
23013
+ console.log(chalk7.gray(` \u2022 Graphs: ${filesByType.graph.join(", ")}`));
22930
23014
  }
22931
23015
  if (filesByType.tool) {
22932
- console.log(chalk6.gray(` \u2022 Tools: ${filesByType.tool.join(", ")}`));
23016
+ console.log(chalk7.gray(` \u2022 Tools: ${filesByType.tool.join(", ")}`));
22933
23017
  }
22934
23018
  if (filesByType.dataComponent) {
22935
- console.log(chalk6.gray(` \u2022 Data components: ${filesByType.dataComponent.join(", ")}`));
23019
+ console.log(chalk7.gray(` \u2022 Data components: ${filesByType.dataComponent.join(", ")}`));
22936
23020
  }
22937
23021
  if (filesByType.artifactComponent) {
22938
- console.log(chalk6.gray(` \u2022 Artifact components: ${filesByType.artifactComponent.join(", ")}`));
23022
+ console.log(
23023
+ chalk7.gray(` \u2022 Artifact components: ${filesByType.artifactComponent.join(", ")}`)
23024
+ );
22939
23025
  }
22940
23026
  if (filesByType.env) {
22941
- console.log(chalk6.gray(` \u2022 Environment: ${filesByType.env.join(", ")}`));
23027
+ console.log(chalk7.gray(` \u2022 Environment: ${filesByType.env.join(", ")}`));
22942
23028
  }
22943
- console.log(chalk6.yellow(` \u26A1 Processing ${generationTasks.length} files in parallel...`));
23029
+ console.log(chalk7.yellow(` \u26A1 Processing ${generationTasks.length} files in parallel...`));
22944
23030
  if (debug) {
22945
- console.log(chalk6.gray("\n\u{1F4CD} Debug: Starting LLM file generation..."));
22946
- console.log(chalk6.gray(` Model: ${modelSettings.model}`));
22947
- console.log(chalk6.gray(` Total tasks: ${generationTasks.length}`));
23031
+ console.log(chalk7.gray("\n\u{1F4CD} Debug: Starting LLM file generation..."));
23032
+ console.log(chalk7.gray(` Model: ${modelSettings.model}`));
23033
+ console.log(chalk7.gray(` Total tasks: ${generationTasks.length}`));
22948
23034
  const startTime = Date.now();
22949
23035
  try {
22950
23036
  await Promise.all(
@@ -22952,24 +23038,32 @@ async function generateProjectFiles(dirs, projectData, modelSettings, environmen
22952
23038
  const taskStartTime = Date.now();
22953
23039
  if (debug) {
22954
23040
  const taskInfo = fileInfo[index2];
22955
- console.log(chalk6.gray(` [${index2 + 1}/${generationTasks.length}] Starting ${taskInfo.type}: ${taskInfo.name}`));
23041
+ console.log(
23042
+ chalk7.gray(
23043
+ ` [${index2 + 1}/${generationTasks.length}] Starting ${taskInfo.type}: ${taskInfo.name}`
23044
+ )
23045
+ );
22956
23046
  }
22957
23047
  await task;
22958
23048
  if (debug) {
22959
23049
  const taskInfo = fileInfo[index2];
22960
23050
  const taskDuration = Date.now() - taskStartTime;
22961
- console.log(chalk6.gray(` [${index2 + 1}/${generationTasks.length}] \u2713 Completed ${taskInfo.type}: ${taskInfo.name} (${taskDuration}ms)`));
23051
+ console.log(
23052
+ chalk7.gray(
23053
+ ` [${index2 + 1}/${generationTasks.length}] \u2713 Completed ${taskInfo.type}: ${taskInfo.name} (${taskDuration}ms)`
23054
+ )
23055
+ );
22962
23056
  }
22963
23057
  })
22964
23058
  );
22965
23059
  } catch (error) {
22966
23060
  if (debug) {
22967
- console.error(chalk6.red("\u{1F4CD} Debug: LLM generation error:"), error);
23061
+ console.error(chalk7.red("\u{1F4CD} Debug: LLM generation error:"), error);
22968
23062
  }
22969
23063
  throw error;
22970
23064
  }
22971
23065
  const totalDuration = Date.now() - startTime;
22972
- console.log(chalk6.gray(`
23066
+ console.log(chalk7.gray(`
22973
23067
  \u{1F4CD} Debug: LLM generation completed in ${totalDuration}ms`));
22974
23068
  } else {
22975
23069
  await Promise.all(generationTasks);
@@ -22978,14 +23072,14 @@ async function generateProjectFiles(dirs, projectData, modelSettings, environmen
22978
23072
  async function pullProjectCommand(options) {
22979
23073
  if (!env2.ANTHROPIC_API_KEY) {
22980
23074
  console.error(
22981
- chalk6.red("Error: ANTHROPIC_API_KEY environment variable is required for the pull command.")
23075
+ chalk7.red("Error: ANTHROPIC_API_KEY environment variable is required for the pull command.")
22982
23076
  );
22983
- console.error(chalk6.gray("Please set your Anthropic API key:"));
22984
- console.error(chalk6.gray(" export ANTHROPIC_API_KEY=your_api_key_here"));
22985
- console.error(chalk6.gray(" or add it to your .env file"));
23077
+ console.error(chalk7.gray("Please set your Anthropic API key:"));
23078
+ console.error(chalk7.gray(" export ANTHROPIC_API_KEY=your_api_key_here"));
23079
+ console.error(chalk7.gray(" or add it to your .env file"));
22986
23080
  process.exit(1);
22987
23081
  }
22988
- const spinner = ora4("Loading configuration...").start();
23082
+ const spinner = ora5("Loading configuration...").start();
22989
23083
  try {
22990
23084
  let config = null;
22991
23085
  let configFound = false;
@@ -23000,7 +23094,9 @@ async function pullProjectCommand(options) {
23000
23094
  configLocation = configPath;
23001
23095
  } catch (error) {
23002
23096
  spinner.fail("Failed to load specified configuration file");
23003
- console.error(chalk6.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
23097
+ console.error(
23098
+ chalk7.red(`Error: ${error instanceof Error ? error.message : String(error)}`)
23099
+ );
23004
23100
  process.exit(1);
23005
23101
  }
23006
23102
  } else {
@@ -23047,12 +23143,14 @@ async function pullProjectCommand(options) {
23047
23143
  }
23048
23144
  if (!configFound || !config) {
23049
23145
  spinner.fail("No inkeep.config.ts found");
23050
- console.error(chalk6.red("Configuration file is required for pull command"));
23051
- console.log(chalk6.yellow("Please create an inkeep.config.ts file with your tenantId and API settings"));
23052
- console.log(chalk6.gray("Searched in:"));
23053
- console.log(chalk6.gray(` \u2022 Current directory: ${searchDir}`));
23054
- console.log(chalk6.gray(` \u2022 Parent directory: ${join7(searchDir, "..")}`));
23055
- console.log(chalk6.gray(` \u2022 Parent directories up to root`));
23146
+ console.error(chalk7.red("Configuration file is required for pull command"));
23147
+ console.log(
23148
+ chalk7.yellow("Please create an inkeep.config.ts file with your tenantId and API settings")
23149
+ );
23150
+ console.log(chalk7.gray("Searched in:"));
23151
+ console.log(chalk7.gray(` \u2022 Current directory: ${searchDir}`));
23152
+ console.log(chalk7.gray(` \u2022 Parent directory: ${join7(searchDir, "..")}`));
23153
+ console.log(chalk7.gray(` \u2022 Parent directories up to root`));
23056
23154
  process.exit(1);
23057
23155
  }
23058
23156
  spinner.succeed(`Configuration loaded from ${configLocation}`);
@@ -23074,10 +23172,10 @@ async function pullProjectCommand(options) {
23074
23172
  spinner.succeed(`Output directory: ${baseDir}`);
23075
23173
  const finalConfig = {
23076
23174
  tenantId: config.tenantId,
23077
- // Tenant ID comes from config, not env flag
23078
23175
  projectId: "",
23079
23176
  // Will be determined from API response or user input
23080
- agentsManageApiUrl: options.agentsManageApiUrl || config.agentsManageApiUrl
23177
+ agentsManageApiUrl: config.agentsManageApi.url,
23178
+ agentsManageApiKey: config.agentsManageApi.apiKey
23081
23179
  };
23082
23180
  if (!options.project) {
23083
23181
  spinner.stop();
@@ -23088,7 +23186,7 @@ async function pullProjectCommand(options) {
23088
23186
  validate: (value) => value ? true : "Project ID is required"
23089
23187
  });
23090
23188
  if (!response.projectId) {
23091
- console.error(chalk6.red("Project ID is required"));
23189
+ console.error(chalk7.red("Project ID is required"));
23092
23190
  process.exit(1);
23093
23191
  }
23094
23192
  finalConfig.projectId = response.projectId;
@@ -23098,16 +23196,19 @@ async function pullProjectCommand(options) {
23098
23196
  finalConfig.projectId = projectIdFromPath;
23099
23197
  }
23100
23198
  spinner.succeed("Configuration loaded");
23101
- console.log(chalk6.gray("Configuration:"));
23102
- console.log(chalk6.gray(` \u2022 Tenant ID: ${finalConfig.tenantId}`));
23103
- console.log(chalk6.gray(` \u2022 Project ID: ${finalConfig.projectId}`));
23104
- console.log(chalk6.gray(` \u2022 API URL: ${finalConfig.agentsManageApiUrl}`));
23199
+ console.log(chalk7.gray("Configuration:"));
23200
+ console.log(chalk7.gray(` \u2022 Tenant ID: ${finalConfig.tenantId}`));
23201
+ console.log(chalk7.gray(` \u2022 Project ID: ${finalConfig.projectId}`));
23202
+ console.log(chalk7.gray(` \u2022 API URL: ${finalConfig.agentsManageApiUrl}`));
23105
23203
  spinner.start("Fetching project data from backend...");
23106
- const projectData = await fetchProjectData(
23204
+ const apiClient = await ManagementApiClient.create(
23205
+ finalConfig.agentsManageApiUrl,
23206
+ options.config,
23207
+ // Pass the config path from options
23107
23208
  finalConfig.tenantId,
23108
- finalConfig.projectId,
23109
- finalConfig.agentsManageApiUrl
23209
+ finalConfig.projectId
23110
23210
  );
23211
+ const projectData = await apiClient.getFullProject(finalConfig.projectId);
23111
23212
  spinner.succeed("Project data fetched");
23112
23213
  const graphCount = Object.keys(projectData.graphs || {}).length;
23113
23214
  const toolCount = Object.keys(projectData.tools || {}).length;
@@ -23119,27 +23220,27 @@ async function pullProjectCommand(options) {
23119
23220
  );
23120
23221
  const dataComponentCount = Object.keys(projectData.dataComponents || {}).length;
23121
23222
  const artifactComponentCount = Object.keys(projectData.artifactComponents || {}).length;
23122
- console.log(chalk6.cyan("\n\u{1F4CA} Project Summary:"));
23123
- console.log(chalk6.gray(` \u2022 Name: ${projectData.name}`));
23124
- console.log(chalk6.gray(` \u2022 Description: ${projectData.description || "No description"}`));
23125
- console.log(chalk6.gray(` \u2022 Graphs: ${graphCount}`));
23126
- console.log(chalk6.gray(` \u2022 Tools: ${toolCount}`));
23127
- console.log(chalk6.gray(` \u2022 Agents: ${agentCount}`));
23223
+ console.log(chalk7.cyan("\n\u{1F4CA} Project Summary:"));
23224
+ console.log(chalk7.gray(` \u2022 Name: ${projectData.name}`));
23225
+ console.log(chalk7.gray(` \u2022 Description: ${projectData.description || "No description"}`));
23226
+ console.log(chalk7.gray(` \u2022 Graphs: ${graphCount}`));
23227
+ console.log(chalk7.gray(` \u2022 Tools: ${toolCount}`));
23228
+ console.log(chalk7.gray(` \u2022 Agents: ${agentCount}`));
23128
23229
  if (dataComponentCount > 0) {
23129
- console.log(chalk6.gray(` \u2022 Data Components: ${dataComponentCount}`));
23230
+ console.log(chalk7.gray(` \u2022 Data Components: ${dataComponentCount}`));
23130
23231
  }
23131
23232
  if (artifactComponentCount > 0) {
23132
- console.log(chalk6.gray(` \u2022 Artifact Components: ${artifactComponentCount}`));
23233
+ console.log(chalk7.gray(` \u2022 Artifact Components: ${artifactComponentCount}`));
23133
23234
  }
23134
23235
  const credentialReferences2 = projectData.credentialReferences || {};
23135
23236
  const credentialCount = Object.keys(credentialReferences2).length;
23136
23237
  if (credentialCount > 0) {
23137
- console.log(chalk6.cyan("\n\u{1F510} Credentials Found:"));
23138
- console.log(chalk6.gray(` \u2022 Total credentials: ${credentialCount}`));
23238
+ console.log(chalk7.cyan("\n\u{1F510} Credentials Found:"));
23239
+ console.log(chalk7.gray(` \u2022 Total credentials: ${credentialCount}`));
23139
23240
  for (const [credId, credData] of Object.entries(credentialReferences2)) {
23140
23241
  const credType = credData.type || "unknown";
23141
23242
  const storeId = credData.credentialStoreId || "unknown";
23142
- console.log(chalk6.gray(` \u2022 ${credId} (${credType}, store: ${storeId})`));
23243
+ console.log(chalk7.gray(` \u2022 ${credId} (${credType}, store: ${storeId})`));
23143
23244
  const usageInfo = credData.usedBy;
23144
23245
  if (usageInfo && Array.isArray(usageInfo) && usageInfo.length > 0) {
23145
23246
  const usageByType = {};
@@ -23147,10 +23248,14 @@ async function pullProjectCommand(options) {
23147
23248
  usageByType[usage.type] = (usageByType[usage.type] || 0) + 1;
23148
23249
  }
23149
23250
  const usageSummary = Object.entries(usageByType).map(([type, count15]) => `${count15} ${type}${count15 > 1 ? "s" : ""}`).join(", ");
23150
- console.log(chalk6.gray(` Used by: ${usageSummary}`));
23251
+ console.log(chalk7.gray(` Used by: ${usageSummary}`));
23151
23252
  }
23152
23253
  }
23153
- console.log(chalk6.yellow(` \u26A0\uFE0F Environment file (${options.env || "development"}.env.ts) will be generated with credential references`));
23254
+ console.log(
23255
+ chalk7.yellow(
23256
+ ` \u26A0\uFE0F Environment file (${options.env || "development"}.env.ts) will be generated with credential references`
23257
+ )
23258
+ );
23154
23259
  }
23155
23260
  spinner.start("Creating project structure...");
23156
23261
  const dirs = createProjectStructure(baseDir, finalConfig.projectId);
@@ -23159,13 +23264,19 @@ async function pullProjectCommand(options) {
23159
23264
  const jsonFilePath = join7(dirs.projectRoot, `${finalConfig.projectId}.json`);
23160
23265
  writeFileSync4(jsonFilePath, JSON.stringify(projectData, null, 2));
23161
23266
  spinner.succeed(`Project data saved to ${jsonFilePath}`);
23162
- console.log(chalk6.green(`\u2705 JSON file created: ${jsonFilePath}`));
23267
+ console.log(chalk7.green(`\u2705 JSON file created: ${jsonFilePath}`));
23163
23268
  }
23164
23269
  spinner.start("Generating project files with LLM...");
23165
23270
  const modelSettings = {
23166
23271
  model: "anthropic/claude-sonnet-4-20250514"
23167
23272
  };
23168
- await generateProjectFiles(dirs, projectData, modelSettings, options.env || "development", options.debug || false);
23273
+ await generateProjectFiles(
23274
+ dirs,
23275
+ projectData,
23276
+ modelSettings,
23277
+ options.env || "development",
23278
+ options.debug || false
23279
+ );
23169
23280
  const fileCount = {
23170
23281
  graphs: Object.keys(projectData.graphs || {}).length,
23171
23282
  tools: Object.keys(projectData.tools || {}).length,
@@ -23176,62 +23287,70 @@ async function pullProjectCommand(options) {
23176
23287
  spinner.succeed(`Project files generated (${totalFiles} files created)`);
23177
23288
  spinner.start("Verifying generated files...");
23178
23289
  try {
23179
- const verificationResult = await verifyGeneratedFiles(dirs.projectRoot, projectData, options.debug || false, config);
23290
+ const verificationResult = await verifyGeneratedFiles(
23291
+ dirs.projectRoot,
23292
+ projectData,
23293
+ options.debug || false
23294
+ );
23180
23295
  if (verificationResult.success) {
23181
23296
  spinner.succeed("Generated files verified successfully");
23182
23297
  if (options.debug && verificationResult.warnings.length > 0) {
23183
- console.log(chalk6.yellow("\n\u26A0\uFE0F Verification warnings:"));
23298
+ console.log(chalk7.yellow("\n\u26A0\uFE0F Verification warnings:"));
23184
23299
  verificationResult.warnings.forEach((warning) => {
23185
- console.log(chalk6.gray(` \u2022 ${warning}`));
23300
+ console.log(chalk7.gray(` \u2022 ${warning}`));
23186
23301
  });
23187
23302
  }
23188
23303
  } else {
23189
23304
  spinner.fail("Generated files verification failed");
23190
- console.error(chalk6.red("\n\u274C Verification errors:"));
23305
+ console.error(chalk7.red("\n\u274C Verification errors:"));
23191
23306
  verificationResult.errors.forEach((error) => {
23192
- console.error(chalk6.red(` \u2022 ${error}`));
23307
+ console.error(chalk7.red(` \u2022 ${error}`));
23193
23308
  });
23194
23309
  if (verificationResult.warnings.length > 0) {
23195
- console.log(chalk6.yellow("\n\u26A0\uFE0F Verification warnings:"));
23310
+ console.log(chalk7.yellow("\n\u26A0\uFE0F Verification warnings:"));
23196
23311
  verificationResult.warnings.forEach((warning) => {
23197
- console.log(chalk6.gray(` \u2022 ${warning}`));
23312
+ console.log(chalk7.gray(` \u2022 ${warning}`));
23198
23313
  });
23199
23314
  }
23200
- console.log(chalk6.gray("\nThe generated files may not accurately represent the pulled project."));
23201
- console.log(chalk6.gray("This could indicate an issue with the LLM generation or schema mappings."));
23315
+ console.log(
23316
+ chalk7.gray("\nThe generated files may not accurately represent the pulled project.")
23317
+ );
23318
+ console.log(
23319
+ chalk7.gray("This could indicate an issue with the LLM generation or schema mappings.")
23320
+ );
23202
23321
  }
23203
23322
  } catch (error) {
23204
23323
  spinner.fail("Verification failed");
23205
- console.error(chalk6.red("Verification error:"), error.message);
23206
- console.log(chalk6.gray("Proceeding without verification..."));
23324
+ console.error(chalk7.red("Verification error:"), error.message);
23325
+ console.log(chalk7.gray("Proceeding without verification..."));
23207
23326
  }
23208
- console.log(chalk6.green("\n\u2728 Project pulled successfully!"));
23209
- console.log(chalk6.cyan("\n\u{1F4C1} Generated structure:"));
23210
- console.log(chalk6.gray(` ${dirs.projectRoot}/`));
23211
- console.log(chalk6.gray(` \u251C\u2500\u2500 index.ts`));
23327
+ console.log(chalk7.green("\n\u2728 Project pulled successfully!"));
23328
+ console.log(chalk7.cyan("\n\u{1F4C1} Generated structure:"));
23329
+ console.log(chalk7.gray(` ${dirs.projectRoot}/`));
23330
+ console.log(chalk7.gray(` \u251C\u2500\u2500 index.ts`));
23212
23331
  if (fileCount.graphs > 0) {
23213
- console.log(chalk6.gray(` \u251C\u2500\u2500 graphs/ (${fileCount.graphs} files)`));
23332
+ console.log(chalk7.gray(` \u251C\u2500\u2500 graphs/ (${fileCount.graphs} files)`));
23214
23333
  }
23215
23334
  if (fileCount.tools > 0) {
23216
- console.log(chalk6.gray(` \u251C\u2500\u2500 tools/ (${fileCount.tools} files)`));
23335
+ console.log(chalk7.gray(` \u251C\u2500\u2500 tools/ (${fileCount.tools} files)`));
23217
23336
  }
23218
23337
  if (fileCount.dataComponents > 0) {
23219
- console.log(chalk6.gray(` \u251C\u2500\u2500 data-components/ (${fileCount.dataComponents} files)`));
23338
+ console.log(chalk7.gray(` \u251C\u2500\u2500 data-components/ (${fileCount.dataComponents} files)`));
23220
23339
  }
23221
23340
  if (fileCount.artifactComponents > 0) {
23222
- console.log(chalk6.gray(` \u251C\u2500\u2500 artifact-components/ (${fileCount.artifactComponents} files)`));
23341
+ console.log(chalk7.gray(` \u251C\u2500\u2500 artifact-components/ (${fileCount.artifactComponents} files)`));
23223
23342
  }
23224
- console.log(chalk6.gray(" \u2514\u2500\u2500 environments/ (4 files)"));
23225
- console.log(chalk6.cyan("\n\u{1F4DD} Next steps:"));
23226
- console.log(chalk6.gray(` \u2022 cd ${dirs.projectRoot}`));
23227
- console.log(chalk6.gray(" \u2022 Review the generated files"));
23228
- console.log(chalk6.gray(" \u2022 Test locally: inkeep push"));
23343
+ console.log(chalk7.gray(" \u2514\u2500\u2500 environments/ (4 files)"));
23344
+ console.log(chalk7.cyan("\n\u{1F4DD} Next steps:"));
23345
+ console.log(chalk7.gray(` \u2022 cd ${dirs.projectRoot}`));
23346
+ console.log(chalk7.gray(" \u2022 Review the generated files"));
23347
+ console.log(chalk7.gray(" \u2022 Test locally: inkeep push"));
23229
23348
  console.log(
23230
- chalk6.gray(' \u2022 Commit changes: git add . && git commit -m "Add project from pull"')
23349
+ chalk7.gray(' \u2022 Commit changes: git add . && git commit -m "Add project from pull"')
23231
23350
  );
23232
23351
  } catch (error) {
23233
23352
  spinner.fail("Failed to pull project");
23234
- console.error(chalk6.red("Error:"), error.message);
23353
+ console.error(chalk7.red("Error:"), error.message);
23235
23354
  process.exit(1);
23236
23355
  }
23237
23356
  }
@@ -23240,9 +23359,9 @@ async function pullProjectCommand(options) {
23240
23359
  init_esm_shims();
23241
23360
  import { existsSync as existsSync8 } from "fs";
23242
23361
  import { join as join9, resolve as resolve5 } from "path";
23243
- import chalk7 from "chalk";
23244
- import ora5 from "ora";
23245
- init_config();
23362
+ import chalk8 from "chalk";
23363
+ import ora6 from "ora";
23364
+ init_cli_pipeline();
23246
23365
 
23247
23366
  // src/utils/environment-loader.ts
23248
23367
  init_esm_shims();
@@ -23297,23 +23416,15 @@ async function loadProject(projectDir) {
23297
23416
  );
23298
23417
  }
23299
23418
  async function pushCommand(options) {
23300
- const spinner = ora5("Loading configuration...").start();
23419
+ const { config } = await initializeCommand({
23420
+ configPath: options.config,
23421
+ showSpinner: true,
23422
+ spinnerText: "Loading configuration...",
23423
+ logConfig: true
23424
+ });
23425
+ let spinner;
23301
23426
  try {
23302
- const config = await validateConfiguration(
23303
- options.tenantId,
23304
- options.agentsManageApiUrl,
23305
- options.agentsRunApiUrl,
23306
- options.config
23307
- );
23308
- spinner.succeed("Configuration loaded");
23309
- console.log(chalk7.gray("Configuration sources:"));
23310
- console.log(chalk7.gray(` \u2022 Tenant ID: ${config.tenantId}`));
23311
- console.log(chalk7.gray(` \u2022 Manage API URL: ${config.agentsManageApiUrl}`));
23312
- console.log(chalk7.gray(` \u2022 Run API URL: ${config.agentsRunApiUrl}`));
23313
- if (config.sources.configFile) {
23314
- console.log(chalk7.gray(` \u2022 Config file: ${config.sources.configFile}`));
23315
- }
23316
- spinner.start("Detecting project...");
23427
+ spinner = ora6("Detecting project...").start();
23317
23428
  let projectDir;
23318
23429
  if (options.project) {
23319
23430
  projectDir = resolve5(process.cwd(), options.project);
@@ -23328,7 +23439,9 @@ async function pushCommand(options) {
23328
23439
  } else {
23329
23440
  spinner.fail("No index.ts found in current directory");
23330
23441
  console.error(
23331
- chalk7.yellow("Please run this command from a directory containing index.ts or use --project <path>")
23442
+ chalk8.yellow(
23443
+ "Please run this command from a directory containing index.ts or use --project <path>"
23444
+ )
23332
23445
  );
23333
23446
  process.exit(1);
23334
23447
  }
@@ -23358,8 +23471,10 @@ async function pushCommand(options) {
23358
23471
  if (typeof project.setConfig === "function") {
23359
23472
  project.setConfig(
23360
23473
  config.tenantId,
23361
- config.agentsManageApiUrl
23362
- // Note: models should be passed here if needed, not agentsRunApiUrl
23474
+ config.agentsManageApiUrl,
23475
+ void 0,
23476
+ // models - not needed here as they come from the project definition
23477
+ config.agentsManageApiKey
23363
23478
  );
23364
23479
  }
23365
23480
  if (options.env && typeof project.setCredentials === "function") {
@@ -23368,11 +23483,11 @@ async function pushCommand(options) {
23368
23483
  const credentials = await loadEnvironmentCredentials(projectDir, options.env);
23369
23484
  project.setCredentials(credentials);
23370
23485
  spinner.text = "Project loaded with credentials";
23371
- console.log(chalk7.gray(` \u2022 Environment: ${options.env}`));
23372
- console.log(chalk7.gray(` \u2022 Credentials loaded: ${Object.keys(credentials).length}`));
23486
+ console.log(chalk8.gray(` \u2022 Environment: ${options.env}`));
23487
+ console.log(chalk8.gray(` \u2022 Credentials loaded: ${Object.keys(credentials).length}`));
23373
23488
  } catch (error) {
23374
23489
  spinner.fail("Failed to load environment credentials");
23375
- console.error(chalk7.red("Error:"), error.message);
23490
+ console.error(chalk8.red("Error:"), error.message);
23376
23491
  process.exit(1);
23377
23492
  }
23378
23493
  }
@@ -23384,8 +23499,8 @@ async function pushCommand(options) {
23384
23499
  const fs5 = await import("fs/promises");
23385
23500
  await fs5.writeFile(jsonFilePath, JSON.stringify(projectDefinition, null, 2));
23386
23501
  spinner.succeed(`Project data saved to ${jsonFilePath}`);
23387
- console.log(chalk7.gray(` \u2022 File: ${jsonFilePath}`));
23388
- console.log(chalk7.gray(` \u2022 Size: ${JSON.stringify(projectDefinition).length} bytes`));
23502
+ console.log(chalk8.gray(` \u2022 File: ${jsonFilePath}`));
23503
+ console.log(chalk8.gray(` \u2022 Size: ${JSON.stringify(projectDefinition).length} bytes`));
23389
23504
  const graphCount = Object.keys(projectDefinition.graphs || {}).length;
23390
23505
  const toolCount = Object.keys(projectDefinition.tools || {}).length;
23391
23506
  const agentCount = Object.values(projectDefinition.graphs || {}).reduce(
@@ -23394,15 +23509,15 @@ async function pushCommand(options) {
23394
23509
  },
23395
23510
  0
23396
23511
  );
23397
- console.log(chalk7.cyan("\n\u{1F4CA} Project Data Summary:"));
23398
- console.log(chalk7.gray(` \u2022 Graphs: ${graphCount}`));
23399
- console.log(chalk7.gray(` \u2022 Tools: ${toolCount}`));
23400
- console.log(chalk7.gray(` \u2022 Agents: ${agentCount}`));
23401
- console.log(chalk7.green("\n\u2728 JSON file generated successfully!"));
23512
+ console.log(chalk8.cyan("\n\u{1F4CA} Project Data Summary:"));
23513
+ console.log(chalk8.gray(` \u2022 Graphs: ${graphCount}`));
23514
+ console.log(chalk8.gray(` \u2022 Tools: ${toolCount}`));
23515
+ console.log(chalk8.gray(` \u2022 Agents: ${agentCount}`));
23516
+ console.log(chalk8.green("\n\u2728 JSON file generated successfully!"));
23402
23517
  process.exit(0);
23403
23518
  } catch (error) {
23404
23519
  spinner.fail("Failed to generate JSON file");
23405
- console.error(chalk7.red("Error:"), error.message);
23520
+ console.error(chalk8.red("Error:"), error.message);
23406
23521
  process.exit(1);
23407
23522
  }
23408
23523
  }
@@ -23412,18 +23527,18 @@ async function pushCommand(options) {
23412
23527
  const projectName = project.getName();
23413
23528
  const stats = project.getStats();
23414
23529
  spinner.succeed(`Project "${projectName}" (${projectId}) pushed successfully`);
23415
- console.log(chalk7.cyan("\n\u{1F4CA} Project Summary:"));
23416
- console.log(chalk7.gray(` \u2022 Project ID: ${projectId}`));
23417
- console.log(chalk7.gray(` \u2022 Name: ${projectName}`));
23418
- console.log(chalk7.gray(` \u2022 Graphs: ${stats.graphCount}`));
23419
- console.log(chalk7.gray(` \u2022 Tenant: ${stats.tenantId}`));
23530
+ console.log(chalk8.cyan("\n\u{1F4CA} Project Summary:"));
23531
+ console.log(chalk8.gray(` \u2022 Project ID: ${projectId}`));
23532
+ console.log(chalk8.gray(` \u2022 Name: ${projectName}`));
23533
+ console.log(chalk8.gray(` \u2022 Graphs: ${stats.graphCount}`));
23534
+ console.log(chalk8.gray(` \u2022 Tenant: ${stats.tenantId}`));
23420
23535
  const graphs = project.getGraphs();
23421
23536
  if (graphs.length > 0) {
23422
- console.log(chalk7.cyan("\n\u{1F4CA} Graph Details:"));
23537
+ console.log(chalk8.cyan("\n\u{1F4CA} Graph Details:"));
23423
23538
  for (const graph of graphs) {
23424
23539
  const graphStats = graph.getStats();
23425
23540
  console.log(
23426
- chalk7.gray(
23541
+ chalk8.gray(
23427
23542
  ` \u2022 ${graph.getName()} (${graph.getId()}): ${graphStats.agentCount} agents, ${graphStats.toolCount} tools`
23428
23543
  )
23429
23544
  );
@@ -23433,37 +23548,40 @@ async function pushCommand(options) {
23433
23548
  const credentialTracking = await project.getCredentialTracking();
23434
23549
  const credentialCount = Object.keys(credentialTracking.credentials).length;
23435
23550
  if (credentialCount > 0) {
23436
- console.log(chalk7.cyan("\n\u{1F510} Credentials:"));
23437
- console.log(chalk7.gray(` \u2022 Total credentials: ${credentialCount}`));
23551
+ console.log(chalk8.cyan("\n\u{1F510} Credentials:"));
23552
+ console.log(chalk8.gray(` \u2022 Total credentials: ${credentialCount}`));
23438
23553
  for (const [credId, credData] of Object.entries(credentialTracking.credentials)) {
23439
23554
  const usageInfo = credentialTracking.usage[credId] || [];
23440
23555
  const credType = credData.type || "unknown";
23441
23556
  const storeId = credData.credentialStoreId || "unknown";
23442
- console.log(chalk7.gray(` \u2022 ${credId} (${credType}, store: ${storeId})`));
23557
+ console.log(chalk8.gray(` \u2022 ${credId} (${credType}, store: ${storeId})`));
23443
23558
  if (usageInfo.length > 0) {
23444
23559
  const usageByType = {};
23445
23560
  for (const usage of usageInfo) {
23446
23561
  usageByType[usage.type] = (usageByType[usage.type] || 0) + 1;
23447
23562
  }
23448
23563
  const usageSummary = Object.entries(usageByType).map(([type, count15]) => `${count15} ${type}${count15 > 1 ? "s" : ""}`).join(", ");
23449
- console.log(chalk7.gray(` Used by: ${usageSummary}`));
23564
+ console.log(chalk8.gray(` Used by: ${usageSummary}`));
23450
23565
  }
23451
23566
  }
23452
23567
  }
23453
- } catch (error) {
23568
+ } catch (_error) {
23454
23569
  if (env2.DEBUG) {
23455
- console.error(chalk7.yellow("Could not retrieve credential tracking information"));
23570
+ console.error(chalk8.yellow("Could not retrieve credential tracking information"));
23456
23571
  }
23457
23572
  }
23458
- console.log(chalk7.green("\n\u2728 Next steps:"));
23459
- console.log(chalk7.gray(` \u2022 Test your project: inkeep chat`));
23460
- console.log(chalk7.gray(` \u2022 View all graphs: inkeep list-graphs`));
23573
+ console.log(chalk8.green("\n\u2728 Next steps:"));
23574
+ console.log(chalk8.gray(` \u2022 Test your project: inkeep chat`));
23575
+ console.log(chalk8.gray(` \u2022 View all graphs: inkeep list-graphs`));
23461
23576
  process.exit(0);
23462
- } catch (error) {
23463
- spinner.fail("Failed to push project");
23464
- console.error(chalk7.red("Error:"), error.message);
23577
+ } catch (_error) {
23578
+ if (spinner) {
23579
+ spinner.fail("Failed to push project");
23580
+ }
23581
+ const error = _error;
23582
+ console.error(chalk8.red("Error:"), error.message);
23465
23583
  if (error.stack && env2.DEBUG) {
23466
- console.error(chalk7.gray(error.stack));
23584
+ console.error(chalk8.gray(error.stack));
23467
23585
  }
23468
23586
  process.exit(1);
23469
23587
  }