- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::nsmcp::CodexQuestionBackend
::nsmcp::CodexQuestionBackendcreate ... \
[ -authenticator (default "::nsmcp::auth") ] \
[ -authorizer (default "::nsmcp::authorization") ] \
[ -bridgeDirectory (default "/work") ] \
[ -bridgeHost (default "") ] \
[ -bridgePort:integer (default "8766") ] \
[ -bridgeSecretFile (default "") ] \
[ -command:required command:required ] \
[ -directory:required directory:required ] \
[ -host (default "") ] \
[ -initializeTimeout (default "30") ] \
[ -launcher:required launcher:required ] \
[ -maxResultBytes (default "131072") ] \
[ -model (default "") ] \
[ -registry (default "::nsmcp::tools") ] \
[ -timeout (default "180") ] \
[ -tokenFile:required tokenFile:required ] \
[ -toolOutputTokens:integer (default "65536") ] \
[ -url:required url:required ]
Defined in /usr/local/ns/tcl/nsmcp/question-backend.tcl
Class Relations
::nx::Class create ::nsmcp::CodexQuestionBackend \ -superclass ::nsmcp::QuestionBackendMethods (to be applied on the object)
initializationSummary (scripted, public)
nsmcp::CodexQuestionBackendinitializationSummary diagnostic
Explain a retained initialization snapshot for the administrator UI.
- Parameters:
- diagnostic (required)
- Sanitized backend diagnostics.
- Returns:
- A bounded description of observed blocked reads.
- Testcases:
- No testcase defined.
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."processTriples (scripted, public)
nsmcp::CodexQuestionBackendprocessTriples capture
Serialize bounded Codex startup diagnostics.
- Parameters:
- capture (required)
- The process and thread snapshot.
- Returns:
- Typed JSON members with approved diagnostic fields.
- Testcases:
- No testcase defined.
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 $triplesMethods (to be applied on instances)
describe (scripted, public)
<instance of nsmcp::CodexQuestionBackend> describe
Describe configured Codex question execution. Report model, timeout and local or bridge transport without starting a provider process.
- Returns:
- The backend metadata dictionary.
- Testcases:
- No testcase defined.
return [dict create backend codex model ${:model} timeout ${:timeout} initializeTimeout ${:initializeTimeout} toolOutputTokens [:outputTokenLimit] transport [expr {${:bridgeHost} eq "" ? "local-stdio" : "bridge-stdio"}]]outputTokenLimit (scripted, public)
<instance of nsmcp::CodexQuestionBackend> outputTokenLimit
Retained backend instances may predate the property after Tcl reload.
- Testcases:
- No testcase defined.
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 $valuerun (scripted, public)
<instance of nsmcp::CodexQuestionBackend> 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.
- Parameters:
- question (required)
- Question text supplied to the selected provider.
- state (required)
- Opaque retained provider continuation or scan state.
- emit (required)
- Event callback prefix; returning false requests cancellation.
- Returns:
- The runner's completion or continuation result.
- Testcases:
- No testcase defined.
set runner [::nsmcp::CodexQuestionRun new -backend [self] -emit $emit] try { return [$runner run $question $state] } finally { $runner destroy }
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
![[i]](/resources/acs-subsite/ZoomIn16.gif)