@zincapp/znvault-cli 4.4.0 → 4.6.0
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/dist/commands/agent/direct/ping.d.ts.map +1 -1
- package/dist/commands/agent/direct/ping.js +3 -1
- package/dist/commands/agent/direct/ping.js.map +1 -1
- package/dist/commands/agent/direct/plugins.d.ts.map +1 -1
- package/dist/commands/agent/direct/plugins.js +3 -1
- package/dist/commands/agent/direct/plugins.js.map +1 -1
- package/dist/commands/agent/direct/update-all.d.ts.map +1 -1
- package/dist/commands/agent/direct/update-all.js +9 -6
- package/dist/commands/agent/direct/update-all.js.map +1 -1
- package/dist/commands/agent/direct/update-plugins.d.ts.map +1 -1
- package/dist/commands/agent/direct/update-plugins.js +90 -64
- package/dist/commands/agent/direct/update-plugins.js.map +1 -1
- package/dist/commands/agent/direct/update.d.ts.map +1 -1
- package/dist/commands/agent/direct/update.js +92 -65
- package/dist/commands/agent/direct/update.js.map +1 -1
- package/dist/commands/agent/direct/version.d.ts.map +1 -1
- package/dist/commands/agent/direct/version.js +3 -1
- package/dist/commands/agent/direct/version.js.map +1 -1
- package/dist/commands/agent/helpers.d.ts +1 -1
- package/dist/commands/agent/helpers.d.ts.map +1 -1
- package/dist/commands/agent/helpers.js +8 -1
- package/dist/commands/agent/helpers.js.map +1 -1
- package/dist/commands/agent/types.d.ts +6 -0
- package/dist/commands/agent/types.d.ts.map +1 -1
- package/dist/commands/kmip/clients.d.ts +4 -0
- package/dist/commands/kmip/clients.d.ts.map +1 -1
- package/dist/commands/kmip/clients.js +37 -0
- package/dist/commands/kmip/clients.js.map +1 -1
- package/dist/commands/kmip/index.d.ts.map +1 -1
- package/dist/commands/kmip/index.js +7 -1
- package/dist/commands/kmip/index.js.map +1 -1
- package/dist/commands/kmip/types.d.ts +1 -0
- package/dist/commands/kmip/types.d.ts.map +1 -1
- package/dist/commands/ssh/connect.d.ts +22 -0
- package/dist/commands/ssh/connect.d.ts.map +1 -1
- package/dist/commands/ssh/connect.js +90 -163
- package/dist/commands/ssh/connect.js.map +1 -1
- package/dist/commands/ssh/forward.d.ts +49 -0
- package/dist/commands/ssh/forward.d.ts.map +1 -0
- package/dist/commands/ssh/forward.js +151 -0
- package/dist/commands/ssh/forward.js.map +1 -0
- package/dist/commands/ssh/index.d.ts.map +1 -1
- package/dist/commands/ssh/index.js +9 -1
- package/dist/commands/ssh/index.js.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/ssh-tunnel.d.ts +41 -0
- package/dist/lib/ssh-tunnel.d.ts.map +1 -0
- package/dist/lib/ssh-tunnel.js +144 -0
- package/dist/lib/ssh-tunnel.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/ping.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/ping.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAsD5D"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// Path: src/commands/agent/direct/ping.ts
|
|
2
2
|
import * as output from '../../../lib/output.js';
|
|
3
3
|
import { resolveHostPort, fetchAgentHealth, formatUptime } from '../helpers.js';
|
|
4
|
+
import { withAgentConnection } from '../../../lib/ssh-tunnel.js';
|
|
4
5
|
export function registerPingCommand(parentCmd) {
|
|
5
6
|
parentCmd
|
|
6
7
|
.command('ping [hostPort]')
|
|
7
8
|
.description('Check agent health directly via HTTP (format: host:port or host, or select from list)')
|
|
8
9
|
.option('--json', 'Output as JSON')
|
|
10
|
+
.option('--no-tunnel', 'Connect directly to host:port instead of via an SSH-CA tunnel')
|
|
9
11
|
.action(async (hostPort, options) => {
|
|
10
12
|
const resolved = await resolveHostPort(hostPort);
|
|
11
13
|
if (!resolved) {
|
|
@@ -14,7 +16,7 @@ export function registerPingCommand(parentCmd) {
|
|
|
14
16
|
const { host, port } = resolved;
|
|
15
17
|
const spinner = output.spinner(`Checking agent at ${host}:${port}...`).start();
|
|
16
18
|
try {
|
|
17
|
-
const health = await
|
|
19
|
+
const health = await withAgentConnection(host, port, { tunnel: options.tunnel !== false }, (h, p) => fetchAgentHealth(h, p));
|
|
18
20
|
spinner.stop();
|
|
19
21
|
if (options.json) {
|
|
20
22
|
output.json(health);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ping.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/ping.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAQ1C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ping.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/ping.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAQ1C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,UAAU,mBAAmB,CAAC,SAAkB;IACpD,SAAS;SACN,OAAO,CAAC,iBAAiB,CAAC;SAC1B,WAAW,CAAC,uFAAuF,CAAC;SACpG,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,aAAa,EAAE,+DAA+D,CAAC;SACtF,MAAM,CAAC,KAAK,EAAE,QAA4B,EAAE,OAA6B,EAAE,EAAE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|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/plugins.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/plugins.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAuD/D"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// Path: src/commands/agent/direct/plugins.ts
|
|
2
2
|
import * as output from '../../../lib/output.js';
|
|
3
3
|
import { resolveHostPort, fetchPluginVersions } from '../helpers.js';
|
|
4
|
+
import { withAgentConnection } from '../../../lib/ssh-tunnel.js';
|
|
4
5
|
export function registerPluginsCommand(parentCmd) {
|
|
5
6
|
parentCmd
|
|
6
7
|
.command('plugins [hostPort]')
|
|
7
8
|
.description('Check plugin versions on an agent (format: host:port or host, or select from list)')
|
|
8
9
|
.option('--json', 'Output as JSON')
|
|
10
|
+
.option('--no-tunnel', 'Connect directly to host:port instead of via an SSH-CA tunnel')
|
|
9
11
|
.action(async (hostPort, options) => {
|
|
10
12
|
const resolved = await resolveHostPort(hostPort);
|
|
11
13
|
if (!resolved) {
|
|
@@ -14,7 +16,7 @@ export function registerPluginsCommand(parentCmd) {
|
|
|
14
16
|
const { host, port } = resolved;
|
|
15
17
|
const spinner = output.spinner(`Checking plugins at ${host}:${port}...`).start();
|
|
16
18
|
try {
|
|
17
|
-
const response = await
|
|
19
|
+
const response = await withAgentConnection(host, port, { tunnel: options.tunnel !== false }, (h, p) => fetchPluginVersions(h, p));
|
|
18
20
|
spinner.stop();
|
|
19
21
|
if (options.json) {
|
|
20
22
|
output.json(response);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/plugins.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAQ7C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/plugins.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAQ7C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,UAAU,sBAAsB,CAAC,SAAkB;IACvD,SAAS;SACN,OAAO,CAAC,oBAAoB,CAAC;SAC7B,WAAW,CAAC,oFAAoF,CAAC;SACjG,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,aAAa,EAAE,+DAA+D,CAAC;SACtF,MAAM,CAAC,KAAK,EAAE,QAA4B,EAAE,OAA6B,EAAE,EAAE;QAC5E,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;QAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,uBAAuB,IAAI,IAAI,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QAEjF,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE,EAAE,CAAC,CAAC,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CAAC,CAAC;gBAC7G,OAAO,CAAC,GAAG,CAAC,qCAAqC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;YACnE,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,8BAA8B,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;YAC3D,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-all.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update-all.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"update-all.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update-all.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0BzC,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAyPjE"}
|
|
@@ -3,6 +3,7 @@ import * as mode from '../../../lib/mode.js';
|
|
|
3
3
|
import * as output from '../../../lib/output.js';
|
|
4
4
|
import { DEFAULT_AGENT_PORT } from '../../../lib/constants.js';
|
|
5
5
|
import { confirmAction, fetchAgentVersion, fetchPluginVersions, triggerAgentUpdate, triggerPluginUpdate, } from '../helpers.js';
|
|
6
|
+
import { withAgentConnection } from '../../../lib/ssh-tunnel.js';
|
|
6
7
|
export function registerUpdateAllCommand(parentCmd) {
|
|
7
8
|
parentCmd
|
|
8
9
|
.command('update-all')
|
|
@@ -12,6 +13,7 @@ export function registerUpdateAllCommand(parentCmd) {
|
|
|
12
13
|
.option('--dry-run', 'Show what would be updated without making changes')
|
|
13
14
|
.option('-y, --yes', 'Skip confirmation')
|
|
14
15
|
.option('--json', 'Output as JSON')
|
|
16
|
+
.option('--no-tunnel', 'Connect directly to each host instead of via an SSH-CA tunnel')
|
|
15
17
|
.action(async (options) => {
|
|
16
18
|
const spinner = output.spinner('Fetching online agents...').start();
|
|
17
19
|
try {
|
|
@@ -51,11 +53,12 @@ export function registerUpdateAllCommand(parentCmd) {
|
|
|
51
53
|
// Check versions for all agents
|
|
52
54
|
const checkSpinner = output.spinner(`Checking ${reachableAgents.length} agent(s)...`).start();
|
|
53
55
|
const agentInfo = [];
|
|
56
|
+
const useTunnel = options.tunnel !== false;
|
|
54
57
|
for (const { agent, ip } of reachableAgents) {
|
|
55
58
|
try {
|
|
56
59
|
if (options.plugins) {
|
|
57
|
-
// Check plugin versions
|
|
58
|
-
const pluginInfo = await
|
|
60
|
+
// Check plugin versions (through an SSH-CA tunnel by default).
|
|
61
|
+
const pluginInfo = await withAgentConnection(ip, DEFAULT_AGENT_PORT, { tunnel: useTunnel }, (h, p) => fetchPluginVersions(h, p));
|
|
59
62
|
const updatesNeeded = pluginInfo.versions.filter(v => v.updateAvailable).length;
|
|
60
63
|
agentInfo.push({
|
|
61
64
|
agent,
|
|
@@ -67,8 +70,8 @@ export function registerUpdateAllCommand(parentCmd) {
|
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
else {
|
|
70
|
-
// Check agent version
|
|
71
|
-
const versionInfo = await
|
|
73
|
+
// Check agent version (through an SSH-CA tunnel by default).
|
|
74
|
+
const versionInfo = await withAgentConnection(ip, DEFAULT_AGENT_PORT, { tunnel: useTunnel }, (h, p) => fetchAgentVersion(h, p));
|
|
72
75
|
agentInfo.push({
|
|
73
76
|
agent,
|
|
74
77
|
ip,
|
|
@@ -172,7 +175,7 @@ export function registerUpdateAllCommand(parentCmd) {
|
|
|
172
175
|
}
|
|
173
176
|
try {
|
|
174
177
|
if (options.plugins) {
|
|
175
|
-
const response = await
|
|
178
|
+
const response = await withAgentConnection(info.ip, DEFAULT_AGENT_PORT, { tunnel: useTunnel }, (h, p) => triggerPluginUpdate(h, p));
|
|
176
179
|
results.push({
|
|
177
180
|
hostname: info.agent.hostname,
|
|
178
181
|
success: response.updated > 0,
|
|
@@ -183,7 +186,7 @@ export function registerUpdateAllCommand(parentCmd) {
|
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
else {
|
|
186
|
-
const response = await
|
|
189
|
+
const response = await withAgentConnection(info.ip, DEFAULT_AGENT_PORT, { tunnel: useTunnel }, (h, p) => triggerAgentUpdate(h, p));
|
|
187
190
|
results.push({
|
|
188
191
|
hostname: info.agent.hostname,
|
|
189
192
|
success: response.success,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-all.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update-all.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAQhD,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,GAEpB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"update-all.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update-all.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAQhD,OAAO,KAAK,IAAI,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;A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update-plugins.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update-plugins.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"update-plugins.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update-plugins.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBzC,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CA0GrE"}
|
|
@@ -1,88 +1,114 @@
|
|
|
1
1
|
// Path: src/commands/agent/direct/update-plugins.ts
|
|
2
2
|
import * as output from '../../../lib/output.js';
|
|
3
3
|
import { resolveHostPort, fetchPluginVersions, triggerPluginUpdate, confirmAction, waitForAgentRestart, } from '../helpers.js';
|
|
4
|
+
import { withAgentConnection } from '../../../lib/ssh-tunnel.js';
|
|
5
|
+
/**
|
|
6
|
+
* Thrown inside the withAgentConnection callback when the failure has ALREADY
|
|
7
|
+
* been reported. Lets the callback unwind (running the tunnel teardown in
|
|
8
|
+
* `finally`) without the outer catch logging the error twice.
|
|
9
|
+
*/
|
|
10
|
+
class AlreadyReportedError extends Error {
|
|
11
|
+
}
|
|
4
12
|
export function registerUpdatePluginsCommand(parentCmd) {
|
|
5
13
|
parentCmd
|
|
6
14
|
.command('update-plugins [hostPort]')
|
|
7
15
|
.description('Trigger plugin updates on an agent (format: host:port or host, or select from list)')
|
|
8
16
|
.option('-y, --yes', 'Skip confirmation prompt')
|
|
9
17
|
.option('--json', 'Output as JSON')
|
|
18
|
+
.option('--no-tunnel', 'Connect directly to host:port instead of via an SSH-CA tunnel')
|
|
10
19
|
.action(async (hostPort, options) => {
|
|
11
20
|
const resolved = await resolveHostPort(hostPort);
|
|
12
21
|
if (!resolved) {
|
|
13
22
|
process.exit(1);
|
|
14
23
|
}
|
|
15
24
|
const { host, port } = resolved;
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
let versions;
|
|
25
|
+
// All HTTP calls (check → trigger → wait-for-restart) share ONE SSH-CA
|
|
26
|
+
// tunnel so the agent's loopback-only :9100 is reachable throughout.
|
|
19
27
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
if (!versions.hasUpdates) {
|
|
29
|
-
if (options.json) {
|
|
30
|
-
output.json({ updated: 0, message: 'All plugins up to date' });
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
console.log('\x1b[32m✓\x1b[0m All plugins are up to date');
|
|
34
|
-
}
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// Show what will be updated
|
|
38
|
-
if (!options.json) {
|
|
39
|
-
console.log();
|
|
40
|
-
console.log('Updates available:');
|
|
41
|
-
for (const plugin of versions.versions) {
|
|
42
|
-
if (plugin.updateAvailable) {
|
|
43
|
-
console.log(` ${plugin.package}: ${plugin.current} → \x1b[32m${plugin.latest}\x1b[0m`);
|
|
28
|
+
await withAgentConnection(host, port, { tunnel: options.tunnel !== false }, async (h, p) => {
|
|
29
|
+
// First check what needs updating.
|
|
30
|
+
const checkSpinner = output.spinner(`Checking plugins at ${host}:${port}...`).start();
|
|
31
|
+
let versions;
|
|
32
|
+
try {
|
|
33
|
+
versions = await fetchPluginVersions(h, p);
|
|
34
|
+
checkSpinner.stop();
|
|
44
35
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const confirmed = await confirmAction('Proceed with update? Agent will restart.');
|
|
51
|
-
if (!confirmed) {
|
|
52
|
-
console.log('Cancelled');
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Trigger update
|
|
57
|
-
const updateSpinner = output.spinner('Updating plugins...').start();
|
|
58
|
-
try {
|
|
59
|
-
const response = await triggerPluginUpdate(host, port);
|
|
60
|
-
updateSpinner.stop();
|
|
61
|
-
if (options.json) {
|
|
62
|
-
output.json(response);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (response.updated === 0) {
|
|
66
|
-
console.log('No updates were applied');
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
console.log(`\x1b[32m✓\x1b[0m Updated ${response.updated} plugin(s)`);
|
|
70
|
-
for (const result of response.results) {
|
|
71
|
-
if (result.success) {
|
|
72
|
-
console.log(` ${result.package}: ${result.previousVersion} → ${result.newVersion}`);
|
|
36
|
+
catch (err) {
|
|
37
|
+
checkSpinner.fail(`Failed to check plugins at ${host}:${port}`);
|
|
38
|
+
output.error(err instanceof Error ? err.message : String(err));
|
|
39
|
+
// Already reported — unwind so the tunnel tears down, then exit.
|
|
40
|
+
throw new AlreadyReportedError();
|
|
73
41
|
}
|
|
74
|
-
|
|
75
|
-
|
|
42
|
+
if (!versions.hasUpdates) {
|
|
43
|
+
if (options.json) {
|
|
44
|
+
output.json({ updated: 0, message: 'All plugins up to date' });
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log('\x1b[32m✓\x1b[0m All plugins are up to date');
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
76
50
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
51
|
+
// Show what will be updated.
|
|
52
|
+
if (!options.json) {
|
|
53
|
+
console.log();
|
|
54
|
+
console.log('Updates available:');
|
|
55
|
+
for (const plugin of versions.versions) {
|
|
56
|
+
if (plugin.updateAvailable) {
|
|
57
|
+
console.log(` ${plugin.package}: ${plugin.current} → \x1b[32m${plugin.latest}\x1b[0m`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
console.log();
|
|
61
|
+
}
|
|
62
|
+
// Confirm.
|
|
63
|
+
if (!options.yes && !options.json) {
|
|
64
|
+
const confirmed = await confirmAction('Proceed with update? Agent will restart.');
|
|
65
|
+
if (!confirmed) {
|
|
66
|
+
console.log('Cancelled');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Trigger update.
|
|
71
|
+
const updateSpinner = output.spinner('Updating plugins...').start();
|
|
72
|
+
try {
|
|
73
|
+
const response = await triggerPluginUpdate(h, p);
|
|
74
|
+
updateSpinner.stop();
|
|
75
|
+
if (options.json) {
|
|
76
|
+
output.json(response);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (response.updated === 0) {
|
|
80
|
+
console.log('No updates were applied');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
console.log(`\x1b[32m✓\x1b[0m Updated ${response.updated} plugin(s)`);
|
|
84
|
+
for (const result of response.results) {
|
|
85
|
+
if (result.success) {
|
|
86
|
+
console.log(` ${result.package}: ${result.previousVersion} → ${result.newVersion}`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
console.log(` \x1b[31m✗\x1b[0m ${result.package}: ${result.error}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (response.willRestart) {
|
|
93
|
+
console.log();
|
|
94
|
+
await waitForAgentRestart(h, p);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
if (err instanceof AlreadyReportedError)
|
|
99
|
+
throw err;
|
|
100
|
+
updateSpinner.fail('Failed to update plugins');
|
|
101
|
+
output.error(err instanceof Error ? err.message : String(err));
|
|
102
|
+
throw new AlreadyReportedError();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
82
105
|
}
|
|
83
106
|
catch (err) {
|
|
84
|
-
|
|
85
|
-
|
|
107
|
+
// AlreadyReportedError: message printed inside the callback; just exit
|
|
108
|
+
// (the tunnel has been torn down by withAgentConnection's finally).
|
|
109
|
+
if (!(err instanceof AlreadyReportedError)) {
|
|
110
|
+
output.error(err instanceof Error ? err.message : String(err));
|
|
111
|
+
}
|
|
86
112
|
process.exit(1);
|
|
87
113
|
}
|
|
88
114
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-plugins.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update-plugins.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAQpD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,GACpB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"update-plugins.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update-plugins.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAQpD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,oBAAqB,SAAQ,KAAK;CAAG;AAE3C,MAAM,UAAU,4BAA4B,CAAC,SAAkB;IAC7D,SAAS;SACN,OAAO,CAAC,2BAA2B,CAAC;SACpC,WAAW,CAAC,qFAAqF,CAAC;SAClG,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC;SAC/C,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,aAAa,EAAE,+DAA+D,CAAC;SACtF,MAAM,CAAC,KAAK,EAAE,QAA4B,EAAE,OAA6B,EAAE,EAAE;QAC5E,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;QAEhC,uEAAuE;QACvE,qE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
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBzC,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CA2G9D"}
|
|
@@ -1,87 +1,114 @@
|
|
|
1
1
|
// Path: src/commands/agent/direct/update.ts
|
|
2
2
|
import * as output from '../../../lib/output.js';
|
|
3
3
|
import { resolveHostPort, fetchAgentVersion, triggerAgentUpdate, confirmAction, waitForAgentRestart, } from '../helpers.js';
|
|
4
|
+
import { withAgentConnection } from '../../../lib/ssh-tunnel.js';
|
|
5
|
+
/**
|
|
6
|
+
* Thrown inside the withAgentConnection callback when the failure has ALREADY
|
|
7
|
+
* been reported to the user. It lets the callback unwind (running the tunnel
|
|
8
|
+
* teardown in `finally`) without the outer catch logging the error twice.
|
|
9
|
+
*/
|
|
10
|
+
class AlreadyReportedError extends Error {
|
|
11
|
+
}
|
|
4
12
|
export function registerUpdateCommand(parentCmd) {
|
|
5
13
|
parentCmd
|
|
6
14
|
.command('update [hostPort]')
|
|
7
15
|
.description('Trigger agent self-update (format: host:port or host, or select from list)')
|
|
8
16
|
.option('-y, --yes', 'Skip confirmation prompt')
|
|
9
17
|
.option('--json', 'Output as JSON')
|
|
18
|
+
.option('--no-tunnel', 'Connect directly to host:port instead of via an SSH-CA tunnel')
|
|
10
19
|
.action(async (hostPort, options) => {
|
|
11
20
|
const resolved = await resolveHostPort(hostPort);
|
|
12
21
|
if (!resolved) {
|
|
13
22
|
process.exit(1);
|
|
14
23
|
}
|
|
15
24
|
const { host, port } = resolved;
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
let versionInfo;
|
|
25
|
+
// All HTTP calls (version check → trigger → wait-for-restart) share ONE
|
|
26
|
+
// SSH-CA tunnel so the agent's loopback-only :9100 is reachable throughout.
|
|
19
27
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
await withAgentConnection(host, port, { tunnel: options.tunnel !== false }, async (h, p) => {
|
|
29
|
+
// First check what version is available.
|
|
30
|
+
const checkSpinner = output.spinner(`Checking agent version at ${host}:${port}...`).start();
|
|
31
|
+
let versionInfo;
|
|
32
|
+
try {
|
|
33
|
+
versionInfo = await fetchAgentVersion(h, p);
|
|
34
|
+
checkSpinner.stop();
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
checkSpinner.fail(`Failed to check agent version at ${host}:${port}`);
|
|
38
|
+
output.error(err instanceof Error ? err.message : String(err));
|
|
39
|
+
// Already reported — unwind so the tunnel tears down, then exit.
|
|
40
|
+
throw new AlreadyReportedError();
|
|
41
|
+
}
|
|
42
|
+
if (!versionInfo.updateAvailable) {
|
|
43
|
+
if (options.json) {
|
|
44
|
+
output.json({ updated: false, message: 'Agent is already at latest version', current: versionInfo.current });
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log(`\x1b[32m✓\x1b[0m Agent is already at latest version (v${versionInfo.current})`);
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!versionInfo.autoUpdateEnabled) {
|
|
52
|
+
if (options.json) {
|
|
53
|
+
output.json({ updated: false, message: 'Auto-update is disabled on this agent', current: versionInfo.current });
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.log(`\x1b[33m⚠\x1b[0m Auto-update is disabled on this agent`);
|
|
57
|
+
console.log(' Enable with AUTO_UPDATE=true environment variable');
|
|
58
|
+
}
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Show what will be updated.
|
|
62
|
+
if (!options.json) {
|
|
63
|
+
console.log();
|
|
64
|
+
console.log('Agent update:');
|
|
65
|
+
console.log(` ${versionInfo.current} → \x1b[32m${versionInfo.latest}\x1b[0m`);
|
|
66
|
+
console.log();
|
|
67
|
+
}
|
|
68
|
+
// Confirm.
|
|
69
|
+
if (!options.yes && !options.json) {
|
|
70
|
+
const confirmed = await confirmAction('Proceed with update? Agent will restart.');
|
|
71
|
+
if (!confirmed) {
|
|
72
|
+
console.log('Cancelled');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Trigger update.
|
|
77
|
+
const updateSpinner = output.spinner('Updating agent...').start();
|
|
78
|
+
try {
|
|
79
|
+
const response = await triggerAgentUpdate(h, p);
|
|
80
|
+
updateSpinner.stop();
|
|
81
|
+
if (options.json) {
|
|
82
|
+
output.json(response);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!response.success) {
|
|
86
|
+
console.log(`\x1b[31m✗\x1b[0m Update failed: ${response.message}`);
|
|
87
|
+
throw new AlreadyReportedError();
|
|
88
|
+
}
|
|
89
|
+
console.log(`\x1b[32m✓\x1b[0m ${response.message}`);
|
|
90
|
+
console.log(` ${response.previousVersion} → ${response.newVersion}`);
|
|
91
|
+
if (response.willRestart) {
|
|
92
|
+
console.log();
|
|
93
|
+
// Poll the agent through the same connection until it answers again.
|
|
94
|
+
await waitForAgentRestart(h, p);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
if (err instanceof AlreadyReportedError)
|
|
99
|
+
throw err;
|
|
100
|
+
updateSpinner.fail('Failed to update agent');
|
|
101
|
+
output.error(err instanceof Error ? err.message : String(err));
|
|
102
|
+
throw new AlreadyReportedError();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
22
105
|
}
|
|
23
106
|
catch (err) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!versionInfo.updateAvailable) {
|
|
29
|
-
if (options.json) {
|
|
30
|
-
output.json({ updated: false, message: 'Agent is already at latest version', current: versionInfo.current });
|
|
107
|
+
// AlreadyReportedError: message printed inside the callback; just exit
|
|
108
|
+
// (the tunnel has been torn down by withAgentConnection's finally).
|
|
109
|
+
if (!(err instanceof AlreadyReportedError)) {
|
|
110
|
+
output.error(err instanceof Error ? err.message : String(err));
|
|
31
111
|
}
|
|
32
|
-
else {
|
|
33
|
-
console.log(`\x1b[32m✓\x1b[0m Agent is already at latest version (v${versionInfo.current})`);
|
|
34
|
-
}
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (!versionInfo.autoUpdateEnabled) {
|
|
38
|
-
if (options.json) {
|
|
39
|
-
output.json({ updated: false, message: 'Auto-update is disabled on this agent', current: versionInfo.current });
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
console.log(`\x1b[33m⚠\x1b[0m Auto-update is disabled on this agent`);
|
|
43
|
-
console.log(' Enable with AUTO_UPDATE=true environment variable');
|
|
44
|
-
}
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
// Show what will be updated
|
|
48
|
-
if (!options.json) {
|
|
49
|
-
console.log();
|
|
50
|
-
console.log('Agent update:');
|
|
51
|
-
console.log(` ${versionInfo.current} → \x1b[32m${versionInfo.latest}\x1b[0m`);
|
|
52
|
-
console.log();
|
|
53
|
-
}
|
|
54
|
-
// Confirm
|
|
55
|
-
if (!options.yes && !options.json) {
|
|
56
|
-
const confirmed = await confirmAction('Proceed with update? Agent will restart.');
|
|
57
|
-
if (!confirmed) {
|
|
58
|
-
console.log('Cancelled');
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Trigger update
|
|
63
|
-
const updateSpinner = output.spinner('Updating agent...').start();
|
|
64
|
-
try {
|
|
65
|
-
const response = await triggerAgentUpdate(host, port);
|
|
66
|
-
updateSpinner.stop();
|
|
67
|
-
if (options.json) {
|
|
68
|
-
output.json(response);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (!response.success) {
|
|
72
|
-
console.log(`\x1b[31m✗\x1b[0m Update failed: ${response.message}`);
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
console.log(`\x1b[32m✓\x1b[0m ${response.message}`);
|
|
76
|
-
console.log(` ${response.previousVersion} → ${response.newVersion}`);
|
|
77
|
-
if (response.willRestart) {
|
|
78
|
-
console.log();
|
|
79
|
-
await waitForAgentRestart(host, port);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch (err) {
|
|
83
|
-
updateSpinner.fail('Failed to update agent');
|
|
84
|
-
output.error(err instanceof Error ? err.message : String(err));
|
|
85
112
|
process.exit(1);
|
|
86
113
|
}
|
|
87
114
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAQ5C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GACpB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/agent/direct/update.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAQ5C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,oBAAqB,SAAQ,KAAK;CAAG;AAE3C,MAAM,UAAU,qBAAqB,CAAC,SAAkB;IACtD,SAAS;SACN,OAAO,CAAC,mBAAmB,CAAC;SAC5B,WAAW,CAAC,4EAA4E,CAAC;SACzF,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC;SAC/C,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,MAAM,IAAI,oBAAoB,EAAE,CAAC;gBACnC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,uEAAuE;YACvE,oEAAoE;YACpE,IAAI,CAAC,CAAC,GAAG,YAAY,oBAAoB,CAAC,EAAE,CAAC;gBAC3C,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACjE,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/version.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../src/commands/agent/direct/version.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CA8C/D"}
|