-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
59 lines (53 loc) · 1.46 KB
/
Copy pathmain.go
File metadata and controls
59 lines (53 loc) · 1.46 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
53
54
55
56
57
58
59
// Temporal alternative — order fulfillment without workers or determinism constraints.
//
// Temporal needs Activities, Workflows, Workers, and deterministic replay.
// AXME needs one intent.
//
// 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 order fulfillment — replaces Temporal Workflow + 3 Activities + Worker
intentID, err := client.SendIntent(ctx, map[string]any{
"intent_type": "order.fulfill.v1",
"to_agent": "agent://myorg/production/order-service",
"order_id": "ORD-123",
"items": []map[string]any{
{"sku": "WIDGET-A", "quantity": 2, "price": 29.99},
{"sku": "GADGET-B", "quantity": 1, "price": 40.01},
},
"total": 99.99,
"shipping_address": map[string]any{
"street": "123 Main St",
"city": "San Francisco",
"state": "CA",
"zip": "94105",
},
}, axme.RequestOptions{})
if err != nil {
log.Fatalf("send intent: %v", err)
}
fmt.Printf("Intent submitted: %s\n", intentID)
// Wait for completion — no polling, no webhooks, no worker
result, err := client.WaitFor(ctx, intentID, axme.ObserveOptions{})
if err != nil {
log.Fatalf("wait: %v", err)
}
fmt.Printf("Final status: %v\n", result["status"])
}