@xyd-js/ask-ai-widget 0.0.0-build-2bb31f3-20251012215032 → 0.0.0-build-340e7ed-20251012221832
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/server-standalone.js +22 -7
- package/dist/server.js +49 -34
- package/package.json +3 -3
- package/src/index.ts +29 -10
|
@@ -24127,8 +24127,9 @@ var require_src2 = __commonJS((exports) => {
|
|
|
24127
24127
|
// src/index.ts
|
|
24128
24128
|
var import_express = __toESM(require_express2(), 1);
|
|
24129
24129
|
import { readFileSync, existsSync } from "node:fs";
|
|
24130
|
-
import { join } from "node:path";
|
|
24130
|
+
import { join, dirname } from "node:path";
|
|
24131
24131
|
import { createServer } from "node:http";
|
|
24132
|
+
import { fileURLToPath } from "node:url";
|
|
24132
24133
|
|
|
24133
24134
|
// ../xyd-ask-ai/dist/node/index.js
|
|
24134
24135
|
import { env as e2 } from "node:process";
|
|
@@ -57219,12 +57220,8 @@ async function ba(e3) {
|
|
|
57219
57220
|
|
|
57220
57221
|
// src/index.ts
|
|
57221
57222
|
async function startServer(mcpServer) {
|
|
57222
|
-
const widgetPath =
|
|
57223
|
-
|
|
57224
|
-
console.log("❌ Widget not found!");
|
|
57225
|
-
console.log("\uD83D\uDD28 Please run: bun run build:widget");
|
|
57226
|
-
process.exit(1);
|
|
57227
|
-
}
|
|
57223
|
+
const widgetPath = findWidgetPath();
|
|
57224
|
+
console.log("✅ Widget found:", widgetPath);
|
|
57228
57225
|
const port = await findAvailablePort(parseInt(process.env.PORT || "3500"));
|
|
57229
57226
|
console.log(`\uD83D\uDD0D Trying to start server on port ${port}...`);
|
|
57230
57227
|
const app = import_express.default();
|
|
@@ -57303,6 +57300,24 @@ async function startServer(mcpServer) {
|
|
|
57303
57300
|
}
|
|
57304
57301
|
});
|
|
57305
57302
|
}
|
|
57303
|
+
function findWidgetPath() {
|
|
57304
|
+
const __filename2 = fileURLToPath(import.meta.url);
|
|
57305
|
+
const __dirname2 = dirname(__filename2);
|
|
57306
|
+
const possiblePaths = [
|
|
57307
|
+
join(process.cwd(), "dist", "widget.js"),
|
|
57308
|
+
join(__dirname2, "..", "dist", "widget.js"),
|
|
57309
|
+
join(__dirname2, "dist", "widget.js")
|
|
57310
|
+
];
|
|
57311
|
+
for (const path of possiblePaths) {
|
|
57312
|
+
if (existsSync(path)) {
|
|
57313
|
+
return path;
|
|
57314
|
+
}
|
|
57315
|
+
}
|
|
57316
|
+
console.log("❌ Widget not found!");
|
|
57317
|
+
console.log("\uD83D\uDD28 Please run: bun run build:widget");
|
|
57318
|
+
console.log("\uD83D\uDCA1 Searched in:", possiblePaths);
|
|
57319
|
+
process.exit(1);
|
|
57320
|
+
}
|
|
57306
57321
|
async function findAvailablePort(startPort = 3500, maxAttempts = 10) {
|
|
57307
57322
|
for (let i2 = 0;i2 < maxAttempts; i2++) {
|
|
57308
57323
|
const port = startPort + i2;
|
package/dist/server.js
CHANGED
|
@@ -157313,7 +157313,7 @@ function G4(e488) {
|
|
|
157313
157313
|
var { className: t481, children: r325 } = e488;
|
|
157314
157314
|
return import_react5.default.createElement("code", { className: "".concat("c1w59zdn", " ").concat(t481 || "") }, import_react5.default.createElement("span", { part: "content" }, r325));
|
|
157315
157315
|
}
|
|
157316
|
-
function
|
|
157316
|
+
function K4(e488) {
|
|
157317
157317
|
var r325, a443 = e488.children, o237 = e488.label, i314 = Wt(), l52 = function(e489, n470, r326) {
|
|
157318
157318
|
var a444 = import_react5.useState(false), o238 = M2(a444, 2), i315 = o238[0], l53 = o238[1];
|
|
157319
157319
|
return function(t481) {
|
|
@@ -157327,9 +157327,9 @@ function Y4(e488) {
|
|
|
157327
157327
|
}), c105 = ["secondary", "tertiary"].includes(e488.kind || "");
|
|
157328
157328
|
c105 && "title" in e488 && (r325 = e488.title);
|
|
157329
157329
|
var u28 = e488.kind || "primary";
|
|
157330
|
-
return import_react5.default.createElement("details", { part: "details", className: "".concat("dwmojve", " ").concat(e488.className || ""), "data-kind": e488.kind, onClick: l52 }, import_react5.default.createElement("summary", { part: "summary" }, u28 === "primary" && import_react5.default.createElement(import_react5.default.Fragment, null, e488.icon || import_react5.default.createElement(
|
|
157330
|
+
return import_react5.default.createElement("details", { part: "details", className: "".concat("dwmojve", " ").concat(e488.className || ""), "data-kind": e488.kind, onClick: l52 }, import_react5.default.createElement("summary", { part: "summary" }, u28 === "primary" && import_react5.default.createElement(import_react5.default.Fragment, null, e488.icon || import_react5.default.createElement(Y4, null), import_react5.default.createElement("div", { part: "summary-deep-label" }, o237)), c105 && import_react5.default.createElement("div", null, import_react5.default.createElement("div", { part: "summary-deep" }, e488.icon || import_react5.default.createElement(X5, null), import_react5.default.createElement("div", { part: "summary-deep-text" }, r325)), import_react5.default.createElement("div", { part: "summary-deep-label" }, o237)), c105 && import_react5.default.createElement(Y4, null)), import_react5.default.createElement("div", { part: "content" }, a443));
|
|
157331
157331
|
}
|
|
157332
|
-
function
|
|
157332
|
+
function Y4() {
|
|
157333
157333
|
return import_react5.default.createElement("div", { part: "icon" }, import_react5.default.createElement("svg", { "data-icon": "true", xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "currentColor", viewBox: "0 0 24 24" }, import_react5.default.createElement("path", { fillRule: "evenodd", d: "M8.293 4.293a1 1 0 0 1 1.414 0l7 7a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414L14.586 12 8.293 5.707a1 1 0 0 1 0-1.414Z", clipRule: "evenodd" })));
|
|
157334
157334
|
}
|
|
157335
157335
|
function X5() {
|
|
@@ -157588,7 +157588,7 @@ function _e2(e488) {
|
|
|
157588
157588
|
return o238.startsWith("/") || (o238 = "/" + o238), "".concat(r326).concat(o238);
|
|
157589
157589
|
console.warn("Multiple canonical links found for property", e489.name, e489.symbolDef.canonical);
|
|
157590
157590
|
return "";
|
|
157591
|
-
}(t481), l52 =
|
|
157591
|
+
}(t481), l52 = ze2(t481);
|
|
157592
157592
|
return l52 ? (i314 && (l52 = import_react5.default.createElement(o237, { className: ye2, href: i314 }, l52)), import_react5.default.createElement("atlas-apiref-proptype", null, import_react5.default.createElement("dd", null, import_react5.default.createElement("code", { className: ge2 }, l52)))) : null;
|
|
157593
157593
|
}
|
|
157594
157594
|
function Pe2(e488) {
|
|
@@ -157664,7 +157664,7 @@ function Te2(e488) {
|
|
|
157664
157664
|
}));
|
|
157665
157665
|
});
|
|
157666
157666
|
}
|
|
157667
|
-
function
|
|
157667
|
+
function ze2(e488) {
|
|
157668
157668
|
var n470 = function e(n471) {
|
|
157669
157669
|
var t481, r325, a443, o237, i314, l52, c105, u28, s187, d29;
|
|
157670
157670
|
if (n471 == null ? undefined : n471.ofProperty)
|
|
@@ -157675,13 +157675,13 @@ function Me2(e488) {
|
|
|
157675
157675
|
var v4 = qe2(n471.ofProperty.ofProperty);
|
|
157676
157676
|
v4 && m82.push(v4);
|
|
157677
157677
|
}
|
|
157678
|
-
var p28 =
|
|
157678
|
+
var p28 = Me2(n471.ofProperty);
|
|
157679
157679
|
return [[].concat([p28, "of"], m82).join(" ")];
|
|
157680
157680
|
case DEFINED_DEFINITION_PROPERTY_TYPE.UNION:
|
|
157681
157681
|
case DEFINED_DEFINITION_PROPERTY_TYPE.ENUM:
|
|
157682
157682
|
case DEFINED_DEFINITION_PROPERTY_TYPE.XOR:
|
|
157683
157683
|
if ((t481 = n471.ofProperty.properties) === null || t481 === undefined ? undefined : t481.length) {
|
|
157684
|
-
var f4 =
|
|
157684
|
+
var f4 = Me2(n471);
|
|
157685
157685
|
if (f4) {
|
|
157686
157686
|
var h6 = "";
|
|
157687
157687
|
return n471.ofProperty.type === DEFINED_DEFINITION_PROPERTY_TYPE.ENUM && ((r325 = n471.ofProperty.ofProperty) === null || r325 === undefined ? undefined : r325.type) && (h6 = qe2({ type: (a443 = n471.ofProperty.ofProperty) === null || a443 === undefined ? undefined : a443.type, properties: n471.ofProperty.properties || [] })), h6 || (h6 = qe2({ type: DEFINED_DEFINITION_PROPERTY_TYPE.UNION, properties: n471.ofProperty.properties || [] })), (h6 == null ? undefined : h6.length) && h6.includes("$$") ? [f4] : [[f4, "of", h6].join(" ")];
|
|
@@ -157691,8 +157691,8 @@ function Me2(e488) {
|
|
|
157691
157691
|
return ((o237 = n471.ofProperty) === null || o237 === undefined ? undefined : o237.ofProperty) ? [(l52 = (i314 = n471.ofProperty) === null || i314 === undefined ? undefined : i314.ofProperty) === null || l52 === undefined ? undefined : l52.type] : [];
|
|
157692
157692
|
default:
|
|
157693
157693
|
if (!n471.ofProperty.name) {
|
|
157694
|
-
var g6 =
|
|
157695
|
-
var n472 =
|
|
157694
|
+
var g6 = Me2(n471), E8 = function(e489) {
|
|
157695
|
+
var n472 = Me2(e489);
|
|
157696
157696
|
if (!n472)
|
|
157697
157697
|
return e489.type;
|
|
157698
157698
|
return n472;
|
|
@@ -157750,7 +157750,7 @@ function Me2(e488) {
|
|
|
157750
157750
|
})) || false;
|
|
157751
157751
|
}(e488) && (n470.length ? n470.push("or", "null") : n470.push("null")), n470.join(" ");
|
|
157752
157752
|
}
|
|
157753
|
-
function
|
|
157753
|
+
function Me2(e488) {
|
|
157754
157754
|
switch (e488.type) {
|
|
157755
157755
|
case DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY:
|
|
157756
157756
|
return "array";
|
|
@@ -157762,7 +157762,7 @@ function ze2(e488) {
|
|
|
157762
157762
|
}
|
|
157763
157763
|
}
|
|
157764
157764
|
function qe2(e488) {
|
|
157765
|
-
var n470, t481 =
|
|
157765
|
+
var n470, t481 = ze2(e488);
|
|
157766
157766
|
return ((n470 = t481 == null ? undefined : t481.startsWith) === null || n470 === undefined ? undefined : n470.call(t481, "$$")) ? "" : t481;
|
|
157767
157767
|
}
|
|
157768
157768
|
function Ie2(e488) {
|
|
@@ -157833,10 +157833,10 @@ function We2(e488) {
|
|
|
157833
157833
|
function Ge2(e488) {
|
|
157834
157834
|
return e488.hasOwnProperty("lineNumber");
|
|
157835
157835
|
}
|
|
157836
|
-
function
|
|
157836
|
+
function Ke2(e488) {
|
|
157837
157837
|
return typeof e488 == "string";
|
|
157838
157838
|
}
|
|
157839
|
-
var
|
|
157839
|
+
var Ye2 = ["color"];
|
|
157840
157840
|
function Xe2(e488, n470) {
|
|
157841
157841
|
return Ze2.apply(this, arguments);
|
|
157842
157842
|
}
|
|
@@ -157894,7 +157894,7 @@ function Qe2(e488) {
|
|
|
157894
157894
|
return e489.map(function(e490) {
|
|
157895
157895
|
if ("tokens" in e490)
|
|
157896
157896
|
throw new Error("Shouldnt be groups");
|
|
157897
|
-
var n471 = [e490.content], t482 = e490.style || {}, r326 = t482.color, a444 = I4(t482,
|
|
157897
|
+
var n471 = [e490.content], t482 = e490.style || {}, r326 = t482.color, a444 = I4(t482, Ye2);
|
|
157898
157898
|
return n471.push(r326), Object.keys(a444).length && n471.push(a444), n471;
|
|
157899
157899
|
});
|
|
157900
157900
|
}(t481.tokens);
|
|
@@ -157905,7 +157905,7 @@ function Qe2(e488) {
|
|
|
157905
157905
|
function en(e488) {
|
|
157906
157906
|
var n470 = [];
|
|
157907
157907
|
return e488.forEach(function(e489) {
|
|
157908
|
-
if (
|
|
157908
|
+
if (Ke2(e489))
|
|
157909
157909
|
n470.push(e489);
|
|
157910
157910
|
else {
|
|
157911
157911
|
var t481 = function(e490) {
|
|
@@ -157923,9 +157923,9 @@ function en(e488) {
|
|
|
157923
157923
|
function nn(e488) {
|
|
157924
157924
|
var n470 = [];
|
|
157925
157925
|
return e488.forEach(function(e489) {
|
|
157926
|
-
if (
|
|
157926
|
+
if (Ke2(e489)) {
|
|
157927
157927
|
var t481 = n470[n470.length - 1];
|
|
157928
|
-
t481 &&
|
|
157928
|
+
t481 && Ke2(t481) ? n470[n470.length - 1] += e489 : e489 !== "" && n470.push(e489);
|
|
157929
157929
|
} else
|
|
157930
157930
|
e489[0].length > 0 && n470.push(e489);
|
|
157931
157931
|
}), n470;
|
|
@@ -158270,9 +158270,9 @@ function Tn(e488) {
|
|
|
158270
158270
|
})) === null || n470 === undefined ? undefined : n470.Block, s187 = Ln({ linesOrGroups: l52, handlers: r325, inlineAnnotations: a443, annotationStack: [].concat(j2(o237), [i314]) });
|
|
158271
158271
|
return u28 ? un.jsx(u28, { annotation: i314, children: s187 }) : s187;
|
|
158272
158272
|
}
|
|
158273
|
-
var
|
|
158274
|
-
var
|
|
158275
|
-
var { code: t481, handlers: r325 } = e488, a443 = r325 === undefined ? [] : r325, o237 = I4(e488,
|
|
158273
|
+
var zn = ["code", "handlers"];
|
|
158274
|
+
var Mn = import_react5.forwardRef(function(e488, n470) {
|
|
158275
|
+
var { code: t481, handlers: r325 } = e488, a443 = r325 === undefined ? [] : r325, o237 = I4(e488, zn), i314 = t481.tokens, l52 = t481.themeName, c105 = t481.lang, u28 = t481.annotations;
|
|
158276
158276
|
if (!i314)
|
|
158277
158277
|
throw new Error("Missing tokens in code block. Use the `highlight` function to generate the tokens.");
|
|
158278
158278
|
a443.filter(function(e489) {
|
|
@@ -158404,13 +158404,13 @@ var Wn = import_react5.default.createContext({ ref: { current: null }, setActive
|
|
|
158404
158404
|
function Gn() {
|
|
158405
158405
|
return import_react5.default.useContext(Wn);
|
|
158406
158406
|
}
|
|
158407
|
-
function
|
|
158407
|
+
function Kn(e488) {
|
|
158408
158408
|
var r325 = e488.children, a443 = import_react5.useRef(null), o237 = import_react5.useState(""), c105 = M2(o237, 2), u28 = c105[0], s187 = c105[1], m82 = import_react5.useState(""), v4 = M2(m82, 2), p28 = v4[0], f4 = v4[1], h6 = Kt();
|
|
158409
158409
|
return import_react5.useEffect(function() {
|
|
158410
158410
|
f4(h6.value);
|
|
158411
|
-
}, [h6.value]), import_react5.default.createElement(Wn, { value: { ref: a443, setActiveTab: s187, setActiveExample: f4 } }, import_react5.default.createElement(UXNode, { name: "CodeSample", props: { tab: u28, example: p28, code: "" } }, import_react5.default.createElement(
|
|
158411
|
+
}, [h6.value]), import_react5.default.createElement(Wn, { value: { ref: a443, setActiveTab: s187, setActiveExample: f4 } }, import_react5.default.createElement(UXNode, { name: "CodeSample", props: { tab: u28, example: p28, code: "" } }, import_react5.default.createElement(Yn, null, r325)));
|
|
158412
158412
|
}
|
|
158413
|
-
function
|
|
158413
|
+
function Yn(e488) {
|
|
158414
158414
|
var n470, t481, r325 = e488.children;
|
|
158415
158415
|
return n470 = Kt(), t481 = Wt(), import_react5.useEffect(function() {
|
|
158416
158416
|
var e489 = n470.tabsRef.current;
|
|
@@ -158475,7 +158475,7 @@ Xn.LineNumber = function(e488) {
|
|
|
158475
158475
|
` || e489.tokens.pop();
|
|
158476
158476
|
})(o237);
|
|
158477
158477
|
var l52 = null;
|
|
158478
|
-
return (e488.descriptionHead || e488.descriptionContent) && (l52 = import_react5.default.createElement("div", { part: "code-description", className: "c1sbwmbs" }, import_react5.default.createElement("div", null, e488.descriptionIcon ? import_react5.default.createElement(Gt, { name: e488.descriptionIcon, size: 16 }) : import_react5.default.createElement(Zn, null)), import_react5.default.createElement("div", null, import_react5.default.createElement(Zt, { weight: "bold" }, e488.descriptionHead), import_react5.default.createElement("span", null, e488.descriptionContent)))), import_react5.default.createElement("xyd-code-pre", null, import_react5.default.createElement(
|
|
158478
|
+
return (e488.descriptionHead || e488.descriptionContent) && (l52 = import_react5.default.createElement("div", { part: "code-description", className: "c1sbwmbs" }, import_react5.default.createElement("div", null, e488.descriptionIcon ? import_react5.default.createElement(Gt, { name: e488.descriptionIcon, size: 16 }) : import_react5.default.createElement(Zn, null)), import_react5.default.createElement("div", null, import_react5.default.createElement(Zt, { weight: "bold" }, e488.descriptionHead), import_react5.default.createElement("span", null, e488.descriptionContent)))), import_react5.default.createElement("xyd-code-pre", null, import_react5.default.createElement(Mn, { part: "pre", "data-size": r325, style: (o237 == null ? undefined : o237.style) || (o237 == null ? undefined : o237.style), className: "".concat(Dn, " ").concat(a443 || ""), code: o237, handlers: i314, ref: t481.ref }), l52);
|
|
158479
158479
|
};
|
|
158480
158480
|
var Jn = { mark: { name: "mark", Line: function(e488) {
|
|
158481
158481
|
return import_react5.default.createElement(Xn.Mark, Object.assign({}, e488));
|
|
@@ -158519,7 +158519,7 @@ function et2(e488) {
|
|
|
158519
158519
|
var nt2 = import_react5.createContext({ lines: undefined, scroll: undefined });
|
|
158520
158520
|
var tt2 = import_react5.default.createContext({});
|
|
158521
158521
|
function rt2(e488) {
|
|
158522
|
-
return import_react5.default.createElement(
|
|
158522
|
+
return import_react5.default.createElement(Kn, null, import_react5.default.createElement(Xn, { codeblocks: e488.codeblocks, theme: e488.theme }, import_react5.default.createElement(at3, Object.assign({}, e488))));
|
|
158523
158523
|
}
|
|
158524
158524
|
function at3(e488) {
|
|
158525
158525
|
var t481, r325 = import_react5.use(Hn).highlighted, o237 = import_react5.useContext(nt2);
|
|
@@ -158640,13 +158640,13 @@ function Ct2(n470) {
|
|
|
158640
158640
|
var a443 = t481.slice(0, 2), o237 = t481.slice(2), i314 = o237.length > 0 ? "Show more (".concat(o237.length, ") reference").concat(o237.length === 1 ? "" : "s") : "";
|
|
158641
158641
|
return e487.createElement(e487.Fragment, null, a443.map(function(n471, t482) {
|
|
158642
158642
|
return e487.createElement(Ot2, { key: t482, reference: n471, index: t482, syntaxHighlight: r325 });
|
|
158643
|
-
}), o237.length > 0 && e487.createElement(
|
|
158643
|
+
}), o237.length > 0 && e487.createElement(K4, { label: i314 }, o237.map(function(n471, t482) {
|
|
158644
158644
|
return e487.createElement(Ot2, { key: t482 + 2, reference: n471, index: t482 + 2, syntaxHighlight: r325 });
|
|
158645
158645
|
})));
|
|
158646
158646
|
}
|
|
158647
158647
|
function Ot2(n470) {
|
|
158648
158648
|
var t481, r325 = n470.reference, a443 = n470.index, o237 = n470.syntaxHighlight;
|
|
158649
|
-
return e487.createElement(e487.Fragment, { key: a443 }, e487.createElement(nr, { size: 3 }, r325.title), ((t481 = r325.context) === null || t481 === undefined ? undefined : t481.fileName) && e487.createElement(
|
|
158649
|
+
return e487.createElement(e487.Fragment, { key: a443 }, e487.createElement(nr, { size: 3 }, r325.title), ((t481 = r325.context) === null || t481 === undefined ? undefined : t481.fileName) && e487.createElement(K4, { label: "", kind: "tertiary", title: e487.createElement(e487.Fragment, null, "Source code in ", e487.createElement(G4, null, r325.context.fileFullPath)), icon: e487.createElement(St2, null) }, e487.createElement(rt2, { name: r325.context.fileName, description: r325.context.sourcecode.description, theme: o237 || undefined, codeblocks: [{ lang: r325.context.sourcecode.lang, meta: "", value: r325.context.sourcecode.code }] })), r325.definitions.map(function(n471, t482) {
|
|
158650
158650
|
var r326;
|
|
158651
158651
|
return e487.createElement(e487.Fragment, { key: t482 }, e487.createElement(nr, { size: 4 }, n471.title), e487.createElement(ar, null, e487.createElement(ar.Head, null, e487.createElement(ar.Tr, null, e487.createElement(ar.Th, null, "Name"), e487.createElement(ar.Th, null, "Type"), e487.createElement(ar.Th, null, "Description"))), e487.createElement(ar.Body, null, (r326 = n471.properties) === null || r326 === undefined ? undefined : r326.map(function(n472, t483) {
|
|
158652
158652
|
return e487.createElement(ar.Tr, { key: t483 }, e487.createElement(ar.Td, null, e487.createElement(G4, null, n472.name)), e487.createElement(ar.Td, null, e487.createElement(G4, null, n472.type)), e487.createElement(ar.Td, { muted: true }, n472.description));
|
|
@@ -193576,8 +193576,9 @@ class MCPServer {
|
|
|
193576
193576
|
// src/index.ts
|
|
193577
193577
|
var import_express = __toESM(require_express2(), 1);
|
|
193578
193578
|
import { readFileSync, existsSync } from "node:fs";
|
|
193579
|
-
import { join as join4 } from "node:path";
|
|
193579
|
+
import { join as join4, dirname } from "node:path";
|
|
193580
193580
|
import { createServer } from "node:http";
|
|
193581
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
193581
193582
|
|
|
193582
193583
|
// ../xyd-ask-ai/dist/node/index.js
|
|
193583
193584
|
import { env as e488 } from "node:process";
|
|
@@ -226668,12 +226669,8 @@ async function ba(e489) {
|
|
|
226668
226669
|
|
|
226669
226670
|
// src/index.ts
|
|
226670
226671
|
async function startServer(mcpServer) {
|
|
226671
|
-
const widgetPath =
|
|
226672
|
-
|
|
226673
|
-
console.log("❌ Widget not found!");
|
|
226674
|
-
console.log("\uD83D\uDD28 Please run: bun run build:widget");
|
|
226675
|
-
process.exit(1);
|
|
226676
|
-
}
|
|
226672
|
+
const widgetPath = findWidgetPath();
|
|
226673
|
+
console.log("✅ Widget found:", widgetPath);
|
|
226677
226674
|
const port = await findAvailablePort(parseInt(process.env.PORT || "3500"));
|
|
226678
226675
|
console.log(`\uD83D\uDD0D Trying to start server on port ${port}...`);
|
|
226679
226676
|
const app = import_express.default();
|
|
@@ -226752,6 +226749,24 @@ async function startServer(mcpServer) {
|
|
|
226752
226749
|
}
|
|
226753
226750
|
});
|
|
226754
226751
|
}
|
|
226752
|
+
function findWidgetPath() {
|
|
226753
|
+
const __filename2 = fileURLToPath2(import.meta.url);
|
|
226754
|
+
const __dirname2 = dirname(__filename2);
|
|
226755
|
+
const possiblePaths = [
|
|
226756
|
+
join4(process.cwd(), "dist", "widget.js"),
|
|
226757
|
+
join4(__dirname2, "..", "dist", "widget.js"),
|
|
226758
|
+
join4(__dirname2, "dist", "widget.js")
|
|
226759
|
+
];
|
|
226760
|
+
for (const path4 of possiblePaths) {
|
|
226761
|
+
if (existsSync(path4)) {
|
|
226762
|
+
return path4;
|
|
226763
|
+
}
|
|
226764
|
+
}
|
|
226765
|
+
console.log("❌ Widget not found!");
|
|
226766
|
+
console.log("\uD83D\uDD28 Please run: bun run build:widget");
|
|
226767
|
+
console.log("\uD83D\uDCA1 Searched in:", possiblePaths);
|
|
226768
|
+
process.exit(1);
|
|
226769
|
+
}
|
|
226755
226770
|
async function findAvailablePort(startPort = 3500, maxAttempts = 10) {
|
|
226756
226771
|
for (let i313 = 0;i313 < maxAttempts; i313++) {
|
|
226757
226772
|
const port = startPort + i313;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/ask-ai-widget",
|
|
3
|
-
"version": "0.0.0-build-
|
|
3
|
+
"version": "0.0.0-build-340e7ed-20251012221832",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"files": [
|
|
@@ -17,8 +17,8 @@
|
|
|
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-
|
|
21
|
-
"@xyd-js/mcp-server": "0.0.0-build-
|
|
20
|
+
"@xyd-js/ask-ai": "0.0.0-build-340e7ed-20251012221832",
|
|
21
|
+
"@xyd-js/mcp-server": "0.0.0-build-340e7ed-20251012221832"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "bun run build:widget && bun run build:server && bun run build:server-standalone",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { join, dirname } from "node:path";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
import express from "express";
|
|
5
6
|
|
|
6
7
|
import { handler as askAiHandler } from "@xyd-js/ask-ai/node";
|
|
@@ -8,14 +9,8 @@ import type { MCPServer } from "@xyd-js/mcp-server/mcp";
|
|
|
8
9
|
|
|
9
10
|
// Start the server
|
|
10
11
|
export async function startServer(mcpServer?: MCPServer) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!existsSync(widgetPath)) {
|
|
15
|
-
console.log("❌ Widget not found!");
|
|
16
|
-
console.log("🔨 Please run: bun run build:widget");
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
12
|
+
const widgetPath = findWidgetPath();
|
|
13
|
+
console.log("✅ Widget found:", widgetPath);
|
|
19
14
|
|
|
20
15
|
// Find an available port
|
|
21
16
|
const port = await findAvailablePort(parseInt(process.env.PORT || "3500"));
|
|
@@ -79,7 +74,7 @@ export async function startServer(mcpServer?: MCPServer) {
|
|
|
79
74
|
while (true) {
|
|
80
75
|
const { done, value } = await reader.read();
|
|
81
76
|
if (done) break;
|
|
82
|
-
|
|
77
|
+
|
|
83
78
|
const chunk = decoder.decode(value, { stream: true });
|
|
84
79
|
res.write(chunk);
|
|
85
80
|
}
|
|
@@ -121,6 +116,30 @@ export async function startServer(mcpServer?: MCPServer) {
|
|
|
121
116
|
});
|
|
122
117
|
}
|
|
123
118
|
|
|
119
|
+
// Find the widget file in multiple possible locations
|
|
120
|
+
function findWidgetPath(): string {
|
|
121
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
122
|
+
const __dirname = dirname(__filename);
|
|
123
|
+
|
|
124
|
+
// Look for widget in multiple possible locations
|
|
125
|
+
const possiblePaths = [
|
|
126
|
+
join(process.cwd(), "dist", "widget.js"), // Local development
|
|
127
|
+
join(__dirname, "..", "dist", "widget.js"), // Package installation
|
|
128
|
+
join(__dirname, "dist", "widget.js"), // Alternative package location
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
for (const path of possiblePaths) {
|
|
132
|
+
if (existsSync(path)) {
|
|
133
|
+
return path;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
console.log("❌ Widget not found!");
|
|
138
|
+
console.log("🔨 Please run: bun run build:widget");
|
|
139
|
+
console.log("💡 Searched in:", possiblePaths);
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
|
|
124
143
|
// Find an available port
|
|
125
144
|
async function findAvailablePort(startPort = 3500, maxAttempts = 10) {
|
|
126
145
|
for (let i = 0; i < maxAttempts; i++) {
|