agentic-payments 0.1.6 → 0.1.8

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 +46 -0
  3. package/package.json +2 -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,8 +2,54 @@
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
 
9
+ // Clean up npx cache on startup to prevent ENOTEMPTY errors
10
+ if (process.env.npm_execpath && process.env.npm_execpath.includes('npx')) {
11
+ try {
12
+ const { existsSync, rmSync, readdirSync, statSync } = await import('fs');
13
+ const { homedir } = await import('os');
14
+ const { join } = await import('path');
15
+
16
+ const npmHome = process.env.NPM_CONFIG_CACHE || join(homedir(), '.npm');
17
+ const npxCacheDir = join(npmHome, '_npx');
18
+
19
+ if (existsSync(npxCacheDir)) {
20
+ const cacheEntries = readdirSync(npxCacheDir);
21
+ const now = Date.now();
22
+ const maxAge = 24 * 60 * 60 * 1000; // 24 hours
23
+
24
+ // Find and remove stale agentic-payments cache
25
+ for (const entry of cacheEntries) {
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
+ }
42
+ }
43
+ } catch (e) {
44
+ // Ignore individual cleanup errors - continue with others
45
+ }
46
+ }
47
+ }
48
+ } catch (error) {
49
+ // Silently fail - don't block server startup
50
+ }
51
+ }
52
+
7
53
  import('../dist/mcp/index.js').catch(err => {
8
54
  console.error('[MCP] Failed to start server:', err);
9
55
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-payments",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Dual-protocol payment infrastructure for autonomous AI commerce (AP2 + ACP)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,6 +45,7 @@
45
45
  "LICENSE-APACHE"
46
46
  ],
47
47
  "scripts": {
48
+ "preinstall": "node scripts/cleanup-npx-cache.js || true",
48
49
  "prebuild": "npm run clean",
49
50
  "build": "npm run build:ts",
50
51
  "build:wasm": "echo 'WASM build skipped - using native TypeScript implementation'",