@haven_ai/sdk 0.1.30-alpha.0 → 0.1.32-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -130,8 +130,8 @@ async function quoteAndPay(): Promise<void> {
130
130
  } catch (err) {
131
131
  if (err instanceof HavenPaymentStateError && err.resumeState) {
132
132
  await writeFile(resumeFile, JSON.stringify(err.resumeState, null, 2))
133
- console.error(`Waiting for user approval in Haven. Resume state saved to ${resumeFile}.`)
134
- console.error(`After approval, rerun with HAVEN_RESUME_PAYMENT_ID=${err.resumeState.paymentId}.`)
133
+ console.error(`Payment did not complete in one pass. Resume state saved to ${resumeFile}.`)
134
+ console.error(`Once the funding leg confirms, rerun with HAVEN_RESUME_PAYMENT_ID=${err.resumeState.paymentId}.`)
135
135
  console.error(`The local file fallback is still available with HAVEN_X402_RESUME=1.`)
136
136
  return
137
137
  }
@@ -91,13 +91,18 @@ authorization = post_haven(authorize_path, {
91
91
  "idempotencyKey": f"python-openapi:{payment_required['resource']['url']}",
92
92
  })
93
93
 
94
- if authorization.get("status") == "pending_approval":
94
+ # A payment outside the agent's on-chain budget is DECLINED before any money
95
+ # moves — /x402/authorize answers 403 delegation_budget_exceeded and no intent
96
+ # row is created. There is no approval queue to wait on, so there is nothing to
97
+ # poll: raise the budget in Haven and run this again.
98
+ if not authorization.get("sign_data"):
95
99
  print(json.dumps({
96
- "payment_id": authorization["payment_id"],
100
+ "status": authorization.get("status"),
101
+ "payment_id": authorization.get("payment_id"),
97
102
  "next_action": authorization.get("next_action"),
98
103
  "message": authorization.get("message"),
99
104
  }, indent=2))
100
- sys.exit("Payment is waiting for approval in Haven. Re-run after approval and use /payments/{id}/resume_state.")
105
+ sys.exit("Haven returned no signing payload for this payment — nothing to sign and nothing queued.")
101
106
 
102
107
  sign_hash = authorization["sign_data"]["hash"]
103
108
  signature = sign_raw_hash(sign_hash, DELEGATE_KEY)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven_ai/sdk",
3
- "version": "0.1.30-alpha.0",
3
+ "version": "0.1.32-alpha.0",
4
4
  "description": "TypeScript SDK for Haven — agent wallet infrastructure",
5
5
  "engines": {
6
6
  "node": ">=22"