Class ::nsmcp::CodexQuestionBackend (public)
::nx::Class ::nsmcp::CodexQuestionBackend
Defined in /usr/local/ns/tcl/nsmcp/question-backend.tcl
- Testcases:
- No testcase defined.
Source code: :public object method processTriples {capture} { # # Serialize bounded Codex startup diagnostics. # # @param capture The process and thread snapshot. # @return Typed JSON members with approved diagnostic fields. # set triples [::nsmcp::codexProcessFields $capture {capturedAtMs elapsedMs processLimit threadLimit} {source status reason}] set processes {};set index 0;set remaining 128 if {[dict exists $capture processes]} { foreach process [lrange [dict get $capture processes] 0 7] { set row [::nsmcp::codexProcessFields $process {pid parentPid startTicks userTicks systemTicks readBytes writeBytes threadCount omittedThreads} {name state}] set threads {};set j 0 if {[dict exists $process threads]} { foreach thread [lrange [dict get $process threads] 0 [expr {$remaining-1}]] { if {$remaining<=0} {break} incr remaining -1 set fields [::nsmcp::codexProcessFields $thread {tid userTicks systemTicks syscall fileDescriptor} {name state waitChannel readOperation fileResolution}] if {[dict exists $thread filePath]} { set path [dict get $thread filePath] if {[string length $path]<=1024 && [string index $path 0] eq "/" && ![regexp {[\x00-\x1f\x7f]} $path]} { lappend fields filePath string $path } } lappend threads $j object $fields incr j } } lappend row threads array $threads lappend processes $index object $row incr index } } lappend triples processes array $processes return $triples } :property {authenticator ::nsmcp::auth} :property {registry ::nsmcp::tools} :property {authorizer ::nsmcp::authorization} :property command:required :property launcher:required :property tokenFile:required :property url:required :property {host {}} :property directory:required :property {model {}} :property {timeout 180} :public object method initializationSummary {diagnostic} { # # Explain a retained initialization snapshot for the administrator UI. # @param diagnostic Sanitized backend diagnostics. # @return A bounded description of observed blocked reads. # if {![dict exists $diagnostic initializationCapture]} {return ""} set capture [dict merge {processes {} status unavailable reason unknown} [dict get $diagnostic initializationCapture]] set findings {} foreach process [dict get $capture processes] { set process [dict merge {threads {}} $process] foreach thread [dict get $process threads] { set thread [dict merge {state {} name unknown waitChannel unknown} $thread] if {[dict get $thread state] ne "D"} {continue} set finding "PID [dict get $process pid], thread [dict get $thread tid]" append finding " ([dict get $thread name]) was blocked in [dict get $thread waitChannel]" if {[dict exists $thread readOperation]} { append finding " during [dict get $thread readOperation]" } if {[dict exists $thread fileDescriptor]} { append finding ", fd [dict get $thread fileDescriptor]" } if {[dict exists $thread filePath]} { append finding ", file [dict get $thread filePath]" } elseif {[dict exists $thread readOperation]} { append finding ", file path unavailable" } lappend findings $finding if {[llength $findings]>=3} {break} } if {[llength $findings]>=3} {break} } if {$findings ne {}} { return "Initialization snapshot: [join $findings {; }]. This is the state observed at timeout." } return "Initialization snapshot: [dict get $capture status] ([dict get $capture reason]); no blocked thread was observed. Details are in the server log." } :property {initializeTimeout 30} :property {toolOutputTokens:integer 65536} :property {maxResultBytes 131072} :property {bridgeHost {}} :property {bridgePort:integer 8766} :property {bridgeSecretFile {}} :property {bridgeDirectory /work} :public method outputTokenLimit {} { # Retained backend instances may predate the property after Tcl reload. set value [expr {[info exists :toolOutputTokens] ? ${:toolOutputTokens} : [ns_config -int ns/server/[ns_info server]/module/nsmcp questionCodexToolOutputTokens 65536]}] if {$value<1024 || $value>262144} { error "questionCodexToolOutputTokens must be between 1024 and 262144" } return $value } :public method describe {} { # # Describe configured Codex question execution. # # Report model, timeout and local or bridge transport without starting a # provider process. # # @return The backend metadata dictionary. # return [dict create backend codex model ${:model} timeout ${:timeout} initializeTimeout ${:initializeTimeout} toolOutputTokens [:outputTokenLimit] transport [expr {${:bridgeHost} eq "" ? "local-stdio" : "bridge-stdio"}]] } :public method run {question state emit} { # # Execute a question through a temporary Codex runner. # # Forward continuation state and events, destroying the runner on both # success and failure. # # @param question Question text supplied to the selected provider. # @param state Opaque retained provider continuation or scan state. # @param emit Event callback prefix; returning false requests cancellation. # # @return The runner's completion or continuation result. # set runner [::nsmcp::CodexQuestionRun new -backend [self] -emit $emit] try { return [$runner run $question $state] } finally { $runner destroy } }XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)