Packages
@loop-engine/adapter-commerce-gateway
Install
1npm install @loop-engine/adapter-commerce-gatewayInstall one LLM SDK based on provider choice:
1npm install @anthropic-ai/sdk2# or3npm install openaiPrerequisites
COMMERCE_GATEWAY_URLCOMMERCE_GATEWAY_API_KEY
CommerceGatewayClient
1const client = new CommerceGatewayClient({2 baseUrl: process.env.COMMERCE_GATEWAY_URL!,3 apiKey: process.env.COMMERCE_GATEWAY_API_KEY!4})Methods:
getInventory(sku)getInventoryBatch(skus)getDemandForecast(sku, horizon?)getSuppliers(sku)getCurrentPrice(sku)getPriceHistory(sku, days)createPurchaseOrder(order)(write operation; post-approval only)recordLoopOutcome(outcome)(optional endpoint support by deployment)
buildProcurementActor
1const actor = buildProcurementActor({2 gatewayClient: client,3 llmProvider: 'openai',4 apiKey: process.env.OPENAI_API_KEY!,5 confidenceThreshold: 0.86})Returns async (context) => Evidence, where context.instance.data.sku drives Gateway queries and the actor returns evidence for a guarded transition.
Evidence shape
1type ProcurementEvidence = {2 recommendedSku: string3 recommendedQty: number4 estimatedCost: number5 supplierId: string6 confidence: number7 rationale: string8 gatewayRequestIds: string[]9 modelUsed: string10 timestamp: string11 _confidence: number12}Read vs write boundary
AI actor functions in this package call read endpoints only. Order creation stays in automation flows after a human approval transition passes guard checks.
buildPricingActor
Related example
See LLM Commerce Gateway Integration for the end-to-end procurement flow.