tidewave 0.5.5 → 0.7.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/CHANGELOG.md +11 -0
- package/README.md +86 -23
- package/dist/cli/index.js +306 -106
- package/dist/core.d.ts +15 -6
- package/dist/http/handlers/config.d.ts +3 -2
- package/dist/http/index.d.ts +7 -3
- package/dist/http/security.d.ts +0 -8
- package/dist/logger/console-patch.d.ts +5 -0
- package/dist/logger/tidewave-log-record-processor.d.ts +1 -1
- package/dist/logger/tidewave-logger.d.ts +37 -0
- package/dist/logger/tidewave-span-processor.d.ts +2 -2
- package/dist/next-js/handler.d.ts +1 -0
- package/dist/next-js/handler.js +379 -456
- package/dist/next-js/instrumentation.d.ts +2 -7
- package/dist/next-js/instrumentation.js +138 -119
- package/dist/resolution/formatters.d.ts +2 -2
- package/dist/resolution/index.d.ts +1 -2
- package/dist/resolution/symbol-finder.d.ts +2 -2
- package/dist/resolution/utils.d.ts +1 -0
- package/dist/tanstack.d.ts +1 -0
- package/dist/tanstack.js +181 -0
- package/dist/vite-plugin.d.ts +0 -1
- package/dist/vite-plugin.js +368 -463
- package/package.json +13 -5
- package/dist/http/handlers/shell.d.ts +0 -6
- package/dist/logger/circular-buffer.d.ts +0 -54
- package/dist/logger/instrumentation.d.ts +0 -2
package/dist/vite-plugin.js
CHANGED
|
@@ -4,25 +4,43 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
7
12
|
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
8
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
22
|
for (let key of __getOwnPropNames(mod))
|
|
11
23
|
if (!__hasOwnProp.call(to, key))
|
|
12
24
|
__defProp(to, key, {
|
|
13
|
-
get: (
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
14
26
|
enumerable: true
|
|
15
27
|
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
16
30
|
return to;
|
|
17
31
|
};
|
|
18
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
var __returnValue = (v) => v;
|
|
34
|
+
function __exportSetter(name, newValue) {
|
|
35
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
36
|
+
}
|
|
19
37
|
var __export = (target, all) => {
|
|
20
38
|
for (var name in all)
|
|
21
39
|
__defProp(target, name, {
|
|
22
40
|
get: all[name],
|
|
23
41
|
enumerable: true,
|
|
24
42
|
configurable: true,
|
|
25
|
-
set: (
|
|
43
|
+
set: __exportSetter.bind(all, name)
|
|
26
44
|
});
|
|
27
45
|
};
|
|
28
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -1674,65 +1692,6 @@ function isLocalIp(ip) {
|
|
|
1674
1692
|
return true;
|
|
1675
1693
|
return false;
|
|
1676
1694
|
}
|
|
1677
|
-
function checkOrigin(req, res, config) {
|
|
1678
|
-
const { origin } = req.headers;
|
|
1679
|
-
if (!origin)
|
|
1680
|
-
return true;
|
|
1681
|
-
const allowedOrigins = config.allowedOrigins || getDefaultAllowedOrigins(config);
|
|
1682
|
-
const originUrl = parseUrl(origin);
|
|
1683
|
-
if (!originUrl) {
|
|
1684
|
-
const message = `For security reasons, Tidewave only accepts requests from allowed origins.
|
|
1685
|
-
|
|
1686
|
-
Invalid origin: ${origin}`;
|
|
1687
|
-
console.warn(message);
|
|
1688
|
-
res.statusCode = 403;
|
|
1689
|
-
res.end(message);
|
|
1690
|
-
return false;
|
|
1691
|
-
}
|
|
1692
|
-
const isAllowed = allowedOrigins.some((allowed) => isOriginAllowed(originUrl, parseUrl(allowed)));
|
|
1693
|
-
if (!isAllowed) {
|
|
1694
|
-
const message = `For security reasons, Tidewave only accepts requests from the same origin your web app is running on.
|
|
1695
|
-
|
|
1696
|
-
If you really want to allow remote connections, configure the Tidewave with the \`allowedOrigins: [${JSON.stringify(origin)}]\` option.`;
|
|
1697
|
-
console.warn(message);
|
|
1698
|
-
res.statusCode = 403;
|
|
1699
|
-
res.end(message);
|
|
1700
|
-
return false;
|
|
1701
|
-
}
|
|
1702
|
-
return true;
|
|
1703
|
-
}
|
|
1704
|
-
function getDefaultAllowedOrigins(config) {
|
|
1705
|
-
const { host, port } = config;
|
|
1706
|
-
if (!(host || port))
|
|
1707
|
-
return [];
|
|
1708
|
-
return [`http://${host}:${port}`, `https://${host}:${port}`];
|
|
1709
|
-
}
|
|
1710
|
-
function parseUrl(url) {
|
|
1711
|
-
try {
|
|
1712
|
-
const isProtocolRelative = url.startsWith("//");
|
|
1713
|
-
const parsed = new URL(isProtocolRelative ? "http:" + url : url);
|
|
1714
|
-
return {
|
|
1715
|
-
scheme: isProtocolRelative ? undefined : parsed.protocol?.slice(0, -1),
|
|
1716
|
-
host: parsed.hostname,
|
|
1717
|
-
port: parsed.port ? parseInt(parsed.port) : undefined
|
|
1718
|
-
};
|
|
1719
|
-
} catch {
|
|
1720
|
-
return null;
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
function isOriginAllowed(origin, allowed) {
|
|
1724
|
-
if (!origin || !allowed)
|
|
1725
|
-
return false;
|
|
1726
|
-
if (allowed.scheme && origin.scheme !== allowed.scheme)
|
|
1727
|
-
return false;
|
|
1728
|
-
if (allowed.port && origin.port !== allowed.port)
|
|
1729
|
-
return false;
|
|
1730
|
-
if (allowed.host.startsWith("*.")) {
|
|
1731
|
-
const allowedDomain = allowed.host.slice(2);
|
|
1732
|
-
return origin.host === allowedDomain || origin.host.endsWith("." + allowedDomain);
|
|
1733
|
-
}
|
|
1734
|
-
return origin.host === allowed.host;
|
|
1735
|
-
}
|
|
1736
1695
|
|
|
1737
1696
|
// node_modules/zod/v3/helpers/util.js
|
|
1738
1697
|
var util, objectUtil, ZodParsedType, getParsedType = (data) => {
|
|
@@ -11828,10 +11787,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
11828
11787
|
}
|
|
11829
11788
|
return output;
|
|
11830
11789
|
}
|
|
11831
|
-
var ucs2encode = function
|
|
11790
|
+
var ucs2encode = function ucs2encode2(array) {
|
|
11832
11791
|
return String.fromCodePoint.apply(String, toConsumableArray(array));
|
|
11833
11792
|
};
|
|
11834
|
-
var basicToDigit = function
|
|
11793
|
+
var basicToDigit = function basicToDigit2(codePoint) {
|
|
11835
11794
|
if (codePoint - 48 < 10) {
|
|
11836
11795
|
return codePoint - 22;
|
|
11837
11796
|
}
|
|
@@ -11843,10 +11802,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
11843
11802
|
}
|
|
11844
11803
|
return base;
|
|
11845
11804
|
};
|
|
11846
|
-
var digitToBasic = function
|
|
11805
|
+
var digitToBasic = function digitToBasic2(digit, flag) {
|
|
11847
11806
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
11848
11807
|
};
|
|
11849
|
-
var adapt = function
|
|
11808
|
+
var adapt = function adapt2(delta, numPoints, firstTime) {
|
|
11850
11809
|
var k = 0;
|
|
11851
11810
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
11852
11811
|
delta += floor(delta / numPoints);
|
|
@@ -11855,7 +11814,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
11855
11814
|
}
|
|
11856
11815
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
11857
11816
|
};
|
|
11858
|
-
var decode = function
|
|
11817
|
+
var decode = function decode2(input) {
|
|
11859
11818
|
var output = [];
|
|
11860
11819
|
var inputLength = input.length;
|
|
11861
11820
|
var i = 0;
|
|
@@ -11903,7 +11862,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
11903
11862
|
}
|
|
11904
11863
|
return String.fromCodePoint.apply(String, output);
|
|
11905
11864
|
};
|
|
11906
|
-
var encode = function
|
|
11865
|
+
var encode = function encode2(input) {
|
|
11907
11866
|
var output = [];
|
|
11908
11867
|
input = ucs2decode(input);
|
|
11909
11868
|
var inputLength = input.length;
|
|
@@ -12017,12 +11976,12 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12017
11976
|
}
|
|
12018
11977
|
return output.join("");
|
|
12019
11978
|
};
|
|
12020
|
-
var toUnicode = function
|
|
11979
|
+
var toUnicode = function toUnicode2(input) {
|
|
12021
11980
|
return mapDomain(input, function(string) {
|
|
12022
11981
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
12023
11982
|
});
|
|
12024
11983
|
};
|
|
12025
|
-
var toASCII = function
|
|
11984
|
+
var toASCII = function toASCII2(input) {
|
|
12026
11985
|
return mapDomain(input, function(string) {
|
|
12027
11986
|
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
|
12028
11987
|
});
|
|
@@ -12419,13 +12378,13 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12419
12378
|
var handler = {
|
|
12420
12379
|
scheme: "http",
|
|
12421
12380
|
domainHost: true,
|
|
12422
|
-
parse: function
|
|
12381
|
+
parse: function parse2(components, options) {
|
|
12423
12382
|
if (!components.host) {
|
|
12424
12383
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
12425
12384
|
}
|
|
12426
12385
|
return components;
|
|
12427
12386
|
},
|
|
12428
|
-
serialize: function
|
|
12387
|
+
serialize: function serialize2(components, options) {
|
|
12429
12388
|
var secure = String(components.scheme).toLowerCase() === "https";
|
|
12430
12389
|
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
|
12431
12390
|
components.port = undefined;
|
|
@@ -12448,7 +12407,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12448
12407
|
var handler$2 = {
|
|
12449
12408
|
scheme: "ws",
|
|
12450
12409
|
domainHost: true,
|
|
12451
|
-
parse: function
|
|
12410
|
+
parse: function parse2(components, options) {
|
|
12452
12411
|
var wsComponents = components;
|
|
12453
12412
|
wsComponents.secure = isSecure(wsComponents);
|
|
12454
12413
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
@@ -12456,7 +12415,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12456
12415
|
wsComponents.query = undefined;
|
|
12457
12416
|
return wsComponents;
|
|
12458
12417
|
},
|
|
12459
|
-
serialize: function
|
|
12418
|
+
serialize: function serialize2(wsComponents, options) {
|
|
12460
12419
|
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
|
|
12461
12420
|
wsComponents.port = undefined;
|
|
12462
12421
|
}
|
|
@@ -12624,7 +12583,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12624
12583
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
12625
12584
|
var handler$6 = {
|
|
12626
12585
|
scheme: "urn:uuid",
|
|
12627
|
-
parse: function
|
|
12586
|
+
parse: function parse2(urnComponents, options) {
|
|
12628
12587
|
var uuidComponents = urnComponents;
|
|
12629
12588
|
uuidComponents.uuid = uuidComponents.nss;
|
|
12630
12589
|
uuidComponents.nss = undefined;
|
|
@@ -12633,7 +12592,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12633
12592
|
}
|
|
12634
12593
|
return uuidComponents;
|
|
12635
12594
|
},
|
|
12636
|
-
serialize: function
|
|
12595
|
+
serialize: function serialize2(uuidComponents, options) {
|
|
12637
12596
|
var urnComponents = uuidComponents;
|
|
12638
12597
|
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
|
|
12639
12598
|
return urnComponents;
|
|
@@ -14079,7 +14038,7 @@ var require_compile = __commonJS((exports, module) => {
|
|
|
14079
14038
|
|
|
14080
14039
|
// node_modules/ajv/lib/cache.js
|
|
14081
14040
|
var require_cache = __commonJS((exports, module) => {
|
|
14082
|
-
var Cache = module.exports = function
|
|
14041
|
+
var Cache = module.exports = function Cache2() {
|
|
14083
14042
|
this._cache = {};
|
|
14084
14043
|
};
|
|
14085
14044
|
Cache.prototype.put = function Cache_put(key, value) {
|
|
@@ -19374,6 +19333,7 @@ var init_zodToJsonSchema = __esm(() => {
|
|
|
19374
19333
|
|
|
19375
19334
|
// node_modules/zod-to-json-schema/dist/esm/index.js
|
|
19376
19335
|
var init_esm = __esm(() => {
|
|
19336
|
+
init_zodToJsonSchema();
|
|
19377
19337
|
init_Options();
|
|
19378
19338
|
init_Refs();
|
|
19379
19339
|
init_parseDef();
|
|
@@ -19405,7 +19365,6 @@ var init_esm = __esm(() => {
|
|
|
19405
19365
|
init_unknown();
|
|
19406
19366
|
init_selectParser();
|
|
19407
19367
|
init_zodToJsonSchema();
|
|
19408
|
-
init_zodToJsonSchema();
|
|
19409
19368
|
});
|
|
19410
19369
|
|
|
19411
19370
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
|
|
@@ -20028,9 +19987,10 @@ var init_mcp = __esm(() => {
|
|
|
20028
19987
|
});
|
|
20029
19988
|
|
|
20030
19989
|
// src/tools.ts
|
|
20031
|
-
var projectEvalDescription, projectEvalInputSchema, referenceDescription = `Module path in format 'module:symbol[#method|.method]'. Supports local files, dependencies, and Node.js builtins.
|
|
19990
|
+
var projectEvalDescription, projectEvalInputSchema, referenceDescription = `Module/file path, optionally with symbol in format 'module[:symbol[#method|.method]]'. Supports local files, dependencies, and Node.js builtins.
|
|
20032
19991
|
|
|
20033
19992
|
Module reference format:
|
|
19993
|
+
- module - List all symbols in the module (file-level documentation)
|
|
20034
19994
|
- module:symbol - Extract a top-level symbol
|
|
20035
19995
|
- module:Class#method - Extract an instance method
|
|
20036
19996
|
- module:Class.method - Extract a static method
|
|
@@ -20038,6 +19998,8 @@ Module reference format:
|
|
|
20038
19998
|
- node:Class.method - Extract a global/builtin static method
|
|
20039
19999
|
|
|
20040
20000
|
Examples:
|
|
20001
|
+
- src/types.ts (list all symbols in file)
|
|
20002
|
+
- lodash (list all symbols in dependency)
|
|
20041
20003
|
- src/types.ts:SymbolInfo (local file symbol)
|
|
20042
20004
|
- lodash:isEmpty (dependency function)
|
|
20043
20005
|
- react:Component#render (instance method)
|
|
@@ -20045,7 +20007,8 @@ Examples:
|
|
|
20045
20007
|
var init_tools = __esm(() => {
|
|
20046
20008
|
init_zod();
|
|
20047
20009
|
projectEvalDescription = `
|
|
20048
|
-
Evaluates JavaScript/TypeScript code
|
|
20010
|
+
Evaluates JavaScript/TypeScript code within your project's build tool
|
|
20011
|
+
(or server for full-stack applications).
|
|
20049
20012
|
|
|
20050
20013
|
The current NodeJS version is: ${process.version}
|
|
20051
20014
|
|
|
@@ -20054,7 +20017,7 @@ including to test the behaviour of a function or to debug
|
|
|
20054
20017
|
something. The tool also returns anything written to standard
|
|
20055
20018
|
output. DO NOT use shell tools to evaluate JavaScript/TypeScript code.
|
|
20056
20019
|
|
|
20057
|
-
Imports are allowed only as the form of dynamic imports with async/await
|
|
20020
|
+
Imports are allowed only as the form of dynamic imports with async/await:
|
|
20058
20021
|
const path = await import('node:path');
|
|
20059
20022
|
`;
|
|
20060
20023
|
projectEvalInputSchema = exports_external.object({
|
|
@@ -20080,7 +20043,26 @@ Defaults to 30000 (30 seconds).`),
|
|
|
20080
20043
|
docs: {
|
|
20081
20044
|
mcp: {
|
|
20082
20045
|
name: "get_docs",
|
|
20083
|
-
description:
|
|
20046
|
+
description: `Extract TypeScript/JavaScript documentation and type information. Works for modules in the current project, dependencies, and builtin node modules.
|
|
20047
|
+
|
|
20048
|
+
Reference format determines what is returned:
|
|
20049
|
+
|
|
20050
|
+
• "module" - Returns file overview and lists all exported symbols with their kinds, line numbers, and brief documentation. Use this to discover what's available in a module.
|
|
20051
|
+
|
|
20052
|
+
• "module:symbol" - Returns detailed documentation for a specific top-level symbol including its type signature, full documentation, JSDoc tags, and source location.
|
|
20053
|
+
|
|
20054
|
+
• "module:Class.staticMethod" - Returns detailed documentation for a static method or property of a class or object.
|
|
20055
|
+
|
|
20056
|
+
• "module:Class#instanceMethod" - Returns detailed documentation for an instance method or property of a class.
|
|
20057
|
+
|
|
20058
|
+
Examples:
|
|
20059
|
+
- "src/types.ts" → Lists all exported symbols in the file
|
|
20060
|
+
- "lodash" → Lists all symbols exported from lodash
|
|
20061
|
+
- "src/types.ts:SymbolInfo" → Full docs for SymbolInfo interface
|
|
20062
|
+
- "react:Component#render" → Docs for React Component's render method
|
|
20063
|
+
- "node:Math.max" → Docs for Math.max static method
|
|
20064
|
+
|
|
20065
|
+
Start with module-only references to explore, then drill into specific symbols for detailed information.`,
|
|
20084
20066
|
inputSchema: docsInputSchema
|
|
20085
20067
|
},
|
|
20086
20068
|
cli: {
|
|
@@ -20129,7 +20111,7 @@ Defaults to 30000 (30 seconds).`),
|
|
|
20129
20111
|
logs: {
|
|
20130
20112
|
mcp: {
|
|
20131
20113
|
name: "get_logs",
|
|
20132
|
-
description: "Retrieve application logs
|
|
20114
|
+
description: "Retrieve application logs within your project's build tool (or server for full-stack applications). Supports filtering by level, time, and pattern matching.",
|
|
20133
20115
|
inputSchema: getLogsInputSchema
|
|
20134
20116
|
}
|
|
20135
20117
|
}
|
|
@@ -20137,18 +20119,21 @@ Defaults to 30000 (30 seconds).`),
|
|
|
20137
20119
|
});
|
|
20138
20120
|
|
|
20139
20121
|
// package.json
|
|
20140
|
-
var name = "tidewave", version = "0.
|
|
20122
|
+
var name = "tidewave", version = "0.7.0", package_default;
|
|
20141
20123
|
var init_package = __esm(() => {
|
|
20142
20124
|
package_default = {
|
|
20143
20125
|
name,
|
|
20144
20126
|
version,
|
|
20145
|
-
description: "Tidewave for JavaScript
|
|
20127
|
+
description: "Tidewave for JavaScript (Next.js, TanStack, Vite)",
|
|
20146
20128
|
keywords: [
|
|
20147
20129
|
"typescript",
|
|
20148
20130
|
"documentation",
|
|
20149
20131
|
"mcp",
|
|
20150
20132
|
"cli",
|
|
20151
|
-
"tidewave"
|
|
20133
|
+
"tidewave",
|
|
20134
|
+
"next",
|
|
20135
|
+
"vite",
|
|
20136
|
+
"tanstack"
|
|
20152
20137
|
],
|
|
20153
20138
|
homepage: "https://tidewave.ai",
|
|
20154
20139
|
repository: {
|
|
@@ -20185,6 +20170,11 @@ var init_package = __esm(() => {
|
|
|
20185
20170
|
import: "./dist/next-js/instrumentation.js",
|
|
20186
20171
|
require: "./dist/next-js/instrumentation.js"
|
|
20187
20172
|
},
|
|
20173
|
+
"./tanstack": {
|
|
20174
|
+
types: "./dist/tanstack.d.ts",
|
|
20175
|
+
import: "./dist/tanstack.js",
|
|
20176
|
+
require: "./dist/tanstack.js"
|
|
20177
|
+
},
|
|
20188
20178
|
"./package.json": "./package.json"
|
|
20189
20179
|
},
|
|
20190
20180
|
files: [
|
|
@@ -20195,7 +20185,7 @@ var init_package = __esm(() => {
|
|
|
20195
20185
|
],
|
|
20196
20186
|
scripts: {
|
|
20197
20187
|
dist: "bun run clean && bun run build:js && bun run build:types",
|
|
20198
|
-
"build:js": "bun build --outdir dist --root src --external typescript --external child_process --external module --external @opentelemetry/api --external @opentelemetry/sdk-logs --external @opentelemetry/sdk-trace-base src/next-js/handler.ts src/next-js/instrumentation.ts src/vite-plugin.ts src/evaluation/eval_worker.ts src/cli/index.ts --target node",
|
|
20188
|
+
"build:js": "bun build --outdir dist --root src --external typescript --external child_process --external module --external @opentelemetry/api --external @opentelemetry/sdk-logs --external @opentelemetry/sdk-trace-base src/next-js/handler.ts src/next-js/instrumentation.ts src/vite-plugin.ts src/tanstack.ts src/evaluation/eval_worker.ts src/cli/index.ts --target node",
|
|
20199
20189
|
"build:types": "tsc -p tsconfig.declarations.json",
|
|
20200
20190
|
dev: "bun run src/cli/index.ts",
|
|
20201
20191
|
test: "bun test",
|
|
@@ -20234,7 +20224,7 @@ var init_package = __esm(() => {
|
|
|
20234
20224
|
next: "^15.5.3",
|
|
20235
20225
|
prettier: "^3.4.2",
|
|
20236
20226
|
vite: "^7.1.5",
|
|
20237
|
-
vitest: "^
|
|
20227
|
+
vitest: "^4.1.8"
|
|
20238
20228
|
},
|
|
20239
20229
|
peerDependencies: {
|
|
20240
20230
|
typescript: "^5"
|
|
@@ -20258,6 +20248,9 @@ function isResolveError(result) {
|
|
|
20258
20248
|
function isExtractError(result) {
|
|
20259
20249
|
return result != null && "error" in result;
|
|
20260
20250
|
}
|
|
20251
|
+
function isFileInfo(result) {
|
|
20252
|
+
return result != null && "exports" in result && Array.isArray(result.exports);
|
|
20253
|
+
}
|
|
20261
20254
|
function resolveError(specifier, source) {
|
|
20262
20255
|
return {
|
|
20263
20256
|
success: false,
|
|
@@ -20456,6 +20449,8 @@ function getSymbolKind(symbol) {
|
|
|
20456
20449
|
return "property";
|
|
20457
20450
|
if (flags & ts2.SymbolFlags.Method)
|
|
20458
20451
|
return "method";
|
|
20452
|
+
if (flags & ts2.SymbolFlags.EnumMember)
|
|
20453
|
+
return "enum member";
|
|
20459
20454
|
if (flags & ts2.SymbolFlags.Enum)
|
|
20460
20455
|
return "enum";
|
|
20461
20456
|
if (flags & ts2.SymbolFlags.Module)
|
|
@@ -20476,6 +20471,27 @@ function getSymbolKind(symbol) {
|
|
|
20476
20471
|
}
|
|
20477
20472
|
return "unknown";
|
|
20478
20473
|
}
|
|
20474
|
+
function getFileOverview(sourceFile) {
|
|
20475
|
+
const leadingComments = ts2.getLeadingCommentRanges(sourceFile.text, 0);
|
|
20476
|
+
if (!leadingComments || leadingComments.length === 0) {
|
|
20477
|
+
return;
|
|
20478
|
+
}
|
|
20479
|
+
for (const comment of leadingComments) {
|
|
20480
|
+
const commentText = sourceFile.text.slice(comment.pos, comment.end);
|
|
20481
|
+
const fileoverviewMatch = commentText.match(/@fileoverview\s+([\s\S]*?)(?=@\w+|$)/);
|
|
20482
|
+
const fileMatch = commentText.match(/@file\s+([\s\S]*?)(?=@\w+|$)/);
|
|
20483
|
+
const match = fileoverviewMatch || fileMatch;
|
|
20484
|
+
if (match && match[1]) {
|
|
20485
|
+
const overviewText = match[1].split(`
|
|
20486
|
+
`).map((line) => line.replace(/^\s*\*\s?/, "").trim()).filter((line) => line.length > 0).join(`
|
|
20487
|
+
`).trim();
|
|
20488
|
+
if (overviewText) {
|
|
20489
|
+
return overviewText;
|
|
20490
|
+
}
|
|
20491
|
+
}
|
|
20492
|
+
}
|
|
20493
|
+
return;
|
|
20494
|
+
}
|
|
20479
20495
|
var init_utils = () => {};
|
|
20480
20496
|
|
|
20481
20497
|
// src/resolution/formatters.ts
|
|
@@ -20572,7 +20588,7 @@ function getTypeString(checker, symbol, type) {
|
|
|
20572
20588
|
}
|
|
20573
20589
|
return defaultTypeString;
|
|
20574
20590
|
}
|
|
20575
|
-
function
|
|
20591
|
+
function formatSymbolInfo(info) {
|
|
20576
20592
|
const output = [];
|
|
20577
20593
|
output.push(`
|
|
20578
20594
|
${info.name}`);
|
|
@@ -20599,7 +20615,36 @@ ${info.name}`);
|
|
|
20599
20615
|
return output.join(`
|
|
20600
20616
|
`);
|
|
20601
20617
|
}
|
|
20602
|
-
|
|
20618
|
+
function formatFileInfo(info) {
|
|
20619
|
+
const output = [];
|
|
20620
|
+
output.push(`
|
|
20621
|
+
File: ${info.path}`);
|
|
20622
|
+
output.push("");
|
|
20623
|
+
if (info.overview) {
|
|
20624
|
+
output.push("Overview:");
|
|
20625
|
+
output.push(info.overview);
|
|
20626
|
+
output.push("");
|
|
20627
|
+
}
|
|
20628
|
+
output.push(`Symbols (${info.exportCount} total):`);
|
|
20629
|
+
output.push("");
|
|
20630
|
+
for (const exp of info.exports) {
|
|
20631
|
+
output.push(`${exp.name} (${exp.kind}) - line ${exp.line}`);
|
|
20632
|
+
if (exp.documentation) {
|
|
20633
|
+
output.push(exp.documentation);
|
|
20634
|
+
}
|
|
20635
|
+
}
|
|
20636
|
+
return output.join(`
|
|
20637
|
+
`);
|
|
20638
|
+
}
|
|
20639
|
+
function formatOutput(info) {
|
|
20640
|
+
if (isFileInfo(info)) {
|
|
20641
|
+
return formatFileInfo(info);
|
|
20642
|
+
}
|
|
20643
|
+
return formatSymbolInfo(info);
|
|
20644
|
+
}
|
|
20645
|
+
var init_formatters = __esm(() => {
|
|
20646
|
+
init_core();
|
|
20647
|
+
});
|
|
20603
20648
|
|
|
20604
20649
|
// src/resolution/symbol-finder.ts
|
|
20605
20650
|
import ts4 from "typescript";
|
|
@@ -20676,7 +20721,12 @@ function getSymbolInfo(checker, symbol, member, isStatic) {
|
|
|
20676
20721
|
return createExtractError("TYPE_ERROR", `Symbol '${symbol.getName()}' has no declarations`);
|
|
20677
20722
|
}
|
|
20678
20723
|
const targetDeclaration = declaration || symbol.declarations[0];
|
|
20679
|
-
|
|
20724
|
+
let type;
|
|
20725
|
+
if (symbol.flags & (ts4.SymbolFlags.Interface | ts4.SymbolFlags.TypeAlias)) {
|
|
20726
|
+
type = checker.getDeclaredTypeOfSymbol(symbol);
|
|
20727
|
+
} else {
|
|
20728
|
+
type = checker.getTypeOfSymbolAtLocation(symbol, targetDeclaration);
|
|
20729
|
+
}
|
|
20680
20730
|
const symbolName = symbol.getName();
|
|
20681
20731
|
let targetSymbol = symbol;
|
|
20682
20732
|
let targetType = type;
|
|
@@ -20690,11 +20740,27 @@ function getSymbolInfo(checker, symbol, member, isStatic) {
|
|
|
20690
20740
|
targetType = checker.getTypeOfSymbolAtLocation(staticMember, staticMember.valueDeclaration);
|
|
20691
20741
|
name2 = `${symbolName}.${member}`;
|
|
20692
20742
|
} else {
|
|
20693
|
-
return createExtractError("MEMBER_NOT_FOUND", `Static member '${member}' not found on '${symbolName}'`);
|
|
20743
|
+
return createExtractError("MEMBER_NOT_FOUND", `Static member '${member}' not found on '${symbolName}'. Available: ${staticMembers.map((m) => m.getName()).join(", ")}`);
|
|
20694
20744
|
}
|
|
20695
20745
|
} else {
|
|
20696
20746
|
let instanceType;
|
|
20697
|
-
if (symbol.flags & ts4.SymbolFlags.
|
|
20747
|
+
if (symbol.flags & ts4.SymbolFlags.Interface) {
|
|
20748
|
+
instanceType = type;
|
|
20749
|
+
const instanceMembers = checker.getPropertiesOfType(instanceType);
|
|
20750
|
+
const instanceMember = instanceMembers.find((s) => s.getName() === member);
|
|
20751
|
+
if (instanceMember) {
|
|
20752
|
+
targetSymbol = instanceMember;
|
|
20753
|
+
const memberDecl = instanceMember.valueDeclaration || instanceMember.declarations?.[0];
|
|
20754
|
+
if (memberDecl) {
|
|
20755
|
+
targetType = checker.getTypeOfSymbolAtLocation(instanceMember, memberDecl);
|
|
20756
|
+
} else {
|
|
20757
|
+
targetType = checker.getTypeOfSymbol(instanceMember);
|
|
20758
|
+
}
|
|
20759
|
+
name2 = `${symbolName}#${member}`;
|
|
20760
|
+
} else {
|
|
20761
|
+
return createExtractError("MEMBER_NOT_FOUND", `Instance member '${member}' not found on interface '${symbolName}'. Available: ${instanceMembers.map((m) => m.getName()).join(", ")}`);
|
|
20762
|
+
}
|
|
20763
|
+
} else if (symbol.flags & ts4.SymbolFlags.Class) {
|
|
20698
20764
|
instanceType = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
20699
20765
|
const constructSignatures = instanceType.getConstructSignatures();
|
|
20700
20766
|
if (constructSignatures.length > 0) {
|
|
@@ -20778,6 +20844,9 @@ var init_symbol_finder = __esm(() => {
|
|
|
20778
20844
|
import ts5 from "typescript";
|
|
20779
20845
|
import path4 from "node:path";
|
|
20780
20846
|
function parseModulePath(modulePath) {
|
|
20847
|
+
if (!modulePath || modulePath.trim() === "") {
|
|
20848
|
+
return createExtractError("INVALID_REQUEST", "Module path is required");
|
|
20849
|
+
}
|
|
20781
20850
|
let module;
|
|
20782
20851
|
let symbolPath;
|
|
20783
20852
|
if (modulePath.startsWith("node:")) {
|
|
@@ -20786,12 +20855,22 @@ function parseModulePath(modulePath) {
|
|
|
20786
20855
|
module = `node:${baseSymbol}`;
|
|
20787
20856
|
symbolPath = nodeSymbol;
|
|
20788
20857
|
} else {
|
|
20789
|
-
const
|
|
20790
|
-
if (
|
|
20791
|
-
|
|
20858
|
+
const colonIndex = modulePath.indexOf(":");
|
|
20859
|
+
if (colonIndex === -1) {
|
|
20860
|
+
module = modulePath;
|
|
20861
|
+
symbolPath = undefined;
|
|
20862
|
+
} else if (colonIndex === 0) {
|
|
20863
|
+
return createExtractError("INVALID_REQUEST", 'Module path is required before ":"');
|
|
20864
|
+
} else {
|
|
20865
|
+
module = modulePath.substring(0, colonIndex);
|
|
20866
|
+
symbolPath = modulePath.substring(colonIndex + 1);
|
|
20867
|
+
if (!symbolPath || symbolPath.trim() === "") {
|
|
20868
|
+
return createExtractError("INVALID_REQUEST", 'Symbol name is required after ":"');
|
|
20869
|
+
}
|
|
20792
20870
|
}
|
|
20793
|
-
|
|
20794
|
-
|
|
20871
|
+
}
|
|
20872
|
+
if (!symbolPath) {
|
|
20873
|
+
return { module, symbol: undefined, member: undefined, isStatic: false };
|
|
20795
20874
|
}
|
|
20796
20875
|
if (symbolPath.includes("#")) {
|
|
20797
20876
|
const [symbol, member] = symbolPath.split("#");
|
|
@@ -20809,6 +20888,37 @@ function parseModulePath(modulePath) {
|
|
|
20809
20888
|
}
|
|
20810
20889
|
return { module, symbol: symbolPath, member: undefined, isStatic: false };
|
|
20811
20890
|
}
|
|
20891
|
+
function getExportSummaries(moduleSymbol, sourceFile, checker) {
|
|
20892
|
+
if (!moduleSymbol) {
|
|
20893
|
+
return [];
|
|
20894
|
+
}
|
|
20895
|
+
try {
|
|
20896
|
+
const exports = checker.getExportsOfModule(moduleSymbol);
|
|
20897
|
+
const summaries = [];
|
|
20898
|
+
for (const exp of exports) {
|
|
20899
|
+
const name2 = exp.getName();
|
|
20900
|
+
const kind = getSymbolKind(exp);
|
|
20901
|
+
const decl = exp.valueDeclaration ?? exp.declarations?.[0];
|
|
20902
|
+
let line = 0;
|
|
20903
|
+
if (decl) {
|
|
20904
|
+
const pos = sourceFile.getLineAndCharacterOfPosition(decl.getStart());
|
|
20905
|
+
line = pos.line + 1;
|
|
20906
|
+
}
|
|
20907
|
+
const fullDoc = ts5.displayPartsToString(exp.getDocumentationComment(checker));
|
|
20908
|
+
const briefDoc = fullDoc.split(`
|
|
20909
|
+
`)[0]?.trim();
|
|
20910
|
+
summaries.push({
|
|
20911
|
+
name: name2,
|
|
20912
|
+
kind,
|
|
20913
|
+
line,
|
|
20914
|
+
documentation: briefDoc || undefined
|
|
20915
|
+
});
|
|
20916
|
+
}
|
|
20917
|
+
return summaries.sort((a, b) => a.line - b.line);
|
|
20918
|
+
} catch {
|
|
20919
|
+
return [];
|
|
20920
|
+
}
|
|
20921
|
+
}
|
|
20812
20922
|
async function extractDocs(modulePath) {
|
|
20813
20923
|
const options = { prefix: process.cwd() };
|
|
20814
20924
|
const parseResult = parseModulePath(modulePath);
|
|
@@ -20831,6 +20941,22 @@ async function extractDocs(modulePath) {
|
|
|
20831
20941
|
}
|
|
20832
20942
|
const { sourceFile, program } = resolvedModule;
|
|
20833
20943
|
const checker = program.getTypeChecker();
|
|
20944
|
+
if (symbol === undefined) {
|
|
20945
|
+
const overview = getFileOverview(sourceFile);
|
|
20946
|
+
const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
|
|
20947
|
+
const exports = getExportSummaries(moduleSymbol, sourceFile, checker);
|
|
20948
|
+
let relativePath = sourceFile.fileName;
|
|
20949
|
+
const cwd = process.cwd();
|
|
20950
|
+
if (relativePath.startsWith(cwd)) {
|
|
20951
|
+
relativePath = path4.relative(cwd, relativePath);
|
|
20952
|
+
}
|
|
20953
|
+
return {
|
|
20954
|
+
path: relativePath,
|
|
20955
|
+
overview,
|
|
20956
|
+
exportCount: exports.length,
|
|
20957
|
+
exports
|
|
20958
|
+
};
|
|
20959
|
+
}
|
|
20834
20960
|
let targetSymbol;
|
|
20835
20961
|
if (isGlobalModule) {
|
|
20836
20962
|
const actualSymbolName = module.startsWith("node:") ? module.slice(5) : module;
|
|
@@ -20851,9 +20977,11 @@ async function extractDocs(modulePath) {
|
|
|
20851
20977
|
const exports = checker.getExportsOfModule(moduleSymbol);
|
|
20852
20978
|
const exportSymbol = exports.find((exp) => exp.getName() === symbol);
|
|
20853
20979
|
if (exportSymbol) {
|
|
20854
|
-
if (exportSymbol.
|
|
20980
|
+
if (exportSymbol.flags & ts5.SymbolFlags.Alias) {
|
|
20981
|
+
targetSymbol = checker.getAliasedSymbol(exportSymbol);
|
|
20982
|
+
} else if (exportSymbol.valueDeclaration && (ts5.isFunctionDeclaration(exportSymbol.valueDeclaration) || ts5.isClassDeclaration(exportSymbol.valueDeclaration) || ts5.isVariableDeclaration(exportSymbol.valueDeclaration) || ts5.isEnumDeclaration(exportSymbol.valueDeclaration))) {
|
|
20855
20983
|
targetSymbol = exportSymbol;
|
|
20856
|
-
} else if (exportSymbol.flags & (ts5.SymbolFlags.Interface | ts5.SymbolFlags.TypeAlias)) {
|
|
20984
|
+
} else if (exportSymbol.flags & (ts5.SymbolFlags.Interface | ts5.SymbolFlags.TypeAlias | ts5.SymbolFlags.Enum)) {
|
|
20857
20985
|
targetSymbol = exportSymbol;
|
|
20858
20986
|
} else {
|
|
20859
20987
|
targetSymbol = findSymbolInJavaScriptFile(sourceFile, checker, symbol);
|
|
@@ -20894,6 +21022,15 @@ async function getSourceLocation(reference) {
|
|
|
20894
21022
|
};
|
|
20895
21023
|
}
|
|
20896
21024
|
const { module, symbol, member, isStatic } = parseResult;
|
|
21025
|
+
if (!symbol) {
|
|
21026
|
+
return {
|
|
21027
|
+
success: false,
|
|
21028
|
+
error: {
|
|
21029
|
+
code: "INVALID_SPECIFIER",
|
|
21030
|
+
message: "Symbol reference required for source location lookup"
|
|
21031
|
+
}
|
|
21032
|
+
};
|
|
21033
|
+
}
|
|
20897
21034
|
const config2 = loadTsConfig(options.prefix);
|
|
20898
21035
|
let resolvedModule = resolveModule(module, config2.options);
|
|
20899
21036
|
let isGlobalModule = false;
|
|
@@ -21014,6 +21151,7 @@ var init_resolution = __esm(() => {
|
|
|
21014
21151
|
init_core();
|
|
21015
21152
|
init_module_resolver();
|
|
21016
21153
|
init_symbol_finder();
|
|
21154
|
+
init_utils();
|
|
21017
21155
|
init_formatters();
|
|
21018
21156
|
});
|
|
21019
21157
|
|
|
@@ -21092,23 +21230,31 @@ var init_src = __esm(() => {
|
|
|
21092
21230
|
};
|
|
21093
21231
|
});
|
|
21094
21232
|
|
|
21095
|
-
// src/logger/
|
|
21096
|
-
|
|
21097
|
-
|
|
21098
|
-
|
|
21099
|
-
|
|
21100
|
-
|
|
21101
|
-
|
|
21102
|
-
|
|
21103
|
-
|
|
21104
|
-
|
|
21105
|
-
|
|
21106
|
-
|
|
21107
|
-
this.
|
|
21108
|
-
|
|
21109
|
-
|
|
21110
|
-
|
|
21111
|
-
|
|
21233
|
+
// src/logger/tidewave-logger.ts
|
|
21234
|
+
import { appendFile, readFile } from "fs/promises";
|
|
21235
|
+
import * as path5 from "path";
|
|
21236
|
+
import * as os from "os";
|
|
21237
|
+
import * as crypto from "crypto";
|
|
21238
|
+
|
|
21239
|
+
class TidewaveLogger {
|
|
21240
|
+
logFilePath;
|
|
21241
|
+
constructor() {
|
|
21242
|
+
const cwd = process.cwd();
|
|
21243
|
+
const digest = crypto.createHash("md5").update(cwd).digest("hex").slice(0, 16);
|
|
21244
|
+
const tempDir = os.tmpdir();
|
|
21245
|
+
this.logFilePath = path5.join(tempDir, `${digest}.tidewave.ndjson`);
|
|
21246
|
+
}
|
|
21247
|
+
async addLog(log) {
|
|
21248
|
+
const line = JSON.stringify(log) + `
|
|
21249
|
+
`;
|
|
21250
|
+
try {
|
|
21251
|
+
await appendFile(this.logFilePath, line, "utf8");
|
|
21252
|
+
} catch (error) {
|
|
21253
|
+
console.log("[Tidewave] failed to write to log file, error:", error);
|
|
21254
|
+
}
|
|
21255
|
+
}
|
|
21256
|
+
async getLogs(options) {
|
|
21257
|
+
let logs = await this.getAllLogs();
|
|
21112
21258
|
if (options?.level) {
|
|
21113
21259
|
const level = options.level.toUpperCase();
|
|
21114
21260
|
logs = logs.filter((log) => log.severityText === level);
|
|
@@ -21126,31 +21272,26 @@ class CircularBuffer {
|
|
|
21126
21272
|
}
|
|
21127
21273
|
return logs;
|
|
21128
21274
|
}
|
|
21129
|
-
getAllLogs() {
|
|
21130
|
-
|
|
21131
|
-
|
|
21275
|
+
async getAllLogs() {
|
|
21276
|
+
try {
|
|
21277
|
+
const content = await readFile(this.logFilePath, "utf8");
|
|
21278
|
+
return content.split(`
|
|
21279
|
+
`).map((line) => {
|
|
21280
|
+
try {
|
|
21281
|
+
return JSON.parse(line);
|
|
21282
|
+
} catch {
|
|
21283
|
+
return null;
|
|
21284
|
+
}
|
|
21285
|
+
}).filter((log) => log !== null);
|
|
21286
|
+
} catch (error) {
|
|
21287
|
+
console.log("[Tidewave] failed to read from log file, error:", error);
|
|
21288
|
+
return [];
|
|
21132
21289
|
}
|
|
21133
|
-
return [...this.buffer.slice(this.writeIndex), ...this.buffer.slice(0, this.writeIndex)].filter(Boolean);
|
|
21134
|
-
}
|
|
21135
|
-
getStats() {
|
|
21136
|
-
return {
|
|
21137
|
-
totalLogs: this.count,
|
|
21138
|
-
bufferSize: this.maxSize,
|
|
21139
|
-
bufferUsage: Math.min(this.count / this.maxSize * 100, 100).toFixed(1) + "%"
|
|
21140
|
-
};
|
|
21141
|
-
}
|
|
21142
|
-
clear() {
|
|
21143
|
-
this.buffer = new Array(this.maxSize);
|
|
21144
|
-
this.writeIndex = 0;
|
|
21145
|
-
this.count = 0;
|
|
21146
21290
|
}
|
|
21147
21291
|
}
|
|
21148
|
-
var
|
|
21149
|
-
var
|
|
21150
|
-
|
|
21151
|
-
globalThis.__tidewaveCircularBuffer = new CircularBuffer(1024);
|
|
21152
|
-
}
|
|
21153
|
-
circularBuffer = globalThis.__tidewaveCircularBuffer;
|
|
21292
|
+
var tidewaveLogger;
|
|
21293
|
+
var init_tidewave_logger = __esm(() => {
|
|
21294
|
+
tidewaveLogger = new TidewaveLogger;
|
|
21154
21295
|
});
|
|
21155
21296
|
|
|
21156
21297
|
// src/mcp.ts
|
|
@@ -21213,7 +21354,7 @@ async function handleGetDocs({ reference }) {
|
|
|
21213
21354
|
isError: true
|
|
21214
21355
|
};
|
|
21215
21356
|
}
|
|
21216
|
-
if (!docs.documentation) {
|
|
21357
|
+
if ("documentation" in docs && !docs.documentation) {
|
|
21217
21358
|
return {
|
|
21218
21359
|
content: [
|
|
21219
21360
|
{
|
|
@@ -21242,15 +21383,15 @@ async function handleGetSourcePath({ reference }) {
|
|
|
21242
21383
|
isError: true
|
|
21243
21384
|
};
|
|
21244
21385
|
}
|
|
21245
|
-
const { path:
|
|
21386
|
+
const { path: path6, format } = sourceResult;
|
|
21246
21387
|
return {
|
|
21247
|
-
content: [{ type: "text", text: `${
|
|
21388
|
+
content: [{ type: "text", text: `${path6}(${format})` }],
|
|
21248
21389
|
isError: false
|
|
21249
21390
|
};
|
|
21250
21391
|
}
|
|
21251
21392
|
async function handleGetLogs(args) {
|
|
21252
21393
|
try {
|
|
21253
|
-
const logs =
|
|
21394
|
+
const logs = await tidewaveLogger.getLogs({
|
|
21254
21395
|
tail: args.tail,
|
|
21255
21396
|
grep: args.grep,
|
|
21256
21397
|
level: args.level,
|
|
@@ -21306,7 +21447,7 @@ var init_mcp2 = __esm(() => {
|
|
|
21306
21447
|
init_package();
|
|
21307
21448
|
init_core();
|
|
21308
21449
|
init_src();
|
|
21309
|
-
|
|
21450
|
+
init_tidewave_logger();
|
|
21310
21451
|
({
|
|
21311
21452
|
docs: { mcp: docsMcp },
|
|
21312
21453
|
source: { mcp: sourceMcp },
|
|
@@ -21318,6 +21459,10 @@ var init_mcp2 = __esm(() => {
|
|
|
21318
21459
|
// src/http/handlers/mcp.ts
|
|
21319
21460
|
async function handleMcp(req, res, next) {
|
|
21320
21461
|
try {
|
|
21462
|
+
if (req.headers.origin) {
|
|
21463
|
+
originNotAllowed(res);
|
|
21464
|
+
return;
|
|
21465
|
+
}
|
|
21321
21466
|
if (req.method !== "POST") {
|
|
21322
21467
|
methodNotAllowed(res);
|
|
21323
21468
|
return;
|
|
@@ -21359,108 +21504,6 @@ var init_mcp3 = __esm(() => {
|
|
|
21359
21504
|
init_mcp2();
|
|
21360
21505
|
});
|
|
21361
21506
|
|
|
21362
|
-
// src/http/handlers/shell.ts
|
|
21363
|
-
import { spawn } from "child_process";
|
|
21364
|
-
import { platform } from "os";
|
|
21365
|
-
async function handleShell(req, res, next) {
|
|
21366
|
-
try {
|
|
21367
|
-
if (req.method !== "POST") {
|
|
21368
|
-
methodNotAllowed(res);
|
|
21369
|
-
return;
|
|
21370
|
-
}
|
|
21371
|
-
const command = req.body?.command;
|
|
21372
|
-
if (!command) {
|
|
21373
|
-
res.statusCode = 400;
|
|
21374
|
-
res.end("Missing command in request body");
|
|
21375
|
-
return;
|
|
21376
|
-
}
|
|
21377
|
-
res.statusCode = 200;
|
|
21378
|
-
res.setHeader("Content-Type", "application/octet-stream");
|
|
21379
|
-
const { cmd, args } = getShellCommand(command);
|
|
21380
|
-
const child = spawn(cmd, args, {
|
|
21381
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
21382
|
-
shell: false,
|
|
21383
|
-
cwd: process.cwd()
|
|
21384
|
-
});
|
|
21385
|
-
child.stdout.on("data", (data) => {
|
|
21386
|
-
if (!res.destroyed) {
|
|
21387
|
-
const chunk = Buffer.concat([
|
|
21388
|
-
Buffer.from([0]),
|
|
21389
|
-
Buffer.from([
|
|
21390
|
-
data.length >>> 24 & 255,
|
|
21391
|
-
data.length >>> 16 & 255,
|
|
21392
|
-
data.length >>> 8 & 255,
|
|
21393
|
-
data.length & 255
|
|
21394
|
-
]),
|
|
21395
|
-
data
|
|
21396
|
-
]);
|
|
21397
|
-
res.write(chunk);
|
|
21398
|
-
}
|
|
21399
|
-
});
|
|
21400
|
-
child.stderr.on("data", (data) => {
|
|
21401
|
-
if (!res.destroyed) {
|
|
21402
|
-
const chunk = Buffer.concat([
|
|
21403
|
-
Buffer.from([0]),
|
|
21404
|
-
Buffer.from([
|
|
21405
|
-
data.length >>> 24 & 255,
|
|
21406
|
-
data.length >>> 16 & 255,
|
|
21407
|
-
data.length >>> 8 & 255,
|
|
21408
|
-
data.length & 255
|
|
21409
|
-
]),
|
|
21410
|
-
data
|
|
21411
|
-
]);
|
|
21412
|
-
res.write(chunk);
|
|
21413
|
-
}
|
|
21414
|
-
});
|
|
21415
|
-
child.on("exit", (code) => {
|
|
21416
|
-
if (!res.destroyed) {
|
|
21417
|
-
const statusData = JSON.stringify({ status: code || 0 });
|
|
21418
|
-
const statusBuffer = Buffer.from(statusData);
|
|
21419
|
-
const chunk = Buffer.concat([
|
|
21420
|
-
Buffer.from([1]),
|
|
21421
|
-
Buffer.from([
|
|
21422
|
-
statusBuffer.length >>> 24 & 255,
|
|
21423
|
-
statusBuffer.length >>> 16 & 255,
|
|
21424
|
-
statusBuffer.length >>> 8 & 255,
|
|
21425
|
-
statusBuffer.length & 255
|
|
21426
|
-
]),
|
|
21427
|
-
statusBuffer
|
|
21428
|
-
]);
|
|
21429
|
-
res.write(chunk);
|
|
21430
|
-
}
|
|
21431
|
-
res.end();
|
|
21432
|
-
});
|
|
21433
|
-
req.on("close", () => {
|
|
21434
|
-
if (!child.killed) {
|
|
21435
|
-
child.kill();
|
|
21436
|
-
}
|
|
21437
|
-
});
|
|
21438
|
-
} catch (e) {
|
|
21439
|
-
console.error(`[Tidewave] Failed to execute shell command: ${e}`);
|
|
21440
|
-
if (!res.headersSent) {
|
|
21441
|
-
res.statusCode = 500;
|
|
21442
|
-
res.setHeader("Content-Type", "application/json");
|
|
21443
|
-
res.end(JSON.stringify({
|
|
21444
|
-
error: "Internal server error",
|
|
21445
|
-
message: e instanceof Error ? e.message : String(e)
|
|
21446
|
-
}));
|
|
21447
|
-
}
|
|
21448
|
-
next(e);
|
|
21449
|
-
}
|
|
21450
|
-
}
|
|
21451
|
-
function getShellCommand(command) {
|
|
21452
|
-
const isWindows = platform() === "win32";
|
|
21453
|
-
if (isWindows) {
|
|
21454
|
-
const comspec = process.env.COMSPEC || "cmd.exe";
|
|
21455
|
-
return { cmd: comspec, args: ["/s", "/c", command] };
|
|
21456
|
-
} else {
|
|
21457
|
-
return { cmd: "sh", args: ["-c", command] };
|
|
21458
|
-
}
|
|
21459
|
-
}
|
|
21460
|
-
var init_shell = __esm(() => {
|
|
21461
|
-
init_http();
|
|
21462
|
-
});
|
|
21463
|
-
|
|
21464
21507
|
// src/http/handlers/html.ts
|
|
21465
21508
|
function createHandleHtml(config) {
|
|
21466
21509
|
return async function handleHtml(req, res, next) {
|
|
@@ -21471,12 +21514,6 @@ function createHandleHtml(config) {
|
|
|
21471
21514
|
}
|
|
21472
21515
|
try {
|
|
21473
21516
|
const clientUrl = config.clientUrl || "https://tidewave.ai";
|
|
21474
|
-
const tidewaveConfig = {
|
|
21475
|
-
project_name: config.projectName || "app",
|
|
21476
|
-
framework_type: config.framework || "unknown",
|
|
21477
|
-
tidewave_version: package_default.version,
|
|
21478
|
-
team: config.team || {}
|
|
21479
|
-
};
|
|
21480
21517
|
res.statusCode = 200;
|
|
21481
21518
|
res.setHeader("Content-Type", "text/html");
|
|
21482
21519
|
res.end(`
|
|
@@ -21484,7 +21521,6 @@ function createHandleHtml(config) {
|
|
|
21484
21521
|
<head>
|
|
21485
21522
|
<meta charset="UTF-8" />
|
|
21486
21523
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
21487
|
-
<meta name="tidewave:config" content="${escapeHtml(JSON.stringify(tidewaveConfig))}" />
|
|
21488
21524
|
<script type="module" src="${clientUrl}/tc/tc.js"></script>
|
|
21489
21525
|
</head>
|
|
21490
21526
|
<body></body>
|
|
@@ -21501,32 +21537,21 @@ function createHandleHtml(config) {
|
|
|
21501
21537
|
}
|
|
21502
21538
|
};
|
|
21503
21539
|
}
|
|
21504
|
-
function escapeHtml(text) {
|
|
21505
|
-
const map2 = {
|
|
21506
|
-
"&": "&",
|
|
21507
|
-
"<": "<",
|
|
21508
|
-
">": ">",
|
|
21509
|
-
'"': """,
|
|
21510
|
-
"'": "'"
|
|
21511
|
-
};
|
|
21512
|
-
return text.replace(/[&<>"']/g, (match) => map2[match]);
|
|
21513
|
-
}
|
|
21514
|
-
var init_html = __esm(() => {
|
|
21515
|
-
init_package();
|
|
21516
|
-
});
|
|
21517
21540
|
|
|
21518
21541
|
// src/http/handlers/config.ts
|
|
21519
|
-
function createHandleConfig(config) {
|
|
21520
|
-
return async function handleConfig(
|
|
21542
|
+
function createHandleConfig(config, getLocalPort) {
|
|
21543
|
+
return async function handleConfig(req, res, next) {
|
|
21521
21544
|
try {
|
|
21522
21545
|
const tidewaveConfig = {
|
|
21523
21546
|
project_name: config.projectName || "app",
|
|
21524
21547
|
framework_type: config.framework || "unknown",
|
|
21525
21548
|
tidewave_version: package_default.version,
|
|
21526
|
-
team: config.team || {}
|
|
21549
|
+
team: config.team || {},
|
|
21550
|
+
local_port: getLocalPort?.(req)
|
|
21527
21551
|
};
|
|
21528
21552
|
res.statusCode = 200;
|
|
21529
21553
|
res.setHeader("Content-Type", "application/json");
|
|
21554
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
21530
21555
|
res.end(JSON.stringify(tidewaveConfig));
|
|
21531
21556
|
} catch (err) {
|
|
21532
21557
|
console.error(`[Tidewave] Failed to serve config: ${err}`);
|
|
@@ -22003,7 +22028,7 @@ var require_has_flag = __commonJS((exports, module) => {
|
|
|
22003
22028
|
|
|
22004
22029
|
// node_modules/supports-color/index.js
|
|
22005
22030
|
var require_supports_color = __commonJS((exports, module) => {
|
|
22006
|
-
var
|
|
22031
|
+
var os2 = __require("os");
|
|
22007
22032
|
var tty = __require("tty");
|
|
22008
22033
|
var hasFlag = require_has_flag();
|
|
22009
22034
|
var { env } = process;
|
|
@@ -22051,7 +22076,7 @@ var require_supports_color = __commonJS((exports, module) => {
|
|
|
22051
22076
|
return min;
|
|
22052
22077
|
}
|
|
22053
22078
|
if (process.platform === "win32") {
|
|
22054
|
-
const osRelease =
|
|
22079
|
+
const osRelease = os2.release().split(".");
|
|
22055
22080
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
22056
22081
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
22057
22082
|
}
|
|
@@ -31866,17 +31891,6 @@ var require_db = __commonJS((exports, module) => {
|
|
|
31866
31891
|
};
|
|
31867
31892
|
});
|
|
31868
31893
|
|
|
31869
|
-
// node_modules/mime-db/index.js
|
|
31870
|
-
var require_mime_db = __commonJS((exports, module) => {
|
|
31871
|
-
/*!
|
|
31872
|
-
* mime-db
|
|
31873
|
-
* Copyright(c) 2014 Jonathan Ong
|
|
31874
|
-
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
|
31875
|
-
* MIT Licensed
|
|
31876
|
-
*/
|
|
31877
|
-
module.exports = require_db();
|
|
31878
|
-
});
|
|
31879
|
-
|
|
31880
31894
|
// node_modules/mime-types/mimeScore.js
|
|
31881
31895
|
var require_mimeScore = __commonJS((exports, module) => {
|
|
31882
31896
|
var FACET_SCORES = {
|
|
@@ -31919,7 +31933,7 @@ var require_mime_types = __commonJS((exports) => {
|
|
|
31919
31933
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
31920
31934
|
* MIT Licensed
|
|
31921
31935
|
*/
|
|
31922
|
-
var db =
|
|
31936
|
+
var db = require_db();
|
|
31923
31937
|
var extname = __require("path").extname;
|
|
31924
31938
|
var mimeScore = require_mimeScore();
|
|
31925
31939
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
@@ -31973,11 +31987,11 @@ var require_mime_types = __commonJS((exports) => {
|
|
|
31973
31987
|
}
|
|
31974
31988
|
return exts[0];
|
|
31975
31989
|
}
|
|
31976
|
-
function lookup(
|
|
31977
|
-
if (!
|
|
31990
|
+
function lookup(path6) {
|
|
31991
|
+
if (!path6 || typeof path6 !== "string") {
|
|
31978
31992
|
return false;
|
|
31979
31993
|
}
|
|
31980
|
-
var extension2 = extname("x." +
|
|
31994
|
+
var extension2 = extname("x." + path6).toLowerCase().slice(1);
|
|
31981
31995
|
if (!extension2) {
|
|
31982
31996
|
return false;
|
|
31983
31997
|
}
|
|
@@ -33131,7 +33145,7 @@ var require_round = __commonJS((exports, module) => {
|
|
|
33131
33145
|
|
|
33132
33146
|
// node_modules/math-intrinsics/isNaN.js
|
|
33133
33147
|
var require_isNaN = __commonJS((exports, module) => {
|
|
33134
|
-
module.exports = Number.isNaN || function
|
|
33148
|
+
module.exports = Number.isNaN || function isNaN2(a) {
|
|
33135
33149
|
return a !== a;
|
|
33136
33150
|
};
|
|
33137
33151
|
});
|
|
@@ -33265,7 +33279,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
33265
33279
|
var toStr = Object.prototype.toString;
|
|
33266
33280
|
var max = Math.max;
|
|
33267
33281
|
var funcType = "[object Function]";
|
|
33268
|
-
var concatty = function
|
|
33282
|
+
var concatty = function concatty2(a, b) {
|
|
33269
33283
|
var arr = [];
|
|
33270
33284
|
for (var i = 0;i < a.length; i += 1) {
|
|
33271
33285
|
arr[i] = a[i];
|
|
@@ -33275,7 +33289,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
33275
33289
|
}
|
|
33276
33290
|
return arr;
|
|
33277
33291
|
};
|
|
33278
|
-
var slicy = function
|
|
33292
|
+
var slicy = function slicy2(arrLike, offset) {
|
|
33279
33293
|
var arr = [];
|
|
33280
33294
|
for (var i = offset || 0, j = 0;i < arrLike.length; i += 1, j += 1) {
|
|
33281
33295
|
arr[j] = arrLike[i];
|
|
@@ -33316,7 +33330,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
33316
33330
|
}
|
|
33317
33331
|
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
|
|
33318
33332
|
if (target.prototype) {
|
|
33319
|
-
var Empty = function
|
|
33333
|
+
var Empty = function Empty2() {};
|
|
33320
33334
|
Empty.prototype = target.prototype;
|
|
33321
33335
|
bound.prototype = new Empty;
|
|
33322
33336
|
Empty.prototype = null;
|
|
@@ -33555,7 +33569,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
33555
33569
|
}
|
|
33556
33570
|
}
|
|
33557
33571
|
var errorProto;
|
|
33558
|
-
var doEval = function
|
|
33572
|
+
var doEval = function doEval2(name2) {
|
|
33559
33573
|
var value;
|
|
33560
33574
|
if (name2 === "%AsyncFunction%") {
|
|
33561
33575
|
value = getEvalledConstructor("async function () {}");
|
|
@@ -33564,12 +33578,12 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
33564
33578
|
} else if (name2 === "%AsyncGeneratorFunction%") {
|
|
33565
33579
|
value = getEvalledConstructor("async function* () {}");
|
|
33566
33580
|
} else if (name2 === "%AsyncGenerator%") {
|
|
33567
|
-
var fn =
|
|
33581
|
+
var fn = doEval2("%AsyncGeneratorFunction%");
|
|
33568
33582
|
if (fn) {
|
|
33569
33583
|
value = fn.prototype;
|
|
33570
33584
|
}
|
|
33571
33585
|
} else if (name2 === "%AsyncIteratorPrototype%") {
|
|
33572
|
-
var gen =
|
|
33586
|
+
var gen = doEval2("%AsyncGenerator%");
|
|
33573
33587
|
if (gen && getProto) {
|
|
33574
33588
|
value = getProto(gen.prototype);
|
|
33575
33589
|
}
|
|
@@ -33640,7 +33654,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
33640
33654
|
var $exec = bind.call($call, RegExp.prototype.exec);
|
|
33641
33655
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
33642
33656
|
var reEscapeChar = /\\(\\)?/g;
|
|
33643
|
-
var stringToPath = function
|
|
33657
|
+
var stringToPath = function stringToPath2(string2) {
|
|
33644
33658
|
var first = $strSlice(string2, 0, 1);
|
|
33645
33659
|
var last = $strSlice(string2, -1);
|
|
33646
33660
|
if (first === "%" && last !== "%") {
|
|
@@ -33654,7 +33668,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
33654
33668
|
});
|
|
33655
33669
|
return result;
|
|
33656
33670
|
};
|
|
33657
|
-
var getBaseIntrinsic = function
|
|
33671
|
+
var getBaseIntrinsic = function getBaseIntrinsic2(name2, allowMissing) {
|
|
33658
33672
|
var intrinsicName = name2;
|
|
33659
33673
|
var alias;
|
|
33660
33674
|
if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
|
@@ -33944,7 +33958,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33944
33958
|
}
|
|
33945
33959
|
return array2;
|
|
33946
33960
|
}();
|
|
33947
|
-
var compactQueue = function
|
|
33961
|
+
var compactQueue = function compactQueue2(queue) {
|
|
33948
33962
|
while (queue.length > 1) {
|
|
33949
33963
|
var item = queue.pop();
|
|
33950
33964
|
var obj = item.obj[item.prop];
|
|
@@ -33959,7 +33973,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33959
33973
|
}
|
|
33960
33974
|
}
|
|
33961
33975
|
};
|
|
33962
|
-
var arrayToObject = function
|
|
33976
|
+
var arrayToObject = function arrayToObject2(source, options) {
|
|
33963
33977
|
var obj = options && options.plainObjects ? { __proto__: null } : {};
|
|
33964
33978
|
for (var i = 0;i < source.length; ++i) {
|
|
33965
33979
|
if (typeof source[i] !== "undefined") {
|
|
@@ -33968,7 +33982,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33968
33982
|
}
|
|
33969
33983
|
return obj;
|
|
33970
33984
|
};
|
|
33971
|
-
var merge = function
|
|
33985
|
+
var merge = function merge2(target, source, options) {
|
|
33972
33986
|
if (!source) {
|
|
33973
33987
|
return target;
|
|
33974
33988
|
}
|
|
@@ -33996,7 +34010,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33996
34010
|
if (has.call(target, i)) {
|
|
33997
34011
|
var targetItem = target[i];
|
|
33998
34012
|
if (targetItem && typeof targetItem === "object" && item && typeof item === "object") {
|
|
33999
|
-
target[i] =
|
|
34013
|
+
target[i] = merge2(targetItem, item, options);
|
|
34000
34014
|
} else {
|
|
34001
34015
|
target.push(item);
|
|
34002
34016
|
}
|
|
@@ -34009,7 +34023,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
34009
34023
|
return Object.keys(source).reduce(function(acc, key) {
|
|
34010
34024
|
var value = source[key];
|
|
34011
34025
|
if (has.call(acc, key)) {
|
|
34012
|
-
acc[key] =
|
|
34026
|
+
acc[key] = merge2(acc[key], value, options);
|
|
34013
34027
|
} else {
|
|
34014
34028
|
acc[key] = value;
|
|
34015
34029
|
}
|
|
@@ -34034,7 +34048,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
34034
34048
|
}
|
|
34035
34049
|
};
|
|
34036
34050
|
var limit = 1024;
|
|
34037
|
-
var encode = function
|
|
34051
|
+
var encode = function encode2(str, defaultEncoder, charset, kind, format) {
|
|
34038
34052
|
if (str.length === 0) {
|
|
34039
34053
|
return str;
|
|
34040
34054
|
}
|
|
@@ -34079,7 +34093,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
34079
34093
|
}
|
|
34080
34094
|
return out;
|
|
34081
34095
|
};
|
|
34082
|
-
var compact = function
|
|
34096
|
+
var compact = function compact2(value) {
|
|
34083
34097
|
var queue = [{ obj: { o: value }, prop: "o" }];
|
|
34084
34098
|
var refs = [];
|
|
34085
34099
|
for (var i = 0;i < queue.length; ++i) {
|
|
@@ -34098,19 +34112,19 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
34098
34112
|
compactQueue(queue);
|
|
34099
34113
|
return value;
|
|
34100
34114
|
};
|
|
34101
|
-
var isRegExp = function
|
|
34115
|
+
var isRegExp = function isRegExp2(obj) {
|
|
34102
34116
|
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
34103
34117
|
};
|
|
34104
|
-
var isBuffer = function
|
|
34118
|
+
var isBuffer = function isBuffer2(obj) {
|
|
34105
34119
|
if (!obj || typeof obj !== "object") {
|
|
34106
34120
|
return false;
|
|
34107
34121
|
}
|
|
34108
34122
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
34109
34123
|
};
|
|
34110
|
-
var combine = function
|
|
34124
|
+
var combine = function combine2(a, b) {
|
|
34111
34125
|
return [].concat(a, b);
|
|
34112
34126
|
};
|
|
34113
|
-
var maybeMap = function
|
|
34127
|
+
var maybeMap = function maybeMap2(val, fn) {
|
|
34114
34128
|
if (isArray(val)) {
|
|
34115
34129
|
var mapped = [];
|
|
34116
34130
|
for (var i = 0;i < val.length; i += 1) {
|
|
@@ -34182,11 +34196,11 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
34182
34196
|
skipNulls: false,
|
|
34183
34197
|
strictNullHandling: false
|
|
34184
34198
|
};
|
|
34185
|
-
var isNonNullishPrimitive = function
|
|
34199
|
+
var isNonNullishPrimitive = function isNonNullishPrimitive2(v) {
|
|
34186
34200
|
return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
|
|
34187
34201
|
};
|
|
34188
34202
|
var sentinel = {};
|
|
34189
|
-
var stringify = function
|
|
34203
|
+
var stringify = function stringify2(object2, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
|
|
34190
34204
|
var obj = object2;
|
|
34191
34205
|
var tmpSc = sideChannel;
|
|
34192
34206
|
var step = 0;
|
|
@@ -34262,11 +34276,11 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
34262
34276
|
sideChannel.set(object2, step);
|
|
34263
34277
|
var valueSideChannel = getSideChannel();
|
|
34264
34278
|
valueSideChannel.set(sentinel, sideChannel);
|
|
34265
|
-
pushToArray(values,
|
|
34279
|
+
pushToArray(values, stringify2(value, keyPrefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, generateArrayPrefix === "comma" && encodeValuesOnly && isArray(obj) ? null : encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
34266
34280
|
}
|
|
34267
34281
|
return values;
|
|
34268
34282
|
};
|
|
34269
|
-
var normalizeStringifyOptions = function
|
|
34283
|
+
var normalizeStringifyOptions = function normalizeStringifyOptions2(opts) {
|
|
34270
34284
|
if (!opts) {
|
|
34271
34285
|
return defaults;
|
|
34272
34286
|
}
|
|
@@ -34543,7 +34557,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
34543
34557
|
}
|
|
34544
34558
|
return parseObject(keys, val, options, valuesParsed);
|
|
34545
34559
|
};
|
|
34546
|
-
var normalizeParseOptions = function
|
|
34560
|
+
var normalizeParseOptions = function normalizeParseOptions2(opts) {
|
|
34547
34561
|
if (!opts) {
|
|
34548
34562
|
return defaults;
|
|
34549
34563
|
}
|
|
@@ -34776,41 +34790,34 @@ var require_body_parser = __commonJS((exports, module) => {
|
|
|
34776
34790
|
// src/http/index.ts
|
|
34777
34791
|
var exports_http = {};
|
|
34778
34792
|
__export(exports_http, {
|
|
34779
|
-
|
|
34793
|
+
originNotAllowed: () => originNotAllowed,
|
|
34780
34794
|
methodNotAllowed: () => methodNotAllowed,
|
|
34781
34795
|
getHandlers: () => getHandlers,
|
|
34782
34796
|
configureServer: () => configureServer,
|
|
34783
34797
|
checkSecurity: () => checkSecurity,
|
|
34784
34798
|
ENDPOINT: () => ENDPOINT
|
|
34785
34799
|
});
|
|
34786
|
-
|
|
34787
|
-
function getHandlers(config) {
|
|
34800
|
+
function getHandlers(config, options = {}) {
|
|
34788
34801
|
return {
|
|
34789
34802
|
"": createHandleHtml(config),
|
|
34790
|
-
config: createHandleConfig(config),
|
|
34791
|
-
mcp: handleMcp
|
|
34792
|
-
shell: handleShell
|
|
34803
|
+
config: createHandleConfig(config, options.getLocalPort),
|
|
34804
|
+
mcp: handleMcp
|
|
34793
34805
|
};
|
|
34794
34806
|
}
|
|
34795
|
-
function configureServer(server = import_connect.default(), config = DEFAULT_OPTIONS) {
|
|
34807
|
+
function configureServer(server = import_connect.default(), config = DEFAULT_OPTIONS, options = {}) {
|
|
34796
34808
|
const securityChecker = checkSecurity(config);
|
|
34797
34809
|
server.use(`${ENDPOINT}`, securityChecker);
|
|
34798
34810
|
server.use(`${ENDPOINT}`, import_body_parser.default.json());
|
|
34799
|
-
const handlers = getHandlers(config);
|
|
34800
|
-
for (const [
|
|
34801
|
-
server.use(ENDPOINT + "/" +
|
|
34811
|
+
const handlers = getHandlers(config, options);
|
|
34812
|
+
for (const [path6, handler] of Object.entries(handlers)) {
|
|
34813
|
+
server.use(ENDPOINT + "/" + path6, handler);
|
|
34802
34814
|
}
|
|
34803
34815
|
return server;
|
|
34804
34816
|
}
|
|
34805
|
-
function serve(server, config = DEFAULT_OPTIONS) {
|
|
34806
|
-
http.createServer(server).listen(config.port || DEFAULT_PORT);
|
|
34807
|
-
}
|
|
34808
34817
|
function checkSecurity(config) {
|
|
34809
34818
|
return (req, res, next) => {
|
|
34810
34819
|
if (!checkRemoteIp(req, res, config))
|
|
34811
34820
|
return;
|
|
34812
|
-
if (!checkOrigin(req, res, config))
|
|
34813
|
-
return;
|
|
34814
34821
|
next();
|
|
34815
34822
|
};
|
|
34816
34823
|
}
|
|
@@ -34818,120 +34825,28 @@ function methodNotAllowed(res) {
|
|
|
34818
34825
|
res.statusCode = 405;
|
|
34819
34826
|
res.setHeader("Allow", "POST");
|
|
34820
34827
|
res.end();
|
|
34821
|
-
return;
|
|
34822
34828
|
}
|
|
34823
|
-
|
|
34829
|
+
function originNotAllowed(res) {
|
|
34830
|
+
const message = "For security reasons, Tidewave does not accept requests with an origin header for this endpoint.";
|
|
34831
|
+
console.warn(message);
|
|
34832
|
+
res.statusCode = 403;
|
|
34833
|
+
res.end(message);
|
|
34834
|
+
}
|
|
34835
|
+
var import_connect, import_body_parser, ENDPOINT = "/tidewave", DEFAULT_OPTIONS;
|
|
34824
34836
|
var init_http = __esm(() => {
|
|
34825
|
-
import_connect = __toESM(require_connect(), 1);
|
|
34826
34837
|
init_mcp3();
|
|
34827
|
-
init_shell();
|
|
34828
|
-
init_html();
|
|
34829
34838
|
init_config();
|
|
34839
|
+
import_connect = __toESM(require_connect(), 1);
|
|
34830
34840
|
import_body_parser = __toESM(require_body_parser(), 1);
|
|
34831
34841
|
DEFAULT_OPTIONS = {
|
|
34832
|
-
allowRemoteAccess: false
|
|
34833
|
-
allowedOrigins: [],
|
|
34834
|
-
port: 5001,
|
|
34835
|
-
host: "localhost"
|
|
34842
|
+
allowRemoteAccess: false
|
|
34836
34843
|
};
|
|
34837
34844
|
});
|
|
34838
34845
|
|
|
34839
|
-
// src/logger/
|
|
34840
|
-
|
|
34841
|
-
|
|
34842
|
-
|
|
34843
|
-
try {
|
|
34844
|
-
const spanType = span.attributes["next.span_type"];
|
|
34845
|
-
const httpMethod = span.attributes["http.method"];
|
|
34846
|
-
const relevantSpanTypes = [
|
|
34847
|
-
"BaseServer.handleRequest",
|
|
34848
|
-
"AppRender.getBodyResult",
|
|
34849
|
-
"AppRouteRouteHandlers.runHandler"
|
|
34850
|
-
];
|
|
34851
|
-
if (!spanType || !relevantSpanTypes.includes(spanType)) {
|
|
34852
|
-
return;
|
|
34853
|
-
}
|
|
34854
|
-
const route = span.attributes["next.route"] || span.attributes["http.route"];
|
|
34855
|
-
const httpUrl = span.attributes["http.url"];
|
|
34856
|
-
const httpTarget = span.attributes["http.target"];
|
|
34857
|
-
const httpStatusCode = span.attributes["http.status_code"];
|
|
34858
|
-
const path5 = route || httpTarget || httpUrl || "unknown";
|
|
34859
|
-
if (typeof path5 === "string" && path5.startsWith("/tidewave")) {
|
|
34860
|
-
return;
|
|
34861
|
-
}
|
|
34862
|
-
const durationMs = this.calculateDuration(span);
|
|
34863
|
-
let message = "";
|
|
34864
|
-
let severity = "INFO";
|
|
34865
|
-
if (spanType === "BaseServer.handleRequest") {
|
|
34866
|
-
const method = httpMethod || "UNKNOWN";
|
|
34867
|
-
const status = httpStatusCode || "unknown";
|
|
34868
|
-
message = `${method} ${path5} ${status} ${durationMs.toFixed(2)}ms`;
|
|
34869
|
-
if (typeof httpStatusCode === "number") {
|
|
34870
|
-
if (httpStatusCode >= 500)
|
|
34871
|
-
severity = "ERROR";
|
|
34872
|
-
else if (httpStatusCode >= 400)
|
|
34873
|
-
severity = "WARN";
|
|
34874
|
-
}
|
|
34875
|
-
} else if (spanType === "AppRender.getBodyResult") {
|
|
34876
|
-
message = `Rendered route: ${route || "unknown"} (${durationMs.toFixed(2)}ms)`;
|
|
34877
|
-
} else if (spanType === "AppRouteRouteHandlers.runHandler") {
|
|
34878
|
-
message = `API route: ${route || "unknown"} (${durationMs.toFixed(2)}ms)`;
|
|
34879
|
-
}
|
|
34880
|
-
circularBuffer.addLog({
|
|
34881
|
-
timestamp: new Date(span.endTime[0] * 1000 + span.endTime[1] / 1e6).toISOString(),
|
|
34882
|
-
severityText: severity,
|
|
34883
|
-
body: message,
|
|
34884
|
-
attributes: {
|
|
34885
|
-
"log.origin": "opentelemetry-span",
|
|
34886
|
-
"span.name": span.name,
|
|
34887
|
-
"span.kind": span.kind,
|
|
34888
|
-
"span.type": spanType,
|
|
34889
|
-
"http.method": httpMethod,
|
|
34890
|
-
"http.route": route,
|
|
34891
|
-
"http.status_code": httpStatusCode,
|
|
34892
|
-
"duration.ms": durationMs
|
|
34893
|
-
}
|
|
34894
|
-
});
|
|
34895
|
-
} catch (_error) {}
|
|
34896
|
-
}
|
|
34897
|
-
calculateDuration(span) {
|
|
34898
|
-
const startTimeMs = span.startTime[0] * 1000 + span.startTime[1] / 1e6;
|
|
34899
|
-
const endTimeMs = span.endTime[0] * 1000 + span.endTime[1] / 1e6;
|
|
34900
|
-
return endTimeMs - startTimeMs;
|
|
34901
|
-
}
|
|
34902
|
-
async forceFlush() {}
|
|
34903
|
-
async shutdown() {}
|
|
34904
|
-
}
|
|
34905
|
-
var init_tidewave_span_processor = __esm(() => {
|
|
34906
|
-
init_circular_buffer();
|
|
34907
|
-
});
|
|
34908
|
-
|
|
34909
|
-
// src/logger/tidewave-log-record-processor.ts
|
|
34910
|
-
class TidewaveLogRecordProcessor {
|
|
34911
|
-
onEmit(logRecord, _context) {
|
|
34912
|
-
try {
|
|
34913
|
-
const body = String(logRecord.body || "");
|
|
34914
|
-
circularBuffer.addLog({
|
|
34915
|
-
timestamp: new Date(logRecord.hrTime[0] * 1000 + logRecord.hrTime[1] / 1e6).toISOString(),
|
|
34916
|
-
severityText: logRecord.severityText || "INFO",
|
|
34917
|
-
body,
|
|
34918
|
-
attributes: logRecord.attributes,
|
|
34919
|
-
resource: logRecord.resource?.attributes
|
|
34920
|
-
});
|
|
34921
|
-
} catch (_error) {}
|
|
34922
|
-
}
|
|
34923
|
-
async forceFlush() {}
|
|
34924
|
-
async shutdown() {}
|
|
34925
|
-
}
|
|
34926
|
-
var init_tidewave_log_record_processor = __esm(() => {
|
|
34927
|
-
init_circular_buffer();
|
|
34928
|
-
});
|
|
34929
|
-
|
|
34930
|
-
// src/logger/instrumentation.ts
|
|
34931
|
-
var exports_instrumentation = {};
|
|
34932
|
-
__export(exports_instrumentation, {
|
|
34933
|
-
TidewaveSpanProcessor: () => TidewaveSpanProcessor,
|
|
34934
|
-
TidewaveLogRecordProcessor: () => TidewaveLogRecordProcessor
|
|
34846
|
+
// src/logger/console-patch.ts
|
|
34847
|
+
var exports_console_patch = {};
|
|
34848
|
+
__export(exports_console_patch, {
|
|
34849
|
+
patchConsole: () => patchConsole
|
|
34935
34850
|
});
|
|
34936
34851
|
function stripAnsiCodes(text) {
|
|
34937
34852
|
return text.replace(ANSI_REGEX, "");
|
|
@@ -34970,15 +34885,18 @@ function patchConsole() {
|
|
|
34970
34885
|
}
|
|
34971
34886
|
return String(arg);
|
|
34972
34887
|
}).map(stripAnsiCodes).join(" ");
|
|
34973
|
-
|
|
34974
|
-
|
|
34975
|
-
|
|
34976
|
-
|
|
34977
|
-
|
|
34978
|
-
|
|
34979
|
-
|
|
34980
|
-
|
|
34981
|
-
|
|
34888
|
+
const isAllWhitespace = body.match(/^\s+$/);
|
|
34889
|
+
if (!isAllWhitespace) {
|
|
34890
|
+
tidewaveLogger.addLog({
|
|
34891
|
+
timestamp: new Date().toISOString(),
|
|
34892
|
+
severityText: severity,
|
|
34893
|
+
body,
|
|
34894
|
+
attributes: {
|
|
34895
|
+
"log.origin": "console",
|
|
34896
|
+
"log.method": method
|
|
34897
|
+
}
|
|
34898
|
+
});
|
|
34899
|
+
}
|
|
34982
34900
|
} catch {}
|
|
34983
34901
|
original(...args);
|
|
34984
34902
|
};
|
|
@@ -34986,47 +34904,34 @@ function patchConsole() {
|
|
|
34986
34904
|
globalThis.__TIDEWAVE_CONSOLE_PATCHED__ = true;
|
|
34987
34905
|
}
|
|
34988
34906
|
var ANSI_REGEX;
|
|
34989
|
-
var
|
|
34990
|
-
|
|
34991
|
-
init_tidewave_span_processor();
|
|
34992
|
-
init_tidewave_log_record_processor();
|
|
34907
|
+
var init_console_patch = __esm(() => {
|
|
34908
|
+
init_tidewave_logger();
|
|
34993
34909
|
ANSI_REGEX = /\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;
|
|
34994
|
-
patchConsole();
|
|
34995
34910
|
});
|
|
34996
34911
|
|
|
34997
34912
|
// src/vite-plugin.ts
|
|
34998
34913
|
init_http();
|
|
34999
34914
|
init_core();
|
|
35000
|
-
|
|
34915
|
+
init_console_patch();
|
|
34916
|
+
patchConsole();
|
|
35001
34917
|
var DEFAULT_CONFIG = {
|
|
35002
|
-
port: 5173,
|
|
35003
|
-
host: "localhost",
|
|
35004
34918
|
allowRemoteAccess: false
|
|
35005
34919
|
};
|
|
35006
|
-
function tidewave(config = {
|
|
34920
|
+
function tidewave(config = {}) {
|
|
35007
34921
|
return {
|
|
35008
34922
|
name: "vite-plugin-tidewave",
|
|
35009
34923
|
configureServer: (server) => tidewaveServer(server, config)
|
|
35010
34924
|
};
|
|
35011
34925
|
}
|
|
35012
34926
|
async function tidewaveServer(server, config = DEFAULT_CONFIG) {
|
|
35013
|
-
const { config: serverConfig } = server;
|
|
35014
|
-
const { host, port } = serverConfig.server;
|
|
35015
|
-
if (port) {
|
|
35016
|
-
config.port = port;
|
|
35017
|
-
}
|
|
35018
|
-
if (typeof host === "string") {
|
|
35019
|
-
config.host = host;
|
|
35020
|
-
} else if (host === undefined) {
|
|
35021
|
-
config.host = "localhost";
|
|
35022
|
-
}
|
|
35023
|
-
if (!(config.host || config.port)) {
|
|
35024
|
-
console.error(`[Tidewave] should have both host and port configured, got: host: ${host} port: ${port}`);
|
|
35025
|
-
return;
|
|
35026
|
-
}
|
|
35027
34927
|
config.framework = "vite";
|
|
35028
34928
|
config.projectName = config.projectName || await getProjectName("vite_app");
|
|
35029
|
-
configureServer(server.middlewares, config
|
|
34929
|
+
configureServer(server.middlewares, config, {
|
|
34930
|
+
getLocalPort: () => {
|
|
34931
|
+
const address = server.httpServer?.address();
|
|
34932
|
+
return typeof address === "object" && address !== null ? address.port : undefined;
|
|
34933
|
+
}
|
|
34934
|
+
});
|
|
35030
34935
|
}
|
|
35031
34936
|
export {
|
|
35032
34937
|
tidewave as default
|