Skip to content

Commit 6ed9ce9

Browse files
committed
update
1 parent 1463ae6 commit 6ed9ce9

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

gui-mvp/frontend/public/sdks/lyenv_sdk.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ def global_config(key: str, default: Any = None) -> Any:
143143
def log(msg: Any) -> None:
144144
_RESPONSE["logs"].append(str(msg))
145145

146+
def log_stream(msg: Any) -> None:
147+
"""
148+
Real-time log channel: write to stderr and flush immediately.
149+
Also keep it in response logs (optional).
150+
"""
151+
s = str(msg)
152+
try:
153+
sys.stderr.write(s + "\n")
154+
sys.stderr.flush()
155+
except Exception:
156+
pass
157+
_RESPONSE["logs"].append(s)
158+
146159
def emit_artifact(path: Any) -> None:
147160
_RESPONSE["artifacts"].append(str(path))
148161

internal/plugin/runtime.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,13 @@ func spawnStdio(ctx context.Context, spec *CommandSpec, pluginDir string, req ma
668668
cmd.Env = withExtraEnv(os.Environ(), spec.Env)
669669

670670
// Capture stdout/stderr
671+
// Capture stdout (keep buffered: stdout is reserved for final JSON response)
671672
var outBuf bytes.Buffer
672-
var errBuf bytes.Buffer
673673
cmd.Stdout = &outBuf
674-
cmd.Stderr = &errBuf
674+
675+
// Stream stderr to terminal in real-time, and also keep a copy in errBuf for logs/errors
676+
var errBuf bytes.Buffer
677+
cmd.Stderr = io.MultiWriter(os.Stderr, &errBuf)
675678

676679
// IMPORTANT: send request JSON to stdin
677680
stdinPipe, err := cmd.StdinPipe()

sdks/python/lyenv_sdk.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ def global_config(key: str, default: Any = None) -> Any:
143143
def log(msg: Any) -> None:
144144
_RESPONSE["logs"].append(str(msg))
145145

146+
def log_stream(msg: Any) -> None:
147+
"""
148+
Real-time log channel: write to stderr and flush immediately.
149+
Also keep it in response logs (optional).
150+
"""
151+
s = str(msg)
152+
try:
153+
sys.stderr.write(s + "\n")
154+
sys.stderr.flush()
155+
except Exception:
156+
pass
157+
_RESPONSE["logs"].append(s)
158+
146159
def emit_artifact(path: Any) -> None:
147160
_RESPONSE["artifacts"].append(str(path))
148161

0 commit comments

Comments
 (0)