agentosity 0.3.0 → 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.
- package/package.json +3 -3
- package/src/index.js +12 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentosity",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Agentosity
|
|
3
|
+
"version": "0.3.2",
|
|
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": {
|
|
7
7
|
"agentosity": "./bin/agentosity.js"
|
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
"directory": "packages/cli"
|
|
29
29
|
},
|
|
30
30
|
"license": "MIT"
|
|
31
|
-
}
|
|
31
|
+
}
|
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 ?? ""}`);
|
|
@@ -75,9 +76,14 @@ async function init(companyArg) {
|
|
|
75
76
|
prof = await get(`/api/profile?device=${cfg.deviceId ?? ""}`);
|
|
76
77
|
}
|
|
77
78
|
if (!prof?.company) {
|
|
78
|
-
const url = `${apiBase()}/checkin`;
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const url = `${apiBase()}/checkin?from=cli`;
|
|
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");
|