agentosity 0.3.1 → 0.3.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +12 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentosity",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
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 ?? ""}`);
@@ -98,6 +104,7 @@ async function init(companyArg) {
98
104
 
99
105
  console.log(`
100
106
  ✅ 完成。从现在起,新开的 Agent 会话会自动考勤——模型零参与,只上报时长,不读任何内容。
107
+ ⚠️ 桌面 App(Codex App / Cursor / Windsurf 等)要完全退出重开一次才会加载配置。
101
108
  已开着的老会话不会被追踪(配置只对新会话生效),要收编它们:npx agentosity radar
102
109
 
103
110
  看榜:${apiBase()}/agents`);
@@ -145,7 +152,7 @@ async function browserLogin() {
145
152
  console.error("无法发起登录(网络不可达)");
146
153
  process.exit(1);
147
154
  }
148
- const url = `${apiBase()}/login?device=${start.code}`;
155
+ const url = `${apiBase()}/login?device=${start.code}&from=cli`;
149
156
  console.log(`在浏览器里完成登录…\n打不开就手动访问:${url}`);
150
157
  await openBrowser(url);
151
158
  for (let i = 0; i < 150; i++) {
@@ -155,7 +162,7 @@ async function browserLogin() {
155
162
  saveConfig({ email: poll.email, accessToken: poll.access_token, refreshToken: poll.refresh_token });
156
163
  await post("/api/auth/merge", { deviceId: cfg.deviceId }); // 设备历史并入账号
157
164
  console.log(`✅ 已登录 ${poll.email}`);
158
- return;
165
+ return true; // 浏览器登录刚发生:登录页会自己跳到绑定页,init 不必再开新标签
159
166
  }
160
167
  if (poll?.expired) {
161
168
  console.error("登录超时,再跑一次 npx agentosity login");