@kortix/agent-tunnel 0.12.7 → 0.13.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/agent-cli.js +1191 -887
- package/package.json +1 -1
- package/src/agent/agent.ts +53 -29
- package/src/agent/banner.ts +82 -0
- package/src/agent/cli-help.test.ts +79 -15
- package/src/agent/cli-reauth.test.ts +205 -0
- package/src/agent/cli.ts +399 -661
- package/src/agent/config.ts +19 -0
- package/src/agent/credential-probe.ts +95 -0
- package/src/agent/credential-store.ts +74 -0
- package/src/agent/device-auth.test.ts +132 -0
- package/src/agent/device-auth.ts +213 -0
- package/src/agent/log-format.ts +24 -0
- package/src/agent/prompts.ts +37 -0
- package/src/agent/service-control.ts +69 -0
- package/src/agent/service-drivers.ts +299 -0
- package/src/agent/service-lifecycle.test.ts +248 -0
- package/src/agent/service-paths.ts +80 -0
- package/src/agent/service-quoting.ts +16 -0
- package/src/agent/service.test.ts +52 -2
- package/src/agent/service.ts +132 -356
- package/src/agent/terminal.ts +53 -0
- package/src/agent/version.ts +52 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const PACKAGE_NAME = '@kortix/agent-tunnel';
|
|
6
|
+
const MAX_LOOKUP_DEPTH = 8;
|
|
7
|
+
|
|
8
|
+
let cached: string | null = null;
|
|
9
|
+
|
|
10
|
+
function moduleDirectory(): string {
|
|
11
|
+
try {
|
|
12
|
+
return dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
} catch {
|
|
14
|
+
return process.cwd();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Reads the shipped version out of package.json at runtime.
|
|
20
|
+
*
|
|
21
|
+
* It cannot be a build-time constant: scripts/publish-npm-package.sh builds the
|
|
22
|
+
* bundle before scripts/stage-npm-publish.mjs stamps the release version into
|
|
23
|
+
* package.json, so anything baked at build time captures the inert repo value.
|
|
24
|
+
* The checked-in `version` field is deliberately not maintained by hand, the
|
|
25
|
+
* same convention @kortix/sdk follows.
|
|
26
|
+
*
|
|
27
|
+
* Walks up from this module so it resolves in both layouts: `dist/agent-cli.js`
|
|
28
|
+
* next to package.json when installed, and `src/agent/version.ts` in the repo.
|
|
29
|
+
*/
|
|
30
|
+
export function agentTunnelVersion(): string {
|
|
31
|
+
if (cached !== null) return cached;
|
|
32
|
+
|
|
33
|
+
let directory = moduleDirectory();
|
|
34
|
+
for (let depth = 0; depth < MAX_LOOKUP_DEPTH; depth++) {
|
|
35
|
+
try {
|
|
36
|
+
const manifest = JSON.parse(readFileSync(join(directory, 'package.json'), 'utf8'));
|
|
37
|
+
if (manifest?.name === PACKAGE_NAME && typeof manifest.version === 'string') {
|
|
38
|
+
const version: string = manifest.version;
|
|
39
|
+
cached = version;
|
|
40
|
+
return version;
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
// Keep walking: this directory has no readable manifest.
|
|
44
|
+
}
|
|
45
|
+
const parent = dirname(directory);
|
|
46
|
+
if (parent === directory) break;
|
|
47
|
+
directory = parent;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
cached = 'unknown';
|
|
51
|
+
return cached;
|
|
52
|
+
}
|