dsh-agy-link 0.6.25 → 0.6.26
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/CHANGELOG.md +14 -0
- package/dist/cli-image.mjs +8 -1
- package/dist/index.js +69 -27
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.26 (2026-11-15)
|
|
4
|
+
|
|
5
|
+
### English
|
|
6
|
+
|
|
7
|
+
- **Fix(goal): only trust `<goal_complete>` on a user-role message (merges PR #111).** `isGoalToolContinuation()` matched the marker as a plain substring on every message role, so any tool result that merely *printed* the literal string (e.g. grepping this package's own `dist/index.js` doc comments) short-circuited the next request into a zero-content `finish(stop)` that DSH records as a normal completion — three silent replies in a row in the reported incident. The textual marker is now gated on `m.role === 'user'`; the genuine `source.kind === 'tool-goal'` notice still short-circuits. Regression test built from the real grep output plus an assistant echo. Thanks to @AlaIchhe for the diagnosis and RED-first test.
|
|
8
|
+
- **Fix(auth): imported Windows credentials no longer create a permanent 401 deadlock (fixes #112).** `/agy import` on a Windows primary account hand-built a token document without `expiry`; `getValidAccessTokenUncached()` read the missing expiry as "valid forever", so the stale access token was reused until Google rejected it, and every refresh path (`force:true` warmup/quota) reused the same judgment — a self-inflicted, unrecoverable loop. The import now uses `buildAgyCredentialDoc()` (the same single writer as the on-disk token file, always with an expiry or a bounded fallback), and a token with **no known expiry** is treated as needing refresh/validation rather than fresh.
|
|
9
|
+
- **Fix(warmup): terminal TOS bans are quarantined instead of probed every 5 minutes (fixes #112).** 403 `TOS_VIOLATION` responses were truncated to 160 characters (losing `appeal_url`) and returned as an ordinary failure, so `authRequired`/cooldowns stayed empty. Errors now keep up to 2000 characters plus an explicit `Appeal:` link; a `TOS_VIOLATION` marks the account `authRequired` and logs the full reason, stopping the scheduled loop. Pure classifier + injected-network regression tests cover both.
|
|
10
|
+
|
|
11
|
+
### 中文
|
|
12
|
+
|
|
13
|
+
- **修复(goal):`<goal_complete>` 仅信任 user 角色消息(合并 PR #111)。** `isGoalToolContinuation()` 此前把该标记当普通子串匹配所有角色;工具输出只要「打印」出这串字面量(例如 grep 本包 `dist/index.js` 的文档注释),下一轮请求就会被短路成零内容 `finish(stop)`,而 DSH 将其记为正常完成——报告里连续三轮空白回复。现文本标记限制在 `m.role === 'user'`,真正的 `source.kind === 'tool-goal'` 通知仍正常短路。回归测试用真实 grep 输出与 assistant 回声构造。感谢 @AlaIchhe 的定位与 RED-first 测试。
|
|
14
|
+
- **修复(认证):Windows 导入凭据不再造成永久 401 死锁(修复 #112)。** `/agy import` 在 Windows 主账号分支手工拼装了缺少 `expiry` 的 token 文档;`getValidAccessTokenUncached()` 把「缺失 expiry」当成永久有效,旧 access_token 一直复用到 Google 拒绝,而 `force:true` 的预热/额度刷新同样绕不过该判断——一次导入就自造不可逆死循环。现在导入复用 `buildAgyCredentialDoc()`(与磁盘 token 文件同一写入器,必带 expiry 或有界兜底),且**未知 expiry 一律视为需要刷新/校验**而非新鲜。
|
|
15
|
+
- **修复(预热):TOS 终态封禁改为隔离,不再每 5 分钟空转(修复 #112)。** 403 `TOS_VIOLATION` 此前被截到 160 字符(丢失 `appeal_url`)并按普通失败返回,`authRequired`/冷却一直为空。现在保留最多 2000 字符并显式附 `Appeal:` 链接;`TOS_VIOLATION` 会把账号标为 `authRequired` 并记录完整原因,停止定时探测。纯分类器 + 注入网络层的回归测试均已覆盖。
|
|
16
|
+
|
|
3
17
|
## 0.6.25 (2026-11-15)
|
|
4
18
|
|
|
5
19
|
### English
|
package/dist/cli-image.mjs
CHANGED
|
@@ -1791,6 +1791,13 @@ function isHarnessInjectedUserText(text) {
|
|
|
1791
1791
|
* "anywhere" swallowed exactly that: a message sent right after a goal
|
|
1792
1792
|
* completed was finished as an empty turn without spawning agy
|
|
1793
1793
|
* (2026-10-17, "把相关的经验整理到agents.md" × 2).
|
|
1794
|
+
*
|
|
1795
|
+
* The TEXTUAL marker is only trustworthy on a user-role message (the `tool-goal`
|
|
1796
|
+
* notice). Reading it out of every message let the agent's own tool output
|
|
1797
|
+
* poison the scan: a `grep` over the built `dist/index.js` — whose doc comments
|
|
1798
|
+
* contain the literal marker — printed it into a tool result, and the very next
|
|
1799
|
+
* request was short-circuited into an EMPTY turn that was still recorded as
|
|
1800
|
+
* "completed" (2026-11-15, three silent replies in a row).
|
|
1794
1801
|
*/
|
|
1795
1802
|
function isGoalToolContinuation(messages) {
|
|
1796
1803
|
if (messages.length === 0) return false;
|
|
@@ -1803,7 +1810,7 @@ function isGoalToolContinuation(messages) {
|
|
|
1803
1810
|
const src = m.source;
|
|
1804
1811
|
if (src && typeof src === "object" && src.kind === "tool-goal") return true;
|
|
1805
1812
|
const text = extractText$1(m);
|
|
1806
|
-
if (text.includes("<goal_complete>")) return true;
|
|
1813
|
+
if (m.role === "user" && text.includes("<goal_complete>")) return true;
|
|
1807
1814
|
if (m.role === "user" && text.trim() !== "" && !isHarnessInjectedUserText(text)) return false;
|
|
1808
1815
|
}
|
|
1809
1816
|
return false;
|
package/dist/index.js
CHANGED
|
@@ -3205,6 +3205,13 @@ function isHarnessInjectedUserText(text) {
|
|
|
3205
3205
|
* "anywhere" swallowed exactly that: a message sent right after a goal
|
|
3206
3206
|
* completed was finished as an empty turn without spawning agy
|
|
3207
3207
|
* (2026-10-17, "把相关的经验整理到agents.md" × 2).
|
|
3208
|
+
*
|
|
3209
|
+
* The TEXTUAL marker is only trustworthy on a user-role message (the `tool-goal`
|
|
3210
|
+
* notice). Reading it out of every message let the agent's own tool output
|
|
3211
|
+
* poison the scan: a `grep` over the built `dist/index.js` — whose doc comments
|
|
3212
|
+
* contain the literal marker — printed it into a tool result, and the very next
|
|
3213
|
+
* request was short-circuited into an EMPTY turn that was still recorded as
|
|
3214
|
+
* "completed" (2026-11-15, three silent replies in a row).
|
|
3208
3215
|
*/
|
|
3209
3216
|
function isGoalToolContinuation(messages) {
|
|
3210
3217
|
if (messages.length === 0) return false;
|
|
@@ -3217,7 +3224,7 @@ function isGoalToolContinuation(messages) {
|
|
|
3217
3224
|
const src = m.source;
|
|
3218
3225
|
if (src && typeof src === "object" && src.kind === "tool-goal") return true;
|
|
3219
3226
|
const text = extractText(m);
|
|
3220
|
-
if (text.includes("<goal_complete>")) return true;
|
|
3227
|
+
if (m.role === "user" && text.includes("<goal_complete>")) return true;
|
|
3221
3228
|
if (m.role === "user" && text.trim() !== "" && !isHarnessInjectedUserText(text)) return false;
|
|
3222
3229
|
}
|
|
3223
3230
|
return false;
|
|
@@ -32038,12 +32045,15 @@ async function fetchUserEmail(accessToken, proxyUrl) {
|
|
|
32038
32045
|
* {"token": {access_token, token_type, refresh_token, expiry}, "auth_method": "consumer"}
|
|
32039
32046
|
* where expiry is a local-time ISO-8601 string with timezone offset.
|
|
32040
32047
|
*/
|
|
32041
|
-
|
|
32042
|
-
|
|
32043
|
-
|
|
32044
|
-
|
|
32045
|
-
|
|
32046
|
-
|
|
32048
|
+
/**
|
|
32049
|
+
* Serialize a token set into agy's own credential document. This is the ONE
|
|
32050
|
+
* writer for both the on-disk token file and the Windows credential slot: an
|
|
32051
|
+
* import that hand-built the doc without `expiry` produced a token that was
|
|
32052
|
+
* treated as valid forever and then 401'd forever (issue #112).
|
|
32053
|
+
*/
|
|
32054
|
+
function buildAgyCredentialDoc(tokens, now = Date.now()) {
|
|
32055
|
+
const expiryIso = formatLocalIso(tokens.expiryMs ?? now + 36e5);
|
|
32056
|
+
return JSON.stringify({
|
|
32047
32057
|
token: {
|
|
32048
32058
|
access_token: tokens.access_token,
|
|
32049
32059
|
token_type: tokens.token_type ?? "Bearer",
|
|
@@ -32051,8 +32061,13 @@ function writeAgyTokenFile(homeDir, tokens) {
|
|
|
32051
32061
|
expiry: expiryIso
|
|
32052
32062
|
},
|
|
32053
32063
|
auth_method: "consumer"
|
|
32054
|
-
};
|
|
32055
|
-
|
|
32064
|
+
});
|
|
32065
|
+
}
|
|
32066
|
+
function writeAgyTokenFile(homeDir, tokens) {
|
|
32067
|
+
const dir = join(homeDir, ".gemini", "antigravity-cli");
|
|
32068
|
+
mkdirSync(dir, { recursive: true });
|
|
32069
|
+
const file = join(dir, "antigravity-oauth-token");
|
|
32070
|
+
writeFileSync(file, buildAgyCredentialDoc(tokens), {
|
|
32056
32071
|
encoding: "utf8",
|
|
32057
32072
|
mode: 384
|
|
32058
32073
|
});
|
|
@@ -37481,14 +37496,7 @@ var PoolAuthFlow = class {
|
|
|
37481
37496
|
if (existing) {
|
|
37482
37497
|
if (existing.dir && !existing.systemHome) saveCredentialBackup(writeAgyTokenFile(existing.dir, tokens));
|
|
37483
37498
|
else if (process.platform === "win32") try {
|
|
37484
|
-
const docStr =
|
|
37485
|
-
token: {
|
|
37486
|
-
access_token: tokens.access_token,
|
|
37487
|
-
token_type: tokens.token_type ?? "Bearer",
|
|
37488
|
-
refresh_token: tokens.refresh_token
|
|
37489
|
-
},
|
|
37490
|
-
auth_method: "consumer"
|
|
37491
|
-
});
|
|
37499
|
+
const docStr = buildAgyCredentialDoc(tokens);
|
|
37492
37500
|
writeWindowsCredentialRaw(docStr, "gemini:antigravity");
|
|
37493
37501
|
writePrimaryCredential({
|
|
37494
37502
|
raw: docStr,
|
|
@@ -38727,10 +38735,19 @@ async function getValidAccessToken(deps, account, tokenRefreshInFlight) {
|
|
|
38727
38735
|
tokenRefreshInFlight.set(account.id, attempt);
|
|
38728
38736
|
return attempt;
|
|
38729
38737
|
}
|
|
38738
|
+
/**
|
|
38739
|
+
* A token is fresh only when it has a KNOWN future expiry (60s buffer).
|
|
38740
|
+
* A missing expiry is not "valid forever": credentials written by older
|
|
38741
|
+
* imports must go through refresh/validation instead of being reused until
|
|
38742
|
+
* they 401 (issue #112).
|
|
38743
|
+
*/
|
|
38744
|
+
function isAccessTokenFresh(tok, now = Date.now()) {
|
|
38745
|
+
return !!tok.accessToken && typeof tok.expiryMs === "number" && tok.expiryMs > now + 6e4;
|
|
38746
|
+
}
|
|
38730
38747
|
async function getValidAccessTokenUncached(deps, account) {
|
|
38731
38748
|
const tok = await deps.getStoredToken(account);
|
|
38732
38749
|
if (!tok) return null;
|
|
38733
|
-
if (tok.accessToken && (
|
|
38750
|
+
if (tok.accessToken && isAccessTokenFresh(tok)) return tok.accessToken;
|
|
38734
38751
|
if (tok.refreshToken) try {
|
|
38735
38752
|
const refreshed = await refreshTokens(tok.refreshToken, deps.proxyFor(account));
|
|
38736
38753
|
if (!isCurrentAccountGrant(deps, account, tok.refreshToken)) return null;
|
|
@@ -39200,6 +39217,21 @@ function planWarmupTargets(params) {
|
|
|
39200
39217
|
targets
|
|
39201
39218
|
};
|
|
39202
39219
|
}
|
|
39220
|
+
/**
|
|
39221
|
+
* Keep the upstream error readable instead of slicing it to 160 characters.
|
|
39222
|
+
* A `TOS_VIOLATION` 403 is a terminal ban: the 5-minute scheduler must stop
|
|
39223
|
+
* hammering that account, and the appeal URL must reach the UI (issue #112).
|
|
39224
|
+
*/
|
|
39225
|
+
function describeWarmupError(status, body) {
|
|
39226
|
+
const detail = body.trim().slice(0, 2e3);
|
|
39227
|
+
const appealUrl = /"appeal_url"\s*:\s*"([^"]+)"/.exec(body)?.[1];
|
|
39228
|
+
const terminal = /TOS_VIOLATION/i.test(body);
|
|
39229
|
+
return {
|
|
39230
|
+
error: `HTTP ${status}: ${detail}${appealUrl ? ` Appeal: ${appealUrl}` : ""}`,
|
|
39231
|
+
terminal,
|
|
39232
|
+
...appealUrl ? { appealUrl } : {}
|
|
39233
|
+
};
|
|
39234
|
+
}
|
|
39203
39235
|
//#endregion
|
|
39204
39236
|
//#region src/features/warmup/history.ts
|
|
39205
39237
|
var WarmupHistoryStore = class {
|
|
@@ -39259,14 +39291,16 @@ var WarmupService = class {
|
|
|
39259
39291
|
agyVersion;
|
|
39260
39292
|
config;
|
|
39261
39293
|
log;
|
|
39294
|
+
fetchImpl;
|
|
39262
39295
|
history;
|
|
39263
|
-
constructor(pool, quota, globalProxy = () => "", agyVersion = () => null, config = () => ({}), log = () => void 0, historyStore) {
|
|
39296
|
+
constructor(pool, quota, globalProxy = () => "", agyVersion = () => null, config = () => ({}), log = () => void 0, historyStore, fetchImpl = agyFetch) {
|
|
39264
39297
|
this.pool = pool;
|
|
39265
39298
|
this.quota = quota;
|
|
39266
39299
|
this.globalProxy = globalProxy;
|
|
39267
39300
|
this.agyVersion = agyVersion;
|
|
39268
39301
|
this.config = config;
|
|
39269
39302
|
this.log = log;
|
|
39303
|
+
this.fetchImpl = fetchImpl;
|
|
39270
39304
|
this.history = historyStore ?? new WarmupHistoryStore();
|
|
39271
39305
|
}
|
|
39272
39306
|
proxyFor(account) {
|
|
@@ -39352,7 +39386,8 @@ var WarmupService = class {
|
|
|
39352
39386
|
let lastStatus = 0;
|
|
39353
39387
|
let lastError = "";
|
|
39354
39388
|
for (const attempt of attempts) for (const ep of endpoints) try {
|
|
39355
|
-
const
|
|
39389
|
+
const targetUrl = `${ep}/v1internal:${attempt.method}${attempt.query}`;
|
|
39390
|
+
const res = await this.fetchImpl(targetUrl, {
|
|
39356
39391
|
method: "POST",
|
|
39357
39392
|
headers,
|
|
39358
39393
|
body: reqBody
|
|
@@ -39379,13 +39414,20 @@ var WarmupService = class {
|
|
|
39379
39414
|
error: "Account requires browser validation (VALIDATION_REQUIRED)",
|
|
39380
39415
|
durationMs: Date.now() - start
|
|
39381
39416
|
};
|
|
39382
|
-
|
|
39383
|
-
|
|
39384
|
-
|
|
39385
|
-
|
|
39386
|
-
|
|
39387
|
-
|
|
39388
|
-
|
|
39417
|
+
const described = describeWarmupError(res.status, errBody);
|
|
39418
|
+
lastError = described.error;
|
|
39419
|
+
if (res.status === 401 || res.status === 403) {
|
|
39420
|
+
if (described.terminal) {
|
|
39421
|
+
this.pool.markAuthRequired(account.id, described.error);
|
|
39422
|
+
this.log(`[agy-link] warmup: ${account.alias || account.id} is terminal: ${described.error}`);
|
|
39423
|
+
}
|
|
39424
|
+
return {
|
|
39425
|
+
ok: false,
|
|
39426
|
+
status: res.status,
|
|
39427
|
+
error: described.error,
|
|
39428
|
+
durationMs: Date.now() - start
|
|
39429
|
+
};
|
|
39430
|
+
}
|
|
39389
39431
|
} catch (err) {
|
|
39390
39432
|
lastError = String(err);
|
|
39391
39433
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agy-link",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.26",
|
|
4
4
|
"description": "Google Antigravity (agy CLI) models for DeepSeek Harness — stream Gemini/Claude/GPT-OSS subscriptions into DSH with thinking, tool activity, token usage and in-GUI Google OAuth login.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|