u-foo 3.1.5 → 3.1.7
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/tui/darwin-arm64/ufoo-tui +0 -0
- package/dist/tui/darwin-x64/ufoo-tui +0 -0
- package/dist/tui/linux-arm64/ufoo-tui +0 -0
- package/dist/tui/linux-x64/ufoo-tui +0 -0
- package/package.json +1 -1
- package/src/code/imageIngest.js +69 -72
- package/src/code/nativeRunner.js +6 -7
- package/src/code/providers/responsesProtocol.js +1 -1
- package/src/ui/format/index.js +1 -1
- package/src/ui/rustUcodeHost.js +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/src/code/imageIngest.js
CHANGED
|
@@ -50,91 +50,84 @@ function expandHome(filePath = "") {
|
|
|
50
50
|
return text;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*/
|
|
57
|
-
function extractImagePathsFromPaste(text = "") {
|
|
53
|
+
// Parse terminal shell quoting without evaluating shell expressions. Keep source
|
|
54
|
+
// spans so the exact pasted spelling (including escapes) can be removed later.
|
|
55
|
+
function imagePathMatches(text = "") {
|
|
58
56
|
const raw = String(text || "");
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Bare tokens / lines
|
|
88
|
-
for (const line of raw.split(/\r?\n/)) {
|
|
89
|
-
const trimmed = line.trim();
|
|
90
|
-
if (!trimmed) continue;
|
|
91
|
-
if (looksLikeImagePath(trimmed)) {
|
|
92
|
-
pushPath(trimmed);
|
|
93
|
-
continue;
|
|
57
|
+
const matches = [];
|
|
58
|
+
let offset = 0;
|
|
59
|
+
for (const line of raw.split(/\n/)) {
|
|
60
|
+
const tokens = [];
|
|
61
|
+
let i = 0;
|
|
62
|
+
while (i < line.length) {
|
|
63
|
+
if (/\s/.test(line[i])) { i += 1; continue; }
|
|
64
|
+
const start = i;
|
|
65
|
+
let value = "";
|
|
66
|
+
let quote = "";
|
|
67
|
+
const windowsPath = /^[A-Za-z]:[\\/]/.test(line.slice(i).replace(/^["']/, ""));
|
|
68
|
+
while (i < line.length) {
|
|
69
|
+
const ch = line[i];
|
|
70
|
+
if (!quote && /\s/.test(ch)) break;
|
|
71
|
+
if (ch === quote) { quote = ""; i += 1; continue; }
|
|
72
|
+
if (!quote && (ch === "'" || ch === '"')) { quote = ch; i += 1; continue; }
|
|
73
|
+
if (ch === "\\" && quote !== "'" && !windowsPath && i + 1 < line.length
|
|
74
|
+
&& (!quote || /[\\"$`]/.test(line[i + 1]))) {
|
|
75
|
+
value += line[i + 1];
|
|
76
|
+
i += 2;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
value += ch;
|
|
80
|
+
i += 1;
|
|
81
|
+
}
|
|
82
|
+
tokens.push({ value, start: offset + start, end: offset + i });
|
|
94
83
|
}
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
const trimmed = line.trim();
|
|
85
|
+
// Preserve support for a raw, unquoted absolute filename containing spaces.
|
|
86
|
+
// Escaped or quoted terminal input always uses the tokenized path above.
|
|
87
|
+
const rawWholePath = !/[\\"']/.test(trimmed)
|
|
88
|
+
&& looksLikeImagePath(trimmed)
|
|
89
|
+
&& tokens.filter((token) => looksLikeImagePath(token.value)).length < 2
|
|
90
|
+
&& !tokens.slice(1).some((token) => /^(?:\/|file:\/\/|~\/)/.test(token.value));
|
|
91
|
+
const candidates = rawWholePath
|
|
92
|
+
? [{ value: trimmed, start: offset + line.indexOf(trimmed), end: offset + line.indexOf(trimmed) + trimmed.length }]
|
|
93
|
+
: tokens;
|
|
94
|
+
for (const token of candidates) {
|
|
95
|
+
if (!looksLikeImagePath(token.value)) continue;
|
|
96
|
+
matches.push({ ...token, path: expandHome(decodeFileUrl(token.value)) });
|
|
97
97
|
}
|
|
98
|
+
offset += line.length + 1;
|
|
98
99
|
}
|
|
100
|
+
return matches;
|
|
101
|
+
}
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
function extractImagePathsFromPaste(text = "") {
|
|
104
|
+
const seen = new Set();
|
|
105
|
+
return imagePathMatches(text).flatMap((match) => {
|
|
106
|
+
const key = path.resolve(match.path);
|
|
107
|
+
if (seen.has(key)) return [];
|
|
108
|
+
seen.add(key);
|
|
109
|
+
return [match.path];
|
|
110
|
+
});
|
|
101
111
|
}
|
|
102
112
|
|
|
103
113
|
function stripExtractedPathsFromText(text = "", paths = []) {
|
|
104
114
|
let out = String(text || "");
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
p,
|
|
110
|
-
p.startsWith("/") ? `file://${p}` : "",
|
|
111
|
-
p.startsWith("/") ? `file://${encodeURI(p)}` : "",
|
|
112
|
-
].filter(Boolean);
|
|
113
|
-
for (const v of variants) {
|
|
114
|
-
out = out.split(v).join(" ");
|
|
115
|
-
}
|
|
115
|
+
const selected = new Set(paths.map((p) => path.resolve(p)));
|
|
116
|
+
const matches = imagePathMatches(out).filter((match) => selected.has(path.resolve(match.path)));
|
|
117
|
+
for (const match of matches.reverse()) {
|
|
118
|
+
out = `${out.slice(0, match.start)} ${out.slice(match.end)}`;
|
|
116
119
|
}
|
|
117
|
-
return out
|
|
118
|
-
.replace(/[ \t]
|
|
119
|
-
.replace(/\n{3,}/g, "\n\n")
|
|
120
|
-
.replace(/[ \t]{2,}/g, " ")
|
|
121
|
-
.replace(/\s+"/g, " ")
|
|
122
|
-
.replace(/"\s+/g, " ")
|
|
123
|
-
.replace(/\s+'/g, " ")
|
|
124
|
-
.replace(/'\s+/g, " ")
|
|
125
|
-
.trim();
|
|
120
|
+
return out.replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n")
|
|
121
|
+
.replace(/[ \t]{2,}/g, " ").trim();
|
|
126
122
|
}
|
|
127
123
|
|
|
128
|
-
function formatImageLogLabel(
|
|
129
|
-
|
|
130
|
-
|| path.basename(String(relPath || pathText || "").trim())
|
|
131
|
-
|| "image";
|
|
132
|
-
return `[image: ${name}]`;
|
|
124
|
+
function formatImageLogLabel(_attachment = {}, index = 0) {
|
|
125
|
+
return `[Image #${index + 1}]`;
|
|
133
126
|
}
|
|
134
127
|
|
|
135
128
|
function formatUserLogWithAttachments(userText = "", attachments = []) {
|
|
136
129
|
const labels = (Array.isArray(attachments) ? attachments : [])
|
|
137
|
-
.map((item) => formatImageLogLabel(item))
|
|
130
|
+
.map((item, index) => formatImageLogLabel(item, index))
|
|
138
131
|
.filter(Boolean);
|
|
139
132
|
const body = String(userText || "").trim();
|
|
140
133
|
if (labels.length === 0) return body;
|
|
@@ -315,14 +308,18 @@ function handleImagePaste(text = "", {
|
|
|
315
308
|
const paths = extractImagePathsFromPaste(raw);
|
|
316
309
|
const attachments = [];
|
|
317
310
|
const errors = [];
|
|
311
|
+
const importedPaths = [];
|
|
318
312
|
|
|
319
313
|
for (const sourcePath of paths) {
|
|
320
314
|
const ingested = ingestImageFile({ sourcePath, workspaceRoot, sessionId });
|
|
321
|
-
if (ingested.ok)
|
|
315
|
+
if (ingested.ok) {
|
|
316
|
+
attachments.push(ingested);
|
|
317
|
+
importedPaths.push(sourcePath);
|
|
318
|
+
}
|
|
322
319
|
else errors.push(ingested.error || "ingest failed");
|
|
323
320
|
}
|
|
324
321
|
|
|
325
|
-
let remaining = stripExtractedPathsFromText(raw,
|
|
322
|
+
let remaining = stripExtractedPathsFromText(raw, importedPaths);
|
|
326
323
|
|
|
327
324
|
// If paste had no usable text/paths, try clipboard PNG (Cmd+V of a screenshot).
|
|
328
325
|
const trimmedRemaining = remaining.trim();
|
|
@@ -330,7 +327,7 @@ function handleImagePaste(text = "", {
|
|
|
330
327
|
|| /[\x00-\x08\x0e-\x1f]/.test(raw)
|
|
331
328
|
|| (Buffer.byteLength(raw, "utf8") > 200 && paths.length === 0 && !/\s/.test(raw.slice(0, 40)));
|
|
332
329
|
|
|
333
|
-
if (tryClipboard && attachments.length === 0 && looksEmptyOrBinary) {
|
|
330
|
+
if (tryClipboard && paths.length === 0 && attachments.length === 0 && looksEmptyOrBinary) {
|
|
334
331
|
const clip = tryIngestClipboardImage({
|
|
335
332
|
workspaceRoot,
|
|
336
333
|
sessionId,
|
package/src/code/nativeRunner.js
CHANGED
|
@@ -127,11 +127,10 @@ const NATIVE_SSE_DISPATCHER_OPTIONS = Object.freeze({
|
|
|
127
127
|
});
|
|
128
128
|
/** Max text-only auto-continues while a plan is waiting on a task (per user submit). */
|
|
129
129
|
const DEFAULT_MAX_PLAN_AUTO_CONTINUES = 24;
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
const DEFAULT_ANTHROPIC_MAX_TOKENS = 64000;
|
|
130
|
+
// Reserve 32K output tokens by default across transports. Override via
|
|
131
|
+
// UFOO_UCODE_MAX_TOKENS (positive integer).
|
|
132
|
+
const DEFAULT_OPENAI_MAX_TOKENS = 32768;
|
|
133
|
+
const DEFAULT_ANTHROPIC_MAX_TOKENS = 32768;
|
|
135
134
|
// Extended thinking defaults live in thinkingLevels.js (medium = 10k).
|
|
136
135
|
// UFOO_UCODE_THINKING=off|low|medium|high|max selects a preset; numeric
|
|
137
136
|
// UFOO_UCODE_THINKING_BUDGET_TOKENS still overrides. 0 disables thinking.
|
|
@@ -1779,8 +1778,8 @@ async function runAnthropicTurn({
|
|
|
1779
1778
|
tools: buildAnthropicToolSpecs(),
|
|
1780
1779
|
stream: true,
|
|
1781
1780
|
};
|
|
1782
|
-
const thinkingBudget = resolveThinkingBudgetTokens();
|
|
1783
|
-
if (thinkingBudget
|
|
1781
|
+
const thinkingBudget = Math.min(resolveThinkingBudgetTokens(), payload.max_tokens - 1);
|
|
1782
|
+
if (thinkingBudget >= 1024) {
|
|
1784
1783
|
payload.thinking = { type: "enabled", budget_tokens: thinkingBudget };
|
|
1785
1784
|
}
|
|
1786
1785
|
if (Array.isArray(systemBlocks) && systemBlocks.length > 0) {
|
package/src/ui/format/index.js
CHANGED
|
@@ -395,7 +395,7 @@ function redactUserMessageForLog(text = "") {
|
|
|
395
395
|
const paths = [...block.matchAll(/^\s*-\s*(.+)$/gm)].map((m) => String(m[1] || "").trim());
|
|
396
396
|
if (paths.length === 0) return "[image]";
|
|
397
397
|
return paths
|
|
398
|
-
.map((
|
|
398
|
+
.map((_, index) => `[Image #${index + 1}]`)
|
|
399
399
|
.join(" ");
|
|
400
400
|
},
|
|
401
401
|
);
|
package/src/ui/rustUcodeHost.js
CHANGED
|
@@ -481,7 +481,7 @@ async function runUcodeRust(props = {}) {
|
|
|
481
481
|
if (Array.isArray(outcome.errors) && outcome.errors.length > 0 && pendingAttachments.length === 0) {
|
|
482
482
|
appendLog(`Image paste: ${outcome.errors[0]}`, "system");
|
|
483
483
|
}
|
|
484
|
-
const labels = pendingAttachments.map((item) => formatImageLogLabel(item
|
|
484
|
+
const labels = pendingAttachments.map((item, index) => formatImageLogLabel(item, index));
|
|
485
485
|
publish("attachments.set", {
|
|
486
486
|
count: pendingAttachments.length,
|
|
487
487
|
labels,
|