@utilix-tech/sdk 0.78.0 → 0.80.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 +8 -0
- package/README.md +21 -6
- package/dist/{ai_agent-CmrVjvYH.d.cts → ai_agent-DeCy0oZK.d.cts} +42 -2
- package/dist/{ai_agent-CmrVjvYH.d.ts → ai_agent-DeCy0oZK.d.ts} +42 -2
- package/dist/{chunk-EKIXOA7B.js → chunk-HJLGUNSO.js} +58 -1
- package/dist/{chunk-RP574L5Z.js → chunk-OFLNVDNX.js} +46 -1
- package/dist/{chunk-XT2BQWXT.js → chunk-RYSN5JNA.js} +49 -1
- package/dist/{chunk-34C6GXCC.js → chunk-WUOZHCIC.js} +217 -1
- package/dist/{code-46xO9xFf.d.cts → code-C4n621_i.d.cts} +30 -2
- package/dist/{code-46xO9xFf.d.ts → code-C4n621_i.d.ts} +30 -2
- package/dist/index.cjs +366 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/{json-CaiYsGDQ.d.cts → json-Ca6gZCNB.d.cts} +45 -2
- package/dist/{json-CaiYsGDQ.d.ts → json-Ca6gZCNB.d.ts} +45 -2
- package/dist/tools/ai_agent.cjs +57 -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 +48 -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/json.cjs +216 -0
- package/dist/tools/json.d.cts +1 -1
- package/dist/tools/json.d.ts +1 -1
- package/dist/tools/json.js +1 -1
- package/dist/tools/units.cjs +45 -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-BqegyALA.d.ts → units-D7YRRwei.d.cts} +29 -2
- package/dist/{units-BqegyALA.d.cts → units-D7YRRwei.d.ts} +29 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.80.0
|
|
6
|
+
- Add `diffJsonPatch`, `applyJsonPatch`, `generateJsonPatch` (json-patch): diff two JSON documents into an RFC 6902 JSON Patch operation list (add/remove/replace/move/copy/test), or apply a patch to a target document.
|
|
7
|
+
- Add `parseConnectionString` (connection-string-parser): parse a database connection URI (postgres, mysql, mongodb, redis, amqp, and similar) into its scheme, credentials, hosts, database, and query parameters.
|
|
8
|
+
|
|
9
|
+
## 0.79.0
|
|
10
|
+
- Add `calculateRealRateOfReturn` (real-rate-of-return-calculator): apply the Fisher equation to solve for whichever of the nominal rate, inflation rate, or inflation-adjusted real rate is missing, given exactly two of the three.
|
|
11
|
+
- Add `calculateRetryBackoffSchedule` (retry-backoff-calculator): compute the full sequence of delays an exponential-backoff retry policy would actually produce, optionally capped and with full/equal jitter ranges, plus the total best-case and worst-case wait across all retries.
|
|
12
|
+
|
|
5
13
|
## 0.78.0
|
|
6
14
|
- Add `ndjsonToCsv` (ndjson-to-csv): convert newline-delimited JSON (one flat object per line) into CSV, inferring the header row from the union of keys across all lines.
|
|
7
15
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**712 developer utility functions for Node.js: runs locally, no API key required.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
@@ -66,7 +66,8 @@ const { formatJson } = require("@utilix-tech/sdk/json");
|
|
|
66
66
|
|
|
67
67
|
```ts
|
|
68
68
|
import { formatJson, minifyJson, diffJson, jsonToTypescript, jsonSchemaToTypescript, validateJson,
|
|
69
|
-
evaluateJsonPath, resolveJsonPointer, applyJsonMergePatch,
|
|
69
|
+
evaluateJsonPath, resolveJsonPointer, applyJsonMergePatch, diffJsonPatch, applyJsonPatch,
|
|
70
|
+
jsonToCsv, yamlToJson, jsonToYaml, getJsonStats } from "@utilix-tech/sdk/json";
|
|
70
71
|
|
|
71
72
|
// Format with 2-space indent
|
|
72
73
|
formatJson('{"name":"alice","age":30}', { indent: 2 });
|
|
@@ -91,6 +92,12 @@ resolveJsonPointer('{"users":[{"name":"Alice"}]}', "/users/0/name");
|
|
|
91
92
|
applyJsonMergePatch('{"a":"b","c":{"d":"e","f":"g"}}', '{"a":"z","c":{"f":null}}');
|
|
92
93
|
// { result: { a: "z", c: { d: "e" } } }
|
|
93
94
|
|
|
95
|
+
// Diff two documents into an RFC 6902 JSON Patch, or apply one
|
|
96
|
+
diffJsonPatch({ a: 1 }, { a: 2 });
|
|
97
|
+
// [{ op: "replace", path: "/a", value: 2 }]
|
|
98
|
+
applyJsonPatch({ foo: "bar" }, [{ op: "add", path: "/baz", value: "qux" }]);
|
|
99
|
+
// { result: { foo: "bar", baz: "qux" } }
|
|
100
|
+
|
|
94
101
|
// Convert JSON to CSV
|
|
95
102
|
jsonToCsv('[{"a":1,"b":2}]');
|
|
96
103
|
|
|
@@ -356,7 +363,7 @@ formatIso8601Duration(90061); // { iso: "P1DT1H1M1S", ... }
|
|
|
356
363
|
### `/units`: Conversions
|
|
357
364
|
|
|
358
365
|
```ts
|
|
359
|
-
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest, calculateTimeValue, calculatePercentageChange, convertAprApy, calculateMarginMarkup, calculateDiscount, applySuccessiveDiscounts, calculateBreakEven, calculateVideoBitrate, calculateRuleOf72, calculateEmi, calculateRoi, compareUnitPrices, calculatePaybackPeriod, calculateCdMaturity, calculateDepreciationSchedule, calculateCashRounding, calculateMovingAverages, calculateGpa, calculateCreditUtilization, calculateDebtToIncomeRatio, calculateBlendedLoanRate, calculateFreelancerRate, calculateExtraPaymentPayoff, calculateLoanRefinance, validateVin, validateIsin, calculateLoanPrepaymentPenalty } from "@utilix-tech/sdk/units";
|
|
366
|
+
import { convertBytes, pxToAll, convert, formatValue, validateCardNumber, validateIban, calculateLoan, validateBarcode, calculateTax, calculateCompoundInterest, validateIsbn, calculateTipSplit, calculateSimpleInterest, calculateTimeValue, calculatePercentageChange, convertAprApy, calculateMarginMarkup, calculateDiscount, applySuccessiveDiscounts, calculateBreakEven, calculateVideoBitrate, calculateRuleOf72, calculateEmi, calculateRoi, compareUnitPrices, calculatePaybackPeriod, calculateCdMaturity, calculateDepreciationSchedule, calculateCashRounding, calculateMovingAverages, calculateGpa, calculateCreditUtilization, calculateDebtToIncomeRatio, calculateBlendedLoanRate, calculateFreelancerRate, calculateExtraPaymentPayoff, calculateLoanRefinance, validateVin, validateIsin, calculateLoanPrepaymentPenalty, calculateRealRateOfReturn } from "@utilix-tech/sdk/units";
|
|
360
367
|
|
|
361
368
|
// File sizes
|
|
362
369
|
convertBytes(1073741824, "GB"); // 1
|
|
@@ -530,6 +537,10 @@ calculateMortgagePoints(300000, 6.5, 360, 1, 0.25);
|
|
|
530
537
|
// Loan prepayment penalty: dollar cost of paying a loan off early
|
|
531
538
|
calculateLoanPrepaymentPenalty(10000, "percent-of-balance", { penaltyPercent: 2 });
|
|
532
539
|
// { payoffBalance: 10000, penaltyAmount: 200, effectivePenaltyPercent: 2, totalPayoffCost: 10200 }
|
|
540
|
+
|
|
541
|
+
// Real rate of return: pass any TWO of nominalRatePercent, inflationRatePercent, realRatePercent
|
|
542
|
+
calculateRealRateOfReturn({ nominalRatePercent: 5, inflationRatePercent: 2 });
|
|
543
|
+
// { nominalRatePercent: 5, inflationRatePercent: 2, realRatePercent: 2.9412, solvedFor: "realRatePercent", ... }
|
|
533
544
|
```
|
|
534
545
|
|
|
535
546
|
---
|
|
@@ -769,7 +780,7 @@ generateCspHeader({ "default-src": ["'self'"], "script-src": ["'self'", "cdn.exa
|
|
|
769
780
|
import { formatSql, minifySql, testRegex, formatHtml, formatGql,
|
|
770
781
|
detectDialect, splitStatements, lookupMime, parseGithubUrl,
|
|
771
782
|
detectRedos, analyzeRegexGroups, testGitignorePatterns, validateEditorConfig,
|
|
772
|
-
validateTsconfig, validatePackageExports } from "@utilix-tech/sdk/code";
|
|
783
|
+
validateTsconfig, validatePackageExports, parseConnectionString } from "@utilix-tech/sdk/code";
|
|
773
784
|
|
|
774
785
|
// SQL
|
|
775
786
|
formatSql("SELECT id,name FROM users WHERE active=1 ORDER BY name");
|
|
@@ -802,6 +813,10 @@ lookupMime("image/jpeg"); // { kind: "mime", matches: [{ extension: "jpg", ...
|
|
|
802
813
|
parseGithubUrl("https://github.com/facebook/react/pull/1234");
|
|
803
814
|
// { owner: "facebook", repo: "react", type: "pull", number: 1234 }
|
|
804
815
|
|
|
816
|
+
// Database connection string parsing
|
|
817
|
+
parseConnectionString("postgres://user:pass@localhost:5432/mydb?sslmode=require");
|
|
818
|
+
// { scheme: "postgres", user: "user", password: "pass", hosts: [{ host: "localhost", port: 5432 }], database: "mydb", params: { sslmode: "require" } }
|
|
819
|
+
|
|
805
820
|
// Regex ReDoS (catastrophic-backtracking) detection
|
|
806
821
|
detectRedos("(a+)+");
|
|
807
822
|
// { risk: "high", safe: false, findings: [{ type: "nested-quantifier", ... }] }
|
|
@@ -1019,14 +1034,14 @@ readMidiInfo(new Uint8Array(midiBytes));
|
|
|
1019
1034
|
| `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert, NDJSON record deduplicator, SRT/WebVTT subtitles, Markdown front matter parser, YAML anchor/alias resolver, CSV column type inferencer, Markdown table column aligner |
|
|
1020
1035
|
| `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, entropy estimator, fake data, CSP nonce generator |
|
|
1021
1036
|
| `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
|
|
1022
|
-
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN/VIN/ISIN validation, loan calculator, EMI calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator, savings goal calculator, ROI calculator, cash denomination/till calculator, payback period calculator, CD maturity calculator, debt-to-income ratio calculator, freelancer hourly rate calculator, debt snowball/avalanche payoff planner, tax-equivalent yield calculator, mortgage discount points break-even calculator, loan prepayment penalty calculator, data transfer time / required bandwidth estimator |
|
|
1037
|
+
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN/VIN/ISIN validation, loan calculator, EMI calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator, savings goal calculator, ROI calculator, cash denomination/till calculator, payback period calculator, CD maturity calculator, debt-to-income ratio calculator, freelancer hourly rate calculator, debt snowball/avalanche payoff planner, tax-equivalent yield calculator, mortgage discount points break-even calculator, loan prepayment penalty calculator, data transfer time / required bandwidth estimator, real rate of return (Fisher equation) calculator |
|
|
1023
1038
|
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing, User-Agent parsing, IPv6 address compress/expand, Permissions-Policy header builder, Client Hints header builder/parser, Content-Disposition header builder/parser, X-Content-Type-Options header builder/risk assessor, sitemap.xml validator, sitemap index splitter, Prefer header builder/parser (RFC 7240), Retry-After header builder/parser (RFC 9110), Priority header builder/parser (RFC 9218), WebSocket close code reference/lookup, Strict-Transport-Security (HSTS) header builder/parser, X-Robots-Tag header builder/parser, WebSocket frame opcode reference/lookup, robots meta tag builder/parser, Cookie header byte-size budget calculator |
|
|
1024
1039
|
| `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header, TOTP/HOTP code generator, webhook HMAC signature verifier |
|
|
1025
1040
|
| `@utilix-tech/sdk/code` | SQL format/minify, HTML format/minify, regex tester, GraphQL format, MIME type lookup, GitHub URL parsing, regex ReDoS detector, Conventional Commits linter, package.json exports field validator, package.json dependency range auditor, regex capture group/backreference visualizer, SVG sprite symbol extractor, ARIA role & attribute validator |
|
|
1026
1041
|
| `@utilix-tech/sdk/color` | Hex/RGB/HSL/HSV/CMYK convert, palette generation, contrast check |
|
|
1027
1042
|
| `@utilix-tech/sdk/css` | CSS gradient, box-shadow, border-radius, keyframe animation generators |
|
|
1028
1043
|
| `@utilix-tech/sdk/misc` | SVG optimize/sanitize, file size format, Unicode inspector |
|
|
1029
|
-
| `@utilix-tech/sdk/ai_agent` | Token estimate/trim, chunk text, extract URLs/JSON/keywords, sanitize HTML, flatten/merge JSON, dedupe lines, validate schema, PII/secret/injection detect, vector similarity, few-shot prompt formatter, tool-definition schema linter |
|
|
1044
|
+
| `@utilix-tech/sdk/ai_agent` | Token estimate/trim, chunk text, extract URLs/JSON/keywords, sanitize HTML, flatten/merge JSON, dedupe lines, validate schema, PII/secret/injection detect, vector similarity, few-shot prompt formatter, tool-definition schema linter, retry/backoff schedule calculator |
|
|
1030
1045
|
| `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes (PNG, JPEG, GIF, WebP, BMP); PDF metadata reading; PDF page dimension/orientation listing; WAV audio info; ID3 tags; ICO favicon inspection; FLAC metadata reading; MP4/WebM video info; GIF frame/loop inspection |
|
|
1031
1046
|
|
|
1032
1047
|
---
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* - prompt-injection : detectPromptInjection
|
|
10
10
|
* - json-repair : repairJson
|
|
11
11
|
* - few-shot-formatter : formatFewShotExamples
|
|
12
|
+
* - retry-backoff-calculator : calculateRetryBackoffSchedule
|
|
12
13
|
*/
|
|
13
14
|
interface ModelPricing {
|
|
14
15
|
model: string;
|
|
@@ -374,6 +375,40 @@ interface ToolSchemaLintResult {
|
|
|
374
375
|
declare function lintToolSchema(jsonText: string): ToolSchemaLintResult | {
|
|
375
376
|
error: string;
|
|
376
377
|
};
|
|
378
|
+
type RetryJitterMode = 'none' | 'full' | 'equal';
|
|
379
|
+
interface RetryBackoffInput {
|
|
380
|
+
baseDelayMs: number;
|
|
381
|
+
multiplier: number;
|
|
382
|
+
maxRetries: number;
|
|
383
|
+
maxDelayMs?: number | null;
|
|
384
|
+
jitter?: RetryJitterMode;
|
|
385
|
+
}
|
|
386
|
+
interface RetryBackoffAttempt {
|
|
387
|
+
attempt: number;
|
|
388
|
+
nominalDelayMs: number;
|
|
389
|
+
minDelayMs: number;
|
|
390
|
+
maxDelayMs: number;
|
|
391
|
+
}
|
|
392
|
+
interface RetryBackoffResult {
|
|
393
|
+
attempts: RetryBackoffAttempt[];
|
|
394
|
+
jitter: RetryJitterMode;
|
|
395
|
+
totalBestCaseMs: number;
|
|
396
|
+
totalWorstCaseMs: number;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Compute the full sequence of delays an exponential-backoff retry policy
|
|
400
|
+
* would actually produce: baseDelayMs * multiplier^(attempt-1), optionally
|
|
401
|
+
* capped at maxDelayMs, for each of maxRetries attempts. With jitter
|
|
402
|
+
* enabled, each attempt gets a [min, max] delay range instead of a single
|
|
403
|
+
* value ("full" jitter is uniform between 0 and the nominal delay; "equal"
|
|
404
|
+
* jitter is uniform between half the nominal delay and the full value),
|
|
405
|
+
* and the totals sum the worst case (always the nominal/max delay) against
|
|
406
|
+
* the best case (the minimum possible delay at every attempt). Pure
|
|
407
|
+
* arithmetic — it doesn't execute any retries or make any request.
|
|
408
|
+
*/
|
|
409
|
+
declare function calculateRetryBackoffSchedule(input: RetryBackoffInput): RetryBackoffResult | {
|
|
410
|
+
error: string;
|
|
411
|
+
};
|
|
377
412
|
|
|
378
413
|
type ai_agent_ChunkStrategy = ChunkStrategy;
|
|
379
414
|
type ai_agent_CompressHtmlResult = CompressHtmlResult;
|
|
@@ -407,6 +442,10 @@ type ai_agent_PiiFinding = PiiFinding;
|
|
|
407
442
|
type ai_agent_PiiType = PiiType;
|
|
408
443
|
type ai_agent_RankedChunk = RankedChunk;
|
|
409
444
|
type ai_agent_RelevanceResult = RelevanceResult;
|
|
445
|
+
type ai_agent_RetryBackoffAttempt = RetryBackoffAttempt;
|
|
446
|
+
type ai_agent_RetryBackoffInput = RetryBackoffInput;
|
|
447
|
+
type ai_agent_RetryBackoffResult = RetryBackoffResult;
|
|
448
|
+
type ai_agent_RetryJitterMode = RetryJitterMode;
|
|
410
449
|
type ai_agent_SanitizeResult = SanitizeResult;
|
|
411
450
|
type ai_agent_SecretDetectResult = SecretDetectResult;
|
|
412
451
|
type ai_agent_SecretFinding = SecretFinding;
|
|
@@ -424,6 +463,7 @@ type ai_agent_UrlMatch = UrlMatch;
|
|
|
424
463
|
type ai_agent_ValidationError = ValidationError;
|
|
425
464
|
type ai_agent_ValidationResult = ValidationResult;
|
|
426
465
|
type ai_agent_VectorSimilarityResult = VectorSimilarityResult;
|
|
466
|
+
declare const ai_agent_calculateRetryBackoffSchedule: typeof calculateRetryBackoffSchedule;
|
|
427
467
|
declare const ai_agent_chunkText: typeof chunkText;
|
|
428
468
|
declare const ai_agent_compressHtml: typeof compressHtml;
|
|
429
469
|
declare const ai_agent_compressJson: typeof compressJson;
|
|
@@ -456,7 +496,7 @@ declare const ai_agent_unflattenJson: typeof unflattenJson;
|
|
|
456
496
|
declare const ai_agent_validateJsonSchema: typeof validateJsonSchema;
|
|
457
497
|
declare const ai_agent_vectorSimilarity: typeof vectorSimilarity;
|
|
458
498
|
declare namespace ai_agent {
|
|
459
|
-
export { type ai_agent_ChunkStrategy as ChunkStrategy, type ai_agent_CompressHtmlResult as CompressHtmlResult, type ai_agent_CompressJsonResult as CompressJsonResult, type ai_agent_CompressMarkdownResult as CompressMarkdownResult, type ai_agent_CostEstimate as CostEstimate, type ai_agent_DedupeResult as DedupeResult, type ai_agent_DedupeStrategy as DedupeStrategy, type ai_agent_DiffEntry2 as DiffEntry2, type ai_agent_DiffOp2 as DiffOp2, type ai_agent_DiffResult2 as DiffResult2, type ai_agent_Entity2 as Entity2, type ai_agent_EntityType2 as EntityType2, type ai_agent_ExtractJsonResult as ExtractJsonResult, type ai_agent_ExtractKeywordsResult as ExtractKeywordsResult, type ai_agent_ExtractUrlsResult as ExtractUrlsResult, type ai_agent_FewShotExample as FewShotExample, type ai_agent_FewShotFormat as FewShotFormat, type ai_agent_FewShotFormatResult as FewShotFormatResult, type ai_agent_InjectionDetectResult as InjectionDetectResult, type ai_agent_InjectionFinding as InjectionFinding, type ai_agent_JsonBlock as JsonBlock, type ai_agent_JsonRepairResult as JsonRepairResult, type ai_agent_Keyword as Keyword, ai_agent_MODEL_PRICING as MODEL_PRICING, type ai_agent_MergeResult as MergeResult, type ai_agent_MergeStrategy as MergeStrategy, type ai_agent_ModelPricing as ModelPricing, type ai_agent_PiiDetectResult as PiiDetectResult, type ai_agent_PiiFinding as PiiFinding, type ai_agent_PiiType as PiiType, type ai_agent_RankedChunk as RankedChunk, type ai_agent_RelevanceResult as RelevanceResult, type ai_agent_SanitizeResult as SanitizeResult, type ai_agent_SecretDetectResult as SecretDetectResult, type ai_agent_SecretFinding as SecretFinding, type ai_agent_SecretType as SecretType, type ai_agent_SummaryResult as SummaryResult, type ai_agent_TableResult2 as TableResult2, type ai_agent_TextChunk as TextChunk, type ai_agent_TokenEstimate as TokenEstimate, type ai_agent_TokenEstimateResult as TokenEstimateResult, type ai_agent_ToolSchemaIssue as ToolSchemaIssue, type ai_agent_ToolSchemaLintResult as ToolSchemaLintResult, type ai_agent_TrimResult as TrimResult, type ai_agent_TrimStrategy as TrimStrategy, type ai_agent_UrlMatch as UrlMatch, type ai_agent_ValidationError as ValidationError, type ai_agent_ValidationResult as ValidationResult, type ai_agent_VectorSimilarityResult as VectorSimilarityResult, ai_agent_chunkText as chunkText, ai_agent_compressHtml as compressHtml, ai_agent_compressJson as compressJson, ai_agent_compressMarkdown as compressMarkdown, ai_agent_deduplicateLines as deduplicateLines, ai_agent_detectPii as detectPii, ai_agent_detectPromptInjection as detectPromptInjection, ai_agent_detectSecrets as detectSecrets, ai_agent_diffJson as diffJson, ai_agent_estimateCost as estimateCost, ai_agent_estimateTokens as estimateTokens, ai_agent_expandQuery as expandQuery, ai_agent_extractEntities as extractEntities, ai_agent_extractJson as extractJson, ai_agent_extractKeywords as extractKeywords, ai_agent_extractTables as extractTables, ai_agent_extractUrls as extractUrls, ai_agent_flattenJson as flattenJson, ai_agent_formatFewShotExamples as formatFewShotExamples, ai_agent_lintToolSchema as lintToolSchema, ai_agent_mergeJson as mergeJson, ai_agent_redactPii as redactPii, ai_agent_repairJson as repairJson, ai_agent_rerankChunks as rerankChunks, ai_agent_sanitizeHtml as sanitizeHtml, ai_agent_scoreRelevance as scoreRelevance, ai_agent_summarizeForLlm as summarizeForLlm, ai_agent_trimToTokens as trimToTokens, ai_agent_unflattenJson as unflattenJson, ai_agent_validateJsonSchema as validateJsonSchema, ai_agent_vectorSimilarity as vectorSimilarity };
|
|
499
|
+
export { type ai_agent_ChunkStrategy as ChunkStrategy, type ai_agent_CompressHtmlResult as CompressHtmlResult, type ai_agent_CompressJsonResult as CompressJsonResult, type ai_agent_CompressMarkdownResult as CompressMarkdownResult, type ai_agent_CostEstimate as CostEstimate, type ai_agent_DedupeResult as DedupeResult, type ai_agent_DedupeStrategy as DedupeStrategy, type ai_agent_DiffEntry2 as DiffEntry2, type ai_agent_DiffOp2 as DiffOp2, type ai_agent_DiffResult2 as DiffResult2, type ai_agent_Entity2 as Entity2, type ai_agent_EntityType2 as EntityType2, type ai_agent_ExtractJsonResult as ExtractJsonResult, type ai_agent_ExtractKeywordsResult as ExtractKeywordsResult, type ai_agent_ExtractUrlsResult as ExtractUrlsResult, type ai_agent_FewShotExample as FewShotExample, type ai_agent_FewShotFormat as FewShotFormat, type ai_agent_FewShotFormatResult as FewShotFormatResult, type ai_agent_InjectionDetectResult as InjectionDetectResult, type ai_agent_InjectionFinding as InjectionFinding, type ai_agent_JsonBlock as JsonBlock, type ai_agent_JsonRepairResult as JsonRepairResult, type ai_agent_Keyword as Keyword, ai_agent_MODEL_PRICING as MODEL_PRICING, type ai_agent_MergeResult as MergeResult, type ai_agent_MergeStrategy as MergeStrategy, type ai_agent_ModelPricing as ModelPricing, type ai_agent_PiiDetectResult as PiiDetectResult, type ai_agent_PiiFinding as PiiFinding, type ai_agent_PiiType as PiiType, type ai_agent_RankedChunk as RankedChunk, type ai_agent_RelevanceResult as RelevanceResult, type ai_agent_RetryBackoffAttempt as RetryBackoffAttempt, type ai_agent_RetryBackoffInput as RetryBackoffInput, type ai_agent_RetryBackoffResult as RetryBackoffResult, type ai_agent_RetryJitterMode as RetryJitterMode, type ai_agent_SanitizeResult as SanitizeResult, type ai_agent_SecretDetectResult as SecretDetectResult, type ai_agent_SecretFinding as SecretFinding, type ai_agent_SecretType as SecretType, type ai_agent_SummaryResult as SummaryResult, type ai_agent_TableResult2 as TableResult2, type ai_agent_TextChunk as TextChunk, type ai_agent_TokenEstimate as TokenEstimate, type ai_agent_TokenEstimateResult as TokenEstimateResult, type ai_agent_ToolSchemaIssue as ToolSchemaIssue, type ai_agent_ToolSchemaLintResult as ToolSchemaLintResult, type ai_agent_TrimResult as TrimResult, type ai_agent_TrimStrategy as TrimStrategy, type ai_agent_UrlMatch as UrlMatch, type ai_agent_ValidationError as ValidationError, type ai_agent_ValidationResult as ValidationResult, type ai_agent_VectorSimilarityResult as VectorSimilarityResult, ai_agent_calculateRetryBackoffSchedule as calculateRetryBackoffSchedule, ai_agent_chunkText as chunkText, ai_agent_compressHtml as compressHtml, ai_agent_compressJson as compressJson, ai_agent_compressMarkdown as compressMarkdown, ai_agent_deduplicateLines as deduplicateLines, ai_agent_detectPii as detectPii, ai_agent_detectPromptInjection as detectPromptInjection, ai_agent_detectSecrets as detectSecrets, ai_agent_diffJson as diffJson, ai_agent_estimateCost as estimateCost, ai_agent_estimateTokens as estimateTokens, ai_agent_expandQuery as expandQuery, ai_agent_extractEntities as extractEntities, ai_agent_extractJson as extractJson, ai_agent_extractKeywords as extractKeywords, ai_agent_extractTables as extractTables, ai_agent_extractUrls as extractUrls, ai_agent_flattenJson as flattenJson, ai_agent_formatFewShotExamples as formatFewShotExamples, ai_agent_lintToolSchema as lintToolSchema, ai_agent_mergeJson as mergeJson, ai_agent_redactPii as redactPii, ai_agent_repairJson as repairJson, ai_agent_rerankChunks as rerankChunks, ai_agent_sanitizeHtml as sanitizeHtml, ai_agent_scoreRelevance as scoreRelevance, ai_agent_summarizeForLlm as summarizeForLlm, ai_agent_trimToTokens as trimToTokens, ai_agent_unflattenJson as unflattenJson, ai_agent_validateJsonSchema as validateJsonSchema, ai_agent_vectorSimilarity as vectorSimilarity };
|
|
460
500
|
}
|
|
461
501
|
|
|
462
|
-
export {
|
|
502
|
+
export { type VectorSimilarityResult as $, type RetryJitterMode as A, type SecretDetectResult as B, type ChunkStrategy as C, type DedupeResult as D, type Entity2 as E, type FewShotExample as F, type SecretFinding as G, type SecretType as H, type InjectionDetectResult as I, type JsonBlock as J, type Keyword as K, type SummaryResult as L, MODEL_PRICING as M, type TextChunk as N, type TokenEstimate as O, type PiiDetectResult as P, type TokenEstimateResult as Q, type RankedChunk as R, type SanitizeResult as S, type TableResult2 as T, type ToolSchemaIssue as U, type ToolSchemaLintResult as V, type TrimResult as W, type TrimStrategy as X, type UrlMatch as Y, type ValidationError as Z, type ValidationResult as _, ai_agent as a, calculateRetryBackoffSchedule as a0, chunkText as a1, compressHtml as a2, compressJson as a3, compressMarkdown as a4, deduplicateLines as a5, detectPii as a6, detectPromptInjection as a7, detectSecrets as a8, diffJson as a9, estimateCost as aa, estimateTokens as ab, expandQuery as ac, extractEntities as ad, extractJson as ae, extractKeywords as af, extractTables as ag, extractUrls as ah, flattenJson as ai, formatFewShotExamples as aj, lintToolSchema as ak, mergeJson as al, redactPii as am, repairJson as an, rerankChunks as ao, sanitizeHtml as ap, scoreRelevance as aq, summarizeForLlm as ar, trimToTokens as as, unflattenJson as at, validateJsonSchema as au, vectorSimilarity as av, type CompressHtmlResult as b, type CompressJsonResult as c, type CompressMarkdownResult as d, type CostEstimate as e, type DedupeStrategy as f, type DiffEntry2 as g, type DiffOp2 as h, type DiffResult2 as i, type EntityType2 as j, type ExtractJsonResult as k, type ExtractKeywordsResult as l, type ExtractUrlsResult as m, type FewShotFormat as n, type FewShotFormatResult as o, type InjectionFinding as p, type JsonRepairResult as q, type MergeResult as r, type MergeStrategy as s, type ModelPricing as t, type PiiFinding as u, type PiiType as v, type RelevanceResult as w, type RetryBackoffAttempt as x, type RetryBackoffInput as y, type RetryBackoffResult as z };
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* - prompt-injection : detectPromptInjection
|
|
10
10
|
* - json-repair : repairJson
|
|
11
11
|
* - few-shot-formatter : formatFewShotExamples
|
|
12
|
+
* - retry-backoff-calculator : calculateRetryBackoffSchedule
|
|
12
13
|
*/
|
|
13
14
|
interface ModelPricing {
|
|
14
15
|
model: string;
|
|
@@ -374,6 +375,40 @@ interface ToolSchemaLintResult {
|
|
|
374
375
|
declare function lintToolSchema(jsonText: string): ToolSchemaLintResult | {
|
|
375
376
|
error: string;
|
|
376
377
|
};
|
|
378
|
+
type RetryJitterMode = 'none' | 'full' | 'equal';
|
|
379
|
+
interface RetryBackoffInput {
|
|
380
|
+
baseDelayMs: number;
|
|
381
|
+
multiplier: number;
|
|
382
|
+
maxRetries: number;
|
|
383
|
+
maxDelayMs?: number | null;
|
|
384
|
+
jitter?: RetryJitterMode;
|
|
385
|
+
}
|
|
386
|
+
interface RetryBackoffAttempt {
|
|
387
|
+
attempt: number;
|
|
388
|
+
nominalDelayMs: number;
|
|
389
|
+
minDelayMs: number;
|
|
390
|
+
maxDelayMs: number;
|
|
391
|
+
}
|
|
392
|
+
interface RetryBackoffResult {
|
|
393
|
+
attempts: RetryBackoffAttempt[];
|
|
394
|
+
jitter: RetryJitterMode;
|
|
395
|
+
totalBestCaseMs: number;
|
|
396
|
+
totalWorstCaseMs: number;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Compute the full sequence of delays an exponential-backoff retry policy
|
|
400
|
+
* would actually produce: baseDelayMs * multiplier^(attempt-1), optionally
|
|
401
|
+
* capped at maxDelayMs, for each of maxRetries attempts. With jitter
|
|
402
|
+
* enabled, each attempt gets a [min, max] delay range instead of a single
|
|
403
|
+
* value ("full" jitter is uniform between 0 and the nominal delay; "equal"
|
|
404
|
+
* jitter is uniform between half the nominal delay and the full value),
|
|
405
|
+
* and the totals sum the worst case (always the nominal/max delay) against
|
|
406
|
+
* the best case (the minimum possible delay at every attempt). Pure
|
|
407
|
+
* arithmetic — it doesn't execute any retries or make any request.
|
|
408
|
+
*/
|
|
409
|
+
declare function calculateRetryBackoffSchedule(input: RetryBackoffInput): RetryBackoffResult | {
|
|
410
|
+
error: string;
|
|
411
|
+
};
|
|
377
412
|
|
|
378
413
|
type ai_agent_ChunkStrategy = ChunkStrategy;
|
|
379
414
|
type ai_agent_CompressHtmlResult = CompressHtmlResult;
|
|
@@ -407,6 +442,10 @@ type ai_agent_PiiFinding = PiiFinding;
|
|
|
407
442
|
type ai_agent_PiiType = PiiType;
|
|
408
443
|
type ai_agent_RankedChunk = RankedChunk;
|
|
409
444
|
type ai_agent_RelevanceResult = RelevanceResult;
|
|
445
|
+
type ai_agent_RetryBackoffAttempt = RetryBackoffAttempt;
|
|
446
|
+
type ai_agent_RetryBackoffInput = RetryBackoffInput;
|
|
447
|
+
type ai_agent_RetryBackoffResult = RetryBackoffResult;
|
|
448
|
+
type ai_agent_RetryJitterMode = RetryJitterMode;
|
|
410
449
|
type ai_agent_SanitizeResult = SanitizeResult;
|
|
411
450
|
type ai_agent_SecretDetectResult = SecretDetectResult;
|
|
412
451
|
type ai_agent_SecretFinding = SecretFinding;
|
|
@@ -424,6 +463,7 @@ type ai_agent_UrlMatch = UrlMatch;
|
|
|
424
463
|
type ai_agent_ValidationError = ValidationError;
|
|
425
464
|
type ai_agent_ValidationResult = ValidationResult;
|
|
426
465
|
type ai_agent_VectorSimilarityResult = VectorSimilarityResult;
|
|
466
|
+
declare const ai_agent_calculateRetryBackoffSchedule: typeof calculateRetryBackoffSchedule;
|
|
427
467
|
declare const ai_agent_chunkText: typeof chunkText;
|
|
428
468
|
declare const ai_agent_compressHtml: typeof compressHtml;
|
|
429
469
|
declare const ai_agent_compressJson: typeof compressJson;
|
|
@@ -456,7 +496,7 @@ declare const ai_agent_unflattenJson: typeof unflattenJson;
|
|
|
456
496
|
declare const ai_agent_validateJsonSchema: typeof validateJsonSchema;
|
|
457
497
|
declare const ai_agent_vectorSimilarity: typeof vectorSimilarity;
|
|
458
498
|
declare namespace ai_agent {
|
|
459
|
-
export { type ai_agent_ChunkStrategy as ChunkStrategy, type ai_agent_CompressHtmlResult as CompressHtmlResult, type ai_agent_CompressJsonResult as CompressJsonResult, type ai_agent_CompressMarkdownResult as CompressMarkdownResult, type ai_agent_CostEstimate as CostEstimate, type ai_agent_DedupeResult as DedupeResult, type ai_agent_DedupeStrategy as DedupeStrategy, type ai_agent_DiffEntry2 as DiffEntry2, type ai_agent_DiffOp2 as DiffOp2, type ai_agent_DiffResult2 as DiffResult2, type ai_agent_Entity2 as Entity2, type ai_agent_EntityType2 as EntityType2, type ai_agent_ExtractJsonResult as ExtractJsonResult, type ai_agent_ExtractKeywordsResult as ExtractKeywordsResult, type ai_agent_ExtractUrlsResult as ExtractUrlsResult, type ai_agent_FewShotExample as FewShotExample, type ai_agent_FewShotFormat as FewShotFormat, type ai_agent_FewShotFormatResult as FewShotFormatResult, type ai_agent_InjectionDetectResult as InjectionDetectResult, type ai_agent_InjectionFinding as InjectionFinding, type ai_agent_JsonBlock as JsonBlock, type ai_agent_JsonRepairResult as JsonRepairResult, type ai_agent_Keyword as Keyword, ai_agent_MODEL_PRICING as MODEL_PRICING, type ai_agent_MergeResult as MergeResult, type ai_agent_MergeStrategy as MergeStrategy, type ai_agent_ModelPricing as ModelPricing, type ai_agent_PiiDetectResult as PiiDetectResult, type ai_agent_PiiFinding as PiiFinding, type ai_agent_PiiType as PiiType, type ai_agent_RankedChunk as RankedChunk, type ai_agent_RelevanceResult as RelevanceResult, type ai_agent_SanitizeResult as SanitizeResult, type ai_agent_SecretDetectResult as SecretDetectResult, type ai_agent_SecretFinding as SecretFinding, type ai_agent_SecretType as SecretType, type ai_agent_SummaryResult as SummaryResult, type ai_agent_TableResult2 as TableResult2, type ai_agent_TextChunk as TextChunk, type ai_agent_TokenEstimate as TokenEstimate, type ai_agent_TokenEstimateResult as TokenEstimateResult, type ai_agent_ToolSchemaIssue as ToolSchemaIssue, type ai_agent_ToolSchemaLintResult as ToolSchemaLintResult, type ai_agent_TrimResult as TrimResult, type ai_agent_TrimStrategy as TrimStrategy, type ai_agent_UrlMatch as UrlMatch, type ai_agent_ValidationError as ValidationError, type ai_agent_ValidationResult as ValidationResult, type ai_agent_VectorSimilarityResult as VectorSimilarityResult, ai_agent_chunkText as chunkText, ai_agent_compressHtml as compressHtml, ai_agent_compressJson as compressJson, ai_agent_compressMarkdown as compressMarkdown, ai_agent_deduplicateLines as deduplicateLines, ai_agent_detectPii as detectPii, ai_agent_detectPromptInjection as detectPromptInjection, ai_agent_detectSecrets as detectSecrets, ai_agent_diffJson as diffJson, ai_agent_estimateCost as estimateCost, ai_agent_estimateTokens as estimateTokens, ai_agent_expandQuery as expandQuery, ai_agent_extractEntities as extractEntities, ai_agent_extractJson as extractJson, ai_agent_extractKeywords as extractKeywords, ai_agent_extractTables as extractTables, ai_agent_extractUrls as extractUrls, ai_agent_flattenJson as flattenJson, ai_agent_formatFewShotExamples as formatFewShotExamples, ai_agent_lintToolSchema as lintToolSchema, ai_agent_mergeJson as mergeJson, ai_agent_redactPii as redactPii, ai_agent_repairJson as repairJson, ai_agent_rerankChunks as rerankChunks, ai_agent_sanitizeHtml as sanitizeHtml, ai_agent_scoreRelevance as scoreRelevance, ai_agent_summarizeForLlm as summarizeForLlm, ai_agent_trimToTokens as trimToTokens, ai_agent_unflattenJson as unflattenJson, ai_agent_validateJsonSchema as validateJsonSchema, ai_agent_vectorSimilarity as vectorSimilarity };
|
|
499
|
+
export { type ai_agent_ChunkStrategy as ChunkStrategy, type ai_agent_CompressHtmlResult as CompressHtmlResult, type ai_agent_CompressJsonResult as CompressJsonResult, type ai_agent_CompressMarkdownResult as CompressMarkdownResult, type ai_agent_CostEstimate as CostEstimate, type ai_agent_DedupeResult as DedupeResult, type ai_agent_DedupeStrategy as DedupeStrategy, type ai_agent_DiffEntry2 as DiffEntry2, type ai_agent_DiffOp2 as DiffOp2, type ai_agent_DiffResult2 as DiffResult2, type ai_agent_Entity2 as Entity2, type ai_agent_EntityType2 as EntityType2, type ai_agent_ExtractJsonResult as ExtractJsonResult, type ai_agent_ExtractKeywordsResult as ExtractKeywordsResult, type ai_agent_ExtractUrlsResult as ExtractUrlsResult, type ai_agent_FewShotExample as FewShotExample, type ai_agent_FewShotFormat as FewShotFormat, type ai_agent_FewShotFormatResult as FewShotFormatResult, type ai_agent_InjectionDetectResult as InjectionDetectResult, type ai_agent_InjectionFinding as InjectionFinding, type ai_agent_JsonBlock as JsonBlock, type ai_agent_JsonRepairResult as JsonRepairResult, type ai_agent_Keyword as Keyword, ai_agent_MODEL_PRICING as MODEL_PRICING, type ai_agent_MergeResult as MergeResult, type ai_agent_MergeStrategy as MergeStrategy, type ai_agent_ModelPricing as ModelPricing, type ai_agent_PiiDetectResult as PiiDetectResult, type ai_agent_PiiFinding as PiiFinding, type ai_agent_PiiType as PiiType, type ai_agent_RankedChunk as RankedChunk, type ai_agent_RelevanceResult as RelevanceResult, type ai_agent_RetryBackoffAttempt as RetryBackoffAttempt, type ai_agent_RetryBackoffInput as RetryBackoffInput, type ai_agent_RetryBackoffResult as RetryBackoffResult, type ai_agent_RetryJitterMode as RetryJitterMode, type ai_agent_SanitizeResult as SanitizeResult, type ai_agent_SecretDetectResult as SecretDetectResult, type ai_agent_SecretFinding as SecretFinding, type ai_agent_SecretType as SecretType, type ai_agent_SummaryResult as SummaryResult, type ai_agent_TableResult2 as TableResult2, type ai_agent_TextChunk as TextChunk, type ai_agent_TokenEstimate as TokenEstimate, type ai_agent_TokenEstimateResult as TokenEstimateResult, type ai_agent_ToolSchemaIssue as ToolSchemaIssue, type ai_agent_ToolSchemaLintResult as ToolSchemaLintResult, type ai_agent_TrimResult as TrimResult, type ai_agent_TrimStrategy as TrimStrategy, type ai_agent_UrlMatch as UrlMatch, type ai_agent_ValidationError as ValidationError, type ai_agent_ValidationResult as ValidationResult, type ai_agent_VectorSimilarityResult as VectorSimilarityResult, ai_agent_calculateRetryBackoffSchedule as calculateRetryBackoffSchedule, ai_agent_chunkText as chunkText, ai_agent_compressHtml as compressHtml, ai_agent_compressJson as compressJson, ai_agent_compressMarkdown as compressMarkdown, ai_agent_deduplicateLines as deduplicateLines, ai_agent_detectPii as detectPii, ai_agent_detectPromptInjection as detectPromptInjection, ai_agent_detectSecrets as detectSecrets, ai_agent_diffJson as diffJson, ai_agent_estimateCost as estimateCost, ai_agent_estimateTokens as estimateTokens, ai_agent_expandQuery as expandQuery, ai_agent_extractEntities as extractEntities, ai_agent_extractJson as extractJson, ai_agent_extractKeywords as extractKeywords, ai_agent_extractTables as extractTables, ai_agent_extractUrls as extractUrls, ai_agent_flattenJson as flattenJson, ai_agent_formatFewShotExamples as formatFewShotExamples, ai_agent_lintToolSchema as lintToolSchema, ai_agent_mergeJson as mergeJson, ai_agent_redactPii as redactPii, ai_agent_repairJson as repairJson, ai_agent_rerankChunks as rerankChunks, ai_agent_sanitizeHtml as sanitizeHtml, ai_agent_scoreRelevance as scoreRelevance, ai_agent_summarizeForLlm as summarizeForLlm, ai_agent_trimToTokens as trimToTokens, ai_agent_unflattenJson as unflattenJson, ai_agent_validateJsonSchema as validateJsonSchema, ai_agent_vectorSimilarity as vectorSimilarity };
|
|
460
500
|
}
|
|
461
501
|
|
|
462
|
-
export {
|
|
502
|
+
export { type VectorSimilarityResult as $, type RetryJitterMode as A, type SecretDetectResult as B, type ChunkStrategy as C, type DedupeResult as D, type Entity2 as E, type FewShotExample as F, type SecretFinding as G, type SecretType as H, type InjectionDetectResult as I, type JsonBlock as J, type Keyword as K, type SummaryResult as L, MODEL_PRICING as M, type TextChunk as N, type TokenEstimate as O, type PiiDetectResult as P, type TokenEstimateResult as Q, type RankedChunk as R, type SanitizeResult as S, type TableResult2 as T, type ToolSchemaIssue as U, type ToolSchemaLintResult as V, type TrimResult as W, type TrimStrategy as X, type UrlMatch as Y, type ValidationError as Z, type ValidationResult as _, ai_agent as a, calculateRetryBackoffSchedule as a0, chunkText as a1, compressHtml as a2, compressJson as a3, compressMarkdown as a4, deduplicateLines as a5, detectPii as a6, detectPromptInjection as a7, detectSecrets as a8, diffJson as a9, estimateCost as aa, estimateTokens as ab, expandQuery as ac, extractEntities as ad, extractJson as ae, extractKeywords as af, extractTables as ag, extractUrls as ah, flattenJson as ai, formatFewShotExamples as aj, lintToolSchema as ak, mergeJson as al, redactPii as am, repairJson as an, rerankChunks as ao, sanitizeHtml as ap, scoreRelevance as aq, summarizeForLlm as ar, trimToTokens as as, unflattenJson as at, validateJsonSchema as au, vectorSimilarity as av, type CompressHtmlResult as b, type CompressJsonResult as c, type CompressMarkdownResult as d, type CostEstimate as e, type DedupeStrategy as f, type DiffEntry2 as g, type DiffOp2 as h, type DiffResult2 as i, type EntityType2 as j, type ExtractJsonResult as k, type ExtractKeywordsResult as l, type ExtractUrlsResult as m, type FewShotFormat as n, type FewShotFormatResult as o, type InjectionFinding as p, type JsonRepairResult as q, type MergeResult as r, type MergeStrategy as s, type ModelPricing as t, type PiiFinding as u, type PiiType as v, type RelevanceResult as w, type RetryBackoffAttempt as x, type RetryBackoffInput as y, type RetryBackoffResult as z };
|
|
@@ -4,6 +4,7 @@ import { __export } from './chunk-MLKGABMK.js';
|
|
|
4
4
|
var ai_agent_exports = {};
|
|
5
5
|
__export(ai_agent_exports, {
|
|
6
6
|
MODEL_PRICING: () => MODEL_PRICING,
|
|
7
|
+
calculateRetryBackoffSchedule: () => calculateRetryBackoffSchedule,
|
|
7
8
|
chunkText: () => chunkText,
|
|
8
9
|
compressHtml: () => compressHtml,
|
|
9
10
|
compressJson: () => compressJson,
|
|
@@ -1116,5 +1117,61 @@ function lintToolSchema(jsonText) {
|
|
|
1116
1117
|
const valid = !issues.some((i) => i.severity === "error");
|
|
1117
1118
|
return { toolCount: normalized.length, issues, valid };
|
|
1118
1119
|
}
|
|
1120
|
+
function calculateRetryBackoffSchedule(input) {
|
|
1121
|
+
const { baseDelayMs, multiplier, maxRetries, maxDelayMs, jitter = "none" } = input;
|
|
1122
|
+
if (!Number.isFinite(baseDelayMs) || baseDelayMs <= 0) {
|
|
1123
|
+
return { error: "baseDelayMs must be a finite number greater than zero" };
|
|
1124
|
+
}
|
|
1125
|
+
if (!Number.isFinite(multiplier) || multiplier < 1) {
|
|
1126
|
+
return { error: "multiplier must be a finite number of at least 1" };
|
|
1127
|
+
}
|
|
1128
|
+
if (!Number.isInteger(maxRetries) || maxRetries < 1 || maxRetries > 50) {
|
|
1129
|
+
return { error: "maxRetries must be a whole number between 1 and 50" };
|
|
1130
|
+
}
|
|
1131
|
+
if (maxDelayMs !== void 0 && maxDelayMs !== null) {
|
|
1132
|
+
if (!Number.isFinite(maxDelayMs) || maxDelayMs <= 0) {
|
|
1133
|
+
return { error: "maxDelayMs must be a finite number greater than zero when provided" };
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
if (jitter !== "none" && jitter !== "full" && jitter !== "equal") {
|
|
1137
|
+
return { error: "jitter must be one of 'none', 'full', or 'equal'" };
|
|
1138
|
+
}
|
|
1139
|
+
const round0 = (n) => Math.round(n);
|
|
1140
|
+
const attempts = [];
|
|
1141
|
+
let totalBestCaseMs = 0;
|
|
1142
|
+
let totalWorstCaseMs = 0;
|
|
1143
|
+
for (let i = 1; i <= maxRetries; i++) {
|
|
1144
|
+
let nominal = baseDelayMs * Math.pow(multiplier, i - 1);
|
|
1145
|
+
if (maxDelayMs !== void 0 && maxDelayMs !== null) {
|
|
1146
|
+
nominal = Math.min(nominal, maxDelayMs);
|
|
1147
|
+
}
|
|
1148
|
+
let minDelay;
|
|
1149
|
+
let maxDelay;
|
|
1150
|
+
if (jitter === "full") {
|
|
1151
|
+
minDelay = 0;
|
|
1152
|
+
maxDelay = nominal;
|
|
1153
|
+
} else if (jitter === "equal") {
|
|
1154
|
+
minDelay = nominal / 2;
|
|
1155
|
+
maxDelay = nominal;
|
|
1156
|
+
} else {
|
|
1157
|
+
minDelay = nominal;
|
|
1158
|
+
maxDelay = nominal;
|
|
1159
|
+
}
|
|
1160
|
+
attempts.push({
|
|
1161
|
+
attempt: i,
|
|
1162
|
+
nominalDelayMs: round0(nominal),
|
|
1163
|
+
minDelayMs: round0(minDelay),
|
|
1164
|
+
maxDelayMs: round0(maxDelay)
|
|
1165
|
+
});
|
|
1166
|
+
totalBestCaseMs += minDelay;
|
|
1167
|
+
totalWorstCaseMs += maxDelay;
|
|
1168
|
+
}
|
|
1169
|
+
return {
|
|
1170
|
+
attempts,
|
|
1171
|
+
jitter,
|
|
1172
|
+
totalBestCaseMs: round0(totalBestCaseMs),
|
|
1173
|
+
totalWorstCaseMs: round0(totalWorstCaseMs)
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1119
1176
|
|
|
1120
|
-
export { MODEL_PRICING, ai_agent_exports, chunkText, compressHtml, compressJson, compressMarkdown, deduplicateLines, detectPii, detectPromptInjection, detectSecrets, diffJson, estimateCost, estimateTokens, expandQuery, extractEntities, extractJson, extractKeywords, extractTables, extractUrls, flattenJson, formatFewShotExamples, lintToolSchema, mergeJson, redactPii, repairJson, rerankChunks, sanitizeHtml, scoreRelevance, summarizeForLlm, trimToTokens, unflattenJson, validateJsonSchema, vectorSimilarity };
|
|
1177
|
+
export { MODEL_PRICING, ai_agent_exports, calculateRetryBackoffSchedule, chunkText, compressHtml, compressJson, compressMarkdown, deduplicateLines, detectPii, detectPromptInjection, detectSecrets, diffJson, estimateCost, estimateTokens, expandQuery, extractEntities, extractJson, extractKeywords, extractTables, extractUrls, flattenJson, formatFewShotExamples, lintToolSchema, mergeJson, redactPii, repairJson, rerankChunks, sanitizeHtml, scoreRelevance, summarizeForLlm, trimToTokens, unflattenJson, validateJsonSchema, vectorSimilarity };
|
|
@@ -44,6 +44,7 @@ __export(units_exports, {
|
|
|
44
44
|
calculateMovingAverages: () => calculateMovingAverages,
|
|
45
45
|
calculatePaybackPeriod: () => calculatePaybackPeriod,
|
|
46
46
|
calculatePercentageChange: () => calculatePercentageChange,
|
|
47
|
+
calculateRealRateOfReturn: () => calculateRealRateOfReturn,
|
|
47
48
|
calculateRequiredBandwidth: () => calculateRequiredBandwidth,
|
|
48
49
|
calculateRoi: () => calculateRoi,
|
|
49
50
|
calculateRuleOf72: () => calculateRuleOf72,
|
|
@@ -2762,5 +2763,49 @@ function calculateRequiredBandwidth(fileSize, fileSizeUnit, targetSeconds) {
|
|
|
2762
2763
|
requiredMBps: requiredBitsPerSecond / 8 / 1e6
|
|
2763
2764
|
};
|
|
2764
2765
|
}
|
|
2766
|
+
var _REAL_RATE_FIELDS = ["nominalRatePercent", "inflationRatePercent", "realRatePercent"];
|
|
2767
|
+
function calculateRealRateOfReturn(input) {
|
|
2768
|
+
const provided = (v) => typeof v === "number" && Number.isFinite(v);
|
|
2769
|
+
const given = _REAL_RATE_FIELDS.filter((f) => provided(input[f]));
|
|
2770
|
+
if (given.length !== 2) {
|
|
2771
|
+
return { error: `Provide exactly two of nominalRatePercent, inflationRatePercent, realRatePercent (got ${given.length})` };
|
|
2772
|
+
}
|
|
2773
|
+
for (const f of given) {
|
|
2774
|
+
const v = input[f];
|
|
2775
|
+
if (v <= -100) return { error: `${f} must be greater than -100` };
|
|
2776
|
+
}
|
|
2777
|
+
const has = (f) => given.includes(f);
|
|
2778
|
+
const nominal0 = input.nominalRatePercent;
|
|
2779
|
+
const inflation0 = input.inflationRatePercent;
|
|
2780
|
+
const real0 = input.realRatePercent;
|
|
2781
|
+
let nominalRatePercent;
|
|
2782
|
+
let inflationRatePercent;
|
|
2783
|
+
let realRatePercent;
|
|
2784
|
+
let solvedFor;
|
|
2785
|
+
if (has("nominalRatePercent") && has("inflationRatePercent")) {
|
|
2786
|
+
nominalRatePercent = nominal0;
|
|
2787
|
+
inflationRatePercent = inflation0;
|
|
2788
|
+
realRatePercent = ((1 + nominal0 / 100) / (1 + inflation0 / 100) - 1) * 100;
|
|
2789
|
+
solvedFor = "realRatePercent";
|
|
2790
|
+
} else if (has("realRatePercent") && has("inflationRatePercent")) {
|
|
2791
|
+
realRatePercent = real0;
|
|
2792
|
+
inflationRatePercent = inflation0;
|
|
2793
|
+
nominalRatePercent = ((1 + real0 / 100) * (1 + inflation0 / 100) - 1) * 100;
|
|
2794
|
+
solvedFor = "nominalRatePercent";
|
|
2795
|
+
} else {
|
|
2796
|
+
nominalRatePercent = nominal0;
|
|
2797
|
+
realRatePercent = real0;
|
|
2798
|
+
inflationRatePercent = ((1 + nominal0 / 100) / (1 + real0 / 100) - 1) * 100;
|
|
2799
|
+
solvedFor = "inflationRatePercent";
|
|
2800
|
+
}
|
|
2801
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
2802
|
+
return {
|
|
2803
|
+
nominalRatePercent: round4(nominalRatePercent),
|
|
2804
|
+
inflationRatePercent: round4(inflationRatePercent),
|
|
2805
|
+
realRatePercent: round4(realRatePercent),
|
|
2806
|
+
given,
|
|
2807
|
+
solvedFor
|
|
2808
|
+
};
|
|
2809
|
+
}
|
|
2765
2810
|
|
|
2766
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, GPA_GRADE_POINTS, USD_DENOMINATIONS, applySuccessiveDiscounts, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateBlendedLoanRate, calculateBreakEven, calculateCashBreakdown, calculateCashRounding, calculateCdMaturity, calculateChange, calculateCompoundInterest, calculateCreditUtilization, calculateDebtToIncomeRatio, calculateDepreciationSchedule, calculateDiscount, calculateEmi, calculateExtraPaymentPayoff, calculateFreelancerRate, calculateGpa, calculateLoan, calculateLoanPrepaymentPenalty, calculateLoanRefinance, calculateMarginMarkup, calculateMortgagePoints, calculateMovingAverages, calculatePaybackPeriod, calculatePercentageChange, calculateRequiredBandwidth, calculateRoi, calculateRuleOf72, calculateSavingsGoal, calculateSimpleInterest, calculateTax, calculateTaxEquivalentYield, calculateTimeValue, calculateTipSplit, calculateTransferTime, calculateVideoBitrate, compareSemver, compareUnitPrices, convert, convertAprApy, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, marginToMarkup, markupToMargin, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, planDebtPayoff, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, validateIsin, validateVin, viewportToPx };
|
|
2811
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, GPA_GRADE_POINTS, USD_DENOMINATIONS, applySuccessiveDiscounts, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateBlendedLoanRate, calculateBreakEven, calculateCashBreakdown, calculateCashRounding, calculateCdMaturity, calculateChange, calculateCompoundInterest, calculateCreditUtilization, calculateDebtToIncomeRatio, calculateDepreciationSchedule, calculateDiscount, calculateEmi, calculateExtraPaymentPayoff, calculateFreelancerRate, calculateGpa, calculateLoan, calculateLoanPrepaymentPenalty, calculateLoanRefinance, calculateMarginMarkup, calculateMortgagePoints, calculateMovingAverages, calculatePaybackPeriod, calculatePercentageChange, calculateRealRateOfReturn, calculateRequiredBandwidth, calculateRoi, calculateRuleOf72, calculateSavingsGoal, calculateSimpleInterest, calculateTax, calculateTaxEquivalentYield, calculateTimeValue, calculateTipSplit, calculateTransferTime, calculateVideoBitrate, compareSemver, compareUnitPrices, convert, convertAprApy, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, marginToMarkup, markupToMargin, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, planDebtPayoff, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, validateIsin, validateVin, viewportToPx };
|
|
@@ -44,6 +44,7 @@ __export(code_exports, {
|
|
|
44
44
|
minifySql: () => minifySql,
|
|
45
45
|
normalizeRef: () => normalizeRef,
|
|
46
46
|
parseCommitTrailers: () => parseCommitTrailers,
|
|
47
|
+
parseConnectionString: () => parseConnectionString,
|
|
47
48
|
parseDockerImage: () => parseDockerImage,
|
|
48
49
|
parseEnv: () => parseEnv,
|
|
49
50
|
parseGitCommand: () => parseGitCommand,
|
|
@@ -3876,5 +3877,52 @@ function validateAria(html) {
|
|
|
3876
3877
|
valid: issues.every((i) => i.severity !== "error")
|
|
3877
3878
|
};
|
|
3878
3879
|
}
|
|
3880
|
+
var CONNECTION_STRING_RE = /^([a-zA-Z][a-zA-Z0-9+.-]*):\/\/(?:([^@/?#]*)@)?([^/?#]*)(?:\/([^?#]*))?(?:\?([^#]*))?$/;
|
|
3881
|
+
function _parseConnectionHost(segment) {
|
|
3882
|
+
const ipv6Match = segment.match(/^\[([^\]]+)\](?::(\d+))?$/);
|
|
3883
|
+
if (ipv6Match) {
|
|
3884
|
+
return { host: ipv6Match[1], port: ipv6Match[2] ? parseInt(ipv6Match[2], 10) : null };
|
|
3885
|
+
}
|
|
3886
|
+
const lastColon = segment.lastIndexOf(":");
|
|
3887
|
+
if (lastColon === -1) return { host: segment, port: null };
|
|
3888
|
+
const portPart = segment.slice(lastColon + 1);
|
|
3889
|
+
if (!/^\d+$/.test(portPart)) return { host: segment, port: null };
|
|
3890
|
+
return { host: segment.slice(0, lastColon), port: parseInt(portPart, 10) };
|
|
3891
|
+
}
|
|
3892
|
+
function parseConnectionString(input) {
|
|
3893
|
+
if (!input || typeof input !== "string" || !input.trim()) {
|
|
3894
|
+
return { error: "Connection string is empty" };
|
|
3895
|
+
}
|
|
3896
|
+
const trimmed = input.trim();
|
|
3897
|
+
const match = trimmed.match(CONNECTION_STRING_RE);
|
|
3898
|
+
if (!match) {
|
|
3899
|
+
return { error: "Not a valid scheme://[user[:password]@]host[,host2][/database][?params] connection string" };
|
|
3900
|
+
}
|
|
3901
|
+
const [, scheme, userinfo, hostPart, databasePart, queryPart] = match;
|
|
3902
|
+
let user = null;
|
|
3903
|
+
let password = null;
|
|
3904
|
+
if (userinfo) {
|
|
3905
|
+
const sepIndex = userinfo.indexOf(":");
|
|
3906
|
+
if (sepIndex === -1) {
|
|
3907
|
+
user = decodeURIComponent(userinfo);
|
|
3908
|
+
} else {
|
|
3909
|
+
user = decodeURIComponent(userinfo.slice(0, sepIndex));
|
|
3910
|
+
password = decodeURIComponent(userinfo.slice(sepIndex + 1));
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
const hosts = hostPart ? hostPart.split(",").filter(Boolean).map(_parseConnectionHost) : [];
|
|
3914
|
+
const database = databasePart ? decodeURIComponent(databasePart) : null;
|
|
3915
|
+
const params = {};
|
|
3916
|
+
if (queryPart) {
|
|
3917
|
+
for (const pair of queryPart.split("&")) {
|
|
3918
|
+
if (!pair) continue;
|
|
3919
|
+
const eqIndex = pair.indexOf("=");
|
|
3920
|
+
const key = eqIndex === -1 ? pair : pair.slice(0, eqIndex);
|
|
3921
|
+
const value = eqIndex === -1 ? "" : pair.slice(eqIndex + 1);
|
|
3922
|
+
params[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
return { scheme, user, password, hosts, database, params };
|
|
3926
|
+
}
|
|
3879
3927
|
|
|
3880
|
-
export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, analyzeRegexGroups, auditDependencyRanges, buildDockerPull, buildDockerRun, buildGitCommand, code_exports, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, extractMarkdownFootnotes, extractSvgSpriteSymbols, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseCommitTrailers, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testGitignorePatterns, testPattern, testRegex, validateAria, validateEditorConfig, validateEnvKey, validatePackageExports, validateTsconfig };
|
|
3928
|
+
export { ALL_FLAGS, CHEATSHEET, DEFAULT_COMMIT_TYPES, MIME_TABLE, OPERATIONS, SQL_DEFAULT_OPTIONS, analyzeRegexGroups, auditDependencyRanges, buildDockerPull, buildDockerRun, buildGitCommand, code_exports, collapseHtmlWhitespace, collapseJsWhitespace, countProperties, countRules, detectDialect, detectOperationType, detectRedos, envToExport, envToJson, extractMarkdownFootnotes, extractSvgSpriteSymbols, formatCss, formatGql, formatHtml, formatSql, getEndpointsByTag, getHtmlStats, getJsStats, getMethodColor, isValidTag, lintConventionalCommit, lookupMime, minifyCss, minifyGql, minifyHtml, minifyJs, minifySql, normalizeRef, parseCommitTrailers, parseConnectionString, parseDockerImage, parseEnv, parseGitCommand, parseGithubUrl, parseSpec, removeConsoleCalls, removeEmptyAttributes, removeHtmlComments, removeJsComments, removeRedundantAttributes, searchCheatsheet, searchEndpoints, splitStatements, testGitignorePatterns, testPattern, testRegex, validateAria, validateEditorConfig, validateEnvKey, validatePackageExports, validateTsconfig };
|