-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
52 lines (46 loc) · 1.26 KB
/
main.go
File metadata and controls
52 lines (46 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Approval workflow without a workflow engine — Go example.
//
// Submit a purchase request with a multi-step approval chain:
// manager approval -> finance approval -> processing.
// No Temporal, no Airflow, no Step Functions.
//
// Usage:
//
// export AXME_API_KEY="your-key"
// go run main.go
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AxmeAI/axme-sdk-go/axme"
)
func main() {
client, err := axme.NewClient(axme.ClientConfig{
APIKey: os.Getenv("AXME_API_KEY"),
})
if err != nil {
log.Fatalf("create client: %v", err)
}
ctx := context.Background()
// Submit purchase request with approval chain
intentID, err := client.SendIntent(ctx, map[string]any{
"intent_type": "purchase.request.v1",
"to_agent": "agent://myorg/production/procurement-service",
"item": "MacBook Pro M4",
"amount_usd": 3499,
"requester": "alice@company.com",
"cost_center": "engineering",
}, axme.RequestOptions{})
if err != nil {
log.Fatalf("send intent: %v", err)
}
fmt.Printf("Purchase request submitted: %s\n", intentID)
// Wait for full approval chain to complete
result, err := client.WaitFor(ctx, intentID, axme.ObserveOptions{})
if err != nil {
log.Fatalf("wait: %v", err)
}
fmt.Printf("Final status: %v\n", result["status"])
}