feat(plugins): add reviewed privileged terminal data pipeline (#2402)

* feat(plugins): add privileged terminal data pipeline

* fix(plugins): harden terminal interceptor lifecycle

* fix(plugins): close terminal interceptor lifecycle gaps

* fix(plugins): preserve terminal interceptor state transitions

* fix(plugin): close terminal pipeline lifecycle gaps

* fix(plugin): harden terminal interceptor startup

* fix(plugin): isolate terminal output route attempts

* fix(plugin): isolate reused terminal sessions

* fix(plugin): harden terminal interceptor boundaries

* fix(plugin): harden terminal replay metadata

* fix(plugin): preserve terminal replay provenance

* fix(plugin): close terminal pipeline lifecycle races

* fix(plugin): harden terminal route handoff

* fix(plugin): contain terminal handoff failures

* fix(plugin): route terminal attachment through RPC

* fix(plugin): validate terminal attachment RPC

* fix(plugin): close unexpected runtime ports

* fix(plugin): canonicalize terminal data frames

* fix(plugin): close terminal pipeline lifecycle gaps

* fix(plugin): close terminal interceptor review gaps

* fix(plugin): harden terminal interceptor protocol handling

* fix(plugin): preserve terminal flow compatibility

* fix(plugin): preserve terminal protocol accounting

* fix(plugin): bound terminal interceptor lifecycle

* fix(plugin): close terminal interceptor review gaps

---------

Co-authored-by: ryan-wong-coder <wangsiyuan19990317@gmail.com>
This commit is contained in:
陈大猫andryan-wong-coder authored and GitHub committed 2026-07-23 09:42:47 +08:00
1 parent 34c4efb225
commit 67f8108713
101 files changed
+8475 -396

No files matched your search

+20 -9
View File
@@ -608,27 +608,31 @@ function createScriptRuntime(deps) {
};
const screenApi = {
send(text) {
send(text, options = {}) {
return markHandled(ignoreIfStopped(async () => {
if (deps.isAborted?.()) return;
assertWriteAllowed("screen.send");
await waitIfPaused();
const payload = String(text ?? "");
await trackStep(`send: ${truncateActivityLabel(formatScriptInputForLog(payload), 60)}`);
const sensitive = options?.sensitive === true;
const visiblePayload = sensitive ? "[sensitive]" : formatScriptInputForLog(payload);
await trackStep(`send: ${truncateActivityLabel(visiblePayload, 60)}`);
if (deps.isAborted?.()) return;
appendLog(runId, `→ ${formatScriptInputForLog(payload)}`);
writeToSession(sessionId, payload, { automated: true });
appendLog(runId, `→ ${visiblePayload}`);
writeToSession(sessionId, payload, { automated: true, sensitive });
}));
},
sendLine(text) {
sendLine(text, options = {}) {
return markHandled(ignoreIfStopped(async () => {
if (deps.isAborted?.()) return;
assertWriteAllowed("screen.sendLine");
await waitIfPaused();
const line = String(text ?? "");
await trackStep(`sendLine: ${truncateActivityLabel(line, 60)}`);
const sensitive = options?.sensitive === true;
const visibleLine = sensitive ? "[sensitive]" : line;
await trackStep(`sendLine: ${truncateActivityLabel(visibleLine, 60)}`);
if (deps.isAborted?.()) return;
appendLog(runId, `→ ${line}`);
appendLog(runId, `→ ${visibleLine}`);
// Bastion menus can ignore a single "line\r" packet even when
// stream.write succeeds. Match xterm: body, then Enter (#1960).
// Consume only pre-send buffer length so prompts that arrive between
@@ -638,6 +642,7 @@ function createScriptRuntime(deps) {
if (line.length > 0) {
writeToSession(sessionId, line, {
automated: true,
sensitive,
invalidateStartupSeed: false,
});
await interruptibleSleep(30, deps.isAborted);
@@ -645,6 +650,7 @@ function createScriptRuntime(deps) {
}
writeToSession(sessionId, "\r", {
automated: true,
sensitive,
invalidateStartupSeed: false,
});
buffer.consumeThroughAbsolute(lengthBeforeSend);
@@ -713,9 +719,14 @@ function createScriptRuntime(deps) {
assertNotAborted();
return markHandled(showDialog("confirm", String(message ?? "")));
},
prompt(message, defaultValue = "") {
prompt(message, defaultValue = "", options = {}) {
assertNotAborted();
return markHandled(showDialog("prompt", String(message ?? ""), String(defaultValue ?? "")));
return markHandled(showDialog(
"prompt",
String(message ?? ""),
String(defaultValue ?? ""),
{ sensitive: options?.sensitive === true },
));
},
form(spec) {
assertNotAborted();