(sessionID, filePath, name, toolCallID string)
| 137 | } |
| 138 | |
| 139 | func (s Service) ExportArtifact(sessionID, filePath, name, toolCallID string) (string, security.DecisionRecord, error) { |
| 140 | meta, err := s.sessionMeta(sessionID) |
| 141 | if err != nil { |
| 142 | return "", security.DecisionRecord{}, err |
| 143 | } |
| 144 | hostPath, err := s.workspacePath(meta.WorkspacePath, filePath) |
| 145 | if err != nil { |
| 146 | return "", security.DecisionRecord{}, err |
| 147 | } |
| 148 | body, err := os.ReadFile(hostPath) |
| 149 | if err != nil { |
| 150 | return "", security.DecisionRecord{}, err |
| 151 | } |
| 152 | if name == "" { |
| 153 | name = filepath.Base(filePath) |
| 154 | } |
| 155 | artifactID := ids.New("artifact") |
| 156 | artifactPath := filepath.Join(s.Paths.Artifacts, artifactID+"-"+name) |
| 157 | if err := os.WriteFile(artifactPath, body, 0o644); err != nil { |
| 158 | return "", security.DecisionRecord{}, err |
| 159 | } |
| 160 | record, err := s.recordEvent(security.Event{ |
| 161 | Source: "computer_api", |
| 162 | EventType: "artifact_export", |
| 163 | RunID: meta.RunID, |
| 164 | SessionID: sessionID, |
| 165 | ToolCallID: ensureToolCallID(toolCallID), |
| 166 | Path: filePath, |
| 167 | }, map[string]any{ |
| 168 | "path": filePath, |
| 169 | "name": name, |
| 170 | "result_ref": artifactPath, |
| 171 | "bytes": len(body), |
| 172 | }) |
| 173 | return artifactPath, record, err |
| 174 | } |
| 175 | |
| 176 | func (s Service) Call(sessionID, module, function string, args map[string]string, toolCallID string, stream bool) (string, security.DecisionRecord, error) { |
| 177 | meta, err := s.sessionMeta(sessionID) |
no test coverage detected