ignis-agent-cli 0.1.2 → 0.1.3
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 +9 -1
- package/dist/index.js +31 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,15 @@ npm install -g ignis-agent-cli
|
|
|
11
11
|
## Configure
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
ignis login --
|
|
14
|
+
ignis login --config-url <user_config_link>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Treat `config_url` as a short-lived bootstrap link. Fetch it once, save local config, and do not redistribute it.
|
|
18
|
+
|
|
19
|
+
Fallback:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
ignis login --base-url https://ignis-cli.funplus-marketing.ai --token <cli_token>
|
|
15
23
|
```
|
|
16
24
|
|
|
17
25
|
This stores config in `~/.ignis/config.json` and reuses the current working directory as the default session context.
|
package/dist/index.js
CHANGED
|
@@ -748,20 +748,29 @@ function toNonNegativeInt(value, fallbackValue) {
|
|
|
748
748
|
import { Command as Command5 } from "commander";
|
|
749
749
|
function buildLoginCommand() {
|
|
750
750
|
const command = new Command5("login");
|
|
751
|
-
command.description("Store CLI token and base URL in ~/.ignis/config.json").
|
|
751
|
+
command.description("Store CLI token and base URL in ~/.ignis/config.json").option("--base-url <url>", "Backend base URL").option("--token <token>", "CLI token").option("--config-url <url>", "Fetch a short-lived config JSON").option("--json", "Print machine-readable JSON output").action(
|
|
752
752
|
wrapCommand(async (options) => {
|
|
753
|
+
const remoteConfig = options.configUrl?.trim() ? await fetchRemoteConfig(options.configUrl.trim()) : null;
|
|
754
|
+
const resolvedBaseUrl = (options.baseUrl?.trim() || remoteConfig?.baseUrl || "").replace(/\/+$/, "");
|
|
755
|
+
const resolvedToken = options.token?.trim() || remoteConfig?.cliToken || "";
|
|
756
|
+
if (!resolvedBaseUrl || !resolvedToken) {
|
|
757
|
+
throw new Error(
|
|
758
|
+
"Missing login config. Use `ignis login --config-url ...` or pass both --base-url and --token."
|
|
759
|
+
);
|
|
760
|
+
}
|
|
753
761
|
const config = await loadConfig();
|
|
754
762
|
const nextConfig = {
|
|
755
763
|
...config,
|
|
756
|
-
baseUrl:
|
|
757
|
-
cliToken:
|
|
764
|
+
baseUrl: resolvedBaseUrl,
|
|
765
|
+
cliToken: resolvedToken
|
|
758
766
|
};
|
|
759
767
|
await saveConfig(nextConfig);
|
|
760
768
|
if (options.json) {
|
|
761
769
|
printJson({
|
|
762
770
|
ok: true,
|
|
763
771
|
config_path: getConfigPath(),
|
|
764
|
-
base_url: nextConfig.baseUrl
|
|
772
|
+
base_url: nextConfig.baseUrl,
|
|
773
|
+
source: remoteConfig ? "config_url" : "direct"
|
|
765
774
|
});
|
|
766
775
|
} else {
|
|
767
776
|
printLoginHuman(getConfigPath());
|
|
@@ -771,6 +780,23 @@ function buildLoginCommand() {
|
|
|
771
780
|
);
|
|
772
781
|
return command;
|
|
773
782
|
}
|
|
783
|
+
async function fetchRemoteConfig(configUrl) {
|
|
784
|
+
const response = await fetch(configUrl, {
|
|
785
|
+
headers: {
|
|
786
|
+
Accept: "application/json, text/plain;q=0.9, */*;q=0.8"
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
if (!response.ok) {
|
|
790
|
+
throw new Error(`Failed to fetch config URL: ${response.status} ${response.statusText}`);
|
|
791
|
+
}
|
|
792
|
+
const payload = await response.json();
|
|
793
|
+
const baseUrl = String(payload.baseUrl || payload.base_url || "").trim().replace(/\/+$/, "");
|
|
794
|
+
const cliToken = String(payload.cliToken || payload.cli_token || "").trim();
|
|
795
|
+
if (!baseUrl || !cliToken) {
|
|
796
|
+
throw new Error("Config URL response must include baseUrl/base_url and cliToken/cli_token");
|
|
797
|
+
}
|
|
798
|
+
return { baseUrl, cliToken };
|
|
799
|
+
}
|
|
774
800
|
|
|
775
801
|
// src/commands/result.ts
|
|
776
802
|
import { Command as Command6, Option as Option4 } from "commander";
|
|
@@ -946,7 +972,7 @@ function buildWaitCommand() {
|
|
|
946
972
|
|
|
947
973
|
// src/index.ts
|
|
948
974
|
var program = new Command11();
|
|
949
|
-
program.name("ignis").description("Ignis CLI for Ultra-Mai").version("0.1.
|
|
975
|
+
program.name("ignis").description("Ignis CLI for Ultra-Mai").version("0.1.2");
|
|
950
976
|
program.addCommand(buildLoginCommand());
|
|
951
977
|
program.addCommand(buildAskCommand());
|
|
952
978
|
program.addCommand(buildHistoryCommand());
|