@elliotsystems/eai 0.1.0 → 0.1.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/bin/eai +6 -0
- package/lib/token-env.js +48 -0
- package/package.json +6 -6
package/bin/eai
CHANGED
|
@@ -24,6 +24,7 @@ const {
|
|
|
24
24
|
isExplicitlyConfigured,
|
|
25
25
|
resolveOpencodeBin,
|
|
26
26
|
} = require("../lib/resolve.js")
|
|
27
|
+
const { injectToken } = require("../lib/token-env.js")
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Resolve symlinks before deriving the package root.
|
|
@@ -81,6 +82,11 @@ if (process.env.ELLIOT_LAUNCHER_DEBUG) {
|
|
|
81
82
|
process.stderr.write(`eai: launching ${resolved.path} (via ${resolved.source})\n`)
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
// Make the current Elliot token available to the runtime's `elliot` provider
|
|
86
|
+
// (which reads it as ELLIOT_TOKEN). Best-effort and side-effect-free on failure;
|
|
87
|
+
// the child inherits process.env, so setting it here is enough.
|
|
88
|
+
injectToken(process.env)
|
|
89
|
+
|
|
84
90
|
// argv passes through untouched and WITHOUT a shell, so quoting, spaces and
|
|
85
91
|
// shell metacharacters in a prompt reach the runtime as the user typed them and
|
|
86
92
|
// are never re-interpreted by an intermediate shell.
|
package/lib/token-env.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Inject the Elliot access token into the environment the OpenCode runtime
|
|
5
|
+
* inherits, so its `elliot` provider (configured by `elliot-ai setup` to use
|
|
6
|
+
* `apiKey: "{env:ELLIOT_TOKEN}"`) authenticates against the LightLLM proxy.
|
|
7
|
+
*
|
|
8
|
+
* ~/.elliot/config.json is the single source of truth for the token; the CLI
|
|
9
|
+
* (`elliot-ai`) refreshes it there. We only READ it here and copy the current
|
|
10
|
+
* `jwt_token` into ELLIOT_TOKEN — no network, no writes, so this adds no latency
|
|
11
|
+
* and cannot corrupt the config.
|
|
12
|
+
*
|
|
13
|
+
* Entirely best-effort: a missing/unreadable/corrupt config, or an env that
|
|
14
|
+
* already sets ELLIOT_TOKEN, leaves things exactly as they were. The launcher's
|
|
15
|
+
* one job — spawning the runtime — must never be blocked by token wiring.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require("fs")
|
|
19
|
+
const os = require("os")
|
|
20
|
+
const path = require("path")
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {NodeJS.ProcessEnv} env the environment to mutate (defaults to process.env)
|
|
24
|
+
* @returns {boolean} true iff ELLIOT_TOKEN was set from the config file
|
|
25
|
+
*/
|
|
26
|
+
function injectToken(env) {
|
|
27
|
+
const target = env || process.env
|
|
28
|
+
|
|
29
|
+
// An explicit ELLIOT_TOKEN in the environment wins — it lets a caller point
|
|
30
|
+
// `eai` at a specific token without touching the config file.
|
|
31
|
+
if (target.ELLIOT_TOKEN) return false
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const configPath = path.join(os.homedir(), ".elliot", "config.json")
|
|
35
|
+
const raw = fs.readFileSync(configPath, "utf-8")
|
|
36
|
+
const config = JSON.parse(raw)
|
|
37
|
+
if (config && typeof config.jwt_token === "string" && config.jwt_token) {
|
|
38
|
+
target.ELLIOT_TOKEN = config.jwt_token
|
|
39
|
+
return true
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
// No config yet (setup not run), unreadable, or malformed — the runtime
|
|
43
|
+
// will simply have no elliot token, which is the pre-existing behaviour.
|
|
44
|
+
}
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = { injectToken }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliotsystems/eai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Elliot AI CLI entry point (eai) - launches the Elliot runtime with arguments forwarded verbatim.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"eai": "./bin/eai"
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"optionalDependencies": {
|
|
27
|
-
"@elliotsystems/eai-darwin-arm64": "0.1.
|
|
28
|
-
"@elliotsystems/eai-darwin-x64": "0.1.
|
|
29
|
-
"@elliotsystems/eai-linux-x64": "0.1.
|
|
30
|
-
"@elliotsystems/eai-linux-arm64": "0.1.
|
|
31
|
-
"@elliotsystems/eai-windows-x64": "0.1.
|
|
27
|
+
"@elliotsystems/eai-darwin-arm64": "0.1.2",
|
|
28
|
+
"@elliotsystems/eai-darwin-x64": "0.1.2",
|
|
29
|
+
"@elliotsystems/eai-linux-x64": "0.1.2",
|
|
30
|
+
"@elliotsystems/eai-linux-arm64": "0.1.2",
|
|
31
|
+
"@elliotsystems/eai-windows-x64": "0.1.2"
|
|
32
32
|
}
|
|
33
33
|
}
|