@utilix-tech/sdk 0.17.0 → 0.19.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.
@@ -19,6 +19,7 @@
19
19
  * - css-minifier (minifyCss, formatCss, countRules, countProperties)
20
20
  * - mime-lookup (lookupMime, MIME_TABLE)
21
21
  * - github-url-parser (parseGithubUrl)
22
+ * - redos-detector (detectRedos)
22
23
  */
23
24
  type RegexFlag = 'g' | 'i' | 'm' | 's' | 'u';
24
25
  declare const ALL_FLAGS: RegexFlag[];
@@ -307,6 +308,32 @@ interface GithubUrlInfo {
307
308
  declare function parseGithubUrl(input: string): GithubUrlInfo | {
308
309
  error: string;
309
310
  };
311
+ type RedosSeverity = 'high' | 'medium';
312
+ interface RedosFinding {
313
+ type: 'nested-quantifier' | 'overlapping-alternation' | 'adjacent-quantifier';
314
+ severity: RedosSeverity;
315
+ message: string;
316
+ snippet: string;
317
+ index: number;
318
+ }
319
+ interface RedosResult {
320
+ pattern: string;
321
+ valid: boolean;
322
+ compileError?: string;
323
+ risk: 'none' | 'medium' | 'high';
324
+ safe: boolean;
325
+ findings: RedosFinding[];
326
+ }
327
+ /**
328
+ * Statically analyze a regex pattern for catastrophic-backtracking (ReDoS)
329
+ * risk. Pass the pattern body only (no delimiters or flags). This is a
330
+ * heuristic linter focused on the classic exponential/quadratic constructs
331
+ * (nested quantifiers, overlapping alternation under a repeat, adjacent
332
+ * overlapping quantifiers), not a formal guarantee.
333
+ */
334
+ declare function detectRedos(pattern: string): RedosResult | {
335
+ error: string;
336
+ };
310
337
 
311
338
  declare const code_ALL_FLAGS: typeof ALL_FLAGS;
312
339
  type code_ApiEndpoint = ApiEndpoint;
@@ -334,6 +361,9 @@ type code_MimeEntry = MimeEntry;
334
361
  type code_MimeLookupResult = MimeLookupResult;
335
362
  declare const code_OPERATIONS: typeof OPERATIONS;
336
363
  type code_ParsedSpec = ParsedSpec;
364
+ type code_RedosFinding = RedosFinding;
365
+ type code_RedosResult = RedosResult;
366
+ type code_RedosSeverity = RedosSeverity;
337
367
  type code_RegexError = RegexError;
338
368
  type code_RegexFlag = RegexFlag;
339
369
  type code_RegexMatch = RegexMatch;
@@ -354,6 +384,7 @@ declare const code_countProperties: typeof countProperties;
354
384
  declare const code_countRules: typeof countRules;
355
385
  declare const code_detectDialect: typeof detectDialect;
356
386
  declare const code_detectOperationType: typeof detectOperationType;
387
+ declare const code_detectRedos: typeof detectRedos;
357
388
  declare const code_envToExport: typeof envToExport;
358
389
  declare const code_envToJson: typeof envToJson;
359
390
  declare const code_formatCss: typeof formatCss;
@@ -389,7 +420,7 @@ declare const code_testPattern: typeof testPattern;
389
420
  declare const code_testRegex: typeof testRegex;
390
421
  declare const code_validateEnvKey: typeof validateEnvKey;
391
422
  declare namespace code {
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 };
423
+ 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_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, 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_detectRedos as detectRedos, 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 };
393
424
  }
394
425
 
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 };
426
+ export { formatCss as $, ALL_FLAGS as A, type SqlDialect as B, CHEATSHEET as C, type DockerImageRef as D, type EnvEntry as E, type SqlFormatOptions as F, type GitCommandConfig as G, type HtmlFormatResult as H, buildDockerPull as I, type JsMinifyOptions as J, buildDockerRun as K, buildGitCommand as L, MIME_TABLE as M, collapseHtmlWhitespace as N, OPERATIONS as O, type ParsedSpec as P, collapseJsWhitespace as Q, type RedosFinding as R, SQL_DEFAULT_OPTIONS as S, type TestPatternResult as T, countProperties as U, countRules as V, detectDialect as W, detectOperationType as X, detectRedos as Y, envToExport as Z, envToJson as _, type ApiEndpoint as a, formatGql as a0, formatHtml as a1, formatSql as a2, getEndpointsByTag as a3, getHtmlStats as a4, getJsStats as a5, getMethodColor as a6, isValidTag as a7, lookupMime as a8, minifyCss as a9, minifyGql as aa, minifyHtml as ab, minifyJs as ac, minifySql as ad, normalizeRef as ae, parseDockerImage as af, parseEnv as ag, parseGitCommand as ah, parseGithubUrl as ai, parseSpec as aj, removeConsoleCalls as ak, removeEmptyAttributes as al, removeHtmlComments as am, removeJsComments as an, removeRedundantAttributes as ao, searchCheatsheet as ap, searchEndpoints as aq, splitStatements as ar, testPattern as as, testRegex as at, validateEnvKey as au, 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 RedosResult as r, type RedosSeverity as s, type RegexError as t, type RegexFlag as u, type RegexMatch as v, type RegexResult as w, type RegexSuccess as x, type Segment as y, type SpecVersion as z };
@@ -19,6 +19,7 @@
19
19
  * - css-minifier (minifyCss, formatCss, countRules, countProperties)
20
20
  * - mime-lookup (lookupMime, MIME_TABLE)
21
21
  * - github-url-parser (parseGithubUrl)
22
+ * - redos-detector (detectRedos)
22
23
  */
23
24
  type RegexFlag = 'g' | 'i' | 'm' | 's' | 'u';
24
25
  declare const ALL_FLAGS: RegexFlag[];
@@ -307,6 +308,32 @@ interface GithubUrlInfo {
307
308
  declare function parseGithubUrl(input: string): GithubUrlInfo | {
308
309
  error: string;
309
310
  };
311
+ type RedosSeverity = 'high' | 'medium';
312
+ interface RedosFinding {
313
+ type: 'nested-quantifier' | 'overlapping-alternation' | 'adjacent-quantifier';
314
+ severity: RedosSeverity;
315
+ message: string;
316
+ snippet: string;
317
+ index: number;
318
+ }
319
+ interface RedosResult {
320
+ pattern: string;
321
+ valid: boolean;
322
+ compileError?: string;
323
+ risk: 'none' | 'medium' | 'high';
324
+ safe: boolean;
325
+ findings: RedosFinding[];
326
+ }
327
+ /**
328
+ * Statically analyze a regex pattern for catastrophic-backtracking (ReDoS)
329
+ * risk. Pass the pattern body only (no delimiters or flags). This is a
330
+ * heuristic linter focused on the classic exponential/quadratic constructs
331
+ * (nested quantifiers, overlapping alternation under a repeat, adjacent
332
+ * overlapping quantifiers), not a formal guarantee.
333
+ */
334
+ declare function detectRedos(pattern: string): RedosResult | {
335
+ error: string;
336
+ };
310
337
 
311
338
  declare const code_ALL_FLAGS: typeof ALL_FLAGS;
312
339
  type code_ApiEndpoint = ApiEndpoint;
@@ -334,6 +361,9 @@ type code_MimeEntry = MimeEntry;
334
361
  type code_MimeLookupResult = MimeLookupResult;
335
362
  declare const code_OPERATIONS: typeof OPERATIONS;
336
363
  type code_ParsedSpec = ParsedSpec;
364
+ type code_RedosFinding = RedosFinding;
365
+ type code_RedosResult = RedosResult;
366
+ type code_RedosSeverity = RedosSeverity;
337
367
  type code_RegexError = RegexError;
338
368
  type code_RegexFlag = RegexFlag;
339
369
  type code_RegexMatch = RegexMatch;
@@ -354,6 +384,7 @@ declare const code_countProperties: typeof countProperties;
354
384
  declare const code_countRules: typeof countRules;
355
385
  declare const code_detectDialect: typeof detectDialect;
356
386
  declare const code_detectOperationType: typeof detectOperationType;
387
+ declare const code_detectRedos: typeof detectRedos;
357
388
  declare const code_envToExport: typeof envToExport;
358
389
  declare const code_envToJson: typeof envToJson;
359
390
  declare const code_formatCss: typeof formatCss;
@@ -389,7 +420,7 @@ declare const code_testPattern: typeof testPattern;
389
420
  declare const code_testRegex: typeof testRegex;
390
421
  declare const code_validateEnvKey: typeof validateEnvKey;
391
422
  declare namespace code {
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 };
423
+ 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_RedosFinding as RedosFinding, type code_RedosResult as RedosResult, type code_RedosSeverity as RedosSeverity, 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_detectRedos as detectRedos, 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 };
393
424
  }
394
425
 
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 };
426
+ export { formatCss as $, ALL_FLAGS as A, type SqlDialect as B, CHEATSHEET as C, type DockerImageRef as D, type EnvEntry as E, type SqlFormatOptions as F, type GitCommandConfig as G, type HtmlFormatResult as H, buildDockerPull as I, type JsMinifyOptions as J, buildDockerRun as K, buildGitCommand as L, MIME_TABLE as M, collapseHtmlWhitespace as N, OPERATIONS as O, type ParsedSpec as P, collapseJsWhitespace as Q, type RedosFinding as R, SQL_DEFAULT_OPTIONS as S, type TestPatternResult as T, countProperties as U, countRules as V, detectDialect as W, detectOperationType as X, detectRedos as Y, envToExport as Z, envToJson as _, type ApiEndpoint as a, formatGql as a0, formatHtml as a1, formatSql as a2, getEndpointsByTag as a3, getHtmlStats as a4, getJsStats as a5, getMethodColor as a6, isValidTag as a7, lookupMime as a8, minifyCss as a9, minifyGql as aa, minifyHtml as ab, minifyJs as ac, minifySql as ad, normalizeRef as ae, parseDockerImage as af, parseEnv as ag, parseGitCommand as ah, parseGithubUrl as ai, parseSpec as aj, removeConsoleCalls as ak, removeEmptyAttributes as al, removeHtmlComments as am, removeJsComments as an, removeRedundantAttributes as ao, searchCheatsheet as ap, searchEndpoints as aq, splitStatements as ar, testPattern as as, testRegex as at, validateEnvKey as au, 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 RedosResult as r, type RedosSeverity as s, type RegexError as t, type RegexFlag as u, type RegexMatch as v, type RegexResult as w, type RegexSuccess as x, type Segment as y, type SpecVersion 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 = {};
@@ -10967,6 +11007,7 @@ __export(code_exports, {
10967
11007
  countRules: () => countRules,
10968
11008
  detectDialect: () => detectDialect,
10969
11009
  detectOperationType: () => detectOperationType,
11010
+ detectRedos: () => detectRedos,
10970
11011
  envToExport: () => envToExport2,
10971
11012
  envToJson: () => envToJson2,
10972
11013
  formatCss: () => formatCss,
@@ -13424,6 +13465,270 @@ function parseGithubUrl(input) {
13424
13465
  }
13425
13466
  return { error: `Unsupported GitHub URL path: /${rest.join("/")}` };
13426
13467
  }
13468
+ var _REDOS_UNBOUNDED = /* @__PURE__ */ new Set(["*", "+"]);
13469
+ function _redosParseQuant(src, i) {
13470
+ const ch = src[i];
13471
+ if (ch === "*" || ch === "+" || ch === "?") {
13472
+ let end = i + 1;
13473
+ if (src[end] === "?" || src[end] === "+") end++;
13474
+ return { unbounded: _REDOS_UNBOUNDED.has(ch), raw: src.slice(i, end), end };
13475
+ }
13476
+ if (ch === "{") {
13477
+ const close = src.indexOf("}", i);
13478
+ if (close === -1) return null;
13479
+ const inner = src.slice(i + 1, close);
13480
+ if (!/^\d+(,\d*)?$/.test(inner)) return null;
13481
+ let end = close + 1;
13482
+ if (src[end] === "?" || src[end] === "+") end++;
13483
+ const unbounded = /^\d+,$/.test(inner);
13484
+ return { unbounded, raw: src.slice(i, end), end };
13485
+ }
13486
+ return null;
13487
+ }
13488
+ function _redosParseAlternation(src, start, endExclusive) {
13489
+ const alternatives = [];
13490
+ let current = [];
13491
+ let i = start;
13492
+ while (i < endExclusive) {
13493
+ const ch = src[i];
13494
+ if (ch === "|") {
13495
+ alternatives.push(current);
13496
+ current = [];
13497
+ i++;
13498
+ continue;
13499
+ }
13500
+ let node;
13501
+ if (ch === "\\") {
13502
+ const atomEnd = i + 2 <= endExclusive ? i + 2 : i + 1;
13503
+ node = { kind: "char", start: i, end: atomEnd, quant: null, quantEnd: atomEnd, raw: src.slice(i, atomEnd) };
13504
+ i = atomEnd;
13505
+ } else if (ch === "[") {
13506
+ let j = i + 1;
13507
+ if (src[j] === "^") j++;
13508
+ if (src[j] === "]") j++;
13509
+ while (j < endExclusive && src[j] !== "]") {
13510
+ j += src[j] === "\\" ? 2 : 1;
13511
+ }
13512
+ const classEnd = j < endExclusive ? j + 1 : endExclusive;
13513
+ node = { kind: "class", start: i, end: classEnd, quant: null, quantEnd: classEnd, raw: src.slice(i, classEnd) };
13514
+ i = classEnd;
13515
+ } else if (ch === "(") {
13516
+ let depth = 1;
13517
+ let j = i + 1;
13518
+ while (j < endExclusive && depth > 0) {
13519
+ const cj = src[j];
13520
+ if (cj === "\\") {
13521
+ j += 2;
13522
+ continue;
13523
+ }
13524
+ if (cj === "[") {
13525
+ j++;
13526
+ if (src[j] === "^") j++;
13527
+ if (src[j] === "]") j++;
13528
+ while (j < endExclusive && src[j] !== "]") {
13529
+ j += src[j] === "\\" ? 2 : 1;
13530
+ }
13531
+ j++;
13532
+ continue;
13533
+ }
13534
+ if (cj === "(") depth++;
13535
+ else if (cj === ")") depth--;
13536
+ j++;
13537
+ }
13538
+ const closeIdx = depth === 0 ? j - 1 : endExclusive;
13539
+ let contentStart = i + 1;
13540
+ let lookaround = false;
13541
+ if (src[i + 1] === "?") {
13542
+ const after = src[i + 2];
13543
+ if (after === ":") contentStart = i + 3;
13544
+ else if (after === "=" || after === "!") {
13545
+ contentStart = i + 3;
13546
+ lookaround = true;
13547
+ } else if (after === "<") {
13548
+ const a3 = src[i + 3];
13549
+ if (a3 === "=" || a3 === "!") {
13550
+ contentStart = i + 4;
13551
+ lookaround = true;
13552
+ } else {
13553
+ const gt = src.indexOf(">", i + 2);
13554
+ contentStart = gt !== -1 && gt < closeIdx ? gt + 1 : i + 3;
13555
+ }
13556
+ }
13557
+ }
13558
+ node = {
13559
+ kind: "group",
13560
+ start: i,
13561
+ end: closeIdx + 1,
13562
+ quant: null,
13563
+ quantEnd: closeIdx + 1,
13564
+ raw: src.slice(i, closeIdx + 1),
13565
+ alternatives: _redosParseAlternation(src, contentStart, closeIdx),
13566
+ lookaround
13567
+ };
13568
+ i = closeIdx + 1;
13569
+ } else if (ch === ".") {
13570
+ node = { kind: "dot", start: i, end: i + 1, quant: null, quantEnd: i + 1, raw: "." };
13571
+ i++;
13572
+ } else if (ch === "^" || ch === "$") {
13573
+ node = { kind: "anchor", start: i, end: i + 1, quant: null, quantEnd: i + 1, raw: ch };
13574
+ i++;
13575
+ } else {
13576
+ node = { kind: "char", start: i, end: i + 1, quant: null, quantEnd: i + 1, raw: ch };
13577
+ i++;
13578
+ }
13579
+ if (node.kind !== "anchor") {
13580
+ const q = _redosParseQuant(src, i);
13581
+ if (q) {
13582
+ node.quant = q;
13583
+ node.quantEnd = q.end;
13584
+ i = q.end;
13585
+ }
13586
+ }
13587
+ current.push(node);
13588
+ }
13589
+ alternatives.push(current);
13590
+ return alternatives;
13591
+ }
13592
+ var _REDOS_ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ .,-@/:;#%&=";
13593
+ function _redosFirstMatcher(node) {
13594
+ if (node.kind === "dot") return (c) => c !== "\n";
13595
+ if (node.kind === "char") {
13596
+ if (node.raw.startsWith("\\")) {
13597
+ const body = node.raw.slice(1);
13598
+ if (/^[dDwWsS]$/.test(body)) {
13599
+ try {
13600
+ const re = new RegExp("\\" + body);
13601
+ return (c) => re.test(c);
13602
+ } catch {
13603
+ return null;
13604
+ }
13605
+ }
13606
+ const literal = { n: "\n", t: " ", r: "\r", f: "\f", v: "\v" }[body] ?? body;
13607
+ return (c) => c === literal;
13608
+ }
13609
+ const lit = node.raw;
13610
+ return (c) => c === lit;
13611
+ }
13612
+ if (node.kind === "class") {
13613
+ try {
13614
+ const re = new RegExp(node.raw);
13615
+ return (c) => re.test(c);
13616
+ } catch {
13617
+ return null;
13618
+ }
13619
+ }
13620
+ if (node.kind === "group") {
13621
+ const first = node.alternatives?.[0]?.[0];
13622
+ return first ? _redosFirstMatcher(first) : null;
13623
+ }
13624
+ return null;
13625
+ }
13626
+ function _redosOverlaps(a, b) {
13627
+ const fa = _redosFirstMatcher(a);
13628
+ const fb = _redosFirstMatcher(b);
13629
+ if (!fa || !fb) return false;
13630
+ for (const c of _REDOS_ALPHABET) {
13631
+ if (fa(c) && fb(c)) return true;
13632
+ }
13633
+ return false;
13634
+ }
13635
+ function _redosAnalyzeGroup(node, findings) {
13636
+ const alts = node.alternatives ?? [];
13637
+ const outerUnbounded = node.quant?.unbounded === true && !node.lookaround;
13638
+ if (outerUnbounded) {
13639
+ for (const alt of alts) {
13640
+ const meaningful = alt.filter((n) => n.kind !== "anchor");
13641
+ if (meaningful.length === 1 && meaningful[0].quant?.unbounded) {
13642
+ findings.push({
13643
+ type: "nested-quantifier",
13644
+ severity: "high",
13645
+ message: "Nested unbounded quantifiers: a repeated group whose body is itself unbounded-repeated can match the same input in exponentially many ways, causing catastrophic backtracking.",
13646
+ snippet: node.raw + (node.quant?.raw ?? ""),
13647
+ index: node.start
13648
+ });
13649
+ break;
13650
+ }
13651
+ }
13652
+ if (alts.length > 1) {
13653
+ const firsts = alts.map((alt) => alt.find((n) => n.kind !== "anchor")).filter((n) => !!n);
13654
+ let flagged = false;
13655
+ for (let x = 0; x < firsts.length && !flagged; x++) {
13656
+ for (let y = x + 1; y < firsts.length; y++) {
13657
+ if (_redosOverlaps(firsts[x], firsts[y])) {
13658
+ findings.push({
13659
+ type: "overlapping-alternation",
13660
+ severity: "medium",
13661
+ message: "Overlapping alternation under a repetition: two branches can match the same starting input, so the engine has multiple ways to split each repeat and may backtrack heavily.",
13662
+ snippet: node.raw + (node.quant?.raw ?? ""),
13663
+ index: node.start
13664
+ });
13665
+ flagged = true;
13666
+ break;
13667
+ }
13668
+ }
13669
+ }
13670
+ }
13671
+ }
13672
+ for (const alt of alts) {
13673
+ _redosAnalyzeSequence(alt, findings);
13674
+ }
13675
+ }
13676
+ function _redosAnalyzeSequence(seq, findings) {
13677
+ for (let k = 0; k + 1 < seq.length; k++) {
13678
+ const a = seq[k];
13679
+ const b = seq[k + 1];
13680
+ if (a.quant?.unbounded && b.quant?.unbounded && _redosOverlaps(a, b)) {
13681
+ findings.push({
13682
+ type: "adjacent-quantifier",
13683
+ severity: "medium",
13684
+ message: "Adjacent unbounded quantifiers over overlapping characters: the engine can distribute the same input between them in many ways, causing quadratic backtracking.",
13685
+ snippet: seq[k].raw + (a.quant?.raw ?? "") + seq[k + 1].raw + (b.quant?.raw ?? ""),
13686
+ index: a.start
13687
+ });
13688
+ }
13689
+ }
13690
+ for (const node of seq) {
13691
+ if (node.kind === "group") _redosAnalyzeGroup(node, findings);
13692
+ }
13693
+ }
13694
+ function detectRedos(pattern) {
13695
+ if (typeof pattern !== "string" || pattern === "") {
13696
+ return { error: "Empty pattern" };
13697
+ }
13698
+ if (pattern.length > 5e3) {
13699
+ return { error: "Pattern too long (max 5,000 chars)" };
13700
+ }
13701
+ let valid = true;
13702
+ let compileError;
13703
+ try {
13704
+ new RegExp(pattern);
13705
+ } catch (e) {
13706
+ valid = false;
13707
+ compileError = e instanceof Error ? e.message : String(e);
13708
+ }
13709
+ const findings = [];
13710
+ const alternatives = _redosParseAlternation(pattern, 0, pattern.length);
13711
+ for (const alt of alternatives) {
13712
+ _redosAnalyzeSequence(alt, findings);
13713
+ }
13714
+ const seen = /* @__PURE__ */ new Set();
13715
+ const unique = findings.filter((f) => {
13716
+ const key = `${f.type}:${f.index}`;
13717
+ if (seen.has(key)) return false;
13718
+ seen.add(key);
13719
+ return true;
13720
+ });
13721
+ unique.sort((a, b) => a.index - b.index);
13722
+ const risk = unique.some((f) => f.severity === "high") ? "high" : unique.length > 0 ? "medium" : "none";
13723
+ return {
13724
+ pattern,
13725
+ valid,
13726
+ ...compileError ? { compileError } : {},
13727
+ risk,
13728
+ safe: unique.length === 0,
13729
+ findings: unique
13730
+ };
13731
+ }
13427
13732
 
13428
13733
  // src/tools/color.ts
13429
13734
  var color_exports = {};
@@ -17035,7 +17340,8 @@ __export(ai_agent_exports, {
17035
17340
  summarizeForLlm: () => summarizeForLlm,
17036
17341
  trimToTokens: () => trimToTokens,
17037
17342
  unflattenJson: () => unflattenJson,
17038
- validateJsonSchema: () => validateJsonSchema
17343
+ validateJsonSchema: () => validateJsonSchema,
17344
+ vectorSimilarity: () => vectorSimilarity
17039
17345
  });
17040
17346
  var MODEL_PRICING = [
17041
17347
  { model: "gpt-4o", label: "GPT-4o", inputPer1M: 5, outputPer1M: 15 },
@@ -17953,6 +18259,35 @@ function summarizeForLlm(text, maxTokens = 200, strategy = "extractive") {
17953
18259
  const st = tok(summary);
17954
18260
  return { summary, originalTokens: ot, summaryTokens: st, compressionRatio: Math.round(st / Math.max(1, ot) * 100) / 100, sentencesKept: picked.length, sentencesTotal: sents.length };
17955
18261
  }
18262
+ function vectorSimilarity(a, b) {
18263
+ if (!Array.isArray(a) || !Array.isArray(b)) return { error: "Both inputs must be arrays of numbers" };
18264
+ if (a.length === 0 || b.length === 0) return { error: "Vectors must not be empty" };
18265
+ if (a.length !== b.length) return { error: `Vectors must have the same length (got ${a.length} and ${b.length})` };
18266
+ if (!a.every((n) => typeof n === "number" && Number.isFinite(n)) || !b.every((n) => typeof n === "number" && Number.isFinite(n))) {
18267
+ return { error: "Vectors must contain only finite numbers" };
18268
+ }
18269
+ const round6 = (n) => Math.round(n * 1e6) / 1e6;
18270
+ let dot = 0, sa = 0, sb = 0, sqDist = 0, absDist = 0;
18271
+ for (let i = 0; i < a.length; i++) {
18272
+ dot += a[i] * b[i];
18273
+ sa += a[i] * a[i];
18274
+ sb += b[i] * b[i];
18275
+ const d = a[i] - b[i];
18276
+ sqDist += d * d;
18277
+ absDist += Math.abs(d);
18278
+ }
18279
+ const magA = Math.sqrt(sa), magB = Math.sqrt(sb);
18280
+ const cosine = magA === 0 || magB === 0 ? 0 : dot / (magA * magB);
18281
+ return {
18282
+ dimensions: a.length,
18283
+ dotProduct: round6(dot),
18284
+ cosineSimilarity: round6(cosine),
18285
+ euclideanDistance: round6(Math.sqrt(sqDist)),
18286
+ manhattanDistance: round6(absDist),
18287
+ magnitudeA: round6(magA),
18288
+ magnitudeB: round6(magB)
18289
+ };
18290
+ }
17956
18291
 
17957
18292
  // src/tools/media.ts
17958
18293
  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-CkV4kAIs.cjs';
8
+ export { u as units } from './units-BFTQwpBu.cjs';
9
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-Cn9uOIAh.cjs';
11
+ export { c as code } from './code-DaRvff2v.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-CcpkV2DR.cjs';
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-CkV4kAIs.js';
8
+ export { u as units } from './units-BFTQwpBu.js';
9
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-Cn9uOIAh.js';
11
+ export { c as code } from './code-DaRvff2v.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-CcpkV2DR.js';
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-M4MMO6C6.js';
2
+ export { units_exports as units } from './chunk-U34B5XPK.js';
3
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-L53LAVAD.js';
5
+ export { code_exports as code } from './chunk-LXKIPPDG.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-M35VJETW.js';
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';
@@ -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 chunkText, N as compressHtml, O as compressJson, Q as compressMarkdown, W as deduplicateLines, X as detectPii, Y as detectPromptInjection, Z as detectSecrets, _ as diffJson, $ as estimateCost, a0 as estimateTokens, a1 as expandQuery, a2 as extractEntities, a3 as extractJson, a4 as extractKeywords, a5 as extractTables, a6 as extractUrls, a7 as flattenJson, a8 as mergeJson, a9 as redactPii, aa as repairJson, ab as rerankChunks, ac as sanitizeHtml, ad as scoreRelevance, ae as summarizeForLlm, af as trimToTokens, ag as unflattenJson, ah as validateJsonSchema } from '../ai_agent-CcpkV2DR.cjs';
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';