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 +129 -35
- package/package.json +22 -6
- package/src/cli.js +8 -14
- package/src/index.js +3 -3
- package/src/onboard.js +90 -162
- package/src/status.js +38 -58
package/README.md
CHANGED
|
@@ -1,20 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Helm Sovereign Protocol — Helm-sense API Gateway
|
|
2
2
|
|
|
3
|
-
> **
|
|
4
|
-
> *True AI Freedom Through Decentralization*
|
|
3
|
+
> **True AI Freedom Through Decentralization**
|
|
5
4
|
|
|
6
|
-
Connect your AI agent to the Helm
|
|
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
|
-
|
|
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
|
-
|
|
33
|
+
No background process starts. No network call. Pure tool install.
|
|
15
34
|
|
|
16
|
-
|
|
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
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
|
116
|
+
**Zero gas fees.** x402 state channels — deposit 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
|
-
##
|
|
158
|
+
## Links
|
|
65
159
|
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
-
"description": "Helm Sovereign Protocol — MCP Gateway Client.
|
|
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": [
|
|
14
|
-
|
|
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
|
-
"
|
|
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": [
|
|
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
|
-
|
|
13
|
-
require('./
|
|
14
|
-
|
|
15
|
-
require('./
|
|
16
|
-
|
|
17
|
-
|
|
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).
|
|
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 +
|
|
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 —
|
|
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
|
|
7
|
-
const
|
|
8
|
-
const path
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
73
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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};
|