@autocodeflow/cli 1.11.0 → 1.12.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/dist/client.d.ts +3 -1
- package/dist/client.js +19 -6
- package/dist/commands/apps.js +5 -1
- package/dist/commands/tasks.js +12 -2
- package/dist/config.js +1 -1
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export declare const ANALYZE_TIMEOUT_MS = 120000;
|
|
|
15
15
|
* (axios per-request timeout 覆盖实例默认,其余端点维持 30s)。
|
|
16
16
|
*/
|
|
17
17
|
export declare const UPLOAD_TIMEOUT_MS = 300000;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Reset client (needed after config changes in same process).
|
|
20
|
+
*/
|
|
19
21
|
export declare function resetClient(): void;
|
|
20
22
|
export declare function unwrap<T>(raw: unknown): T;
|
|
21
23
|
/**
|
package/dist/client.js
CHANGED
|
@@ -21,11 +21,9 @@ export const ANALYZE_TIMEOUT_MS = 120_000;
|
|
|
21
21
|
* (axios per-request timeout 覆盖实例默认,其余端点维持 30s)。
|
|
22
22
|
*/
|
|
23
23
|
export const UPLOAD_TIMEOUT_MS = 300_000;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
/** Reset client (needed after config changes in same process). */
|
|
24
|
+
/**
|
|
25
|
+
* Reset client (needed after config changes in same process).
|
|
26
|
+
*/
|
|
29
27
|
export function resetClient() {
|
|
30
28
|
_client = null;
|
|
31
29
|
}
|
|
@@ -64,12 +62,27 @@ export function unwrap(raw) {
|
|
|
64
62
|
// - 非幂等请求重放与 DR-06 的区分:重放只发生在「401=请求从未到达业务层
|
|
65
63
|
// 被拒」的认证态,不是业务副作用重试,单次重放安全。
|
|
66
64
|
let refreshInFlight = null;
|
|
65
|
+
/**
|
|
66
|
+
* 刷新 access token。
|
|
67
|
+
*
|
|
68
|
+
* BUG-13 的原始自愈逻辑:401 → POST /auth/refresh → 拿到新 token 后重放。
|
|
69
|
+
*
|
|
70
|
+
* **NETOPT-7(审计 P1-4,2026-10-17)**:此前这里用裸 `baseUrl()` 拼接,
|
|
71
|
+
* 而 admin-api 有全局 `api` 前缀(main.ts setGlobalPrefix)——请求实际打到
|
|
72
|
+
* `http://host:3105/auth/refresh`(缺 `/api`)→ **404** → catch 吞掉 → 返回
|
|
73
|
+
* null → 调用方 `clearAuth()` 把 access + refresh token 一起清空。也就是说
|
|
74
|
+
* **每一次正常的令牌过期都会把用户登出**,用户被迫重新 `acf login`(而
|
|
75
|
+
* refresh token 本身还有 30 天寿命、完全有效)。
|
|
76
|
+
*
|
|
77
|
+
* 修复:走与其它请求同一个归一入口 `normalizeApiBase(getApiUrl())`,
|
|
78
|
+
* 两条路径的 base 永远一致(同源漂移已被本缺陷证明代价极高)。
|
|
79
|
+
*/
|
|
67
80
|
async function refreshAccessToken() {
|
|
68
81
|
const refreshToken = getRefreshToken();
|
|
69
82
|
if (!refreshToken)
|
|
70
83
|
return null;
|
|
71
84
|
try {
|
|
72
|
-
const r = await axios.post(`${
|
|
85
|
+
const r = await axios.post(`${normalizeApiBase(getApiUrl())}/auth/refresh`, { refreshToken }, { timeout: 10_000 });
|
|
73
86
|
const data = unwrap(r.data);
|
|
74
87
|
if (typeof data?.accessToken === "string" && data.accessToken.length > 0) {
|
|
75
88
|
setToken(data.accessToken);
|
package/dist/commands/apps.js
CHANGED
|
@@ -171,7 +171,11 @@ export function appsCommand() {
|
|
|
171
171
|
// form-data 依赖。字段名 file/name/runtime/version 是服务端 multer +
|
|
172
172
|
// DTO 白名单;不手动设 Content-Type(会把 boundary 写死)。
|
|
173
173
|
const form = new FormData();
|
|
174
|
-
|
|
174
|
+
// @types/node 26 收紧了 Buffer 与 DOM BlobPart 的关系:Buffer 是
|
|
175
|
+
// Uint8Array<ArrayBufferLike>,而 BlobPart 要 ArrayBuffer-backed,
|
|
176
|
+
// 直接传 buf 会 TS2322。用 Uint8Array 视图包一层(**零拷贝**,共享
|
|
177
|
+
// 同一块内存,运行时行为与原来完全一致)即可满足签名。
|
|
178
|
+
form.append('file', new Blob([new Uint8Array(buf)], { type: 'application/zip' }), path.basename(zip));
|
|
175
179
|
form.append('name', opts.name);
|
|
176
180
|
if (opts.runtime)
|
|
177
181
|
form.append('runtime', opts.runtime);
|
package/dist/commands/tasks.js
CHANGED
|
@@ -709,15 +709,25 @@ export function tasksCommand() {
|
|
|
709
709
|
// Promise.all 保序:results[i] 对应 taskIds[i](失败项为 { id, error })。
|
|
710
710
|
const results = await post(`/tasks/batch/${action}`, { taskIds });
|
|
711
711
|
spinner.stop();
|
|
712
|
+
// 逐项失败计数——**先算后分支**:`--json` 此前在计数之前就 return,
|
|
713
|
+
// 于是 `acf task batch ... --json` 即使整批失败也以退出码 0 结束
|
|
714
|
+
// (CLI-EXIT-01 的「部分失败 → 非零」语义只在人类可读分支生效)。
|
|
715
|
+
// CI 脚本据此把部分失败当成功,继续跑本不该跑的下游步骤。
|
|
716
|
+
const failures = (results ?? []).filter((r) => r && typeof r === 'object' && 'error' in r);
|
|
717
|
+
const failed = failures.length;
|
|
712
718
|
if (opts.json) {
|
|
713
719
|
console.log(JSON.stringify(results ?? []));
|
|
720
|
+
if (failed > 0) {
|
|
721
|
+
// 机器可读模式同样要把失败信号交给 shell:stdout 保持纯 JSON
|
|
722
|
+
// (不污染调用方的 jq),失败原因走 stderr。
|
|
723
|
+
console.error(`Batch ${action} finished with ${failed} failure(s) out of ${taskIds.length} task(s).`);
|
|
724
|
+
process.exitCode = 1;
|
|
725
|
+
}
|
|
714
726
|
return;
|
|
715
727
|
}
|
|
716
|
-
let failed = 0;
|
|
717
728
|
(results ?? []).forEach((r, i) => {
|
|
718
729
|
const tid = taskIds[i] ?? String(i);
|
|
719
730
|
if (r && typeof r === 'object' && 'error' in r) {
|
|
720
|
-
failed++;
|
|
721
731
|
console.log(chalk.red(`✗ ${tid}: ${String(r.error)}`));
|
|
722
732
|
}
|
|
723
733
|
else {
|
package/dist/config.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* protection matters. Node has no cross-platform OS keyring (unlike Electron's
|
|
9
9
|
* safeStorage — see ADR-012; acf-cli is plain Node, not Electron), so the CLI
|
|
10
10
|
* cannot encrypt at rest without pulling a native keytar dependency. The chosen
|
|
11
|
-
* minimum posture — explicitly allowed by docs/
|
|
11
|
+
* minimum posture — explicitly allowed by docs/archive/audits/sec-01-review-report.md §四 — is:
|
|
12
12
|
* 1. the config file is created with 0600 (owner read/write only), and any
|
|
13
13
|
* legacy group/world-readable file is repaired to 0600 on load;
|
|
14
14
|
* 2. credentials can be injected per-invocation via ACF_TOKEN /
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autocodeflow/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "AutoCodeFlow CLI — manage tasks, executions and applications from the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"ora": "^9.4.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/node": "
|
|
39
|
+
"@types/node": "26.6.5",
|
|
40
40
|
"typescript": "^5.9.3",
|
|
41
41
|
"vitest": "^5.0.1",
|
|
42
42
|
"tsx": "^4.20.6"
|