langmart-gateway-type3 3.0.0 → 3.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
@@ -1,5 +1,7 @@
1
1
  # Gateway Type 3 - Seller-Managed Gateway
2
2
 
3
+ [![npm version](https://badge.fury.io/js/langmart-gateway-type3.svg)](https://www.npmjs.com/package/langmart-gateway-type3)
4
+
3
5
  ## Overview
4
6
  Type 3 Gateway is a seller-managed gateway client that runs on the seller's infrastructure. It connects to the marketplace via WebSocket and uses the seller's own API keys to fulfill requests.
5
7
 
@@ -18,42 +20,200 @@ Type 3 Gateway is a seller-managed gateway client that runs on the seller's infr
18
20
  - **Interactive CLI UI** with chat interface and model management
19
21
  - **Intelligent Image Generation** with keyword-based auto-detection
20
22
  - **Terminal Image Preview** for generated images
23
+ - **DevOps Mode**: Full session management with bash, SSH, and system tools
24
+
25
+ ---
26
+
27
+ ## 🚀 Quick Install (Recommended)
28
+
29
+ Install the gateway on any server with a single command:
30
+
31
+ ```bash
32
+ # Using unpkg CDN (recommended)
33
+ curl -fsSL https://unpkg.com/langmart-gateway-type3/scripts/install.sh | bash -s -- \
34
+ --marketplace-url ws://your-marketplace:8081 \
35
+ --api-key YOUR_API_KEY \
36
+ --full \
37
+ --service
38
+ ```
39
+
40
+ ### Install Options
41
+
42
+ | Option | Description | Default |
43
+ |--------|-------------|---------|
44
+ | `--marketplace-url URL` | Marketplace WebSocket URL | `ws://localhost:8081` |
45
+ | `--api-key KEY` | Gateway API key for authentication | (none) |
46
+ | `--port PORT` | Gateway port | `8083` |
47
+ | `--install-dir DIR` | Installation directory | `/opt/langmart-gateway` |
48
+ | `--capabilities CAPS` | Capabilities: `session,llm` or `llm` | `llm` |
49
+ | `--full` | Enable full capabilities (DevOps + LLM) | (disabled) |
50
+ | `--service` | Install as systemd service | (disabled) |
51
+
52
+ ### Examples
53
+
54
+ ```bash
55
+ # LLM routing only (default)
56
+ curl -fsSL https://unpkg.com/langmart-gateway-type3/scripts/install.sh | bash -s -- \
57
+ --marketplace-url ws://10.0.1.117:8081 \
58
+ --api-key sk-test-inference-key
59
+
60
+ # Full DevOps mode with systemd service
61
+ curl -fsSL https://unpkg.com/langmart-gateway-type3/scripts/install.sh | bash -s -- \
62
+ --marketplace-url ws://10.0.1.117:8081 \
63
+ --api-key sk-test-inference-key \
64
+ --full \
65
+ --service
66
+
67
+ # Custom port and directory
68
+ curl -fsSL https://unpkg.com/langmart-gateway-type3/scripts/install.sh | bash -s -- \
69
+ --marketplace-url ws://10.0.1.117:8081 \
70
+ --api-key sk-test-inference-key \
71
+ --port 9000 \
72
+ --install-dir /home/user/gateway
73
+ ```
74
+
75
+ ### Alternative CDN
21
76
 
22
- ## Installation
77
+ ```bash
78
+ # Using jsdelivr
79
+ curl -fsSL https://cdn.jsdelivr.net/npm/langmart-gateway-type3/scripts/install.sh | bash -s -- [OPTIONS]
80
+ ```
81
+
82
+ ---
83
+
84
+ ## 📦 Manual Installation
85
+
86
+ ### Option 1: npm install
23
87
 
24
88
  ```bash
89
+ # Create installation directory
90
+ mkdir -p /opt/langmart-gateway && cd /opt/langmart-gateway
91
+
92
+ # Initialize and install
93
+ npm init -y
94
+ npm install langmart-gateway-type3
95
+
96
+ # Create .env file
97
+ cat > .env << EOF
98
+ INSTANCE_ID=gw3-$(hostname)-$(date +%s | tail -c 5)
99
+ GATEWAY_PORT=8083
100
+ MARKETPLACE_URL=ws://your-marketplace:8081
101
+ GATEWAY_API_KEY=your-api-key
102
+ GATEWAY_CAPABILITIES=llm
103
+ NODE_ENV=production
104
+ EOF
105
+
106
+ # Start the gateway
107
+ node node_modules/langmart-gateway-type3/dist/index-server.js
108
+ ```
109
+
110
+ ### Option 2: Clone and Build
111
+
112
+ ```bash
113
+ # Clone the repository
114
+ git clone https://github.com/YiHuangDB/LangMartDesign.git
115
+ cd LangMartDesign/gateway-type3
116
+
25
117
  # Install dependencies
26
118
  npm install
27
119
 
28
120
  # Build TypeScript
29
121
  npm run build
122
+
123
+ # Configure
124
+ cp .env.example .env
125
+ # Edit .env with your settings
126
+
127
+ # Start
128
+ npm start
30
129
  ```
31
130
 
32
- ## Configuration
131
+ ---
132
+
133
+ ## ⚙️ Configuration
134
+
135
+ ### Environment Variables
33
136
 
34
- Environment variables:
35
137
  ```bash
36
- GATEWAY3_ID=gw3-seller-001 # Gateway identifier
37
- GATEWAY3_API_KEY=sk-test-001 # Marketplace API key
38
- MARKETPLACE_URL=ws://localhost:8090 # Marketplace WebSocket URL
138
+ # Gateway identification
139
+ INSTANCE_ID=gw3-server-001 # Gateway identifier (auto-generated if not set)
140
+ GATEWAY_PORT=8083 # Gateway HTTP/WebSocket port
141
+
142
+ # Marketplace connection
143
+ MARKETPLACE_URL=ws://localhost:8081 # Marketplace WebSocket URL
144
+ GATEWAY_API_KEY=sk-your-key # Marketplace API key
145
+
146
+ # Capabilities
147
+ GATEWAY_CAPABILITIES=llm # "llm" or "session,llm" for full DevOps
39
148
 
40
- # Provider API Keys (seller's own keys)
149
+ # Local vault (for storing provider API keys)
150
+ VAULT_PATH=.vault/credentials.enc # Encrypted vault path
151
+ VAULT_PASSWORD=random-secure-password # Vault encryption password
152
+
153
+ # Provider API Keys (seller's own keys - stored in vault)
41
154
  OPENAI_API_KEY=sk-... # OpenAI API key
42
155
  ANTHROPIC_API_KEY=sk-ant-... # Anthropic API key
43
- GOOGLE_API_KEY=... # Google API key
44
- DEEPSEEK_API_KEY=sk-... # DeepSeek API key
156
+ GROQ_API_KEY=gsk_... # Groq API key
45
157
  ```
46
158
 
47
- ## Running
159
+ ### Capability Modes
160
+
161
+ | Mode | GATEWAY_CAPABILITIES | Description |
162
+ |------|---------------------|-------------|
163
+ | **LLM Only** | `llm` | Routes LLM requests to providers (default) |
164
+ | **Full DevOps** | `session,llm` | LLM routing + bash, SSH, file ops, system tools |
165
+
166
+ ---
167
+
168
+ ## 🏃 Running
169
+
170
+ ### Manual Start
48
171
 
49
172
  ```bash
50
- # Development mode (with TypeScript)
51
- npm run dev
173
+ cd /opt/langmart-gateway
52
174
 
53
- # Production mode (compiled JavaScript)
54
- npm start
175
+ # If installed via npm
176
+ ./start.sh
177
+
178
+ # Or directly
179
+ node node_modules/langmart-gateway-type3/dist/index-server.js
55
180
  ```
56
181
 
182
+ ### Systemd Service
183
+
184
+ If installed with `--service`:
185
+
186
+ ```bash
187
+ # Start
188
+ sudo systemctl start langmart-gateway
189
+
190
+ # Stop
191
+ sudo systemctl stop langmart-gateway
192
+
193
+ # Status
194
+ sudo systemctl status langmart-gateway
195
+
196
+ # Logs
197
+ sudo journalctl -u langmart-gateway -f
198
+ ```
199
+
200
+ ### Verify Installation
201
+
202
+ ```bash
203
+ # Health check
204
+ curl http://localhost:8083/health
205
+
206
+ # Expected response:
207
+ {
208
+ "status": "healthy",
209
+ "gatewayId": "gw3-server-12345",
210
+ "capabilities": ["session", "llm"],
211
+ "tools": 18
212
+ }
213
+ ```
214
+
215
+ ---
216
+
57
217
  ## How It Works
58
218
 
59
219
  1. **Connection**: Gateway connects to marketplace via WebSocket
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langmart-gateway-type3",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "LangMart Type 3 Gateway - Seller-Managed Gateway with Local Vault",
5
5
  "main": "dist/index-server.js",
6
6
  "types": "dist/index-server.d.ts",
@@ -101,7 +101,7 @@
101
101
  "scripts/start.sh",
102
102
  "scripts/stop.sh",
103
103
  "scripts/status.sh",
104
- "scripts/install-remote.sh",
104
+ "scripts/install.sh",
105
105
  ".env.example",
106
106
  "README.md"
107
107
  ],
@@ -1,13 +1,23 @@
1
1
  #!/bin/bash
2
- # Remote Installation Script for LangMart Gateway Type 3
3
- # Usage: curl -fsSL https://raw.githubusercontent.com/YiHuangDB/LangMartDesign/main/gateway-type3/scripts/install-remote.sh | bash
4
- # Or: bash install-remote.sh [OPTIONS]
2
+ # Installation Script for LangMart Gateway Type 3
3
+ # Run this script ON the target server to install the gateway
4
+ #
5
+ # Usage (from npm/unpkg - recommended):
6
+ # curl -fsSL https://unpkg.com/langmart-gateway-type3/scripts/install.sh | bash -s -- [OPTIONS]
7
+ #
8
+ # Usage (from npm/jsdelivr):
9
+ # curl -fsSL https://cdn.jsdelivr.net/npm/langmart-gateway-type3/scripts/install.sh | bash -s -- [OPTIONS]
10
+ #
11
+ # Or download and run:
12
+ # bash install.sh [OPTIONS]
5
13
  #
6
14
  # Options:
7
15
  # --marketplace-url URL Marketplace WebSocket URL (default: ws://localhost:8081)
8
16
  # --api-key KEY Gateway API key for authentication
9
17
  # --port PORT Gateway port (default: 8083)
10
18
  # --install-dir DIR Installation directory (default: /opt/langmart-gateway)
19
+ # --capabilities CAPS Gateway capabilities: session,llm or llm (default: llm)
20
+ # --full Enable full capabilities (DevOps + LLM routing)
11
21
  # --service Install as systemd service
12
22
  # --help Show this help message
13
23
 
@@ -26,6 +36,7 @@ INSTALL_DIR="/opt/langmart-gateway"
26
36
  GATEWAY_PORT="8083"
27
37
  MARKETPLACE_URL="ws://localhost:8081"
28
38
  GATEWAY_API_KEY=""
39
+ GATEWAY_CAPABILITIES=""
29
40
  INSTALL_SERVICE=false
30
41
  GITHUB_TOKEN=""
31
42
 
@@ -52,6 +63,14 @@ while [[ $# -gt 0 ]]; do
52
63
  INSTALL_SERVICE=true
53
64
  shift
54
65
  ;;
66
+ --capabilities)
67
+ GATEWAY_CAPABILITIES="$2"
68
+ shift 2
69
+ ;;
70
+ --full)
71
+ GATEWAY_CAPABILITIES="session,llm"
72
+ shift
73
+ ;;
55
74
  --github-token)
56
75
  GITHUB_TOKEN="$2"
57
76
  shift 2
@@ -67,11 +86,13 @@ while [[ $# -gt 0 ]]; do
67
86
  echo " --port PORT Gateway port (default: 8083)"
68
87
  echo " --install-dir DIR Installation directory (default: /opt/langmart-gateway)"
69
88
  echo " --service Install as systemd service"
89
+ echo " --capabilities CAPS Gateway capabilities: session,llm or llm (default: llm only)"
90
+ echo " --full Enable full capabilities (session + llm) - DevOps mode"
70
91
  echo " --github-token TOKEN GitHub token for npm package access"
71
92
  echo " --help Show this help message"
72
93
  echo ""
73
94
  echo "Example:"
74
- echo " $0 --marketplace-url ws://10.0.1.117:8081 --api-key sk-test-key --service"
95
+ echo " $0 --marketplace-url ws://10.0.1.117:8081 --api-key sk-test-key --full --service"
75
96
  exit 0
76
97
  ;;
77
98
  *)
@@ -155,22 +176,17 @@ if [ ! -f package.json ]; then
155
176
  fi
156
177
 
157
178
  # Install the gateway package
158
- echo -e "${CYAN}[4/6] Installing @langmart/gateway-type3...${NC}"
159
- if [ -n "$GITHUB_TOKEN" ]; then
160
- npm install @langmart/gateway-type3@latest
161
- else
162
- # Direct clone fallback for development
163
- echo -e "${YELLOW}Cloning from GitHub repository...${NC}"
164
- git clone --depth 1 https://github.com/YiHuangDB/LangMartDesign.git /tmp/langmart-clone
165
- cp -r /tmp/langmart-clone/gateway-type3/* .
166
- rm -rf /tmp/langmart-clone
167
- npm install --production
168
- npm run build
169
- fi
179
+ echo -e "${CYAN}[4/6] Installing langmart-gateway-type3...${NC}"
180
+ # Install from npm (no token needed for public packages)
181
+ npm install langmart-gateway-type3@latest
170
182
  echo -e "${GREEN}✓ Gateway package installed${NC}"
171
183
 
172
184
  # Create environment file
173
185
  echo -e "${CYAN}[5/6] Creating environment configuration...${NC}"
186
+
187
+ # Generate vault password
188
+ VAULT_PWD=$(openssl rand -base64 32)
189
+
174
190
  cat > .env << EOF
175
191
  # LangMart Gateway Type 3 Configuration
176
192
  # Generated by install-remote.sh on $(date)
@@ -185,9 +201,12 @@ MARKETPLACE_URL=${MARKETPLACE_URL}
185
201
  # Gateway authentication
186
202
  GATEWAY_API_KEY=${GATEWAY_API_KEY}
187
203
 
204
+ # Gateway capabilities (session,llm = full DevOps mode, llm = LLM routing only)
205
+ GATEWAY_CAPABILITIES=${GATEWAY_CAPABILITIES:-llm}
206
+
188
207
  # Local vault configuration
189
208
  VAULT_PATH=.vault/credentials.enc
190
- VAULT_PASSWORD=$(openssl rand -base64 32)
209
+ VAULT_PASSWORD=${VAULT_PWD}
191
210
 
192
211
  # Environment
193
212
  NODE_ENV=production
@@ -199,11 +218,17 @@ echo -e "${GREEN}✓ Environment file created${NC}"
199
218
  cat > start.sh << 'STARTEOF'
200
219
  #!/bin/bash
201
220
  cd "$(dirname "$0")"
202
- source .env 2>/dev/null || true
203
221
 
204
- if [ -d node_modules/@langmart/gateway-type3 ]; then
222
+ # Export all variables from .env file
223
+ if [ -f .env ]; then
224
+ set -a
225
+ source .env
226
+ set +a
227
+ fi
228
+
229
+ if [ -d node_modules/langmart-gateway-type3 ]; then
205
230
  # Installed via npm
206
- node node_modules/@langmart/gateway-type3/dist/index-server.js
231
+ node node_modules/langmart-gateway-type3/dist/index-server.js
207
232
  else
208
233
  # Direct installation
209
234
  node dist/index-server.js
@@ -265,6 +290,11 @@ echo ""
265
290
  echo -e "${CYAN}Installation Directory: ${INSTALL_DIR}${NC}"
266
291
  echo -e "${CYAN}Gateway Port: ${GATEWAY_PORT}${NC}"
267
292
  echo -e "${CYAN}Marketplace URL: ${MARKETPLACE_URL}${NC}"
293
+ if [ -n "$GATEWAY_CAPABILITIES" ] && [ "$GATEWAY_CAPABILITIES" = "session,llm" ]; then
294
+ echo -e "${CYAN}Mode: Full (DevOps + LLM Routing)${NC}"
295
+ else
296
+ echo -e "${CYAN}Mode: LLM Routing Only${NC}"
297
+ fi
268
298
  echo ""
269
299
  echo -e "${YELLOW}Before starting, configure your API key:${NC}"
270
300
  echo -e " ${CYAN}1. Edit ${INSTALL_DIR}/.env${NC}"