@cotal-ai/manager 0.3.1 → 0.3.2
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/runtime/pty.d.ts.map +1 -1
- package/dist/runtime/pty.js +26 -27
- package/dist/runtime/pty.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pty.d.ts","sourceRoot":"","sources":["../../src/runtime/pty.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAiB,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"pty.d.ts","sourceRoot":"","sources":["../../src/runtime/pty.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAiB,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAkBtF;;;;;GAKG;AACH,qBAAa,UAAW,YAAW,OAAO;IACxC,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAU;IAE/B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW;CA8FhE"}
|
package/dist/runtime/pty.js
CHANGED
|
@@ -3,19 +3,17 @@ const DEFAULT_COLS = 120;
|
|
|
3
3
|
const DEFAULT_ROWS = 32;
|
|
4
4
|
/** How much terminal output to retain for late-attach scrollback replay. */
|
|
5
5
|
const SCROLLBACK_BYTES = 256 * 1024;
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/** Spacing between auto-confirm Enter presses, and how many to send. Claude's startup gates
|
|
7
|
+
* (workspace-trust, then the dev-channels warning) each wait for Enter and neither has a headless
|
|
8
|
+
* override. The count is variable — a fresh folder shows both, a re-launch on a now-trusted folder
|
|
9
|
+
* shows only the channels gate — and each gate's screen is static once rendered, so we don't match
|
|
10
|
+
* text or count prompts: press Enter blindly a few times, spaced so each press lands on the next
|
|
11
|
+
* gate and a dropped press is retried. Both gates default-highlight "proceed", so Enter accepts the
|
|
12
|
+
* safe option; any extra press lands on Claude's empty input as a no-op. */
|
|
13
|
+
const CONFIRM_INTERVAL_MS = 1_000;
|
|
14
|
+
const MAX_CONFIRMS = 5;
|
|
8
15
|
/** Grace window for a clean exit before a graceful stop escalates to SIGKILL. */
|
|
9
16
|
const GRACE_MS = 3_000;
|
|
10
|
-
/** Strip ANSI control sequences and whitespace so a confirm prompt matches regardless
|
|
11
|
-
* of how a TUI positions its text (cursor moves between words, not spaces). */
|
|
12
|
-
function normalizeForMatch(s) {
|
|
13
|
-
return s
|
|
14
|
-
.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, "") // OSC
|
|
15
|
-
.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "") // CSI
|
|
16
|
-
.replace(/\x1b[@-Z\\-_]/g, "") // other escapes
|
|
17
|
-
.replace(/\s+/g, "");
|
|
18
|
-
}
|
|
19
17
|
/**
|
|
20
18
|
* The default runtime: the manager spawns the agent in a pseudo-terminal it owns
|
|
21
19
|
* via `@lydell/node-pty`. A real native TUI — the manager keeps full OS-signal
|
|
@@ -39,13 +37,21 @@ export class PtyRuntime {
|
|
|
39
37
|
let alive = true;
|
|
40
38
|
let cols = DEFAULT_COLS;
|
|
41
39
|
let rows = DEFAULT_ROWS;
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
// Clear Claude's startup gates (workspace-trust, dev-channels warning) by pressing Enter on a
|
|
41
|
+
// timer during the startup window — see CONFIRM_INTERVAL_MS for why this is blind, not output-
|
|
42
|
+
// driven. A spawn that opts in sets `spec.confirm` truthy.
|
|
43
|
+
let confirmTimer;
|
|
44
|
+
if (spec.confirm) {
|
|
45
|
+
let presses = 0;
|
|
46
|
+
confirmTimer = setInterval(() => {
|
|
47
|
+
if (!alive || presses++ >= MAX_CONFIRMS) {
|
|
48
|
+
clearInterval(confirmTimer);
|
|
49
|
+
confirmTimer = undefined;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
proc.write("\r");
|
|
53
|
+
}, CONFIRM_INTERVAL_MS);
|
|
54
|
+
}
|
|
49
55
|
proc.onData((d) => {
|
|
50
56
|
const b = Buffer.from(d, "utf8");
|
|
51
57
|
ring.push(b);
|
|
@@ -53,20 +59,13 @@ export class PtyRuntime {
|
|
|
53
59
|
while (ringBytes > SCROLLBACK_BYTES && ring.length > 1) {
|
|
54
60
|
ringBytes -= ring.shift().length;
|
|
55
61
|
}
|
|
56
|
-
if (confirmArmed) {
|
|
57
|
-
confirmBuf = (confirmBuf + d).slice(-8192);
|
|
58
|
-
if (normalizeForMatch(confirmBuf).includes(confirmTarget)) {
|
|
59
|
-
confirmArmed = false;
|
|
60
|
-
// Let the TUI finish wiring up its raw-mode input loop (it may flush
|
|
61
|
-
// stdin on init) before pressing Enter, or the keypress is dropped.
|
|
62
|
-
setTimeout(() => alive && proc.write("\r"), 500);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
62
|
for (const fn of dataSubs)
|
|
66
63
|
fn(b);
|
|
67
64
|
});
|
|
68
65
|
proc.onExit(() => {
|
|
69
66
|
alive = false;
|
|
67
|
+
if (confirmTimer)
|
|
68
|
+
clearInterval(confirmTimer);
|
|
70
69
|
for (const fn of exitSubs)
|
|
71
70
|
fn();
|
|
72
71
|
});
|
package/dist/runtime/pty.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pty.js","sourceRoot":"","sources":["../../src/runtime/pty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AAGxC,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG,GAAG,GAAG,IAAI,CAAC;AACpC
|
|
1
|
+
{"version":3,"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,IAAI,GAAG,CAAC,CAAC;oBACT,IAAI,GAAG,CAAC,CAAC;oBACT,IAAI,KAAK;wBAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC/B,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cotal-ai/manager",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@xterm/xterm": "^5.5.0",
|
|
24
24
|
"ws": "^8.21.0",
|
|
25
25
|
"yaml": "^2.9.0",
|
|
26
|
-
"@cotal-ai/core": "0.3.
|
|
26
|
+
"@cotal-ai/core": "0.3.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/ws": "^8.18.1"
|