返回 DeepSeek-Reasonix
tool.go
根目录 / internal / eventwire / tool.go
1 package eventwire
2
3 import (
4 "encoding/json"
5
6 "reasonix/internal/event"
7 "reasonix/internal/provider"
8 )
9
10 // Tool is the JSON form of an event.Tool.
11 type Tool struct {
12 RunState provider.ToolRunState `json:"runState,omitempty"`
13 Diagnostic json.RawMessage `json:"diagnostic,omitempty"`
14 Verifying bool `json:"verifying,omitempty"`
15 ID string `json:"id,omitempty"`
16 Name string `json:"name"`
17 Args string `json:"args,omitempty" externalizable:"true"`
18 Todos []event.Todo `json:"todos"`
19 TodoWritten bool `json:"todoWritten,omitempty"`
20 ResolvedName string `json:"resolvedName,omitempty"`
21 CapabilityID string `json:"capabilityId,omitempty"`
22 Output string `json:"output,omitempty" externalizable:"true"`
23 Err string `json:"err,omitempty" externalizable:"true"`
24 ReadOnly bool `json:"readOnly"`
25 Truncated bool `json:"truncated,omitempty"`
26 DurationMs int64 `json:"durationMs,omitempty"`
27 StartedAt int64 `json:"startedAt,omitempty"` // unix ms; zero when the call never ran
28 EndedAt int64 `json:"endedAt,omitempty"`
29 Partial bool `json:"partial,omitempty"`
30 ArgChars int `json:"argChars,omitempty"`
31 Refreshed bool `json:"refreshed,omitempty"`
32 ParentID string `json:"parentId,omitempty"`
33 AttemptID string `json:"attemptId,omitempty"` // host-local stream_attempt id for speculative partials
34 SubagentRef string `json:"subagentRef,omitempty"`
35 SubagentStatus string `json:"subagentStatus,omitempty"`
36 SubagentErrorCode string `json:"subagentErrorCode,omitempty"`
37 SubagentRetryable bool `json:"subagentRetryable,omitempty"`
38 Diff string `json:"diff,omitempty" externalizable:"true"`
39 Added int `json:"added,omitempty"`
40 Removed int `json:"removed,omitempty"`
41 Profile *Profile `json:"profile,omitempty"`
42 Execution *ShellExecution `json:"execution,omitempty"`
43 PresentedFiles []provider.PresentedFile `json:"presentedFiles,omitempty"`
44 }
45
46 func toWireTool(in event.Tool) *Tool {
47 todos := make([]event.Todo, len(in.Todos))
48 copy(todos, in.Todos)
49 wt := &Tool{
50 RunState: in.RunState,
51 Diagnostic: append(json.RawMessage(nil), in.Diagnostic...),
52 ID: in.ID, Name: in.Name, Args: in.Args,
53 Todos: todos, TodoWritten: in.TodoWritten,
54 ResolvedName: in.ResolvedName, CapabilityID: in.CapabilityID,
55 Output: in.Output, Err: in.Err,
56 ReadOnly: in.ReadOnly, Truncated: in.Truncated,
57 Verifying: in.Verifying,
58 DurationMs: in.DurationMs, Partial: in.Partial,
59 StartedAt: in.StartedAt, EndedAt: in.EndedAt,
60 ArgChars: in.ArgChars, Refreshed: in.Refreshed,
61 ParentID: in.ParentID, AttemptID: in.AttemptID,
62 Diff: in.Diff, Added: in.Added, Removed: in.Removed,
63 SubagentRef: in.SubagentRef, SubagentStatus: in.SubagentStatus,
64 SubagentErrorCode: in.SubagentErrorCode, SubagentRetryable: in.SubagentRetryable,
65 PresentedFiles: append([]provider.PresentedFile(nil), in.PresentedFiles...),
66 }
67 if in.Profile != nil {
68 wt.Profile = &Profile{Model: in.Profile.Model, Effort: in.Profile.Effort}
69 }
70 if in.Execution != nil {
71 wt.Execution = toWireShellExecution(in.Execution)
72 }
73 return wt
74 }
75
75 lines GO