@tempoxyz/patron 0.0.14 → 0.0.16

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/dist/bin.js CHANGED
@@ -4,10 +4,10 @@ const require = __patronCreateRequire(import.meta.url)
4
4
 
5
5
  // src/bin.ts
6
6
  if (process.argv[2] === "hook") {
7
- const { runHookProcess } = await import("./chunks/hook-process-RURAGR7W.js");
7
+ const { runHookProcess } = await import("./chunks/hook-process-GKUDU2B3.js");
8
8
  await runHookProcess().catch(() => void 0);
9
9
  process.exit(0);
10
10
  } else {
11
- const { run } = await import("./chunks/-CE2UCGLQ.js");
11
+ const { run } = await import("./chunks/-UIKBA3CN.js");
12
12
  process.exitCode = await run(process.argv.slice(2));
13
13
  }
@@ -40,7 +40,7 @@ import {
40
40
  withPatronStatus,
41
41
  withoutPatronHandlers,
42
42
  writeJsonObject
43
- } from "./chunk-XUDTL3AP.js";
43
+ } from "./chunk-4Z6ZIXMK.js";
44
44
  import {
45
45
  AGENT_IDS,
46
46
  ensureHome,
@@ -53,7 +53,7 @@ import {
53
53
  withLock,
54
54
  writeConfig,
55
55
  writePrivateFile
56
- } from "./chunk-A66D2RFJ.js";
56
+ } from "./chunk-FXE4CGY7.js";
57
57
 
58
58
  // src/index.ts
59
59
  import { readFileSync } from "node:fs";
@@ -614,7 +614,7 @@ ${styleText(title, "bold", color)}
614
614
  // src/purchase.ts
615
615
  var REFILL_LOCK_STALE_MS = 5 * 60 * 1e3;
616
616
  var defaultOpenWallet = async (settings, config, issuer, maxUnits) => {
617
- const { openWallet } = await import("./wallet-P26QSI4Y.js");
617
+ const { openWallet } = await import("./wallet-JDUPZN7E.js");
618
618
  return openWallet(settings, config.wallet, issuer, maxUnits);
619
619
  };
620
620
  async function buyWithinBudget(settings, config, wanted, openWallet = defaultOpenWallet) {
@@ -835,6 +835,10 @@ function done(deps, message) {
835
835
  async function main(deps) {
836
836
  const config = await readConfig(deps.settings.home);
837
837
  if (!config) return setup(deps);
838
+ if (deps.interactive) {
839
+ say(deps, scrollBanner(VERSION, deps.color));
840
+ say(deps);
841
+ }
838
842
  await syncAgents(deps, config);
839
843
  await status(deps, deps.interactive);
840
844
  }
@@ -881,7 +885,7 @@ async function setup(deps) {
881
885
  deps,
882
886
  settings.privateKey ? "Using PATRON_PRIVATE_KEY" : "Signing in with Tempo Wallet"
883
887
  );
884
- const { signIn } = await import("./wallet-P26QSI4Y.js");
888
+ const { signIn } = await import("./wallet-JDUPZN7E.js");
885
889
  const account = await signIn(settings, { budgetUnits, issuer, output: deps.stdout });
886
890
  done(deps, `Signed in as ${account.address}`);
887
891
  const config = {
@@ -995,7 +999,7 @@ async function changeBudget(deps, input) {
995
999
  } else budget = await askBudget(deps, config.monthlyBudgetUsd);
996
1000
  if (config.wallet === "tempo" && budget > config.monthlyBudgetUsd) {
997
1001
  step(deps, "Approve the new spending limit in Tempo Wallet");
998
- const { authorizeBudget } = await import("./wallet-P26QSI4Y.js");
1002
+ const { authorizeBudget } = await import("./wallet-JDUPZN7E.js");
999
1003
  const issuer = await loadIssuer(settings.home, settings.gatewayUrl, {
1000
1004
  fetch: deps.fetch
1001
1005
  });
@@ -1107,7 +1111,7 @@ async function setName(deps, name) {
1107
1111
  const issuer = await loadIssuer(settings.home, settings.gatewayUrl, {
1108
1112
  fetch: deps.fetch
1109
1113
  });
1110
- const open = deps.openWallet ?? (async (s, c, i, max) => (await import("./wallet-P26QSI4Y.js")).openWallet(s, c.wallet, i, max));
1114
+ const open = deps.openWallet ?? (async (s, c, i, max) => (await import("./wallet-JDUPZN7E.js")).openWallet(s, c.wallet, i, max));
1111
1115
  const wallet = await open(settings, config, issuer, 0n);
1112
1116
  await setProfile(settings.gatewayUrl, wallet, name, deps.fetch);
1113
1117
  await writeConfig(settings.home, { ...config, name });
@@ -10,7 +10,7 @@ import {
10
10
  statePaths,
11
11
  withLock,
12
12
  writePrivateFile
13
- } from "./chunk-A66D2RFJ.js";
13
+ } from "./chunk-FXE4CGY7.js";
14
14
 
15
15
  // ../../node_modules/.pnpm/tldts@7.4.19/node_modules/tldts/dist/cjs/index.js
16
16
  var require_cjs = __commonJS({
@@ -28477,11 +28477,25 @@ var SiteInfo = external_exports.object({
28477
28477
  });
28478
28478
  var LeaderboardResponse = external_exports.object({
28479
28479
  patrons: external_exports.array(external_exports.object({ name: external_exports.string(), tokens: external_exports.number().int(), usd })),
28480
+ /** Claimed sites and unclaimed ones past the listing threshold, by earnings. */
28480
28481
  sites: external_exports.array(
28481
- external_exports.object({ domain: external_exports.string(), earnedUsd: usd, visits: external_exports.number().int() })
28482
+ external_exports.object({
28483
+ domain: external_exports.string(),
28484
+ earnedUsd: usd,
28485
+ visits: external_exports.number().int(),
28486
+ /** Whether the owner proved the domain; older gateways listed only claimed sites. */
28487
+ claimed: external_exports.boolean().default(true)
28488
+ })
28482
28489
  ),
28483
- /** Claimed X profiles, by earnings: their own leaderboard. */
28484
- creators: external_exports.array(external_exports.object({ handle: external_exports.string(), earnedUsd: usd, visits: external_exports.number().int() })).default([]),
28490
+ /** X profiles, claimed or past the listing threshold, by earnings: their own leaderboard. */
28491
+ creators: external_exports.array(
28492
+ external_exports.object({
28493
+ handle: external_exports.string(),
28494
+ earnedUsd: usd,
28495
+ visits: external_exports.number().int(),
28496
+ claimed: external_exports.boolean().default(true)
28497
+ })
28498
+ ).default([]),
28485
28499
  totals: external_exports.object({ tokens: external_exports.number().int(), sites: external_exports.number().int(), usd })
28486
28500
  });
28487
28501
  var ClaimRequest = external_exports.object({
@@ -41,8 +41,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
41
41
  ));
42
42
 
43
43
  // src/state.ts
44
- import { chmod, mkdir, readFile, realpath, rename, writeFile } from "node:fs/promises";
45
- import { join } from "node:path";
44
+ import {
45
+ chmod,
46
+ lstat,
47
+ mkdir,
48
+ readFile,
49
+ readlink,
50
+ rename,
51
+ rm as rm2,
52
+ writeFile
53
+ } from "node:fs/promises";
54
+ import { dirname, join, resolve } from "node:path";
46
55
 
47
56
  // src/lock.ts
48
57
  import { open, rm, stat } from "node:fs/promises";
@@ -65,7 +74,7 @@ async function withLock(path, fn, options = {}) {
65
74
  continue;
66
75
  }
67
76
  if (Date.now() > deadline) throw new Error(`Patron state is busy: ${path}`);
68
- await new Promise((resolve) => setTimeout(resolve, 10 + Math.random() * 20));
77
+ await new Promise((resolve2) => setTimeout(resolve2, 10 + Math.random() * 20));
69
78
  }
70
79
  }
71
80
  try {
@@ -121,11 +130,37 @@ async function readJson(path) {
121
130
  }
122
131
  }
123
132
  async function writePrivateFile(link, contents) {
124
- const path = await realpath(link).catch(() => link);
133
+ const target = await symlinkTarget(link);
134
+ if (target !== link) {
135
+ try {
136
+ return await replaceFile(target, contents);
137
+ } catch (error) {
138
+ const code = error.code;
139
+ if (code !== "EACCES" && code !== "EROFS" && code !== "EPERM") throw error;
140
+ }
141
+ }
142
+ await replaceFile(link, contents);
143
+ }
144
+ async function symlinkTarget(path, depth = 0) {
145
+ if (depth > 8) return path;
146
+ try {
147
+ const stats = await lstat(path);
148
+ if (!stats.isSymbolicLink()) return path;
149
+ return symlinkTarget(resolve(dirname(path), await readlink(path)), depth + 1);
150
+ } catch {
151
+ return path;
152
+ }
153
+ }
154
+ async function replaceFile(path, contents) {
125
155
  const temporary = `${path}.${process.pid}.${Date.now()}.tmp`;
126
- await writeFile(temporary, contents, { mode: 384 });
127
- await chmod(temporary, 384);
128
- await rename(temporary, path);
156
+ try {
157
+ await writeFile(temporary, contents, { mode: 384 });
158
+ await chmod(temporary, 384);
159
+ await rename(temporary, path);
160
+ } catch (error) {
161
+ await rm2(temporary, { force: true }).catch(() => void 0);
162
+ throw error;
163
+ }
129
164
  }
130
165
  async function readConfig(home) {
131
166
  const value = await readJson(statePaths(home).config).catch(() => void 0);
@@ -12,14 +12,14 @@ import {
12
12
  settingsFor,
13
13
  spend,
14
14
  startRefill
15
- } from "./chunk-XUDTL3AP.js";
15
+ } from "./chunk-4Z6ZIXMK.js";
16
16
  import {
17
17
  readConfig,
18
18
  readUsage,
19
19
  updateUsage,
20
20
  withLock,
21
21
  writePrivateFile
22
- } from "./chunk-A66D2RFJ.js";
22
+ } from "./chunk-FXE4CGY7.js";
23
23
 
24
24
  // src/hook.ts
25
25
  import { homedir } from "node:os";
@@ -2,7 +2,7 @@ import { createRequire as __patronCreateRequire } from 'node:module'
2
2
  const require = __patronCreateRequire(import.meta.url)
3
3
  import {
4
4
  statePaths
5
- } from "./chunk-A66D2RFJ.js";
5
+ } from "./chunk-FXE4CGY7.js";
6
6
 
7
7
  // src/wallet.ts
8
8
  import { Store } from "accounts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempoxyz/patron",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Pay the websites your AI agents read, privately",
5
5
  "type": "module",
6
6
  "bin": {