@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.
- package/README.md +110 -91
- package/dist/index.cjs +175 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +127 -37
- package/dist/index.d.ts +127 -37
- package/dist/index.js +175 -109
- package/dist/index.js.map +1 -1
- package/examples/mcp-x402-sse.ts +2 -2
- package/examples/x402_openapi_python.py +8 -3
- package/package.json +1 -1
package/examples/mcp-x402-sse.ts
CHANGED
|
@@ -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(`
|
|
134
|
-
console.error(`
|
|
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
|
-
|
|
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
|
-
"
|
|
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("
|
|
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)
|