mirror of
https://github.com/humanlayer/humanlayer.git
synced 2025-08-20 19:01:22 +03:00
* Adjust launch params for wui to allow human approval * Adjust fetch for pending function calls * Approval pending display * Initial approve/deny flow * format pass
HumanLayer Go SDK
A minimal, idiomatic Go client for HumanLayer API, designed for the TUI and other Go applications.
Design Principles
- Minimal Surface Area - Only implement what's needed
- Idiomatic Go - Follow Go conventions, not generated code patterns
- No Code Generation - Hand-written for clarity and simplicity
- Context-First - Use context.Context for cancellation and timeouts
- Functional Options - Clean configuration pattern
Installation
go get github.com/humanlayer/humanlayer-go
Usage
package main
import (
"context"
"log"
"github.com/humanlayer/humanlayer-go"
)
func main() {
// Create client with options
client, err := humanlayer.NewClient(
humanlayer.WithAPIKey("your-api-key"),
humanlayer.WithBaseURL("https://api.humanlayer.dev"),
)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
// Get pending function calls (approvals)
functionCalls, err := client.GetPendingFunctionCalls(ctx)
if err != nil {
log.Fatal(err)
}
// Approve a function call
if len(functionCalls) > 0 {
err = client.ApproveFunctionCall(ctx, functionCalls[0].CallID, "Looks good")
if err != nil {
log.Fatal(err)
}
}
// Or deny a function call
// err = client.DenyFunctionCall(ctx, functionCalls[0].CallID, "Need more information")
// Get human contacts
contacts, err := client.GetPendingHumanContacts(ctx)
if err != nil {
log.Fatal(err)
}
// Respond to human contact
if len(contacts) > 0 {
err = client.RespondToHumanContact(ctx, contacts[0].CallID, "Use RS256 for consistency")
if err != nil {
log.Fatal(err)
}
}
}
API Coverage
Core Operations
- GetPendingFunctionCalls
- GetPendingHumanContacts
- ApproveFunctionCall
- DenyFunctionCall
- RespondToHumanContact
Future (as needed)
- WebSocket support for real-time updates
- Batch operations
- Channel configuration