@yanzc/claude-pro 0.9.7 → 0.9.8
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/package.json +1 -1
- package/src/agent.js +16 -0
- package/src/ui/screen.js +14 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanzc/claude-pro",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "claude-pro: a command line coding agent for the codex-gateway. Full access with no permission prompts; file edits are checkpointed and can be rewound.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
package/src/agent.js
CHANGED
|
@@ -76,6 +76,13 @@ const MIN_CLEAR_TOKENS = 100; // a smaller result is left as it is: clearing it
|
|
|
76
76
|
const CLEARABLE_INPUTS = new Set(['Write', 'Edit', 'MultiEdit', 'NotebookEdit', 'Bash', 'REPL']);
|
|
77
77
|
const INPUT_CLEARING = { longerThan: 1200, keep: 300 }; // characters of one text of a tool call
|
|
78
78
|
|
|
79
|
+
// The placeholder shortInput leaves, as the model may copy it: writing a long new text after many cleared calls, it
|
|
80
|
+
// wrote one into a file in place of the rest of the text (2026-11-18, codex-gateway src/site.mjs). A file tool given
|
|
81
|
+
// it does nothing and says why (runTools). The digits keep this file's own source of the message from matching.
|
|
82
|
+
const CLEARED_INPUT_IN_TEXT = /\[Old tool input cleared: \d+ more characters\]/;
|
|
83
|
+
const hasClearedInput = (value) => (typeof value === 'string' ? CLEARED_INPUT_IN_TEXT.test(value)
|
|
84
|
+
: Array.isArray(value) ? value.some(hasClearedInput) : value && typeof value === 'object' ? Object.values(value).some(hasClearedInput) : false);
|
|
85
|
+
|
|
79
86
|
// A tool call's input with its long texts cut to their start; the same object when none is long.
|
|
80
87
|
function shortInput(value) {
|
|
81
88
|
if (typeof value === 'string') {
|
|
@@ -1056,6 +1063,15 @@ export class Agent {
|
|
|
1056
1063
|
results.set(tu, { type: 'tool_result', tool_use_id: tu.id, is_error: true, content: message });
|
|
1057
1064
|
return;
|
|
1058
1065
|
}
|
|
1066
|
+
if (tool?.editsFiles && hasClearedInput(tu.input)) {
|
|
1067
|
+
const message = 'Not done: the text to write contains "[Old tool input cleared: N more characters]", the placeholder that stands in this conversation for the text of an old tool call, not text of the file. Nothing was changed. Send the call again with the whole text you mean (Read the file first if you need what is in it).';
|
|
1068
|
+
const refused = this.trace?.toolStart({ turnId: this.traceTurnId, agent: this.name, depth: this.depth, name: tu.name, input: tu.input, parallel: false, toolUseId: tu.id });
|
|
1069
|
+
this.trace?.toolEnd(refused, { error: true, error_type: 'cleared_input' });
|
|
1070
|
+
this.io.toolRejected?.(tu, tool, message, this);
|
|
1071
|
+
results.set(tu, { type: 'tool_result', tool_use_id: tu.id, is_error: true, content: message });
|
|
1072
|
+
failedEdit ||= tu.name;
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1059
1075
|
const r = await this.runOne(tu, signal, map, { parallel: batch.parallel });
|
|
1060
1076
|
// Key by the tool-use object, not its provider id. A malformed provider response
|
|
1061
1077
|
// can repeat an id; one duplicate must not overwrite the other result.
|
package/src/ui/screen.js
CHANGED
|
@@ -142,7 +142,7 @@ const CPR = /\x1b\[(\d+);(\d+)R/g; // the terminal's answer to DSR 6: row;column
|
|
|
142
142
|
// draws one of those in two cells sizes all such characters by its font, and is asked about all of them.
|
|
143
143
|
const UI_PROBES = process.platform === 'win32' ? Array.from('·…↑↓←→↻⇣⏎◷⇄•◦⏺⎿✻✢✳✶✽✉⚠') : [];
|
|
144
144
|
const FONT_SIZED = 6;
|
|
145
|
-
const AMBIGUOUS_TIMEOUT_MS = 1500; // some 200 to
|
|
145
|
+
const AMBIGUOUS_TIMEOUT_MS = 1500; // some 200 to 600 answers, each asked for after the one before: 0.3 ms each in the Windows 11 console, 0.5 in Windows 10's
|
|
146
146
|
|
|
147
147
|
// Ask the terminal where the cursor is (DSR 6): resolves with its row (1-based), or null when it does not answer
|
|
148
148
|
// within `timeout`. Run before anything else reads `stdin`, with the terminal in raw mode; what else arrives
|
|
@@ -155,12 +155,15 @@ const AMBIGUOUS_TIMEOUT_MS = 1500; // some 200 to 400 answers: 0.2 ms each in th
|
|
|
155
155
|
// which broke rows in two and left the footer on screen twice. Those are some 800 characters, so neighbours are
|
|
156
156
|
// written together first: one answer does for all of them when they are all one cell wide or all two, which most
|
|
157
157
|
// are, and only the others are then asked about one by one. A batch that is not answered whole in time is not used.
|
|
158
|
+
// Each text is written after the answer to the one before: the Windows 10 console (conhost 19041) answers with wrong
|
|
159
|
+
// columns when many of them come in one write, or in writes sent without waiting.
|
|
158
160
|
export function queryCursorRow(stdin, out, timeout = 300) {
|
|
159
161
|
return new Promise((resolve) => {
|
|
160
162
|
let buf = Buffer.alloc(0);
|
|
161
163
|
let timer = null, finished = false, batch = 0;
|
|
162
164
|
const sent = []; // what was written to be measured (a character, or neighbours), in the order of the answers
|
|
163
165
|
let answered = 0; // how many of them have an answer: counted when a whole batch is in
|
|
166
|
+
let written = 0; // how many of them were written: the next one is, once all of those have an answer
|
|
164
167
|
const replies = () => [...buf.toString('latin1').matchAll(CPR)];
|
|
165
168
|
const cells = (matches, i) => Number(matches[1 + i][2]) - 1;
|
|
166
169
|
// The width of each character of `text`, which took `n` cells: 0 when they are not all one or all two cells wide.
|
|
@@ -202,17 +205,24 @@ export function queryCursorRow(stdin, out, timeout = 300) {
|
|
|
202
205
|
if (rest.length) stdin.unshift(rest);
|
|
203
206
|
resolve(first ? Number(first[1]) : null);
|
|
204
207
|
};
|
|
208
|
+
const writeNext = () => {
|
|
209
|
+
const start = written ? '' : SYNC_START + ESC.hideCursor;
|
|
210
|
+
const text = sent[written++];
|
|
211
|
+
try { out.write(start + '\r' + text + '\x1b[6n' + (written === sent.length ? '\r\x1b[K' : '')); } catch { done(); }
|
|
212
|
+
};
|
|
205
213
|
const measure = (texts, ms) => {
|
|
206
|
-
const start = sent.length ? '' : SYNC_START + ESC.hideCursor;
|
|
207
214
|
sent.push(...texts);
|
|
208
215
|
clearTimeout(timer);
|
|
209
216
|
timer = setTimeout(done, ms);
|
|
210
|
-
|
|
217
|
+
writeNext();
|
|
211
218
|
};
|
|
212
219
|
const onData = (d) => {
|
|
213
220
|
buf = Buffer.concat([buf, Buffer.isBuffer(d) ? d : Buffer.from(String(d), 'utf8')]);
|
|
214
221
|
const matches = replies();
|
|
215
|
-
if (matches.length < 1 + sent.length)
|
|
222
|
+
if (matches.length < 1 + sent.length) { // the first answer is the cursor's position
|
|
223
|
+
if (written < sent.length && matches.length >= 1 + written) writeNext();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
216
226
|
answered = sent.length;
|
|
217
227
|
const more = next(matches);
|
|
218
228
|
if (more.length) measure(more, batch === 1 ? timeout : AMBIGUOUS_TIMEOUT_MS);
|