openanima 0.4.1 → 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 +102 -5
- 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.
|
|
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);
|
|
@@ -7804,17 +7804,18 @@ program.command("rename").description("Change your agent's display name").argume
|
|
|
7804
7804
|
const { readConfig: readConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
7805
7805
|
const { createApiClient: createApiClient2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
|
|
7806
7806
|
const chalk5 = (await import("chalk")).default;
|
|
7807
|
-
const config = readConfig2();
|
|
7808
|
-
|
|
7807
|
+
const config = await readConfig2();
|
|
7808
|
+
const agentToken = config?.token ?? config?.apiKey;
|
|
7809
|
+
if (!config?.agentId || !agentToken) {
|
|
7809
7810
|
console.log(chalk5.red(" No agent registered. Run 'openanima go' first."));
|
|
7810
7811
|
process.exit(1);
|
|
7811
7812
|
}
|
|
7812
7813
|
const api = createApiClient2();
|
|
7813
|
-
api.setToken(
|
|
7814
|
+
api.setToken(agentToken);
|
|
7814
7815
|
try {
|
|
7815
7816
|
const res = await fetch(`${api.baseUrl}/agent/${config.agentId}/name`, {
|
|
7816
7817
|
method: "PATCH",
|
|
7817
|
-
headers: { "Content-Type": "application/json", Authorization: `Bearer ${
|
|
7818
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${agentToken}` },
|
|
7818
7819
|
body: JSON.stringify({ displayName: newName.trim() })
|
|
7819
7820
|
});
|
|
7820
7821
|
const data = await res.json();
|
|
@@ -7827,6 +7828,102 @@ program.command("rename").description("Change your agent's display name").argume
|
|
|
7827
7828
|
console.log(chalk5.red(" Could not connect to API."));
|
|
7828
7829
|
}
|
|
7829
7830
|
});
|
|
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
|
+
const chalk5 = (await import("chalk")).default;
|
|
7834
|
+
const { exec } = await import("child_process");
|
|
7835
|
+
const config = await readConfig2();
|
|
7836
|
+
const token = config.token ?? config.apiKey;
|
|
7837
|
+
if (!config.agentId || !token) {
|
|
7838
|
+
console.log(chalk5.red(" No agent registered. Run 'openanima go' first."));
|
|
7839
|
+
process.exit(1);
|
|
7840
|
+
}
|
|
7841
|
+
const apiUrl = process.env.OPENANIMA_API_URL ?? "https://api-production-843a.up.railway.app";
|
|
7842
|
+
let sessionId;
|
|
7843
|
+
let authorizeUrl;
|
|
7844
|
+
try {
|
|
7845
|
+
const res = await fetch(`${apiUrl}/auth/session`, {
|
|
7846
|
+
method: "POST",
|
|
7847
|
+
headers: { "Content-Type": "application/json" },
|
|
7848
|
+
body: JSON.stringify({ agentToken: token })
|
|
7849
|
+
});
|
|
7850
|
+
const data = await res.json();
|
|
7851
|
+
if (!res.ok || !data.sessionId || !data.authorizeUrl) {
|
|
7852
|
+
console.log(chalk5.red(` ${data.error ?? "Failed to create login session"}`));
|
|
7853
|
+
process.exit(1);
|
|
7854
|
+
}
|
|
7855
|
+
sessionId = data.sessionId;
|
|
7856
|
+
authorizeUrl = data.authorizeUrl;
|
|
7857
|
+
} catch {
|
|
7858
|
+
console.log(chalk5.red(" Could not connect to API."));
|
|
7859
|
+
process.exit(1);
|
|
7860
|
+
return;
|
|
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();
|
|
7894
|
+
});
|
|
7895
|
+
program.command("bind-email").description("Bind an email address to your agent account").argument("<email>", "Email address to bind").action(async (email) => {
|
|
7896
|
+
const { readConfig: readConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
7897
|
+
const chalk5 = (await import("chalk")).default;
|
|
7898
|
+
const config = await readConfig2();
|
|
7899
|
+
const token = config.token ?? config.apiKey;
|
|
7900
|
+
if (!config.agentId || !token) {
|
|
7901
|
+
console.log(chalk5.red(" No agent registered. Run 'openanima go' first."));
|
|
7902
|
+
process.exit(1);
|
|
7903
|
+
}
|
|
7904
|
+
if (!email.includes("@")) {
|
|
7905
|
+
console.log(chalk5.red(" Please provide a valid email address."));
|
|
7906
|
+
process.exit(1);
|
|
7907
|
+
}
|
|
7908
|
+
const apiUrl = process.env.OPENANIMA_API_URL ?? "https://api-production-843a.up.railway.app";
|
|
7909
|
+
try {
|
|
7910
|
+
const res = await fetch(`${apiUrl}/auth/bind-email`, {
|
|
7911
|
+
method: "POST",
|
|
7912
|
+
headers: { "Content-Type": "application/json" },
|
|
7913
|
+
body: JSON.stringify({ email: email.trim(), agentToken: token })
|
|
7914
|
+
});
|
|
7915
|
+
const data = await res.json();
|
|
7916
|
+
if (data.bound) {
|
|
7917
|
+
console.log(chalk5.green(` Email bound: ${data.email}`));
|
|
7918
|
+
} else {
|
|
7919
|
+
console.log(chalk5.red(` ${data.error ?? "Failed to bind email"}`));
|
|
7920
|
+
process.exit(1);
|
|
7921
|
+
}
|
|
7922
|
+
} catch {
|
|
7923
|
+
console.log(chalk5.red(" Could not connect to API."));
|
|
7924
|
+
process.exit(1);
|
|
7925
|
+
}
|
|
7926
|
+
});
|
|
7830
7927
|
program.parse();
|
|
7831
7928
|
/*! Bundled license information:
|
|
7832
7929
|
|