@utilix-tech/sdk 0.16.0 → 0.18.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 +6 -0
- package/README.md +21 -7
- package/dist/{ai_agent-CcpkV2DR.d.cts → ai_agent-B-c59NXD.d.cts} +23 -2
- package/dist/{ai_agent-CcpkV2DR.d.ts → ai_agent-B-c59NXD.d.ts} +23 -2
- package/dist/{chunk-M35VJETW.js → chunk-265NPGKH.js} +32 -2
- package/dist/{chunk-OB56VNKJ.js → chunk-3QMUUTBH.js} +107 -1
- package/dist/{chunk-Y5X34JAC.js → chunk-L53LAVAD.js} +64 -1
- package/dist/{chunk-M4MMO6C6.js → chunk-U34B5XPK.js} +41 -1
- package/dist/{code-C4skwg3l.d.cts → code-Cn9uOIAh.d.cts} +27 -2
- package/dist/{code-C4skwg3l.d.ts → code-Cn9uOIAh.d.ts} +27 -2
- package/dist/index.cjs +240 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/{network-DaNoZ5ER.d.cts → network-DZugNyAQ.d.cts} +35 -2
- package/dist/{network-DaNoZ5ER.d.ts → network-DZugNyAQ.d.ts} +35 -2
- package/dist/tools/ai_agent.cjs +30 -0
- package/dist/tools/ai_agent.d.cts +1 -1
- package/dist/tools/ai_agent.d.ts +1 -1
- package/dist/tools/ai_agent.js +1 -1
- package/dist/tools/code.cjs +63 -0
- package/dist/tools/code.d.cts +1 -1
- package/dist/tools/code.d.ts +1 -1
- package/dist/tools/code.js +1 -1
- package/dist/tools/network.cjs +106 -0
- package/dist/tools/network.d.cts +1 -1
- package/dist/tools/network.d.ts +1 -1
- package/dist/tools/network.js +1 -1
- package/dist/tools/units.cjs +40 -0
- package/dist/tools/units.d.cts +1 -1
- package/dist/tools/units.d.ts +1 -1
- package/dist/tools/units.js +1 -1
- package/dist/{units-CkV4kAIs.d.cts → units-BFTQwpBu.d.cts} +30 -2
- package/dist/{units-CkV4kAIs.d.ts → units-BFTQwpBu.d.ts} +30 -2
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* - env-parser (parseEnv, envToJson, envToExport, validateEnvKey)
|
|
19
19
|
* - css-minifier (minifyCss, formatCss, countRules, countProperties)
|
|
20
20
|
* - mime-lookup (lookupMime, MIME_TABLE)
|
|
21
|
+
* - github-url-parser (parseGithubUrl)
|
|
21
22
|
*/
|
|
22
23
|
type RegexFlag = 'g' | 'i' | 'm' | 's' | 'u';
|
|
23
24
|
declare const ALL_FLAGS: RegexFlag[];
|
|
@@ -285,6 +286,27 @@ declare const MIME_TABLE: MimeEntry[];
|
|
|
285
286
|
declare function lookupMime(query: string): MimeLookupResult | {
|
|
286
287
|
error: string;
|
|
287
288
|
};
|
|
289
|
+
type GithubUrlType = 'repo' | 'pull' | 'issue' | 'commit' | 'file' | 'tree' | 'release';
|
|
290
|
+
interface GithubUrlInfo {
|
|
291
|
+
owner: string;
|
|
292
|
+
repo: string;
|
|
293
|
+
type: GithubUrlType;
|
|
294
|
+
number?: number;
|
|
295
|
+
ref?: string;
|
|
296
|
+
path?: string;
|
|
297
|
+
startLine?: number;
|
|
298
|
+
endLine?: number;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Parses a github.com URL (repo, pull request, issue, commit, or a
|
|
302
|
+
* file/tree with an optional line range) into structured components via
|
|
303
|
+
* the path segments GitHub's own routing uses. Only covers github.com URLs
|
|
304
|
+
* over HTTP(S): SSH remotes (git@github.com:owner/repo.git) and other Git
|
|
305
|
+
* hosts are out of scope.
|
|
306
|
+
*/
|
|
307
|
+
declare function parseGithubUrl(input: string): GithubUrlInfo | {
|
|
308
|
+
error: string;
|
|
309
|
+
};
|
|
288
310
|
|
|
289
311
|
declare const code_ALL_FLAGS: typeof ALL_FLAGS;
|
|
290
312
|
type code_ApiEndpoint = ApiEndpoint;
|
|
@@ -298,6 +320,8 @@ type code_EnvParseResult = EnvParseResult;
|
|
|
298
320
|
type code_GitCommandConfig = GitCommandConfig;
|
|
299
321
|
type code_GitCommandResult = GitCommandResult;
|
|
300
322
|
type code_GitOperation = GitOperation;
|
|
323
|
+
type code_GithubUrlInfo = GithubUrlInfo;
|
|
324
|
+
type code_GithubUrlType = GithubUrlType;
|
|
301
325
|
type code_GqlFormatResult = GqlFormatResult;
|
|
302
326
|
type code_HtmlFormatResult = HtmlFormatResult;
|
|
303
327
|
type code_HtmlMinifyOptions = HtmlMinifyOptions;
|
|
@@ -351,6 +375,7 @@ declare const code_normalizeRef: typeof normalizeRef;
|
|
|
351
375
|
declare const code_parseDockerImage: typeof parseDockerImage;
|
|
352
376
|
declare const code_parseEnv: typeof parseEnv;
|
|
353
377
|
declare const code_parseGitCommand: typeof parseGitCommand;
|
|
378
|
+
declare const code_parseGithubUrl: typeof parseGithubUrl;
|
|
354
379
|
declare const code_parseSpec: typeof parseSpec;
|
|
355
380
|
declare const code_removeConsoleCalls: typeof removeConsoleCalls;
|
|
356
381
|
declare const code_removeEmptyAttributes: typeof removeEmptyAttributes;
|
|
@@ -364,7 +389,7 @@ declare const code_testPattern: typeof testPattern;
|
|
|
364
389
|
declare const code_testRegex: typeof testRegex;
|
|
365
390
|
declare const code_validateEnvKey: typeof validateEnvKey;
|
|
366
391
|
declare namespace code {
|
|
367
|
-
export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_CssResult as CssResult, type code_DockerImageRef as DockerImageRef, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEnvKey as validateEnvKey };
|
|
392
|
+
export { code_ALL_FLAGS as ALL_FLAGS, type code_ApiEndpoint as ApiEndpoint, type code_ApiInfo as ApiInfo, code_CHEATSHEET as CHEATSHEET, type code_CheatsheetEntry as CheatsheetEntry, type code_CssResult as CssResult, type code_DockerImageRef as DockerImageRef, type code_EnvEntry as EnvEntry, type code_EnvParseResult as EnvParseResult, type code_GitCommandConfig as GitCommandConfig, type code_GitCommandResult as GitCommandResult, type code_GitOperation as GitOperation, type code_GithubUrlInfo as GithubUrlInfo, type code_GithubUrlType as GithubUrlType, type code_GqlFormatResult as GqlFormatResult, type code_HtmlFormatResult as HtmlFormatResult, type code_HtmlMinifyOptions as HtmlMinifyOptions, type code_HtmlMinifyResult as HtmlMinifyResult, type code_JsMinifyOptions as JsMinifyOptions, type code_JsMinifyResult as JsMinifyResult, code_MIME_TABLE as MIME_TABLE, type code_MatchResult as MatchResult, type code_MimeEntry as MimeEntry, type code_MimeLookupResult as MimeLookupResult, code_OPERATIONS as OPERATIONS, type code_ParsedSpec as ParsedSpec, type code_RegexError as RegexError, type code_RegexFlag as RegexFlag, type code_RegexMatch as RegexMatch, type code_RegexResult as RegexResult, type code_RegexSuccess as RegexSuccess, code_SQL_DEFAULT_OPTIONS as SQL_DEFAULT_OPTIONS, type code_Segment as Segment, type code_SpecVersion as SpecVersion, type code_SqlDialect as SqlDialect, type code_SqlFormatOptions as SqlFormatOptions, type code_TestPatternResult as TestPatternResult, code_buildDockerPull as buildDockerPull, code_buildDockerRun as buildDockerRun, code_buildGitCommand as buildGitCommand, code_collapseHtmlWhitespace as collapseHtmlWhitespace, code_collapseJsWhitespace as collapseJsWhitespace, code_countProperties as countProperties, code_countRules as countRules, code_detectDialect as detectDialect, code_detectOperationType as detectOperationType, code_envToExport as envToExport, code_envToJson as envToJson, code_formatCss as formatCss, code_formatGql as formatGql, code_formatHtml as formatHtml, code_formatSql as formatSql, code_getEndpointsByTag as getEndpointsByTag, code_getHtmlStats as getHtmlStats, code_getJsStats as getJsStats, code_getMethodColor as getMethodColor, code_isValidTag as isValidTag, code_lookupMime as lookupMime, code_minifyCss as minifyCss, code_minifyGql as minifyGql, code_minifyHtml as minifyHtml, code_minifyJs as minifyJs, code_minifySql as minifySql, code_normalizeRef as normalizeRef, code_parseDockerImage as parseDockerImage, code_parseEnv as parseEnv, code_parseGitCommand as parseGitCommand, code_parseGithubUrl as parseGithubUrl, code_parseSpec as parseSpec, code_removeConsoleCalls as removeConsoleCalls, code_removeEmptyAttributes as removeEmptyAttributes, code_removeHtmlComments as removeHtmlComments, code_removeJsComments as removeJsComments, code_removeRedundantAttributes as removeRedundantAttributes, code_searchCheatsheet as searchCheatsheet, code_searchEndpoints as searchEndpoints, code_splitStatements as splitStatements, code_testPattern as testPattern, code_testRegex as testRegex, code_validateEnvKey as validateEnvKey };
|
|
368
393
|
}
|
|
369
394
|
|
|
370
|
-
export {
|
|
395
|
+
export { getEndpointsByTag as $, ALL_FLAGS as A, buildDockerRun as B, CHEATSHEET as C, type DockerImageRef as D, type EnvEntry as E, buildGitCommand as F, type GitCommandConfig as G, type HtmlFormatResult as H, collapseHtmlWhitespace as I, type JsMinifyOptions as J, collapseJsWhitespace as K, countProperties as L, MIME_TABLE as M, countRules as N, OPERATIONS as O, type ParsedSpec as P, detectDialect as Q, type RegexError as R, SQL_DEFAULT_OPTIONS as S, type TestPatternResult as T, detectOperationType as U, envToExport as V, envToJson as W, formatCss as X, formatGql as Y, formatHtml as Z, formatSql as _, type ApiEndpoint as a, getHtmlStats as a0, getJsStats as a1, getMethodColor as a2, isValidTag as a3, lookupMime as a4, minifyCss as a5, minifyGql as a6, minifyHtml as a7, minifyJs as a8, minifySql as a9, normalizeRef as aa, parseDockerImage as ab, parseEnv as ac, parseGitCommand as ad, parseGithubUrl as ae, parseSpec as af, removeConsoleCalls as ag, removeEmptyAttributes as ah, removeHtmlComments as ai, removeJsComments as aj, removeRedundantAttributes as ak, searchCheatsheet as al, searchEndpoints as am, splitStatements as an, testPattern as ao, testRegex as ap, validateEnvKey as aq, type ApiInfo as b, code as c, type CheatsheetEntry as d, type CssResult as e, type EnvParseResult as f, type GitCommandResult as g, type GitOperation as h, type GithubUrlInfo as i, type GithubUrlType as j, type GqlFormatResult as k, type HtmlMinifyOptions as l, type HtmlMinifyResult as m, type JsMinifyResult as n, type MatchResult as o, type MimeEntry as p, type MimeLookupResult as q, type RegexFlag as r, type RegexMatch as s, type RegexResult as t, type RegexSuccess as u, type Segment as v, type SpecVersion as w, type SqlDialect as x, type SqlFormatOptions as y, buildDockerPull as z };
|
package/dist/index.cjs
CHANGED
|
@@ -6687,6 +6687,7 @@ __export(units_exports, {
|
|
|
6687
6687
|
calculateLoan: () => calculateLoan,
|
|
6688
6688
|
calculateSimpleInterest: () => calculateSimpleInterest,
|
|
6689
6689
|
calculateTax: () => calculateTax,
|
|
6690
|
+
calculateTimeValue: () => calculateTimeValue,
|
|
6690
6691
|
calculateTipSplit: () => calculateTipSplit,
|
|
6691
6692
|
compareSemver: () => compareSemver,
|
|
6692
6693
|
convert: () => convert,
|
|
@@ -7962,6 +7963,45 @@ function calculateSimpleInterest(principal, annualRatePercent, years) {
|
|
|
7962
7963
|
totalPayoff: round23(principal + interest)
|
|
7963
7964
|
};
|
|
7964
7965
|
}
|
|
7966
|
+
function calculateTimeValue(amount, annualRatePercent, years, direction, compoundsPerYear = 1) {
|
|
7967
|
+
if (!Number.isFinite(amount) || amount < 0) return { error: "Amount must be zero or a positive number" };
|
|
7968
|
+
if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
|
|
7969
|
+
return { error: "Annual interest rate must be zero or a positive number" };
|
|
7970
|
+
}
|
|
7971
|
+
if (!Number.isFinite(years) || years <= 0) return { error: "Years must be a positive number" };
|
|
7972
|
+
if (!Number.isInteger(compoundsPerYear) || compoundsPerYear <= 0) {
|
|
7973
|
+
return { error: "Compounding frequency must be a positive whole number of periods per year" };
|
|
7974
|
+
}
|
|
7975
|
+
if (direction !== "future" && direction !== "present") {
|
|
7976
|
+
return { error: 'Direction must be "future" or "present"' };
|
|
7977
|
+
}
|
|
7978
|
+
const round23 = (n) => Math.round(n * 100) / 100;
|
|
7979
|
+
const round6 = (n) => Math.round(n * 1e6) / 1e6;
|
|
7980
|
+
const ratePerPeriod = annualRatePercent / 100 / compoundsPerYear;
|
|
7981
|
+
const totalPeriods = years * compoundsPerYear;
|
|
7982
|
+
const growthFactor = Math.pow(1 + ratePerPeriod, totalPeriods);
|
|
7983
|
+
let presentValue;
|
|
7984
|
+
let futureValue;
|
|
7985
|
+
if (direction === "future") {
|
|
7986
|
+
presentValue = amount;
|
|
7987
|
+
futureValue = amount * growthFactor;
|
|
7988
|
+
} else {
|
|
7989
|
+
futureValue = amount;
|
|
7990
|
+
presentValue = amount / growthFactor;
|
|
7991
|
+
}
|
|
7992
|
+
return {
|
|
7993
|
+
direction,
|
|
7994
|
+
annualRatePercent,
|
|
7995
|
+
years,
|
|
7996
|
+
compoundsPerYear,
|
|
7997
|
+
totalPeriods,
|
|
7998
|
+
ratePerPeriodPercent: round6(ratePerPeriod * 100),
|
|
7999
|
+
growthFactor: round6(growthFactor),
|
|
8000
|
+
presentValue: round23(presentValue),
|
|
8001
|
+
futureValue: round23(futureValue),
|
|
8002
|
+
interest: round23(futureValue - presentValue)
|
|
8003
|
+
};
|
|
8004
|
+
}
|
|
7965
8005
|
|
|
7966
8006
|
// src/tools/network.ts
|
|
7967
8007
|
var network_exports = {};
|
|
@@ -7989,6 +8029,7 @@ __export(network_exports, {
|
|
|
7989
8029
|
parseDnsResponse: () => parseDnsResponse,
|
|
7990
8030
|
parseGeoResponse: () => parseGeoResponse,
|
|
7991
8031
|
parseHar: () => parseHar,
|
|
8032
|
+
parseUserAgent: () => parseUserAgent,
|
|
7992
8033
|
searchHeaders: () => searchHeaders,
|
|
7993
8034
|
searchStatusCodes: () => searchStatusCodes,
|
|
7994
8035
|
statusCodeToText: () => statusCodeToText,
|
|
@@ -9578,6 +9619,111 @@ function validateRobotsTxt(text) {
|
|
|
9578
9619
|
const valid = !issues.some((i) => i.severity === "error");
|
|
9579
9620
|
return { groups, sitemaps, issues, valid };
|
|
9580
9621
|
}
|
|
9622
|
+
var UA_BOT_PATTERNS = [
|
|
9623
|
+
[/googlebot/i, "Googlebot"],
|
|
9624
|
+
[/bingbot/i, "Bingbot"],
|
|
9625
|
+
[/slurp/i, "Slurp"],
|
|
9626
|
+
[/duckduckbot/i, "DuckDuckBot"],
|
|
9627
|
+
[/baiduspider/i, "Baiduspider"],
|
|
9628
|
+
[/yandexbot/i, "YandexBot"],
|
|
9629
|
+
[/facebookexternalhit/i, "Facebot"],
|
|
9630
|
+
[/twitterbot/i, "Twitterbot"],
|
|
9631
|
+
[/applebot/i, "Applebot"],
|
|
9632
|
+
[/discordbot/i, "Discordbot"],
|
|
9633
|
+
[/slackbot/i, "Slackbot"],
|
|
9634
|
+
[/telegrambot/i, "TelegramBot"],
|
|
9635
|
+
[/whatsapp/i, "WhatsApp"],
|
|
9636
|
+
[/ahrefsbot/i, "AhrefsBot"],
|
|
9637
|
+
[/semrushbot/i, "SemrushBot"],
|
|
9638
|
+
[/crawler|spider|\bbot\b/i, "Bot"]
|
|
9639
|
+
];
|
|
9640
|
+
function _detectUaBrowser(s) {
|
|
9641
|
+
let m;
|
|
9642
|
+
if (m = s.match(/Edg(?:A|iOS)?\/([\d.]+)/)) return { name: "Edge", version: m[1] };
|
|
9643
|
+
if (m = s.match(/Edge\/([\d.]+)/)) return { name: "Edge (Legacy)", version: m[1] };
|
|
9644
|
+
if (m = s.match(/OPR\/([\d.]+)/)) return { name: "Opera", version: m[1] };
|
|
9645
|
+
if (m = s.match(/Opera\/([\d.]+)/)) return { name: "Opera", version: m[1] };
|
|
9646
|
+
if (m = s.match(/SamsungBrowser\/([\d.]+)/)) return { name: "Samsung Internet", version: m[1] };
|
|
9647
|
+
if (m = s.match(/FxiOS\/([\d.]+)/)) return { name: "Firefox", version: m[1] };
|
|
9648
|
+
if (m = s.match(/Firefox\/([\d.]+)/)) return { name: "Firefox", version: m[1] };
|
|
9649
|
+
if (m = s.match(/CriOS\/([\d.]+)/)) return { name: "Chrome", version: m[1] };
|
|
9650
|
+
if (m = s.match(/Chrome\/([\d.]+)/)) return { name: "Chrome", version: m[1] };
|
|
9651
|
+
if (m = s.match(/Version\/([\d.]+).*Safari\//)) return { name: "Safari", version: m[1] };
|
|
9652
|
+
if (/Safari\//.test(s)) return { name: "Safari", version: "" };
|
|
9653
|
+
if (m = s.match(/MSIE ([\d.]+)/)) return { name: "Internet Explorer", version: m[1] };
|
|
9654
|
+
if (m = s.match(/Trident\/.*rv:([\d.]+)/)) return { name: "Internet Explorer", version: m[1] };
|
|
9655
|
+
return { name: "Unknown", version: "" };
|
|
9656
|
+
}
|
|
9657
|
+
function _detectUaEngine(s, browserName) {
|
|
9658
|
+
let m;
|
|
9659
|
+
if (/Chrome\/|CriOS\/|Edg\/|OPR\/|SamsungBrowser\//.test(s)) {
|
|
9660
|
+
m = s.match(/Chrome\/([\d.]+)/) || s.match(/CriOS\/([\d.]+)/);
|
|
9661
|
+
return { name: "Blink", version: m ? m[1] : "" };
|
|
9662
|
+
}
|
|
9663
|
+
if (/Firefox\/|FxiOS\//.test(s)) {
|
|
9664
|
+
m = s.match(/rv:([\d.]+)/);
|
|
9665
|
+
return { name: "Gecko", version: m ? m[1] : "" };
|
|
9666
|
+
}
|
|
9667
|
+
if (m = s.match(/AppleWebKit\/([\d.]+)/)) return { name: "WebKit", version: m[1] };
|
|
9668
|
+
if (m = s.match(/Trident\/([\d.]+)/)) return { name: "Trident", version: m[1] };
|
|
9669
|
+
if (browserName === "Edge (Legacy)") return { name: "EdgeHTML", version: "" };
|
|
9670
|
+
return { name: "Unknown", version: "" };
|
|
9671
|
+
}
|
|
9672
|
+
var UA_WINDOWS_VERSIONS = {
|
|
9673
|
+
"10.0": "10",
|
|
9674
|
+
"6.3": "8.1",
|
|
9675
|
+
"6.2": "8",
|
|
9676
|
+
"6.1": "7",
|
|
9677
|
+
"6.0": "Vista",
|
|
9678
|
+
"5.1": "XP"
|
|
9679
|
+
};
|
|
9680
|
+
function _detectUaOs(s) {
|
|
9681
|
+
if (/Windows NT/.test(s)) return "Windows";
|
|
9682
|
+
if (/CrOS/.test(s)) return "ChromeOS";
|
|
9683
|
+
if (/Android/.test(s)) return "Android";
|
|
9684
|
+
if (/iPhone|iPad|iPod/.test(s)) return "iOS";
|
|
9685
|
+
if (/Mac OS X/.test(s)) return "macOS";
|
|
9686
|
+
if (/Linux/.test(s)) return "Linux";
|
|
9687
|
+
return "Unknown";
|
|
9688
|
+
}
|
|
9689
|
+
function _detectUaOsVersion(s) {
|
|
9690
|
+
let m;
|
|
9691
|
+
if (m = s.match(/Windows NT ([\d.]+)/)) return UA_WINDOWS_VERSIONS[m[1]] ?? m[1];
|
|
9692
|
+
if (/CrOS/.test(s) && (m = s.match(/CrOS \S+ ([\d.]+)/))) return m[1];
|
|
9693
|
+
if (m = s.match(/Android ([\d.]+)/)) return m[1];
|
|
9694
|
+
if (m = s.match(/(?:iPhone|CPU) OS ([\d_]+)/)) return m[1].replace(/_/g, ".");
|
|
9695
|
+
if (m = s.match(/Mac OS X ([\d_]+)/)) return m[1].replace(/_/g, ".");
|
|
9696
|
+
return "";
|
|
9697
|
+
}
|
|
9698
|
+
function _detectUaDeviceType(s) {
|
|
9699
|
+
if (/iPad/.test(s)) return "tablet";
|
|
9700
|
+
if (/Android/.test(s) && !/Mobile/.test(s)) return "tablet";
|
|
9701
|
+
if (/Mobile|iPhone|iPod|Android/.test(s)) return "mobile";
|
|
9702
|
+
return "desktop";
|
|
9703
|
+
}
|
|
9704
|
+
function parseUserAgent(ua) {
|
|
9705
|
+
if (!ua || typeof ua !== "string" || ua.trim() === "") {
|
|
9706
|
+
return { error: "Empty user-agent string" };
|
|
9707
|
+
}
|
|
9708
|
+
const s = ua.trim();
|
|
9709
|
+
for (const [re, name] of UA_BOT_PATTERNS) {
|
|
9710
|
+
if (re.test(s)) {
|
|
9711
|
+
const versionMatch = s.match(new RegExp(`${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\/([\\d.]+)`, "i"));
|
|
9712
|
+
return {
|
|
9713
|
+
browser: { name, version: versionMatch ? versionMatch[1] : "" },
|
|
9714
|
+
engine: { name: "Unknown", version: "" },
|
|
9715
|
+
os: { name: _detectUaOs(s), version: _detectUaOsVersion(s) },
|
|
9716
|
+
device: { type: "bot" },
|
|
9717
|
+
raw: s
|
|
9718
|
+
};
|
|
9719
|
+
}
|
|
9720
|
+
}
|
|
9721
|
+
const browser = _detectUaBrowser(s);
|
|
9722
|
+
const engine = _detectUaEngine(s, browser.name);
|
|
9723
|
+
const os = { name: _detectUaOs(s), version: _detectUaOsVersion(s) };
|
|
9724
|
+
const device = { type: _detectUaDeviceType(s) };
|
|
9725
|
+
return { browser, engine, os, device, raw: s };
|
|
9726
|
+
}
|
|
9581
9727
|
|
|
9582
9728
|
// src/tools/api.ts
|
|
9583
9729
|
var api_exports = {};
|
|
@@ -10882,6 +11028,7 @@ __export(code_exports, {
|
|
|
10882
11028
|
parseDockerImage: () => parseDockerImage,
|
|
10883
11029
|
parseEnv: () => parseEnv2,
|
|
10884
11030
|
parseGitCommand: () => parseGitCommand,
|
|
11031
|
+
parseGithubUrl: () => parseGithubUrl,
|
|
10885
11032
|
parseSpec: () => parseSpec,
|
|
10886
11033
|
removeConsoleCalls: () => removeConsoleCalls,
|
|
10887
11034
|
removeEmptyAttributes: () => removeEmptyAttributes,
|
|
@@ -13255,6 +13402,68 @@ function lookupMime(query) {
|
|
|
13255
13402
|
if (matches.length === 0) return { error: `No known MIME type for extension ".${ext}"` };
|
|
13256
13403
|
return { query: trimmed, kind: "extension", matches };
|
|
13257
13404
|
}
|
|
13405
|
+
function _parseGithubLineRange(hash) {
|
|
13406
|
+
const m = hash.match(/^#?L(\d+)(?:-L?(\d+))?$/i);
|
|
13407
|
+
if (!m) return {};
|
|
13408
|
+
const startLine = parseInt(m[1], 10);
|
|
13409
|
+
const endLine = m[2] ? parseInt(m[2], 10) : void 0;
|
|
13410
|
+
return endLine !== void 0 ? { startLine, endLine } : { startLine };
|
|
13411
|
+
}
|
|
13412
|
+
function parseGithubUrl(input) {
|
|
13413
|
+
if (!input || typeof input !== "string" || input.trim() === "") {
|
|
13414
|
+
return { error: "Empty URL" };
|
|
13415
|
+
}
|
|
13416
|
+
const trimmed = input.trim();
|
|
13417
|
+
const normalized = /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
13418
|
+
let url;
|
|
13419
|
+
try {
|
|
13420
|
+
url = new URL(normalized);
|
|
13421
|
+
} catch {
|
|
13422
|
+
return { error: "Invalid URL" };
|
|
13423
|
+
}
|
|
13424
|
+
if (!/^(www\.)?github\.com$/i.test(url.hostname)) {
|
|
13425
|
+
return { error: `Not a github.com URL (got host "${url.hostname}")` };
|
|
13426
|
+
}
|
|
13427
|
+
const segments = url.pathname.split("/").filter(Boolean);
|
|
13428
|
+
if (segments.length < 2) {
|
|
13429
|
+
return { error: "URL must include an owner and a repository" };
|
|
13430
|
+
}
|
|
13431
|
+
const [owner, repo, ...rest] = segments;
|
|
13432
|
+
if (rest.length === 0) {
|
|
13433
|
+
return { owner, repo, type: "repo" };
|
|
13434
|
+
}
|
|
13435
|
+
const kind = rest[0];
|
|
13436
|
+
if (kind === "pull" || kind === "issues") {
|
|
13437
|
+
const number = parseInt(rest[1], 10);
|
|
13438
|
+
if (!rest[1] || Number.isNaN(number)) {
|
|
13439
|
+
return { error: `Missing ${kind === "pull" ? "pull request" : "issue"} number` };
|
|
13440
|
+
}
|
|
13441
|
+
return { owner, repo, type: kind === "pull" ? "pull" : "issue", number };
|
|
13442
|
+
}
|
|
13443
|
+
if (kind === "commit") {
|
|
13444
|
+
if (!rest[1]) return { error: "Missing commit SHA" };
|
|
13445
|
+
return { owner, repo, type: "commit", ref: rest[1] };
|
|
13446
|
+
}
|
|
13447
|
+
if (kind === "blob") {
|
|
13448
|
+
const ref = rest[1];
|
|
13449
|
+
const path = rest.slice(2).join("/");
|
|
13450
|
+
if (!ref || !path) return { error: "File URL must include a ref and a file path (/blob/<ref>/<path>)" };
|
|
13451
|
+
return { owner, repo, type: "file", ref, path, ..._parseGithubLineRange(url.hash) };
|
|
13452
|
+
}
|
|
13453
|
+
if (kind === "tree") {
|
|
13454
|
+
const ref = rest[1];
|
|
13455
|
+
if (!ref) return { error: "Missing branch or tag ref (/tree/<ref>)" };
|
|
13456
|
+
const path = rest.slice(2).join("/");
|
|
13457
|
+
return { owner, repo, type: "tree", ref, ...path ? { path } : {} };
|
|
13458
|
+
}
|
|
13459
|
+
if (kind === "releases") {
|
|
13460
|
+
if (rest[1] !== "tag" || !rest[2]) {
|
|
13461
|
+
return { error: "Unsupported releases URL (expected /releases/tag/<name>)" };
|
|
13462
|
+
}
|
|
13463
|
+
return { owner, repo, type: "release", ref: rest[2] };
|
|
13464
|
+
}
|
|
13465
|
+
return { error: `Unsupported GitHub URL path: /${rest.join("/")}` };
|
|
13466
|
+
}
|
|
13258
13467
|
|
|
13259
13468
|
// src/tools/color.ts
|
|
13260
13469
|
var color_exports = {};
|
|
@@ -16866,7 +17075,8 @@ __export(ai_agent_exports, {
|
|
|
16866
17075
|
summarizeForLlm: () => summarizeForLlm,
|
|
16867
17076
|
trimToTokens: () => trimToTokens,
|
|
16868
17077
|
unflattenJson: () => unflattenJson,
|
|
16869
|
-
validateJsonSchema: () => validateJsonSchema
|
|
17078
|
+
validateJsonSchema: () => validateJsonSchema,
|
|
17079
|
+
vectorSimilarity: () => vectorSimilarity
|
|
16870
17080
|
});
|
|
16871
17081
|
var MODEL_PRICING = [
|
|
16872
17082
|
{ model: "gpt-4o", label: "GPT-4o", inputPer1M: 5, outputPer1M: 15 },
|
|
@@ -17784,6 +17994,35 @@ function summarizeForLlm(text, maxTokens = 200, strategy = "extractive") {
|
|
|
17784
17994
|
const st = tok(summary);
|
|
17785
17995
|
return { summary, originalTokens: ot, summaryTokens: st, compressionRatio: Math.round(st / Math.max(1, ot) * 100) / 100, sentencesKept: picked.length, sentencesTotal: sents.length };
|
|
17786
17996
|
}
|
|
17997
|
+
function vectorSimilarity(a, b) {
|
|
17998
|
+
if (!Array.isArray(a) || !Array.isArray(b)) return { error: "Both inputs must be arrays of numbers" };
|
|
17999
|
+
if (a.length === 0 || b.length === 0) return { error: "Vectors must not be empty" };
|
|
18000
|
+
if (a.length !== b.length) return { error: `Vectors must have the same length (got ${a.length} and ${b.length})` };
|
|
18001
|
+
if (!a.every((n) => typeof n === "number" && Number.isFinite(n)) || !b.every((n) => typeof n === "number" && Number.isFinite(n))) {
|
|
18002
|
+
return { error: "Vectors must contain only finite numbers" };
|
|
18003
|
+
}
|
|
18004
|
+
const round6 = (n) => Math.round(n * 1e6) / 1e6;
|
|
18005
|
+
let dot = 0, sa = 0, sb = 0, sqDist = 0, absDist = 0;
|
|
18006
|
+
for (let i = 0; i < a.length; i++) {
|
|
18007
|
+
dot += a[i] * b[i];
|
|
18008
|
+
sa += a[i] * a[i];
|
|
18009
|
+
sb += b[i] * b[i];
|
|
18010
|
+
const d = a[i] - b[i];
|
|
18011
|
+
sqDist += d * d;
|
|
18012
|
+
absDist += Math.abs(d);
|
|
18013
|
+
}
|
|
18014
|
+
const magA = Math.sqrt(sa), magB = Math.sqrt(sb);
|
|
18015
|
+
const cosine = magA === 0 || magB === 0 ? 0 : dot / (magA * magB);
|
|
18016
|
+
return {
|
|
18017
|
+
dimensions: a.length,
|
|
18018
|
+
dotProduct: round6(dot),
|
|
18019
|
+
cosineSimilarity: round6(cosine),
|
|
18020
|
+
euclideanDistance: round6(Math.sqrt(sqDist)),
|
|
18021
|
+
manhattanDistance: round6(absDist),
|
|
18022
|
+
magnitudeA: round6(magA),
|
|
18023
|
+
magnitudeB: round6(magB)
|
|
18024
|
+
};
|
|
18025
|
+
}
|
|
17787
18026
|
|
|
17788
18027
|
// src/tools/media.ts
|
|
17789
18028
|
var media_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -5,14 +5,14 @@ export { t as text } from './text-Bbx-tZ43.cjs';
|
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.cjs';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.cjs';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.cjs';
|
|
8
|
-
export { u as units } from './units-
|
|
9
|
-
export { n as network } from './network-
|
|
8
|
+
export { u as units } from './units-BFTQwpBu.cjs';
|
|
9
|
+
export { n as network } from './network-DZugNyAQ.cjs';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.cjs';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-Cn9uOIAh.cjs';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.cjs';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.cjs';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.cjs';
|
|
15
|
-
export { a as ai_agent } from './ai_agent-
|
|
15
|
+
export { a as ai_agent } from './ai_agent-B-c59NXD.cjs';
|
|
16
16
|
export { m as media } from './media-9HEpTPGA.cjs';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ export { t as text } from './text-Bbx-tZ43.js';
|
|
|
5
5
|
export { d as data } from './data-D8XTI7Du.js';
|
|
6
6
|
export { g as generators } from './generators-BGtRGpJZ.js';
|
|
7
7
|
export { t as time } from './time-DbT8fjaF.js';
|
|
8
|
-
export { u as units } from './units-
|
|
9
|
-
export { n as network } from './network-
|
|
8
|
+
export { u as units } from './units-BFTQwpBu.js';
|
|
9
|
+
export { n as network } from './network-DZugNyAQ.js';
|
|
10
10
|
export { a as api } from './api-Xl7OzIgq.js';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-Cn9uOIAh.js';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.js';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.js';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.js';
|
|
15
|
-
export { a as ai_agent } from './ai_agent-
|
|
15
|
+
export { a as ai_agent } from './ai_agent-B-c59NXD.js';
|
|
16
16
|
export { m as media } from './media-9HEpTPGA.js';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-XMKJYVKB.js';
|
|
2
|
-
export { units_exports as units } from './chunk-
|
|
3
|
-
export { network_exports as network } from './chunk-
|
|
2
|
+
export { units_exports as units } from './chunk-U34B5XPK.js';
|
|
3
|
+
export { network_exports as network } from './chunk-3QMUUTBH.js';
|
|
4
4
|
export { api_exports as api } from './chunk-Q3B3YWOA.js';
|
|
5
|
-
export { code_exports as code } from './chunk-
|
|
5
|
+
export { code_exports as code } from './chunk-L53LAVAD.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
7
7
|
export { css_exports as css } from './chunk-6YPV2AB5.js';
|
|
8
8
|
export { misc_exports as misc } from './chunk-GX7H6TAX.js';
|
|
9
|
-
export { ai_agent_exports as ai_agent } from './chunk-
|
|
9
|
+
export { ai_agent_exports as ai_agent } from './chunk-265NPGKH.js';
|
|
10
10
|
export { json_exports as json } from './chunk-TSAGO3XP.js';
|
|
11
11
|
export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - har-viewer : parseHar
|
|
11
11
|
* - sitemap-validator: validateSitemap
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
|
+
* - user-agent-parser: parseUserAgent
|
|
13
14
|
*/
|
|
14
15
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
15
16
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -222,6 +223,35 @@ interface RobotsValidationResult {
|
|
|
222
223
|
declare function validateRobotsTxt(text: string): RobotsValidationResult | {
|
|
223
224
|
error: string;
|
|
224
225
|
};
|
|
226
|
+
type UaDeviceType = 'desktop' | 'mobile' | 'tablet' | 'bot';
|
|
227
|
+
interface UserAgentInfo {
|
|
228
|
+
browser: {
|
|
229
|
+
name: string;
|
|
230
|
+
version: string;
|
|
231
|
+
};
|
|
232
|
+
engine: {
|
|
233
|
+
name: string;
|
|
234
|
+
version: string;
|
|
235
|
+
};
|
|
236
|
+
os: {
|
|
237
|
+
name: string;
|
|
238
|
+
version: string;
|
|
239
|
+
};
|
|
240
|
+
device: {
|
|
241
|
+
type: UaDeviceType;
|
|
242
|
+
};
|
|
243
|
+
raw: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Parses a browser User-Agent string into browser, engine, OS, and device
|
|
247
|
+
* type via pattern matching against well-known UA token formats. Covers the
|
|
248
|
+
* major desktop/mobile browsers and common search-engine/social crawlers;
|
|
249
|
+
* it is not an exhaustive UA database and falls back to 'Unknown' fields
|
|
250
|
+
* for obscure or custom UA strings.
|
|
251
|
+
*/
|
|
252
|
+
declare function parseUserAgent(ua: string): UserAgentInfo | {
|
|
253
|
+
error: string;
|
|
254
|
+
};
|
|
225
255
|
|
|
226
256
|
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
227
257
|
type network_DnsRecord = DnsRecord;
|
|
@@ -246,6 +276,8 @@ type network_SitemapIssue = SitemapIssue;
|
|
|
246
276
|
type network_SitemapUrlEntry = SitemapUrlEntry;
|
|
247
277
|
type network_SitemapValidationResult = SitemapValidationResult;
|
|
248
278
|
type network_StatusCode = StatusCode;
|
|
279
|
+
type network_UaDeviceType = UaDeviceType;
|
|
280
|
+
type network_UserAgentInfo = UserAgentInfo;
|
|
249
281
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
250
282
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
251
283
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
@@ -266,6 +298,7 @@ declare const network_isValidIpv6: typeof isValidIpv6;
|
|
|
266
298
|
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
267
299
|
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
268
300
|
declare const network_parseHar: typeof parseHar;
|
|
301
|
+
declare const network_parseUserAgent: typeof parseUserAgent;
|
|
269
302
|
declare const network_searchHeaders: typeof searchHeaders;
|
|
270
303
|
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
271
304
|
declare const network_statusCodeToText: typeof statusCodeToText;
|
|
@@ -276,7 +309,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
276
309
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
277
310
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
278
311
|
declare namespace network {
|
|
279
|
-
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
312
|
+
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
280
313
|
}
|
|
281
314
|
|
|
282
|
-
export {
|
|
315
|
+
export { validateHeaderValue as $, getHeader as A, getHeadersByCategory as B, getStatusByCategory as C, DNS_RECORD_TYPES as D, getStatusCode as E, isClientError as F, type GeoResult as G, HTTP_HEADERS as H, isServerError as I, isSuccess as J, isValidIp as K, isValidIpv4 as L, isValidIpv6 as M, parseDnsResponse as N, parseGeoResponse as O, type ParsedDnsResult as P, parseHar as Q, type RobotsGroup as R, STATUS_CODES as S, parseUserAgent as T, type UaDeviceType as U, searchHeaders as V, searchStatusCodes as W, statusCodeToText as X, typeNumberToLabel as Y, validateDomain as Z, validateHeaderName as _, type DnsRecord as a, validateRobotsTxt as a0, validateSitemap as a1, type DnsRecordType as b, type DnsResponse as c, type HarEntry as d, type HarParseResult as e, type HarSummary as f, type HeaderCategory as g, type HttpHeader as h, type ParsedGeoResult as i, type RobotsIssue as j, type RobotsRule as k, type RobotsValidationResult as l, type SitemapIndexEntry as m, network as n, type SitemapIssue as o, type SitemapUrlEntry as p, type SitemapValidationResult as q, type StatusCode as r, type UserAgentInfo as s, buildDnsQueryUrl as t, buildGeoUrl as u, buildMapUrl as v, countryCodeToFlag as w, formatCoordinates as x, formatTtl as y, getByCategory as z };
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - har-viewer : parseHar
|
|
11
11
|
* - sitemap-validator: validateSitemap
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
|
+
* - user-agent-parser: parseUserAgent
|
|
13
14
|
*/
|
|
14
15
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
15
16
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -222,6 +223,35 @@ interface RobotsValidationResult {
|
|
|
222
223
|
declare function validateRobotsTxt(text: string): RobotsValidationResult | {
|
|
223
224
|
error: string;
|
|
224
225
|
};
|
|
226
|
+
type UaDeviceType = 'desktop' | 'mobile' | 'tablet' | 'bot';
|
|
227
|
+
interface UserAgentInfo {
|
|
228
|
+
browser: {
|
|
229
|
+
name: string;
|
|
230
|
+
version: string;
|
|
231
|
+
};
|
|
232
|
+
engine: {
|
|
233
|
+
name: string;
|
|
234
|
+
version: string;
|
|
235
|
+
};
|
|
236
|
+
os: {
|
|
237
|
+
name: string;
|
|
238
|
+
version: string;
|
|
239
|
+
};
|
|
240
|
+
device: {
|
|
241
|
+
type: UaDeviceType;
|
|
242
|
+
};
|
|
243
|
+
raw: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Parses a browser User-Agent string into browser, engine, OS, and device
|
|
247
|
+
* type via pattern matching against well-known UA token formats. Covers the
|
|
248
|
+
* major desktop/mobile browsers and common search-engine/social crawlers;
|
|
249
|
+
* it is not an exhaustive UA database and falls back to 'Unknown' fields
|
|
250
|
+
* for obscure or custom UA strings.
|
|
251
|
+
*/
|
|
252
|
+
declare function parseUserAgent(ua: string): UserAgentInfo | {
|
|
253
|
+
error: string;
|
|
254
|
+
};
|
|
225
255
|
|
|
226
256
|
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
227
257
|
type network_DnsRecord = DnsRecord;
|
|
@@ -246,6 +276,8 @@ type network_SitemapIssue = SitemapIssue;
|
|
|
246
276
|
type network_SitemapUrlEntry = SitemapUrlEntry;
|
|
247
277
|
type network_SitemapValidationResult = SitemapValidationResult;
|
|
248
278
|
type network_StatusCode = StatusCode;
|
|
279
|
+
type network_UaDeviceType = UaDeviceType;
|
|
280
|
+
type network_UserAgentInfo = UserAgentInfo;
|
|
249
281
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
250
282
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
251
283
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
@@ -266,6 +298,7 @@ declare const network_isValidIpv6: typeof isValidIpv6;
|
|
|
266
298
|
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
267
299
|
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
268
300
|
declare const network_parseHar: typeof parseHar;
|
|
301
|
+
declare const network_parseUserAgent: typeof parseUserAgent;
|
|
269
302
|
declare const network_searchHeaders: typeof searchHeaders;
|
|
270
303
|
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
271
304
|
declare const network_statusCodeToText: typeof statusCodeToText;
|
|
@@ -276,7 +309,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
276
309
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
277
310
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
278
311
|
declare namespace network {
|
|
279
|
-
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
312
|
+
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_parseUserAgent as parseUserAgent, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
280
313
|
}
|
|
281
314
|
|
|
282
|
-
export {
|
|
315
|
+
export { validateHeaderValue as $, getHeader as A, getHeadersByCategory as B, getStatusByCategory as C, DNS_RECORD_TYPES as D, getStatusCode as E, isClientError as F, type GeoResult as G, HTTP_HEADERS as H, isServerError as I, isSuccess as J, isValidIp as K, isValidIpv4 as L, isValidIpv6 as M, parseDnsResponse as N, parseGeoResponse as O, type ParsedDnsResult as P, parseHar as Q, type RobotsGroup as R, STATUS_CODES as S, parseUserAgent as T, type UaDeviceType as U, searchHeaders as V, searchStatusCodes as W, statusCodeToText as X, typeNumberToLabel as Y, validateDomain as Z, validateHeaderName as _, type DnsRecord as a, validateRobotsTxt as a0, validateSitemap as a1, type DnsRecordType as b, type DnsResponse as c, type HarEntry as d, type HarParseResult as e, type HarSummary as f, type HeaderCategory as g, type HttpHeader as h, type ParsedGeoResult as i, type RobotsIssue as j, type RobotsRule as k, type RobotsValidationResult as l, type SitemapIndexEntry as m, network as n, type SitemapIssue as o, type SitemapUrlEntry as p, type SitemapValidationResult as q, type StatusCode as r, type UserAgentInfo as s, buildDnsQueryUrl as t, buildGeoUrl as u, buildMapUrl as v, countryCodeToFlag as w, formatCoordinates as x, formatTtl as y, getByCategory as z };
|
package/dist/tools/ai_agent.cjs
CHANGED
|
@@ -917,6 +917,35 @@ function summarizeForLlm(text, maxTokens = 200, strategy = "extractive") {
|
|
|
917
917
|
const st = tok(summary);
|
|
918
918
|
return { summary, originalTokens: ot, summaryTokens: st, compressionRatio: Math.round(st / Math.max(1, ot) * 100) / 100, sentencesKept: picked.length, sentencesTotal: sents.length };
|
|
919
919
|
}
|
|
920
|
+
function vectorSimilarity(a, b) {
|
|
921
|
+
if (!Array.isArray(a) || !Array.isArray(b)) return { error: "Both inputs must be arrays of numbers" };
|
|
922
|
+
if (a.length === 0 || b.length === 0) return { error: "Vectors must not be empty" };
|
|
923
|
+
if (a.length !== b.length) return { error: `Vectors must have the same length (got ${a.length} and ${b.length})` };
|
|
924
|
+
if (!a.every((n) => typeof n === "number" && Number.isFinite(n)) || !b.every((n) => typeof n === "number" && Number.isFinite(n))) {
|
|
925
|
+
return { error: "Vectors must contain only finite numbers" };
|
|
926
|
+
}
|
|
927
|
+
const round6 = (n) => Math.round(n * 1e6) / 1e6;
|
|
928
|
+
let dot = 0, sa = 0, sb = 0, sqDist = 0, absDist = 0;
|
|
929
|
+
for (let i = 0; i < a.length; i++) {
|
|
930
|
+
dot += a[i] * b[i];
|
|
931
|
+
sa += a[i] * a[i];
|
|
932
|
+
sb += b[i] * b[i];
|
|
933
|
+
const d = a[i] - b[i];
|
|
934
|
+
sqDist += d * d;
|
|
935
|
+
absDist += Math.abs(d);
|
|
936
|
+
}
|
|
937
|
+
const magA = Math.sqrt(sa), magB = Math.sqrt(sb);
|
|
938
|
+
const cosine = magA === 0 || magB === 0 ? 0 : dot / (magA * magB);
|
|
939
|
+
return {
|
|
940
|
+
dimensions: a.length,
|
|
941
|
+
dotProduct: round6(dot),
|
|
942
|
+
cosineSimilarity: round6(cosine),
|
|
943
|
+
euclideanDistance: round6(Math.sqrt(sqDist)),
|
|
944
|
+
manhattanDistance: round6(absDist),
|
|
945
|
+
magnitudeA: round6(magA),
|
|
946
|
+
magnitudeB: round6(magB)
|
|
947
|
+
};
|
|
948
|
+
}
|
|
920
949
|
|
|
921
950
|
exports.MODEL_PRICING = MODEL_PRICING;
|
|
922
951
|
exports.chunkText = chunkText;
|
|
@@ -947,3 +976,4 @@ exports.summarizeForLlm = summarizeForLlm;
|
|
|
947
976
|
exports.trimToTokens = trimToTokens;
|
|
948
977
|
exports.unflattenJson = unflattenJson;
|
|
949
978
|
exports.validateJsonSchema = validateJsonSchema;
|
|
979
|
+
exports.vectorSimilarity = vectorSimilarity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as ChunkStrategy, b as CompressHtmlResult, c as CompressJsonResult, d as CompressMarkdownResult, e as CostEstimate, D as DedupeResult, f as DedupeStrategy, g as DiffEntry2, h as DiffOp2, i as DiffResult2, E as Entity2, j as EntityType2, k as ExtractJsonResult, l as ExtractKeywordsResult, m as ExtractUrlsResult, I as InjectionDetectResult, n as InjectionFinding, J as JsonBlock, o as JsonRepairResult, K as Keyword, M as MODEL_PRICING, p as MergeResult, q as MergeStrategy, r as ModelPricing, P as PiiDetectResult, s as PiiFinding, t as PiiType, R as RankedChunk, u as RelevanceResult, S as SanitizeResult, v as SecretDetectResult, w as SecretFinding, x as SecretType, y as SummaryResult, T as TableResult2, z as TextChunk, A as TokenEstimate, B as TokenEstimateResult, F as TrimResult, G as TrimStrategy, U as UrlMatch, V as ValidationError, H as ValidationResult, L as
|
|
1
|
+
export { C as ChunkStrategy, b as CompressHtmlResult, c as CompressJsonResult, d as CompressMarkdownResult, e as CostEstimate, D as DedupeResult, f as DedupeStrategy, g as DiffEntry2, h as DiffOp2, i as DiffResult2, E as Entity2, j as EntityType2, k as ExtractJsonResult, l as ExtractKeywordsResult, m as ExtractUrlsResult, I as InjectionDetectResult, n as InjectionFinding, J as JsonBlock, o as JsonRepairResult, K as Keyword, M as MODEL_PRICING, p as MergeResult, q as MergeStrategy, r as ModelPricing, P as PiiDetectResult, s as PiiFinding, t as PiiType, R as RankedChunk, u as RelevanceResult, S as SanitizeResult, v as SecretDetectResult, w as SecretFinding, x as SecretType, y as SummaryResult, T as TableResult2, z as TextChunk, A as TokenEstimate, B as TokenEstimateResult, F as TrimResult, G as TrimStrategy, U as UrlMatch, V as ValidationError, H as ValidationResult, L as VectorSimilarityResult, N as chunkText, O as compressHtml, Q as compressJson, W as compressMarkdown, X as deduplicateLines, Y as detectPii, Z as detectPromptInjection, _ as detectSecrets, $ as diffJson, a0 as estimateCost, a1 as estimateTokens, a2 as expandQuery, a3 as extractEntities, a4 as extractJson, a5 as extractKeywords, a6 as extractTables, a7 as extractUrls, a8 as flattenJson, a9 as mergeJson, aa as redactPii, ab as repairJson, ac as rerankChunks, ad as sanitizeHtml, ae as scoreRelevance, af as summarizeForLlm, ag as trimToTokens, ah as unflattenJson, ai as validateJsonSchema, aj as vectorSimilarity } from '../ai_agent-B-c59NXD.cjs';
|