@defai.digital/ax-cli 3.14.4 → 3.14.5
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.
|
@@ -10,6 +10,8 @@ import { processImageFromPath, formatBytes, ImageProcessingError, SUPPORTED_IMAG
|
|
|
10
10
|
const AT_REF_PATTERN = /@((?!https?:\/\/|ftp:\/\/|file:\/\/|data:)[^\s]+\.(png|jpg|jpeg|gif|webp)|"[^"]+\.(png|jpg|jpeg|gif|webp)"|'[^']+\.(png|jpg|jpeg|gif|webp)')/gi;
|
|
11
11
|
// Supports Unix (/path), relative (./path, ../path), Windows (C:\path), UNC (\\server\share), and quoted paths
|
|
12
12
|
const DIRECT_PATH_PATTERN = /^(\/[^\s]+\.(png|jpg|jpeg|gif|webp)|\.\.?\/[^\s]+\.(png|jpg|jpeg|gif|webp)|[a-zA-Z]:[\\/][^\s]+\.(png|jpg|jpeg|gif|webp)|\\\\[^\s]+\.(png|jpg|jpeg|gif|webp)|"[^"]+\.(png|jpg|jpeg|gif|webp)"|'[^']+\.(png|jpg|jpeg|gif|webp)')$/i;
|
|
13
|
+
// Inline quoted paths without @ prefix - allows "path.png" or 'path.png' anywhere in text
|
|
14
|
+
const INLINE_QUOTED_PATH_PATTERN = /(?:^|(?<=\s))("[^"]+\.(png|jpg|jpeg|gif|webp)"|'[^']+\.(png|jpg|jpeg|gif|webp)')/gi;
|
|
13
15
|
/** Strip surrounding quotes from a path */
|
|
14
16
|
function stripQuotes(p) {
|
|
15
17
|
if ((p.startsWith('"') && p.endsWith('"')) || (p.startsWith("'") && p.endsWith("'"))) {
|
|
@@ -24,6 +26,7 @@ export async function parseImageInput(input, workingDir = process.cwd()) {
|
|
|
24
26
|
let textContent = input;
|
|
25
27
|
const seenPaths = new Set(); // Track by resolved path to avoid duplicates
|
|
26
28
|
const pathToIndex = new Map(); // Map resolved path to image index
|
|
29
|
+
// Process @-prefixed image references
|
|
27
30
|
for (const [fullMatch, relativePath] of input.matchAll(AT_REF_PATTERN)) {
|
|
28
31
|
try {
|
|
29
32
|
const cleanPath = stripQuotes(relativePath);
|
|
@@ -46,6 +49,28 @@ export async function parseImageInput(input, workingDir = process.cwd()) {
|
|
|
46
49
|
errors.push(`${fullMatch}: ${error instanceof ImageProcessingError ? error.message : 'Failed to process'}`);
|
|
47
50
|
}
|
|
48
51
|
}
|
|
52
|
+
// Process inline quoted paths without @ prefix (e.g., '/path/to/image.png' or "/path/to/image.png")
|
|
53
|
+
for (const [fullMatch] of textContent.matchAll(INLINE_QUOTED_PATH_PATTERN)) {
|
|
54
|
+
try {
|
|
55
|
+
const cleanPath = stripQuotes(fullMatch.trim());
|
|
56
|
+
const image = await processImageFromPath(cleanPath, workingDir);
|
|
57
|
+
const resolvedPath = image.originalPath;
|
|
58
|
+
if (seenPaths.has(resolvedPath)) {
|
|
59
|
+
const existingIndex = pathToIndex.get(resolvedPath);
|
|
60
|
+
const name = path.basename(cleanPath);
|
|
61
|
+
textContent = textContent.split(fullMatch).join(`[Image #${existingIndex}: ${name}]`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
seenPaths.add(resolvedPath);
|
|
65
|
+
const name = path.basename(cleanPath);
|
|
66
|
+
images.push({ image, preview: `[Image: ${name}]`, originalReference: fullMatch });
|
|
67
|
+
pathToIndex.set(resolvedPath, images.length);
|
|
68
|
+
textContent = textContent.split(fullMatch).join(`[Image #${images.length}: ${name}]`);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
errors.push(`${fullMatch}: ${error instanceof ImageProcessingError ? error.message : 'Failed to process'}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
49
74
|
// Handle direct file path as entire input
|
|
50
75
|
const trimmed = input.trim();
|
|
51
76
|
if (!images.length && DIRECT_PATH_PATTERN.test(trimmed)) {
|
|
@@ -65,9 +90,11 @@ export async function parseImageInput(input, workingDir = process.cwd()) {
|
|
|
65
90
|
}
|
|
66
91
|
// Quick check for @ references (unquoted or quoted)
|
|
67
92
|
const AT_REF_CHECK = /@(?:(?!https?:\/\/|ftp:\/\/|file:\/\/|data:)[^\s]+\.(png|jpg|jpeg|gif|webp)|"[^"]+\.(png|jpg|jpeg|gif|webp)"|'[^']+\.(png|jpg|jpeg|gif|webp)')/i;
|
|
93
|
+
// Quick check for inline quoted paths
|
|
94
|
+
const INLINE_QUOTED_CHECK = /(?:^|\s)("[^"]+\.(png|jpg|jpeg|gif|webp)"|'[^']+\.(png|jpg|jpeg|gif|webp)')/i;
|
|
68
95
|
/** Check if input contains image references (quick check) */
|
|
69
96
|
export function hasImageReferences(input) {
|
|
70
|
-
return AT_REF_CHECK.test(input) || DIRECT_PATH_PATTERN.test(input.trim());
|
|
97
|
+
return AT_REF_CHECK.test(input) || DIRECT_PATH_PATTERN.test(input.trim()) || INLINE_QUOTED_CHECK.test(input);
|
|
71
98
|
}
|
|
72
99
|
/** Build multimodal message content from parsed input */
|
|
73
100
|
export function buildMessageContent(parsed) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-handler.js","sourceRoot":"","sources":["../../../src/ui/utils/image-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,WAAW,EAEX,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AAkBxC,oDAAoD;AACpD,6EAA6E;AAC7E,uFAAuF;AACvF,MAAM,cAAc,GAAG,gJAAgJ,CAAC;AACxK,+GAA+G;AAC/G,MAAM,mBAAmB,GAAG,mOAAmO,CAAC;
|
|
1
|
+
{"version":3,"file":"image-handler.js","sourceRoot":"","sources":["../../../src/ui/utils/image-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,WAAW,EAEX,oBAAo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CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,MAAM,CAAC,WAAW,GAAG,gBAAgB,CAAC;IACtC,MAAM,CAAC,0BAA0B,GAAG,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defai.digital/ax-cli",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.5",
|
|
4
4
|
"sdkVersion": "1.3.0",
|
|
5
5
|
"description": "Enterprise-Class AI Command Line Interface - Primary support for GLM (General Language Model) with multi-provider AI orchestration powered by AutomatosX.",
|
|
6
6
|
"type": "module",
|