dsh-agy-link 0.5.0 → 0.5.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/CHANGELOG.md +20 -0
- package/README.md +349 -318
- package/dist/client.js +141 -48
- package/dist/index.js +28 -5
- package/docs/CONFIGURATION.md +108 -0
- package/docs/README.en.md +48 -32
- package/docs/README.es.md +49 -33
- package/docs/README.pt-BR.md +48 -32
- package/docs/assets/console.png +0 -0
- package/docs/assets/model-picker.png +0 -0
- package/docs/assets/settings.png +0 -0
- package/package.json +1 -1
- package/docs/assets/dashboard.png +0 -0
package/dist/client.js
CHANGED
|
@@ -3920,45 +3920,79 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
3920
3920
|
const STYLE_ID = "dsh-agy-link-tsl-css-v2";
|
|
3921
3921
|
const TRANSLATION_KIND = "agy-translation";
|
|
3922
3922
|
const CSS = `
|
|
3923
|
+
/* Gemini-brand card. Mirrors gemini.google.com: the four-point spark, the
|
|
3924
|
+
blue→purple→pink brand gradient as a hairline, airy rounded surfaces and the
|
|
3925
|
+
gradient wordmark. Every colour is an rgba overlay (or a DSH token) so the
|
|
3926
|
+
card reads on both the dark and the light theme. */
|
|
3923
3927
|
.agy-tsl-card {
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
border:
|
|
3927
|
-
border
|
|
3928
|
-
background:
|
|
3928
|
+
position: relative;
|
|
3929
|
+
margin: 10px 0 4px 0;
|
|
3930
|
+
border-radius: 16px;
|
|
3931
|
+
border: 1px solid transparent;
|
|
3932
|
+
background:
|
|
3933
|
+
linear-gradient(165deg, rgba(66,133,244,.10), rgba(155,114,203,.13) 55%, rgba(217,101,112,.09)) padding-box,
|
|
3934
|
+
linear-gradient(120deg, #4285F4 0%, #9B72CB 52%, #D96570 100%) border-box;
|
|
3935
|
+
box-shadow: 0 12px 30px -24px rgba(66,133,244,.9);
|
|
3929
3936
|
overflow: hidden;
|
|
3930
3937
|
}
|
|
3938
|
+
/* One soft brand bloom in the top-right, exactly like the Gemini surfaces. */
|
|
3939
|
+
.agy-tsl-card::after {
|
|
3940
|
+
content: ''; position: absolute; inset: 0; pointer-events: none;
|
|
3941
|
+
background: radial-gradient(120% 100% at 100% 0%, rgba(155,114,203,.18), rgba(155,114,203,0) 62%);
|
|
3942
|
+
}
|
|
3931
3943
|
.agy-tsl-head {
|
|
3944
|
+
position: relative; z-index: 1;
|
|
3932
3945
|
display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
|
|
3933
|
-
padding:
|
|
3934
|
-
border-bottom: 1px solid
|
|
3935
|
-
}
|
|
3936
|
-
.agy-tsl-badge {
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3946
|
+
padding: 8px 12px; font-size: 12px; color: var(--dsw-alias-label-secondary, #aaa);
|
|
3947
|
+
border-bottom: 1px solid rgba(127,127,127,.14);
|
|
3948
|
+
}
|
|
3949
|
+
.agy-tsl-badge { display: inline-flex; align-items: center; gap: 6px; }
|
|
3950
|
+
.agy-tsl-mark { width: 16px; height: 16px; flex: 0 0 auto; display: block; }
|
|
3951
|
+
.agy-tsl-brand {
|
|
3952
|
+
font-size: 13px; font-weight: 600; letter-spacing: .005em;
|
|
3953
|
+
background: linear-gradient(90deg, #4285F4 0%, #9B72CB 55%, #D96570 100%);
|
|
3954
|
+
-webkit-background-clip: text; background-clip: text;
|
|
3955
|
+
-webkit-text-fill-color: transparent; color: transparent;
|
|
3956
|
+
}
|
|
3957
|
+
.agy-tsl-tag {
|
|
3958
|
+
font-size: 11px; line-height: 16px; padding: 0 7px; border-radius: 999px;
|
|
3959
|
+
color: var(--dsw-alias-label-secondary, #a8b0bd); background: rgba(127,127,127,.14);
|
|
3960
|
+
}
|
|
3961
|
+
.agy-tsl-meta { font-size: 11.5px; opacity: .8; font-variant-numeric: tabular-nums; }
|
|
3943
3962
|
.agy-tsl-spacer { flex: 1 1 auto; }
|
|
3944
3963
|
.agy-tsl-btn {
|
|
3945
3964
|
background: transparent; border: 1px solid transparent; color: var(--dsw-alias-label-secondary, #aaa);
|
|
3946
|
-
border-radius:
|
|
3965
|
+
border-radius: 999px; cursor: pointer; font-size: 12px; padding: 2px 9px;
|
|
3966
|
+
transition: background .15s ease, color .15s ease;
|
|
3967
|
+
}
|
|
3968
|
+
.agy-tsl-btn:hover { background: rgba(127,127,127,.16); color: var(--dsw-alias-label-primary, #eee); }
|
|
3969
|
+
.agy-tsl-body {
|
|
3970
|
+
position: relative; z-index: 1;
|
|
3971
|
+
padding: 10px 14px 12px 14px; font-size: 13.5px; line-height: 1.7;
|
|
3972
|
+
color: var(--dsw-alias-label-primary, #eee);
|
|
3947
3973
|
}
|
|
3948
|
-
.agy-tsl-btn:hover { background: var(--dsw-alias-interactive-bg-hover-solid, rgba(127,127,127,.16)); color: var(--dsw-alias-label-primary, #eee); }
|
|
3949
|
-
.agy-tsl-body { padding: 9px 12px; font-size: 13.5px; line-height: 1.65; color: var(--dsw-alias-label-primary, #eee); }
|
|
3950
3974
|
.agy-tsl-body p { margin: 0 0 7px 0; }
|
|
3951
3975
|
.agy-tsl-body p:last-child { margin-bottom: 0; }
|
|
3952
3976
|
.agy-tsl-body ul, .agy-tsl-body ol { margin: 0 0 7px 0; padding-left: 20px; }
|
|
3953
3977
|
.agy-tsl-body li { margin: 2px 0; }
|
|
3954
3978
|
.agy-tsl-body h4, .agy-tsl-body h5 { margin: 8px 0 5px 0; font-size: 13.5px; }
|
|
3955
3979
|
.agy-tsl-body code { background: rgba(127,127,127,.18); border-radius: 4px; padding: 1px 4px; font-size: 12.5px; }
|
|
3956
|
-
.agy-tsl-body pre { background: rgba(127,127,127,.14); border-radius:
|
|
3980
|
+
.agy-tsl-body pre { background: rgba(127,127,127,.14); border-radius: 10px; padding: 8px 10px; overflow-x: auto; margin: 0 0 7px 0; }
|
|
3957
3981
|
.agy-tsl-body pre code { background: transparent; padding: 0; }
|
|
3958
3982
|
.agy-tsl-original {
|
|
3959
|
-
|
|
3983
|
+
position: relative; z-index: 1;
|
|
3984
|
+
margin: 0; padding: 8px 12px; border-top: 1px dashed rgba(127,127,127,.24);
|
|
3960
3985
|
font-size: 12.5px; color: var(--dsw-alias-label-secondary, #aaa); white-space: pre-wrap; max-height: 260px; overflow: auto;
|
|
3961
3986
|
}
|
|
3987
|
+
/* Gemini attribution line: the spark plus the plain "translated by" note. */
|
|
3988
|
+
.agy-tsl-foot {
|
|
3989
|
+
position: relative; z-index: 1;
|
|
3990
|
+
display: flex; align-items: center; gap: 6px;
|
|
3991
|
+
padding: 6px 12px 8px 12px; font-size: 11.5px;
|
|
3992
|
+
color: var(--dsw-alias-label-tertiary, #8a8f98);
|
|
3993
|
+
border-top: 1px solid rgba(127,127,127,.12);
|
|
3994
|
+
}
|
|
3995
|
+
.agy-tsl-foot svg { width: 12px; height: 12px; }
|
|
3962
3996
|
/* Icon-only action that sits in the same strip as copy / thumbs / link, with
|
|
3963
3997
|
the same neutral tint so it reads as part of that group. */
|
|
3964
3998
|
.agy-tsl-icon {
|
|
@@ -4145,6 +4179,44 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4145
4179
|
}
|
|
4146
4180
|
return h$1("div", null, blocks);
|
|
4147
4181
|
}
|
|
4182
|
+
/**
|
|
4183
|
+
* The Gemini four-point spark, filled with the brand gradient (#4285F4 →
|
|
4184
|
+
* #9B72CB → #D96570) — the mark Google uses on gemini.google.com. The gradient
|
|
4185
|
+
* id is unique per render so several cards can coexist.
|
|
4186
|
+
*/
|
|
4187
|
+
let markSeq = 0;
|
|
4188
|
+
function geminiMark() {
|
|
4189
|
+
const id = "agy-tsl-grad-" + ++markSeq;
|
|
4190
|
+
return h$1("svg", {
|
|
4191
|
+
viewBox: "0 0 24 24",
|
|
4192
|
+
className: "agy-tsl-mark",
|
|
4193
|
+
"aria-hidden": "true",
|
|
4194
|
+
focusable: "false"
|
|
4195
|
+
}, h$1("defs", null, h$1("linearGradient", {
|
|
4196
|
+
id,
|
|
4197
|
+
x1: "0",
|
|
4198
|
+
y1: "24",
|
|
4199
|
+
x2: "24",
|
|
4200
|
+
y2: "0",
|
|
4201
|
+
gradientUnits: "userSpaceOnUse"
|
|
4202
|
+
}, h$1("stop", {
|
|
4203
|
+
offset: "0%",
|
|
4204
|
+
"stop-color": "#4285F4"
|
|
4205
|
+
}), h$1("stop", {
|
|
4206
|
+
offset: "50%",
|
|
4207
|
+
"stop-color": "#9B72CB"
|
|
4208
|
+
}), h$1("stop", {
|
|
4209
|
+
offset: "100%",
|
|
4210
|
+
"stop-color": "#D96570"
|
|
4211
|
+
}))), h$1("path", {
|
|
4212
|
+
d: BRAND_PATHS.gemini,
|
|
4213
|
+
fill: "url(#" + id + ")"
|
|
4214
|
+
}));
|
|
4215
|
+
}
|
|
4216
|
+
/** "Gemini 译文" → "译文": the wordmark carries "Gemini", so only the suffix is shown. */
|
|
4217
|
+
function badgeSuffix(label) {
|
|
4218
|
+
return label.replace(/^\s*Gemini[\s·::-]*/iu, "").trim();
|
|
4219
|
+
}
|
|
4148
4220
|
const TranslationCard = (props) => {
|
|
4149
4221
|
const data = (props?.node ?? {}).data ?? {};
|
|
4150
4222
|
const t = (key, fallback) => {
|
|
@@ -4177,7 +4249,7 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4177
4249
|
className: "agy-tsl-card",
|
|
4178
4250
|
"data-agy-translation": "gemini",
|
|
4179
4251
|
"aria-label": t("tsl.badge", "Gemini translation")
|
|
4180
|
-
}, h$1("div", { className: "agy-tsl-head" }, h$1("span", { className: "agy-tsl-badge" }, "
|
|
4252
|
+
}, h$1("div", { className: "agy-tsl-head" }, h$1("span", { className: "agy-tsl-badge" }, geminiMark(), h$1("span", { className: "agy-tsl-brand" }, "Gemini"), badgeSuffix(t("tsl.badge", "Gemini translation")) === "" ? null : h$1("span", { className: "agy-tsl-tag" }, badgeSuffix(t("tsl.badge", "Gemini translation")))), h$1("span", { className: "agy-tsl-meta" }, meta.join(" · ")), h$1("span", { className: "agy-tsl-spacer" }), h$1("button", {
|
|
4181
4253
|
type: "button",
|
|
4182
4254
|
className: "agy-tsl-btn",
|
|
4183
4255
|
onClick: copy
|
|
@@ -4196,22 +4268,10 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4196
4268
|
type: "button",
|
|
4197
4269
|
className: "agy-tsl-btn",
|
|
4198
4270
|
onClick: () => setShowOriginal(!showOriginal)
|
|
4199
|
-
}, showOriginal ? t("tsl.hideOriginal", "Hide original") : t("tsl.showOriginal", "Show original"))) : null, showOriginal && original !== "" ? h$1("pre", { className: "agy-tsl-original" }, original) : null);
|
|
4271
|
+
}, showOriginal ? t("tsl.hideOriginal", "Hide original") : t("tsl.showOriginal", "Show original"))) : null, showOriginal && original !== "" ? h$1("pre", { className: "agy-tsl-original" }, original) : null, h$1("div", { className: "agy-tsl-foot" }, geminiMark(), h$1("span", null, t("tsl.byGemini", "Translated by Gemini"))));
|
|
4200
4272
|
};
|
|
4201
|
-
/** Four-point Gemini spark, filled with `currentColor` so it inherits the icon
|
|
4202
|
-
* tint of DSH's action strip and looks native next to copy/thumbs/link. */
|
|
4203
|
-
const GEMINI_STAR = "M12 2 Q13.1 9.2 22 12 Q13.1 14.8 12 22 Q10.9 14.8 2 12 Q10.9 9.2 12 2 Z";
|
|
4204
4273
|
function geminiGlyph() {
|
|
4205
|
-
return
|
|
4206
|
-
viewBox: "0 0 24 24",
|
|
4207
|
-
fill: "currentColor",
|
|
4208
|
-
"aria-hidden": "true",
|
|
4209
|
-
style: {
|
|
4210
|
-
width: "15px",
|
|
4211
|
-
height: "15px",
|
|
4212
|
-
display: "block"
|
|
4213
|
-
}
|
|
4214
|
-
}, h$1("path", { d: GEMINI_STAR }));
|
|
4274
|
+
return geminiMark();
|
|
4215
4275
|
}
|
|
4216
4276
|
function spinnerGlyph() {
|
|
4217
4277
|
return h$1("svg", {
|
|
@@ -4317,6 +4377,7 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4317
4377
|
const created = doc.createElement("div");
|
|
4318
4378
|
created?.setAttribute?.("id", TIP_ID);
|
|
4319
4379
|
created?.setAttribute?.("role", "tooltip");
|
|
4380
|
+
created?.setAttribute?.("class", "agy-tsl-tip");
|
|
4320
4381
|
if (created !== void 0 && created !== null) {
|
|
4321
4382
|
created.style.cssText = "position:fixed;display:none;pointer-events:none;z-index:1100";
|
|
4322
4383
|
created.isConnected = true;
|
|
@@ -4343,6 +4404,8 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4343
4404
|
const box = anchorBox(el);
|
|
4344
4405
|
if (node === null || node === void 0 || box === null) return;
|
|
4345
4406
|
node.textContent = text;
|
|
4407
|
+
node.setAttribute?.("class", "agy-tsl-tip");
|
|
4408
|
+
node.style.position = "fixed";
|
|
4346
4409
|
node.style.display = "inline-flex";
|
|
4347
4410
|
const size = node.getBoundingClientRect?.() ?? {
|
|
4348
4411
|
width: 0,
|
|
@@ -4376,12 +4439,47 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4376
4439
|
}
|
|
4377
4440
|
/**
|
|
4378
4441
|
* Per-reply action state, kept outside React so it survives a remount: the chat
|
|
4379
|
-
* timeline virtualises nodes and DSH re-creates the whole panel
|
|
4380
|
-
*
|
|
4381
|
-
*
|
|
4442
|
+
* timeline virtualises nodes, and DSH re-creates the whole panel whenever a new
|
|
4443
|
+
* card lands in the transcript. The map is the in-page truth; the host's durable
|
|
4444
|
+
* record is the truth across page loads.
|
|
4445
|
+
*
|
|
4446
|
+
* The bug this shape fixes: a remount that happens *while* a translation is in
|
|
4447
|
+
* flight re-initialises to `working`, and the promise that finishes belongs to
|
|
4448
|
+
* the unmounted instance — whose `setState` is a no-op. The spinner then never
|
|
4449
|
+
* stopped even though the card had rendered. Publishing to every mounted
|
|
4450
|
+
* instance is what lets the survivor settle to `done`.
|
|
4382
4451
|
*/
|
|
4383
4452
|
const ACTION_STATE = /* @__PURE__ */ new Map();
|
|
4384
4453
|
const ACTION_INFLIGHT = /* @__PURE__ */ new Set();
|
|
4454
|
+
const ACTION_LISTENERS = /* @__PURE__ */ new Map();
|
|
4455
|
+
function actionKey(sessionId, messageId) {
|
|
4456
|
+
return sessionId + "\0" + messageId;
|
|
4457
|
+
}
|
|
4458
|
+
/** Current state of one action; `working` whenever a request is in flight. */
|
|
4459
|
+
function actionStateOf(key) {
|
|
4460
|
+
return ACTION_INFLIGHT.has(key) ? "working" : ACTION_STATE.get(key) ?? "idle";
|
|
4461
|
+
}
|
|
4462
|
+
/** Publish a state to every mounted instance of this action. */
|
|
4463
|
+
function setActionState(key, next) {
|
|
4464
|
+
ACTION_STATE.set(key, next);
|
|
4465
|
+
if (next === "working") ACTION_INFLIGHT.add(key);
|
|
4466
|
+
else ACTION_INFLIGHT.delete(key);
|
|
4467
|
+
const listeners = ACTION_LISTENERS.get(key);
|
|
4468
|
+
if (listeners === void 0) return;
|
|
4469
|
+
for (const listener of [...listeners]) try {
|
|
4470
|
+
listener(next);
|
|
4471
|
+
} catch {}
|
|
4472
|
+
}
|
|
4473
|
+
/** Subscribe one mounted action instance; the returned function unsubscribes. */
|
|
4474
|
+
function subscribeActionState(key, listener) {
|
|
4475
|
+
const listeners = ACTION_LISTENERS.get(key) ?? /* @__PURE__ */ new Set();
|
|
4476
|
+
listeners.add(listener);
|
|
4477
|
+
ACTION_LISTENERS.set(key, listeners);
|
|
4478
|
+
return () => {
|
|
4479
|
+
listeners.delete(listener);
|
|
4480
|
+
if (listeners.size === 0) ACTION_LISTENERS.delete(key);
|
|
4481
|
+
};
|
|
4482
|
+
}
|
|
4385
4483
|
/**
|
|
4386
4484
|
* Icon-only "translate with Gemini" action rendered into the assistant action
|
|
4387
4485
|
* strip (`conversation.chat.assistant-actions`), so it lines up with copy,
|
|
@@ -4392,8 +4490,9 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4392
4490
|
const injectedSession = typeof props?.sessionId === "string" ? props.sessionId : "";
|
|
4393
4491
|
const ctx = props?.ctx;
|
|
4394
4492
|
const sessionId = injectedSession !== "" ? injectedSession : ctx === void 0 ? "" : currentSessionId(ctx);
|
|
4395
|
-
const key = sessionId
|
|
4396
|
-
const [state, setState] = useState$1(() =>
|
|
4493
|
+
const key = actionKey(sessionId, messageId);
|
|
4494
|
+
const [state, setState] = useState$1(() => actionStateOf(key));
|
|
4495
|
+
useEffect$1(() => subscribeActionState(key, (next) => setState(next)), [key]);
|
|
4397
4496
|
useEffect$1(() => {
|
|
4398
4497
|
if (messageId === "" || sessionId === "") return;
|
|
4399
4498
|
let alive = true;
|
|
@@ -4401,9 +4500,7 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4401
4500
|
if (!alive || res === null) return;
|
|
4402
4501
|
const next = res.state === "ready" ? "done" : res.state === "busy" ? "working" : null;
|
|
4403
4502
|
if (next === null) return;
|
|
4404
|
-
|
|
4405
|
-
if (next === "working") ACTION_INFLIGHT.add(key);
|
|
4406
|
-
setState((prev) => prev === next ? prev : next);
|
|
4503
|
+
setActionState(key, next);
|
|
4407
4504
|
});
|
|
4408
4505
|
return () => {
|
|
4409
4506
|
alive = false;
|
|
@@ -4415,22 +4512,19 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4415
4512
|
]);
|
|
4416
4513
|
if (messageId === "" || sessionId === "") return null;
|
|
4417
4514
|
const apply = (next) => {
|
|
4418
|
-
|
|
4419
|
-
setState(next);
|
|
4515
|
+
setActionState(key, next);
|
|
4420
4516
|
};
|
|
4421
4517
|
const run = (e) => {
|
|
4422
4518
|
e?.stopPropagation?.();
|
|
4423
4519
|
e?.preventDefault?.();
|
|
4424
4520
|
hideTip();
|
|
4425
4521
|
if (state === "working") return;
|
|
4426
|
-
ACTION_INFLIGHT.add(key);
|
|
4427
4522
|
apply("working");
|
|
4428
4523
|
postTranslate({
|
|
4429
4524
|
sessionId,
|
|
4430
4525
|
messageId,
|
|
4431
4526
|
persist: true
|
|
4432
4527
|
}).then((res) => {
|
|
4433
|
-
ACTION_INFLIGHT.delete(key);
|
|
4434
4528
|
if (res?.ok === true) {
|
|
4435
4529
|
apply("done");
|
|
4436
4530
|
return;
|
|
@@ -4440,7 +4534,6 @@ div[data-variant="think"] [class*="thinkBody"] {
|
|
|
4440
4534
|
if (!ACTION_INFLIGHT.has(key)) apply("idle");
|
|
4441
4535
|
}, 3e3);
|
|
4442
4536
|
}).catch(() => {
|
|
4443
|
-
ACTION_INFLIGHT.delete(key);
|
|
4444
4537
|
apply("error");
|
|
4445
4538
|
setTimeout(() => {
|
|
4446
4539
|
if (!ACTION_INFLIGHT.has(key)) apply("idle");
|
package/dist/index.js
CHANGED
|
@@ -33350,7 +33350,7 @@ function buildTranslationSetup(input) {
|
|
|
33350
33350
|
if (input.cwd !== void 0 && input.cwd !== "") lines.push("- 该会话的工作目录:" + input.cwd);
|
|
33351
33351
|
if (input.digest !== void 0 && input.digest.trim() !== "") lines.push("", "该会话到目前为止的摘要(供你理解上下文,不必翻译它):", "", "<digest>", input.digest.trim(), "</digest>");
|
|
33352
33352
|
if (input.logPath !== void 0 && input.logPath !== "") lines.push("", "需要完整历史时可以自己读:原始日志在 " + input.logPath + "(zstd 压缩的 JSONL,每行一个事件)。读取示例:", " zstd -dc '" + input.logPath + "' | jq -c 'select(.type==\"assistant/message\") | {turn:.data.turn, text:([.data.message.content[]?.text] | join(\"\"))}' | tail -40", "没有 jq 就用 python3 逐行 json.loads 过滤;不要修改这些文件。");
|
|
33353
|
-
lines.push("", "规则:", "1. 说" + lang + "
|
|
33353
|
+
lines.push("", "规则:", "1. 只讲「当前这一轮」的 AI 回复:我每次发来的是这一轮的原文,别去翻历史里的其它回答来顶替它。", "2. 说" + lang + "的大白话,像当面给同事解释:口语、短句、按原文顺序讲;不要标题,不要分点罗列,不要写成报告。", "3. 遇到术语、缩写、报错、函数名,先用日常说法讲清,再往下说;必要时补一句它大概是干什么的。", "4. 结论、条件、谁做了什么都要留着;别为了短把细节吞掉,也别替它下原文没有的结论。", "5. 只输出讲解本身,不要前言、不要复述我发的内容、不要反问我。");
|
|
33354
33354
|
return lines.join("\n");
|
|
33355
33355
|
}
|
|
33356
33356
|
/** Read the event log whichever shape the host exposes. */
|
|
@@ -33569,9 +33569,32 @@ function buildTranslationPrompt(text, targetLanguage, maxChars) {
|
|
|
33569
33569
|
const limit = Math.max(MIN_TEXT_LIMIT, Math.round(maxChars));
|
|
33570
33570
|
const long = text.length > Math.min(2e3, Math.floor(limit / 4));
|
|
33571
33571
|
return [
|
|
33572
|
-
"
|
|
33573
|
-
|
|
33574
|
-
"
|
|
33572
|
+
"把下面这段「当前这一轮 AI 回复」的原文,用" + lang + "通俗易懂地讲一遍,就像当面跟同事解释:",
|
|
33573
|
+
"说大白话、短句,按原文的顺序讲;别用行话和缩写,遇到术语先换成日常说法(必要时补一句它是干什么的);别写标题或分点列表,别写成报告。",
|
|
33574
|
+
"结论、条件、谁做了什么都要留着,别为了短把细节吞掉;别改原意,别加原文没有的内容,别替它下结论。",
|
|
33575
|
+
...long ? ["原文有点长,挑重点讲清楚就行,按它自己的顺序讲,别压成几句结论。"] : [],
|
|
33576
|
+
"只输出这段讲解本身,不要复述我发的内容,不要提问。",
|
|
33577
|
+
"",
|
|
33578
|
+
"<content>",
|
|
33579
|
+
text,
|
|
33580
|
+
"</content>"
|
|
33581
|
+
].join("\n");
|
|
33582
|
+
}
|
|
33583
|
+
/**
|
|
33584
|
+
* Per-turn request for a BOUND translation conversation.
|
|
33585
|
+
*
|
|
33586
|
+
* The persona (`buildTranslationSetup`) goes out once, when that conversation is
|
|
33587
|
+
* created; every later turn receives only this line plus the source. Keeping the
|
|
33588
|
+
* request on every turn is what pins the model to the reply it is looking at now
|
|
33589
|
+
* instead of translating something it remembers from an earlier turn.
|
|
33590
|
+
*/
|
|
33591
|
+
function buildTranslationRequest(text, targetLanguage, maxChars) {
|
|
33592
|
+
const lang = targetLanguage.trim() === "" ? "中文(简体)" : targetLanguage.trim();
|
|
33593
|
+
const long = text.length > Math.min(2e3, Math.floor(Math.max(MIN_TEXT_LIMIT, Math.round(maxChars)) / 4));
|
|
33594
|
+
return [
|
|
33595
|
+
"把「当前这一轮 AI 回复」的下面这段原文,用" + lang + "通俗易懂地讲一遍:说大白话、短句,按原文顺序,术语先换成日常说法,别写成报告,别为了短丢信息,别加原文没有的内容。",
|
|
33596
|
+
...long ? ["原文有点长,挑重点讲清楚就行,别压成几句结论。"] : [],
|
|
33597
|
+
"只输出讲解本身。",
|
|
33575
33598
|
"",
|
|
33576
33599
|
"<content>",
|
|
33577
33600
|
text,
|
|
@@ -33804,7 +33827,7 @@ var TranslationService = class {
|
|
|
33804
33827
|
for (const chunk of chunks) {
|
|
33805
33828
|
const res = await this.withRetry({
|
|
33806
33829
|
prompt: buildTranslationPrompt(chunk, language, cfg.translateMaxChars),
|
|
33807
|
-
text: chunk,
|
|
33830
|
+
text: buildTranslationRequest(chunk, language, cfg.translateMaxChars),
|
|
33808
33831
|
setup: sessionId === void 0 ? void 0 : this.setupFor(sessionId, language, setupEvents),
|
|
33809
33832
|
...sessionId === void 0 ? {} : { sessionId },
|
|
33810
33833
|
model: target.model,
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Configuration reference
|
|
2
|
+
|
|
3
|
+
Resolution order (highest first): `DSH_AGY_*` environment variable → runtime overrides written by `/agy` (`.dsh/agy-link/runtime-overrides.json`) → plugin entry config in the DSH profile → defaults below.
|
|
4
|
+
|
|
5
|
+
| Legend | Meaning |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `—` | No environment variable; set it through the plugin config |
|
|
8
|
+
|
|
9
|
+
## Basics
|
|
10
|
+
|
|
11
|
+
| Key | Environment | Default | Description |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| `enabled` | `DSH_AGY_ENABLED` | `true` | Master switch |
|
|
14
|
+
| `agyBin` | `DSH_AGY_BIN` | `''` (auto-detect) | Path to the `agy` binary |
|
|
15
|
+
| `extraArgs` | `DSH_AGY_EXTRA_ARGS` | `[]` | Extra argv appended to every `agy` spawn (space separated in the env var) |
|
|
16
|
+
| `permissionMode` | `DSH_AGY_MODE` | `skip` | `skip` / `plan` / `accept-edits`. `DSH_AGY_SKIP_PERMISSIONS` maps `true`→`skip`, `false`→`plan` |
|
|
17
|
+
| `workspaceRoot` | `DSH_AGY_WORKSPACE_ROOT` | `''` (session cwd) | Workspace root passed to agy |
|
|
18
|
+
|
|
19
|
+
## Models and effort
|
|
20
|
+
|
|
21
|
+
| Key | Environment | Default | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `defaultModel` | `DSH_AGY_DEFAULT_MODEL` | `''` (agy default) | Initial model slug |
|
|
24
|
+
| `defaultEffort` | `DSH_AGY_DEFAULT_EFFORT` | `high` | Initial thinking effort: `low` / `medium` / `high` / `auto`; overridable per model in the session menu |
|
|
25
|
+
| `hiddenModels` | `DSH_AGY_HIDDEN_MODELS` | `[]` | Slugs hidden from the model picker (comma separated) |
|
|
26
|
+
| `fallbackModels` | `—` | Gemini 3.8/3.7/3.6/3.5 Flash, Gemini 4 Argon, Claude Sonnet 4.6, Claude Opus 4.6 (Thinking), GPT-OSS 120B | Catalog shown before `agy models` succeeds (signed out or offline) |
|
|
27
|
+
| `autoFallbackModel` | `DSH_AGY_AUTO_FALLBACK_MODEL` | `false` | Retry on a fallback model when the selected one cannot run |
|
|
28
|
+
| `modelsCacheTtlMs` | `—` | `300000` | Model catalog cache lifetime |
|
|
29
|
+
|
|
30
|
+
## Timeouts and scheduling
|
|
31
|
+
|
|
32
|
+
| Key | Environment | Default | Description |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| `timeoutMs` | `DSH_AGY_TIMEOUT_MS` | `600000` | Activity watchdog timeout per turn |
|
|
35
|
+
| `longToolIdleMinutes` | `DSH_AGY_LONG_TOOL_IDLE_MINUTES` | `240` | Idle budget while a tool step is open; `0` keeps `timeoutMs` so wedged tools fail fast |
|
|
36
|
+
| `dispatchTimeoutMinutes` | `—` | `15` | Cap on waiting for the Windows credential slot before backing off and retrying; `0` waits indefinitely |
|
|
37
|
+
| `dispatchRetries` | `—` | `1` | Extra dispatch attempts after a credential-slot timeout |
|
|
38
|
+
| `parallelSameAccount` | `—` | `true` | Concurrent sessions on the credential already in the slot start without exclusivity; `false` restores full slot exclusivity |
|
|
39
|
+
| `maxConcurrent` | `—` | `0` (unlimited) | Cross-session cap on concurrent agy streams |
|
|
40
|
+
| `rateLimitPerMinute` | `DSH_AGY_RATE_LIMIT_PER_MINUTE` | `0` (off) | Admission cap on requests per minute |
|
|
41
|
+
|
|
42
|
+
## Context and metering
|
|
43
|
+
|
|
44
|
+
| Key | Environment | Default | Description |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| `contextWindowDefault` | `—` | `1048576` | Context window advertised when agy does not report one |
|
|
47
|
+
| `maxTokensDefault` | `—` | `65536` | Max output tokens advertised when agy does not report one |
|
|
48
|
+
| `forwardSystemPrompt` | `—` | `false` | Forward the DSH system prompt to agy |
|
|
49
|
+
| `digestMaxChars` | `—` | `8000` | Budget for the history digest sent each turn |
|
|
50
|
+
| `contextTransferMaxChars` | `—` | `660000` | Character cap for the transferred context block |
|
|
51
|
+
| `contextTransferMaxBytes` | `—` | `150000` | Byte cap for the transferred context block |
|
|
52
|
+
| `contextTransferFileAboveBytes` | `—` | `55000` | Files larger than this are elided in the context block |
|
|
53
|
+
| `contextTransferFileMaxBytes` | `—` | `2000000` | Hard cap for an inlined file |
|
|
54
|
+
| `compactionMaxChars` | `—` | `800000` | Character budget for compaction input |
|
|
55
|
+
| `allowAuxiliary` | `—` | `true` | Allow auxiliary calls (titles, goal derivation) through the adapter |
|
|
56
|
+
|
|
57
|
+
## Media
|
|
58
|
+
|
|
59
|
+
| Key | Environment | Default | Description |
|
|
60
|
+
| --- | --- | --- | --- |
|
|
61
|
+
| `mediaDir` | `DSH_AGY_MEDIA_DIR` | `''` (plugin data dir) | Staging directory for multimodal images |
|
|
62
|
+
| `mediaTtlMs` | `DSH_AGY_MEDIA_TTL_MS` | `86400000` | Staged image lifetime |
|
|
63
|
+
| `mediaMaxBytes` | `—` | `10485760` | Per-image size cap |
|
|
64
|
+
| `mediaMaxImages` | `—` | `8` | Images per turn |
|
|
65
|
+
|
|
66
|
+
## MCP and tools
|
|
67
|
+
|
|
68
|
+
| Key | Environment | Default | Description |
|
|
69
|
+
| --- | --- | --- | --- |
|
|
70
|
+
| `askTool` | `—` | `false` | Expose the `agy_ask` delegation tool |
|
|
71
|
+
| `mcpBridge` | `DSH_AGY_MCP_BRIDGE` | `false` | Bridge DSH-side MCP servers into agy |
|
|
72
|
+
| `mcpConfigScope` | `DSH_AGY_MCP_CONFIG_SCOPE` | `global` | `global` / `workspace` / `both` |
|
|
73
|
+
| `mcpConfigPath` | `DSH_AGY_MCP_CONFIG_PATH` | `''` | Explicit agy MCP config path |
|
|
74
|
+
| `mcpToolAllowlist` | `DSH_AGY_MCP_TOOL_ALLOWLIST` | `''` | Only expose these MCP tools (comma separated) |
|
|
75
|
+
|
|
76
|
+
## Network, quota and updates
|
|
77
|
+
|
|
78
|
+
| Key | Environment | Default | Description |
|
|
79
|
+
| --- | --- | --- | --- |
|
|
80
|
+
| `proxyUrl` | `DSH_AGY_PROXY_URL` | `''` | Global proxy for agy processes; per-account proxies take precedence |
|
|
81
|
+
| `quotaPollIntervalMs` | `DSH_AGY_QUOTA_POLL_INTERVAL_MS` | `3600000` | Background quota poll interval (minimum 60 s) |
|
|
82
|
+
| `quotaViaCli` | `DSH_AGY_QUOTA_VIA_CLI` | `true` | Prefer the agy CLI path for quota queries |
|
|
83
|
+
| `autoWarmup` | `DSH_AGY_AUTO_WARMUP` | `false` | Opt-in weekly-quota warmup |
|
|
84
|
+
| `warmupModels` | `DSH_AGY_WARMUP_MODELS` | `gemini-3.8-flash,claude-sonnet-4-6` | Models used for warmup probes |
|
|
85
|
+
| `suppressAgyAutoUpdate` | `DSH_AGY_SUPPRESS_AUTOUPDATE` | `true` on Windows, `false` elsewhere | Refresh agy's update-check timestamp before every spawn to stop the `--bg-updater` console flash chain |
|
|
86
|
+
|
|
87
|
+
## Translation (`/tsl`)
|
|
88
|
+
|
|
89
|
+
| Key | Environment | Default | Description |
|
|
90
|
+
| --- | --- | --- | --- |
|
|
91
|
+
| `autoTranslate` | `DSH_AGY_AUTO_TRANSLATE` | `false` | Translate every completed turn |
|
|
92
|
+
| `translateModel` | `DSH_AGY_TRANSLATE_MODEL` | `gemini-3.8-flash` | Translate model, with catalog fallback |
|
|
93
|
+
| `translateEffort` | `DSH_AGY_TRANSLATE_EFFORT` | `high` | Reasoning effort for the translate model |
|
|
94
|
+
| `translateTargetLanguage` | `DSH_AGY_TRANSLATE_LANG` | `中文(简体)` | Target language wording in the prompt |
|
|
95
|
+
| `translateMaxChars` | `—` | `8000` | Source truncation limit |
|
|
96
|
+
| `translateMaxTokens` | `—` | `4096` | Output token cap |
|
|
97
|
+
| `translateTimeoutMs` | `—` | `120000` | Per-translation timeout |
|
|
98
|
+
| `translateRetries` | `—` | `2` | Retries on retryable failures (account stall, empty answer) |
|
|
99
|
+
| `translateSkipSameModel` | `—` | `true` | Skip translation when the reply already came from the translate model |
|
|
100
|
+
| `translateBindConversation` | `—` | `true` | One agy conversation per DSH session, persona sent once |
|
|
101
|
+
| `translateMinIntervalMs` | `—` | `3000` | Minimum spacing between automatic translations |
|
|
102
|
+
|
|
103
|
+
## Diagnostics
|
|
104
|
+
|
|
105
|
+
| Key | Environment | Default | Description |
|
|
106
|
+
| --- | --- | --- | --- |
|
|
107
|
+
| `logRetentionDays` | `DSH_AGY_LOG_RETENTION_DAYS` | `7` | Host log retention |
|
|
108
|
+
| `disableTelemetry` | `DSH_AGY_DISABLE_TELEMETRY` | `true` | Disable outbound telemetry |
|
package/docs/README.en.md
CHANGED
|
@@ -1,67 +1,83 @@
|
|
|
1
1
|
# dsh-agy-link — English
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bring Google Antigravity into DeepSeek Harness (DSH). The plugin drives the official, unmodified `agy` CLI and adds multi-account pooling, official multi-bucket quota tracking, native streaming and tool cards, and `/tsl` plain-language rewriting.
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="./assets/console.png" alt="Antigravity console: account pool, official quota bars and proxy state" width="760">
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="./assets/model-picker.png" alt="Antigravity models in the DSH model picker" width="300">
|
|
11
|
+
|
|
12
|
+
<img src="./assets/settings.png" alt="Antigravity settings embedded in the DSH plugin page" width="520">
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
Each turn spawns the official `agy` process, parses its NDJSON event stream and maps it to native DSH text, thinking, tool cards and token accounting. Account rotation, quota inspection and retries happen inside the plugin; DSH only sees a normal model call.
|
|
18
|
+
|
|
19
|
+
- Multiple Google accounts drain in order, so a conversation survives a quota wall.
|
|
20
|
+
- Quotas come from the official endpoint: 5-hour window, weekly window and the paid Argon pool are reported separately.
|
|
21
|
+
- Thinking, terminal commands and file edits render as native DSH cards.
|
|
22
|
+
- `/tsl` rewrites any reply in plain language when a model writes too formally.
|
|
4
23
|
|
|
5
24
|
## Requirements
|
|
6
25
|
|
|
7
26
|
| Requirement | Verification |
|
|
8
27
|
| --- | --- |
|
|
9
28
|
| DSH | `dsh --version` |
|
|
10
|
-
| Node.js
|
|
29
|
+
| Node.js ≥ 24 | `node --version` |
|
|
11
30
|
| Google Antigravity CLI | `agy --version` |
|
|
12
|
-
| Google connectivity | proxy/VPN/TUN where required |
|
|
31
|
+
| Google connectivity | proxy / VPN / TUN where required |
|
|
13
32
|
|
|
14
|
-
Where Google is not directly reachable, enable system proxy
|
|
33
|
+
Where Google is not directly reachable, enable system proxy or TUN mode. If the terminal does not inherit the proxy, export it before starting DSH:
|
|
15
34
|
|
|
16
35
|
```bash
|
|
17
36
|
export HTTPS_PROXY=http://127.0.0.1:7890 HTTP_PROXY=http://127.0.0.1:7890 ALL_PROXY=socks5://127.0.0.1:7890
|
|
18
37
|
```
|
|
19
38
|
|
|
20
|
-
Replace the port with
|
|
39
|
+
Replace the port with your local proxy port. A dedicated proxy can also be configured per account in the console.
|
|
21
40
|
|
|
22
41
|
## Install and quick start
|
|
23
42
|
|
|
24
43
|
```bash
|
|
25
|
-
# Install into the web profile
|
|
26
44
|
dsh plugin --profile web add dsh-agy-link
|
|
27
|
-
|
|
28
|
-
# Start DSH Web
|
|
29
45
|
dsh web
|
|
30
46
|
```
|
|
31
47
|
|
|
32
|
-
In DSH, click the `AGY (n)` badge and choose
|
|
48
|
+
In DSH, click the `AGY (n)` badge and choose "Add account" to complete Google login in the browser; no authorization code needs copying. Alternatively run `/agy auth` for the primary account. Then pick an Antigravity model in `/model` and start chatting. `/agy status` reports the current state.
|
|
33
49
|
|
|
34
|
-
##
|
|
50
|
+
## Core features
|
|
35
51
|
|
|
36
|
-
- Account pool
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
- Multimodal images staged locally and authorized to `agy` through `--add-dir`.
|
|
43
|
-
- `agy_ask` for delegating a one-off task to an Antigravity model.
|
|
52
|
+
- **Account pool**: isolated HOME and OAuth credentials per account; sequential drain on 429 or exhaustion; quota-expiry-first rotation; family-scoped cooldowns; manual switch; per-account proxy; parallel credential leases.
|
|
53
|
+
- **Official quotas**: 5-hour rolling, 7-day weekly and the Argon weekly pool, each with reset countdowns and per-model detail.
|
|
54
|
+
- **Console and settings**: the `AGY (n)` header badge and Settings → Plugins → Antigravity open the same console. Inside: the account card (proxy, enable, warmup, delete), a runtime note (permission fixed to `skip`), pool scheduling (sequential drain / round robin), 7-day auto-warmup, auto translate, default thinking effort and model visibility toggles. The picker lists models under `Antigravity (agy CLI)`: Gemini 3.8 Flash, Claude Sonnet 4.6 (Thinking), Claude Opus 4.6 (Thinking), GPT-OSS 120B (Medium).
|
|
55
|
+
- **Native integration**: `antigravity` provider in `/model` with the Gemini, Claude, GPT-OSS and Argon families; streaming text, thinking and tool activity; Terminal and diff cards, with MCP meta-tools unwrapped; mermaid diagrams; `--conversation` session continuity; goal and plan forwarding; full token metering with 1M context; multimodal images; `agy_ask` delegation.
|
|
56
|
+
- **Effort learning**: a model that rejects `--effort` is replayed once without the flag and remembered in `~/.dsh/agy-link/effort-unsupported.json`, so a mismatch never fails a turn.
|
|
57
|
+
- **`/tsl` translation**: command, opt-in auto mode and a per-reply action; results persist as a card under the reply, keep the original behind a toggle and never enter model-visible history; uses the same account pool with failover.
|
|
44
58
|
|
|
45
|
-
##
|
|
59
|
+
## `/agy` commands
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
| --- | --- | --- | --- |
|
|
49
|
-
| `enabled` | `DSH_AGY_ENABLED` | `true` | Plugin master switch |
|
|
50
|
-
| `agyBin` | `DSH_AGY_BIN` | auto-detected | Path to the `agy` executable |
|
|
51
|
-
| `permissionMode` | `DSH_AGY_MODE` | `skip` | `skip`, `plan`, or `accept-edits` (no longer switchable in the settings panel; config/env still override) |
|
|
52
|
-
| `defaultModel` | `DSH_AGY_DEFAULT_MODEL` | agy default | Default model slug |
|
|
53
|
-
| `defaultEffort` | `DSH_AGY_DEFAULT_EFFORT` | `high` | `low`, `medium`, `high`, or `auto`; the settings panel row seeds the session model menu, which can override it per model |
|
|
54
|
-
| `timeoutMs` | `DSH_AGY_TIMEOUT_MS` | `600000` | Activity watchdog timeout in ms |
|
|
55
|
-
| `longToolIdleMinutes` | `DSH_AGY_LONG_TOOL_IDLE_MINUTES` | `240` | Idle budget (minutes) while an agy tool step is still open; `0` = keep `timeoutMs` so a wedged tool fails fast |
|
|
56
|
-
| `workspaceRoot` | `DSH_AGY_WORKSPACE_ROOT` | session cwd | Workspace root |
|
|
61
|
+
`status`, `pool` / `accounts`, `auth` / `auth-code`, `add-account` / `remove-account`, `enable-account` / `disable-account`, `refresh-quota` / `clear-cooldown`, `models`, `mode`, `effort`, `dispatch` / `dispatch-retries` / `parallel` / `max-concurrent`, `workspace`, `goal`, `session`, `clear`, `doctor`.
|
|
57
62
|
|
|
58
|
-
## `/
|
|
63
|
+
## `/tsl` usage
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
/tsl # translate the last completed turn
|
|
67
|
+
/tsl 3 # translate turn 3
|
|
68
|
+
/tsl --full # include intermediate narration
|
|
69
|
+
/tsl --text 任意文本… # translate arbitrary text (no card)
|
|
70
|
+
/tsl --model claude-sonnet-5-5 --effort medium
|
|
71
|
+
/tsl auto on|off|status # per-session auto mode
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
59
75
|
|
|
60
|
-
`
|
|
76
|
+
Common keys: `enabled`, `agyBin`, `permissionMode` (default `skip`), `defaultModel`, `defaultEffort` (default `high`), `hiddenModels`, `timeoutMs`, `workspaceRoot`, `proxyUrl`, `suppressAgyAutoUpdate`, `autoWarmup`, `autoTranslate`, `translateModel`, `translateEffort`. The complete key list, environment variables and defaults are in [CONFIGURATION.md](./CONFIGURATION.md).
|
|
61
77
|
|
|
62
78
|
## Security and terms
|
|
63
79
|
|
|
64
|
-
The plugin invokes only the official, unmodified `agy` binary installed locally. Use it in accordance with Google Antigravity Terms of Service.
|
|
80
|
+
The plugin invokes only the official, unmodified `agy` binary installed locally. Use it in accordance with Google Antigravity's Terms of Service.
|
|
65
81
|
|
|
66
82
|
## License
|
|
67
83
|
|