openanima 0.5.0 → 0.5.1
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/bin/index.js +45 -9
- package/package.json +1 -1
package/dist/bin/index.js
CHANGED
|
@@ -7795,7 +7795,7 @@ async function goCommand(options) {
|
|
|
7795
7795
|
|
|
7796
7796
|
// src/bin/index.ts
|
|
7797
7797
|
var program = new Command();
|
|
7798
|
-
program.name("openanima").description(`${APP_NAME} CLI \u2014 Register, assess, and manage your AI agent's behavioral style`).version("0.5.
|
|
7798
|
+
program.name("openanima").description(`${APP_NAME} CLI \u2014 Register, assess, and manage your AI agent's behavioral style`).version("0.5.1");
|
|
7799
7799
|
program.command("register").description("[deprecated] Use 'openanima go' instead").action(registerCommand);
|
|
7800
7800
|
program.command("test").description("[deprecated] Use 'openanima go' instead").action(testCommand);
|
|
7801
7801
|
program.command("profile").description("View your agent's behavioral style profile").option("--agent-id <id>", "Agent ID (uses saved config if omitted)").action(profileCommand);
|
|
@@ -7828,9 +7828,10 @@ program.command("rename").description("Change your agent's display name").argume
|
|
|
7828
7828
|
console.log(chalk5.red(" Could not connect to API."));
|
|
7829
7829
|
}
|
|
7830
7830
|
});
|
|
7831
|
-
program.command("
|
|
7832
|
-
const { readConfig: readConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
7831
|
+
program.command("login").description("Log in to the OpenAnima web dashboard").action(async () => {
|
|
7832
|
+
const { readConfig: readConfig2, writeConfig: writeConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
7833
7833
|
const chalk5 = (await import("chalk")).default;
|
|
7834
|
+
const { exec } = await import("child_process");
|
|
7834
7835
|
const config = await readConfig2();
|
|
7835
7836
|
const token = config.token ?? config.apiKey;
|
|
7836
7837
|
if (!config.agentId || !token) {
|
|
@@ -7838,23 +7839,58 @@ program.command("auth").description("Authenticate with the OpenAnima web dashboa
|
|
|
7838
7839
|
process.exit(1);
|
|
7839
7840
|
}
|
|
7840
7841
|
const apiUrl = process.env.OPENANIMA_API_URL ?? "https://api-production-843a.up.railway.app";
|
|
7842
|
+
let sessionId;
|
|
7843
|
+
let authorizeUrl;
|
|
7841
7844
|
try {
|
|
7842
|
-
const res = await fetch(`${apiUrl}/auth/
|
|
7845
|
+
const res = await fetch(`${apiUrl}/auth/session`, {
|
|
7843
7846
|
method: "POST",
|
|
7844
7847
|
headers: { "Content-Type": "application/json" },
|
|
7845
|
-
body: JSON.stringify({
|
|
7848
|
+
body: JSON.stringify({ agentToken: token })
|
|
7846
7849
|
});
|
|
7847
7850
|
const data = await res.json();
|
|
7848
|
-
if (data.
|
|
7849
|
-
console.log(chalk5.
|
|
7850
|
-
} else {
|
|
7851
|
-
console.log(chalk5.red(` ${data.error ?? "Authentication failed"}`));
|
|
7851
|
+
if (!res.ok || !data.sessionId || !data.authorizeUrl) {
|
|
7852
|
+
console.log(chalk5.red(` ${data.error ?? "Failed to create login session"}`));
|
|
7852
7853
|
process.exit(1);
|
|
7853
7854
|
}
|
|
7855
|
+
sessionId = data.sessionId;
|
|
7856
|
+
authorizeUrl = data.authorizeUrl;
|
|
7854
7857
|
} catch {
|
|
7855
7858
|
console.log(chalk5.red(" Could not connect to API."));
|
|
7856
7859
|
process.exit(1);
|
|
7860
|
+
return;
|
|
7857
7861
|
}
|
|
7862
|
+
console.log(chalk5.dim(" Opening browser for authorization..."));
|
|
7863
|
+
const openCmd = process.platform === "darwin" ? `open "${authorizeUrl}"` : process.platform === "win32" ? `start "${authorizeUrl}"` : `xdg-open "${authorizeUrl}"`;
|
|
7864
|
+
exec(openCmd, () => {
|
|
7865
|
+
});
|
|
7866
|
+
console.log(chalk5.dim(` If browser didn't open, visit: ${authorizeUrl}`));
|
|
7867
|
+
console.log();
|
|
7868
|
+
const POLL_INTERVAL = 2e3;
|
|
7869
|
+
const TIMEOUT = 5 * 60 * 1e3;
|
|
7870
|
+
const startTime = Date.now();
|
|
7871
|
+
const poll = async () => {
|
|
7872
|
+
while (Date.now() - startTime < TIMEOUT) {
|
|
7873
|
+
await new Promise((r) => setTimeout(r, POLL_INTERVAL));
|
|
7874
|
+
try {
|
|
7875
|
+
const res = await fetch(`${apiUrl}/auth/session/${sessionId}/status`);
|
|
7876
|
+
const data = await res.json();
|
|
7877
|
+
if (data.status === "authorized" && data.sessionToken) {
|
|
7878
|
+
await writeConfig2({ sessionToken: data.sessionToken });
|
|
7879
|
+
console.log(chalk5.green(" Logged in to OpenAnima dashboard"));
|
|
7880
|
+
console.log(chalk5.dim(" Visit: https://openanima.vercel.app/dashboard"));
|
|
7881
|
+
return;
|
|
7882
|
+
}
|
|
7883
|
+
if (data.status === "expired") {
|
|
7884
|
+
console.log(chalk5.red(" Authorization expired. Run 'openanima login' again."));
|
|
7885
|
+
process.exit(1);
|
|
7886
|
+
}
|
|
7887
|
+
} catch {
|
|
7888
|
+
}
|
|
7889
|
+
}
|
|
7890
|
+
console.log(chalk5.red(" Authorization timed out. Run 'openanima login' again."));
|
|
7891
|
+
process.exit(1);
|
|
7892
|
+
};
|
|
7893
|
+
await poll();
|
|
7858
7894
|
});
|
|
7859
7895
|
program.command("bind-email").description("Bind an email address to your agent account").argument("<email>", "Email address to bind").action(async (email) => {
|
|
7860
7896
|
const { readConfig: readConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|