@alicloud/autowonder 0.0.1 → 0.3.34
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 +39 -19
- package/bin/cli.js +25 -47
- package/bin/qoder-bootstrap.js +68 -58
- package/bin/qoder-generations.js +79 -0
- package/bin/shared.js +2 -1
- package/bin/token-proxy-ca.js +129 -0
- package/bin/token-proxy-helper.js +52 -0
- package/bin/token-proxy-manager.js +114 -0
- package/bin/token-proxy-service.js +57 -0
- package/bin/token-proxy.js +27 -15
- package/bin/windows-job-runner.ps1 +8 -5
- package/package.json +3 -3
- package/vendor/autowonder-daemon-darwin-amd64 +0 -0
- package/vendor/autowonder-daemon-darwin-arm64 +0 -0
- package/vendor/autowonder-daemon-linux-amd64 +0 -0
- package/vendor/autowonder-daemon-linux-arm64 +0 -0
- package/vendor/autowonder-daemon-win32-amd64.exe +0 -0
- package/vendor/autowonder-daemon-win32-arm64.exe +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
本分支为 `0.0.1` beta 测试发布,升级器的通道查询仅使用 `@alicloud/autowonder` 的 `beta` 标签。使用 `npx -y @alicloud/autowonder@beta` 或固定版本 `@alicloud/autowonder@0.0.1`;不发布 latest,不合并 master。
|
|
1
|
+
# autowonder
|
|
4
2
|
|
|
5
3
|
AutoWonder 本地 agent runtime。安装后启动 daemon,持续轮询本地 assignment 队列并执行任务包。
|
|
6
4
|
|
|
@@ -8,10 +6,10 @@ AutoWonder 本地 agent runtime。安装后启动 daemon,持续轮询本地 as
|
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
8
|
# Qoder CLI(模型使用 provider model ID;Context Window 使用固定档位)
|
|
11
|
-
npx -y @alicloud/autowonder@0.
|
|
9
|
+
npx -y @alicloud/autowonder@0.3.34 connect --ws-url <wss-endpoint> --token <executor-token> --executor-id <executor-id> --provider qoder --model qmodel_latest --reasoning-effort medium --context-window 260000
|
|
12
10
|
|
|
13
11
|
# Qoder CLI CN
|
|
14
|
-
npx -y @alicloud/autowonder@0.
|
|
12
|
+
npx -y @alicloud/autowonder@0.3.34 connect --ws-url <wss-endpoint> --token <executor-token> --executor-id <executor-id> --provider qodercn
|
|
15
13
|
```
|
|
16
14
|
|
|
17
15
|
`connect` 会安装当前 npm 包内置的 daemon,并使用页面生成的 WebSocket endpoint、Token 和执行器 ID 建立连接。客户端只支持通过 Qoder 系列 CLI 启动(`qoder` 对应 `qodercli`,`qodercn` 对应 `qodercn`),其他 `--provider` 取值会在启动 daemon 前直接报错拦截并提示 `Unsupported provider`。选择 Qoder CLI 或 Qoder CLI CN 时需要 Node.js 20+;runtime 会在缺少对应 CLI 时自动通过 npm 安装,并在尚未登录时打开浏览器登录。runtime 会继承当前用户的 HOME、环境变量和 CLI 登录状态。
|
|
@@ -29,9 +27,9 @@ runtime 启动时始终只拉取一次 Platform 环境变量快照,即使已
|
|
|
29
27
|
|
|
30
28
|
出于安全考虑,命令行 token 可能出现在 shell 历史和操作系统进程列表中,建议优先使用环境变量或 Platform 绑定。
|
|
31
29
|
|
|
32
|
-
`connect` 和 `start` 都要求 Qoder CLI / Qoder CLI CN 版本至少为 `1.1.65
|
|
30
|
+
`connect` 和 `start` 都要求 Qoder CLI / Qoder CLI CN 版本至少为 `1.1.65`。检测到旧版、无法解析的版本,或共享安装被其他进程的安装锁占用时,runtime 不再原位升级共享 CLI,而是安装到独立的私有 generation(`~/.autowonder/qoder-generations/<provider>/gen-*`):先校验候选二进制版本,再原子发布 `current.json` 指向已验证的 generation,启动时直接使用该 generation 的具体路径。候选安装或校验失败不会被选中,上一代保留为回退;旧 generation 不自动删除。显式指定的外部可执行文件(`AUTOWONDER_QODER_CLI` / `AUTOWONDER_QODERCN_CLI`)在校验通过后仍直接使用,runtime 不会原地修改它。daemon 退出与 re-exec 前会取消并等待进行中的 Qoder 安装/升级维护任务,避免遗留共享安装票据让同机其他执行器的版本预检持续失败。所有 Qoder 系列子进程(普通任务、conversation、warm 会话、恢复回退、命令与模型探测)都会强制注入固定的 `QODER_INTEGRATION_ID`,调用方环境不能覆盖该流量归因标识。
|
|
33
31
|
|
|
34
|
-
`qodercn` 是国内版 Qoder CLI。runtime 会在缺少 `qodercn` 时自动把 `@qodercn-ai/qoderclicn`
|
|
32
|
+
`qodercn` 是国内版 Qoder CLI。runtime 会在缺少 `qodercn` 时自动把 `@qodercn-ai/qoderclicn` 安装到独立 generation `~/.autowonder/qoder-generations/qodercn/`(旧版本写入的 `~/.autowonder/qoder-cn-cli` 安装仍会被识别),并在尚未登录时打开浏览器登录。它使用自己的配置根(`QODERCN_CONFIG_DIR`,默认 `~/.qoder-cn`),与国际版 `qoder` 不共享可执行文件、凭证和会话。可用 `AUTOWONDER_QODERCN_CLI` 指定自定义可执行文件路径。
|
|
35
33
|
|
|
36
34
|
Qoder 的 Context Window 只能使用 `1000000`、`400000` 或 `260000`,Reasoning Effort 只能使用 `none`、`low`、`medium`、`high`、`xhigh` 或 `max`。`--model` 不再校验固定白名单:取值经 `AUTOWONDER_MODEL` 原样透传给 Qoder CLI,因此服务端上线新模型无需升级本客户端。建议直接复制 AutoWonder 执行器页面生成的命令,避免把模型展示名称误当成 provider model ID。
|
|
37
35
|
|
|
@@ -41,11 +39,11 @@ daemon 还在协议能力位里声明 `TASK_MODEL_SELECTION_V1`:服务端可
|
|
|
41
39
|
|
|
42
40
|
daemon 建立执行器接入连接时会在 WebSocket URL 上附带本机主机名(取不到时不带该参数,服务端按未上报处理),服务端据此在执行器列表区分同一数字员工在多台机器上的执行器。对执行机用户无新增参数或环境变量。
|
|
43
41
|
|
|
44
|
-
daemon 还在协议能力位里声明 `terminal_steer_v1`:服务端可对当前正在执行的派单下发 `TASK_STEER` 终端插话(含 `guidanceId`、`dispatchId` 与内容)。daemon 只在该派单存在活跃 provider 回合时受理:协作式取消当前回合、等待退出后在同一 agent
|
|
42
|
+
daemon 还在协议能力位里声明 `terminal_steer_v1`:服务端可对当前正在执行的派单下发 `TASK_STEER` 终端插话(含 `guidanceId`、`dispatchId` 与内容)。daemon 只在该派单存在活跃 provider 回合时受理:协作式取消当前回合、等待退出后在同一 agent 会话内携带插话内容继续执行。终端插话的回执时机是「已交给 ACP 会话」而不是「插话回合执行成功」:插话内容写入 `session/prompt` 后立即回传 `TASK_STEER_ACK`(`APPLIED`),同一批插话只回执一次,插话回合随后失败、取消或超时都不会改写这条回执;提交本身失败时仍按回合结果回传 `FAILED`。评论续接等非终端插话批次仍在回合结束后回执。无活跃回合、回合已结束或接收队列已满时明确返回失败,不影响原任务状态。插话与评论投递、工作流回复路由相互独立(重复投递去重、回执可重放)。该能力对执行机用户无新增参数或环境变量。
|
|
45
43
|
|
|
46
44
|
daemon 还会响应服务端的 `CONVERSATION_COMMANDS_PROBE` 帧,用独立会话抓取该会话工作目录下可用的斜杠命令,回传 `CONVERSATION_COMMANDS_RESULT` 帧,让会话面板在用户输入 `/` 时列出真实可用的命令。该探测与回合执行完全隔离:任何失败只产生 `FAILED` / `TIMEOUT` 帧,不影响进行中的会话;provider 后端不支持抓取时同样降级为 `FAILED` 帧。帧里的 `executorId` 与本机不一致或非正数时直接忽略,避免在别的执行器工作区里建目录或启动 CLI。daemon 侧给整个探测 25 秒硬上限,刻意长于 agent 侧的 20 秒预算,使 agent 自己的超时先触发并可被归类。
|
|
47
45
|
|
|
48
|
-
给 `connect` 追加 `--token-aware-enable` 可开启 qoder / qodercn 的 token 用量采集:CLI
|
|
46
|
+
给 `connect` 追加 `--token-aware-enable` 可开启 qoder / qodercn 的 token 用量采集:CLI 会确保本机存在一个**共享**的本地 HTTPS 转发代理(`bin/token-proxy.js`)——同一用户、同一配置根、同一端口只保留一个实例,监听者属于共享服务而不是某个 daemon,退出某个执行器不会主动停掉它,数据目录为 `~/.autowonder/token-tap/`。代理从 Qoder API 的 SSE 响应流中提取 usage 数据并按 dispatch ID 归属上报。启用的 `connect` 用已安装 daemon 提供的 `token-proxy-helper` 核验监听者身份(系统监听者 owner、用户、进程出生时间、可执行路径与参数、脚本内容、profile),核验不通过的一律拒绝接管,健康响应里的 PID 本身不足以授权终止;健康检查同时验证到回环 echo 服务的 CONNECT 转发,模型/上游错误不触发重启,只有连续三次本地故障观测才在原生锁(macOS/Linux `flock`,Windows 按用户/scope 命名 mutex)下替换进程,且每 60 秒最多 3 次重启。CA 使用不可变 generation 目录加原子 `current.json` 指针,旧版代理的可用 CA 经私有 `takeover-ca.json` 接管,替换进程绑定端口后才消费它。用量日志把旧路径与新路径显式合并并按文件维护偏移。usage 解析失败只丢失计量数据;代理不可用时仅告警并继续。代理端口可用 `TOKEN_PROXY_PORT` 环境变量调整(默认 19876,自定义端口的数据目录为 `~/.autowonder/token-tap/ports/<port>/`)。启用后模型流量经过代理,连接失败由客户端处理重试,不保证自动直连。代理对 TCP 建连和两端 TLS 握手设置 15 秒期限,对无读写活动的连接设置 120 秒空闲期限;超时、报错或任一端关闭时释放两端连接,持续有数据的 SSE 流不受总时长限制,连续静默超过 120 秒的流会断开。平台差异:Linux 恢复依赖 pidfd(Linux 5.3+)且锁目录必须是受支持的本地文件系统(不支持 NFS/virtiofs);Windows 原生恢复只在 amd64 验证,ARM64 与 32 位 Node 未验证;macOS 在发信号前重新核对进程出生时间,但不像 pidfd/进程句柄那样原子。关键生命周期事件写入 `~/.autowonder/token-tap/lifecycle.log`。
|
|
49
47
|
|
|
50
48
|
`connect` 支持 `--workspace-root <path>` 指定 dispatch 仓库与任务工作区所在目录(默认 `~/autowonder_workspaces`)。该参数会转发给 daemon,等价于设置 `AUTOWONDER_WORKSPACE_ROOT` 环境变量,适合把工作区放在非默认路径的执行机上(如 Windows 的 `D:\autowonder`)。
|
|
51
49
|
|
|
@@ -89,7 +87,9 @@ daemon 默认启用本地工作区 GC:启动 30 秒后开始检查,之后每
|
|
|
89
87
|
|
|
90
88
|
`~/autowonder_workspaces`(可由 `--workspace-root` 或 `AUTOWONDER_WORKSPACE_ROOT` 修改)保存每个任务独立的工作文件和 checkout/worktree;`~/.autowonder/git-object-cache/v1` 保存可供多个任务复用 Git 历史对象的本地 bare mirror。每个任务仍会得到所请求准确 commit 的独立工作区。已缓存的固定 commit 可以不查询远端;允许联网时,`HEAD`、branch 或 tag 等可移动 ref 会在每次 materialization 时向远端解析为准确 commit,仅在 mirror 缺少该对象时 fetch。缓存优化失败时,只有其临时目录已经完成可验证的干净回滚才会回退到原有的远端完整 clone 流程;若无法证明干净回滚,则会保留现场并返回错误,不进入回退。任何路径都不会发布不完整的目标目录;已经存在的任务仓库只做校验,不会被 fetch、reset、clean、checkout 或覆盖。本版本不会自动淘汰 Git 对象缓存,工作区 GC 也不会删除该缓存。
|
|
91
89
|
|
|
92
|
-
任务包 `repos.json` 可为仓库声明继承来源 revision 的回退列表(`sourceRevisionFallbackRefs`):当派单要求的继承 revision 已无法解析为 commit(例如上游分支被删除或强推)时,runtime 会按该列表依次回退物化,命中后以回退 commit 作为该仓库本次使用的来源继续执行,并发出 `repo_source_revision_abandoned` 事件(含仓库、回退 commit 与原因)。只有「ref 无法解析」会触发回退——传输、权限、工作区归属与策略类失败不触发;声明了固定 base commit
|
|
90
|
+
任务包 `repos.json` 可为仓库声明继承来源 revision 的回退列表(`sourceRevisionFallbackRefs`):当派单要求的继承 revision 已无法解析为 commit(例如上游分支被删除或强推)时,runtime 会按该列表依次回退物化,命中后以回退 commit 作为该仓库本次使用的来源继续执行,并发出 `repo_source_revision_abandoned` 事件(含仓库、回退 commit 与原因)。只有「ref 无法解析」会触发回退——传输、权限、工作区归属与策略类失败不触发;声明了固定 base commit 的仓库不使用回退。该能力对执行机用户无新增参数或环境变量。来源 revision 产物里的 `checkoutVerification: "required"` 表示远端探测未能确认 HEAD(不等于 HEAD 未发布),下游应在开始验收前物化该精确 HEAD;旧消费方仍按原有远端校验逻辑处理。
|
|
91
|
+
|
|
92
|
+
任务工作区里的仓库工作分支名按派单 ID、attempt 与仓库名确定性生成。仓库名不含可用 ref 字符时(例如纯非 ASCII 名称),runtime 改用基于仓库名的 SHA-256 摘要生成 `repo-<hex>` 后缀,保证分支名合法、稳定且不依赖仓库 URL。Windows 上物化重命名与 GC 清理不再对保留的父目录请求 DELETE 访问,也不再用字节数组承载 `FILE_DISPOSITION_INFORMATION_EX`(4 字节对齐导致的 `STATUS_DATATYPE_MISALIGNMENT`),因此重命名目标父目录不会再因访问冲突失败。
|
|
93
93
|
|
|
94
94
|
任务工作区里的 Git 策略(是否允许提交/推送与工作区边界)由 runtime 安装的自包含钩子强制执行:默认策略不依赖 runtime 二进制或任务配置继续存在,因此历史任务残留不会让普通的 `git commit` / `git push` 失败,策略禁止时分别以退出码 `73` / `74` 拒绝提交与推送,提交还要求 HEAD 位于具名分支(detached 时以 `77` 拒绝)。安装是幂等的,只有确实声明了打包触发的仓库才会链式调用 runtime。daemon 启动时会在 15 秒预算内把本执行器历史 capsule 中可核对的旧版包装脚本迁移为这种自包含形式;模板、配置或元数据不完整的历史一律保留现场,不做全机扫描,也不恢复用户原有的 `hooksPath`。
|
|
95
95
|
|
|
@@ -101,9 +101,27 @@ daemon 重启或崩溃后重新接管未完成的派单时,runtime 不会直
|
|
|
101
101
|
|
|
102
102
|
恢复执行前会把工作目录规范化为绝对路径并解析符号链接(Qoder 会话按物理目录索引),因此通过符号链接别名派发的任务在重启后仍能找到并续接原会话。
|
|
103
103
|
|
|
104
|
+
完成交付进入 `uploading` 后,永久性上传失败(产物超限、权限拒绝或其他已判定的终态错误)不再被外层自动重试循环持续重投:runtime 记录终态失败、停止该派单的重试,并保留本次业务结果与产物责任等待平台处置;只有可恢复错误才按 30 秒退避继续。取消请求贯穿完成交付与启动恢复——上传阶段的取消会立即把该派单标记为已取消并释放待发布结果,恢复 worker 在启动前或上传重试过程中被取消时不再继续投递,对已进入终态且没有活跃处理器的派单会按幂等成功回应该取消。启动恢复中只做纯上传/发布结果的派单状态显示为 `uploading`,其被拒绝的上传仍以服务端权威所有权栅栏为准,不在本地凭空创建新的业务失败或结果身份。
|
|
105
|
+
|
|
106
|
+
暂停也走同一条持久化回执链路:`TASK_PAUSED` 只有在服务端确认接受后才从结果 outbox 删除,未接受时保留并可重发;服务端再次下发同一派单的暂停指令时,runtime 直接从 capsule 中已落盘的暂停结果(`runtime-result.json`,先校验租户、工单、派单、attempt 与 checkpoint 回执)重放该回执,而不要求暂停协调器仍留在内存里等待,因此 daemon 重启或回执丢失都不会让等待该派单返工的一方永久挂起。
|
|
107
|
+
|
|
108
|
+
暂停边界本身是冻结的:收到暂停指令后 runtime 先停掉普通检查点保存,再把结果与归档(含检查点序号与 SHA-256)原子写入 capsule 的 `state/pause-checkpoint.json`(0600),此后该派单不再落新检查点。服务端确认暂停并回传同一序号与 SHA-256 后,runtime 先写小而持久的确认凭据 `state/pause-checkpoint-confirmed.json`(仅当身份与回执匹配),再删除体积较大的归档;未被确认的暂停结果与归档一直保留,因此暂停 ACK 丢失只会占盘,不会让暂停事实消失。等待恢复期间若本地归档已缺失但确认凭据存在,runtime 会按 capsule 中保留的仓库状态重建检查点并回写新的序号与 SHA-256;恢复只上传冻结的本地状态,不会重新启动 provider 或执行 hooks。工作区 GC 只有在暂停归档已释放且存在与租户、工单、派单、attempt 完全匹配的确认凭据时才把暂停尝试视为终态并回收 capsule,避免提前删除仍可重建的暂停现场。
|
|
109
|
+
|
|
110
|
+
派单回合以 Qoder 自报的 `cancelled the prompt` 结束、而 runtime 并未发起取消,且本轮既无助手输出也无工具/提问活动时,不再直接判为失败:runtime 最多做 2 次有界恢复,第二次改用新会话并重建同一 workflow 上下文,重试前按退避等待,期间的暂停请求仍即时生效。只要已产生输出或工具副作用、存在待处理插话,或取消来自外部上下文,就不会重试;由多次调用组合而成的回合也不会授权重放其前置轮次。
|
|
111
|
+
|
|
112
|
+
Qoder 取消会在失败历史里附带 runtime 侧上下文诊断(是否尝试过取消、上下文状态),随 telemetry 一起导出,用于区分「模型自行中止」与「真实取消」。该诊断对执行机用户无新增参数或环境变量。
|
|
113
|
+
|
|
114
|
+
## 会话回合可靠性
|
|
115
|
+
|
|
116
|
+
conversation 回合只有在其结果成功、未被取消且取得 provider 返回的 session id 后,才把会话与该 session 绑定(工作目录内 `.autowonder-conversation-session.json`,含 provider、session id 与 system prompt 摘要)。此前「请求了某个 prompt」不等于 provider 真正采纳了它;绑定缺失、provider 变化、session 变化或 prompt 摘要变化都会重建会话并复用已保存历史。绑定写入失败只记日志,不会把已完成的工具副作用变成可重试的失败回合。对话历史也只在回合成功时追加。
|
|
117
|
+
|
|
118
|
+
人工回答的投递与传输解耦:回答先落盘为 receipt,再进入有界的 ACK 队列(最多 512 条待发提示,写回执优先于发提示),发送失败不阻塞任务,也不起本地重试循环;服务端重投或回合结束后的 receiptOnly 查询以落盘 receipt 为准,冲突的回答只会得到拒绝提示,不会污染已存在的真实回执。等待人工回答超时或回合被取消时,runtime 通过回合上下文停止 provider,而不是回传 ACP「人工拒绝」;回答注册器不可用时回合直接以 FAILED 回执。
|
|
119
|
+
|
|
104
120
|
## 自动更新
|
|
105
121
|
|
|
106
|
-
|
|
122
|
+
自 0.3.33 起正式 npm 包迁移为 `@alicloud/autowonder`(命令名与二进制身份仍是 `autowonder`),旧包 `autowonder` 的 `beta` 停在 0.3.32(`latest` 仍为 0.2.130)。平台触发升级时,版本元数据及 tarball 从 `@alicloud/autowonder` 获取(最新版本查询使用 `latest`,指定版本查询使用对应版本号)。旧客户端先升级到旧包中的桥接版本,再由平台指派版本号更高的组织包;新包未发布或查询失败时保留当前版本,不回退查询旧包。组织包必须延续递增版本号,不能用 `0.0.1` 替代已安装的 `0.3.x`。此变更不启用后台自动检查。
|
|
123
|
+
|
|
124
|
+
daemon 不会自行追新:后台自动更新策略默认关闭,且没有环境变量可以重新开启,因此 daemon 不会主动查询 npm 的 `@alicloud/autowonder/latest`、下载、安装或重启。版本由平台决定,见下文的服务端指定版本升级;没有服务端升级指令时,即使本地配置了更短的检查周期也不会产生任何 npm 请求。
|
|
107
125
|
|
|
108
126
|
升级能力与后台策略是两件事:标准安装的正式版 daemon 仍会初始化升级器并在心跳里上报远程升级能力,因此平台可以下发指定版本的升级指令。收到 `EXECUTOR_UPGRADE`(或 `EXECUTOR_RESTART` 且 `update=true`)后,daemon 才会按指令解析 npm tarball、校验 SHA-512 SRI、包版本和平台二进制;只有在没有运行/恢复任务且结果 outbox 已收到服务端确认时,才会暂停接单、原子切换二进制并重启。启动失败会恢复上一个二进制。
|
|
109
127
|
|
|
@@ -112,7 +130,7 @@ daemon 不会自行追新:后台自动更新策略默认关闭,且没有环
|
|
|
112
130
|
```bash
|
|
113
131
|
# 使用兼容的 npm registry(仅影响按平台指令解析版本时使用的源)
|
|
114
132
|
AUTOWONDER_NPM_REGISTRY=https://registry.npmjs.org \
|
|
115
|
-
npx -y @alicloud/autowonder@
|
|
133
|
+
npx -y @alicloud/autowonder@latest connect ...
|
|
116
134
|
```
|
|
117
135
|
|
|
118
136
|
## 在线应用启动命令
|
|
@@ -179,7 +197,7 @@ mv "$queue/.assignment.tmp" "$queue/assignment.json"
|
|
|
179
197
|
也可以直接提交到本地 API:
|
|
180
198
|
|
|
181
199
|
```bash
|
|
182
|
-
npx -y @alicloud/autowonder@0.
|
|
200
|
+
npx -y @alicloud/autowonder@0.3.34 dispatch ./assignment.json
|
|
183
201
|
```
|
|
184
202
|
|
|
185
203
|
## 上传工单附件
|
|
@@ -187,7 +205,7 @@ npx -y @alicloud/autowonder@0.0.1 dispatch ./assignment.json
|
|
|
187
205
|
把本地需求/设计文档直接上传到工单,避免在会话里传递大文件:
|
|
188
206
|
|
|
189
207
|
```bash
|
|
190
|
-
npx -y @alicloud/autowonder@0.
|
|
208
|
+
npx -y @alicloud/autowonder@0.3.34 workitem upload --server-url <autowonder-server-url> --workitem-id <id> --file <filepath-1> --file <filepath-2> --json
|
|
191
209
|
```
|
|
192
210
|
|
|
193
211
|
上传令牌通过 MCP 工具 `autowonder.workitem_cli_upload_token` 签发,经 `--token` 或 `AUTOWONDER_UPLOAD_TOKEN` 环境变量传入。`--file` 可重复指定多个文件;`--json` 输出机器可读结果。失败时按错误类型返回不同退出码(401→3、403→4、404→5、409→6、413→7、其他 4xx→8、网络/重定向→9)。
|
|
@@ -197,7 +215,7 @@ npx -y @alicloud/autowonder@0.0.1 workitem upload --server-url <autowonder-serve
|
|
|
197
215
|
把工单上已有的需求/设计文档下载到本地目录,再用本地文件工具阅读,避免把大文件或二进制附件搬进会话上下文:
|
|
198
216
|
|
|
199
217
|
```bash
|
|
200
|
-
npx -y @alicloud/autowonder@0.
|
|
218
|
+
npx -y @alicloud/autowonder@0.3.34 workitem download --server-url <autowonder-server-url> --workitem-id <id> --file <name-or-id> --output-dir <dir> --json
|
|
201
219
|
```
|
|
202
220
|
|
|
203
221
|
下载令牌通过 MCP 工具 `autowonder.workitem_cli_download_token` 签发(与上传令牌相互独立),经 `--token` 或 `AUTOWONDER_DOWNLOAD_TOKEN` 环境变量传入。`--file` 可重复指定文档名或 artifact id,省略则下载该工单的全部附件;`--output-dir` 默认为当前目录;`--json` 输出机器可读结果,含每个文件的 `id`、`name`、`path`、`size`。退出码约定与 `workitem upload` 相同(401→3、403→4、404→5、409→6、413→7、其他 4xx→8、网络/重定向→9)。
|
|
@@ -207,7 +225,7 @@ npx -y @alicloud/autowonder@0.0.1 workitem download --server-url <autowonder-ser
|
|
|
207
225
|
把需求/设计文档上传到 7x24 定时任务,用法与工单附件一致(同一套上传令牌与预检规则):
|
|
208
226
|
|
|
209
227
|
```bash
|
|
210
|
-
npx -y @alicloud/autowonder@0.
|
|
228
|
+
npx -y @alicloud/autowonder@0.3.34 scheduled-task upload --server-url <autowonder-server-url> --scheduled-task-id <id> --file <filepath-1> --file <filepath-2> --json
|
|
211
229
|
```
|
|
212
230
|
|
|
213
231
|
上传令牌同样通过 `autowonder.workitem_cli_upload_token` 签发(令牌为用户级,对当前可修改的任意定时任务生效),经 `--token` 或 `AUTOWONDER_UPLOAD_TOKEN` 传入;退出码约定与 `workitem upload` 相同。
|
|
@@ -215,8 +233,8 @@ npx -y @alicloud/autowonder@0.0.1 scheduled-task upload --server-url <autowonder
|
|
|
215
233
|
## 管理 daemon
|
|
216
234
|
|
|
217
235
|
```bash
|
|
218
|
-
npx -y @alicloud/autowonder@0.
|
|
219
|
-
npx -y @alicloud/autowonder@0.
|
|
236
|
+
npx -y @alicloud/autowonder@0.3.34 status
|
|
237
|
+
npx -y @alicloud/autowonder@0.3.34 stop
|
|
220
238
|
```
|
|
221
239
|
|
|
222
240
|
默认 API 是 `http://127.0.0.1:34989`,日志位于 `~/.autowonder/daemon.log`。npm 包不包含任何 agent、MCP 或服务端凭证。
|
|
@@ -239,9 +257,11 @@ daemon 内置独立于工作区 GC 的保留清扫:默认每小时运行一次
|
|
|
239
257
|
## 调试
|
|
240
258
|
|
|
241
259
|
```bash
|
|
242
|
-
npx -y @alicloud/autowonder@0.
|
|
260
|
+
npx -y @alicloud/autowonder@0.3.34 connect ... --debug
|
|
243
261
|
```
|
|
244
262
|
|
|
245
263
|
`--debug` 会让 CLI 以 `AUTOWONDER_DEBUG=1` 启动 daemon,把完整的 daemon 与 agent 活动(runtime 事件流、provider 事件解码、重试退避与会话门等待、空闲时的阻塞点)同时输出到控制台和会话调试日志。调试日志不做脱敏,仅用于本机排障;不传 `--debug` 时该环境变量不会注入。
|
|
246
264
|
|
|
265
|
+
daemon 把仅用于展示的事件(`text`、`thinking`、`log`、`thinking_started`、`thinking_completed`)放进有界单协程队列(4096 条 / 16 MiB,关闭时最多等待 5 秒排水),与业务事件处理隔离:展示通道变慢或阻塞不会拖住工具、卡片、回执等业务控制事件。排队溢出或未送达只计入丢失量,并以 `provider_observation_delivery_summary` 事件和结果里的 `observationLoss` 元数据上报。诊断/日志写入失败不会把已成功的业务执行变成投递失败,完成边界后的 diagnostic flush 错误也不会凭空创建 completion 投递所有权。该机制对执行机用户无新增参数或环境变量。
|
|
266
|
+
|
|
247
267
|
`--debug` 之外还有一条由服务端驱动的班组调试日志采集通道,两者互不依赖。runtime 在 `protocolFeatures` 中声明 `DEBUG_LOG_V1`,服务端只会给声明了该能力位的 runtime 下发 `debugLog` 策略;策略在打包时冻结进 assignment(`enabled` / `maxBytes` / `uploadUrl`),执行期不再变化。开启后 runtime 会把本轮完整调试日志写到 capsule 内,单轮硬上限默认 200MB(可由 `debugLog.maxBytes` 覆盖),所在卷剩余空间低于 2GB 时停止写入,单条记录超过 8MB 会被截断并打标记。它是旁路设计:写入队列满时丢行而不反压任务热路径,收尾等待最多 5 秒。回合结束时按 `DIRECT`(对象存储预签名 PUT)或 `RELAY`(服务端中转)通道上传,结果以 `debugLog` 段附在 `TASK_RESULT` 上(`status` 为 `UPLOADED` / `FAILED`,含字节数与 SHA-256);报告里的错误文本会把 URL 查询串替换为 `<redacted>`,避免执行器令牌或对象存储签名外泄。
|
package/bin/cli.js
CHANGED
|
@@ -504,65 +504,43 @@ async function cmdConnect(args) {
|
|
|
504
504
|
delete env[selectedAccessTokenEnv];
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
-
//
|
|
508
|
-
let
|
|
507
|
+
// The listener belongs to the shared service, never to an individual daemon.
|
|
508
|
+
let stopProxyWatch = () => {};
|
|
509
509
|
if (flags["token-aware-enable"]) {
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
spawnSync(process.execPath, ["-e", "setTimeout(()=>{},200)"], { stdio: "ignore" }); // cross-platform sleep
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
if (fs.existsSync(caCertPath)) {
|
|
534
|
-
// Pass proxy config to daemon via env. The daemon will set per-dispatch
|
|
535
|
-
// HTTPS_PROXY=http://d-{dispatchId}:x@host:port for each qodercli process,
|
|
536
|
-
// so the proxy can tag token records with the exact dispatch ID.
|
|
537
|
-
env.AUTOWONDER_TOKEN_PROXY_PORT = String(proxyPort);
|
|
538
|
-
env.AUTOWONDER_TOKEN_PROXY_CA = caCertPath;
|
|
539
|
-
env.AUTOWONDER_TOKEN_PROXY_DIAG_LOG = path.join(AUTOWONDER_HOME, "token-tap", "proxy-diag.log");
|
|
540
|
-
env.NODE_EXTRA_CA_CERTS = caCertPath;
|
|
541
|
-
log(`Token tracking enabled (proxy pid=${tokenProxyChild.pid}, port=${proxyPort})`);
|
|
542
|
-
} else {
|
|
543
|
-
log("WARN: token-proxy CA cert not ready, continuing without token tracking");
|
|
544
|
-
}
|
|
545
|
-
} catch (e) {
|
|
546
|
-
log(`WARN: token-proxy start failed (${e.message}), continuing without token tracking`);
|
|
547
|
-
}
|
|
548
|
-
} else {
|
|
549
|
-
log(`WARN: token-proxy.js not found at ${tokenProxyScript}, --token-aware-enable ignored`);
|
|
550
|
-
}
|
|
510
|
+
const { configuration, ensureSharedProxy, watchSharedProxy } = require("./token-proxy-manager");
|
|
511
|
+
const proxy = configuration();
|
|
512
|
+
proxy.debug = Boolean(flags.debug);
|
|
513
|
+
proxy.helper = DAEMON_BIN;
|
|
514
|
+
const ready = await ensureSharedProxy(proxy);
|
|
515
|
+
env.AUTOWONDER_TOKEN_PROXY_PORT = String(proxy.port);
|
|
516
|
+
env.AUTOWONDER_TOKEN_PROXY_MANAGED = "1";
|
|
517
|
+
env.AUTOWONDER_TOKEN_PROXY_LEGACY_ALLOWED = "1";
|
|
518
|
+
env.AUTOWONDER_TOKEN_PROXY_BASE_DIR = proxy.baseDir;
|
|
519
|
+
env.AUTOWONDER_TOKEN_PROXY_NODE_PATH = process.execPath;
|
|
520
|
+
env.AUTOWONDER_TOKEN_PROXY_SCRIPT_PATH = path.join(__dirname, "token-proxy.js");
|
|
521
|
+
env.AUTOWONDER_TOKEN_PROXY_LEGACY_USAGE_LOG = path.join(proxy.baseDir, "token-usage.jsonl");
|
|
522
|
+
env.AUTOWONDER_TOKEN_PROXY_USAGE_LOG = path.join(proxy.dataDir, "token-usage.jsonl");
|
|
523
|
+
env.AUTOWONDER_TOKEN_PROXY_SCOPE = proxy.scope;
|
|
524
|
+
env.AUTOWONDER_TOKEN_PROXY_STATE_DIR = path.join(proxy.dataDir, "managed");
|
|
525
|
+
env.AUTOWONDER_TOKEN_PROXY_CA = ready.caPath || path.join(proxy.dataDir, "managed", ready.generation, "ca.pem");
|
|
526
|
+
env.NODE_EXTRA_CA_CERTS = env.AUTOWONDER_TOKEN_PROXY_CA;
|
|
527
|
+
env.AUTOWONDER_TOKEN_PROXY_DIAG_LOG = path.join(proxy.dataDir, "proxy-diag.log");
|
|
528
|
+
stopProxyWatch = watchSharedProxy(proxy, log);
|
|
529
|
+
log(`Shared token tracking enabled (port=${proxy.port})`);
|
|
551
530
|
}
|
|
552
531
|
|
|
553
532
|
const child = spawn(DAEMON_BIN, [], { env, stdio: "inherit" });
|
|
554
533
|
child.on("exit", (code) => {
|
|
555
|
-
|
|
556
|
-
if (tokenProxyChild) { try { process.kill(tokenProxyChild.pid); } catch (_) {} }
|
|
534
|
+
stopProxyWatch();
|
|
557
535
|
process.exit(code || 0);
|
|
558
536
|
});
|
|
559
537
|
process.on("SIGINT", () => {
|
|
560
538
|
child.kill("SIGINT");
|
|
561
|
-
|
|
539
|
+
stopProxyWatch();
|
|
562
540
|
});
|
|
563
541
|
process.on("SIGTERM", () => {
|
|
564
542
|
child.kill("SIGTERM");
|
|
565
|
-
|
|
543
|
+
stopProxyWatch();
|
|
566
544
|
});
|
|
567
545
|
}
|
|
568
546
|
|
package/bin/qoder-bootstrap.js
CHANGED
|
@@ -5,6 +5,7 @@ const crypto = require("crypto");
|
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const os = require("os");
|
|
7
7
|
const path = require("path");
|
|
8
|
+
const generations = require("./qoder-generations");
|
|
8
9
|
|
|
9
10
|
const { ensureDir, error, findOnPath, log, resolveUserPath } = require("./shared");
|
|
10
11
|
|
|
@@ -23,12 +24,14 @@ const WINDOWS_JOB_RUNNER = path.join(__dirname, "windows-job-runner.ps1");
|
|
|
23
24
|
|
|
24
25
|
function spawnSyncWithTreeTimeout(executable, args, options) {
|
|
25
26
|
const timeout = options.timeout;
|
|
26
|
-
const
|
|
27
|
+
const { windowsVerbatimArguments, ...childOptions } = options;
|
|
28
|
+
const runnerOptions = { ...childOptions, timeout: timeout + 30000 };
|
|
27
29
|
if (IS_WIN32) {
|
|
28
30
|
const powershell = path.join(process.env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
29
31
|
const encodedArgs = Buffer.from(JSON.stringify(args), "utf8").toString("base64");
|
|
30
32
|
return spawnSync(powershell, ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File",
|
|
31
|
-
WINDOWS_JOB_RUNNER, "-TimeoutMs", String(timeout), "-Executable", executable, "-ArgsBase64", encodedArgs
|
|
33
|
+
WINDOWS_JOB_RUNNER, "-TimeoutMs", String(timeout), "-Executable", executable, "-ArgsBase64", encodedArgs,
|
|
34
|
+
...(windowsVerbatimArguments ? ["-VerbatimArguments"] : [])], runnerOptions);
|
|
32
35
|
}
|
|
33
36
|
return spawnSync(process.execPath, [PROCESS_TREE_RUNNER, String(timeout), executable, JSON.stringify(args)], runnerOptions);
|
|
34
37
|
}
|
|
@@ -135,9 +138,9 @@ function spawnQoderSync(executable, args, options = {}) {
|
|
|
135
138
|
const spawnArgs = ["/d", "/v:off", "/s", "/c", invocation.command];
|
|
136
139
|
if (options.treeTimeout) {
|
|
137
140
|
const { treeTimeout: _, ...treeOptions } = options;
|
|
138
|
-
return spawnSyncWithTreeTimeout(comspec, spawnArgs, { ...treeOptions, env: invocation.env });
|
|
141
|
+
return spawnSyncWithTreeTimeout(comspec, spawnArgs, { ...treeOptions, env: invocation.env, windowsVerbatimArguments: true });
|
|
139
142
|
}
|
|
140
|
-
return spawnSync(comspec, spawnArgs, { ...options, env: invocation.env });
|
|
143
|
+
return spawnSync(comspec, spawnArgs, { ...options, env: invocation.env, windowsVerbatimArguments: true });
|
|
141
144
|
}
|
|
142
145
|
if (options.treeTimeout) {
|
|
143
146
|
const { treeTimeout: _, ...treeOptions } = options;
|
|
@@ -260,6 +263,8 @@ function findQoderExecutable(provider) {
|
|
|
260
263
|
error(`${profile.envVar} points at ${resolved}, which is not executable; falling back to PATH.`);
|
|
261
264
|
}
|
|
262
265
|
}
|
|
266
|
+
const managed = generations.current(generationOptions(profile));
|
|
267
|
+
if (managed) return managed;
|
|
263
268
|
const onPath = findOnPath(profile.executable);
|
|
264
269
|
if (onPath) return onPath;
|
|
265
270
|
if (IS_WIN32) {
|
|
@@ -284,22 +289,38 @@ function managedQoderExecutable(profile) {
|
|
|
284
289
|
return path.join(qoderPaths(profile).managedDir, "node_modules", ".bin", binName);
|
|
285
290
|
}
|
|
286
291
|
|
|
292
|
+
function generationOptions(profile) {
|
|
293
|
+
const provider = profile === QODER_FAMILY_PROFILES.qodercn ? "qodercn" : "qoder";
|
|
294
|
+
return {
|
|
295
|
+
root: path.join(os.homedir(), ".autowonder", "qoder-generations", provider),
|
|
296
|
+
executable: IS_WIN32 ? profile.windowsShimName : profile.managedBinName,
|
|
297
|
+
verify: (bin) => qoderVersionMeetsMinimum(probeQoderVersionUntil(profile, bin,
|
|
298
|
+
(probe) => qoderVersionMeetsMinimum(probe.version)).version),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
287
302
|
function installQoderCLI(provider, options = {}) {
|
|
288
303
|
const profile = QODER_FAMILY_PROFILES[provider];
|
|
289
|
-
if (options.
|
|
290
|
-
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
return installQoderCLIUnlocked(provider);
|
|
296
|
-
});
|
|
297
|
-
return result || "";
|
|
304
|
+
if (options.skipIfPresent) {
|
|
305
|
+
const current = generations.current(generationOptions(profile));
|
|
306
|
+
if (current) return current;
|
|
307
|
+
}
|
|
308
|
+
return installQoderCLIUnlocked(provider);
|
|
298
309
|
}
|
|
299
310
|
|
|
300
311
|
function installQoderCLIUnlocked(provider) {
|
|
301
312
|
const profile = QODER_FAMILY_PROFILES[provider];
|
|
302
|
-
|
|
313
|
+
try {
|
|
314
|
+
return generations.install({ ...generationOptions(profile),
|
|
315
|
+
install: (prefix) => installQoderPackage(profile, prefix),
|
|
316
|
+
});
|
|
317
|
+
} catch (err) {
|
|
318
|
+
error(`${profile.displayName} requires version 1.1.65 or newer: ${err.message}`);
|
|
319
|
+
return "";
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function installQoderPackage(profile, managedDir) {
|
|
303
324
|
log(`${profile.displayName} is not installed. Installing ${profile.npmPackage}...`);
|
|
304
325
|
const args = [
|
|
305
326
|
"install", "--prefix", managedDir, profile.npmPackage, "--no-audit", "--no-fund",
|
|
@@ -332,9 +353,7 @@ function installQoderCLIUnlocked(provider) {
|
|
|
332
353
|
error(`Failed to install ${profile.displayName} into ${managedDir}: ${detail}`);
|
|
333
354
|
return "";
|
|
334
355
|
}
|
|
335
|
-
|
|
336
|
-
if (!executable) error(`${profile.displayName} was installed but ${profile.executable} is not available on PATH.`);
|
|
337
|
-
return executable;
|
|
356
|
+
return true;
|
|
338
357
|
}
|
|
339
358
|
|
|
340
359
|
const MACHINE_ID_REL_PATH = path.join(".auth", "machine_id");
|
|
@@ -619,10 +638,10 @@ function validateQoderLockTickets(tickets) {
|
|
|
619
638
|
}
|
|
620
639
|
}
|
|
621
640
|
|
|
622
|
-
function withQoderUpdateLock(executable, fn) {
|
|
641
|
+
function withQoderUpdateLock(executable, fn, timeoutMs = 15 * 60 * 1000) {
|
|
623
642
|
const lockPaths = qoderUpdateLockPaths(executable);
|
|
624
643
|
fs.mkdirSync(path.dirname(lockPaths[0]), { recursive: true, mode: 0o700 });
|
|
625
|
-
const deadline = Date.now() +
|
|
644
|
+
const deadline = Date.now() + timeoutMs;
|
|
626
645
|
const owner = { pid: process.pid, token: crypto.randomBytes(16).toString("hex") };
|
|
627
646
|
const acquired = [];
|
|
628
647
|
let failure = null;
|
|
@@ -676,48 +695,39 @@ function withQoderUpdateLock(executable, fn) {
|
|
|
676
695
|
}
|
|
677
696
|
|
|
678
697
|
function ensureMinimumQoderVersion(profile, provider, executable) {
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
// An up-to-date CLI answers nothing far more often than it is really too
|
|
687
|
-
// old, so confirm the failure before paying for a download.
|
|
688
|
-
log(`${profile.displayName} did not report a version on the first probe (${describeQoderVersionProbe(probe)}); re-probing before updating...`);
|
|
689
|
-
probe = probeQoderVersionUntil(profile, executable, (candidate) => candidate.outcome === "ok", probe);
|
|
690
|
-
}
|
|
691
|
-
if (qoderVersionMeetsMinimum(probe.version)) return { ok: true, version: probe.version };
|
|
692
|
-
|
|
693
|
-
log(`${profile.displayName} ${probe.version} is older than required version 1.1.65 (or could not be parsed). Updating the current installation to latest...`);
|
|
694
|
-
const update = spawnQoderSync(executable, ["update"], { stdio: "inherit", timeout: 5 * 60 * 1000, treeTimeout: true });
|
|
695
|
-
if (update.status !== 0) {
|
|
696
|
-
const managedDir = qoderPaths(profile).managedDir;
|
|
697
|
-
if (executable.startsWith(`${managedDir}${path.sep}`)) {
|
|
698
|
-
const reinstalled = installQoderCLI(provider, { lockHeld: true });
|
|
699
|
-
if (reinstalled) {
|
|
700
|
-
executable = reinstalled;
|
|
701
|
-
probe = probeQoderVersionUntil(profile, executable, (candidate) => qoderVersionMeetsMinimum(candidate.version));
|
|
702
|
-
if (qoderVersionMeetsMinimum(probe.version)) return { ok: true, version: probe.version, executable };
|
|
703
|
-
}
|
|
698
|
+
const opts = generationOptions(profile);
|
|
699
|
+
let probe;
|
|
700
|
+
const inspect = () => {
|
|
701
|
+
probe = probeQoderBinaryVersion(executable);
|
|
702
|
+
if (isTransientQoderVersionProbe(probe)) {
|
|
703
|
+
log(`${profile.displayName} did not report a version; re-probing before selecting another installation...`);
|
|
704
|
+
probe = probeQoderVersionUntil(profile, executable, (candidate) => candidate.outcome === "ok", probe);
|
|
704
705
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
706
|
+
return qoderVersionMeetsMinimum(probe.version) ? { ok: true, version: probe.version, executable } : null;
|
|
707
|
+
};
|
|
708
|
+
// Known private generations have no in-place writer in this protocol.
|
|
709
|
+
// External installations still coordinate with legacy writers. Never delete
|
|
710
|
+
// their tickets: a blocked installation can only be replaced by a new prefix.
|
|
711
|
+
let verified;
|
|
712
|
+
try {
|
|
713
|
+
verified = generations.contains(opts, executable) ? inspect()
|
|
714
|
+
: withQoderUpdateLock(executable, inspect, 2000);
|
|
715
|
+
} catch (err) {
|
|
716
|
+
log(`Shared Qoder installation is unavailable (${err.message}); selecting a separate generation.`);
|
|
717
|
+
}
|
|
718
|
+
if (verified) return verified;
|
|
719
|
+
let selected = generations.current(opts);
|
|
720
|
+
if (!selected && probe && probe.outcome !== "ok"
|
|
721
|
+
&& !executable.startsWith(`${qoderPaths(profile).managedDir}${path.sep}`)
|
|
722
|
+
&& !generations.contains(opts, executable)) {
|
|
723
|
+
error(`${profile.displayName} requires version 1.1.65 or newer; version probe failed without evidence of an old version.`);
|
|
716
724
|
reportQoderVersionProbe(probe);
|
|
717
725
|
return { ok: false, version: probe.version, executable };
|
|
718
726
|
}
|
|
719
|
-
|
|
720
|
-
return { ok:
|
|
727
|
+
if (!selected) selected = installQoderCLI(provider);
|
|
728
|
+
if (!selected) return { ok: false, version: probe?.version || "unknown", executable };
|
|
729
|
+
const finalProbe = probeQoderVersionUntil(profile, selected, (p) => qoderVersionMeetsMinimum(p.version));
|
|
730
|
+
return { ok: qoderVersionMeetsMinimum(finalProbe.version), version: finalProbe.version, executable: selected };
|
|
721
731
|
}
|
|
722
732
|
|
|
723
733
|
// A missing or unreadable record means "no history", never a bootstrap failure.
|
|
@@ -1130,7 +1140,7 @@ async function ensureQoderReady(provider, options = {}) {
|
|
|
1130
1140
|
return false;
|
|
1131
1141
|
}
|
|
1132
1142
|
|
|
1133
|
-
const managedCopy = executable.startsWith(`${paths.managedDir}${path.sep}`);
|
|
1143
|
+
const managedCopy = generations.contains(generationOptions(profile), executable) || executable.startsWith(`${paths.managedDir}${path.sep}`);
|
|
1134
1144
|
|
|
1135
1145
|
// B — a managed copy that cannot run at all gets refreshed once.
|
|
1136
1146
|
if (verdict.state === "cli_unusable" && managedCopy && !refreshed) {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
// Schema and directory layout are shared with pkg/agent/qoder_install.go.
|
|
7
|
+
const GENERATION = /^gen-[a-zA-Z0-9_-]+$/;
|
|
8
|
+
|
|
9
|
+
function readPointer(root) {
|
|
10
|
+
try {
|
|
11
|
+
const pointer = JSON.parse(fs.readFileSync(path.join(root, "current.json"), "utf8"));
|
|
12
|
+
return pointer.schema === 1 ? pointer : {};
|
|
13
|
+
} catch { return {}; }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function executablePath(root, generation, executable) {
|
|
17
|
+
if (typeof generation !== "string" || !GENERATION.test(generation)) return "";
|
|
18
|
+
try {
|
|
19
|
+
const dir = path.join(root, generation);
|
|
20
|
+
const stat = fs.lstatSync(dir);
|
|
21
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) return "";
|
|
22
|
+
const bin = path.join(dir, "node_modules", ".bin", executable);
|
|
23
|
+
const relative = path.relative(fs.realpathSync(dir), fs.realpathSync(bin));
|
|
24
|
+
if (path.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path.sep}`)) return "";
|
|
25
|
+
return bin;
|
|
26
|
+
} catch { return ""; }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function current({ root, executable, verify }) {
|
|
30
|
+
const pointer = readPointer(root);
|
|
31
|
+
for (const generation of [pointer.generation, pointer.previous]) {
|
|
32
|
+
const bin = executablePath(root, generation, executable);
|
|
33
|
+
if (bin && verify(bin)) return bin;
|
|
34
|
+
}
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function contains({ root, executable }, bin) {
|
|
39
|
+
const parts = path.relative(root, bin).split(path.sep);
|
|
40
|
+
return parts.length === 4 && executablePath(root, parts[0], executable) === bin;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function install({ root, executable, install: runInstall, verify }) {
|
|
44
|
+
fs.mkdirSync(root, { recursive: true, mode: 0o700 });
|
|
45
|
+
const prefix = fs.mkdtempSync(path.join(root, "gen-"));
|
|
46
|
+
// Failure leaves an unselected directory. Never race a surviving npm helper
|
|
47
|
+
// by deleting its prefix; the next install owns a different directory.
|
|
48
|
+
if (!runInstall(prefix, executable)) {
|
|
49
|
+
throw new Error("private Qoder installation failed; previous generation retained");
|
|
50
|
+
}
|
|
51
|
+
const generation = path.basename(prefix);
|
|
52
|
+
const bin = executablePath(root, generation, executable);
|
|
53
|
+
if (!bin || !verify(bin)) {
|
|
54
|
+
throw new Error("private Qoder generation failed version verification; previous generation retained");
|
|
55
|
+
}
|
|
56
|
+
const previous = readPointer(root).generation;
|
|
57
|
+
const pointer = { schema: 1, generation };
|
|
58
|
+
if (typeof previous === "string" && GENERATION.test(previous)) pointer.previous = previous;
|
|
59
|
+
const tmp = path.join(root, `.current-${generation}`);
|
|
60
|
+
const fd = fs.openSync(tmp, "wx", 0o600);
|
|
61
|
+
try {
|
|
62
|
+
fs.writeFileSync(fd, JSON.stringify(pointer));
|
|
63
|
+
fs.fsyncSync(fd);
|
|
64
|
+
} finally { fs.closeSync(fd); }
|
|
65
|
+
try {
|
|
66
|
+
fs.renameSync(tmp, path.join(root, "current.json"));
|
|
67
|
+
} finally {
|
|
68
|
+
try { fs.unlinkSync(tmp); } catch {}
|
|
69
|
+
}
|
|
70
|
+
// Windows rename has platform-specific durability; the executable is always
|
|
71
|
+
// verified again on read, so a lost pointer after power loss triggers retry.
|
|
72
|
+
if (process.platform !== "win32") {
|
|
73
|
+
const directory = fs.openSync(root, "r");
|
|
74
|
+
try { fs.fsyncSync(directory); } finally { fs.closeSync(directory); }
|
|
75
|
+
}
|
|
76
|
+
return bin;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = { current, install, contains, executablePath };
|
package/bin/shared.js
CHANGED
|
@@ -29,7 +29,8 @@ function resolveUserPath(value) {
|
|
|
29
29
|
// spaces can never be split or misquoted by a shell.
|
|
30
30
|
function findOnPath(name) {
|
|
31
31
|
const isWin32 = process.platform === "win32";
|
|
32
|
-
|
|
32
|
+
// npm also writes a POSIX shim without an extension; prefer Windows entries.
|
|
33
|
+
const suffixes = isWin32 ? [".exe", ".cmd", ".bat", ".com", ""] : [""];
|
|
33
34
|
const entries = (process.env.PATH || process.env.Path || "").split(path.delimiter);
|
|
34
35
|
for (const entry of entries) {
|
|
35
36
|
if (!entry) continue;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Caller must own the proxy listener before changing this store.
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const crypto = require('crypto');
|
|
6
|
+
const { execFile } = require('child_process');
|
|
7
|
+
const { promisify } = require('util');
|
|
8
|
+
const run = promisify(execFile);
|
|
9
|
+
const GENERATION = /^gen-[0-9a-f-]{36}$/;
|
|
10
|
+
const OPENSSL_CANDIDATES = ['openssl', '/usr/bin/openssl', '/opt/homebrew/bin/openssl',
|
|
11
|
+
'C:\\Program Files\\Git\\usr\\bin\\openssl.exe', 'C:\\Program Files\\OpenSSL-Win64\\bin\\openssl.exe'];
|
|
12
|
+
let openssl;
|
|
13
|
+
async function resolveOpenSSL() {
|
|
14
|
+
if (openssl) return openssl;
|
|
15
|
+
for (const cmd of OPENSSL_CANDIDATES) {
|
|
16
|
+
try { await run(cmd, ['version'], { timeout: 5000, windowsHide: true }); openssl = cmd; return cmd; } catch (_) {}
|
|
17
|
+
}
|
|
18
|
+
throw new Error('TokenProxy requires OpenSSL; install it before enabling token tracking');
|
|
19
|
+
}
|
|
20
|
+
function validPair(cert, key) {
|
|
21
|
+
const x = new crypto.X509Certificate(cert);
|
|
22
|
+
if (!x.ca || !x.checkPrivateKey(crypto.createPrivateKey(key)) || Date.parse(x.validFrom) > Date.now() || Date.parse(x.validTo) <= Date.now()) throw new Error('Invalid or expired TokenProxy CA pair');
|
|
23
|
+
return { cert, key, fingerprint: crypto.createHash('sha256').update(x.raw).digest('hex') };
|
|
24
|
+
}
|
|
25
|
+
function readPair(certPath, keyPath) { return validPair(fs.readFileSync(certPath), fs.readFileSync(keyPath)); }
|
|
26
|
+
function readGeneration(root, name) {
|
|
27
|
+
if (!GENERATION.test(name || '')) throw new Error('Invalid TokenProxy generation');
|
|
28
|
+
const dir = path.join(root, name);
|
|
29
|
+
return { ...readPair(path.join(dir, 'ca.pem'), path.join(dir, 'key.pem')), generation: name,
|
|
30
|
+
certPath: path.join(dir, 'ca.pem'), keyPath: path.join(dir, 'key.pem'), cacheDir: path.join(dir, 'hosts') };
|
|
31
|
+
}
|
|
32
|
+
function newGeneration(root, pair) {
|
|
33
|
+
const name = `gen-${crypto.randomUUID()}`, dir = path.join(root, name);
|
|
34
|
+
fs.mkdirSync(dir, { mode: 0o700 });
|
|
35
|
+
fs.writeFileSync(path.join(dir, 'key.pem'), pair.key, { mode: 0o600, flag: 'wx' });
|
|
36
|
+
fs.writeFileSync(path.join(dir, 'ca.pem'), pair.cert, { mode: 0o600, flag: 'wx' });
|
|
37
|
+
return readGeneration(root, name);
|
|
38
|
+
}
|
|
39
|
+
function publish(root, current, backup) {
|
|
40
|
+
const file = path.join(root, `.current-${crypto.randomUUID()}.tmp`);
|
|
41
|
+
try {
|
|
42
|
+
fs.writeFileSync(file, JSON.stringify({ version: 1, generation: current.generation, fingerprint: current.fingerprint, backup: backup.generation }), { mode: 0o600 });
|
|
43
|
+
fs.renameSync(file, path.join(root, 'current.json'));
|
|
44
|
+
} finally { try { fs.unlinkSync(file); } catch (_) {} }
|
|
45
|
+
prune(root, new Set([current.generation, backup.generation]));
|
|
46
|
+
}
|
|
47
|
+
function prune(root, keep) {
|
|
48
|
+
// Failed publication and crash leftovers are bounded too, not just successful rotations.
|
|
49
|
+
const retired = fs.readdirSync(root).filter(n => GENERATION.test(n) && !keep.has(n))
|
|
50
|
+
.map(n => ({ n, time: fs.statSync(path.join(root, n)).mtimeMs })).sort((a, b) => b.time - a.time);
|
|
51
|
+
for (const { n } of retired.slice(6)) fs.rmSync(path.join(root, n), { recursive: true, force: true });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function generate(root) {
|
|
55
|
+
const dir = path.join(root, `gen-${crypto.randomUUID()}`);
|
|
56
|
+
fs.mkdirSync(dir, { mode: 0o700 });
|
|
57
|
+
const keyPath = path.join(dir, 'key.pem'), certPath = path.join(dir, 'ca.pem');
|
|
58
|
+
const config = path.join(dir, 'openssl.cnf');
|
|
59
|
+
fs.writeFileSync(config, '[req]\ndistinguished_name=dn\nx509_extensions=v3_ca\nprompt=no\n[dn]\nCN=AutoWonder Token Tap CA\n[v3_ca]\nbasicConstraints=critical,CA:TRUE\nkeyUsage=critical,keyCertSign,cRLSign\n', { mode: 0o600 });
|
|
60
|
+
try {
|
|
61
|
+
await run(await resolveOpenSSL(), ['req', '-new', '-x509', '-newkey', 'rsa:2048', '-nodes', '-keyout', keyPath, '-out', certPath, '-days', '3650', '-config', config], { timeout: 15000, windowsHide: true, maxBuffer: 1024 * 1024 });
|
|
62
|
+
fs.chmodSync(keyPath, 0o600);
|
|
63
|
+
return readGeneration(root, path.basename(dir));
|
|
64
|
+
} catch (e) { try { fs.rmSync(dir, { recursive: true, force: true }); } catch (_) {} throw e; }
|
|
65
|
+
}
|
|
66
|
+
async function updateManagedCA(dataDir) {
|
|
67
|
+
const root = path.join(dataDir, 'managed');
|
|
68
|
+
fs.mkdirSync(root, { recursive: true, mode: 0o700 });
|
|
69
|
+
// Written only by the native helper after validating the live legacy owner.
|
|
70
|
+
// Consume only after this service has bound the listener; publication is
|
|
71
|
+
// retryable if the helper/service dies before unlinking the bundle.
|
|
72
|
+
const takeover = path.join(dataDir, 'takeover-ca.json');
|
|
73
|
+
if (fs.existsSync(takeover)) {
|
|
74
|
+
let pair;
|
|
75
|
+
if (fs.statSync(takeover).size <= 2 * 1024 * 1024) {
|
|
76
|
+
const raw = fs.readFileSync(takeover, 'utf8');
|
|
77
|
+
try { const bundle = JSON.parse(raw); pair = validPair(bundle.cert, bundle.key); } catch (_) {}
|
|
78
|
+
}
|
|
79
|
+
if (pair) {
|
|
80
|
+
const active = newGeneration(root, pair), backup = newGeneration(root, pair);
|
|
81
|
+
publish(root, active, backup);
|
|
82
|
+
fs.unlinkSync(takeover);
|
|
83
|
+
return active;
|
|
84
|
+
}
|
|
85
|
+
// Invalid contents cannot establish trust. Existing managed recovery or
|
|
86
|
+
// a new generation handles this case; filesystem errors still retry.
|
|
87
|
+
fs.unlinkSync(takeover);
|
|
88
|
+
}
|
|
89
|
+
const pointer = path.join(root, 'current.json');
|
|
90
|
+
const alreadyManaged = fs.existsSync(pointer) || fs.readdirSync(root).some(n => GENERATION.test(n));
|
|
91
|
+
let meta, active, backup;
|
|
92
|
+
try { meta = JSON.parse(fs.readFileSync(pointer, 'utf8')); } catch (_) {}
|
|
93
|
+
prune(root, new Set(meta ? [meta.generation, meta.backup] : []));
|
|
94
|
+
if (meta && meta.version === 1) {
|
|
95
|
+
try { active = readGeneration(root, meta.generation); if (active.fingerprint !== meta.fingerprint) active = null; } catch (_) {}
|
|
96
|
+
try { backup = readGeneration(root, meta.backup); if (backup.fingerprint !== meta.fingerprint) backup = null; } catch (_) {}
|
|
97
|
+
}
|
|
98
|
+
if (active) {
|
|
99
|
+
if (!backup) { backup = newGeneration(root, active); publish(root, active, backup); }
|
|
100
|
+
return active;
|
|
101
|
+
}
|
|
102
|
+
if (backup) active = newGeneration(root, backup);
|
|
103
|
+
// Only the initial migration imports the legacy CA. A stale legacy file must
|
|
104
|
+
// never roll an already-managed installation back to a retired trust root.
|
|
105
|
+
if (!active && !alreadyManaged) {
|
|
106
|
+
try { active = newGeneration(root, readPair(path.join(dataDir, 'ca-cert.pem'), path.join(dataDir, 'ca-key.pem'))); } catch (_) {}
|
|
107
|
+
}
|
|
108
|
+
if (!active) active = await generate(root);
|
|
109
|
+
if (!backup || backup.fingerprint !== active.fingerprint) backup = newGeneration(root, active);
|
|
110
|
+
publish(root, active, backup);
|
|
111
|
+
return active;
|
|
112
|
+
}
|
|
113
|
+
async function ensureManagedCA(dataDir) {
|
|
114
|
+
const root = path.join(dataDir, 'managed');
|
|
115
|
+
fs.mkdirSync(root, { recursive: true, mode: 0o700 });
|
|
116
|
+
const before = new Set(fs.readdirSync(root));
|
|
117
|
+
try { return await updateManagedCA(dataDir); }
|
|
118
|
+
catch (error) {
|
|
119
|
+
let published = {};
|
|
120
|
+
try { published = JSON.parse(fs.readFileSync(path.join(root, 'current.json'), 'utf8')); } catch (_) {}
|
|
121
|
+
for (const name of fs.readdirSync(root)) {
|
|
122
|
+
if (GENERATION.test(name) && !before.has(name) && name !== published.generation && name !== published.backup) {
|
|
123
|
+
try { fs.rmSync(path.join(root, name), { recursive: true, force: true }); } catch (_) {}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
module.exports = { ensureManagedCA, resolveOpenSSL, validPair };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
const net = require('net');
|
|
4
|
+
const crypto = require('crypto');
|
|
5
|
+
function runHelper(cfg, action, { timeoutMs = 25000, stopped = () => false } = {}) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const child = spawn(cfg.helper, ['token-proxy-helper', action], { windowsHide: true, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
8
|
+
let out = '', err = '', done = false;
|
|
9
|
+
const finish = (error, value) => { if (done) return; done = true; clearTimeout(timer); clearInterval(cancelPoll); error ? reject(error) : resolve(value); };
|
|
10
|
+
const timer = setTimeout(() => { child.kill('SIGKILL'); finish(new Error('TokenProxy helper exceeded hard deadline')); }, timeoutMs);
|
|
11
|
+
const cancelPoll = setInterval(() => { if (stopped()) { child.kill('SIGKILL'); finish(new Error('TokenProxy helper cancelled')); } }, 100);
|
|
12
|
+
child.on('error', finish);
|
|
13
|
+
child.stdin.on('error', () => {});
|
|
14
|
+
child.stdout.on('data', b => { out += b; if (out.length > 65536) { child.kill('SIGKILL'); finish(new Error('TokenProxy helper output too large')); } });
|
|
15
|
+
child.stderr.on('data', b => { err = (err + b).slice(-4096); });
|
|
16
|
+
child.on('close', code => {
|
|
17
|
+
if (code !== 0) return finish(new Error(`TokenProxy helper failed: ${err.trim() || code}`));
|
|
18
|
+
try { const result = JSON.parse(out); if (!result || typeof result.state !== 'string') throw new Error('missing state'); finish(null, result); }
|
|
19
|
+
catch (_) { finish(new Error('Invalid TokenProxy helper response')); }
|
|
20
|
+
});
|
|
21
|
+
child.stdin.end(JSON.stringify({ debug: Boolean(cfg.debug), port: cfg.port, dataDir: cfg.dataDir, baseDir: cfg.baseDir, scope: cfg.scope,
|
|
22
|
+
nodePath: process.execPath, scriptPath: require('path').join(__dirname, 'token-proxy.js') }));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
// Local forwarding is checked separately from health so a responsive health
|
|
26
|
+
// endpoint cannot conceal a stalled CONNECT handler. Never touches the model.
|
|
27
|
+
function forwardingHealthy(port, timeoutMs = 1500) {
|
|
28
|
+
return new Promise(resolve => {
|
|
29
|
+
const sockets = new Set(); let done = false, timer;
|
|
30
|
+
const server = net.createServer(s => { sockets.add(s); s.on('error', () => finish(false)); s.on('data', b => s.write(b)); });
|
|
31
|
+
const finish = value => { if (done) return; done = true; clearTimeout(timer); for (const s of sockets) s.destroy(); server.close(); resolve(value); };
|
|
32
|
+
timer = setTimeout(() => finish(false), timeoutMs);
|
|
33
|
+
server.on('error', () => finish(false));
|
|
34
|
+
server.listen(0, '127.0.0.1', () => {
|
|
35
|
+
if (done) { server.close(); return; }
|
|
36
|
+
const target = `127.0.0.1:${server.address().port}`;
|
|
37
|
+
const s = net.connect(port, '127.0.0.1'); sockets.add(s);
|
|
38
|
+
let buf = Buffer.alloc(0), connected = false; const nonce = crypto.randomBytes(32);
|
|
39
|
+
s.on('error', () => finish(false)); s.on('end', () => finish(false));
|
|
40
|
+
s.on('connect', () => s.write(`CONNECT ${target} HTTP/1.1\r\nHost: ${target}\r\n\r\n`));
|
|
41
|
+
s.on('data', b => {
|
|
42
|
+
buf = Buffer.concat([buf, b]); if (buf.length > 8192) return finish(false);
|
|
43
|
+
if (!connected) { const end = buf.indexOf('\r\n\r\n'); if (end < 0) return;
|
|
44
|
+
if (!buf.toString('ascii', 0, end).startsWith('HTTP/1.1 200 ')) return finish(false);
|
|
45
|
+
connected = true; buf = buf.subarray(end + 4); s.write(nonce);
|
|
46
|
+
}
|
|
47
|
+
if (buf.length >= 32) finish(buf.equals(nonce));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
module.exports = { runHelper, forwardingHealthy };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const http = require('http');
|
|
6
|
+
const crypto = require('crypto');
|
|
7
|
+
const { spawn } = require('child_process');
|
|
8
|
+
const HEALTH_PATH = '/__autowonder_token_proxy/health';
|
|
9
|
+
const SERVICE = 'autowonder-token-proxy';
|
|
10
|
+
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
11
|
+
function configuration({ port = process.env.TOKEN_PROXY_PORT || 19876, dataDir = path.join(os.homedir(), '.autowonder', 'token-tap') } = {}) {
|
|
12
|
+
port = Number(port);
|
|
13
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error('TOKEN_PROXY_PORT must be an integer between 1 and 65535');
|
|
14
|
+
const baseDir = path.resolve(dataDir);
|
|
15
|
+
if (port !== 19876) dataDir = path.join(baseDir, 'ports', String(port));
|
|
16
|
+
fs.mkdirSync(dataDir, { recursive: true, mode: 0o700 });
|
|
17
|
+
dataDir = fs.realpathSync(dataDir);
|
|
18
|
+
return { port, dataDir, baseDir, scope: crypto.createHash('sha256').update(dataDir).digest('hex') };
|
|
19
|
+
}
|
|
20
|
+
function probeProxy(cfg) {
|
|
21
|
+
return new Promise(resolve => {
|
|
22
|
+
let timer;
|
|
23
|
+
const finish = value => { clearTimeout(timer); resolve(value); };
|
|
24
|
+
const req = http.get({ hostname: '127.0.0.1', port: cfg.port, path: HEALTH_PATH, agent: false, timeout: 1500 }, res => {
|
|
25
|
+
if (res.statusCode === 405) { res.resume(); finish({ state: 'legacy' }); return; }
|
|
26
|
+
let body = '';
|
|
27
|
+
res.on('data', b => { body += b; if (body.length > 16384) { finish({ state: 'foreign' }); res.destroy(); } });
|
|
28
|
+
res.on('error', () => finish({ state: 'unresponsive' }));
|
|
29
|
+
res.on('end', () => { try { finish(JSON.parse(body)); } catch (_) { finish({ state: 'foreign' }); } });
|
|
30
|
+
});
|
|
31
|
+
timer = setTimeout(() => { finish({ state: 'unresponsive' }); req.destroy(); }, 1500);
|
|
32
|
+
timer.unref();
|
|
33
|
+
req.on('timeout', () => req.destroy());
|
|
34
|
+
req.on('error', e => finish({ state: e.code === 'ECONNREFUSED' ? 'absent' : 'unresponsive' }));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function classify(h, cfg) {
|
|
38
|
+
if (!h || typeof h !== 'object') return 'foreign';
|
|
39
|
+
if (h.service === SERVICE) {
|
|
40
|
+
if (h.protocol !== 1 || h.scope !== cfg.scope) return 'incompatible';
|
|
41
|
+
if (h.state === 'ready' && (!/^gen-[0-9a-f-]{36}$/.test(h.generation || '') || !/^[0-9a-f]{64}$/.test(h.fingerprint || ''))) return 'incompatible';
|
|
42
|
+
return h.state;
|
|
43
|
+
}
|
|
44
|
+
return ['absent', 'unresponsive'].includes(h.state) ? h.state : 'foreign';
|
|
45
|
+
}
|
|
46
|
+
function launchProxy(cfg) {
|
|
47
|
+
const child = spawn(process.execPath, [path.join(__dirname, 'token-proxy.js'), 'start', '--managed', '--port', String(cfg.port)], {
|
|
48
|
+
detached: true, windowsHide: true, stdio: 'ignore',
|
|
49
|
+
env: { ...process.env, AUTOWONDER_TOKEN_PROXY_DATA_DIR: cfg.dataDir, AUTOWONDER_TOKEN_PROXY_BASE_DIR: cfg.baseDir, ...(cfg.debug ? { AUTOWONDER_DEBUG: "1" } : {}) },
|
|
50
|
+
});
|
|
51
|
+
// spawn errors are asynchronous; always attach a listener even when detached.
|
|
52
|
+
const started = new Promise((resolve, reject) => { child.once('spawn', resolve); child.once('error', reject); });
|
|
53
|
+
child.unref();
|
|
54
|
+
return started;
|
|
55
|
+
}
|
|
56
|
+
async function ensureSharedProxy(cfg, { timeoutMs = 30000, stopped = () => false, monitorOnly = false } = {}) {
|
|
57
|
+
const deadline = Date.now() + timeoutMs;
|
|
58
|
+
if (cfg.helper) {
|
|
59
|
+
const { runHelper, forwardingHealthy } = require('./token-proxy-helper');
|
|
60
|
+
let last;
|
|
61
|
+
while (!stopped() && Date.now() < deadline) {
|
|
62
|
+
const health = await probeProxy(cfg);
|
|
63
|
+
const state = classify(health, cfg);
|
|
64
|
+
const cached = cfg.verified;
|
|
65
|
+
if (monitorOnly && cached && Date.now() - cached.at < 30000 &&
|
|
66
|
+
((state === 'ready' && health.instanceId === cached.value.instanceId && health.fingerprint === cached.value.fingerprint) ||
|
|
67
|
+
(health.state === 'legacy' && cached.value.state === 'legacy')) && await forwardingHealthy(cfg.port)) return cached.value;
|
|
68
|
+
const remaining = deadline - Date.now();
|
|
69
|
+
if (remaining <= 0 || stopped()) break;
|
|
70
|
+
last = await runHelper(cfg, 'recover', { timeoutMs: Math.min(25000, remaining), stopped });
|
|
71
|
+
if (['ready', 'legacy'].includes(last.state)) {
|
|
72
|
+
cfg.verified = { at: Date.now(), value: last };
|
|
73
|
+
return last;
|
|
74
|
+
}
|
|
75
|
+
if (!['starting', 'blocked', 'absent', 'unresponsive'].includes(last.state)) throw new Error(`TokenProxy cannot be admitted (${last.state})`);
|
|
76
|
+
await sleep(500);
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`TokenProxy is not ready (${last && last.state || 'unavailable'})`);
|
|
79
|
+
}
|
|
80
|
+
let nextSpawn = 0, attempts = 0, last;
|
|
81
|
+
while (!stopped() && Date.now() < deadline) {
|
|
82
|
+
last = await probeProxy(cfg);
|
|
83
|
+
const state = classify(last, cfg);
|
|
84
|
+
if (state === 'ready') return last;
|
|
85
|
+
if (state === 'foreign' || state === 'incompatible') throw new Error(`TokenProxy port ${cfg.port} is occupied by a legacy, foreign or incompatible service; drain and migrate the old executors without terminating other users' processes`);
|
|
86
|
+
if (state === 'absent' && Date.now() >= nextSpawn) {
|
|
87
|
+
await sleep(50 + Math.random() * 200);
|
|
88
|
+
if (stopped()) break;
|
|
89
|
+
if (classify(await probeProxy(cfg), cfg) === 'absent' && !stopped()) {
|
|
90
|
+
await launchProxy(cfg);
|
|
91
|
+
nextSpawn = Date.now() + Math.min(10000, 1000 * 2 ** Math.min(attempts++, 4));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
await sleep(200);
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`TokenProxy is not ready (${last && last.state || 'unavailable'}); see ${path.join(cfg.dataDir, 'lifecycle.log')}`);
|
|
97
|
+
}
|
|
98
|
+
function watchSharedProxy(cfg, log = () => {}, { intervalMs = 2000 } = {}) {
|
|
99
|
+
let stopped = false, timer, previous = '';
|
|
100
|
+
const tick = async () => {
|
|
101
|
+
if (stopped) return;
|
|
102
|
+
try {
|
|
103
|
+
const h = await ensureSharedProxy(cfg, { timeoutMs: 10000, stopped: () => stopped, monitorOnly: true });
|
|
104
|
+
const status = `ready:${h.instanceId}:${h.fingerprint}`;
|
|
105
|
+
if (status !== previous && !stopped) { log(`Shared TokenProxy ready on ${cfg.port}`); previous = status; }
|
|
106
|
+
} catch (e) {
|
|
107
|
+
if (!stopped && previous !== e.message) { log(`WARN: ${e.message}`); previous = e.message; }
|
|
108
|
+
}
|
|
109
|
+
if (!stopped) { timer = setTimeout(tick, intervalMs); timer.unref(); }
|
|
110
|
+
};
|
|
111
|
+
timer = setTimeout(tick, intervalMs); timer.unref();
|
|
112
|
+
return () => { stopped = true; clearTimeout(timer); };
|
|
113
|
+
}
|
|
114
|
+
module.exports = { configuration, probeProxy, ensureSharedProxy, watchSharedProxy, classify, HEALTH_PATH, SERVICE };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
const { configuration, HEALTH_PATH, SERVICE } = require('./token-proxy-manager');
|
|
5
|
+
const { ensureManagedCA, resolveOpenSSL } = require('./token-proxy-ca');
|
|
6
|
+
async function startManagedProxy(port) {
|
|
7
|
+
const { createProxyServer, getHostCert, createRotatingWriter, installDiagLog } = require('./token-proxy');
|
|
8
|
+
const cfg = configuration({ port, dataDir: process.env.AUTOWONDER_TOKEN_PROXY_BASE_DIR });
|
|
9
|
+
let ca, state = 'starting', retry = 0, timer, closed = false, failure = '', writer;
|
|
10
|
+
const instanceId = crypto.randomUUID();
|
|
11
|
+
const server = createProxyServer({ ca: {}, hostCertificate: host => getHostCert(host, ca) });
|
|
12
|
+
const handlers = server.listeners('connect');
|
|
13
|
+
server.removeAllListeners('connect');
|
|
14
|
+
server.on('connect', (...args) => {
|
|
15
|
+
if (state !== 'ready') { args[1].end('HTTP/1.1 503 TokenProxy recovering\r\nConnection: close\r\n\r\n'); return; }
|
|
16
|
+
for (const handler of handlers) handler(...args);
|
|
17
|
+
});
|
|
18
|
+
server.removeAllListeners('request');
|
|
19
|
+
server.on('request', (req, res) => {
|
|
20
|
+
if (req.method !== 'GET' || req.url !== HEALTH_PATH) { res.writeHead(405); res.end(); return; }
|
|
21
|
+
res.setHeader('Content-Type', 'application/json');
|
|
22
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
23
|
+
res.end(JSON.stringify({ service: SERVICE, protocol: 1, scope: cfg.scope, state, instanceId,
|
|
24
|
+
pid: process.pid, fingerprint: ca && ca.fingerprint, generation: ca && ca.generation, error: failure }));
|
|
25
|
+
});
|
|
26
|
+
server.on('error', e => {
|
|
27
|
+
// Losing a bind race is normal; losers never touch shared CA/log files.
|
|
28
|
+
if (e.code !== 'EADDRINUSE') console.error(`[token-proxy] listen failed: ${e.code || e.message}`);
|
|
29
|
+
process.exit(e.code === 'EADDRINUSE' ? 0 : 1);
|
|
30
|
+
});
|
|
31
|
+
await new Promise(resolve => server.listen({ host: '127.0.0.1', port: cfg.port, exclusive: true }, resolve));
|
|
32
|
+
try { installDiagLog(); } catch (_) {}
|
|
33
|
+
try { writer = createRotatingWriter(path.join(cfg.dataDir, 'lifecycle.log'), { maxBytes: 4 * 1024 * 1024, maxArchives: 3 }); } catch (_) {}
|
|
34
|
+
const log = message => writer && writer.write(`${new Date().toISOString()} pid=${process.pid} instance=${instanceId} ${message}\n`);
|
|
35
|
+
log(`listening port=${cfg.port}`);
|
|
36
|
+
const maintain = async () => {
|
|
37
|
+
try {
|
|
38
|
+
const next = await ensureManagedCA(cfg.dataDir);
|
|
39
|
+
next.openssl = await resolveOpenSSL();
|
|
40
|
+
if (!ca || ca.generation !== next.generation) log(`ready generation=${next.generation}`);
|
|
41
|
+
ca = next; state = 'ready'; retry = 0; failure = '';
|
|
42
|
+
} catch (e) {
|
|
43
|
+
state = 'blocked'; failure = String(e.code || 'CA_INITIALIZATION_FAILED');
|
|
44
|
+
log(`blocked reason=${failure}`);
|
|
45
|
+
retry++;
|
|
46
|
+
}
|
|
47
|
+
if (!closed) {
|
|
48
|
+
timer = setTimeout(maintain, state === 'ready' ? 15000 : Math.min(30000, 1000 * 2 ** Math.min(retry, 5)));
|
|
49
|
+
timer.unref();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const shutdown = () => { closed = true; clearTimeout(timer); log('shutdown'); server.close(); process.exit(0); };
|
|
53
|
+
process.on('SIGINT', shutdown); process.on('SIGTERM', shutdown);
|
|
54
|
+
await maintain();
|
|
55
|
+
return server;
|
|
56
|
+
}
|
|
57
|
+
module.exports = { startManagedProxy };
|
package/bin/token-proxy.js
CHANGED
|
@@ -35,7 +35,7 @@ const MAX_LOG_SIZE = 10 * 1024 * 1024; // 10MB, then rotate
|
|
|
35
35
|
const DEFAULT_LOG_MAX_BYTES = 100 * 1024 * 1024; // 100MiB, then rotate
|
|
36
36
|
const LOG_MAX_BYTES = intEnv('AUTOWONDER_LOG_MAX_BYTES', DEFAULT_LOG_MAX_BYTES);
|
|
37
37
|
const RAW_LOG_MAX_BYTES = intEnv('AUTOWONDER_RAW_LOG_MAX_BYTES', DEFAULT_LOG_MAX_BYTES);
|
|
38
|
-
const DATA_DIR = path.join(os.homedir(), '.autowonder', 'token-tap');
|
|
38
|
+
const DATA_DIR = process.env.AUTOWONDER_TOKEN_PROXY_DATA_DIR || path.join(os.homedir(), '.autowonder', 'token-tap');
|
|
39
39
|
const CA_KEY_PATH = path.join(DATA_DIR, 'ca-key.pem');
|
|
40
40
|
const CA_CERT_PATH = path.join(DATA_DIR, 'ca-cert.pem');
|
|
41
41
|
const USAGE_LOG_PATH = path.join(DATA_DIR, 'token-usage.jsonl');
|
|
@@ -79,7 +79,7 @@ function shouldSniffHost(hostname, exactHosts = SNIFF_HOSTS, suffixes = SNIFF_HO
|
|
|
79
79
|
// a name carrying the timestamp and pid, and reopens a fresh file at the same
|
|
80
80
|
// path. A live descriptor is never truncated or unlinked, so no diagnostic
|
|
81
81
|
// line is lost mid-write.
|
|
82
|
-
function createRotatingWriter(filePath, { maxBytes = DEFAULT_LOG_MAX_BYTES } = {}) {
|
|
82
|
+
function createRotatingWriter(filePath, { maxBytes = DEFAULT_LOG_MAX_BYTES, maxArchives = 0 } = {}) {
|
|
83
83
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
84
84
|
let fd = fs.openSync(filePath, 'a', 0o600);
|
|
85
85
|
let size = fs.fstatSync(fd).size;
|
|
@@ -108,6 +108,11 @@ function createRotatingWriter(filePath, { maxBytes = DEFAULT_LOG_MAX_BYTES } = {
|
|
|
108
108
|
fs.closeSync(fd);
|
|
109
109
|
try {
|
|
110
110
|
fs.renameSync(filePath, archivePath());
|
|
111
|
+
if (maxArchives > 0) {
|
|
112
|
+
const ext = path.extname(filePath), prefix = path.basename(filePath, ext) + '.';
|
|
113
|
+
const entries = fs.readdirSync(path.dirname(filePath)).filter(n => n.startsWith(prefix) && n.endsWith(ext) && n !== path.basename(filePath)).sort().reverse();
|
|
114
|
+
for (const name of entries.slice(maxArchives)) { try { fs.unlinkSync(path.join(path.dirname(filePath), name)); } catch (_) {} }
|
|
115
|
+
}
|
|
111
116
|
} catch (_) {
|
|
112
117
|
// Archive failure keeps the live file in place; the incoming line
|
|
113
118
|
// still has to land somewhere.
|
|
@@ -231,15 +236,20 @@ function isCertExpired(certPath) {
|
|
|
231
236
|
}
|
|
232
237
|
|
|
233
238
|
function getHostCert(hostname, ca) {
|
|
234
|
-
if (
|
|
239
|
+
if (!/^[a-zA-Z0-9.-]+$/.test(hostname)) return null;
|
|
240
|
+
if (hostCertCache.size > 256) hostCertCache.clear();
|
|
241
|
+
const cacheKey = `${ca.fingerprint || 'legacy'}:${hostname}`;
|
|
242
|
+
if (hostCertCache.has(cacheKey)) return hostCertCache.get(cacheKey);
|
|
243
|
+
const certDir = ca.cacheDir || DATA_DIR;
|
|
244
|
+
fs.mkdirSync(certDir, { recursive: true, mode: 0o700 });
|
|
235
245
|
|
|
236
|
-
const certPath = path.join(
|
|
237
|
-
const keyPath = path.join(
|
|
246
|
+
const certPath = path.join(certDir, `${hostname}.pem`);
|
|
247
|
+
const keyPath = path.join(certDir, `${hostname}-key.pem`);
|
|
238
248
|
|
|
239
249
|
// Return cached cert from disk if still valid
|
|
240
250
|
const onDisk = readCertPair(certPath, keyPath);
|
|
241
251
|
if (onDisk && !isCertExpired(certPath)) {
|
|
242
|
-
hostCertCache.set(
|
|
252
|
+
hostCertCache.set(cacheKey, onDisk);
|
|
243
253
|
return onDisk;
|
|
244
254
|
}
|
|
245
255
|
if (!onDisk) {
|
|
@@ -258,27 +268,27 @@ function getHostCert(hostname, ca) {
|
|
|
258
268
|
const { execFileSync } = require('child_process');
|
|
259
269
|
// Per-process temp names keep two proxies that share one data dir from
|
|
260
270
|
// overwriting each other's signing inputs.
|
|
261
|
-
const csrPath = path.join(
|
|
262
|
-
const extPath = path.join(
|
|
271
|
+
const csrPath = path.join(certDir, `${hostname}.${process.pid}.csr`);
|
|
272
|
+
const extPath = path.join(certDir, `${hostname}.${process.pid}.ext`);
|
|
263
273
|
fs.writeFileSync(keyPath, privateKey, { mode: 0o600 });
|
|
264
274
|
fs.writeFileSync(extPath, `[v3_ext]\nsubjectAltName=DNS:${hostname}\n`, { mode: 0o600 });
|
|
265
275
|
|
|
266
276
|
// A per-signing random serial removes the shared ca-cert.srl file that
|
|
267
277
|
// concurrent signings used to race on. The ext file is a real path because
|
|
268
278
|
// openssl cannot reopen /dev/stdin when stdin is a Node pipe.
|
|
269
|
-
const sign = extraArgs => execFileSync('openssl', [
|
|
270
|
-
'x509', '-req', '-in', csrPath, '-CA', CA_CERT_PATH, '-CAkey', CA_KEY_PATH,
|
|
279
|
+
const sign = extraArgs => execFileSync(ca.openssl || 'openssl', [
|
|
280
|
+
'x509', '-req', '-in', csrPath, '-CA', ca.certPath || CA_CERT_PATH, '-CAkey', ca.keyPath || CA_KEY_PATH,
|
|
271
281
|
'-set_serial', `0x${crypto.randomBytes(16).toString('hex')}`,
|
|
272
282
|
'-out', certPath, '-days', '365', ...extraArgs,
|
|
273
|
-
], { stdio: 'pipe' });
|
|
283
|
+
], { stdio: 'pipe', timeout: 15000, windowsHide: true });
|
|
274
284
|
|
|
275
285
|
try {
|
|
276
|
-
execFileSync('openssl', ['req', '-new', '-key', keyPath, '-out', csrPath, '-subj', `/CN=${hostname}`], { stdio: 'pipe' });
|
|
286
|
+
execFileSync(ca.openssl || 'openssl', ['req', '-new', '-key', keyPath, '-out', csrPath, '-subj', `/CN=${hostname}`], { stdio: 'pipe', timeout: 15000, windowsHide: true });
|
|
277
287
|
sign(['-extfile', extPath, '-extensions', 'v3_ext']);
|
|
278
288
|
} catch (_) {
|
|
279
289
|
// Windows fallback: without SAN extension
|
|
280
290
|
try {
|
|
281
|
-
execFileSync('openssl', ['req', '-new', '-key', keyPath, '-out', csrPath, '-subj', `/CN=${hostname}`], { stdio: 'pipe' });
|
|
291
|
+
execFileSync(ca.openssl || 'openssl', ['req', '-new', '-key', keyPath, '-out', csrPath, '-subj', `/CN=${hostname}`], { stdio: 'pipe', timeout: 15000, windowsHide: true });
|
|
282
292
|
sign([]);
|
|
283
293
|
} catch (e2) {
|
|
284
294
|
// Cannot generate host cert — report and fall back to a blind tunnel.
|
|
@@ -299,7 +309,7 @@ function getHostCert(hostname, ca) {
|
|
|
299
309
|
try { fs.unlinkSync(extPath); } catch (_) {}
|
|
300
310
|
return null;
|
|
301
311
|
}
|
|
302
|
-
hostCertCache.set(
|
|
312
|
+
hostCertCache.set(cacheKey, result);
|
|
303
313
|
// Cleanup temp files
|
|
304
314
|
try { fs.unlinkSync(csrPath); } catch (_) {}
|
|
305
315
|
try { fs.unlinkSync(extPath); } catch (_) {}
|
|
@@ -1100,7 +1110,9 @@ if (require.main === module) {
|
|
|
1100
1110
|
if (command === 'start') {
|
|
1101
1111
|
const portIdx = args.indexOf('--port');
|
|
1102
1112
|
const port = portIdx >= 0 ? parseInt(args[portIdx + 1]) : DEFAULT_PORT;
|
|
1103
|
-
|
|
1113
|
+
if (args.includes('--managed')) {
|
|
1114
|
+
setImmediate(() => require('./token-proxy-service').startManagedProxy(port).catch(e => { console.error(e.message); process.exit(1); }));
|
|
1115
|
+
} else { startProxy(port); }
|
|
1104
1116
|
} else if (command === 'query') {
|
|
1105
1117
|
const jsonFlag = args.includes('--json');
|
|
1106
1118
|
const sinceIdx = args.indexOf('--since');
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
param(
|
|
2
2
|
[Parameter(Mandatory = $true)][int]$TimeoutMs,
|
|
3
3
|
[Parameter(Mandatory = $true)][string]$Executable,
|
|
4
|
-
[Parameter(Mandatory = $true)][string]$ArgsBase64
|
|
4
|
+
[Parameter(Mandatory = $true)][string]$ArgsBase64,
|
|
5
|
+
[switch]$VerbatimArguments
|
|
5
6
|
)
|
|
6
7
|
|
|
7
8
|
$ErrorActionPreference = "Stop"
|
|
8
9
|
$argumentJson = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($ArgsBase64))
|
|
9
|
-
|
|
10
|
+
# Windows PowerShell 5.1 emits the JSON array as one pipeline object.
|
|
11
|
+
# Capture it directly so string[] conversion preserves argument boundaries.
|
|
12
|
+
[string[]]$childArguments = ConvertFrom-Json $argumentJson
|
|
10
13
|
|
|
11
14
|
if (-not ("AutoWonder.WindowsJobRunner" -as [type])) {
|
|
12
15
|
Add-Type -TypeDefinition @'
|
|
@@ -76,7 +79,7 @@ namespace AutoWonder {
|
|
|
76
79
|
result.Append('\\', slashes * 2).Append('"'); return result.ToString();
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
public static int Run(string executable, string[] args, int timeoutMs) {
|
|
82
|
+
public static int Run(string executable, string[] args, int timeoutMs, bool verbatimArguments) {
|
|
80
83
|
IntPtr job = IntPtr.Zero; PROCESS_INFORMATION process = new PROCESS_INFORMATION();
|
|
81
84
|
try {
|
|
82
85
|
job = CreateJobObject(IntPtr.Zero, null);
|
|
@@ -91,7 +94,7 @@ namespace AutoWonder {
|
|
|
91
94
|
} finally { Marshal.FreeHGlobal(limitsPtr); }
|
|
92
95
|
|
|
93
96
|
var command = new StringBuilder(Quote(executable));
|
|
94
|
-
foreach (string arg in args ?? new string[0]) command.Append(' ').Append(Quote(arg ?? ""));
|
|
97
|
+
foreach (string arg in args ?? new string[0]) command.Append(' ').Append(verbatimArguments ? (arg ?? "") : Quote(arg ?? ""));
|
|
95
98
|
var startup = new STARTUPINFO(); startup.cb = Marshal.SizeOf(startup);
|
|
96
99
|
startup.dwFlags = STARTF_USESTDHANDLES;
|
|
97
100
|
startup.hStdInput = GetStdHandle(-10); startup.hStdOutput = GetStdHandle(-11); startup.hStdError = GetStdHandle(-12);
|
|
@@ -122,5 +125,5 @@ namespace AutoWonder {
|
|
|
122
125
|
'@
|
|
123
126
|
}
|
|
124
127
|
|
|
125
|
-
try { exit [AutoWonder.WindowsJobRunner]::Run($Executable, $childArguments, $TimeoutMs) }
|
|
128
|
+
try { exit [AutoWonder.WindowsJobRunner]::Run($Executable, $childArguments, $TimeoutMs, $VerbatimArguments.IsPresent) }
|
|
126
129
|
catch { [Console]::Error.WriteLine($_.Exception.ToString()); exit 125 }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/autowonder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.34",
|
|
4
4
|
"description": "AutoWonder local runtime — execute AI agent dispatch packages on your machine",
|
|
5
5
|
"bin": {
|
|
6
6
|
"autowonder": "bin/cli.js"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public",
|
|
32
|
-
"registry": "https://registry.npmjs.org",
|
|
33
|
-
"tag": "
|
|
32
|
+
"registry": "https://registry.npmjs.org/",
|
|
33
|
+
"tag": "latest"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": ">=16"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|