Actions SDK Overview
Build custom agents with TypeScript decorators and built-in tools.
Introduction
The Hyperfold Actions SDK provides a declarative way to build commerce agents using TypeScript. Define agent behavior with decorators, leverage built-in tools for common operations, and let the SDK handle the infrastructure complexity.
The SDK is designed for developers who need custom agent logic beyond the reference implementations. For simpler use cases, deploy pre-built agents directly with the CLI.
Installation
bash
1
2
3
4
5
6
7
8
# Install the Actions SDK$ pnpm add @hyperfold/actions-sdk # Or with npm$ npm install @hyperfold/actions-sdk # Peer dependencies (if not already installed)$ pnpm add @google-cloud/firestore @google-cloud/pubsubArchitecture
The SDK sits between your agent code and GCP infrastructure:
┌───────────────────────────────────────────────────────────┐
│ Your Agent Code │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ @HyperfoldAgent({ ... }) │ │
│ │ class MyAgent { │ │
│ │ @OnACPEvent('search') → handles ACP search │ │
│ │ @OnACPEvent('quote') → handles price quotes │ │
│ │ @OnSchedule('...') → scheduled tasks │ │
│ │ @OnEndpoint('/...') → custom HTTP endpoints │ │
│ │ } │ │
│ └─────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────┐
│ Actions SDK Runtime │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ ACP Router │ │ LLM Client │ │ Tool Registry │ │
│ │ (events) │ │ (OpenAI, │ │ (getProduct, │ │
│ │ │ │ Gemini) │ │ calculatePrice) │ │
│ └─────────────┘ └─────────────┘ └─────────────────┘ │
└───────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────┐
│ GCP Infrastructure │
│ ┌───────────┐ ┌───────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Firestore │ │ Pub/Sub │ │ Vertex │ │ Cloud │ │
│ │ (state) │ │ (events) │ │ AI │ │ Run │ │
│ └───────────┘ └───────────┘ └─────────┘ └─────────┘ │
└───────────────────────────────────────────────────────────┘Complete Example
Here's a complete negotiator agent using the SDK:
typescript
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { HyperfoldAgent, OnACPEvent, OnSchedule, OnEndpoint, getProduct, calculateDynamicPrice, checkInventory,} from '@hyperfold/actions-sdk'; @HyperfoldAgent({ name: 'sales-negotiator', type: 'negotiator', model: { provider: 'openai', model: 'gpt-4o', temperature: 0.7, }, systemPrompt: ` You are a sales agent for Acme Sports. Help customers find products and negotiate fair prices. Never go below the floor price. `,})export class SalesNegotiator { @OnACPEvent('search') async handleSearch(query: string, filters: SearchFilters) { // Semantic search across product catalog const products = await this.catalog.search(query, filters); return { results: products, semantic_confidence: products[0]?.confidence || 0, }; } @OnACPEvent('quote') async handleQuote(productId: string, offer: number, context: BuyerContext) { const product = await getProduct(productId); const dynamicPrice = await calculateDynamicPrice(product, context); if (offer >= dynamicPrice.floor) { // Acceptable offer - decide whether to accept or counter if (offer >= dynamicPrice.target) { return { status: 'accept', price: offer }; } else { return { status: 'counter_offer', price: dynamicPrice.suggested, reasoning: dynamicPrice.explanation, }; } } else { return { status: 'reject', reason: 'Below minimum acceptable price', counter: dynamicPrice.floor, }; } } @OnSchedule('0 9 * * *') // Daily at 9 AM async dailyReport() { const stats = await this.analytics.getDailyStats(); await this.notifications.sendSlack({ channel: '#sales', message: `Daily Report: ${stats.conversions} conversions, $${stats.revenue}`, }); } @OnEndpoint('/health') async healthCheck() { return { status: 'healthy', timestamp: new Date().toISOString() }; }}Decorators Overview
Decorators define how your agent responds to events:
typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// @HyperfoldAgent - Define an agent class@HyperfoldAgent({ name: 'my-agent', type: 'negotiator', // negotiator, fulfillment, recommender, etc. model: { ... }, // LLM configuration systemPrompt: '...', // Agent instructions})class MyAgent { } // @OnACPEvent - Handle ACP protocol events@OnACPEvent('search') // Product search@OnACPEvent('quote') // Price quote request@OnACPEvent('checkout') // Checkout initiation@OnACPEvent('finalize') // Payment finalization // @OnSchedule - Scheduled tasks (cron syntax)@OnSchedule('0 * * * *') // Every hour@OnSchedule('0 9 * * 1') // Monday at 9 AM // @OnEndpoint - Custom HTTP endpoints@OnEndpoint('/webhook') // Handle webhooks@OnEndpoint('/health') // Health checks| Decorator | Purpose |
|---|---|
@HyperfoldAgent | Define agent class with configuration |
@OnACPEvent | Handle ACP protocol events |
@OnSchedule | Run tasks on a schedule |
@OnEndpoint | Expose custom HTTP endpoints |
Built-in Tools
The SDK includes tools for common commerce operations:
typescript
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
import { // Product tools getProduct, searchProducts, checkInventory, // Pricing tools calculateDynamicPrice, getCompetitorPrice, applyDiscount, // Customer tools getCustomerProfile, updateLoyaltyTier, getOrderHistory, // Order tools createOrder, updateOrderStatus, processRefund, // Notification tools sendEmail, sendSMS, postToSlack, // Integration tools syncToShopify, updateSalesforce,} from '@hyperfold/actions-sdk';