-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
44 lines (39 loc) · 1.22 KB
/
main.ts
File metadata and controls
44 lines (39 loc) · 1.22 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
/**
* Temporal alternative — order fulfillment without workers or determinism constraints.
*
* Temporal needs Activities, Workflows, Workers, and deterministic replay.
* AXME needs one intent.
*
* Usage:
* npm install @axme/axme
* export AXME_API_KEY="your-key"
* npx tsx main.ts
*/
import { AxmeClient } from "@axme/axme";
async function main() {
const client = new AxmeClient({ apiKey: process.env.AXME_API_KEY! });
// Submit order fulfillment — replaces Temporal Workflow + 3 Activities + Worker
const intentId = await client.sendIntent({
intentType: "order.fulfill.v1",
toAgent: "agent://myorg/production/order-service",
payload: {
orderId: "ORD-123",
items: [
{ sku: "WIDGET-A", quantity: 2, price: 29.99 },
{ sku: "GADGET-B", quantity: 1, price: 40.01 },
],
total: 99.99,
shippingAddress: {
street: "123 Main St",
city: "San Francisco",
state: "CA",
zip: "94105",
},
},
});
console.log(`Intent submitted: ${intentId}`);
// Wait for completion — no polling, no webhooks, no worker
const result = await client.waitFor(intentId);
console.log(`Final status: ${result.status}`);
}
main().catch(console.error);