MCPcopy Create free account
hub / github.com/ByteYellow/AgentProvenance / ExportArtifact

Method ExportArtifact

internal/computerapi/service.go:139–174  ·  view source on GitHub ↗
(sessionID, filePath, name, toolCallID string)

Source from the content-addressed store, hash-verified

137}
138
139func (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
176func (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)

Callers 1

apiCmdFunction · 0.80

Calls 7

sessionMetaMethod · 0.95
workspacePathMethod · 0.95
recordEventMethod · 0.95
NewFunction · 0.92
ensureToolCallIDFunction · 0.85
ReadFileMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected