agentic-payments 0.1.7 → 0.1.9

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 (3) hide show
  1. package/bin/cli.js +46 -0
  2. package/bin/mcp.js +23 -7
  3. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -3,8 +3,54 @@
3
3
  /**
4
4
  * Agentic Payments CLI
5
5
  * Command-line interface for AP2, ACP, and MCP operations
6
+ *
7
+ * Includes aggressive cache cleanup to prevent ENOTEMPTY errors in remote environments
6
8
  */
7
9
 
10
+ // Clean up npx cache on startup to prevent ENOTEMPTY errors
11
+ if (process.env.npm_execpath && process.env.npm_execpath.includes('npx')) {
12
+ try {
13
+ const { existsSync, rmSync, readdirSync, statSync } = await import('fs');
14
+ const { homedir } = await import('os');
15
+ const { join } = await import('path');
16
+
17
+ const npmHome = process.env.NPM_CONFIG_CACHE || join(homedir(), '.npm');
18
+ const npxCacheDir = join(npmHome, '_npx');
19
+
20
+ if (existsSync(npxCacheDir)) {
21
+ const cacheEntries = readdirSync(npxCacheDir);
22
+ const now = Date.now();
23
+ const maxAge = 24 * 60 * 60 * 1000; // 24 hours
24
+
25
+ // Find and remove stale agentic-payments cache
26
+ for (const entry of cacheEntries) {
27
+ try {
28
+ const entryPath = join(npxCacheDir, entry);
29
+ const pkgPath = join(entryPath, 'node_modules', 'agentic-payments');
30
+
31
+ if (existsSync(pkgPath)) {
32
+ // Check if cache is stale (older than 24 hours)
33
+ const stats = statSync(entryPath);
34
+ const age = now - stats.mtimeMs;
35
+
36
+ if (age > maxAge) {
37
+ // Remove entire cache entry for stale caches
38
+ rmSync(entryPath, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
39
+ } else {
40
+ // For fresh caches, just remove the package directory
41
+ rmSync(pkgPath, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
42
+ }
43
+ }
44
+ } catch (e) {
45
+ // Ignore individual cleanup errors - continue with others
46
+ }
47
+ }
48
+ }
49
+ } catch (error) {
50
+ // Silently fail - don't block CLI startup
51
+ }
52
+ }
53
+
8
54
  const args = process.argv.slice(2);
9
55
  const command = args[0];
10
56
 
package/bin/mcp.js CHANGED
@@ -2,12 +2,14 @@
2
2
  /**
3
3
  * MCP Server Binary Entry Point
4
4
  * Launches the Agentic Payments MCP server
5
+ *
6
+ * Includes aggressive cache cleanup to prevent ENOTEMPTY errors in remote environments
5
7
  */
6
8
 
7
9
  // Clean up npx cache on startup to prevent ENOTEMPTY errors
8
10
  if (process.env.npm_execpath && process.env.npm_execpath.includes('npx')) {
9
11
  try {
10
- const { existsSync, rmSync, readdirSync } = await import('fs');
12
+ const { existsSync, rmSync, readdirSync, statSync } = await import('fs');
11
13
  const { homedir } = await import('os');
12
14
  const { join } = await import('path');
13
15
 
@@ -16,16 +18,30 @@ if (process.env.npm_execpath && process.env.npm_execpath.includes('npx')) {
16
18
 
17
19
  if (existsSync(npxCacheDir)) {
18
20
  const cacheEntries = readdirSync(npxCacheDir);
21
+ const now = Date.now();
22
+ const maxAge = 24 * 60 * 60 * 1000; // 24 hours
19
23
 
20
24
  // Find and remove stale agentic-payments cache
21
25
  for (const entry of cacheEntries) {
22
- const pkgPath = join(npxCacheDir, entry, 'node_modules', 'agentic-payments');
23
- if (existsSync(pkgPath)) {
24
- try {
25
- rmSync(join(npxCacheDir, entry), { recursive: true, force: true, maxRetries: 3 });
26
- } catch (e) {
27
- // Ignore cleanup errors
26
+ try {
27
+ const entryPath = join(npxCacheDir, entry);
28
+ const pkgPath = join(entryPath, 'node_modules', 'agentic-payments');
29
+
30
+ if (existsSync(pkgPath)) {
31
+ // Check if cache is stale (older than 24 hours)
32
+ const stats = statSync(entryPath);
33
+ const age = now - stats.mtimeMs;
34
+
35
+ if (age > maxAge) {
36
+ // Remove entire cache entry for stale caches
37
+ rmSync(entryPath, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
38
+ } else {
39
+ // For fresh caches, just remove the package directory
40
+ rmSync(pkgPath, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
41
+ }
28
42
  }
43
+ } catch (e) {
44
+ // Ignore individual cleanup errors - continue with others
29
45
  }
30
46
  }
31
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-payments",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Dual-protocol payment infrastructure for autonomous AI commerce (AP2 + ACP)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",