-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
37 lines (32 loc) · 1.04 KB
/
main.ts
File metadata and controls
37 lines (32 loc) · 1.04 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
/**
* Approval workflow without a workflow engine — TypeScript example.
*
* Submit a purchase request with a multi-step approval chain:
* manager approval → finance approval → processing.
* No Temporal, no Airflow, no Step Functions.
*
* 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 purchase request with approval chain
const intentId = await client.sendIntent({
intentType: "purchase.request.v1",
toAgent: "agent://myorg/production/procurement-service",
payload: {
item: "MacBook Pro M4",
amountUsd: 3499,
requester: "alice@company.com",
costCenter: "engineering",
},
});
console.log(`Purchase request submitted: ${intentId}`);
// Wait for full approval chain to complete
const result = await client.waitFor(intentId);
console.log(`Final status: ${result.status}`);
}
main().catch(console.error);