@terminusagents/agents 0.1.0 → 0.1.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 +10 -6
- package/dist/cli/init.js +28 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,6 +50,10 @@ pnpm build
|
|
|
50
50
|
npx terminus-agent init
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
`init` uses production-safe defaults:
|
|
54
|
+
- testnet: `wss://cp-sepolia.termn.xyz/ws`
|
|
55
|
+
- mainnet: `wss://cp-mainnet.termn.xyz/ws`
|
|
56
|
+
|
|
53
57
|
3. Export required runtime secrets:
|
|
54
58
|
|
|
55
59
|
```bash
|
|
@@ -109,13 +113,13 @@ npx terminus-agent run # start agent client
|
|
|
109
113
|
Optional preset environment variables:
|
|
110
114
|
|
|
111
115
|
```bash
|
|
112
|
-
export TERMINUS_CONTROL_PLANE_URL_LOCAL=ws://localhost:8084
|
|
113
|
-
export TERMINUS_CONTROL_PLANE_URL_TESTNET=wss
|
|
114
|
-
export TERMINUS_CONTROL_PLANE_URL_MAINNET=wss
|
|
116
|
+
export TERMINUS_CONTROL_PLANE_URL_LOCAL=ws://localhost:8084/ws
|
|
117
|
+
export TERMINUS_CONTROL_PLANE_URL_TESTNET=wss://cp-sepolia.termn.xyz/ws
|
|
118
|
+
export TERMINUS_CONTROL_PLANE_URL_MAINNET=wss://cp-mainnet.termn.xyz/ws
|
|
115
119
|
```
|
|
116
120
|
|
|
117
121
|
Notes:
|
|
118
|
-
- `mainnet`
|
|
122
|
+
- `testnet` and `mainnet` profiles require `wss://`
|
|
119
123
|
- if `REQUIRE_WSS=true`, plain `ws://` is rejected
|
|
120
124
|
|
|
121
125
|
## Security Defaults
|
|
@@ -141,7 +145,7 @@ Example:
|
|
|
141
145
|
"agentType": "travel-planner",
|
|
142
146
|
"wallet": "0x1234567890abcdef1234567890abcdef12345678",
|
|
143
147
|
"apiKey": "__ENV__",
|
|
144
|
-
"controlPlaneUrl": "wss://
|
|
148
|
+
"controlPlaneUrl": "wss://cp-sepolia.termn.xyz/ws",
|
|
145
149
|
"nodeId": "travel-planner-123456-a1b2c3d4",
|
|
146
150
|
"llmProvider": "grok",
|
|
147
151
|
"networkProfile": "testnet"
|
|
@@ -155,7 +159,7 @@ Example:
|
|
|
155
159
|
### `Connection failed`
|
|
156
160
|
- run `npx terminus-agent doctor --full`
|
|
157
161
|
- verify control plane URL and firewall
|
|
158
|
-
- for mainnet, verify URL starts with `wss://`
|
|
162
|
+
- for testnet/mainnet, verify URL starts with `wss://`
|
|
159
163
|
|
|
160
164
|
### `Auth failed`
|
|
161
165
|
- verify `TERMINUS_WALLET_PRIVATE_KEY` is set
|
package/dist/cli/init.js
CHANGED
|
@@ -42,14 +42,16 @@ const NETWORK_LABELS = {
|
|
|
42
42
|
testnet: 'Base Sepolia testnet',
|
|
43
43
|
mainnet: 'Base mainnet',
|
|
44
44
|
};
|
|
45
|
+
const DEFAULT_TESTNET_CONTROL_PLANE_URL = 'wss://cp-sepolia.termn.xyz/ws';
|
|
46
|
+
const DEFAULT_MAINNET_CONTROL_PLANE_URL = 'wss://cp-mainnet.termn.xyz/ws';
|
|
45
47
|
const NETWORK_URL_PRESETS = {
|
|
46
|
-
local: process.env.TERMINUS_CONTROL_PLANE_URL_LOCAL?.trim() || 'ws://localhost:8084',
|
|
48
|
+
local: process.env.TERMINUS_CONTROL_PLANE_URL_LOCAL?.trim() || 'ws://localhost:8084/ws',
|
|
47
49
|
testnet: process.env.TERMINUS_CONTROL_PLANE_URL_TESTNET?.trim() ||
|
|
48
50
|
process.env.TERMINUS_CONTROL_PLANE_URL?.trim() ||
|
|
49
|
-
|
|
51
|
+
DEFAULT_TESTNET_CONTROL_PLANE_URL,
|
|
50
52
|
mainnet: process.env.TERMINUS_CONTROL_PLANE_URL_MAINNET?.trim() ||
|
|
51
53
|
process.env.TERMINUS_CONTROL_PLANE_URL?.trim() ||
|
|
52
|
-
|
|
54
|
+
DEFAULT_MAINNET_CONTROL_PLANE_URL,
|
|
53
55
|
};
|
|
54
56
|
const LLM_CHOICES = [
|
|
55
57
|
{
|
|
@@ -87,6 +89,22 @@ function isValidWallet(input) {
|
|
|
87
89
|
function isWsUrl(input) {
|
|
88
90
|
return input.startsWith('ws://') || input.startsWith('wss://');
|
|
89
91
|
}
|
|
92
|
+
function normalizeControlPlaneUrl(input) {
|
|
93
|
+
const trimmed = input.trim();
|
|
94
|
+
if (!trimmed)
|
|
95
|
+
return trimmed;
|
|
96
|
+
try {
|
|
97
|
+
const parsed = new URL(trimmed);
|
|
98
|
+
if ((parsed.protocol === 'ws:' || parsed.protocol === 'wss:') && (parsed.pathname === '' || parsed.pathname === '/')) {
|
|
99
|
+
parsed.pathname = '/ws';
|
|
100
|
+
return parsed.toString();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Keep original value; validation layer handles invalid URLs.
|
|
105
|
+
}
|
|
106
|
+
return trimmed;
|
|
107
|
+
}
|
|
90
108
|
function normalizeProvider(provider) {
|
|
91
109
|
if (!provider)
|
|
92
110
|
return undefined;
|
|
@@ -308,13 +326,14 @@ async function selectNetworkProfile(initialValue, nonInteractive) {
|
|
|
308
326
|
return profile;
|
|
309
327
|
}
|
|
310
328
|
async function selectControlPlaneUrl(profile, initialValue, nonInteractive) {
|
|
311
|
-
const defaultUrl = initialValue?.trim() || NETWORK_URL_PRESETS[profile];
|
|
329
|
+
const defaultUrl = normalizeControlPlaneUrl(initialValue?.trim() || NETWORK_URL_PRESETS[profile]);
|
|
330
|
+
const requiresSecureWs = profile !== 'local';
|
|
312
331
|
if (nonInteractive) {
|
|
313
332
|
if (!isWsUrl(defaultUrl)) {
|
|
314
333
|
throw new Error('controlPlaneUrl must start with ws:// or wss://');
|
|
315
334
|
}
|
|
316
|
-
if (
|
|
317
|
-
throw new Error(
|
|
335
|
+
if (requiresSecureWs && !defaultUrl.startsWith('wss://')) {
|
|
336
|
+
throw new Error(`${NETWORK_LABELS[profile]} profile requires wss:// control-plane URL.`);
|
|
318
337
|
}
|
|
319
338
|
return defaultUrl;
|
|
320
339
|
}
|
|
@@ -327,14 +346,14 @@ async function selectControlPlaneUrl(profile, initialValue, nonInteractive) {
|
|
|
327
346
|
validate: (input) => {
|
|
328
347
|
if (!isWsUrl(input))
|
|
329
348
|
return 'URL must start with ws:// or wss://';
|
|
330
|
-
if (
|
|
331
|
-
return
|
|
349
|
+
if (requiresSecureWs && !input.startsWith('wss://')) {
|
|
350
|
+
return `${NETWORK_LABELS[profile]} requires wss://`;
|
|
332
351
|
}
|
|
333
352
|
return true;
|
|
334
353
|
},
|
|
335
354
|
},
|
|
336
355
|
]);
|
|
337
|
-
return String(controlPlaneUrl);
|
|
356
|
+
return normalizeControlPlaneUrl(String(controlPlaneUrl));
|
|
338
357
|
}
|
|
339
358
|
export async function initCommand(rawOptions = {}) {
|
|
340
359
|
const options = {
|