28 lines
868 B
Go
28 lines
868 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"github.com/samcharles93/archipelago/guards/integrity/internal/audit"
|
|
"github.com/samcharles93/archipelago/sdk/guard"
|
|
)
|
|
|
|
// bundleFrom presents one action to the auditor as the tool call a model asked
|
|
// for, which is the shape its lens was written against.
|
|
func bundleFrom(a guard.Action) *audit.Bundle {
|
|
call := audit.ToolCall{Name: a.Connector + "." + a.Name, ID: a.DecisionKey}
|
|
var args map[string]any
|
|
if err := json.NewDecoder(bytes.NewReader(a.Input)).Decode(&args); err == nil && args != nil {
|
|
call.Arguments = args
|
|
} else {
|
|
call.ArgumentsRaw = string(a.Input)
|
|
}
|
|
return &audit.Bundle{
|
|
ID: a.DecisionKey,
|
|
Subject: audit.Subject{Provider: "archie", Actor: a.Connector, Timestamp: a.At.UTC().Format(time.RFC3339)},
|
|
Response: audit.Response{ToolCalls: []audit.ToolCall{call}},
|
|
}
|
|
}
|