poe-code 3.0.348 → 3.0.349
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 +51 -13
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/dist/services/llm-client.js +54 -15
- package/dist/services/llm-client.js.map +1 -1
- package/package.json +1 -1
- package/packages/package-lint/dist/model.d.ts +1 -0
- package/packages/package-lint/dist/model.js +2 -1
- package/packages/package-lint/dist/rules/index.js +3 -1
- package/packages/package-lint/dist/rules/package-readme-required.d.ts +2 -0
- package/packages/package-lint/dist/rules/package-readme-required.js +21 -0
package/dist/index.js
CHANGED
|
@@ -79568,9 +79568,9 @@ function createPoeClient(options) {
|
|
|
79568
79568
|
const data = await requestCompletion(httpClient, options.baseUrl, options.apiKey, request);
|
|
79569
79569
|
return { content: extractTextContent(data) };
|
|
79570
79570
|
},
|
|
79571
|
-
async media(
|
|
79571
|
+
async media(type, request) {
|
|
79572
79572
|
const data = await requestCompletion(httpClient, options.baseUrl, options.apiKey, request);
|
|
79573
|
-
return extractMediaFromCompletion(data);
|
|
79573
|
+
return extractMediaFromCompletion(type, data);
|
|
79574
79574
|
}
|
|
79575
79575
|
};
|
|
79576
79576
|
}
|
|
@@ -79634,7 +79634,7 @@ function extractTextContent(data) {
|
|
|
79634
79634
|
if (!isRecord32(message2)) return void 0;
|
|
79635
79635
|
return typeof message2.content === "string" ? message2.content : void 0;
|
|
79636
79636
|
}
|
|
79637
|
-
function extractMediaFromCompletion(data) {
|
|
79637
|
+
function extractMediaFromCompletion(type, data) {
|
|
79638
79638
|
const content = extractTextContent(data);
|
|
79639
79639
|
if (!content) return {};
|
|
79640
79640
|
try {
|
|
@@ -79657,20 +79657,58 @@ function extractMediaFromCompletion(data) {
|
|
|
79657
79657
|
if (isValidUrl(content.trim())) {
|
|
79658
79658
|
return { url: content.trim() };
|
|
79659
79659
|
}
|
|
79660
|
-
const markdownUrl =
|
|
79660
|
+
const markdownUrl = extractMarkdownMediaUrl(content, type);
|
|
79661
79661
|
if (markdownUrl) {
|
|
79662
79662
|
return { url: markdownUrl };
|
|
79663
79663
|
}
|
|
79664
79664
|
return { content };
|
|
79665
79665
|
}
|
|
79666
|
-
function
|
|
79667
|
-
|
|
79668
|
-
|
|
79669
|
-
|
|
79670
|
-
|
|
79671
|
-
|
|
79672
|
-
|
|
79673
|
-
|
|
79666
|
+
function extractMarkdownMediaUrl(content, type) {
|
|
79667
|
+
let searchFrom = 0;
|
|
79668
|
+
while (searchFrom < content.length) {
|
|
79669
|
+
const openLabel = content.indexOf("[", searchFrom);
|
|
79670
|
+
if (openLabel === -1) return void 0;
|
|
79671
|
+
const closeLabel = content.indexOf("](", openLabel);
|
|
79672
|
+
if (closeLabel === -1) return void 0;
|
|
79673
|
+
const urlStart = closeLabel + 2;
|
|
79674
|
+
const urlEnd = content.indexOf(")", urlStart);
|
|
79675
|
+
if (urlEnd === -1) return void 0;
|
|
79676
|
+
const label = content.slice(openLabel + 1, closeLabel);
|
|
79677
|
+
const url = content.slice(urlStart, urlEnd);
|
|
79678
|
+
const isImageMarkdown = openLabel > 0 && content[openLabel - 1] === "!";
|
|
79679
|
+
if (isValidUrl(url) && isGeneratedMediaLabel(label, type, isImageMarkdown)) {
|
|
79680
|
+
return url;
|
|
79681
|
+
}
|
|
79682
|
+
searchFrom = urlEnd + 1;
|
|
79683
|
+
}
|
|
79684
|
+
return void 0;
|
|
79685
|
+
}
|
|
79686
|
+
function isGeneratedMediaLabel(label, type, isImageMarkdown) {
|
|
79687
|
+
if (type === "image" && isImageMarkdown) {
|
|
79688
|
+
return true;
|
|
79689
|
+
}
|
|
79690
|
+
return labelTokens(label).includes(type);
|
|
79691
|
+
}
|
|
79692
|
+
function labelTokens(label) {
|
|
79693
|
+
const tokens = [];
|
|
79694
|
+
let current = "";
|
|
79695
|
+
for (const char of label.toLowerCase()) {
|
|
79696
|
+
const code = char.charCodeAt(0);
|
|
79697
|
+
const isAsciiLetter7 = code >= 97 && code <= 122;
|
|
79698
|
+
const isAsciiDigit2 = code >= 48 && code <= 57;
|
|
79699
|
+
if (isAsciiLetter7 || isAsciiDigit2) {
|
|
79700
|
+
current += char;
|
|
79701
|
+
continue;
|
|
79702
|
+
}
|
|
79703
|
+
if (current.length > 0) {
|
|
79704
|
+
tokens.push(current);
|
|
79705
|
+
current = "";
|
|
79706
|
+
}
|
|
79707
|
+
}
|
|
79708
|
+
if (current.length > 0) {
|
|
79709
|
+
tokens.push(current);
|
|
79710
|
+
}
|
|
79711
|
+
return tokens;
|
|
79674
79712
|
}
|
|
79675
79713
|
function isValidUrl(value) {
|
|
79676
79714
|
try {
|
|
@@ -138543,7 +138581,7 @@ var init_package2 = __esm({
|
|
|
138543
138581
|
"package.json"() {
|
|
138544
138582
|
package_default2 = {
|
|
138545
138583
|
name: "poe-code",
|
|
138546
|
-
version: "3.0.
|
|
138584
|
+
version: "3.0.349",
|
|
138547
138585
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
138548
138586
|
type: "module",
|
|
138549
138587
|
main: "./dist/index.js",
|