@utilix-tech/sdk 0.30.0 → 0.32.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +21 -9
  3. package/dist/{ai_agent-B-c59NXD.d.cts → ai_agent-C1zudGgT.d.cts} +24 -2
  4. package/dist/{ai_agent-B-c59NXD.d.ts → ai_agent-C1zudGgT.d.ts} +24 -2
  5. package/dist/{chunk-66QHV5KW.js → chunk-6FIB72KX.js} +66 -1
  6. package/dist/{chunk-I63BCOAG.js → chunk-GDIZWDBY.js} +57 -1
  7. package/dist/{chunk-AFEZ6N4A.js → chunk-H2USEUHD.js} +67 -1
  8. package/dist/{chunk-265NPGKH.js → chunk-W3J7GZVQ.js} +25 -1
  9. package/dist/{data-XRb0D7Zn.d.cts → data-C4lCByXw.d.cts} +24 -2
  10. package/dist/{data-XRb0D7Zn.d.ts → data-C4lCByXw.d.ts} +24 -2
  11. package/dist/index.cjs +211 -0
  12. package/dist/index.d.cts +4 -4
  13. package/dist/index.d.ts +4 -4
  14. package/dist/index.js +4 -4
  15. package/dist/{text-D1fySkCB.d.cts → text-CA-zuD0C.d.cts} +34 -2
  16. package/dist/{text-D1fySkCB.d.ts → text-CA-zuD0C.d.ts} +34 -2
  17. package/dist/tools/ai_agent.cjs +24 -0
  18. package/dist/tools/ai_agent.d.cts +1 -1
  19. package/dist/tools/ai_agent.d.ts +1 -1
  20. package/dist/tools/ai_agent.js +1 -1
  21. package/dist/tools/data.cjs +65 -0
  22. package/dist/tools/data.d.cts +1 -1
  23. package/dist/tools/data.d.ts +1 -1
  24. package/dist/tools/data.js +1 -1
  25. package/dist/tools/text.cjs +66 -0
  26. package/dist/tools/text.d.cts +1 -1
  27. package/dist/tools/text.d.ts +1 -1
  28. package/dist/tools/text.js +1 -1
  29. package/dist/tools/units.cjs +56 -0
  30. package/dist/tools/units.d.cts +1 -1
  31. package/dist/tools/units.d.ts +1 -1
  32. package/dist/tools/units.js +1 -1
  33. package/dist/{units-COt5uI20.d.ts → units-DQYLZd1n.d.cts} +33 -2
  34. package/dist/{units-COt5uI20.d.cts → units-DQYLZd1n.d.ts} +33 -2
  35. package/package.json +1 -1
@@ -13,6 +13,7 @@
13
13
  * - env-diff-checker: diffEnvExample
14
14
  * - ndjson-formatter: validateNdjson, minifyNdjson, formatNdjson, ndjsonToJsonArray, jsonArrayToNdjson
15
15
  * - subtitle-converter: parseSubtitleTimestamp, formatSubtitleTimestamp, detectSubtitleFormat, parseSubtitles, serializeSubtitles, convertSubtitles, shiftSubtitles
16
+ * - markdown-front-matter-parser: parseFrontMatter
16
17
  */
17
18
  interface ValidationResult {
18
19
  valid: boolean;
@@ -272,6 +273,24 @@ declare function convertSubtitles(input: string, target: SubtitleFormat, sourceF
272
273
  declare function shiftSubtitles(input: string, offsetSeconds: number, target?: SubtitleFormat): ConvertedSubtitles | {
273
274
  error: string;
274
275
  };
276
+ interface FrontMatterResult {
277
+ frontMatter: Record<string, unknown>;
278
+ body: string;
279
+ hasFrontMatter: boolean;
280
+ raw: string;
281
+ }
282
+ interface FrontMatterError {
283
+ error: string;
284
+ }
285
+ /**
286
+ * Split a Markdown document into its YAML front matter (delimited by --- lines
287
+ * at the top) and body content. Parses simple scalar values (strings, quoted
288
+ * strings, booleans, numbers, null), inline arrays (`tags: [a, b]`), and YAML
289
+ * block lists (`tags:\n - a\n - b`). Not a full YAML parser: nested mappings
290
+ * and multi-line block scalars are not supported. A document with no opening
291
+ * "---" delimiter is returned as-is with `hasFrontMatter: false`.
292
+ */
293
+ declare function parseFrontMatter(input: string): FrontMatterResult | FrontMatterError;
275
294
 
276
295
  type data_ConvertedSubtitles = ConvertedSubtitles;
277
296
  type data_CsvParseResult = CsvParseResult;
@@ -279,6 +298,8 @@ type data_EnvDiffError = EnvDiffError;
279
298
  type data_EnvDiffResult = EnvDiffResult;
280
299
  type data_EnvEntry = EnvEntry;
281
300
  type data_EnvParseResult = EnvParseResult;
301
+ type data_FrontMatterError = FrontMatterError;
302
+ type data_FrontMatterResult = FrontMatterResult;
282
303
  type data_IniSection = IniSection;
283
304
  type data_NdjsonLineResult = NdjsonLineResult;
284
305
  type data_NdjsonValidateResult = NdjsonValidateResult;
@@ -318,6 +339,7 @@ declare const data_minifyXml: typeof minifyXml;
318
339
  declare const data_ndjsonToJsonArray: typeof ndjsonToJsonArray;
319
340
  declare const data_parseCsv: typeof parseCsv;
320
341
  declare const data_parseEnv: typeof parseEnv;
342
+ declare const data_parseFrontMatter: typeof parseFrontMatter;
321
343
  declare const data_parseIni: typeof parseIni;
322
344
  declare const data_parseSubtitleTimestamp: typeof parseSubtitleTimestamp;
323
345
  declare const data_parseSubtitles: typeof parseSubtitles;
@@ -335,7 +357,7 @@ declare const data_validateXml: typeof validateXml;
335
357
  declare const data_validateYaml: typeof validateYaml;
336
358
  declare const data_xmlToJson: typeof xmlToJson;
337
359
  declare namespace data {
338
- export { type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
360
+ export { type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
339
361
  }
340
362
 
341
- export { toCsvString as $, iniToJson as A, jsonArrayToNdjson as B, type ConvertedSubtitles as C, jsonToIni as D, type EnvDiffError as E, jsonToToml as F, jsonToXml as G, minifyNdjson as H, type IniSection as I, minifyToml as J, minifyXml as K, ndjsonToJsonArray as L, parseCsv as M, type NdjsonLineResult as N, parseEnv as O, type ParseOptions as P, parseIni as Q, parseSubtitleTimestamp as R, type SubtitleCue as S, type TomlFormatResult as T, parseSubtitles as U, type ValidationResult as V, parseXmlToObject as W, type XmlFormatResult as X, serializeSubtitles as Y, shiftSubtitles as Z, stringifyIni as _, type CsvParseResult as a, tomlToJson as a0, validateEnvKey as a1, validateIni as a2, validateNdjson as a3, validateToml as a4, validateXml as a5, validateYaml as a6, xmlToJson as a7, type EnvDiffResult as b, type EnvEntry as c, data as d, type EnvParseResult as e, type NdjsonValidateResult as f, type ParsedIni as g, type ParsedSubtitles as h, type SubtitleFormat as i, type XmlToJsonOptions as j, convertSubtitles as k, csvToJson as l, detectDelimiter as m, detectSubtitleFormat as n, diffEnvExample as o, envToExport as p, envToJson as q, formatNdjson as r, formatSubtitleTimestamp as s, formatToml as t, formatXml as u, getSection as v, getSectionNames as w, getTomlStats as x, getXmlStats as y, getYamlStats as z };
363
+ export { serializeSubtitles as $, getYamlStats as A, iniToJson as B, type ConvertedSubtitles as C, jsonArrayToNdjson as D, type EnvDiffError as E, type FrontMatterError as F, jsonToIni as G, jsonToToml as H, type IniSection as I, jsonToXml as J, minifyNdjson as K, minifyToml as L, minifyXml as M, type NdjsonLineResult as N, ndjsonToJsonArray as O, type ParseOptions as P, parseCsv as Q, parseEnv as R, type SubtitleCue as S, type TomlFormatResult as T, parseFrontMatter as U, type ValidationResult as V, parseIni as W, type XmlFormatResult as X, parseSubtitleTimestamp as Y, parseSubtitles as Z, parseXmlToObject as _, type CsvParseResult as a, shiftSubtitles as a0, stringifyIni as a1, toCsvString as a2, tomlToJson as a3, validateEnvKey as a4, validateIni as a5, validateNdjson as a6, validateToml as a7, validateXml as a8, validateYaml as a9, xmlToJson as aa, type EnvDiffResult as b, type EnvEntry as c, data as d, type EnvParseResult as e, type FrontMatterResult as f, type NdjsonValidateResult as g, type ParsedIni as h, type ParsedSubtitles as i, type SubtitleFormat as j, type XmlToJsonOptions as k, convertSubtitles as l, csvToJson as m, detectDelimiter as n, detectSubtitleFormat as o, diffEnvExample as p, envToExport as q, envToJson as r, formatNdjson as s, formatSubtitleTimestamp as t, formatToml as u, formatXml as v, getSection as w, getSectionNames as x, getTomlStats as y, getXmlStats as z };
package/dist/index.cjs CHANGED
@@ -2017,6 +2017,7 @@ __export(text_exports, {
2017
2017
  LINE_OPS: () => LINE_OPS,
2018
2018
  MORSE_CODE: () => MORSE_CODE,
2019
2019
  addBorder: () => addBorder,
2020
+ analyzeSentenceLengths: () => analyzeSentenceLengths,
2020
2021
  analyzeText: () => analyzeText,
2021
2022
  applyOp: () => applyOp,
2022
2023
  applyOps: () => applyOps,
@@ -4605,6 +4606,71 @@ function calculateStringDistance(a, b, options) {
4605
4606
  const similarity = maxLength === 0 ? 1 : Math.round((1 - distance / maxLength) * 1e4) / 1e4;
4606
4607
  return { a, b, distance, similarity, maxLength, mode };
4607
4608
  }
4609
+ function splitIntoSentencesForLengthDist(text) {
4610
+ const matches = text.match(/[^.!?]+[.!?]*/g);
4611
+ if (!matches) return [];
4612
+ return matches.map((s) => s.trim()).filter((s) => s.length > 0);
4613
+ }
4614
+ function countWordsInSentence(sentence) {
4615
+ return (sentence.match(/[a-zA-Z']+/g) ?? []).length;
4616
+ }
4617
+ function analyzeSentenceLengths(text) {
4618
+ const sentences = splitIntoSentencesForLengthDist(text);
4619
+ const lengths = sentences.map(countWordsInSentence).filter((n) => n > 0);
4620
+ if (lengths.length === 0) {
4621
+ return {
4622
+ sentenceCount: 0,
4623
+ lengths: [],
4624
+ minLength: 0,
4625
+ maxLength: 0,
4626
+ meanLength: 0,
4627
+ medianLength: 0,
4628
+ stdDev: 0,
4629
+ coefficientOfVariation: 0,
4630
+ consistency: "No sentences to analyze",
4631
+ buckets: []
4632
+ };
4633
+ }
4634
+ const sentenceCount2 = lengths.length;
4635
+ const minLength = Math.min(...lengths);
4636
+ const maxLength = Math.max(...lengths);
4637
+ const meanLength = lengths.reduce((a, b) => a + b, 0) / sentenceCount2;
4638
+ const sorted = [...lengths].sort((a, b) => a - b);
4639
+ const mid = Math.floor(sorted.length / 2);
4640
+ const medianLength = sorted.length % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
4641
+ const variance = lengths.reduce((sum, n) => sum + (n - meanLength) ** 2, 0) / sentenceCount2;
4642
+ const stdDev = Math.sqrt(variance);
4643
+ const coefficientOfVariation = meanLength > 0 ? stdDev / meanLength : 0;
4644
+ let consistency;
4645
+ if (coefficientOfVariation < 0.3) consistency = "Consistent \u2014 sentence lengths vary little";
4646
+ else if (coefficientOfVariation < 0.6) consistency = "Moderate variation in sentence length";
4647
+ else consistency = "Highly variable sentence length";
4648
+ const bucketWidth = 5;
4649
+ const bucketCount = Math.max(1, Math.ceil(maxLength / bucketWidth));
4650
+ const buckets = [];
4651
+ for (let i = 0; i < bucketCount; i++) {
4652
+ const min = i * bucketWidth + 1;
4653
+ const max = (i + 1) * bucketWidth;
4654
+ buckets.push({ label: `${min}-${max}`, min, max, count: 0 });
4655
+ }
4656
+ for (const len of lengths) {
4657
+ const idx = Math.min(Math.floor((len - 1) / bucketWidth), bucketCount - 1);
4658
+ buckets[idx].count++;
4659
+ }
4660
+ const round23 = (n) => Math.round(n * 100) / 100;
4661
+ return {
4662
+ sentenceCount: sentenceCount2,
4663
+ lengths,
4664
+ minLength,
4665
+ maxLength,
4666
+ meanLength: round23(meanLength),
4667
+ medianLength: round23(medianLength),
4668
+ stdDev: round23(stdDev),
4669
+ coefficientOfVariation: round23(coefficientOfVariation),
4670
+ consistency,
4671
+ buckets
4672
+ };
4673
+ }
4608
4674
 
4609
4675
  // src/tools/data.ts
4610
4676
  var data_exports = {};
@@ -4636,6 +4702,7 @@ __export(data_exports, {
4636
4702
  ndjsonToJsonArray: () => ndjsonToJsonArray,
4637
4703
  parseCsv: () => parseCsv,
4638
4704
  parseEnv: () => parseEnv,
4705
+ parseFrontMatter: () => parseFrontMatter,
4639
4706
  parseIni: () => parseIni,
4640
4707
  parseSubtitleTimestamp: () => parseSubtitleTimestamp,
4641
4708
  parseSubtitles: () => parseSubtitles,
@@ -5938,6 +6005,70 @@ function shiftSubtitles(input, offsetSeconds, target) {
5938
6005
  warnings
5939
6006
  };
5940
6007
  }
6008
+ function parseFrontMatterScalar(value) {
6009
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
6010
+ return value.slice(1, -1);
6011
+ }
6012
+ if (value === "true") return true;
6013
+ if (value === "false") return false;
6014
+ if (value === "null" || value === "~") return null;
6015
+ if (value !== "" && !Number.isNaN(Number(value))) return Number(value);
6016
+ return value;
6017
+ }
6018
+ function parseFrontMatter(input) {
6019
+ if (typeof input !== "string" || input.length === 0) return { error: "input is required" };
6020
+ const normalized = input.replace(/\r\n/g, "\n");
6021
+ if (!normalized.startsWith("---\n") && normalized !== "---") {
6022
+ return { frontMatter: {}, body: input, hasFrontMatter: false, raw: "" };
6023
+ }
6024
+ const closingIdx = normalized.indexOf("\n---", 4);
6025
+ if (closingIdx === -1) {
6026
+ return { error: 'Front matter opening delimiter found but no closing "---" delimiter' };
6027
+ }
6028
+ const raw = normalized.slice(4, closingIdx);
6029
+ let afterClose = normalized.slice(closingIdx + 4);
6030
+ if (afterClose.startsWith("\n")) afterClose = afterClose.slice(1);
6031
+ const frontMatter = {};
6032
+ const rawLines = raw.split("\n");
6033
+ let i = 0;
6034
+ while (i < rawLines.length) {
6035
+ const line = rawLines[i];
6036
+ if (line.trim() === "" || line.trim().startsWith("#")) {
6037
+ i++;
6038
+ continue;
6039
+ }
6040
+ const colonIdx = line.indexOf(":");
6041
+ if (colonIdx === -1) return { error: `Invalid front matter line ${i + 1}: expected "key: value"` };
6042
+ const key = line.slice(0, colonIdx).trim();
6043
+ if (!key) return { error: `Invalid front matter line ${i + 1}: empty key` };
6044
+ const rest = line.slice(colonIdx + 1).trim();
6045
+ if (rest === "") {
6046
+ const listItems = [];
6047
+ let j = i + 1;
6048
+ while (j < rawLines.length && /^\s*-\s+/.test(rawLines[j])) {
6049
+ listItems.push(rawLines[j].replace(/^\s*-\s+/, "").trim());
6050
+ j++;
6051
+ }
6052
+ if (listItems.length > 0) {
6053
+ frontMatter[key] = listItems.map(parseFrontMatterScalar);
6054
+ i = j;
6055
+ continue;
6056
+ }
6057
+ frontMatter[key] = null;
6058
+ i++;
6059
+ continue;
6060
+ }
6061
+ if (rest.startsWith("[") && rest.endsWith("]")) {
6062
+ const inner = rest.slice(1, -1).trim();
6063
+ frontMatter[key] = inner === "" ? [] : inner.split(",").map((s) => parseFrontMatterScalar(s.trim()));
6064
+ i++;
6065
+ continue;
6066
+ }
6067
+ frontMatter[key] = parseFrontMatterScalar(rest);
6068
+ i++;
6069
+ }
6070
+ return { frontMatter, body: afterClose, hasFrontMatter: true, raw };
6071
+ }
5941
6072
 
5942
6073
  // src/tools/generators.ts
5943
6074
  var generators_exports = {};
@@ -7357,6 +7488,7 @@ __export(units_exports, {
7357
7488
  calculateBreakEven: () => calculateBreakEven,
7358
7489
  calculateCompoundInterest: () => calculateCompoundInterest,
7359
7490
  calculateDiscount: () => calculateDiscount,
7491
+ calculateEmi: () => calculateEmi,
7360
7492
  calculateLoan: () => calculateLoan,
7361
7493
  calculateMarginMarkup: () => calculateMarginMarkup,
7362
7494
  calculatePercentageChange: () => calculatePercentageChange,
@@ -9011,6 +9143,61 @@ function calculateRuleOf72(value, direction) {
9011
9143
  errorPercent: round4(errorPercent)
9012
9144
  };
9013
9145
  }
9146
+ function calculateEmi(principal, annualRatePercent, tenure, tenureUnit = "years") {
9147
+ if (!Number.isFinite(principal) || principal <= 0) return { error: "Principal must be a positive number" };
9148
+ if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
9149
+ return { error: "Annual interest rate must be zero or a positive number" };
9150
+ }
9151
+ if (tenureUnit !== "years" && tenureUnit !== "months") {
9152
+ return { error: 'tenureUnit must be "years" or "months"' };
9153
+ }
9154
+ if (!Number.isFinite(tenure) || tenure <= 0) return { error: "Tenure must be a positive number" };
9155
+ const tenureMonths = Math.round(tenureUnit === "years" ? tenure * 12 : tenure);
9156
+ if (tenureMonths <= 0) return { error: "Tenure must resolve to at least 1 month" };
9157
+ const monthlyRate = annualRatePercent / 100 / 12;
9158
+ let emi;
9159
+ if (monthlyRate === 0) {
9160
+ emi = principal / tenureMonths;
9161
+ } else {
9162
+ const factor = Math.pow(1 + monthlyRate, tenureMonths);
9163
+ emi = principal * monthlyRate * factor / (factor - 1);
9164
+ }
9165
+ const yearlyBreakdown = [];
9166
+ let balance = round2(principal);
9167
+ let totalPayment = 0;
9168
+ let yearPrincipal = 0;
9169
+ let yearInterest = 0;
9170
+ let year = 1;
9171
+ for (let month = 1; month <= tenureMonths; month++) {
9172
+ const interest = monthlyRate === 0 ? 0 : round2(balance * monthlyRate);
9173
+ let principalPortion = round2(emi) - interest;
9174
+ if (month === tenureMonths || principalPortion > balance) principalPortion = balance;
9175
+ const payment = round2(principalPortion + interest);
9176
+ balance = Math.max(round2(balance - principalPortion), 0);
9177
+ totalPayment += payment;
9178
+ yearPrincipal += principalPortion;
9179
+ yearInterest += interest;
9180
+ const isYearEnd = month % 12 === 0 || month === tenureMonths;
9181
+ if (isYearEnd) {
9182
+ yearlyBreakdown.push({
9183
+ year,
9184
+ principalPaid: round2(yearPrincipal),
9185
+ interestPaid: round2(yearInterest),
9186
+ balance
9187
+ });
9188
+ year += 1;
9189
+ yearPrincipal = 0;
9190
+ yearInterest = 0;
9191
+ }
9192
+ }
9193
+ return {
9194
+ emi: round2(emi),
9195
+ totalInterest: round2(totalPayment - principal),
9196
+ totalPayment: round2(totalPayment),
9197
+ tenureMonths,
9198
+ yearlyBreakdown
9199
+ };
9200
+ }
9014
9201
 
9015
9202
  // src/tools/network.ts
9016
9203
  var network_exports = {};
@@ -18565,6 +18752,7 @@ __export(ai_agent_exports, {
18565
18752
  extractTables: () => extractTables,
18566
18753
  extractUrls: () => extractUrls,
18567
18754
  flattenJson: () => flattenJson,
18755
+ formatFewShotExamples: () => formatFewShotExamples,
18568
18756
  mergeJson: () => mergeJson,
18569
18757
  redactPii: () => redactPii,
18570
18758
  repairJson: () => repairJson,
@@ -19522,6 +19710,29 @@ function vectorSimilarity(a, b) {
19522
19710
  magnitudeB: round6(magB)
19523
19711
  };
19524
19712
  }
19713
+ function formatFewShotExamples(examples, format = "numbered", delimiter = "---") {
19714
+ const valid = (examples ?? []).filter((e) => e?.input?.trim() && e?.output?.trim());
19715
+ if (valid.length === 0) {
19716
+ return { formatted: "", exampleCount: 0, format };
19717
+ }
19718
+ let formatted;
19719
+ if (format === "xml") {
19720
+ formatted = valid.map((e) => `<example>
19721
+ <input>${e.input.trim()}</input>
19722
+ <output>${e.output.trim()}</output>
19723
+ </example>`).join("\n\n");
19724
+ } else if (format === "delimiter") {
19725
+ formatted = valid.map((e) => `Input: ${e.input.trim()}
19726
+ Output: ${e.output.trim()}`).join(`
19727
+ ${delimiter}
19728
+ `);
19729
+ } else {
19730
+ formatted = valid.map((e, i) => `Example ${i + 1}:
19731
+ Input: ${e.input.trim()}
19732
+ Output: ${e.output.trim()}`).join("\n\n");
19733
+ }
19734
+ return { formatted, exampleCount: valid.length, format };
19735
+ }
19525
19736
 
19526
19737
  // src/tools/media.ts
19527
19738
  var media_exports = {};
package/dist/index.d.cts CHANGED
@@ -1,18 +1,18 @@
1
1
  export { j as json } from './json-Ta9JykSB.cjs';
2
2
  export { e as encoding } from './encoding-Dk3wpmb3.cjs';
3
3
  export { h as hashing } from './hashing-CnetQFD_.cjs';
4
- export { t as text } from './text-D1fySkCB.cjs';
5
- export { d as data } from './data-XRb0D7Zn.cjs';
4
+ export { t as text } from './text-CA-zuD0C.cjs';
5
+ export { d as data } from './data-C4lCByXw.cjs';
6
6
  export { g as generators } from './generators-Du8cBesn.cjs';
7
7
  export { t as time } from './time-KqJjdqII.cjs';
8
- export { u as units } from './units-COt5uI20.cjs';
8
+ export { u as units } from './units-DQYLZd1n.cjs';
9
9
  export { n as network } from './network-D7Epuerc.cjs';
10
10
  export { a as api } from './api-DmTNE4c1.cjs';
11
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-B-c59NXD.cjs';
15
+ export { a as ai_agent } from './ai_agent-C1zudGgT.cjs';
16
16
  export { m as media } from './media-fD8dJ5qR.cjs';
17
17
 
18
18
  declare const version = "0.1.0";
package/dist/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  export { j as json } from './json-Ta9JykSB.js';
2
2
  export { e as encoding } from './encoding-Dk3wpmb3.js';
3
3
  export { h as hashing } from './hashing-CnetQFD_.js';
4
- export { t as text } from './text-D1fySkCB.js';
5
- export { d as data } from './data-XRb0D7Zn.js';
4
+ export { t as text } from './text-CA-zuD0C.js';
5
+ export { d as data } from './data-C4lCByXw.js';
6
6
  export { g as generators } from './generators-Du8cBesn.js';
7
7
  export { t as time } from './time-KqJjdqII.js';
8
- export { u as units } from './units-COt5uI20.js';
8
+ export { u as units } from './units-DQYLZd1n.js';
9
9
  export { n as network } from './network-D7Epuerc.js';
10
10
  export { a as api } from './api-DmTNE4c1.js';
11
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-B-c59NXD.js';
15
+ export { a as ai_agent } from './ai_agent-C1zudGgT.js';
16
16
  export { m as media } from './media-fD8dJ5qR.js';
17
17
 
18
18
  declare const version = "0.1.0";
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  export { media_exports as media } from './chunk-L6V4W4SU.js';
2
- export { units_exports as units } from './chunk-I63BCOAG.js';
2
+ export { units_exports as units } from './chunk-GDIZWDBY.js';
3
3
  export { network_exports as network } from './chunk-CSNTHZHF.js';
4
4
  export { api_exports as api } from './chunk-52ZDKSIX.js';
5
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-265NPGKH.js';
9
+ export { ai_agent_exports as ai_agent } from './chunk-W3J7GZVQ.js';
10
10
  export { json_exports as json } from './chunk-WVEKRKGU.js';
11
11
  export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
12
12
  export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
13
- export { text_exports as text } from './chunk-AFEZ6N4A.js';
14
- export { data_exports as data } from './chunk-66QHV5KW.js';
13
+ export { text_exports as text } from './chunk-H2USEUHD.js';
14
+ export { data_exports as data } from './chunk-6FIB72KX.js';
15
15
  export { generators_exports as generators } from './chunk-3TYWIX3B.js';
16
16
  export { time_exports as time } from './chunk-IEPWZERQ.js';
17
17
  import './chunk-MLKGABMK.js';
@@ -22,6 +22,7 @@
22
22
  * - passive-voice-detector: detectPassiveVoice
23
23
  * - readability-score: scoreReadability
24
24
  * - filler-word-detector: detectFillerWords
25
+ * - sentence-length-distribution: analyzeSentenceLengths
25
26
  */
26
27
  interface WordCountResult {
27
28
  words: number;
@@ -327,6 +328,34 @@ declare function calculateStringDistance(a: string, b: string, options?: {
327
328
  }): StringDistanceResult | {
328
329
  error: string;
329
330
  };
331
+ interface SentenceLengthBucket {
332
+ label: string;
333
+ min: number;
334
+ max: number;
335
+ count: number;
336
+ }
337
+ interface SentenceLengthDistribution {
338
+ sentenceCount: number;
339
+ lengths: number[];
340
+ minLength: number;
341
+ maxLength: number;
342
+ meanLength: number;
343
+ medianLength: number;
344
+ stdDev: number;
345
+ coefficientOfVariation: number;
346
+ consistency: string;
347
+ buckets: SentenceLengthBucket[];
348
+ }
349
+ /**
350
+ * Split text into sentences and report a histogram of sentence lengths (in
351
+ * words), plus mean/median/standard-deviation stats and a coefficient of
352
+ * variation, which is a distinct signal from the Flesch/Fog readability
353
+ * scores: two paragraphs can share the same reading grade while one alternates
354
+ * short and long sentences and the other stays uniform. Sentence splitting
355
+ * uses simple terminal-punctuation matching, so it can miscount abbreviations
356
+ * (e.g. "Dr.") as sentence boundaries.
357
+ */
358
+ declare function analyzeSentenceLengths(text: string): SentenceLengthDistribution;
330
359
 
331
360
  type text_AsciiFont = AsciiFont;
332
361
  type text_AsciiOptions = AsciiOptions;
@@ -359,6 +388,8 @@ type text_PassiveVoiceResult = PassiveVoiceResult;
359
388
  type text_PassiveVoiceSentence = PassiveVoiceSentence;
360
389
  type text_ReadabilityResult = ReadabilityResult;
361
390
  type text_ReadabilityScore = ReadabilityScore;
391
+ type text_SentenceLengthBucket = SentenceLengthBucket;
392
+ type text_SentenceLengthDistribution = SentenceLengthDistribution;
362
393
  type text_SlugSeparator = SlugSeparator;
363
394
  type text_StringDistanceMode = StringDistanceMode;
364
395
  type text_StringDistanceResult = StringDistanceResult;
@@ -366,6 +397,7 @@ type text_TableOptions = TableOptions;
366
397
  type text_TextAnalysis = TextAnalysis;
367
398
  type text_WordCountResult = WordCountResult;
368
399
  declare const text_addBorder: typeof addBorder;
400
+ declare const text_analyzeSentenceLengths: typeof analyzeSentenceLengths;
369
401
  declare const text_analyzeText: typeof analyzeText;
370
402
  declare const text_applyOp: typeof applyOp;
371
403
  declare const text_applyOps: typeof applyOps;
@@ -419,7 +451,7 @@ declare const text_textToMorse: typeof textToMorse;
419
451
  declare const text_unescapeString: typeof unescapeString;
420
452
  declare const text_wordFrequency: typeof wordFrequency;
421
453
  declare namespace text {
422
- export { type text_AsciiFont as AsciiFont, type text_AsciiOptions as AsciiOptions, text_CASE_FORMATS as CASE_FORMATS, type text_CaseFormat as CaseFormat, type text_ConvertOptions as ConvertOptions, text_DEFAULT_CONVERT_OPTIONS as DEFAULT_CONVERT_OPTIONS, type text_DiffFile as DiffFile, type text_DiffHunk as DiffHunk, type text_DiffLine as DiffLine, type text_DiffResult as DiffResult, type text_DiffType as DiffType, type text_DiffViewerLine as DiffViewerLine, text_ESCAPE_MODES as ESCAPE_MODES, type text_EscapeMode as EscapeMode, type text_FillerCategory as FillerCategory, type text_FillerMatch as FillerMatch, type text_FillerWordResult as FillerWordResult, text_LINE_OPS as LINE_OPS, type text_LineOp as LineOp, type text_LineType as LineType, type text_LoremUnit as LoremUnit, text_MORSE_CODE as MORSE_CODE, type text_MarkdownResult as MarkdownResult, type text_MorseOptions as MorseOptions, type text_ParsedDiff as ParsedDiff, type text_ParsedTable as ParsedTable, type text_PassiveVoiceMatch as PassiveVoiceMatch, type text_PassiveVoiceResult as PassiveVoiceResult, type text_PassiveVoiceSentence as PassiveVoiceSentence, type text_ReadabilityResult as ReadabilityResult, type text_ReadabilityScore as ReadabilityScore, type text_SlugSeparator as SlugSeparator, type text_StringDistanceMode as StringDistanceMode, type text_StringDistanceResult as StringDistanceResult, type text_TableOptions as TableOptions, type text_TextAnalysis as TextAnalysis, type text_WordCountResult as WordCountResult, text_addBorder as addBorder, text_analyzeText as analyzeText, text_applyOp as applyOp, text_applyOps as applyOps, text_calculateStringDistance as calculateStringDistance, text_centerText as centerText, text_convertAll as convertAll, text_convertCase as convertCase, text_countWords as countWords, text_csvToHtml as csvToHtml, text_csvToMarkdown as csvToMarkdown, text_detectDelimiter as detectDelimiter, text_detectFillerWords as detectFillerWords, text_detectPassiveVoice as detectPassiveVoice, text_diffLines as diffLines, text_diffLinesSimple as diffLinesSimple, text_diffStats as diffStats, text_escapeAll as escapeAll, text_escapeString as escapeString, text_extractHeadings as extractHeadings, text_formatReadingTime as formatReadingTime, text_generate as generate, text_generateDiff as generateDiff, text_generateHtmlTable as generateHtmlTable, text_generateMarkdownTable as generateMarkdownTable, text_generateParagraphs as generateParagraphs, text_generateSentences as generateSentences, text_generateWords as generateWords, text_getAvailableFonts as getAvailableFonts, text_getMorseForChar as getMorseForChar, text_getMorseTiming as getMorseTiming, text_htmlToMarkdown as htmlToMarkdown, text_isValidMorse as isValidMorse, text_markdownToHtml as markdownToHtml, text_morseToText as morseToText, text_numberToOrdinal as numberToOrdinal, text_numberToRoman as numberToRoman, text_numberToWords as numberToWords, text_ordinalWords as ordinalWords, text_parseDiff as parseDiff, text_parseTableData as parseTableData, text_readabilityScore as readabilityScore, text_renderMarkdown as renderMarkdown, text_romanToNumber as romanToNumber, text_scoreReadability as scoreReadability, text_sentenceCount as sentenceCount, text_slugify as slugify, text_slugifyAll as slugifyAll, text_syllableCount as syllableCount, text_textToAscii as textToAscii, text_textToMorse as textToMorse, text_unescapeString as unescapeString, text_wordFrequency as wordFrequency };
454
+ export { type text_AsciiFont as AsciiFont, type text_AsciiOptions as AsciiOptions, text_CASE_FORMATS as CASE_FORMATS, type text_CaseFormat as CaseFormat, type text_ConvertOptions as ConvertOptions, text_DEFAULT_CONVERT_OPTIONS as DEFAULT_CONVERT_OPTIONS, type text_DiffFile as DiffFile, type text_DiffHunk as DiffHunk, type text_DiffLine as DiffLine, type text_DiffResult as DiffResult, type text_DiffType as DiffType, type text_DiffViewerLine as DiffViewerLine, text_ESCAPE_MODES as ESCAPE_MODES, type text_EscapeMode as EscapeMode, type text_FillerCategory as FillerCategory, type text_FillerMatch as FillerMatch, type text_FillerWordResult as FillerWordResult, text_LINE_OPS as LINE_OPS, type text_LineOp as LineOp, type text_LineType as LineType, type text_LoremUnit as LoremUnit, text_MORSE_CODE as MORSE_CODE, type text_MarkdownResult as MarkdownResult, type text_MorseOptions as MorseOptions, type text_ParsedDiff as ParsedDiff, type text_ParsedTable as ParsedTable, type text_PassiveVoiceMatch as PassiveVoiceMatch, type text_PassiveVoiceResult as PassiveVoiceResult, type text_PassiveVoiceSentence as PassiveVoiceSentence, type text_ReadabilityResult as ReadabilityResult, type text_ReadabilityScore as ReadabilityScore, type text_SentenceLengthBucket as SentenceLengthBucket, type text_SentenceLengthDistribution as SentenceLengthDistribution, type text_SlugSeparator as SlugSeparator, type text_StringDistanceMode as StringDistanceMode, type text_StringDistanceResult as StringDistanceResult, type text_TableOptions as TableOptions, type text_TextAnalysis as TextAnalysis, type text_WordCountResult as WordCountResult, text_addBorder as addBorder, text_analyzeSentenceLengths as analyzeSentenceLengths, text_analyzeText as analyzeText, text_applyOp as applyOp, text_applyOps as applyOps, text_calculateStringDistance as calculateStringDistance, text_centerText as centerText, text_convertAll as convertAll, text_convertCase as convertCase, text_countWords as countWords, text_csvToHtml as csvToHtml, text_csvToMarkdown as csvToMarkdown, text_detectDelimiter as detectDelimiter, text_detectFillerWords as detectFillerWords, text_detectPassiveVoice as detectPassiveVoice, text_diffLines as diffLines, text_diffLinesSimple as diffLinesSimple, text_diffStats as diffStats, text_escapeAll as escapeAll, text_escapeString as escapeString, text_extractHeadings as extractHeadings, text_formatReadingTime as formatReadingTime, text_generate as generate, text_generateDiff as generateDiff, text_generateHtmlTable as generateHtmlTable, text_generateMarkdownTable as generateMarkdownTable, text_generateParagraphs as generateParagraphs, text_generateSentences as generateSentences, text_generateWords as generateWords, text_getAvailableFonts as getAvailableFonts, text_getMorseForChar as getMorseForChar, text_getMorseTiming as getMorseTiming, text_htmlToMarkdown as htmlToMarkdown, text_isValidMorse as isValidMorse, text_markdownToHtml as markdownToHtml, text_morseToText as morseToText, text_numberToOrdinal as numberToOrdinal, text_numberToRoman as numberToRoman, text_numberToWords as numberToWords, text_ordinalWords as ordinalWords, text_parseDiff as parseDiff, text_parseTableData as parseTableData, text_readabilityScore as readabilityScore, text_renderMarkdown as renderMarkdown, text_romanToNumber as romanToNumber, text_scoreReadability as scoreReadability, text_sentenceCount as sentenceCount, text_slugify as slugify, text_slugifyAll as slugifyAll, text_syllableCount as syllableCount, text_textToAscii as textToAscii, text_textToMorse as textToMorse, text_unescapeString as unescapeString, text_wordFrequency as wordFrequency };
423
455
  }
424
456
 
425
- export { diffLinesSimple as $, type AsciiFont as A, addBorder as B, CASE_FORMATS as C, DEFAULT_CONVERT_OPTIONS as D, ESCAPE_MODES as E, type FillerCategory as F, analyzeText as G, applyOp as H, applyOps as I, calculateStringDistance as J, centerText as K, LINE_OPS as L, MORSE_CODE as M, convertAll as N, convertCase as O, type ParsedDiff as P, countWords as Q, type ReadabilityResult as R, type SlugSeparator as S, type TableOptions as T, csvToHtml as U, csvToMarkdown as V, type WordCountResult as W, detectDelimiter as X, detectFillerWords as Y, detectPassiveVoice as Z, diffLines as _, type AsciiOptions as a, diffStats as a0, escapeAll as a1, escapeString as a2, extractHeadings as a3, formatReadingTime as a4, generate as a5, generateDiff as a6, generateHtmlTable as a7, generateMarkdownTable as a8, generateParagraphs as a9, wordFrequency as aA, generateSentences as aa, generateWords as ab, getAvailableFonts as ac, getMorseForChar as ad, getMorseTiming as ae, htmlToMarkdown as af, isValidMorse as ag, markdownToHtml as ah, morseToText as ai, numberToOrdinal as aj, numberToRoman as ak, numberToWords as al, ordinalWords as am, parseDiff as an, parseTableData as ao, readabilityScore as ap, renderMarkdown as aq, romanToNumber as ar, scoreReadability as as, sentenceCount as at, slugify as au, slugifyAll as av, syllableCount as aw, textToAscii as ax, textToMorse as ay, unescapeString as az, type CaseFormat as b, type ConvertOptions as c, type DiffFile as d, type DiffHunk as e, type DiffLine as f, type DiffResult as g, type DiffType as h, type DiffViewerLine as i, type EscapeMode as j, type FillerMatch as k, type FillerWordResult as l, type LineOp as m, type LineType as n, type LoremUnit as o, type MarkdownResult as p, type MorseOptions as q, type ParsedTable as r, type PassiveVoiceMatch as s, text as t, type PassiveVoiceResult as u, type PassiveVoiceSentence as v, type ReadabilityScore as w, type StringDistanceMode as x, type StringDistanceResult as y, type TextAnalysis as z };
457
+ export { detectFillerWords as $, type AsciiFont as A, type StringDistanceResult as B, CASE_FORMATS as C, DEFAULT_CONVERT_OPTIONS as D, ESCAPE_MODES as E, type FillerCategory as F, type TextAnalysis as G, addBorder as H, analyzeSentenceLengths as I, analyzeText as J, applyOp as K, LINE_OPS as L, MORSE_CODE as M, applyOps as N, calculateStringDistance as O, type ParsedDiff as P, centerText as Q, type ReadabilityResult as R, type SentenceLengthBucket as S, type TableOptions as T, convertAll as U, convertCase as V, type WordCountResult as W, countWords as X, csvToHtml as Y, csvToMarkdown as Z, detectDelimiter as _, type AsciiOptions as a, detectPassiveVoice as a0, diffLines as a1, diffLinesSimple as a2, diffStats as a3, escapeAll as a4, escapeString as a5, extractHeadings as a6, formatReadingTime as a7, generate as a8, generateDiff as a9, textToAscii as aA, textToMorse as aB, unescapeString as aC, wordFrequency as aD, generateHtmlTable as aa, generateMarkdownTable as ab, generateParagraphs as ac, generateSentences as ad, generateWords as ae, getAvailableFonts as af, getMorseForChar as ag, getMorseTiming as ah, htmlToMarkdown as ai, isValidMorse as aj, markdownToHtml as ak, morseToText as al, numberToOrdinal as am, numberToRoman as an, numberToWords as ao, ordinalWords as ap, parseDiff as aq, parseTableData as ar, readabilityScore as as, renderMarkdown as at, romanToNumber as au, scoreReadability as av, sentenceCount as aw, slugify as ax, slugifyAll as ay, syllableCount as az, type CaseFormat as b, type ConvertOptions as c, type DiffFile as d, type DiffHunk as e, type DiffLine as f, type DiffResult as g, type DiffType as h, type DiffViewerLine as i, type EscapeMode as j, type FillerMatch as k, type FillerWordResult as l, type LineOp as m, type LineType as n, type LoremUnit as o, type MarkdownResult as p, type MorseOptions as q, type ParsedTable as r, type PassiveVoiceMatch as s, text as t, type PassiveVoiceResult as u, type PassiveVoiceSentence as v, type ReadabilityScore as w, type SentenceLengthDistribution as x, type SlugSeparator as y, type StringDistanceMode as z };
@@ -22,6 +22,7 @@
22
22
  * - passive-voice-detector: detectPassiveVoice
23
23
  * - readability-score: scoreReadability
24
24
  * - filler-word-detector: detectFillerWords
25
+ * - sentence-length-distribution: analyzeSentenceLengths
25
26
  */
26
27
  interface WordCountResult {
27
28
  words: number;
@@ -327,6 +328,34 @@ declare function calculateStringDistance(a: string, b: string, options?: {
327
328
  }): StringDistanceResult | {
328
329
  error: string;
329
330
  };
331
+ interface SentenceLengthBucket {
332
+ label: string;
333
+ min: number;
334
+ max: number;
335
+ count: number;
336
+ }
337
+ interface SentenceLengthDistribution {
338
+ sentenceCount: number;
339
+ lengths: number[];
340
+ minLength: number;
341
+ maxLength: number;
342
+ meanLength: number;
343
+ medianLength: number;
344
+ stdDev: number;
345
+ coefficientOfVariation: number;
346
+ consistency: string;
347
+ buckets: SentenceLengthBucket[];
348
+ }
349
+ /**
350
+ * Split text into sentences and report a histogram of sentence lengths (in
351
+ * words), plus mean/median/standard-deviation stats and a coefficient of
352
+ * variation, which is a distinct signal from the Flesch/Fog readability
353
+ * scores: two paragraphs can share the same reading grade while one alternates
354
+ * short and long sentences and the other stays uniform. Sentence splitting
355
+ * uses simple terminal-punctuation matching, so it can miscount abbreviations
356
+ * (e.g. "Dr.") as sentence boundaries.
357
+ */
358
+ declare function analyzeSentenceLengths(text: string): SentenceLengthDistribution;
330
359
 
331
360
  type text_AsciiFont = AsciiFont;
332
361
  type text_AsciiOptions = AsciiOptions;
@@ -359,6 +388,8 @@ type text_PassiveVoiceResult = PassiveVoiceResult;
359
388
  type text_PassiveVoiceSentence = PassiveVoiceSentence;
360
389
  type text_ReadabilityResult = ReadabilityResult;
361
390
  type text_ReadabilityScore = ReadabilityScore;
391
+ type text_SentenceLengthBucket = SentenceLengthBucket;
392
+ type text_SentenceLengthDistribution = SentenceLengthDistribution;
362
393
  type text_SlugSeparator = SlugSeparator;
363
394
  type text_StringDistanceMode = StringDistanceMode;
364
395
  type text_StringDistanceResult = StringDistanceResult;
@@ -366,6 +397,7 @@ type text_TableOptions = TableOptions;
366
397
  type text_TextAnalysis = TextAnalysis;
367
398
  type text_WordCountResult = WordCountResult;
368
399
  declare const text_addBorder: typeof addBorder;
400
+ declare const text_analyzeSentenceLengths: typeof analyzeSentenceLengths;
369
401
  declare const text_analyzeText: typeof analyzeText;
370
402
  declare const text_applyOp: typeof applyOp;
371
403
  declare const text_applyOps: typeof applyOps;
@@ -419,7 +451,7 @@ declare const text_textToMorse: typeof textToMorse;
419
451
  declare const text_unescapeString: typeof unescapeString;
420
452
  declare const text_wordFrequency: typeof wordFrequency;
421
453
  declare namespace text {
422
- export { type text_AsciiFont as AsciiFont, type text_AsciiOptions as AsciiOptions, text_CASE_FORMATS as CASE_FORMATS, type text_CaseFormat as CaseFormat, type text_ConvertOptions as ConvertOptions, text_DEFAULT_CONVERT_OPTIONS as DEFAULT_CONVERT_OPTIONS, type text_DiffFile as DiffFile, type text_DiffHunk as DiffHunk, type text_DiffLine as DiffLine, type text_DiffResult as DiffResult, type text_DiffType as DiffType, type text_DiffViewerLine as DiffViewerLine, text_ESCAPE_MODES as ESCAPE_MODES, type text_EscapeMode as EscapeMode, type text_FillerCategory as FillerCategory, type text_FillerMatch as FillerMatch, type text_FillerWordResult as FillerWordResult, text_LINE_OPS as LINE_OPS, type text_LineOp as LineOp, type text_LineType as LineType, type text_LoremUnit as LoremUnit, text_MORSE_CODE as MORSE_CODE, type text_MarkdownResult as MarkdownResult, type text_MorseOptions as MorseOptions, type text_ParsedDiff as ParsedDiff, type text_ParsedTable as ParsedTable, type text_PassiveVoiceMatch as PassiveVoiceMatch, type text_PassiveVoiceResult as PassiveVoiceResult, type text_PassiveVoiceSentence as PassiveVoiceSentence, type text_ReadabilityResult as ReadabilityResult, type text_ReadabilityScore as ReadabilityScore, type text_SlugSeparator as SlugSeparator, type text_StringDistanceMode as StringDistanceMode, type text_StringDistanceResult as StringDistanceResult, type text_TableOptions as TableOptions, type text_TextAnalysis as TextAnalysis, type text_WordCountResult as WordCountResult, text_addBorder as addBorder, text_analyzeText as analyzeText, text_applyOp as applyOp, text_applyOps as applyOps, text_calculateStringDistance as calculateStringDistance, text_centerText as centerText, text_convertAll as convertAll, text_convertCase as convertCase, text_countWords as countWords, text_csvToHtml as csvToHtml, text_csvToMarkdown as csvToMarkdown, text_detectDelimiter as detectDelimiter, text_detectFillerWords as detectFillerWords, text_detectPassiveVoice as detectPassiveVoice, text_diffLines as diffLines, text_diffLinesSimple as diffLinesSimple, text_diffStats as diffStats, text_escapeAll as escapeAll, text_escapeString as escapeString, text_extractHeadings as extractHeadings, text_formatReadingTime as formatReadingTime, text_generate as generate, text_generateDiff as generateDiff, text_generateHtmlTable as generateHtmlTable, text_generateMarkdownTable as generateMarkdownTable, text_generateParagraphs as generateParagraphs, text_generateSentences as generateSentences, text_generateWords as generateWords, text_getAvailableFonts as getAvailableFonts, text_getMorseForChar as getMorseForChar, text_getMorseTiming as getMorseTiming, text_htmlToMarkdown as htmlToMarkdown, text_isValidMorse as isValidMorse, text_markdownToHtml as markdownToHtml, text_morseToText as morseToText, text_numberToOrdinal as numberToOrdinal, text_numberToRoman as numberToRoman, text_numberToWords as numberToWords, text_ordinalWords as ordinalWords, text_parseDiff as parseDiff, text_parseTableData as parseTableData, text_readabilityScore as readabilityScore, text_renderMarkdown as renderMarkdown, text_romanToNumber as romanToNumber, text_scoreReadability as scoreReadability, text_sentenceCount as sentenceCount, text_slugify as slugify, text_slugifyAll as slugifyAll, text_syllableCount as syllableCount, text_textToAscii as textToAscii, text_textToMorse as textToMorse, text_unescapeString as unescapeString, text_wordFrequency as wordFrequency };
454
+ export { type text_AsciiFont as AsciiFont, type text_AsciiOptions as AsciiOptions, text_CASE_FORMATS as CASE_FORMATS, type text_CaseFormat as CaseFormat, type text_ConvertOptions as ConvertOptions, text_DEFAULT_CONVERT_OPTIONS as DEFAULT_CONVERT_OPTIONS, type text_DiffFile as DiffFile, type text_DiffHunk as DiffHunk, type text_DiffLine as DiffLine, type text_DiffResult as DiffResult, type text_DiffType as DiffType, type text_DiffViewerLine as DiffViewerLine, text_ESCAPE_MODES as ESCAPE_MODES, type text_EscapeMode as EscapeMode, type text_FillerCategory as FillerCategory, type text_FillerMatch as FillerMatch, type text_FillerWordResult as FillerWordResult, text_LINE_OPS as LINE_OPS, type text_LineOp as LineOp, type text_LineType as LineType, type text_LoremUnit as LoremUnit, text_MORSE_CODE as MORSE_CODE, type text_MarkdownResult as MarkdownResult, type text_MorseOptions as MorseOptions, type text_ParsedDiff as ParsedDiff, type text_ParsedTable as ParsedTable, type text_PassiveVoiceMatch as PassiveVoiceMatch, type text_PassiveVoiceResult as PassiveVoiceResult, type text_PassiveVoiceSentence as PassiveVoiceSentence, type text_ReadabilityResult as ReadabilityResult, type text_ReadabilityScore as ReadabilityScore, type text_SentenceLengthBucket as SentenceLengthBucket, type text_SentenceLengthDistribution as SentenceLengthDistribution, type text_SlugSeparator as SlugSeparator, type text_StringDistanceMode as StringDistanceMode, type text_StringDistanceResult as StringDistanceResult, type text_TableOptions as TableOptions, type text_TextAnalysis as TextAnalysis, type text_WordCountResult as WordCountResult, text_addBorder as addBorder, text_analyzeSentenceLengths as analyzeSentenceLengths, text_analyzeText as analyzeText, text_applyOp as applyOp, text_applyOps as applyOps, text_calculateStringDistance as calculateStringDistance, text_centerText as centerText, text_convertAll as convertAll, text_convertCase as convertCase, text_countWords as countWords, text_csvToHtml as csvToHtml, text_csvToMarkdown as csvToMarkdown, text_detectDelimiter as detectDelimiter, text_detectFillerWords as detectFillerWords, text_detectPassiveVoice as detectPassiveVoice, text_diffLines as diffLines, text_diffLinesSimple as diffLinesSimple, text_diffStats as diffStats, text_escapeAll as escapeAll, text_escapeString as escapeString, text_extractHeadings as extractHeadings, text_formatReadingTime as formatReadingTime, text_generate as generate, text_generateDiff as generateDiff, text_generateHtmlTable as generateHtmlTable, text_generateMarkdownTable as generateMarkdownTable, text_generateParagraphs as generateParagraphs, text_generateSentences as generateSentences, text_generateWords as generateWords, text_getAvailableFonts as getAvailableFonts, text_getMorseForChar as getMorseForChar, text_getMorseTiming as getMorseTiming, text_htmlToMarkdown as htmlToMarkdown, text_isValidMorse as isValidMorse, text_markdownToHtml as markdownToHtml, text_morseToText as morseToText, text_numberToOrdinal as numberToOrdinal, text_numberToRoman as numberToRoman, text_numberToWords as numberToWords, text_ordinalWords as ordinalWords, text_parseDiff as parseDiff, text_parseTableData as parseTableData, text_readabilityScore as readabilityScore, text_renderMarkdown as renderMarkdown, text_romanToNumber as romanToNumber, text_scoreReadability as scoreReadability, text_sentenceCount as sentenceCount, text_slugify as slugify, text_slugifyAll as slugifyAll, text_syllableCount as syllableCount, text_textToAscii as textToAscii, text_textToMorse as textToMorse, text_unescapeString as unescapeString, text_wordFrequency as wordFrequency };
423
455
  }
424
456
 
425
- export { diffLinesSimple as $, type AsciiFont as A, addBorder as B, CASE_FORMATS as C, DEFAULT_CONVERT_OPTIONS as D, ESCAPE_MODES as E, type FillerCategory as F, analyzeText as G, applyOp as H, applyOps as I, calculateStringDistance as J, centerText as K, LINE_OPS as L, MORSE_CODE as M, convertAll as N, convertCase as O, type ParsedDiff as P, countWords as Q, type ReadabilityResult as R, type SlugSeparator as S, type TableOptions as T, csvToHtml as U, csvToMarkdown as V, type WordCountResult as W, detectDelimiter as X, detectFillerWords as Y, detectPassiveVoice as Z, diffLines as _, type AsciiOptions as a, diffStats as a0, escapeAll as a1, escapeString as a2, extractHeadings as a3, formatReadingTime as a4, generate as a5, generateDiff as a6, generateHtmlTable as a7, generateMarkdownTable as a8, generateParagraphs as a9, wordFrequency as aA, generateSentences as aa, generateWords as ab, getAvailableFonts as ac, getMorseForChar as ad, getMorseTiming as ae, htmlToMarkdown as af, isValidMorse as ag, markdownToHtml as ah, morseToText as ai, numberToOrdinal as aj, numberToRoman as ak, numberToWords as al, ordinalWords as am, parseDiff as an, parseTableData as ao, readabilityScore as ap, renderMarkdown as aq, romanToNumber as ar, scoreReadability as as, sentenceCount as at, slugify as au, slugifyAll as av, syllableCount as aw, textToAscii as ax, textToMorse as ay, unescapeString as az, type CaseFormat as b, type ConvertOptions as c, type DiffFile as d, type DiffHunk as e, type DiffLine as f, type DiffResult as g, type DiffType as h, type DiffViewerLine as i, type EscapeMode as j, type FillerMatch as k, type FillerWordResult as l, type LineOp as m, type LineType as n, type LoremUnit as o, type MarkdownResult as p, type MorseOptions as q, type ParsedTable as r, type PassiveVoiceMatch as s, text as t, type PassiveVoiceResult as u, type PassiveVoiceSentence as v, type ReadabilityScore as w, type StringDistanceMode as x, type StringDistanceResult as y, type TextAnalysis as z };
457
+ export { detectFillerWords as $, type AsciiFont as A, type StringDistanceResult as B, CASE_FORMATS as C, DEFAULT_CONVERT_OPTIONS as D, ESCAPE_MODES as E, type FillerCategory as F, type TextAnalysis as G, addBorder as H, analyzeSentenceLengths as I, analyzeText as J, applyOp as K, LINE_OPS as L, MORSE_CODE as M, applyOps as N, calculateStringDistance as O, type ParsedDiff as P, centerText as Q, type ReadabilityResult as R, type SentenceLengthBucket as S, type TableOptions as T, convertAll as U, convertCase as V, type WordCountResult as W, countWords as X, csvToHtml as Y, csvToMarkdown as Z, detectDelimiter as _, type AsciiOptions as a, detectPassiveVoice as a0, diffLines as a1, diffLinesSimple as a2, diffStats as a3, escapeAll as a4, escapeString as a5, extractHeadings as a6, formatReadingTime as a7, generate as a8, generateDiff as a9, textToAscii as aA, textToMorse as aB, unescapeString as aC, wordFrequency as aD, generateHtmlTable as aa, generateMarkdownTable as ab, generateParagraphs as ac, generateSentences as ad, generateWords as ae, getAvailableFonts as af, getMorseForChar as ag, getMorseTiming as ah, htmlToMarkdown as ai, isValidMorse as aj, markdownToHtml as ak, morseToText as al, numberToOrdinal as am, numberToRoman as an, numberToWords as ao, ordinalWords as ap, parseDiff as aq, parseTableData as ar, readabilityScore as as, renderMarkdown as at, romanToNumber as au, scoreReadability as av, sentenceCount as aw, slugify as ax, slugifyAll as ay, syllableCount as az, type CaseFormat as b, type ConvertOptions as c, type DiffFile as d, type DiffHunk as e, type DiffLine as f, type DiffResult as g, type DiffType as h, type DiffViewerLine as i, type EscapeMode as j, type FillerMatch as k, type FillerWordResult as l, type LineOp as m, type LineType as n, type LoremUnit as o, type MarkdownResult as p, type MorseOptions as q, type ParsedTable as r, type PassiveVoiceMatch as s, text as t, type PassiveVoiceResult as u, type PassiveVoiceSentence as v, type ReadabilityScore as w, type SentenceLengthDistribution as x, type SlugSeparator as y, type StringDistanceMode as z };
@@ -946,6 +946,29 @@ function vectorSimilarity(a, b) {
946
946
  magnitudeB: round6(magB)
947
947
  };
948
948
  }
949
+ function formatFewShotExamples(examples, format = "numbered", delimiter = "---") {
950
+ const valid = (examples ?? []).filter((e) => e?.input?.trim() && e?.output?.trim());
951
+ if (valid.length === 0) {
952
+ return { formatted: "", exampleCount: 0, format };
953
+ }
954
+ let formatted;
955
+ if (format === "xml") {
956
+ formatted = valid.map((e) => `<example>
957
+ <input>${e.input.trim()}</input>
958
+ <output>${e.output.trim()}</output>
959
+ </example>`).join("\n\n");
960
+ } else if (format === "delimiter") {
961
+ formatted = valid.map((e) => `Input: ${e.input.trim()}
962
+ Output: ${e.output.trim()}`).join(`
963
+ ${delimiter}
964
+ `);
965
+ } else {
966
+ formatted = valid.map((e, i) => `Example ${i + 1}:
967
+ Input: ${e.input.trim()}
968
+ Output: ${e.output.trim()}`).join("\n\n");
969
+ }
970
+ return { formatted, exampleCount: valid.length, format };
971
+ }
949
972
 
950
973
  exports.MODEL_PRICING = MODEL_PRICING;
951
974
  exports.chunkText = chunkText;
@@ -966,6 +989,7 @@ exports.extractKeywords = extractKeywords;
966
989
  exports.extractTables = extractTables;
967
990
  exports.extractUrls = extractUrls;
968
991
  exports.flattenJson = flattenJson;
992
+ exports.formatFewShotExamples = formatFewShotExamples;
969
993
  exports.mergeJson = mergeJson;
970
994
  exports.redactPii = redactPii;
971
995
  exports.repairJson = repairJson;
@@ -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 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';
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, F as FewShotExample, n as FewShotFormat, o as FewShotFormatResult, I as InjectionDetectResult, p as InjectionFinding, J as JsonBlock, q as JsonRepairResult, K as Keyword, M as MODEL_PRICING, r as MergeResult, s as MergeStrategy, t as ModelPricing, P as PiiDetectResult, u as PiiFinding, v as PiiType, R as RankedChunk, w as RelevanceResult, S as SanitizeResult, x as SecretDetectResult, y as SecretFinding, z as SecretType, A as SummaryResult, T as TableResult2, B as TextChunk, G as TokenEstimate, H as TokenEstimateResult, L as TrimResult, N as TrimStrategy, U as UrlMatch, V as ValidationError, O as ValidationResult, Q as VectorSimilarityResult, W as chunkText, X as compressHtml, Y as compressJson, Z as compressMarkdown, _ as deduplicateLines, $ as detectPii, a0 as detectPromptInjection, a1 as detectSecrets, a2 as diffJson, a3 as estimateCost, a4 as estimateTokens, a5 as expandQuery, a6 as extractEntities, a7 as extractJson, a8 as extractKeywords, a9 as extractTables, aa as extractUrls, ab as flattenJson, ac as formatFewShotExamples, ad as mergeJson, ae as redactPii, af as repairJson, ag as rerankChunks, ah as sanitizeHtml, ai as scoreRelevance, aj as summarizeForLlm, ak as trimToTokens, al as unflattenJson, am as validateJsonSchema, an as vectorSimilarity } from '../ai_agent-C1zudGgT.cjs';