@chatcode/chatcode-cli 3.0.5-rc.6 → 3.0.5-rc.7
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/lib/{command-errors-DGyKMxEq.js → command-errors-CnbcOM1a.js} +12 -12
- package/lib/{command-trees-Bh2WKUZ3.js → command-trees-CU7BxVJo.js} +2 -2
- package/lib/{component-identity-B7wyM-aN.js → component-identity-kZK1_hFy.js} +3 -3
- package/lib/{extension-events-JX8c4mnR.js → extension-events-hLxwPvpg.js} +20 -20
- package/lib/{host-access-ClndygbX.js → host-access-kT-u85k_.js} +1 -1
- package/lib/{keymap-nfqAZoFE.js → keymap-DS1M8sDo.js} +2 -2
- package/lib/{plugin-C9yd07Wb.js → plugin-d65VulBk.js} +583 -532
- package/lib/{scenes-C5_xUR61.js → scenes-DG6T8t-A.js} +3 -3
- package/lib/{settings-sections-CRhTUEBm.js → settings-sections-2SuE0biI.js} +3 -3
- package/lib/{statusBarSettings-ChS8Z4Jf.js → statusBarSettings-B2MEAwnI.js} +3 -3
- package/lib/{themes-bFi516uK.js → themes-DUO7kGW-.js} +12 -12
- package/lib/tui-compat-command-trees.js +1 -1
- package/lib/tui-compat-extensions.js +3 -3
- package/lib/tui-compat-plugin-host.js +5 -5
- package/lib/tui-compat-scenes.js +1 -1
- package/lib/tui-compat-settings-sections.js +1 -1
- package/lib/tui-compat-working-activity.js +1 -1
- package/lib/tui-compat-workspaces.js +1 -1
- package/lib/tui-compat.js +5 -5
- package/lib/{workspaces-ous4jIwo.js → workspaces-CLOkL_yE.js} +2 -2
- package/package.json +23 -23
- package/runtime/manifest.json +2 -2
- package/runtime/node_modules/@deepseek-ai/dsh-atomic-write/lib/index.js +38 -38
- package/runtime/node_modules/@deepseek-ai/dsh-atomic-write/lib/types/index.d.ts +2 -2
- package/runtime/node_modules/@deepseek-ai/dsh-atomic-write/lib/types/linux-lock.d.ts +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-atomic-write/lib/types/windows-lock.d.ts +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/client.js +2 -2
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/index.js +77 -10
- package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/error-diagnostic.d.ts +15 -0
- package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/protocol-adapter.d.ts +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/types/transport.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { isVolatile } from "@deepseek-ai/cosmokit";
|
|
3
|
-
import { EMPTY_RESPONSE_CODE, IMAGE_OFFLOAD_REQUIRED_CODE, LlmAdapter, LlmError, ProviderRequestId, ReasoningEffortId, RetryPolicySchema, ToolCallId, attributionHeaders, contentHasImage, isContextWindowExceededError, isQuotaExceededError, offloadedImageText, projectOffloadedImages, requestImageHandleText, requiredImageOffload, resolveImageAttachmentAccess, resolveRetryPolicy, textOnlyImageText } from "@deepseek-ai/dsh-llm";
|
|
3
|
+
import { EMPTY_RESPONSE_CODE, IMAGE_OFFLOAD_REQUIRED_CODE, LlmAdapter, LlmError, ProviderRequestId, ReasoningEffortId, RetryPolicySchema, ToolCallId, attributionHeaders, contentHasImage, errorChain, isContextWindowExceededError, isQuotaExceededError, offloadedImageText, projectOffloadedImages, requestImageHandleText, requiredImageOffload, resolveImageAttachmentAccess, resolveRetryPolicy, textOnlyImageText } from "@deepseek-ai/dsh-llm";
|
|
4
4
|
import { MAX_TIMER_DELAY_MS, deadline, idleWatchdog, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
5
5
|
import { ImageVariantId, longEdgeDimensions, requestImageDimensions } from "@deepseek-ai/dsh-attachment";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
@@ -1483,8 +1483,57 @@ async function prepareFileIds(messages, versions, files) {
|
|
|
1483
1483
|
return ids;
|
|
1484
1484
|
}
|
|
1485
1485
|
//#endregion
|
|
1486
|
+
//#region lib/types/error-diagnostic.js
|
|
1487
|
+
/** Bounded provider diagnostics with request credentials and endpoint addresses removed. */
|
|
1488
|
+
/**
|
|
1489
|
+
* Remove credentials, URLs, terminal controls, and oversized response text.
|
|
1490
|
+
* @param value - provider message or diagnostic cause.
|
|
1491
|
+
* @param secrets - credential and endpoint values captured for this request.
|
|
1492
|
+
* @returns a single-line diagnostic capped after redaction.
|
|
1493
|
+
*/
|
|
1494
|
+
function redactProviderDiagnostic(value, secrets = []) {
|
|
1495
|
+
let text = value.replace(/\u001b\][^\u0007]*(?:\u0007|\u001b\\)/gu, "").replace(/\u001b\[[0-?]*[ -/]*[@-~]/gu, "");
|
|
1496
|
+
const variants = secrets.filter((value) => value.length > 0).flatMap((value) => [
|
|
1497
|
+
value,
|
|
1498
|
+
encodeURIComponent(value),
|
|
1499
|
+
JSON.stringify(value).slice(1, -1)
|
|
1500
|
+
]).sort((a, b) => b.length - a.length);
|
|
1501
|
+
for (const secret of variants) if (secret.length >= 8) text = text.split(secret).join("[REDACTED]");
|
|
1502
|
+
else {
|
|
1503
|
+
const literal = secret.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
1504
|
+
text = text.replace(new RegExp(`(?<![\\p{L}\\p{N}_-])${literal}(?![\\p{L}\\p{N}_-])`, "gu"), "[REDACTED]");
|
|
1505
|
+
}
|
|
1506
|
+
text = text.replace(/\bhttps?:\/\/[^\s<>"'`\\]+/giu, "[REDACTED]").replace(/\b(Bearer|Basic)\s+[a-z0-9._~+\/-]+=*/giu, "$1 [REDACTED]").replace(/((?:["']?(?:[\w-]*api[ _-]?key|authorization|[\w-]*token|password|secret|base[ _-]?url)["']?)\s*[:=]\s*)(?:(?:Bearer|Basic)\s+)?(?:\[REDACTED\]|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s,;}\]]+)/giu, "$1[REDACTED]").replace(/\bsk-[a-z0-9_-]+/giu, "[REDACTED]").replace(/[\x00-\x1f\x7f-\x9f]/gu, " ").replace(/\s+/gu, " ").trim();
|
|
1507
|
+
return text.length <= 4096 ? text : `${text.slice(0, 4095)}…`;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Extract human-readable fields without dumping arbitrary JSON response data.
|
|
1511
|
+
* @param raw - decoded provider error, or a non-JSON response body.
|
|
1512
|
+
* @returns the first nonempty message, detail, msg, or error string.
|
|
1513
|
+
*/
|
|
1514
|
+
function providerDiagnosticMessage(raw) {
|
|
1515
|
+
const read = (value, depth) => {
|
|
1516
|
+
if (typeof value === "string") return value.trim();
|
|
1517
|
+
if (depth === 0 || typeof value !== "object" || value === null) return "";
|
|
1518
|
+
for (const key of [
|
|
1519
|
+
"error",
|
|
1520
|
+
"message",
|
|
1521
|
+
"detail",
|
|
1522
|
+
"msg"
|
|
1523
|
+
]) {
|
|
1524
|
+
if (!(key in value)) continue;
|
|
1525
|
+
const text = read(value[key], depth - 1);
|
|
1526
|
+
if (text !== "") return text;
|
|
1527
|
+
}
|
|
1528
|
+
return "";
|
|
1529
|
+
};
|
|
1530
|
+
const message = read(raw, 3);
|
|
1531
|
+
if (!/<(?:!doctype\s+html|html|head|body|title)\b|<\/[a-z][^>]*>/iu.test(message)) return message;
|
|
1532
|
+
return message.replace(/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/giu, "").replace(/<[^>]*>/gu, " ").replace(/ /giu, " ");
|
|
1533
|
+
}
|
|
1534
|
+
//#endregion
|
|
1486
1535
|
//#region lib/types/transport.js
|
|
1487
|
-
/** Normalize HTTP and in-band
|
|
1536
|
+
/** Normalize HTTP and in-band provider errors; the request owner redacts captured secrets. */
|
|
1488
1537
|
/** Read only provider error fields used by bounded Files recovery.
|
|
1489
1538
|
* @param raw - decoded HTTP error response.
|
|
1490
1539
|
* @returns code, type, and message text, without unrelated response fields.
|
|
@@ -1509,7 +1558,7 @@ function providerErrorDetail(raw) {
|
|
|
1509
1558
|
function providerError(raw, status, headers, protocol = "Messages") {
|
|
1510
1559
|
const envelope = typeof raw === "object" && raw !== null ? raw : {};
|
|
1511
1560
|
const error = typeof envelope.error === "object" && envelope.error !== null ? envelope.error : {};
|
|
1512
|
-
const message =
|
|
1561
|
+
const message = providerDiagnosticMessage(raw).trim() || `DeepSeek ${protocol} request failed (${status ?? "stream error"})`;
|
|
1513
1562
|
const type = typeof error.type === "string" ? error.type : "";
|
|
1514
1563
|
const detail = `${type} ${typeof error.code === "string" ? error.code : ""} ${message}`;
|
|
1515
1564
|
let code;
|
|
@@ -1683,6 +1732,11 @@ var DeepSeekProtocolAdapter = class extends LlmAdapter {
|
|
|
1683
1732
|
signal.throwIfAborted();
|
|
1684
1733
|
const { messages, versions } = await prepareImages(options.messages, connection, options.model, this.dependencies.resolveAttachments?.(), this.imageAccess, signal);
|
|
1685
1734
|
const auth = await this.dependencies.resolveAuth(connection);
|
|
1735
|
+
const secrets = [
|
|
1736
|
+
connection.baseURL,
|
|
1737
|
+
new URL(connection.baseURL).host,
|
|
1738
|
+
...Object.values(auth.headers).flatMap((value) => [value, value.replace(/^(?:Bearer|Basic)\s+/iu, "")])
|
|
1739
|
+
];
|
|
1686
1740
|
try {
|
|
1687
1741
|
const files = new RequestFiles(this.files, {
|
|
1688
1742
|
baseURL: connection.baseURL,
|
|
@@ -1739,16 +1793,16 @@ var DeepSeekProtocolAdapter = class extends LlmAdapter {
|
|
|
1739
1793
|
});
|
|
1740
1794
|
if (!response.ok) {
|
|
1741
1795
|
const text = await response.text();
|
|
1742
|
-
let raw;
|
|
1796
|
+
let raw = text;
|
|
1743
1797
|
try {
|
|
1744
1798
|
raw = JSON.parse(text);
|
|
1745
1799
|
} catch (_nonJsonGatewayError) {}
|
|
1746
1800
|
const detail = providerErrorDetail(raw);
|
|
1747
1801
|
if (await files.retry(detail)) continue;
|
|
1748
1802
|
const failure = providerError(raw, response.status, response.headers, this.protocol.name);
|
|
1749
|
-
throw new LlmError(files.errorMessage(response.status, failure.message, detail), failure.code, {
|
|
1803
|
+
throw new LlmError(redactProviderDiagnostic(files.errorMessage(response.status, failure.message, detail), secrets), failure.code, {
|
|
1750
1804
|
...failure.failure,
|
|
1751
|
-
cause: new Error(text)
|
|
1805
|
+
cause: new Error(redactProviderDiagnostic(text, secrets))
|
|
1752
1806
|
});
|
|
1753
1807
|
}
|
|
1754
1808
|
await extensions.accept();
|
|
@@ -1757,16 +1811,28 @@ var DeepSeekProtocolAdapter = class extends LlmAdapter {
|
|
|
1757
1811
|
return;
|
|
1758
1812
|
}
|
|
1759
1813
|
} catch (error) {
|
|
1814
|
+
let safeError = error;
|
|
1815
|
+
if (error instanceof Error) {
|
|
1816
|
+
const message = redactProviderDiagnostic(error.message, secrets);
|
|
1817
|
+
const cause = error.cause === void 0 ? void 0 : redactProviderDiagnostic(errorChain(error.cause), secrets);
|
|
1818
|
+
if (message !== error.message || cause !== void 0 && cause !== errorChain(error.cause)) {
|
|
1819
|
+
const options = cause === void 0 ? {} : { cause: new Error(cause) };
|
|
1820
|
+
safeError = error instanceof LlmError ? new LlmError(message, error.code, {
|
|
1821
|
+
...error.failure,
|
|
1822
|
+
...options
|
|
1823
|
+
}) : new Error(message, options);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1760
1826
|
if (auth.onRequestError !== void 0) {
|
|
1761
1827
|
let mapped;
|
|
1762
1828
|
try {
|
|
1763
|
-
mapped = await auth.onRequestError(
|
|
1829
|
+
mapped = await auth.onRequestError(safeError);
|
|
1764
1830
|
} catch (_credentialUpdateFailed) {
|
|
1765
|
-
throw
|
|
1831
|
+
throw safeError;
|
|
1766
1832
|
}
|
|
1767
1833
|
throw mapped;
|
|
1768
1834
|
}
|
|
1769
|
-
throw
|
|
1835
|
+
throw safeError;
|
|
1770
1836
|
}
|
|
1771
1837
|
}
|
|
1772
1838
|
};
|
|
@@ -2590,8 +2656,9 @@ async function* translate(payloads) {
|
|
|
2590
2656
|
try {
|
|
2591
2657
|
chunk = JSON.parse(payload);
|
|
2592
2658
|
} catch (_invalidProviderJson) {
|
|
2593
|
-
throw new LlmError(
|
|
2659
|
+
throw new LlmError("malformed SSE payload", "MALFORMED_RESPONSE");
|
|
2594
2660
|
}
|
|
2661
|
+
if ("error" in chunk) throw providerError(chunk, void 0, void 0, "Chat Completions");
|
|
2595
2662
|
for (const choice of chunk.choices ?? []) {
|
|
2596
2663
|
const delta = choice.delta;
|
|
2597
2664
|
const reasoning = delta?.reasoning_content;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Bounded provider diagnostics with request credentials and endpoint addresses removed. */
|
|
2
|
+
/**
|
|
3
|
+
* Remove credentials, URLs, terminal controls, and oversized response text.
|
|
4
|
+
* @param value - provider message or diagnostic cause.
|
|
5
|
+
* @param secrets - credential and endpoint values captured for this request.
|
|
6
|
+
* @returns a single-line diagnostic capped after redaction.
|
|
7
|
+
*/
|
|
8
|
+
export declare function redactProviderDiagnostic(value: string, secrets?: readonly string[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* Extract human-readable fields without dumping arbitrary JSON response data.
|
|
11
|
+
* @param raw - decoded provider error, or a non-JSON response body.
|
|
12
|
+
* @returns the first nonempty message, detail, msg, or error string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function providerDiagnosticMessage(raw: unknown): string;
|
|
15
|
+
//# sourceMappingURL=error-diagnostic.d.ts.map
|
|
@@ -19,7 +19,7 @@ export declare class DeepSeekProtocolAdapter<C extends Connection = Connection>
|
|
|
19
19
|
name: string;
|
|
20
20
|
};
|
|
21
21
|
providerRetryPolicy(_provider: string): import("@deepseek-ai/dsh-llm").ResolvedRetryPolicy;
|
|
22
|
-
listModels(provider: string): Promise<
|
|
22
|
+
listModels(provider: string): Promise<import("@deepseek-ai/dsh-llm").LlmModelInfo[] | never[]>;
|
|
23
23
|
resolveModel(provider: string, model: string, _signal?: AbortSignal): Promise<{
|
|
24
24
|
context?: import("@deepseek-ai/dsh-llm").LlmModelContext;
|
|
25
25
|
defaultMaxTokens?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Normalize HTTP and in-band
|
|
1
|
+
/** Normalize HTTP and in-band provider errors; the request owner redacts captured secrets. */
|
|
2
2
|
import { LlmError } from '@deepseek-ai/dsh-llm';
|
|
3
3
|
/** Read only provider error fields used by bounded Files recovery.
|
|
4
4
|
* @param raw - decoded HTTP error response.
|