Files
humanlayer/humanlayer-go
Sundeep Malladi 26ca56c8e5 Launch daemon with correct args; initial UI for approve/deny (#227)
* Adjust launch params for wui to allow human approval

* Adjust fetch for pending function calls

* Approval pending display

* Initial approve/deny flow

* format pass
2025-06-19 14:31:03 -05:00
..
2025-05-27 14:52:05 -07:00
2025-05-27 14:52:05 -07:00
2025-05-27 14:58:49 -07:00

HumanLayer Go SDK

A minimal, idiomatic Go client for HumanLayer API, designed for the TUI and other Go applications.

Design Principles

  1. Minimal Surface Area - Only implement what's needed
  2. Idiomatic Go - Follow Go conventions, not generated code patterns
  3. No Code Generation - Hand-written for clarity and simplicity
  4. Context-First - Use context.Context for cancellation and timeouts
  5. 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