@runtypelabs/cli 2.32.1 → 2.32.2
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/dist/index.js +349 -274
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -17017,6 +17017,353 @@ var artifactSSEEventSchema = external_exports.discriminatedUnion("type", [
|
|
|
17017
17017
|
]);
|
|
17018
17018
|
var UNIFIED_SSE_EVENT_TYPE_SET = new Set(UNIFIED_SSE_EVENT_TYPES);
|
|
17019
17019
|
|
|
17020
|
+
// ../shared/dist/chunk-REUID6D4.mjs
|
|
17021
|
+
function parseHTMLWithRegex(html) {
|
|
17022
|
+
if (typeof html !== "string") {
|
|
17023
|
+
throw new Error("parseHTML: input must be a string");
|
|
17024
|
+
}
|
|
17025
|
+
try {
|
|
17026
|
+
const parser = {
|
|
17027
|
+
stripTags(value) {
|
|
17028
|
+
return value.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
|
|
17029
|
+
},
|
|
17030
|
+
querySelector(selector) {
|
|
17031
|
+
try {
|
|
17032
|
+
const tag = selector.replace(/[^a-zA-Z0-9-]/g, "");
|
|
17033
|
+
const match = html.match(new RegExp("<" + tag + "[^>]*>(.*?)<\\/" + tag + ">", "is"));
|
|
17034
|
+
return match ? parser.stripTags(match[1]).trim() || null : null;
|
|
17035
|
+
} catch {
|
|
17036
|
+
return null;
|
|
17037
|
+
}
|
|
17038
|
+
},
|
|
17039
|
+
querySelectorAll(selector) {
|
|
17040
|
+
try {
|
|
17041
|
+
const tag = selector.replace(/[^a-zA-Z0-9-]/g, "");
|
|
17042
|
+
const regex = new RegExp("<" + tag + "[^>]*>(.*?)<\\/" + tag + ">", "gis");
|
|
17043
|
+
const results = [];
|
|
17044
|
+
let match;
|
|
17045
|
+
while ((match = regex.exec(html)) !== null) {
|
|
17046
|
+
const value = parser.stripTags(match[1]).trim();
|
|
17047
|
+
if (value) results.push(value);
|
|
17048
|
+
}
|
|
17049
|
+
return results;
|
|
17050
|
+
} catch {
|
|
17051
|
+
return [];
|
|
17052
|
+
}
|
|
17053
|
+
}
|
|
17054
|
+
};
|
|
17055
|
+
const titleMatch = html.match(/<title[^>]*>(.*?)<\/title>/is);
|
|
17056
|
+
const title = titleMatch ? parser.stripTags(titleMatch[1]).trim() || void 0 : void 0;
|
|
17057
|
+
const headingRegex = /<h[1-6][^>]*>(.*?)<\/h[1-6]>/gis;
|
|
17058
|
+
const headings = [];
|
|
17059
|
+
let headingMatch;
|
|
17060
|
+
while ((headingMatch = headingRegex.exec(html)) !== null) {
|
|
17061
|
+
const text2 = parser.stripTags(headingMatch[1]).trim();
|
|
17062
|
+
if (text2) headings.push(text2);
|
|
17063
|
+
}
|
|
17064
|
+
const linkRegex = /<a\s[^>]*href=["']([^"']*)["'][^>]*>(.*?)<\/a>/gis;
|
|
17065
|
+
const links = [];
|
|
17066
|
+
let linkMatch;
|
|
17067
|
+
while ((linkMatch = linkRegex.exec(html)) !== null) {
|
|
17068
|
+
const href = linkMatch[1];
|
|
17069
|
+
const text2 = parser.stripTags(linkMatch[2]).trim();
|
|
17070
|
+
if (href) links.push({ href, text: text2 });
|
|
17071
|
+
}
|
|
17072
|
+
const text = parser.stripTags(html);
|
|
17073
|
+
return {
|
|
17074
|
+
title,
|
|
17075
|
+
headings,
|
|
17076
|
+
links,
|
|
17077
|
+
text,
|
|
17078
|
+
querySelector: parser.querySelector,
|
|
17079
|
+
querySelectorAll: parser.querySelectorAll
|
|
17080
|
+
};
|
|
17081
|
+
} catch (error51) {
|
|
17082
|
+
throw new Error(
|
|
17083
|
+
`parseHTML failed: ${error51 instanceof Error ? error51.message : "Unknown error"}`,
|
|
17084
|
+
{
|
|
17085
|
+
cause: error51
|
|
17086
|
+
}
|
|
17087
|
+
);
|
|
17088
|
+
}
|
|
17089
|
+
}
|
|
17090
|
+
function createPortableHelpers(parseHTML) {
|
|
17091
|
+
return {
|
|
17092
|
+
parseHTML,
|
|
17093
|
+
/**
|
|
17094
|
+
* Extract email addresses from text
|
|
17095
|
+
* @param text Text to search for emails
|
|
17096
|
+
* @returns Array of found email addresses
|
|
17097
|
+
*/
|
|
17098
|
+
extractEmails(text) {
|
|
17099
|
+
if (typeof text !== "string") {
|
|
17100
|
+
return [];
|
|
17101
|
+
}
|
|
17102
|
+
const emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
|
|
17103
|
+
const matches = text.match(emailRegex);
|
|
17104
|
+
return matches ? [...new Set(matches)] : [];
|
|
17105
|
+
},
|
|
17106
|
+
/**
|
|
17107
|
+
* Extract URLs from text
|
|
17108
|
+
* @param text Text to search for URLs
|
|
17109
|
+
* @returns Array of found URLs
|
|
17110
|
+
*/
|
|
17111
|
+
extractURLs(text) {
|
|
17112
|
+
if (typeof text !== "string") {
|
|
17113
|
+
return [];
|
|
17114
|
+
}
|
|
17115
|
+
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/g;
|
|
17116
|
+
const matches = text.match(urlRegex);
|
|
17117
|
+
return matches ? [...new Set(matches)] : [];
|
|
17118
|
+
},
|
|
17119
|
+
/**
|
|
17120
|
+
* Extract phone numbers from text
|
|
17121
|
+
* @param text Text to search for phone numbers
|
|
17122
|
+
* @returns Array of found phone numbers
|
|
17123
|
+
*/
|
|
17124
|
+
extractPhoneNumbers(text) {
|
|
17125
|
+
if (typeof text !== "string") {
|
|
17126
|
+
return [];
|
|
17127
|
+
}
|
|
17128
|
+
const phoneRegex = /(?:\+?1[-.\s]?)?(?:\([0-9]{3}\)|[0-9]{3})[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}/g;
|
|
17129
|
+
const matches = text.match(phoneRegex);
|
|
17130
|
+
return matches ? [...new Set(matches)] : [];
|
|
17131
|
+
},
|
|
17132
|
+
/**
|
|
17133
|
+
* Truncate text to specified length with ellipsis
|
|
17134
|
+
* @param text Text to truncate
|
|
17135
|
+
* @param length Maximum length
|
|
17136
|
+
* @returns Truncated text
|
|
17137
|
+
*/
|
|
17138
|
+
truncate(text, length) {
|
|
17139
|
+
if (typeof text !== "string" || typeof length !== "number") {
|
|
17140
|
+
return text || "";
|
|
17141
|
+
}
|
|
17142
|
+
if (text.length <= length) {
|
|
17143
|
+
return text;
|
|
17144
|
+
}
|
|
17145
|
+
return text.substring(0, length).trim() + "...";
|
|
17146
|
+
},
|
|
17147
|
+
/**
|
|
17148
|
+
* Create URL-friendly slug from text
|
|
17149
|
+
* @param text Text to slugify
|
|
17150
|
+
* @returns URL-friendly slug
|
|
17151
|
+
*/
|
|
17152
|
+
slugify(text) {
|
|
17153
|
+
if (typeof text !== "string") {
|
|
17154
|
+
return "";
|
|
17155
|
+
}
|
|
17156
|
+
return text.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
17157
|
+
},
|
|
17158
|
+
/**
|
|
17159
|
+
* Convert Markdown to HTML (basic conversion)
|
|
17160
|
+
* @param markdown Markdown text
|
|
17161
|
+
* @returns HTML string
|
|
17162
|
+
*/
|
|
17163
|
+
markdown2html(markdown) {
|
|
17164
|
+
if (typeof markdown !== "string") {
|
|
17165
|
+
return "";
|
|
17166
|
+
}
|
|
17167
|
+
return markdown.replace(/^### (.*$)/gim, "<h3>$1</h3>").replace(/^## (.*$)/gim, "<h2>$1</h2>").replace(/^# (.*$)/gim, "<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim, "<strong>$1</strong>").replace(/__(.*?)__/gim, "<strong>$1</strong>").replace(/\*(.*?)\*/gim, "<em>$1</em>").replace(/_(.*?)_/gim, "<em>$1</em>").replace(/`(.*?)`/gim, "<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim, '<a href="$2">$1</a>').replace(/\n\n/gim, "</p><p>").replace(/\n/gim, "<br>").replace(/^(?!<[h|u|o|l])/gim, "<p>").replace(/$/gim, "</p>").replace(/<p><\/p>/gim, "").replace(/<p>(<h[1-6]>.*<\/h[1-6]>)<\/p>/gim, "$1");
|
|
17168
|
+
},
|
|
17169
|
+
/**
|
|
17170
|
+
* Convert HTML to Markdown (basic conversion)
|
|
17171
|
+
* @param html HTML string
|
|
17172
|
+
* @returns Markdown text
|
|
17173
|
+
*/
|
|
17174
|
+
html2markdown(html) {
|
|
17175
|
+
if (typeof html !== "string") {
|
|
17176
|
+
return "";
|
|
17177
|
+
}
|
|
17178
|
+
return html.replace(/<h1[^>]*>(.*?)<\/h1>/gim, "# $1\n\n").replace(/<h2[^>]*>(.*?)<\/h2>/gim, "## $1\n\n").replace(/<h3[^>]*>(.*?)<\/h3>/gim, "### $1\n\n").replace(/<h4[^>]*>(.*?)<\/h4>/gim, "#### $1\n\n").replace(/<h5[^>]*>(.*?)<\/h5>/gim, "##### $1\n\n").replace(/<h6[^>]*>(.*?)<\/h6>/gim, "###### $1\n\n").replace(/<strong[^>]*>(.*?)<\/strong>/gim, "**$1**").replace(/<b[^>]*>(.*?)<\/b>/gim, "**$1**").replace(/<em[^>]*>(.*?)<\/em>/gim, "*$1*").replace(/<i[^>]*>(.*?)<\/i>/gim, "*$1*").replace(/<code[^>]*>(.*?)<\/code>/gim, "`$1`").replace(/<a[^>]*href="([^"]*)"[^>]*>(.*?)<\/a>/gim, "[$2]($1)").replace(/<br[^>]*>/gim, "\n").replace(/<\/p>/gim, "\n\n").replace(/<p[^>]*>/gim, "").replace(/<li[^>]*>(.*?)<\/li>/gim, "- $1\n").replace(/<ul[^>]*>/gim, "\n").replace(/<\/ul>/gim, "\n").replace(/<ol[^>]*>/gim, "\n").replace(/<\/ol>/gim, "\n").replace(/<[^>]+>/gim, "").replace(/\n\s*\n\s*\n/gim, "\n\n").trim();
|
|
17179
|
+
},
|
|
17180
|
+
/**
|
|
17181
|
+
* Parse date from various string formats
|
|
17182
|
+
* @param dateStr Date string to parse
|
|
17183
|
+
* @returns Date object or null if invalid
|
|
17184
|
+
*/
|
|
17185
|
+
parseDate(dateStr) {
|
|
17186
|
+
if (typeof dateStr !== "string") {
|
|
17187
|
+
return null;
|
|
17188
|
+
}
|
|
17189
|
+
try {
|
|
17190
|
+
const date5 = new Date(dateStr);
|
|
17191
|
+
return isNaN(date5.getTime()) ? null : date5;
|
|
17192
|
+
} catch {
|
|
17193
|
+
return null;
|
|
17194
|
+
}
|
|
17195
|
+
},
|
|
17196
|
+
/**
|
|
17197
|
+
* Format date according to specified format
|
|
17198
|
+
* @param date Date object or string
|
|
17199
|
+
* @param format Format string (simple patterns)
|
|
17200
|
+
* @returns Formatted date string
|
|
17201
|
+
*/
|
|
17202
|
+
formatDate(date5, format) {
|
|
17203
|
+
const defaultFormat = format || "YYYY-MM-DD";
|
|
17204
|
+
let dateObj;
|
|
17205
|
+
if (typeof date5 === "string") {
|
|
17206
|
+
dateObj = new Date(date5);
|
|
17207
|
+
} else if (date5 instanceof Date) {
|
|
17208
|
+
dateObj = date5;
|
|
17209
|
+
} else {
|
|
17210
|
+
return "";
|
|
17211
|
+
}
|
|
17212
|
+
if (isNaN(dateObj.getTime())) {
|
|
17213
|
+
return "";
|
|
17214
|
+
}
|
|
17215
|
+
const year = dateObj.getFullYear();
|
|
17216
|
+
const month = String(dateObj.getMonth() + 1).padStart(2, "0");
|
|
17217
|
+
const day = String(dateObj.getDate()).padStart(2, "0");
|
|
17218
|
+
const hours = String(dateObj.getHours()).padStart(2, "0");
|
|
17219
|
+
const minutes = String(dateObj.getMinutes()).padStart(2, "0");
|
|
17220
|
+
const seconds = String(dateObj.getSeconds()).padStart(2, "0");
|
|
17221
|
+
return defaultFormat.replace(/YYYY/g, String(year)).replace(/MM/g, month).replace(/DD/g, day).replace(/HH/g, hours).replace(/mm/g, minutes).replace(/ss/g, seconds);
|
|
17222
|
+
},
|
|
17223
|
+
/**
|
|
17224
|
+
* Add days to a date
|
|
17225
|
+
* @param date Date object or string
|
|
17226
|
+
* @param days Number of days to add (can be negative)
|
|
17227
|
+
* @returns New Date object
|
|
17228
|
+
*/
|
|
17229
|
+
addDays(date5, days) {
|
|
17230
|
+
let dateObj;
|
|
17231
|
+
if (typeof date5 === "string") {
|
|
17232
|
+
dateObj = new Date(date5);
|
|
17233
|
+
} else if (date5 instanceof Date) {
|
|
17234
|
+
dateObj = new Date(date5.getTime());
|
|
17235
|
+
} else {
|
|
17236
|
+
return null;
|
|
17237
|
+
}
|
|
17238
|
+
if (isNaN(dateObj.getTime()) || typeof days !== "number") {
|
|
17239
|
+
return null;
|
|
17240
|
+
}
|
|
17241
|
+
dateObj.setDate(dateObj.getDate() + days);
|
|
17242
|
+
return dateObj;
|
|
17243
|
+
},
|
|
17244
|
+
/**
|
|
17245
|
+
* Validate email address format
|
|
17246
|
+
* @param email Email address to validate
|
|
17247
|
+
* @returns True if valid email format
|
|
17248
|
+
*/
|
|
17249
|
+
isValidEmail(email3) {
|
|
17250
|
+
if (typeof email3 !== "string") {
|
|
17251
|
+
return false;
|
|
17252
|
+
}
|
|
17253
|
+
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
17254
|
+
return emailRegex.test(email3);
|
|
17255
|
+
},
|
|
17256
|
+
/**
|
|
17257
|
+
* Validate URL format
|
|
17258
|
+
* @param url URL to validate
|
|
17259
|
+
* @returns True if valid URL format
|
|
17260
|
+
*/
|
|
17261
|
+
isValidURL(url2) {
|
|
17262
|
+
if (typeof url2 !== "string") {
|
|
17263
|
+
return false;
|
|
17264
|
+
}
|
|
17265
|
+
try {
|
|
17266
|
+
new URL(url2);
|
|
17267
|
+
return true;
|
|
17268
|
+
} catch {
|
|
17269
|
+
return false;
|
|
17270
|
+
}
|
|
17271
|
+
},
|
|
17272
|
+
/**
|
|
17273
|
+
* Validate JSON string
|
|
17274
|
+
* @param str String to validate as JSON
|
|
17275
|
+
* @returns True if valid JSON
|
|
17276
|
+
*/
|
|
17277
|
+
isValidJSON(str) {
|
|
17278
|
+
if (typeof str !== "string") {
|
|
17279
|
+
return false;
|
|
17280
|
+
}
|
|
17281
|
+
try {
|
|
17282
|
+
JSON.parse(str);
|
|
17283
|
+
return true;
|
|
17284
|
+
} catch {
|
|
17285
|
+
return false;
|
|
17286
|
+
}
|
|
17287
|
+
},
|
|
17288
|
+
/**
|
|
17289
|
+
* Encode string to base64
|
|
17290
|
+
* @param str String to encode
|
|
17291
|
+
* @returns Base64 encoded string
|
|
17292
|
+
*/
|
|
17293
|
+
base64Encode(str) {
|
|
17294
|
+
if (typeof str !== "string") {
|
|
17295
|
+
return "";
|
|
17296
|
+
}
|
|
17297
|
+
try {
|
|
17298
|
+
return btoa(str);
|
|
17299
|
+
} catch {
|
|
17300
|
+
return btoa(unescape(encodeURIComponent(str)));
|
|
17301
|
+
}
|
|
17302
|
+
},
|
|
17303
|
+
/**
|
|
17304
|
+
* Decode base64 string
|
|
17305
|
+
* @param str Base64 string to decode
|
|
17306
|
+
* @returns Decoded string
|
|
17307
|
+
*/
|
|
17308
|
+
base64Decode(str) {
|
|
17309
|
+
if (typeof str !== "string") {
|
|
17310
|
+
return "";
|
|
17311
|
+
}
|
|
17312
|
+
try {
|
|
17313
|
+
return atob(str);
|
|
17314
|
+
} catch {
|
|
17315
|
+
try {
|
|
17316
|
+
return decodeURIComponent(escape(atob(str)));
|
|
17317
|
+
} catch {
|
|
17318
|
+
return "";
|
|
17319
|
+
}
|
|
17320
|
+
}
|
|
17321
|
+
},
|
|
17322
|
+
/**
|
|
17323
|
+
* URL encode string
|
|
17324
|
+
* @param str String to encode
|
|
17325
|
+
* @returns URL encoded string
|
|
17326
|
+
*/
|
|
17327
|
+
urlEncode(str) {
|
|
17328
|
+
if (typeof str !== "string") {
|
|
17329
|
+
return "";
|
|
17330
|
+
}
|
|
17331
|
+
return encodeURIComponent(str);
|
|
17332
|
+
},
|
|
17333
|
+
/**
|
|
17334
|
+
* URL decode string
|
|
17335
|
+
* @param str URL encoded string to decode
|
|
17336
|
+
* @returns Decoded string
|
|
17337
|
+
*/
|
|
17338
|
+
urlDecode(str) {
|
|
17339
|
+
if (typeof str !== "string") {
|
|
17340
|
+
return "";
|
|
17341
|
+
}
|
|
17342
|
+
try {
|
|
17343
|
+
return decodeURIComponent(str);
|
|
17344
|
+
} catch {
|
|
17345
|
+
return str;
|
|
17346
|
+
}
|
|
17347
|
+
},
|
|
17348
|
+
/**
|
|
17349
|
+
* Return the first argument that is neither null nor undefined (a named
|
|
17350
|
+
* first-non-null / nullish coalesce). The script-side counterpart of the
|
|
17351
|
+
* `{{a ?? b}}` template operator — in templates prefer `{{a ?? b}}`; use
|
|
17352
|
+
* `helpers.coalesce(a, b)` inside transform-data scripts.
|
|
17353
|
+
* @param values Candidate values in priority order
|
|
17354
|
+
* @returns The first non-null/undefined value, or null if all are null/undefined
|
|
17355
|
+
*/
|
|
17356
|
+
coalesce(...values) {
|
|
17357
|
+
for (const value of values) {
|
|
17358
|
+
if (value !== null && value !== void 0) {
|
|
17359
|
+
return value;
|
|
17360
|
+
}
|
|
17361
|
+
}
|
|
17362
|
+
return null;
|
|
17363
|
+
}
|
|
17364
|
+
};
|
|
17365
|
+
}
|
|
17366
|
+
|
|
17020
17367
|
// ../shared/dist/index.mjs
|
|
17021
17368
|
var FORMULA_TRIGGER = /^[=+\-@\t\r\n]/;
|
|
17022
17369
|
var STRICT_NUMBER = /^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;
|
|
@@ -22013,280 +22360,8 @@ function parseCreateFlowValidationInput(payload) {
|
|
|
22013
22360
|
};
|
|
22014
22361
|
}
|
|
22015
22362
|
var SERIALIZED_HELPERS_SOURCE = `
|
|
22016
|
-
// Transform helper functions
|
|
22017
|
-
const helpers = (
|
|
22018
|
-
// Regex-based HTML tag stripper for extracting text content
|
|
22019
|
-
const stripTags = (html) => html.replace(/<[^>]*>/g, ' ').replace(/\\s+/g, ' ').trim()
|
|
22020
|
-
|
|
22021
|
-
return {
|
|
22022
|
-
parseHTML: (html) => {
|
|
22023
|
-
if (typeof html !== 'string') throw new Error('parseHTML: input must be a string')
|
|
22024
|
-
try {
|
|
22025
|
-
// Extract title
|
|
22026
|
-
const titleMatch = html.match(/<title[^>]*>(.*?)<\\/title>/is)
|
|
22027
|
-
const title = titleMatch ? stripTags(titleMatch[1]).trim() || undefined : undefined
|
|
22028
|
-
|
|
22029
|
-
// Extract headings (h1-h6)
|
|
22030
|
-
const headingRegex = /<h[1-6][^>]*>(.*?)<\\/h[1-6]>/gis
|
|
22031
|
-
const headings = []
|
|
22032
|
-
let hMatch
|
|
22033
|
-
while ((hMatch = headingRegex.exec(html)) !== null) {
|
|
22034
|
-
const text = stripTags(hMatch[1]).trim()
|
|
22035
|
-
if (text) headings.push(text)
|
|
22036
|
-
}
|
|
22037
|
-
|
|
22038
|
-
// Extract links
|
|
22039
|
-
const linkRegex = /<a\\s[^>]*href=["']([^"']*)["'][^>]*>(.*?)<\\/a>/gis
|
|
22040
|
-
const links = []
|
|
22041
|
-
let lMatch
|
|
22042
|
-
while ((lMatch = linkRegex.exec(html)) !== null) {
|
|
22043
|
-
const href = lMatch[1]
|
|
22044
|
-
const text = stripTags(lMatch[2]).trim()
|
|
22045
|
-
if (href) links.push({ href, text })
|
|
22046
|
-
}
|
|
22047
|
-
|
|
22048
|
-
// Extract all text content
|
|
22049
|
-
const text = stripTags(html)
|
|
22050
|
-
|
|
22051
|
-
// Simple querySelector (CSS element selectors only)
|
|
22052
|
-
const querySelector = (selector) => {
|
|
22053
|
-
try {
|
|
22054
|
-
const tag = selector.replace(/[^a-zA-Z0-9-]/g, '')
|
|
22055
|
-
const match = html.match(new RegExp('<' + tag + '[^>]*>(.*?)<\\\\/' + tag + '>', 'is'))
|
|
22056
|
-
return match ? stripTags(match[1]).trim() || null : null
|
|
22057
|
-
} catch (error) {
|
|
22058
|
-
return null
|
|
22059
|
-
}
|
|
22060
|
-
}
|
|
22061
|
-
|
|
22062
|
-
// Simple querySelectorAll (CSS element selectors only)
|
|
22063
|
-
const querySelectorAll = (selector) => {
|
|
22064
|
-
try {
|
|
22065
|
-
const tag = selector.replace(/[^a-zA-Z0-9-]/g, '')
|
|
22066
|
-
const regex = new RegExp('<' + tag + '[^>]*>(.*?)<\\\\/' + tag + '>', 'gis')
|
|
22067
|
-
const results = []
|
|
22068
|
-
let m
|
|
22069
|
-
while ((m = regex.exec(html)) !== null) {
|
|
22070
|
-
const t = stripTags(m[1]).trim()
|
|
22071
|
-
if (t) results.push(t)
|
|
22072
|
-
}
|
|
22073
|
-
return results
|
|
22074
|
-
} catch (error) {
|
|
22075
|
-
return []
|
|
22076
|
-
}
|
|
22077
|
-
}
|
|
22078
|
-
|
|
22079
|
-
return { title, headings, links, text, querySelector, querySelectorAll }
|
|
22080
|
-
} catch (error) {
|
|
22081
|
-
throw new Error('parseHTML failed: ' + (error instanceof Error ? error.message : 'Unknown error'))
|
|
22082
|
-
}
|
|
22083
|
-
},
|
|
22084
|
-
|
|
22085
|
-
extractEmails: (text) => {
|
|
22086
|
-
if (typeof text !== 'string') return []
|
|
22087
|
-
const emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/g
|
|
22088
|
-
const matches = text.match(emailRegex)
|
|
22089
|
-
return matches ? [...new Set(matches)] : []
|
|
22090
|
-
},
|
|
22091
|
-
|
|
22092
|
-
extractURLs: (text) => {
|
|
22093
|
-
if (typeof text !== 'string') return []
|
|
22094
|
-
const urlRegex = /https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&/=]*)/g
|
|
22095
|
-
const matches = text.match(urlRegex)
|
|
22096
|
-
return matches ? [...new Set(matches)] : []
|
|
22097
|
-
},
|
|
22098
|
-
|
|
22099
|
-
extractPhoneNumbers: (text) => {
|
|
22100
|
-
if (typeof text !== 'string') return []
|
|
22101
|
-
const phoneRegex = /(?:\\+?1[-.\\s]?)?(?:\\([0-9]{3}\\)|[0-9]{3})[-.\\s]?[0-9]{3}[-.\\s]?[0-9]{4}/g
|
|
22102
|
-
const matches = text.match(phoneRegex)
|
|
22103
|
-
return matches ? [...new Set(matches)] : []
|
|
22104
|
-
},
|
|
22105
|
-
|
|
22106
|
-
truncate: (text, length) => {
|
|
22107
|
-
if (typeof text !== 'string' || typeof length !== 'number') return text || ''
|
|
22108
|
-
if (text.length <= length) return text
|
|
22109
|
-
return text.substring(0, length).trim() + '...'
|
|
22110
|
-
},
|
|
22111
|
-
|
|
22112
|
-
slugify: (text) => {
|
|
22113
|
-
if (typeof text !== 'string') return ''
|
|
22114
|
-
return text
|
|
22115
|
-
.toLowerCase()
|
|
22116
|
-
.trim()
|
|
22117
|
-
.replace(/[^\\w\\s-]/g, '')
|
|
22118
|
-
.replace(/[\\s_-]+/g, '-')
|
|
22119
|
-
.replace(/^-+|-+$/g, '')
|
|
22120
|
-
},
|
|
22121
|
-
|
|
22122
|
-
markdown2html: (markdown) => {
|
|
22123
|
-
if (typeof markdown !== 'string') return ''
|
|
22124
|
-
return markdown
|
|
22125
|
-
.replace(/^### (.*$)/gim, '<h3>$1</h3>')
|
|
22126
|
-
.replace(/^## (.*$)/gim, '<h2>$1</h2>')
|
|
22127
|
-
.replace(/^# (.*$)/gim, '<h1>$1</h1>')
|
|
22128
|
-
.replace(/\\*\\*(.*?)\\*\\*/gim, '<strong>$1</strong>')
|
|
22129
|
-
.replace(/__(.*?)__/gim, '<strong>$1</strong>')
|
|
22130
|
-
.replace(/\\*(.*?)\\*/gim, '<em>$1</em>')
|
|
22131
|
-
.replace(/_(.*?)_/gim, '<em>$1</em>')
|
|
22132
|
-
.replace(/\`(.*?)\`/gim, '<code>$1</code>')
|
|
22133
|
-
.replace(/\\[([^\\]]+)\\]\\(([^)]+)\\)/gim, '<a href="$2">$1</a>')
|
|
22134
|
-
.replace(/\\n\\n/gim, '</p><p>')
|
|
22135
|
-
.replace(/\\n/gim, '<br>')
|
|
22136
|
-
.replace(/^(?!<[h|u|o|l])/gim, '<p>')
|
|
22137
|
-
.replace(/$/gim, '</p>')
|
|
22138
|
-
.replace(/<p><\\/p>/gim, '')
|
|
22139
|
-
.replace(/<p>(<h[1-6]>.*<\\/h[1-6]>)<\\/p>/gim, '$1')
|
|
22140
|
-
},
|
|
22141
|
-
|
|
22142
|
-
html2markdown: (html) => {
|
|
22143
|
-
if (typeof html !== 'string') return ''
|
|
22144
|
-
return html
|
|
22145
|
-
.replace(/<h1[^>]*>(.*?)<\\/h1>/gim, '# $1\\n\\n')
|
|
22146
|
-
.replace(/<h2[^>]*>(.*?)<\\/h2>/gim, '## $1\\n\\n')
|
|
22147
|
-
.replace(/<h3[^>]*>(.*?)<\\/h3>/gim, '### $1\\n\\n')
|
|
22148
|
-
.replace(/<h4[^>]*>(.*?)<\\/h4>/gim, '#### $1\\n\\n')
|
|
22149
|
-
.replace(/<h5[^>]*>(.*?)<\\/h5>/gim, '##### $1\\n\\n')
|
|
22150
|
-
.replace(/<h6[^>]*>(.*?)<\\/h6>/gim, '###### $1\\n\\n')
|
|
22151
|
-
.replace(/<strong[^>]*>(.*?)<\\/strong>/gim, '**$1**')
|
|
22152
|
-
.replace(/<b[^>]*>(.*?)<\\/b>/gim, '**$1**')
|
|
22153
|
-
.replace(/<em[^>]*>(.*?)<\\/em>/gim, '*$1*')
|
|
22154
|
-
.replace(/<i[^>]*>(.*?)<\\/i>/gim, '*$1*')
|
|
22155
|
-
.replace(/<code[^>]*>(.*?)<\\/code>/gim, '\`$1\`')
|
|
22156
|
-
.replace(/<a[^>]*href="([^"]*)"[^>]*>(.*?)<\\/a>/gim, '[$2]($1)')
|
|
22157
|
-
.replace(/<br[^>]*>/gim, '\\n')
|
|
22158
|
-
.replace(/<\\/p>/gim, '\\n\\n')
|
|
22159
|
-
.replace(/<p[^>]*>/gim, '')
|
|
22160
|
-
.replace(/<li[^>]*>(.*?)<\\/li>/gim, '- $1\\n')
|
|
22161
|
-
.replace(/<ul[^>]*>/gim, '\\n')
|
|
22162
|
-
.replace(/<\\/ul>/gim, '\\n')
|
|
22163
|
-
.replace(/<ol[^>]*>/gim, '\\n')
|
|
22164
|
-
.replace(/<\\/ol>/gim, '\\n')
|
|
22165
|
-
.replace(/<[^>]+>/gim, '')
|
|
22166
|
-
.replace(/\\n\\s*\\n\\s*\\n/gim, '\\n\\n')
|
|
22167
|
-
.trim()
|
|
22168
|
-
},
|
|
22169
|
-
|
|
22170
|
-
parseDate: (dateStr) => {
|
|
22171
|
-
if (typeof dateStr !== 'string') return null
|
|
22172
|
-
try {
|
|
22173
|
-
const date = new Date(dateStr)
|
|
22174
|
-
return isNaN(date.getTime()) ? null : date
|
|
22175
|
-
} catch {
|
|
22176
|
-
return null
|
|
22177
|
-
}
|
|
22178
|
-
},
|
|
22179
|
-
|
|
22180
|
-
formatDate: (date, format) => {
|
|
22181
|
-
const defaultFormat = format || 'YYYY-MM-DD'
|
|
22182
|
-
let dateObj
|
|
22183
|
-
if (typeof date === 'string') {
|
|
22184
|
-
dateObj = new Date(date)
|
|
22185
|
-
} else if (date instanceof Date) {
|
|
22186
|
-
dateObj = date
|
|
22187
|
-
} else {
|
|
22188
|
-
return ''
|
|
22189
|
-
}
|
|
22190
|
-
if (isNaN(dateObj.getTime())) return ''
|
|
22191
|
-
const year = dateObj.getFullYear()
|
|
22192
|
-
const month = String(dateObj.getMonth() + 1).padStart(2, '0')
|
|
22193
|
-
const day = String(dateObj.getDate()).padStart(2, '0')
|
|
22194
|
-
const hours = String(dateObj.getHours()).padStart(2, '0')
|
|
22195
|
-
const minutes = String(dateObj.getMinutes()).padStart(2, '0')
|
|
22196
|
-
const seconds = String(dateObj.getSeconds()).padStart(2, '0')
|
|
22197
|
-
return defaultFormat
|
|
22198
|
-
.replace(/YYYY/g, String(year))
|
|
22199
|
-
.replace(/MM/g, month)
|
|
22200
|
-
.replace(/DD/g, day)
|
|
22201
|
-
.replace(/HH/g, hours)
|
|
22202
|
-
.replace(/mm/g, minutes)
|
|
22203
|
-
.replace(/ss/g, seconds)
|
|
22204
|
-
},
|
|
22205
|
-
|
|
22206
|
-
addDays: (date, days) => {
|
|
22207
|
-
let dateObj
|
|
22208
|
-
if (typeof date === 'string') {
|
|
22209
|
-
dateObj = new Date(date)
|
|
22210
|
-
} else if (date instanceof Date) {
|
|
22211
|
-
dateObj = new Date(date.getTime())
|
|
22212
|
-
} else {
|
|
22213
|
-
return null
|
|
22214
|
-
}
|
|
22215
|
-
if (isNaN(dateObj.getTime()) || typeof days !== 'number') return null
|
|
22216
|
-
dateObj.setDate(dateObj.getDate() + days)
|
|
22217
|
-
return dateObj
|
|
22218
|
-
},
|
|
22219
|
-
|
|
22220
|
-
isValidEmail: (email) => {
|
|
22221
|
-
if (typeof email !== 'string') return false
|
|
22222
|
-
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/
|
|
22223
|
-
return emailRegex.test(email)
|
|
22224
|
-
},
|
|
22225
|
-
|
|
22226
|
-
isValidURL: (url) => {
|
|
22227
|
-
if (typeof url !== 'string') return false
|
|
22228
|
-
try {
|
|
22229
|
-
new URL(url)
|
|
22230
|
-
return true
|
|
22231
|
-
} catch {
|
|
22232
|
-
return false
|
|
22233
|
-
}
|
|
22234
|
-
},
|
|
22235
|
-
|
|
22236
|
-
isValidJSON: (str) => {
|
|
22237
|
-
if (typeof str !== 'string') return false
|
|
22238
|
-
try {
|
|
22239
|
-
JSON.parse(str)
|
|
22240
|
-
return true
|
|
22241
|
-
} catch {
|
|
22242
|
-
return false
|
|
22243
|
-
}
|
|
22244
|
-
},
|
|
22245
|
-
|
|
22246
|
-
base64Encode: (str) => {
|
|
22247
|
-
if (typeof str !== 'string') return ''
|
|
22248
|
-
try {
|
|
22249
|
-
return btoa(str)
|
|
22250
|
-
} catch {
|
|
22251
|
-
return btoa(unescape(encodeURIComponent(str)))
|
|
22252
|
-
}
|
|
22253
|
-
},
|
|
22254
|
-
|
|
22255
|
-
base64Decode: (str) => {
|
|
22256
|
-
if (typeof str !== 'string') return ''
|
|
22257
|
-
try {
|
|
22258
|
-
return atob(str)
|
|
22259
|
-
} catch {
|
|
22260
|
-
try {
|
|
22261
|
-
return decodeURIComponent(escape(atob(str)))
|
|
22262
|
-
} catch {
|
|
22263
|
-
return ''
|
|
22264
|
-
}
|
|
22265
|
-
}
|
|
22266
|
-
},
|
|
22267
|
-
|
|
22268
|
-
urlEncode: (str) => {
|
|
22269
|
-
if (typeof str !== 'string') return ''
|
|
22270
|
-
return encodeURIComponent(str)
|
|
22271
|
-
},
|
|
22272
|
-
|
|
22273
|
-
urlDecode: (str) => {
|
|
22274
|
-
if (typeof str !== 'string') return ''
|
|
22275
|
-
try {
|
|
22276
|
-
return decodeURIComponent(str)
|
|
22277
|
-
} catch {
|
|
22278
|
-
return str
|
|
22279
|
-
}
|
|
22280
|
-
},
|
|
22281
|
-
|
|
22282
|
-
coalesce: (...values) => {
|
|
22283
|
-
for (const value of values) {
|
|
22284
|
-
if (value !== null && value !== undefined) return value
|
|
22285
|
-
}
|
|
22286
|
-
return null
|
|
22287
|
-
},
|
|
22288
|
-
}
|
|
22289
|
-
})()
|
|
22363
|
+
// Transform helper functions generated from the canonical portable factory.
|
|
22364
|
+
const helpers = (${createPortableHelpers.toString()})(${parseHTMLWithRegex.toString()})
|
|
22290
22365
|
`.trim();
|
|
22291
22366
|
var AGENT_EXECUTION_STATUSES = [
|
|
22292
22367
|
"queued",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/cli",
|
|
3
|
-
"version": "2.32.
|
|
3
|
+
"version": "2.32.2",
|
|
4
4
|
"description": "Command-line interface for Runtype AI platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"rosie-skills": "0.8.1",
|
|
28
28
|
"yaml": "^2.9.0",
|
|
29
29
|
"@runtypelabs/ink-components": "0.3.5",
|
|
30
|
-
"@runtypelabs/sdk": "6.3.
|
|
30
|
+
"@runtypelabs/sdk": "6.3.6",
|
|
31
31
|
"@runtypelabs/terminal-animations": "0.2.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"tsx": "^4.7.1",
|
|
44
44
|
"typescript": "^6.0.3",
|
|
45
45
|
"vitest": "^4.1.0",
|
|
46
|
-
"@runtypelabs/shared": "3.9.
|
|
46
|
+
"@runtypelabs/shared": "3.9.2"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=22.12.0"
|