troxy-cli 1.8.8 → 1.8.9
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/bin/troxy.js +2 -0
- package/package.json +1 -1
- package/src/init.js +13 -4
- package/src/tests/init.test.js +27 -0
package/bin/troxy.js
CHANGED
|
@@ -510,6 +510,8 @@ switch (command) {
|
|
|
510
510
|
|
|
511
511
|
Setup (one time, API key required)
|
|
512
512
|
troxy init --key <api-key> Connect this machine as an MCP + save key
|
|
513
|
+
troxy init --key <api-key> --name "My Agent" Same, no interactive prompt
|
|
514
|
+
(for cloud/scripted agents that can't answer stdin)
|
|
513
515
|
troxy restart Restart the MCP background service
|
|
514
516
|
troxy uninstall Remove Troxy from this machine
|
|
515
517
|
troxy status API health + MCP status (no login needed)
|
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -121,7 +121,7 @@ const MCP_CLIENTS = [
|
|
|
121
121
|
},
|
|
122
122
|
];
|
|
123
123
|
|
|
124
|
-
export async function runInit({ key } = {}) {
|
|
124
|
+
export async function runInit({ key, name } = {}) {
|
|
125
125
|
if (!key || !key.startsWith('txy-')) {
|
|
126
126
|
console.error('\n Error: --key is required and must start with txy-');
|
|
127
127
|
console.error(' Usage: npx troxy-cli init --key txy-...\n');
|
|
@@ -155,10 +155,19 @@ export async function runInit({ key } = {}) {
|
|
|
155
155
|
console.log('✓');
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
// Ask for agent name (default to hostname so users don't get stuck)
|
|
158
|
+
// Ask for agent name (default to hostname so users don't get stuck) — unless
|
|
159
|
+
// --name was passed, in which case skip the interactive prompt entirely.
|
|
160
|
+
// Needed for cloud agents (Base44 Superagent, etc.) that can't reliably
|
|
161
|
+
// respond to a stdin prompt and would otherwise hang init indefinitely.
|
|
159
162
|
const defaultName = os.hostname() || 'my-agent';
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
let agentName;
|
|
164
|
+
if (name) {
|
|
165
|
+
agentName = name;
|
|
166
|
+
console.log(` Naming this agent "${agentName}"`);
|
|
167
|
+
} else {
|
|
168
|
+
const answer = await prompt(` Name this agent (press Enter for "${defaultName}"): `);
|
|
169
|
+
agentName = answer || defaultName;
|
|
170
|
+
}
|
|
162
171
|
|
|
163
172
|
// Save config
|
|
164
173
|
saveConfig({ apiKey: key, agentName });
|
package/src/tests/init.test.js
CHANGED
|
@@ -20,3 +20,30 @@ describe('flag validation', () => {
|
|
|
20
20
|
assert.ok(key.startsWith('txy-'));
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
|
+
|
|
24
|
+
describe('agent name resolution (--name flag)', () => {
|
|
25
|
+
// Mirrors the branch added to runInit in src/init.js: a cloud/scripted agent
|
|
26
|
+
// (Base44 Superagent, etc.) can't answer an interactive stdin prompt, so
|
|
27
|
+
// `troxy init --key ... --name "X"` must skip the prompt entirely rather
|
|
28
|
+
// than hang waiting for input that will never come — found live testing a
|
|
29
|
+
// real Base44 agent against this exact CLI (TXY-128).
|
|
30
|
+
function resolveAgentName(name, promptAnswer, defaultName) {
|
|
31
|
+
if (name) return name;
|
|
32
|
+
return promptAnswer || defaultName;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
it('uses --name directly, without ever consulting the prompt answer', () => {
|
|
36
|
+
const agentName = resolveAgentName('Lyra SuperAgent', undefined, 'some-hostname');
|
|
37
|
+
assert.equal(agentName, 'Lyra SuperAgent');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('falls back to the interactive prompt answer when --name is not given', () => {
|
|
41
|
+
const agentName = resolveAgentName(undefined, 'Chosen Name', 'some-hostname');
|
|
42
|
+
assert.equal(agentName, 'Chosen Name');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('falls back to the hostname default when neither --name nor a prompt answer is given', () => {
|
|
46
|
+
const agentName = resolveAgentName(undefined, '', 'some-hostname');
|
|
47
|
+
assert.equal(agentName, 'some-hostname');
|
|
48
|
+
});
|
|
49
|
+
});
|