alink-cli 0.10.2 → 0.11.0
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/README.md +16 -44
- package/bin/agentlink-account.js +25 -0
- package/bin/agentlink.js +65 -9
- package/dist/bin.mjs +3 -2
- package/dist/bin.mjs.map +1 -1
- package/dist/ui.js +49 -82
- package/package.json +2 -2
package/dist/ui.js
CHANGED
|
@@ -1378,7 +1378,7 @@ var require_react_development = __commonJS({
|
|
|
1378
1378
|
var dispatcher = resolveDispatcher();
|
|
1379
1379
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1380
1380
|
}
|
|
1381
|
-
function
|
|
1381
|
+
function useRef2(initialValue) {
|
|
1382
1382
|
var dispatcher = resolveDispatcher();
|
|
1383
1383
|
return dispatcher.useRef(initialValue);
|
|
1384
1384
|
}
|
|
@@ -2172,7 +2172,7 @@ var require_react_development = __commonJS({
|
|
|
2172
2172
|
exports.useLayoutEffect = useLayoutEffect2;
|
|
2173
2173
|
exports.useMemo = useMemo4;
|
|
2174
2174
|
exports.useReducer = useReducer;
|
|
2175
|
-
exports.useRef =
|
|
2175
|
+
exports.useRef = useRef2;
|
|
2176
2176
|
exports.useState = useState3;
|
|
2177
2177
|
exports.useSyncExternalStore = useSyncExternalStore;
|
|
2178
2178
|
exports.useTransition = useTransition;
|
|
@@ -27090,7 +27090,7 @@ var require_backend = __commonJS({
|
|
|
27090
27090
|
return [initialArg, function() {
|
|
27091
27091
|
}];
|
|
27092
27092
|
},
|
|
27093
|
-
useRef: function
|
|
27093
|
+
useRef: function useRef2(initialValue) {
|
|
27094
27094
|
var hook = nextHook();
|
|
27095
27095
|
initialValue = null !== hook ? hook.memoizedState : {
|
|
27096
27096
|
current: initialValue
|
|
@@ -48305,8 +48305,8 @@ async function stopDaemon(timeoutMs = 1e4) {
|
|
|
48305
48305
|
}
|
|
48306
48306
|
rmSync(PID_FILE, { force: true });
|
|
48307
48307
|
}
|
|
48308
|
-
function restartDaemon(options) {
|
|
48309
|
-
stopDaemon();
|
|
48308
|
+
async function restartDaemon(options) {
|
|
48309
|
+
await stopDaemon();
|
|
48310
48310
|
return startDaemon(options);
|
|
48311
48311
|
}
|
|
48312
48312
|
function defaultMachineName() {
|
|
@@ -48356,6 +48356,19 @@ function quit(exit) {
|
|
|
48356
48356
|
exit();
|
|
48357
48357
|
process.exit(0);
|
|
48358
48358
|
}
|
|
48359
|
+
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
48360
|
+
function Loading({ label }) {
|
|
48361
|
+
const [frame, setFrame] = (0, import_react22.useState)(0);
|
|
48362
|
+
(0, import_react22.useEffect)(() => {
|
|
48363
|
+
const id = setInterval(() => setFrame((current) => current + 1), 80);
|
|
48364
|
+
return () => clearInterval(id);
|
|
48365
|
+
}, []);
|
|
48366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: "cyan", children: [
|
|
48367
|
+
SPINNER_FRAMES[frame % SPINNER_FRAMES.length],
|
|
48368
|
+
" ",
|
|
48369
|
+
label
|
|
48370
|
+
] });
|
|
48371
|
+
}
|
|
48359
48372
|
function StatusBar({ running, status }) {
|
|
48360
48373
|
const hub = status?.hub || loadConfig().hub;
|
|
48361
48374
|
const loggedIn = isLoggedIn(hub);
|
|
@@ -48538,6 +48551,7 @@ function App2() {
|
|
|
48538
48551
|
const [config, setConfig] = (0, import_react22.useState)(loadConfig());
|
|
48539
48552
|
const [inputValue, setInputValue] = (0, import_react22.useState)("");
|
|
48540
48553
|
const [settingsField, setSettingsField] = (0, import_react22.useState)(null);
|
|
48554
|
+
const [reconnecting, setReconnecting] = (0, import_react22.useState)(false);
|
|
48541
48555
|
const [authTick, setAuthTick] = (0, import_react22.useState)(0);
|
|
48542
48556
|
(0, import_react22.useEffect)(() => {
|
|
48543
48557
|
const id = setInterval(() => {
|
|
@@ -48554,7 +48568,7 @@ function App2() {
|
|
|
48554
48568
|
items.push({ label: "\u542F\u52A8 daemon", value: "start" });
|
|
48555
48569
|
} else {
|
|
48556
48570
|
items.push({ label: "\u505C\u6B62 daemon", value: "stop" });
|
|
48557
|
-
items.push({ label: "\u91CD\
|
|
48571
|
+
items.push({ label: "\u91CD\u65B0\u8FDE\u63A5 AgentLink", value: "restart" });
|
|
48558
48572
|
}
|
|
48559
48573
|
items.push({ label: "\u67E5\u770B\u72B6\u6001\u8BE6\u60C5", value: "status" });
|
|
48560
48574
|
items.push({ label: loggedIn ? "\u9000\u51FA\u8D26\u53F7" : "\u767B\u5F55\u8D26\u53F7", value: loggedIn ? "logout" : "login" });
|
|
@@ -48570,7 +48584,7 @@ function App2() {
|
|
|
48570
48584
|
if (selectedIndex >= menuItems.length) setSelectedIndex(0);
|
|
48571
48585
|
}, [menuItems, selectedIndex]);
|
|
48572
48586
|
use_input_default((input, key) => {
|
|
48573
|
-
if (view !== "menu") return;
|
|
48587
|
+
if (view !== "menu" || reconnecting) return;
|
|
48574
48588
|
if (key.upArrow || input === "k") {
|
|
48575
48589
|
let next = selectedIndex;
|
|
48576
48590
|
do {
|
|
@@ -48672,7 +48686,7 @@ function App2() {
|
|
|
48672
48686
|
}
|
|
48673
48687
|
}
|
|
48674
48688
|
}
|
|
48675
|
-
function handleConfirm() {
|
|
48689
|
+
async function handleConfirm() {
|
|
48676
48690
|
if (!confirmAction) return;
|
|
48677
48691
|
const cfg = loadConfig();
|
|
48678
48692
|
if (confirmAction.type === "stop") {
|
|
@@ -48688,18 +48702,23 @@ function App2() {
|
|
|
48688
48702
|
setConfirmAction(null);
|
|
48689
48703
|
return;
|
|
48690
48704
|
}
|
|
48705
|
+
setView("menu");
|
|
48706
|
+
setConfirmAction(null);
|
|
48707
|
+
setReconnecting(true);
|
|
48691
48708
|
try {
|
|
48692
|
-
const pid = restartDaemon({
|
|
48709
|
+
const pid = await restartDaemon({
|
|
48693
48710
|
hub: cfg.hub,
|
|
48694
48711
|
credential,
|
|
48695
48712
|
cwd: cfg.dir,
|
|
48696
48713
|
approval: cfg.approval,
|
|
48697
48714
|
approvalRenotifyMin: cfg.approvalRenotifyMin
|
|
48698
48715
|
});
|
|
48699
|
-
setNotice(`
|
|
48716
|
+
setNotice(`AgentLink \u5DF2\u5F00\u59CB\u91CD\u65B0\u8FDE\u63A5 (PID ${pid})`);
|
|
48700
48717
|
setRunning(true);
|
|
48701
48718
|
} catch (err) {
|
|
48702
|
-
setNotice(`\u91CD\
|
|
48719
|
+
setNotice(`\u91CD\u65B0\u8FDE\u63A5\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
48720
|
+
} finally {
|
|
48721
|
+
setReconnecting(false);
|
|
48703
48722
|
}
|
|
48704
48723
|
} else if (confirmAction.type === "logout") {
|
|
48705
48724
|
stopDaemon().catch(() => void 0);
|
|
@@ -48719,7 +48738,7 @@ function App2() {
|
|
|
48719
48738
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48720
48739
|
ConfirmDialog,
|
|
48721
48740
|
{
|
|
48722
|
-
title: confirmAction?.type === "stop" ? "\u786E\u5B9A\u8981\u505C\u6B62 daemon \u5417\uFF1F" : confirmAction?.type === "restart" ? "\u786E\u5B9A\u8981\u91CD\
|
|
48741
|
+
title: confirmAction?.type === "stop" ? "\u786E\u5B9A\u8981\u505C\u6B62 daemon \u5417\uFF1F" : confirmAction?.type === "restart" ? "\u786E\u5B9A\u8981\u91CD\u65B0\u8FDE\u63A5 AgentLink \u5417\uFF1F" : "\u786E\u5B9A\u8981\u9000\u51FA\u8D26\u53F7\u5417\uFF1F\u9000\u51FA\u540E\u4F1A\u505C\u6B62 daemon\u3002",
|
|
48723
48742
|
onConfirm: handleConfirm,
|
|
48724
48743
|
onCancel: () => {
|
|
48725
48744
|
setView("menu");
|
|
@@ -48770,6 +48789,7 @@ function App2() {
|
|
|
48770
48789
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MachinesView, { onDone: () => setView("menu") });
|
|
48771
48790
|
case "menu":
|
|
48772
48791
|
default:
|
|
48792
|
+
if (reconnecting) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, { label: "\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5 AgentLink..." });
|
|
48773
48793
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexDirection: "column", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Menu, { items: menuItems, selectedIndex }) });
|
|
48774
48794
|
}
|
|
48775
48795
|
}
|
|
@@ -48900,86 +48920,33 @@ function LoginView({
|
|
|
48900
48920
|
onCancel,
|
|
48901
48921
|
setNotice
|
|
48902
48922
|
}) {
|
|
48903
|
-
const [stage, setStage] = (0, import_react22.useState)("identifier");
|
|
48904
|
-
const [identifier, setIdentifier] = (0, import_react22.useState)("");
|
|
48905
|
-
const [inputVal, setInputVal] = (0, import_react22.useState)("");
|
|
48906
48923
|
const [error, setError] = (0, import_react22.useState)("");
|
|
48924
|
+
const started = (0, import_react22.useRef)(false);
|
|
48925
|
+
(0, import_react22.useEffect)(() => {
|
|
48926
|
+
if (started.current) return;
|
|
48927
|
+
started.current = true;
|
|
48928
|
+
void runDetachedScript(["login", "--hub", hub]).then((code) => {
|
|
48929
|
+
if (code === 0) {
|
|
48930
|
+
setNotice("\u767B\u5F55\u6210\u529F\uFF0C\u8FD9\u53F0\u7535\u8111\u5DF2\u52A0\u5165\u8D26\u53F7\u3002");
|
|
48931
|
+
onDone();
|
|
48932
|
+
} else {
|
|
48933
|
+
setError(`\u767B\u5F55\u6D41\u7A0B\u5F02\u5E38\u7ED3\u675F\uFF08\u9000\u51FA\u7801 ${code}\uFF09\u3002`);
|
|
48934
|
+
}
|
|
48935
|
+
});
|
|
48936
|
+
}, [hub]);
|
|
48907
48937
|
use_input_default((input, key) => {
|
|
48908
|
-
if (
|
|
48909
|
-
if (key.return) {
|
|
48910
|
-
setError("");
|
|
48911
|
-
setInputVal("");
|
|
48912
|
-
setStage("password");
|
|
48913
|
-
} else if (key.escape || key.ctrl && input === "c") {
|
|
48914
|
-
onCancel();
|
|
48915
|
-
}
|
|
48938
|
+
if (error && (key.escape || key.ctrl && input === "c")) onCancel();
|
|
48916
48939
|
});
|
|
48917
|
-
|
|
48918
|
-
setStage("submitting");
|
|
48919
|
-
try {
|
|
48920
|
-
const { hostname: hostname2 } = await import("node:os");
|
|
48921
|
-
const account = await import(new URL("../bin/agentlink-account.js", import.meta.url).href);
|
|
48922
|
-
const config = await account.loadAgentLinkAccountConfig(hub);
|
|
48923
|
-
const result = await account.registerAgentLinkAccountMachine({
|
|
48924
|
-
hub,
|
|
48925
|
-
config,
|
|
48926
|
-
identifier: id,
|
|
48927
|
-
password: pw,
|
|
48928
|
-
machineName: hostname2()
|
|
48929
|
-
});
|
|
48930
|
-
saveCredential(result.credential, hub);
|
|
48931
|
-
if (result.jwt) saveSessionJwt(result.jwt, hub);
|
|
48932
|
-
setNotice("\u767B\u5F55\u6210\u529F\uFF0C\u8FD9\u53F0\u7535\u8111\u5DF2\u52A0\u5165\u8D26\u53F7\u3002");
|
|
48933
|
-
onDone();
|
|
48934
|
-
} catch (err) {
|
|
48935
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
48936
|
-
setStage("error");
|
|
48937
|
-
}
|
|
48938
|
-
}
|
|
48939
|
-
if (stage === "submitting") {
|
|
48940
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "cyan", children: "\u23F3 \u6B63\u5728\u767B\u5F55\u5E76\u6CE8\u518C\u8FD9\u53F0\u673A\u5668..." });
|
|
48941
|
-
}
|
|
48942
|
-
if (stage === "error") {
|
|
48940
|
+
if (error) {
|
|
48943
48941
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { flexDirection: "column", borderStyle: "round", borderColor: "red", paddingX: 1, children: [
|
|
48944
48942
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: "redBright", children: [
|
|
48945
48943
|
"\u2716 \u767B\u5F55\u5931\u8D25\uFF1A",
|
|
48946
48944
|
error
|
|
48947
48945
|
] }),
|
|
48948
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "gray", children: "
|
|
48946
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "gray", children: "Esc \u8FD4\u56DE\u83DC\u5355" })
|
|
48949
48947
|
] });
|
|
48950
48948
|
}
|
|
48951
|
-
|
|
48952
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48953
|
-
SimpleInput,
|
|
48954
|
-
{
|
|
48955
|
-
label: "\u5BC6\u7801\uFF1A",
|
|
48956
|
-
value: inputVal,
|
|
48957
|
-
mask: true,
|
|
48958
|
-
onChange: setInputVal,
|
|
48959
|
-
onSubmit: () => {
|
|
48960
|
-
const pw = inputVal;
|
|
48961
|
-
setInputVal("");
|
|
48962
|
-
void submit(identifier, pw);
|
|
48963
|
-
},
|
|
48964
|
-
onCancel
|
|
48965
|
-
}
|
|
48966
|
-
);
|
|
48967
|
-
}
|
|
48968
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48969
|
-
SimpleInput,
|
|
48970
|
-
{
|
|
48971
|
-
label: "\u8D26\u53F7\uFF08\u7528\u6237\u540D\u6216\u90AE\u7BB1\uFF09\uFF1A",
|
|
48972
|
-
value: inputVal,
|
|
48973
|
-
onChange: setInputVal,
|
|
48974
|
-
onSubmit: () => {
|
|
48975
|
-
if (!inputVal.trim()) return;
|
|
48976
|
-
setIdentifier(inputVal.trim());
|
|
48977
|
-
setInputVal("");
|
|
48978
|
-
setStage("password");
|
|
48979
|
-
},
|
|
48980
|
-
onCancel
|
|
48981
|
-
}
|
|
48982
|
-
);
|
|
48949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "cyan", children: "\u23F3 \u8BF7\u5728\u6D4F\u89C8\u5668\u5B8C\u6210 GitHub \u767B\u5F55..." });
|
|
48983
48950
|
}
|
|
48984
48951
|
function saveSessionJwt(jwt, hub) {
|
|
48985
48952
|
const sessionFile = join2(STATE_DIR, "session");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alink-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "一条命令把工作机接入 AgentLink,随时随地遥控本机的编码 agent。One command to link your machine to AgentLink and control your coding agents from anywhere.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acp",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"coding-agent",
|
|
12
12
|
"remote-control"
|
|
13
13
|
],
|
|
14
|
-
"homepage": "https://
|
|
14
|
+
"homepage": "https://link.harmopath.com/marketing",
|
|
15
15
|
"bugs": "https://github.com/baichen99/agentlink/issues",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"repository": {
|