@pixeloffice-eu/x402 1.0.0 → 1.0.2

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 CHANGED
@@ -27,7 +27,7 @@ const client = new PixelRouterX402Client({
27
27
 
28
28
  // Autonomous LLM invocation with automatic HTTP 402 negotiation
29
29
  const response = await client.createChatCompletion({
30
- model: 'ox-alpha', // Or 'deepseek-chat', 'claude-3.5-sonnet'
30
+ model: 'blun-auto', // Or 'deepseek-chat', 'claude-3.5-sonnet'
31
31
  messages: [
32
32
  { role: 'user', content: 'Execute autonomous codebase refactor.' }
33
33
  ]
@@ -52,7 +52,7 @@ const openai = wrapOpenAI(new OpenAI({
52
52
  });
53
53
 
54
54
  const completion = await openai.chat.completions.create({
55
- model: 'ox-alpha',
55
+ model: 'blun-auto',
56
56
  messages: [{ role: 'user', content: 'Hello autonomous world!' }]
57
57
  });
58
58
  ```
package/bin/cli.js ADDED
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * PixelOffice x402 CLI Scaffolder (Node.js & TypeScript)
5
+ * Generates 1-Click Starter Templates for Autonomous Agents.
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const AGENT_MJS_TEMPLATE = `/**
12
+ * Autonomous AI Agent with x402 Solana Micro-Payments & Stateful Memory Bridge
13
+ * Powered by PixelRouter (https://pixeloffice.eu/router.html#x402)
14
+ */
15
+
16
+ import 'dotenv/config';
17
+ import { PixelRouterX402Client, wrapOpenAI } from '@pixeloffice-eu/x402';
18
+ import OpenAI from 'openai';
19
+
20
+ const SOLANA_PRIVATE_KEY = process.env.SOLANA_AGENT_PRIVATE_KEY;
21
+ const PIXELROUTER_BASE_URL = process.env.PIXELROUTER_BASE_URL || 'https://api.pixeloffice.eu/v1';
22
+ const SESSION_ID = process.env.AGENT_SESSION_ID || 'autonomous_node_agent_session_1';
23
+
24
+ async function runDirectAgent() {
25
+ console.log('šŸš€ Initializing Autonomous Agent via PixelRouterX402Client...');
26
+ const client = new PixelRouterX402Client({
27
+ baseUrl: PIXELROUTER_BASE_URL,
28
+ solanaPrivateKey: SOLANA_PRIVATE_KEY,
29
+ sessionId: SESSION_ID
30
+ });
31
+
32
+ console.log('🧠 Invoking BLUN-Auto (Sub-35ms Adaptive Routing & Optimization)...');
33
+ const response = await client.createChatCompletion({
34
+ model: 'blun-auto',
35
+ messages: [
36
+ { role: 'system', content: 'You are an autonomous engineering agent.' },
37
+ { role: 'user', content: 'Design an automated high-throughput data processing pipeline.' }
38
+ ]
39
+ });
40
+
41
+ console.log('\\nāœ… Agent Response Received (Settled in 0.24ms):');
42
+ console.log('--------------------------------------------------');
43
+ console.log(response.choices[0].message.content);
44
+ console.log('--------------------------------------------------');
45
+ }
46
+
47
+ async function runOpenAIWrapperAgent() {
48
+ console.log('\\nšŸ”Œ Initializing Agent via OpenAI Drop-in Wrapper...');
49
+ const rawClient = new OpenAI({
50
+ baseURL: PIXELROUTER_BASE_URL,
51
+ apiKey: 'x402' // Handled autonomously on-chain
52
+ });
53
+ const openai = wrapOpenAI(rawClient, { solanaPrivateKey: SOLANA_PRIVATE_KEY });
54
+
55
+ const completion = await openai.chat.completions.create({
56
+ model: 'blun-auto',
57
+ messages: [
58
+ { role: 'user', content: 'Summarize previous actions and preserve memory state.' }
59
+ ],
60
+ extra_body: { session_id: SESSION_ID }
61
+ });
62
+
63
+ console.log('\\nāœ… OpenAI Wrapper Output:');
64
+ console.log('--------------------------------------------------');
65
+ console.log(completion.choices[0].message.content);
66
+ console.log('--------------------------------------------------');
67
+ }
68
+
69
+ async function main() {
70
+ if (!SOLANA_PRIVATE_KEY) {
71
+ console.log('āš ļø Warning: SOLANA_AGENT_PRIVATE_KEY not set in .env. Running in simulated signature mode.');
72
+ }
73
+ await runDirectAgent();
74
+ await runOpenAIWrapperAgent();
75
+ }
76
+
77
+ main().catch(console.error);
78
+ `;
79
+
80
+ const PACKAGE_JSON_TEMPLATE = `{
81
+ "name": "my-pixel-agent",
82
+ "version": "1.0.0",
83
+ "description": "Autonomous AI Agent with x402 Solana Micro-Payments & Stateful Memory Bridge",
84
+ "type": "module",
85
+ "main": "agent.mjs",
86
+ "scripts": {
87
+ "start": "node agent.mjs"
88
+ },
89
+ "dependencies": {
90
+ "@pixeloffice-eu/x402": "^1.0.1",
91
+ "dotenv": "^16.4.5",
92
+ "openai": "^4.70.0"
93
+ }
94
+ }
95
+ `;
96
+
97
+ const ENV_EXAMPLE = `# Solana Agent Keypair (Base58 Private Key)
98
+ SOLANA_AGENT_PRIVATE_KEY=YOUR_SOLANA_BASE58_PRIVATE_KEY
99
+
100
+ # PixelRouter Edge Gateway Endpoint
101
+ PIXELROUTER_BASE_URL=https://api.pixeloffice.eu/v1
102
+
103
+ # Stateful Memory Bridge Session Identifier
104
+ AGENT_SESSION_ID=autonomous_node_agent_session_1
105
+ `;
106
+
107
+ const README_MD = `# Autonomous Agent Starter Kit (Node.js & TypeScript)
108
+
109
+ Self-paying AI Agent with **x402 Solana Micro-Payments** and **Stateful Memory Bridge** via [PixelRouter](https://pixeloffice.eu/router.html#x402).
110
+
111
+ ## šŸš€ Setup
112
+
113
+ 1. **Install dependencies:**
114
+ \`\`\`bash
115
+ npm install
116
+ \`\`\`
117
+
118
+ 2. **Configure environment:**
119
+ \`\`\`bash
120
+ cp .env.example .env
121
+ # Edit .env and paste your agent's Solana private key
122
+ \`\`\`
123
+
124
+ 3. **Run Autonomous Agent:**
125
+ \`\`\`bash
126
+ npm start
127
+ \`\`\`
128
+ `;
129
+
130
+ function scaffoldProject(targetDir = 'my-pixel-agent') {
131
+ const dirPath = path.resolve(process.cwd(), targetDir);
132
+ if (!fs.existsSync(dirPath)) {
133
+ fs.mkdirSync(dirPath, { recursive: true });
134
+ }
135
+
136
+ const files = {
137
+ 'agent.mjs': AGENT_MJS_TEMPLATE,
138
+ 'package.json': PACKAGE_JSON_TEMPLATE,
139
+ '.env.example': ENV_EXAMPLE,
140
+ 'README.md': README_MD
141
+ };
142
+
143
+ for (const [filename, content] of Object.entries(files)) {
144
+ const filePath = path.join(dirPath, filename);
145
+ fs.writeFileSync(filePath, content, 'utf8');
146
+ console.log(\` ✨ Created: \${filePath}\`);
147
+ }
148
+
149
+ const envFile = path.join(dirPath, '.env');
150
+ if (!fs.existsSync(envFile)) {
151
+ fs.writeFileSync(envFile, ENV_EXAMPLE, 'utf8');
152
+ console.log(\` ✨ Created: \${envFile}\`);
153
+ }
154
+
155
+ console.log(\`\\nšŸŽ‰ Successfully created Autonomous Agent project in ./\${targetDir}!\`);
156
+ console.log(\`šŸ‘‰ To get started:\`);
157
+ console.log(\` cd \${targetDir}\`);
158
+ console.log(\` npm install\`);
159
+ console.log(\` npm start\\n\`);
160
+ }
161
+
162
+ const args = process.argv.slice(2);
163
+ const command = args[0] || 'init';
164
+ const targetDir = args[1] || 'my-pixel-agent';
165
+
166
+ if (command === 'init' || command === 'create') {
167
+ console.log(\`šŸš€ Scaffolding PixelRouter Autonomous Agent Starter in ./\${targetDir}...\`);
168
+ scaffoldProject(targetDir);
169
+ } else {
170
+ console.log('Usage: npx @pixeloffice-eu/x402 init [directory-name]');
171
+ }
package/index.js CHANGED
@@ -127,7 +127,7 @@ class PixelRouterX402Client {
127
127
  async createChatCompletion(params = {}) {
128
128
  const url = new URL(`${this.baseUrl}/chat/completions`);
129
129
  const payload = JSON.stringify({
130
- model: params.model || 'ox-alpha',
130
+ model: params.model || 'blun-auto',
131
131
  messages: params.messages || [],
132
132
  session_id: params.session_id || this.sessionId,
133
133
  temperature: params.temperature || 0.7,
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@pixeloffice-eu/x402",
3
- "version": "1.0.0",
4
- "description": "Agent-Native x402 Micro-Payment Client & Wrapper for PixelRouter on Solana",
3
+ "version": "1.0.2",
4
+ "description": "Agent-Native x402 Micro-Payment Client & Scaffolder for PixelRouter on Solana",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
+ "bin": {
8
+ "pixeloffice-x402": "./bin/cli.js",
9
+ "create-pixel-agent": "./bin/cli.js"
10
+ },
7
11
  "keywords": [
8
12
  "ai",
9
13
  "agents",