@clawos-dev/clawd 0.2.152 → 0.2.153-beta.322.6a8336d
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/cli.cjs +54 -18
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -36861,32 +36861,38 @@ init_claude_history();
|
|
|
36861
36861
|
// src/pty/pty-child-process.ts
|
|
36862
36862
|
var import_node_events = require("events");
|
|
36863
36863
|
var import_node_stream2 = require("stream");
|
|
36864
|
+
var PASTE_ENTER_DELAY_MS = 240;
|
|
36864
36865
|
var PtyChildProcess = class extends import_node_events.EventEmitter {
|
|
36865
36866
|
constructor(pty, opts = {}) {
|
|
36866
36867
|
super();
|
|
36867
36868
|
this.pty = pty;
|
|
36868
36869
|
this.pid = pty.pid;
|
|
36869
|
-
const { logger, tag } = opts;
|
|
36870
|
+
const { logger, tag, submitGate } = opts;
|
|
36870
36871
|
logger?.debug("pty-child constructed", { pid: this.pid, tag });
|
|
36871
36872
|
const writeToPty = (data) => {
|
|
36872
36873
|
const match = data.match(/^(\x1b\[200~[\s\S]*\x1b\[201~)(\r+)$/);
|
|
36873
|
-
if (match) {
|
|
36874
|
-
const paste = match[1];
|
|
36875
|
-
const enter = match[2];
|
|
36876
|
-
logger?.debug("[RG] pty-paste", { tag, pasteLen: paste.length, enterLen: enter.length });
|
|
36877
|
-
pty.write(paste);
|
|
36878
|
-
setTimeout(() => {
|
|
36879
|
-
try {
|
|
36880
|
-
pty.write(enter);
|
|
36881
|
-
logger?.debug("[RG] pty-paste-enter", { tag, wrote: "\\r", disposed: false });
|
|
36882
|
-
} catch (err) {
|
|
36883
|
-
logger?.debug("[RG] pty-paste-enter", { tag, error: err.message });
|
|
36884
|
-
logger?.warn("pty delayed \\r failed", { tag, error: err.message });
|
|
36885
|
-
}
|
|
36886
|
-
}, 240);
|
|
36887
|
-
} else {
|
|
36874
|
+
if (!match) {
|
|
36888
36875
|
logger?.debug("[RG] pty-write-direct", { tag, len: data.length });
|
|
36889
36876
|
pty.write(data);
|
|
36877
|
+
return;
|
|
36878
|
+
}
|
|
36879
|
+
const paste = match[1];
|
|
36880
|
+
const enter = match[2];
|
|
36881
|
+
logger?.debug("[RG] pty-paste", { tag, pasteLen: paste.length, enterLen: enter.length });
|
|
36882
|
+
pty.write(paste);
|
|
36883
|
+
const writeEnter = () => {
|
|
36884
|
+
try {
|
|
36885
|
+
pty.write(enter);
|
|
36886
|
+
logger?.debug("[RG] pty-paste-enter", { tag, wrote: "\\r" });
|
|
36887
|
+
} catch (err) {
|
|
36888
|
+
logger?.debug("[RG] pty-paste-enter", { tag, error: err.message });
|
|
36889
|
+
logger?.warn("pty delayed \\r failed", { tag, error: err.message });
|
|
36890
|
+
}
|
|
36891
|
+
};
|
|
36892
|
+
if (submitGate) {
|
|
36893
|
+
submitGate().then(writeEnter, writeEnter);
|
|
36894
|
+
} else {
|
|
36895
|
+
setTimeout(writeEnter, PASTE_ENTER_DELAY_MS);
|
|
36890
36896
|
}
|
|
36891
36897
|
};
|
|
36892
36898
|
this.stdin = new import_node_stream2.Writable({
|
|
@@ -37073,6 +37079,35 @@ function createTerminalSurface(opts) {
|
|
|
37073
37079
|
}
|
|
37074
37080
|
};
|
|
37075
37081
|
}
|
|
37082
|
+
function inputBoxContent(lines) {
|
|
37083
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
37084
|
+
const t = lines[i].trimStart();
|
|
37085
|
+
if (t.startsWith("\u276F")) return t.slice(1).trim();
|
|
37086
|
+
}
|
|
37087
|
+
return "";
|
|
37088
|
+
}
|
|
37089
|
+
function waitInputEcho(surface, opts = {}) {
|
|
37090
|
+
const stableMs = opts.stableMs ?? 150;
|
|
37091
|
+
const maxMs = opts.maxMs ?? 5e3;
|
|
37092
|
+
return new Promise((resolve6) => {
|
|
37093
|
+
let settled = false;
|
|
37094
|
+
let stableTimer = null;
|
|
37095
|
+
const finish = () => {
|
|
37096
|
+
if (settled) return;
|
|
37097
|
+
settled = true;
|
|
37098
|
+
unsub();
|
|
37099
|
+
if (stableTimer) clearTimeout(stableTimer);
|
|
37100
|
+
clearTimeout(maxTimer);
|
|
37101
|
+
resolve6();
|
|
37102
|
+
};
|
|
37103
|
+
const unsub = surface.onTick((lines) => {
|
|
37104
|
+
if (!stableTimer && inputBoxContent(lines).length > 0) {
|
|
37105
|
+
stableTimer = setTimeout(finish, stableMs);
|
|
37106
|
+
}
|
|
37107
|
+
});
|
|
37108
|
+
const maxTimer = setTimeout(finish, maxMs);
|
|
37109
|
+
});
|
|
37110
|
+
}
|
|
37076
37111
|
function observePopup(surface, opts) {
|
|
37077
37112
|
let visible = null;
|
|
37078
37113
|
let pendingClear = null;
|
|
@@ -37299,12 +37334,13 @@ var ClaudeTuiAdapter = class extends ClaudeAdapter {
|
|
|
37299
37334
|
if (ctx.toolSessionId && this.tuiOpts.onPtyRegister) {
|
|
37300
37335
|
this.tuiOpts.onPtyRegister(ctx.toolSessionId, pty);
|
|
37301
37336
|
}
|
|
37337
|
+
const surface = createTerminalSurface();
|
|
37302
37338
|
const ptyChild = new PtyChildProcess(pty, {
|
|
37303
37339
|
logger: this.tuiLogger,
|
|
37304
|
-
tag: ctx.toolSessionId ?? "no-tsid"
|
|
37340
|
+
tag: ctx.toolSessionId ?? "no-tsid",
|
|
37341
|
+
submitGate: () => waitInputEcho(surface)
|
|
37305
37342
|
});
|
|
37306
37343
|
const bootGate = createBootGate(pty, this.tuiLogger);
|
|
37307
|
-
const surface = createTerminalSurface();
|
|
37308
37344
|
const readyObserver = observeReady(surface, {
|
|
37309
37345
|
quietMs: 500,
|
|
37310
37346
|
onReady: () => {
|
package/package.json
CHANGED