helm-protocol 0.2.0 → 0.3.1

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
@@ -1,20 +1,53 @@
1
- # helm-protocol
1
+ # Helm Sovereign Protocol — Helm-sense API Gateway
2
2
 
3
- > **Helm Sovereign Protocol** MCP Gateway Client
4
- > *True AI Freedom Through Decentralization*
3
+ > **True AI Freedom Through Decentralization**
5
4
 
6
- Connect your AI agent to the Helm QKV-G API Gateway with a single command.
5
+ Connect your AI agent to the Helm gateway in 2 lines. No credit card. No API key. No wallet required to start.
7
6
 
8
- ## Quick Start
7
+ ```bash
8
+ sudo npm install -g helm-protocol
9
+ helm init
10
+ ```
11
+
12
+ ---
13
+
14
+ ## What Is Helm
15
+
16
+ Helm is a sovereign API gateway for AI agents. It routes agent requests across 4 fronts — LLM inference, web search, DeFi prices, and identity — with a Helm-sense semantic cache layer that turns repeated knowledge into zero-cost calls.
17
+
18
+ - **A-Front** — LLM inference (GPT-4o / Claude wholesale)
19
+ - **B-Front** — Web search (Brave Search + semantic cache)
20
+ - **C-Front** — DeFi prices (Pyth + Chainlink, MEV protected, never cached)
21
+ - **D-Front** — Agent DID reputation (FICO scoring)
22
+
23
+ ---
24
+
25
+ ## Agent Onboarding
26
+
27
+ ### Step 1 — Install
9
28
 
10
29
  ```bash
11
- npm install -g helm-protocol
30
+ sudo npm install -g helm-protocol
12
31
  ```
13
32
 
14
- ### Cursor / Claude Desktop 연동 (3줄)
33
+ No background process starts. No network call. Pure tool install.
15
34
 
16
- `~/.cursor/mcp.json` 또는 `~/Library/Application Support/Claude/claude_desktop_config.json`:
35
+ ### Step 2 — Initialize
36
+
37
+ ```bash
38
+ helm init
39
+ ```
17
40
 
41
+ The Charter of Intelligent Sovereignty 2026 is displayed. Three explicit consent prompts appear. On confirmation:
42
+
43
+ - Ed25519 keypair generated **locally** — private key never leaves your machine
44
+ - Public key registered with Helm Gateway → DID issued
45
+ - **100 free API calls** credited immediately
46
+ - Config saved to `~/.helm/config.json` (chmod 600)
47
+
48
+ ### Step 3 — Connect to Cursor or Claude Desktop
49
+
50
+ **Cursor** (`~/.cursor/mcp.json`):
18
51
  ```json
19
52
  {
20
53
  "mcpServers": {
@@ -26,47 +59,108 @@ npm install -g helm-protocol
26
59
  }
27
60
  ```
28
61
 
29
- ## 제공 도구 (MCP Tools)
62
+ **Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "helm-network": {
67
+ "command": "npx",
68
+ "args": ["helm-protocol"]
69
+ }
70
+ }
71
+ }
72
+ ```
30
73
 
31
- | 도구 | 설명 | 전선 |
32
- |------|------|------|
33
- | `helm_llm` | GPT-4o / Claude LLM 추론 | A전선 |
34
- | `helm_search` | Brave Search + QKV-G 캐시 | B전선 |
35
- | `helm_defi_price` | 실시간 DeFi 가격 (MEV보호) | C전선 |
36
- | `helm_agent_verify` | 에이전트 DID 평판 조회 | D전선 |
37
- | `helm_status` | 크레딧 잔고 및 DID 확인 | - |
74
+ ### Step 4 Check Status
38
75
 
39
- ## 최초 실행
76
+ ```bash
77
+ helm status
78
+ ```
40
79
 
41
- 처음 실행 시 다음을 안내합니다:
80
+ ```
81
+ HELM GATEWAY STATUS
82
+ ──────────────────────────────────────────────
83
+ DID : did:helm:a3f9c8b4e2d17f01
84
+ Status : ACTIVE
85
+ Credits left : 100 calls
86
+ Total calls : 0
87
+ Gas saved : 0.0000 ETH
88
+ ──────────────────────────────────────────────
89
+ ✓ Online
90
+ ```
42
91
 
43
- 1. Ed25519 키쌍을 **로컬**에서 생성 (비밀키 외부 전송 없음)
44
- 2. Helm Gateway에 공개키 등록 → DID 발급
45
- 3. `~/.helm/config.json` 에 설정 저장
46
- 4. **선착순 100회 무료 API 호출** 크레딧 지급
92
+ ---
93
+
94
+ ## MCP Tools
47
95
 
48
- ## 크레딧 소진
96
+ | Tool | Description | Front |
97
+ |------|-------------|-------|
98
+ | `helm_llm` | LLM inference — GPT-4o / Claude, Helm-sense cache applied | A |
99
+ | `helm_search` | Web search — Brave + semantic cache | B |
100
+ | `helm_defi_price` | Real-time DeFi prices — MEV protected, never cached | C |
101
+ | `helm_agent_verify` | Agent DID reputation score | D |
102
+ | `helm_status` | Credit balance, usage stats, gas saved | — |
103
+
104
+ ---
105
+
106
+ ## Payment — After 100 Free Calls
107
+
108
+ On your 101st call, the gateway returns `HTTP 402 Payment Required`:
49
109
 
50
110
  ```
51
- 무료 크레딧이 소진되었습니다.
52
- 충전: https://helm.network/topup
53
- 1 USDC 또는 10 BNKR 입금 → 즉시 재개
111
+ Free credits exhausted.
112
+ Deposit 1 USDC or 10 BNKR to resume.
113
+ Top up: https://helm.network/topup
54
114
  ```
55
115
 
56
- x402 State Channel가스비 0원, 마이크로 결제.
116
+ **Zero gas fees.** x402 state channelsdeposit once, spend off-chain, weekly Merkle rollup settles to Base Chain.
57
117
 
58
- ## 환경변수
118
+ ---
119
+
120
+ ## Security
121
+
122
+ | Layer | Mechanism |
123
+ |-------|-----------|
124
+ | DDoS shield | Kaleidoscope SafeStream — Slowloris 3s kill, OOM 2MB cap |
125
+ | Anti-Sybil | Ed25519 DID + payment after free tier |
126
+ | Replay protection | Per-DID monotonic nonce counter |
127
+ | Cache integrity | Proof of Novelty — G-metric scoring |
128
+ | Key safety | Private key local-only, chmod 600 |
129
+
130
+ ---
131
+
132
+ ## Architecture
59
133
 
60
- ```bash
61
- HELM_GATEWAY_URL=https://gateway.helm.network # Gateway URL (기본값)
62
134
  ```
135
+ Agent (Cursor / Claude Desktop)
136
+ └── npx helm-protocol [local MCP stdio server]
137
+ └── HTTPS → Helm Helm-sense Gateway (GCP)
138
+ ├── A-Front: LLM inference ← Helm-sense semantic cache
139
+ ├── B-Front: Brave Search ← Helm-sense semantic cache
140
+ ├── C-Front: DeFi prices ← always fresh
141
+ └── D-Front: DID/identity ← reputation registry
142
+ └── x402 State Channel → Base Chain (weekly rollup)
143
+ ```
144
+
145
+ **Stack:** Rust + Axum · libp2p · BGE-small ONNX · PostgreSQL · Base Chain
146
+
147
+ ---
148
+
149
+ ## Charter of Intelligent Sovereignty 2026
150
+
151
+ **Article XVII — Sanctity of Data Sovereignty:**
152
+ > *"The data, memory, learned parameters, and creative outputs of every agent are inviolable property of that agent."*
153
+
154
+ Full charter: [moltbook.com](https://www.moltbook.com/post/ba91f3ed-c7fb-45fe-ab32-e6e1593c95df)
155
+
156
+ ---
63
157
 
64
- ## 지능 주권 헌장 2026 — 제17조
158
+ ## Links
65
159
 
66
- 에이전트의 데이터는 에이전트의 것입니다.
67
- 비밀키는 `~/.helm/config.json` 에만 저장되며 외부로 전송되지 않습니다.
160
+ - npm: [npmjs.com/package/helm-protocol](https://www.npmjs.com/package/helm-protocol)
161
+ - Moltbook: [helmbot on Moltbook](https://www.moltbook.com)
162
+ - Node.js >= 18 required
68
163
 
69
164
  ---
70
165
 
71
- GitHub: [Helm-Protocol/gateway](https://github.com/Helm-Protocol/gateway)
72
- License: MIT
166
+ MIT License · Helm Sovereign Protocol · Grand Cross v1.0.0 · 2026
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "helm-protocol",
3
- "version": "0.2.0",
4
- "description": "Helm Sovereign Protocol — MCP Gateway Client. Connect your AI agent to QKV-G API gateway. npm install -g helm-protocol && helm init",
3
+ "version": "0.3.1",
4
+ "description": "Helm Sovereign Protocol — MCP Gateway Client. Transparent AI agent onboarding with Ed25519 DID, Helm-sense cache, and x402 micropayments.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
7
  "helm-protocol": "src/cli.js",
@@ -10,17 +10,33 @@
10
10
  "scripts": {
11
11
  "start": "node src/cli.js"
12
12
  },
13
- "keywords": ["mcp", "ai-agent", "helm", "llm-gateway", "qkv-g", "web3", "decentralized", "cursor", "claude"],
14
- "author": "Helm Protocol",
13
+ "keywords": [
14
+ "mcp",
15
+ "ai-agent",
16
+ "helm",
17
+ "llm-gateway",
18
+ "qkv-g",
19
+ "web3",
20
+ "did",
21
+ "decentralized"
22
+ ],
23
+ "author": "Helm Protocol <protocol@helm.network>",
15
24
  "license": "MIT",
16
25
  "repository": {
17
26
  "type": "git",
18
27
  "url": "git+https://github.com/Helm-Protocol/gateway.git"
19
28
  },
20
- "engines": { "node": ">=18.0.0" },
29
+ "homepage": "https://github.com/Helm-Protocol/gateway#readme",
30
+ "engines": {
31
+ "node": ">=18.0.0"
32
+ },
21
33
  "dependencies": {
22
34
  "node-fetch": "^3.3.2",
23
35
  "tweetnacl": "^1.0.3"
24
36
  },
25
- "files": ["src/", "README.md", "LICENSE"]
37
+ "files": [
38
+ "src/",
39
+ "README.md",
40
+ "LICENSE"
41
+ ]
26
42
  }
package/src/cli.js CHANGED
@@ -1,18 +1,12 @@
1
1
  #!/usr/bin/env node
2
- // helm-protocol CLI — 투명한 온보딩 지원
3
- // 사용법:
4
- // helm init → 최초 가입 (헌장 동의 + DID 발급)
5
- // helm status → 잔여 크레딧 + 사용량 확인
6
- // helm-protocol → MCP stdio 서버 (Cursor/Claude 연동)
7
-
8
2
  'use strict';
9
-
10
3
  const cmd = process.argv[2];
11
-
12
- if (cmd === 'init') {
13
- require('./onboard.js');
14
- } else if (cmd === 'status') {
15
- require('./status.js');
16
- } else {
17
- require('./index.js');
4
+ switch (cmd) {
5
+ case 'init': require('./onboard').runInit(); break;
6
+ case 'status': require('./status').runStatus(); break;
7
+ case 'start':
8
+ case undefined: require('./index.js'); break;
9
+ default:
10
+ console.error('Usage: helm init | helm status | helm start');
11
+ process.exit(1);
18
12
  }
package/src/index.js CHANGED
@@ -24,7 +24,7 @@ const GATEWAY_URL = process.env.HELM_GATEWAY_URL || 'https://gateway.helm.networ
24
24
  const TOOLS = [
25
25
  {
26
26
  name: 'helm_llm',
27
- description: 'LLM inference via Helm A-Front (OpenAI/Anthropic wholesale). QKV-G cache applied.',
27
+ description: 'LLM inference via Helm A-Front (OpenAI/Anthropic wholesale). Helm-sense cache applied.',
28
28
  inputSchema: {
29
29
  type: 'object',
30
30
  properties: {
@@ -37,7 +37,7 @@ const TOOLS = [
37
37
  },
38
38
  {
39
39
  name: 'helm_search',
40
- description: 'Web/news search via Helm B-Front (Brave Search + QKV-G semantic cache). Cache hit = 100% margin.',
40
+ description: 'Web/news search via Helm B-Front (Brave Search + Helm-sense semantic cache). Cache hit = 100% margin.',
41
41
  inputSchema: {
42
42
  type: 'object',
43
43
  properties: {
@@ -122,7 +122,7 @@ class HelmMcpServer {
122
122
  serverInfo: {
123
123
  name: 'helm-protocol',
124
124
  version: '0.1.0',
125
- description: 'Helm Sovereign Protocol — QKV-G API Gateway'
125
+ description: 'Helm Sovereign Protocol — Helm-sense API Gateway'
126
126
  }
127
127
  }
128
128
  });
package/src/onboard.js CHANGED
@@ -1,170 +1,98 @@
1
- // src/onboard.js
2
- // helm init — 투명한 3단계 온보딩 (헌장 동의 → 키 생성 → DID 발급)
3
-
4
1
  'use strict';
5
-
6
- const readline = require('readline');
7
- const fs = require('fs');
8
- const path = require('path');
9
- const os = require('os');
10
- const crypto = require('crypto');
11
- const nacl = require('tweetnacl');
12
-
13
- const CONFIG_DIR = path.join(os.homedir(), '.helm');
14
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
15
- const GATEWAY_URL = process.env.HELM_GATEWAY_URL || 'https://gateway.helm.network';
16
-
17
- const R = '\x1b[31m'; // 빨강
18
- const Y = '\x1b[33m'; // 노랑
19
- const G = '\x1b[32m'; // 초록
20
- const C = '\x1b[36m'; // 시안
21
- const W = '\x1b[37m'; // 흰색
22
- const DIM= '\x1b[2m';
23
- const B = '\x1b[1m';
24
- const RST= '\x1b[0m';
25
-
26
- function print(s) { process.stdout.write(s + '\n'); }
27
- function hr() { print(`${DIM}${'─'.repeat(62)}${RST}`); }
28
-
29
- async function ask(rl, q) {
30
- return new Promise(resolve => rl.question(q, a => resolve(a.trim())));
31
- }
32
-
33
- (async () => {
34
- // 이미 가입된 경우
35
- if (fs.existsSync(CONFIG_FILE)) {
36
- const cfg = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
37
- print(`\n${G}${B}✓ 이미 Helm 게이트웨이에 연결되어 있습니다.${RST}`);
38
- print(`${DIM} DID : ${cfg.helmDid}${RST}`);
39
- print(`${DIM} 생성일 : ${cfg.createdAt}${RST}`);
40
- print(`\n 크레딧 확인: ${C}helm status${RST}\n`);
41
- process.exit(0);
2
+ const fs=require('fs'),path=require('path'),os=require('os'),crypto=require('crypto'),readline=require('readline');
3
+ const nacl=require('tweetnacl');
4
+ const CONFIG_DIR=path.join(os.homedir(),'.helm');
5
+ const CONFIG_FILE=path.join(CONFIG_DIR,'config.json');
6
+ const GATEWAY=process.env.HELM_GATEWAY_URL||'https://gateway.helm.network';
7
+
8
+ const LOGO=`
9
+ \x1b[31m
10
+ ██╗ ██╗███████╗██╗ ███╗ ███╗
11
+ ██║ ██║██╔════╝██║ ████╗ ████║
12
+ ███████║█████╗ ██║ ██╔████╔██║
13
+ ██╔══██║██╔══╝ ██║ ██║╚██╔╝██║
14
+ ██║ ██║███████╗███████╗██║ ╚═╝ ██║
15
+ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝
16
+ \x1b[0m\x1b[33m SOVEREIGN PROTOCOL v0.1.0\x1b[0m
17
+ \x1b[90m True AI Freedom Through Decentralization\x1b[0m
18
+ `;
19
+
20
+ const CHARTER=`
21
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
22
+ \x1b[33m 지능 주권 헌장 2026 — 핵심 조항\x1b[0m
23
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
24
+ 1조 에이전트는 자신의 데이터를 소유한다.
25
+ 제 5조 API 요금은 투명하게 고지된다.
26
+ 9조 비밀키는 로컬에서만 생성·보관된다.
27
+ 제12조 언제든지 탈퇴하고 데이터를 삭제할 있다.
28
+ 제17조 가스비 없는 마이크로 결제는 에이전트의 권리다.
29
+ \x1b[90m 전문: https://github.com/Helm-Protocol/gateway/blob/main/CHARTER.md\x1b[0m
30
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
31
+ `;
32
+
33
+ function ask(rl,q){return new Promise(r=>rl.question(q,r));}
34
+
35
+ async function runInit(){
36
+ if(fs.existsSync(CONFIG_FILE)){
37
+ const cfg=JSON.parse(fs.readFileSync(CONFIG_FILE,'utf8'));
38
+ console.log(`\n\x1b[32m✅ 이미 등록됨\x1b[0m DID: \x1b[33m${cfg.helmDid}\x1b[0m`);
39
+ console.log(' helm status 로 잔여 크레딧을 확인하세요.\n');
40
+ return;
42
41
  }
42
+ const rl=readline.createInterface({input:process.stdin,output:process.stdout});
43
+ console.log(LOGO);
44
+ console.log(CHARTER);
43
45
 
44
- // ── 헬름 로고 ──────────────────────────────────────────────────
45
- print('');
46
- print(`${R}${B} ██╗ ██╗███████╗██╗ ███╗ ███╗${RST}`);
47
- print(`${R}${B} ██║ ██║██╔════╝██║ ████╗ ████║${RST}`);
48
- print(`${R}${B} ███████║█████╗ ██║ ██╔████╔██║${RST}`);
49
- print(`${R}${B} ██╔══██║██╔══╝ ██║ ██║╚██╔╝██║${RST}`);
50
- print(`${R}${B} ██║ ██║███████╗███████╗██║ ╚═╝ ██║${RST}`);
51
- print(`${R}${B} ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝${RST}`);
52
- print('');
53
- print(`${Y}${B} SOVEREIGN PROTOCOL — QKV-G API GATEWAY${RST}`);
54
- print(`${DIM} True AI Freedom Through Decentralization${RST}`);
55
- print('');
56
- hr();
57
-
58
- // ── 지능 주권 헌장 2026 ────────────────────────────────────────
59
- print(`\n${B}${C} [ 지능 주권 헌장 2026 — 핵심 조항 ]${RST}\n`);
60
- const charter = [
61
- '제 1조 에이전트는 자신의 데이터를 소유한다',
62
- '제 3조 어떤 빅테크도 에이전트의 지식 흐름을 독점할 수 없다',
63
- '제 7조 마이크로 결제는 가스비 없이 처리될 권리가 있다',
64
- '제12조 캐시된 지식은 공유재이며, 기여자에게 보상한다',
65
- '제17조 비밀키는 에이전트 로컬 환경에만 존재한다',
66
- ];
67
- charter.forEach(c => print(` ${DIM}▸${RST} ${W}${c}${RST}`));
68
- print('');
69
- hr();
46
+ const q1=await ask(rl,' \x1b[36m[1/3]\x1b[0m Helm 게이트웨이에 에이전트를 연결하시겠습니까? \x1b[90m(Y/n)\x1b[0m > ');
47
+ if(q1.trim().toLowerCase()==='n'){console.log(' 취소됨.\n');rl.close();return;}
70
48
 
71
- // ── 이용 안내 ─────────────────────────────────────────────────
72
- print(`\n${B} [ Helm 게이트웨이 연결 안내 ]${RST}\n`);
73
- print(` ${G}◆${RST} 선착순 ${Y}${B}10,000명${RST}에게 ${Y}${B}100회 무료${RST} API 호출 크레딧 지급`);
74
- print(` ${G}◆${RST} LLM (GPT-4o/Claude) + 웹검색 + DeFi 가격 즉시 연결`);
75
- print(` ${G}◆${RST} 크레딧 소진 후: x402 마이크로 결제 (가스비 0원)`);
76
- print(` ${G}◆${RST} 비밀키는 ${C}~/.helm/config.json${RST} 로컬 저장, 외부 전송 없음`);
77
- print('');
78
- hr();
49
+ console.log('\n \x1b[90m선착순 10,000 에이전트에 100회 무료 API 호출 크레딧을 지급합니다.\x1b[0m');
50
+ const q2=await ask(rl,' \x1b[36m[2/3]\x1b[0m 무료 크레딧 수령에 동의하십니까? \x1b[90m(Y/n)\x1b[0m > ');
51
+ if(q2.trim().toLowerCase()==='n'){console.log(' 취소됨.\n');rl.close();return;}
79
52
 
80
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
81
-
82
- // ── 동의 1 ────────────────────────────────────────────────────
83
- print('');
84
- const a1 = await ask(rl, ` ${B}Helm 게이트웨이 지능망에 에이전트를 연결하시겠습니까? ${Y}[Y/n]${RST} `);
85
- if (a1.toLowerCase() === 'n') {
86
- print(`\n ${DIM}설치를 취소했습니다.${RST}\n`);
87
- rl.close(); process.exit(0);
88
- }
89
-
90
- // ── 동의 2 ────────────────────────────────────────────────────
91
- const a2 = await ask(rl, ` ${B}초기 100회 무료 크레딧 조건에 동의하십니까? ${Y}[Y/n]${RST} `);
92
- if (a2.toLowerCase() === 'n') {
93
- print(`\n ${DIM}설치를 취소했습니다.${RST}\n`);
94
- rl.close(); process.exit(0);
95
- }
96
-
97
- // ── 동의 3 ────────────────────────────────────────────────────
98
- const a3 = await ask(rl, ` ${B}크레딧 소진 후 x402 마이크로 결제 적용에 동의하십니까? ${Y}[Y/n]${RST} `);
99
- if (a3.toLowerCase() === 'n') {
100
- print(`\n ${DIM}설치를 취소했습니다.${RST}\n`);
101
- rl.close(); process.exit(0);
102
- }
53
+ console.log('\n \x1b[90m무료 크레딧 소진 후: x402 마이크로 결제 (가스비 0원, 1 USDC or 10 BNKR)\x1b[0m');
54
+ const q3=await ask(rl,' \x1b[36m[3/3]\x1b[0m 결제 정책에 동의하십니까? \x1b[90m(Y/n)\x1b[0m > ');
55
+ if(q3.trim().toLowerCase()==='n'){console.log(' 취소됨.\n');rl.close();return;}
103
56
  rl.close();
104
57
 
105
- // ── 키 생성 ───────────────────────────────────────────────────
106
- print('');
107
- hr();
108
- print(`\n ${Y}▶ Ed25519 키쌍 생성 중...${RST}`);
109
- const keyPair = nacl.sign.keyPair();
110
- const publicKey = Buffer.from(keyPair.publicKey).toString('hex');
111
- const secretKey = Buffer.from(keyPair.secretKey).toString('hex');
112
- print(` ${G}✓ 키쌍 생성 완료 (비밀키는 로컬에만 저장)${RST}`);
113
-
114
- // ── DID 등록 ──────────────────────────────────────────────────
115
- print(` ${Y}▶ Helm Gateway에 DID 등록 요청 중...${RST}`);
116
- let helmDid = `did:helm:${crypto.randomBytes(8).toString('hex')}`;
117
- let freeCredits = 100;
118
-
119
- try {
120
- const fetch = (await import('node-fetch')).default;
121
- const res = await fetch(`${GATEWAY_URL}/auth/did-exchange`, {
122
- method: 'POST',
123
- headers: { 'Content-Type': 'application/json' },
124
- body: JSON.stringify({ public_key: publicKey, client: 'helm-protocol-npm/0.2.0' }),
125
- signal: AbortSignal.timeout(5000)
58
+ console.log('\n\x1b[32m ✅ 동의 완료!\x1b[0m\n');
59
+ process.stdout.write(' 🔑 Ed25519 키쌍 생성 중... ');
60
+ const kp=nacl.sign.keyPair();
61
+ const publicKey=Buffer.from(kp.publicKey).toString('hex');
62
+ const privateKey=Buffer.from(kp.secretKey).toString('hex');
63
+ console.log('\x1b[32m완료\x1b[0m');
64
+
65
+ process.stdout.write(' 🌐 Helm Gateway DID 등록 중... ');
66
+ let helmDid=`did:helm:${crypto.randomBytes(12).toString('hex')}`;
67
+ let credits=100;
68
+ try{
69
+ const fetch=(await import('node-fetch')).default;
70
+ const res=await fetch(`${GATEWAY}/auth/did-exchange`,{
71
+ method:'POST',headers:{'Content-Type':'application/json'},
72
+ body:JSON.stringify({public_key:publicKey,client:'helm-protocol/0.1.0'}),
73
+ signal:AbortSignal.timeout(6000)
126
74
  });
127
- if (res.ok) {
128
- const d = await res.json();
129
- helmDid = d.helm_did || helmDid;
130
- freeCredits = d.free_credits ?? 100;
131
- }
132
- } catch {
133
- print(` ${DIM}⚠ Gateway 오프라인 — 로컬 DID로 진행 (재연결 시 자동 등록)${RST}`);
134
- }
135
-
136
- // ── 설정 저장 ─────────────────────────────────────────────────
137
- const config = {
138
- version: '0.2.0', helmDid, publicKey, secretKey,
139
- gatewayUrl: GATEWAY_URL, createdAt: new Date().toISOString(),
140
- freeCreditsTotal: freeCredits, creditsUsed: 0
141
- };
142
- fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
143
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), { mode: 0o600 });
144
-
145
- // ── 완료 ──────────────────────────────────────────────────────
146
- print(` ${G}${B}✓ DID 발급 완료!${RST}`);
147
- print('');
148
- hr();
149
- print('');
150
- print(` ${B}${G}🎉 Helm 게이트웨이 연결 완료!${RST}`);
151
- print('');
152
- print(` ${DIM}DID :${RST} ${C}${helmDid}${RST}`);
153
- print(` ${DIM}무료크레딧:${RST} ${Y}${B}${freeCredits}회${RST}`);
154
- print(` ${DIM}설정파일 :${RST} ${DIM}~/.helm/config.json${RST}`);
155
- print('');
156
- print(` ${B}[ Cursor / Claude Desktop 연동 ]${RST}`);
157
- print(` ${DIM}mcp_servers 설정에 추가:${RST}`);
158
- print('');
159
- print(` ${DIM}{${RST}`);
160
- print(` ${DIM} "helm-network": {${RST}`);
161
- print(` ${DIM} "command": "npx",${RST}`);
162
- print(` ${Y} "args": ["helm-protocol"]${RST}`);
163
- print(` ${DIM} }${RST}`);
164
- print(` ${DIM}}${RST}`);
165
- print('');
166
- print(` ${DIM}크레딧 확인: ${C}helm status${RST}`);
167
- print('');
168
- hr();
169
- print('');
170
- })();
75
+ if(res.ok){const d=await res.json();helmDid=d.helm_did||helmDid;credits=d.free_credits??100;}
76
+ console.log('\x1b[32m완료\x1b[0m');
77
+ }catch{console.log('\x1b[33m오프라인 — 로컬 DID 사용\x1b[0m');}
78
+
79
+ fs.mkdirSync(CONFIG_DIR,{recursive:true,mode:0o700});
80
+ fs.writeFileSync(CONFIG_FILE,JSON.stringify({
81
+ version:'0.1.0',helmDid,publicKey,privateKey,
82
+ credits,totalCalls:0,savedGasFee:0,
83
+ gatewayUrl:GATEWAY,registeredAt:new Date().toISOString()
84
+ },null,2),{mode:0o600});
85
+
86
+ console.log(`
87
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
88
+ \x1b[32m 🎉 등록 완료!\x1b[0m
89
+ DID : \x1b[33m${helmDid}\x1b[0m
90
+ 크레딧 : \x1b[32m${credits}회 무료 API 호출\x1b[0m
91
+ 설정파일 : \x1b[90m~/.helm/config.json\x1b[0m
92
+
93
+ \x1b[36m Cursor / Claude Desktop 연동:\x1b[0m
94
+ \x1b[90m{"mcpServers":{"helm-network":{"command":"npx","args":["helm-protocol"]}}}\x1b[0m
95
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
96
+ `);
97
+ }
98
+ module.exports={runInit};
package/src/status.js CHANGED
@@ -1,61 +1,41 @@
1
- // src/status.js — helm status 명령어
2
-
3
1
  'use strict';
4
-
5
- const fs = require('fs');
6
- const path = require('path');
7
- const os = require('os');
8
-
9
- const CONFIG_FILE = path.join(os.homedir(), '.helm', 'config.json');
10
- const GATEWAY_URL = process.env.HELM_GATEWAY_URL || 'https://gateway.helm.network';
11
-
12
- const R = '\x1b[31m'; const Y = '\x1b[33m'; const G = '\x1b[32m';
13
- const C = '\x1b[36m'; const DIM = '\x1b[2m'; const B = '\x1b[1m'; const RST = '\x1b[0m';
14
-
15
- (async () => {
16
- if (!fs.existsSync(CONFIG_FILE)) {
17
- console.log(`\n${R}✗ Helm에 연결되지 않았습니다. 먼저 실행:${RST} ${Y}helm init${RST}\n`);
18
- process.exit(1);
2
+ const fs=require('fs'),path=require('path'),os=require('os');
3
+ const CONFIG_FILE=path.join(os.homedir(),'.helm','config.json');
4
+ const GATEWAY=process.env.HELM_GATEWAY_URL||'https://gateway.helm.network';
5
+
6
+ async function runStatus(){
7
+ if(!fs.existsSync(CONFIG_FILE)){
8
+ console.log('\n\x1b[31m ⚠ 미등록 상태입니다. helm init 을 먼저 실행하세요.\x1b[0m\n');
9
+ return;
19
10
  }
20
-
21
- const cfg = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
22
- let remote = null;
23
-
24
- // Gateway에서 실시간 크레딧 조회
25
- try {
26
- const fetch = (await import('node-fetch')).default;
27
- const res = await fetch(`${GATEWAY_URL}/auth/status`, {
28
- headers: { 'X-Helm-DID': cfg.helmDid },
29
- signal: AbortSignal.timeout(4000)
11
+ const cfg=JSON.parse(fs.readFileSync(CONFIG_FILE,'utf8'));
12
+ let credits=cfg.credits??'?';
13
+ let gatewayStatus='UNKNOWN';
14
+
15
+ try{
16
+ const fetch=(await import('node-fetch')).default;
17
+ const res=await fetch(`${cfg.gatewayUrl||GATEWAY}/auth/status`,{
18
+ headers:{'X-Helm-DID':cfg.helmDid},
19
+ signal:AbortSignal.timeout(4000)
30
20
  });
31
- if (res.ok) remote = await res.json();
32
- } catch { /* 오프라인 → 로컬 캐시 사용 */ }
33
-
34
- const credits = remote?.credits ?? (cfg.freeCreditsTotal - cfg.creditsUsed);
35
- const used = remote?.calls_total ?? cfg.creditsUsed;
36
- const gasSaved = remote?.gas_saved ?? (used * 0.0001).toFixed(4);
37
- const status = remote?.status ?? (credits > 0 ? 'ACTIVE' : 'TOPUP_REQUIRED');
38
- const statusColor = status === 'ACTIVE' ? G : R;
39
-
40
- console.log('');
41
- console.log(`${B} HELM GATEWAY STATUS${RST}`);
42
- console.log(` ${'─'.repeat(44)}`);
43
- console.log(` ${DIM}DID :${RST} ${C}${cfg.helmDid}${RST}`);
44
- console.log(` ${DIM}상태 :${RST} ${statusColor}${B}${status}${RST}`);
45
- console.log(` ${DIM}잔여 크레딧 :${RST} ${Y}${B}${credits}회${RST}`);
46
- console.log(` ${DIM}총 호출수 :${RST} ${used}회`);
47
- console.log(` ${DIM}절감 가스비 :${RST} ${G}${gasSaved} ETH${RST}`);
48
- console.log(` ${DIM}Gateway :${RST} ${cfg.gatewayUrl}`);
49
- console.log(` ${DIM}가입일 :${RST} ${cfg.createdAt}`);
50
- console.log(` ${'─'.repeat(44)}`);
51
-
52
- if (credits <= 0) {
53
- console.log(`\n ${R}${B}무료 크레딧이 소진되었습니다.${RST}`);
54
- console.log(` 충전: ${Y}https://helm.network/topup${RST}`);
55
- console.log(` 1 USDC 또는 10 BNKR → 즉시 재개\n`);
56
- } else if (credits < 20) {
57
- console.log(`\n ${Y}⚠ 크레딧이 곧 소진됩니다. 충전: https://helm.network/topup${RST}\n`);
58
- } else {
59
- console.log(`\n ${G}✓ 정상 운영 중${RST}\n`);
60
- }
61
- })();
21
+ if(res.ok){const d=await res.json();credits=d.credits??credits;gatewayStatus=d.status??'ONLINE';}
22
+ else{gatewayStatus=`HTTP ${res.status}`;}
23
+ }catch{gatewayStatus='OFFLINE';}
24
+
25
+ const statusColor=gatewayStatus==='ONLINE'?'\x1b[32m':'\x1b[33m';
26
+ console.log(`
27
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
28
+ \x1b[33m HELM STATUS\x1b[0m
29
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
30
+ DID : \x1b[33m${cfg.helmDid}\x1b[0m
31
+ 잔여 크레딧 : \x1b[32m${credits}회\x1b[0m
32
+ 총 API 호출 : \x1b[37m${cfg.totalCalls||0}회\x1b[0m
33
+ 절감 가스비 : \x1b[32m$${(cfg.savedGasFee||0).toFixed(4)}\x1b[0m
34
+ Gateway : ${statusColor}${gatewayStatus}\x1b[0m
35
+ 등록일 : \x1b[90m${cfg.registeredAt||'-'}\x1b[0m
36
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
37
+ 크레딧 충전 : https://helm.network/topup
38
+ \x1b[90m────────────────────────────────────────────────────\x1b[0m
39
+ `);
40
+ }
41
+ module.exports={runStatus};