@paydlux/agent 0.1.14 → 0.1.15

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.
Files changed (2) hide show
  1. package/dist/desk.js +15 -5
  2. package/package.json +1 -1
package/dist/desk.js CHANGED
@@ -175,14 +175,24 @@ export class ApprovalDesk {
175
175
  */
176
176
  sweepExpired() {
177
177
  const now = Date.now();
178
+ // A request nobody has even opened yet gets the same window as one the
179
+ // phone is holding: the seller said how long a human has to decide, and a
180
+ // parked request past that window is not going to be answered. Leaving it
181
+ // `pending` forever means the buyer's retry keeps reusing a handle that
182
+ // will never move, instead of parking a fresh one a human will actually see.
183
+ const decideWindow = (this.cfg.decideWithinSeconds ?? 1800) * 1000;
178
184
  for (const r of this.records.values()) {
179
- if (r.status !== "awaiting_phone" && r.status !== "approved")
180
- continue;
181
- const exp = r.challenge?.summary.expiresAt;
182
- if (!exp || Number(exp) * 1000 > now)
185
+ let deadline = null;
186
+ if (r.status === "pending") {
187
+ deadline = r.at + decideWindow;
188
+ }
189
+ else if (r.status === "awaiting_phone" || r.status === "approved") {
190
+ deadline = r.challenge?.summary.expiresAt ? Number(r.challenge.summary.expiresAt) * 1000 : null;
191
+ }
192
+ if (deadline === null || deadline > now)
183
193
  continue;
184
194
  r.status = "expired";
185
- r.reason = `nobody approved it before the deadline (${new Date(Number(exp) * 1000).toISOString()})`;
195
+ r.reason = `nobody approved it before the deadline (${new Date(deadline).toISOString()})`;
186
196
  console.log(`[desk] ${r.id} expired: the deadline passed with no approval`);
187
197
  }
188
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paydlux/agent",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Payments for AI agents that a human approves. Spending mandates enforced on the Stellar ledger: 2-of-2 vault, pre-authorised transaction envelopes, HTTP 402, USDC.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",