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