agentosity 0.2.0 → 0.2.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/package.json +3 -3
- package/src/index.js +42 -8
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentosity",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Agentosity
|
|
3
|
+
"version": "0.2.1",
|
|
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
|
@@ -25,10 +25,10 @@ export async function main(argv) {
|
|
|
25
25
|
default:
|
|
26
26
|
console.log(`agentosity — AI-native is a number now.
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
npx agentosity login
|
|
30
|
-
npx agentosity
|
|
31
|
-
|
|
28
|
+
两步开始:
|
|
29
|
+
npx agentosity login # 1. 弹浏览器登录
|
|
30
|
+
npx agentosity init "<公司名>" # 2. 绑定公司 + 自动接入所有 harness
|
|
31
|
+
(无浏览器环境:login <邮箱> 收验证码,再 login <邮箱> <验证码>)
|
|
32
32
|
|
|
33
33
|
其他:
|
|
34
34
|
npx agentosity radar 进程雷达:补录本机未接入 MCP 的 Agent 会话(常驻)
|
|
@@ -77,10 +77,8 @@ async function init(company) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
async function login(email, code) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
80
|
+
// 不带参数:浏览器登录(像 npm login / gh auth login 一样)
|
|
81
|
+
if (!email) return browserLogin();
|
|
84
82
|
if (!code) {
|
|
85
83
|
const r = await post("/api/auth/send", { email });
|
|
86
84
|
if (r?.ok) console.log(`✅ 验证码已发到 ${email},收到后跑:npx agentosity login ${email} <验证码>`);
|
|
@@ -101,6 +99,42 @@ async function login(email, code) {
|
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
101
|
|
|
102
|
+
async function browserLogin() {
|
|
103
|
+
const cfg = saveConfig({}); // 确保 deviceId 存在
|
|
104
|
+
const start = await post("/api/device/start", {});
|
|
105
|
+
if (!start?.code) {
|
|
106
|
+
console.error("无法发起登录(网络不可达)");
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
const url = `${apiBase()}/login?device=${start.code}`;
|
|
110
|
+
console.log(`在浏览器里完成登录…\n打不开就手动访问:${url}`);
|
|
111
|
+
try {
|
|
112
|
+
const { spawn } = await import("node:child_process");
|
|
113
|
+
const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
114
|
+
const child = spawn(opener, [url], { stdio: "ignore", detached: true, shell: process.platform === "win32" });
|
|
115
|
+
child.on("error", () => {});
|
|
116
|
+
child.unref();
|
|
117
|
+
} catch {
|
|
118
|
+
/* 打不开浏览器就靠上面打印的 URL */
|
|
119
|
+
}
|
|
120
|
+
for (let i = 0; i < 150; i++) {
|
|
121
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
122
|
+
const poll = await post(`/api/device/poll?code=${start.code}`, undefined, { method: "GET" });
|
|
123
|
+
if (poll?.ok && poll.access_token) {
|
|
124
|
+
saveConfig({ email: poll.email, accessToken: poll.access_token, refreshToken: poll.refresh_token });
|
|
125
|
+
await post("/api/auth/merge", { deviceId: cfg.deviceId }); // 设备历史并入账号
|
|
126
|
+
console.log(`✅ 已登录 ${poll.email}`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (poll?.expired) {
|
|
130
|
+
console.error("登录超时,再跑一次 npx agentosity login");
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
console.error("登录超时,再跑一次 npx agentosity login");
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
|
|
104
138
|
async function clockout() {
|
|
105
139
|
const cfg = loadConfig();
|
|
106
140
|
if (!cfg.accessToken) {
|