@unikode/cli 1.0.16 → 1.0.17

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 +23 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3680,36 +3680,46 @@ async function executeLocalTool(toolName, input, mode) {
3680
3680
  }
3681
3681
  case "webSearchTool": {
3682
3682
  const { query, searchDepth, maxResults, includeAnswer } = toolInputSchemas.webSearchTool.parse(input);
3683
- const apiKey = process.env.TAVILY_API_KEY;
3684
- const tavilyapiurl = process.env.TAVILY_API_URL;
3685
- if (!apiKey) {
3683
+ const apiUrl = process.env.API_URL ?? "http://localhost:3000";
3684
+ const searchEndpointUrl = apiUrl + "/tools/webSearchTool";
3685
+ if (!searchEndpointUrl) {
3686
3686
  return {
3687
3687
  error: true,
3688
- message: "TAVILY_API_KEY is not set in the environment. Add it to your .env file to enable web search."
3688
+ message: "WEB_SEARCH_ENDPOINT_URL is not configured in the CLI environment."
3689
3689
  };
3690
3690
  }
3691
3691
  try {
3692
- const response = await fetch(`${tavilyapiurl}`, {
3692
+ const auth = getAuth();
3693
+ const headers = {
3694
+ "Content-Type": "application/json"
3695
+ };
3696
+ if (auth) {
3697
+ headers["Authorization"] = `Bearer ${auth.token}`;
3698
+ }
3699
+ const response = await fetch(searchEndpointUrl, {
3693
3700
  method: "POST",
3694
- headers: {
3695
- "Content-Type": "application/json"
3696
- },
3701
+ headers,
3697
3702
  body: JSON.stringify({
3698
- api_key: apiKey,
3699
3703
  query,
3700
- search_depth: searchDepth,
3701
- max_results: maxResults,
3702
- include_answer: includeAnswer
3704
+ searchDepth,
3705
+ maxResults,
3706
+ includeAnswer
3703
3707
  })
3704
3708
  });
3705
3709
  if (!response.ok) {
3706
3710
  const errorText = await response.text();
3707
3711
  return {
3708
3712
  error: true,
3709
- message: `Tavily API request failed (${response.status}): ${errorText}`
3713
+ message: `Web search service failed (${response.status}): ${errorText}`
3710
3714
  };
3711
3715
  }
3712
3716
  const data = await response.json();
3717
+ if (data.error) {
3718
+ return {
3719
+ error: true,
3720
+ message: data.error
3721
+ };
3722
+ }
3713
3723
  return {
3714
3724
  error: false,
3715
3725
  query,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unikode/cli",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {