返回 DeepSeek-Reasonix
execution.go
根目录 / internal / jobs / execution.go
1 package jobs
2
3 import (
4 "context"
5
6 "reasonix/internal/tool"
7 )
8
9 // HasTimedOut reports whether teardown returned before every job had unwound.
10 func (r TeardownResult) HasTimedOut() bool { return len(r.TimedOut) > 0 }
11
12 // SetExecution records terminal shell metadata for the background job carried
13 // by ctx. It is host-only metadata and does not change the persisted job log.
14 func SetExecution(ctx context.Context, execution *tool.ShellExecution) {
15 if execution == nil {
16 return
17 }
18 j, _ := ctx.Value(jobCtxKey{}).(*Job)
19 if j == nil {
20 return
21 }
22 j.mu.Lock()
23 j.execution = tool.CloneShellExecution(execution)
24 j.mu.Unlock()
25 }
26
27 // ExecutionForSession returns terminal shell metadata only for a job owned by
28 // parentSession. Task jobs and running shell jobs normally return nil.
29 func (m *Manager) ExecutionForSession(parentSession, id string) *tool.ShellExecution {
30 j := m.get(parentSession, id)
31 if j == nil {
32 return nil
33 }
34 j.mu.Lock()
35 defer j.mu.Unlock()
36 return tool.CloneShellExecution(j.execution)
37 }
38
38 lines GO