agentosity 0.3.1 → 0.3.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +11 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentosity",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Agentosity — AI-native is a number now. Automatic attendance for your AI agents (stdio MCP lifecycle + activity probes) + human clock-out CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -47,8 +47,9 @@ async function init(companyArg) {
47
47
 
48
48
  // 1. 登录(没有就当场走浏览器授权)
49
49
  let cfg = loadConfig();
50
+ let didBrowserLogin = false;
50
51
  if (!cfg.accessToken) {
51
- await browserLogin(); // 失败会自行退出
52
+ didBrowserLogin = (await browserLogin()) === true; // 失败会自行退出
52
53
  cfg = loadConfig();
53
54
  } else {
54
55
  console.log(`✓ 已登录 ${cfg.email ?? ""}`);
@@ -76,8 +77,13 @@ async function init(companyArg) {
76
77
  }
77
78
  if (!prof?.company) {
78
79
  const url = `${apiBase()}/checkin?from=cli`;
79
- console.log(`在网页上选择你的公司…\n打不开就手动访问:${url}`);
80
- await openBrowser(url);
80
+ if (didBrowserLogin) {
81
+ // 登录页会自动跳到绑定页,别再开第二个标签页戳用户
82
+ console.log(`在刚才的浏览器页面里选择你的公司…\n没看到就手动访问:${url}`);
83
+ } else {
84
+ console.log(`在网页上选择你的公司…\n打不开就手动访问:${url}`);
85
+ await openBrowser(url);
86
+ }
81
87
  for (let i = 0; i < 150 && !prof?.company; i++) {
82
88
  await new Promise((r) => setTimeout(r, 2000));
83
89
  const p = await get(`/api/profile?device=${cfg.deviceId ?? ""}`);
@@ -145,7 +151,7 @@ async function browserLogin() {
145
151
  console.error("无法发起登录(网络不可达)");
146
152
  process.exit(1);
147
153
  }
148
- const url = `${apiBase()}/login?device=${start.code}`;
154
+ const url = `${apiBase()}/login?device=${start.code}&from=cli`;
149
155
  console.log(`在浏览器里完成登录…\n打不开就手动访问:${url}`);
150
156
  await openBrowser(url);
151
157
  for (let i = 0; i < 150; i++) {
@@ -155,7 +161,7 @@ async function browserLogin() {
155
161
  saveConfig({ email: poll.email, accessToken: poll.access_token, refreshToken: poll.refresh_token });
156
162
  await post("/api/auth/merge", { deviceId: cfg.deviceId }); // 设备历史并入账号
157
163
  console.log(`✅ 已登录 ${poll.email}`);
158
- return;
164
+ return true; // 浏览器登录刚发生:登录页会自己跳到绑定页,init 不必再开新标签
159
165
  }
160
166
  if (poll?.expired) {
161
167
  console.error("登录超时,再跑一次 npx agentosity login");