Table of Contents

Class ProcessSessionManager

Namespace
JD.AI.Core.Tools
Assembly
JD.AI.Core.dll

Manages lifecycle of background and foreground process sessions used by the exec/process tool surface.

public sealed class ProcessSessionManager
Inheritance
ProcessSessionManager
Inherited Members

Constructors

ProcessSessionManager(string?, TimeSpan?, int)

public ProcessSessionManager(string? metadataRoot = null, TimeSpan? completedRetention = null, int maxLogCharsPerStream = 200000)

Parameters

metadataRoot string
completedRetention TimeSpan?
maxLogCharsPerStream int

Methods

Clear(string, bool)

public int Clear(string scopeKey, bool includeRunning = false)

Parameters

scopeKey string
includeRunning bool

Returns

int

ExecAsync(string, ProcessExecRequest, CancellationToken)

public Task<ProcessSessionSnapshot> ExecAsync(string scopeKey, ProcessExecRequest request, CancellationToken ct = default)

Parameters

scopeKey string
request ProcessExecRequest
ct CancellationToken

Returns

Task<ProcessSessionSnapshot>

GetLogs(string, string, int)

public ProcessSessionLogs? GetLogs(string scopeKey, string sessionId, int maxChars = 4000)

Parameters

scopeKey string
sessionId string
maxChars int

Returns

ProcessSessionLogs

List(string, bool)

public IReadOnlyList<ProcessSessionSnapshot> List(string scopeKey, bool includeCompleted = true)

Parameters

scopeKey string
includeCompleted bool

Returns

IReadOnlyList<ProcessSessionSnapshot>

PollAsync(string, string, int, CancellationToken)

public Task<ProcessSessionSnapshot?> PollAsync(string scopeKey, string sessionId, int yieldMs = 0, CancellationToken ct = default)

Parameters

scopeKey string
sessionId string
yieldMs int
ct CancellationToken

Returns

Task<ProcessSessionSnapshot>

TryKill(string, string, out ProcessSessionSnapshot?, out string?)

public bool TryKill(string scopeKey, string sessionId, out ProcessSessionSnapshot? snapshot, out string? error)

Parameters

scopeKey string
sessionId string
snapshot ProcessSessionSnapshot
error string

Returns

bool

TryRemove(string, string, bool, out string?)

public bool TryRemove(string scopeKey, string sessionId, bool force, out string? error)

Parameters

scopeKey string
sessionId string
force bool
error string

Returns

bool

TryWriteInput(string, string, string, out ProcessSessionSnapshot?, out string?)

public bool TryWriteInput(string scopeKey, string sessionId, string input, out ProcessSessionSnapshot? snapshot, out string? error)

Parameters

scopeKey string
sessionId string
input string
snapshot ProcessSessionSnapshot
error string

Returns

bool

WaitForIdleAsync(CancellationToken)

Waits for all background session tasks (stdout/stderr pumps and exit monitors) to complete. Call this after Clear(string, bool) to ensure no orphaned I/O threads remain before the caller exits — for example, at the end of a test fixture tear-down so that CLR profilers (e.g. coverage collectors) can finalize cleanly.

public Task WaitForIdleAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task