npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lucc9527/auto-terminal

v0.3.0

Published

Temporary, permission-scoped LAN terminal sharing for Codex with one-time authorization codes

Downloads

89

Readme

Auto Terminal

用一次性授权码,让 Codex 临时操作内网 Linux 服务器。npm 包:@lucc9527/auto-terminal,全局命令:autotm

每台服务器独立授权。需要时启动,选择权限和时间;用完断开或到期,程序关闭本次监听端口。没有管理中心、常驻 Agent、开机自启或永久配对。

安装与使用

服务器和 Codex 所在设备都安装 Node.js(支持 20+,建议使用 22/24 LTS),然后执行:

npm install -g @lucc9527/auto-terminal

安装不会启动服务、配置防火墙或修改 Codex。服务端使用普通 Linux 用户运行;不允许 root 开放终端。Linux 交互终端还需要 /bin/bash/usr/bin/script/bin/ps,一般由系统的 Bash、util-linux/bsdutils、procps 提供。程序本身及证书生成全部使用 Node.js,不需要 Python、编译工具或 OpenSSL 命令。

1. 在要管理的 Linux 服务器上启动:

autotm

按向导选择内网 IP、服务器名称、只读或终端权限、授权时长、延迟生效时间、空闲超时、工作目录和可选客户端 IP 范围。多网卡时选择 Codex 设备能访问的那张网卡。程序自动生成包含地址、证书指纹和随机凭据的授权码,因此客户端不用另填 IP 或 SSH 用户名。

授权码属于秘密,复制到自己的连接终端中即可,不要发到聊天、工单或公开日志中。服务器窗口必须保持运行,按 Ctrl-C 随时结束授权。

2. 在 Codex 设备的本地终端连接:

autotm skill install
autotm client connect --name web-01

在隐藏输入提示中粘贴授权码。skill install 安装到当前用户的 Codex Skill 目录,已有不同内容会先备份。新开 Codex 会话或重新加载 Skill 列表后,可以说:

使用 auto-terminal,查看 web-01 的系统状态。

客户端目前支持 macOS/Linux。服务器上的文件读取和交互 PTY 专门面向 Linux;macOS 服务仅用于开发诊断。服务器的防火墙必须允许客户端访问所选内网端口(默认 8743);程序不会自动开放防火墙。

3. 管理多台服务器:

# 每台服务器分别运行 autotm,分别输入其授权码
autotm client connect --name web-01
autotm client connect --name db-01
autotm client servers
autotm client info --server web-01

每个操作都必须明确指定 --server,不会把一台服务器的权限扩展到其他服务器。

4. 用完关闭:

autotm client disconnect --server web-01

这会结束该服务器的本次授权、停止任务、关闭端口,并删除本地连接配置。其他服务器不受影响。

权限和时间

| 设置 | 行为 | | --- | --- | | read | 固定系统状态接口,以及指定读取目录内普通文件的末尾最多 64 KiB;不允许任意命令 | | terminal | 以启动服务的 Unix 用户身份运行 Bash 命令或交互终端;目录不是沙箱 | | 授权有效时长 | 默认 30 分钟,从设定的生效时刻开始计时,最长 24 小时 | | 延迟生效 | 默认立即生效;可提前配对和查看信息,生效前禁止任务 | | 配对等待 | 默认 5 分钟,从服务启动计时;期间无人配对则关闭 | | 空闲超时 | 默认 2 分钟,从配对后最后一次有效请求计时;延迟生效时不早于生效时刻起算 | | 单任务最长运行 | 默认 10 分钟;客户端请求可缩短,不能突破服务器限制或授权截止时间 | | 任务数量 | 最多 3 个并行任务,每次授权最多 100 个任务 |

服务器保存并执行权限和截止时间,客户端不能通过修改本地配置延长授权。计时使用单调时钟。刷新状态可续空闲时间,但不能延长绝对截止时间。

终端权限可以访问该 Unix 用户有权访问的其他目录,也可以执行该用户已有权执行的 sudo 或 Docker 等操作。需要权限收窄时,应使用专门的低权限 Linux 用户;工作目录和命令黑名单不能代替操作系统隔离。

常用命令

# 不用向导,直接创建一次 30 分钟的只读授权
autotm share --host 192.168.1.10 --mode read \
  --read-root /srv/app/logs --duration 30m --allow-client 192.168.1.25/32

# 创建终端授权
autotm share --host 192.168.1.10 --mode terminal \
  --workdir /srv/app --duration 30m --idle-timeout 2m

# 将授权码写入一个新建的 0600 文件;结束时删除,终端不显示授权码
autotm share --host 192.168.1.10 --mode read --code-out /tmp/my-private-code

# 如果已通过私有方式把授权码文件放到客户端,可直接读取该文件连接
autotm client connect --name web-01 --code-file /absolute/private-code

autotm client status --server web-01
autotm client read-file --server web-01 --path /srv/app/logs/app.log
autotm client exec --server web-01 --command 'pwd' --timeout 60s
autotm client wait --server web-01 --task TASK_UUID --seconds 30
autotm client task --server web-01 --task TASK_UUID --offset 0

# 需要 shell 状态时使用交互终端
autotm client terminal --server web-01 --cwd /srv/app --timeout 10m
autotm client input --server web-01 --task TASK_UUID --text 'pwd
'
autotm client stop --server web-01 --task TASK_UUID

autotm --help
autotm --version

创建任务返回 task_id,然后查询结果。不同 exec 不共享 shell 状态,terminal 可以保留环境变量和当前目录。输出最多保留末尾 256 Ki 字符,响应的 offset 是字符偏移,truncated 表示有旧输出被丢弃。wait 最多轮询 60 秒,另有单次网络请求超时;返回时不会自动停止任务。

提交任务和终端输入前,客户端向 stderr 打印 request_id。如果提交后响应丢失,只能用同一个 ID、相同参数重试,或查询已知任务 ID;不要使用新 ID 重复执行可能已经完成的操作。

连接和安全边界

  • 只绑定具体 RFC1918 内网 IPv4 或 loopback,不绑定 0.0.0.0,不提供公网穿透。
  • 每次启动在内存中生成新 TLS 证书和随机授权码。客户端先校验证书 SHA-256 指纹,再发送凭据;不会跟随重定向或发送到其他地址。
  • 一次性授权码成功配对后失效,改用绑定客户端源 IP 的临时会话凭据。移动网络导致源 IP 改变时需重新授权。
  • 服务端仅在内存中持有凭据摘要;退出后没有可恢复的远端配对。客户端配置位于 ~/.config/auto-terminal/v3/,目录 0700、文件 0600,拒绝软链接凭据文件和宽松权限。
  • --config-dirAUTO_TERMINAL_CONFIG_DIR 可更改客户端配置目录。--replace 只替换同名本地配置,不撤销旧服务器授权。
  • Linux 只读接口逐级使用目录描述符和 O_NOFOLLOW 打开文件,拒绝 ..、软链接、设备及非普通文件。
  • Ctrl-C、SIGTERM、SIGHUP、授权到期、配对超时、空闲超时或客户端 disconnect 会结束授权。正常关闭会终止跟踪到的任务后代和进程组;无法撤销已完成的写入,也不保证清理主动脱离进程树的程序。SIGKILL、断电或进程被挂起时,不能保证立即清理任务。
  • forget --server NAME 仅删除本地配置。网络不通时 disconnect 未成功就不能声称已远端撤销,此时服务器自身的超时仍会生效。
  • 日志和命令输出可能包含业务秘密;按需查看,避免复制到聊天。程序不提供业务操作审计存储。

开发、打包与迁移

npm ci
npm test
npm pack --dry-run
npm pack
npm publish --access public

包只包含 bin/src/、Skill、README 和验证说明,不包含本地配置、授权码、旧版本、测试数据或开发环境。npm 公开发布不等于授权开源再分发,目前元数据为 UNLICENSED,尚未选择开源许可证。

v0.3.0 是 Node.js 重写版。Python v0.2 使用 auto-terminalat2_ 授权码;本版本使用 autotmat3_,两者协议和配置目录独立。旧授权不能直接复用,应先关闭旧服务,再用新版本生成授权。旧版本源码备份不进入 npm 包。

测试范围及 Linux 实机待验证项见 验证记录