@xyd-js/ask-ai-widget 0.0.0-build-be800ef-20251021211339 → 0.0.0-build-a1d398e-20251028174055

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyd-js/ask-ai-widget",
3
- "version": "0.0.0-build-be800ef-20251021211339",
3
+ "version": "0.0.0-build-a1d398e-20251028174055",
4
4
  "type": "module",
5
5
  "main": "dist/server.js",
6
6
  "files": [
@@ -17,9 +17,9 @@
17
17
  "express": "^4.18.2",
18
18
  "react": "^19.0.0",
19
19
  "react-dom": "^19.0.0",
20
- "@xyd-js/ask-ai": "0.0.0-build-be800ef-20251021211339",
20
+ "@xyd-js/ask-ai": "0.0.0-build-a1d398e-20251028174055",
21
21
  "@xyd-js/cli-sdk": "0.1.0-build.0",
22
- "@xyd-js/mcp-server": "0.0.0-build-be800ef-20251021211339"
22
+ "@xyd-js/mcp-server": "0.0.0-build-a1d398e-20251028174055"
23
23
  },
24
24
  "devDependencies": {
25
25
  "openapi-typescript": "^7.9.1"
package/server.ts CHANGED
@@ -5,16 +5,18 @@ import { loadSetting } from "./src/utils";
5
5
 
6
6
  loadSetting()
7
7
  .then((settings) => {
8
- if (!settings.mcp?.url) {
9
- throw new Error("MCP_SOURCE is not set");
10
- }
8
+ const openApiSource = settings.sources?.openapi || "";
9
+ const llmsTxtSource = settings.sources?.llmsTxt || "";
11
10
 
12
- const openApiSource = settings.mcp?.sources?.openapi || "";
13
- if (!openApiSource) {
14
- console.warn("Open API source is not set");
11
+ if (!llmsTxtSource && !openApiSource) {
12
+ console.warn("llms txt or open api source is not set");
15
13
  }
16
14
 
17
- const mcpServer = new MCPServer(openApiSource);
15
+ const mcpServer = new MCPServer({
16
+ uniformSources: openApiSource,
17
+ llmsSources: llmsTxtSource,
18
+ openAIApiKey: process.env.OPENAI_API_KEY || "", // TODO: configurable
19
+ });
18
20
 
19
21
  return startServer(settings, mcpServer);
20
22
  })
package/src/Widget.tsx CHANGED
@@ -6,6 +6,7 @@ import { AskAI, useAskAI } from "@xyd-js/ask-ai/react";
6
6
 
7
7
  interface WidgetConfig {
8
8
  endpointURL?: string;
9
+ dockInput: boolean;
9
10
  }
10
11
 
11
12
  interface AskWidgetProps {
@@ -50,6 +51,7 @@ export function AskWidget({ config = {} }: AskWidgetProps) {
50
51
  onSubmit={submit as any}
51
52
  disabled={disabled}
52
53
  placeholder={getPlaceholder()}
54
+ dockInput={config?.dockInput || undefined}
53
55
  ref={ref}
54
56
  >
55
57
  <div slot="title">
@@ -80,5 +82,5 @@ export function AskWidget({ config = {} }: AskWidgetProps) {
80
82
  }
81
83
 
82
84
  function _Message({ message }: { message: string }) {
83
- return <ProseMd content={message} />;
85
+ return <ProseMd languges={['javascript', 'jsx', 'tsx', 'ts', 'txt', 'md', 'mdx', 'bash']} content={message} />;
84
86
  }
package/src/index.ts CHANGED
@@ -3,7 +3,6 @@ import { join, dirname } from "node:path";
3
3
  import { createServer } from "node:http";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
- import { Router } from 'express';
7
6
  import express from "express";
8
7
 
9
8
  import { handler as askAiHandler } from "@xyd-js/ask-ai/node";
@@ -66,7 +65,8 @@ export async function startServer(
66
65
  body: body,
67
66
  });
68
67
 
69
- let mcpUrl = settings.mcp?.url || "";
68
+ // TODO: check if it works
69
+ let mcpUrl = settings.mcp?.url || request.url + "/mcp";
70
70
  if (Array.isArray(mcpUrl)) {
71
71
  console.warn("MCP as array is not supported, using the first one");
72
72
  mcpUrl = mcpUrl[0];
package/src/settings.ts CHANGED
@@ -61,12 +61,12 @@ export interface Sources {
61
61
  * @example "http://localhost:3000/openapi.yaml"
62
62
  * @example ["http://localhost:3000/openapi.yaml", "./openapi.yaml"]
63
63
  */
64
- openapi: string | string[];
64
+ openapi?: string | string[];
65
65
 
66
66
  /**
67
- * The LLMs sources to use
67
+ * The LLMs txt sources to use
68
68
  * @example "http://localhost:3000/llms.tx"
69
69
  * @example ["http://localhost:3000/llms.txt", "./llms.txt"]
70
70
  */
71
- llms: string | string[];
71
+ llmsTxt?: string | string[];
72
72
  }
package/src/utils.ts CHANGED
@@ -61,7 +61,7 @@ function ensureSettings(settings: Settings) {
61
61
  if (!settings.sources) {
62
62
  settings.sources = {
63
63
  openapi: "",
64
- llms: "",
64
+ llmsTxt: "",
65
65
  };
66
66
  }
67
67
 
@@ -70,9 +70,9 @@ function ensureSettings(settings: Settings) {
70
70
  console.log("(env settings): using OPENAPI_SOURCE");
71
71
  }
72
72
 
73
- if (process.env.LLMS_SOURCE) {
74
- settings.sources.llms = process.env.LLMS_SOURCE;
75
- console.log("(env settings): using LLMS_SOURCE");
73
+ if (process.env.LLMS_TXT_SOURCE) {
74
+ settings.sources.llmsTxt = process.env.LLMS_TXT_SOURCE;
75
+ console.log("(env settings): using LLMS_TXT_SOURCE");
76
76
  }
77
77
 
78
78
  if (process.env.MCP_URL) {
package/widget.tsx CHANGED
@@ -9,8 +9,13 @@ import { AskWidget } from "./src/Widget";
9
9
  // Extract data attributes
10
10
  const config = {
11
11
  askAiServer: resolveServerUrl(currentScript),
12
+ dockInput: true,
12
13
  };
13
14
 
15
+ if (currentScript?.dataset["dockInput"] === "false") {
16
+ config.dockInput = false;
17
+ }
18
+
14
19
  // Create a container div and append it to body
15
20
  const container = document.createElement("div");
16
21
  container.id = "xyd-ask-ai-widget";
@@ -22,6 +27,7 @@ import { AskWidget } from "./src/Widget";
22
27
  <AskWidget
23
28
  config={{
24
29
  endpointURL: `${config.askAiServer}/ask`,
30
+ dockInput: config.dockInput,
25
31
  }}
26
32
  />
27
33
  );