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

Method Call

internal/computerapi/service.go:176–212  ·  view source on GitHub ↗
(sessionID, module, function string, args map[string]string, toolCallID string, stream bool)

Source from the content-addressed store, hash-verified

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)
178 if err != nil {
179 return "", security.DecisionRecord{}, err
180 }
181 if module != "shell" || function != "exec" {
182 return "", security.DecisionRecord{}, fmt.Errorf("unsupported call target %s/%s; v1 supports shell/exec", module, function)
183 }
184 command := strings.TrimSpace(args["command"])
185 if command == "" {
186 return "", security.DecisionRecord{}, fmt.Errorf("call arg command is required")
187 }
188 driver, err := runtimeplane.NewDriver("docker", s.Paths)
189 if err != nil {
190 return "", security.DecisionRecord{}, err
191 }
192 processID, err := control.Service{DB: s.DB, Paths: s.Paths, Driver: driver}.Exec(sessionID, []string{"sh", "-lc", command}, stream)
193 if err != nil {
194 return "", security.DecisionRecord{}, err
195 }
196 record, err := s.recordEvent(security.Event{
197 Source: "computer_api",
198 EventType: "call",
199 RunID: meta.RunID,
200 SessionID: sessionID,
201 ToolCallID: ensureToolCallID(toolCallID),
202 ProcessID: processID,
203 Args: []string{module, function, command},
204 }, map[string]any{
205 "module": module,
206 "function": function,
207 "command": command,
208 "process_id": processID,
209 "result_ref": "process:" + processID,
210 })
211 return processID, record, err
212}
213
214func (s Service) sessionMeta(sessionID string) (SessionMeta, error) {
215 var meta SessionMeta

Callers 1

apiCmdFunction · 0.80

Calls 4

sessionMetaMethod · 0.95
recordEventMethod · 0.95
ensureToolCallIDFunction · 0.85
ExecMethod · 0.65

Tested by

no test coverage detected