@eddyskywalker/dsh-chatgpt-subscription 0.75.2 → 0.76.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 +35 -0
- package/README.md +1 -1
- package/lib/client.js +978 -789
- package/lib/client.js.map +1 -1
- package/lib/index.js +630 -306
- package/lib/types/client/CodexSubscriptionSection.d.ts.map +1 -1
- package/lib/types/client/antigravity-acp/AntigravityAcpSection.d.ts.map +1 -1
- package/lib/types/client/antigravity-acp/locales.d.ts +6 -0
- package/lib/types/client/antigravity-acp/locales.d.ts.map +1 -1
- package/lib/types/client/claude/ClaudeSection.d.ts.map +1 -1
- package/lib/types/client/cline-pass/ClinePassSection.d.ts.map +1 -1
- package/lib/types/client/command-code/CommandCodeSection.d.ts.map +1 -1
- package/lib/types/client/common/LineProxySection.d.ts +78 -0
- package/lib/types/client/common/LineProxySection.d.ts.map +1 -0
- package/lib/types/client/glm-coding-plan/GlmCodingPlanSection.d.ts.map +1 -1
- package/lib/types/client/kimi-code/KimiCodeSection.d.ts.map +1 -1
- package/lib/types/client/locales-ru/antigravity-acp.d.ts.map +1 -1
- package/lib/types/client/locales-ru/hub.d.ts.map +1 -1
- package/lib/types/client/locales.d.ts +15 -3
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/minimax-code/MinimaxCodeSection.d.ts.map +1 -1
- package/lib/types/client/ollama/OllamaSection.d.ts.map +1 -1
- package/lib/types/client/opendesign/OpenDesignSection.d.ts.map +1 -1
- package/lib/types/client/qoder/QoderSection.d.ts.map +1 -1
- package/lib/types/client/step-code/StepCodeSection.d.ts.map +1 -1
- package/lib/types/client/workbuddy/WorkBuddySection.d.ts.map +1 -1
- package/lib/types/compat.d.ts +1 -1
- package/lib/types/host/antigravity-acp/binary.d.ts +6 -0
- package/lib/types/host/antigravity-acp/binary.d.ts.map +1 -1
- package/lib/types/host/antigravity-acp/login.d.ts +9 -16
- package/lib/types/host/antigravity-acp/login.d.ts.map +1 -1
- package/lib/types/host/preferences.d.ts.map +1 -1
- package/lib/types/host/proxy-manager.d.ts +37 -3
- package/lib/types/host/proxy-manager.d.ts.map +1 -1
- package/lib/types/host/routes.d.ts.map +1 -1
- package/lib/types/host/workbuddy/model-catalog.d.ts +20 -10
- package/lib/types/host/workbuddy/model-catalog.d.ts.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/contracts.d.ts +53 -0
- package/lib/types/shared/contracts.d.ts.map +1 -1
- package/lib/types/shared/preferences.d.ts +51 -1
- package/lib/types/shared/preferences.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -817,7 +817,7 @@ const ROUTE_PREFIX$5 = "/api/dsh-chatgpt-subscription";
|
|
|
817
817
|
* `test/responses-client.test.ts` asserts the two agree, so a release that
|
|
818
818
|
* forgets this constant fails the suite instead of shipping quietly.
|
|
819
819
|
*/
|
|
820
|
-
const PLUGIN_VERSION = "0.
|
|
820
|
+
const PLUGIN_VERSION = "0.76.1";
|
|
821
821
|
const CODEX_CHATGPT_PROVIDER_ID = "codex-chatgpt";
|
|
822
822
|
const CODEX_API_BASE = "https://chatgpt.com/backend-api/codex";
|
|
823
823
|
const CODEX_RESPONSES_URL = `${CODEX_API_BASE}/responses`;
|
|
@@ -6692,6 +6692,337 @@ function isSource(value) {
|
|
|
6692
6692
|
return value !== null;
|
|
6693
6693
|
}
|
|
6694
6694
|
//#endregion
|
|
6695
|
+
//#region src/shared/contracts.ts
|
|
6696
|
+
/**
|
|
6697
|
+
* Every provider line a proxy choice can be stored for.
|
|
6698
|
+
*
|
|
6699
|
+
* The ids are the LLM route ids this plugin registers, not the shorthand some
|
|
6700
|
+
* host tables use: model request control spells the Claude line `claude` while
|
|
6701
|
+
* its route id is `claude-subscription`, and it never lists `opendesign` or
|
|
6702
|
+
* `workbuddy-subscription` under those names. Keeping one list here means the
|
|
6703
|
+
* card, the store and the fetch wiring cannot drift apart.
|
|
6704
|
+
*/
|
|
6705
|
+
const LINE_PROXY_PROVIDER_IDS = [
|
|
6706
|
+
"codex-chatgpt",
|
|
6707
|
+
"claude-subscription",
|
|
6708
|
+
"kimi-code",
|
|
6709
|
+
"minimax-code",
|
|
6710
|
+
"command-code",
|
|
6711
|
+
"ollama",
|
|
6712
|
+
"glm-coding-plan",
|
|
6713
|
+
"step-code",
|
|
6714
|
+
"cline-pass",
|
|
6715
|
+
"qoder",
|
|
6716
|
+
"opendesign",
|
|
6717
|
+
"workbuddy-subscription",
|
|
6718
|
+
"antigravity-acp"
|
|
6719
|
+
];
|
|
6720
|
+
//#endregion
|
|
6721
|
+
//#region src/shared/compaction-route.ts
|
|
6722
|
+
/** Runtime membership test for one stored target. */
|
|
6723
|
+
function isCompactionRouteTarget(value) {
|
|
6724
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6725
|
+
const record = value;
|
|
6726
|
+
return isNonEmptyString(record.provider) && isNonEmptyString(record.model);
|
|
6727
|
+
}
|
|
6728
|
+
function isNonEmptyString(value) {
|
|
6729
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
6730
|
+
}
|
|
6731
|
+
/**
|
|
6732
|
+
* Decide whether the payload is admissible on the target.
|
|
6733
|
+
*
|
|
6734
|
+
* An undisclosed modality list is unknown, not negative: the harness documents
|
|
6735
|
+
* absence as "not disclosed", so refusing on it would disable the feature on
|
|
6736
|
+
* every route that simply does not advertise. The request still runs, and a
|
|
6737
|
+
* real rejection falls back the same way an error does.
|
|
6738
|
+
*
|
|
6739
|
+
* @param facts - what the directory says about the target.
|
|
6740
|
+
* @param needs - what the payload contains.
|
|
6741
|
+
* @returns the refusal reason, or `undefined` when the target may take it.
|
|
6742
|
+
*/
|
|
6743
|
+
function compactionSkipReason(facts, needs) {
|
|
6744
|
+
const modalities = facts.modalities;
|
|
6745
|
+
if (modalities === void 0) return void 0;
|
|
6746
|
+
const accepts = new Set(modalities);
|
|
6747
|
+
if (needs.video && !accepts.has("video")) return "target-accepts-no-video";
|
|
6748
|
+
}
|
|
6749
|
+
/**
|
|
6750
|
+
* Whether the target can carry images inline.
|
|
6751
|
+
*
|
|
6752
|
+
* Used for the recorded outcome only: an image the target cannot take is
|
|
6753
|
+
* replaced by a placeholder during projection, so the summary is still produced
|
|
6754
|
+
* but may describe a screenshot it never saw.
|
|
6755
|
+
*
|
|
6756
|
+
* @param facts - what the directory says about the target.
|
|
6757
|
+
* @returns false only when the target discloses image support and omits it.
|
|
6758
|
+
*/
|
|
6759
|
+
function compactionRoutesImages(facts) {
|
|
6760
|
+
const modalities = facts.modalities;
|
|
6761
|
+
if (modalities === void 0) return true;
|
|
6762
|
+
return modalities.includes("image");
|
|
6763
|
+
}
|
|
6764
|
+
//#endregion
|
|
6765
|
+
//#region src/shared/preferences.ts
|
|
6766
|
+
const PREFERENCES_NAMESPACE = "dsh-chatgpt-subscription";
|
|
6767
|
+
const DEFAULT_PREFERENCES = {
|
|
6768
|
+
enabled: true,
|
|
6769
|
+
quickQuotaVisible: false,
|
|
6770
|
+
fastMode: false,
|
|
6771
|
+
outputVerbosity: null,
|
|
6772
|
+
reasoningSummary: null,
|
|
6773
|
+
visibleModelIds: [...DEFAULT_VISIBLE_CODEX_MODEL_IDS],
|
|
6774
|
+
searchProvider: "dsh",
|
|
6775
|
+
contextWindowOverrides: {},
|
|
6776
|
+
proxyMode: "auto",
|
|
6777
|
+
customProxyUrl: null,
|
|
6778
|
+
noProxy: null,
|
|
6779
|
+
lineProxies: {},
|
|
6780
|
+
compactionRoute: null,
|
|
6781
|
+
subagentDefaultModels: [],
|
|
6782
|
+
subagentModelsByMainModel: {},
|
|
6783
|
+
subagentDefaultAllowParentFork: false,
|
|
6784
|
+
subagentAllowParentForkByMainModel: {}
|
|
6785
|
+
};
|
|
6786
|
+
const SEARCH_PROVIDER_CODEX = "codex";
|
|
6787
|
+
function isSearchProviderPreference(value) {
|
|
6788
|
+
return value === "dsh" || value === "codex";
|
|
6789
|
+
}
|
|
6790
|
+
function isCodexOutputVerbosity(value) {
|
|
6791
|
+
return value === "low" || value === "medium" || value === "high";
|
|
6792
|
+
}
|
|
6793
|
+
function isCodexReasoningSummary(value) {
|
|
6794
|
+
return value === "auto" || value === "concise" || value === "detailed" || value === "none";
|
|
6795
|
+
}
|
|
6796
|
+
function isProxyMode(value) {
|
|
6797
|
+
return value === "auto" || value === "custom" || value === "direct";
|
|
6798
|
+
}
|
|
6799
|
+
/** The shipped per-line proxy: system proxy, exactly like the old shared setting. */
|
|
6800
|
+
const DEFAULT_LINE_PROXY = {
|
|
6801
|
+
mode: "auto",
|
|
6802
|
+
customProxyUrl: null
|
|
6803
|
+
};
|
|
6804
|
+
/**
|
|
6805
|
+
* One custom proxy URL in the shape the transport accepts.
|
|
6806
|
+
*
|
|
6807
|
+
* Mirrors the shared preference store's own normalization: a bare `host:port`
|
|
6808
|
+
* gains `http://`, and a blank URL is `null` (which makes a `custom` line fall
|
|
6809
|
+
* back to a direct connection, the same reading the global setting had).
|
|
6810
|
+
* @param value - Raw URL from a card or a stored document.
|
|
6811
|
+
* @returns the normalized URL, or null when there is none.
|
|
6812
|
+
*/
|
|
6813
|
+
function normalizeLineProxyUrl(value) {
|
|
6814
|
+
if (typeof value !== "string") return null;
|
|
6815
|
+
const trimmed = value.trim();
|
|
6816
|
+
if (trimmed.length === 0) return null;
|
|
6817
|
+
if (/^https?:\/\//i.test(trimmed) || /^socks5?:\/\//i.test(trimmed)) return trimmed;
|
|
6818
|
+
return `http://${trimmed}`;
|
|
6819
|
+
}
|
|
6820
|
+
/**
|
|
6821
|
+
* Normalize one line's proxy entry.
|
|
6822
|
+
* @param value - Candidate entry from a card or a stored document.
|
|
6823
|
+
* @returns the normalized entry, or null when the value is not a usable one.
|
|
6824
|
+
*/
|
|
6825
|
+
function normalizeLineProxyConfig(value) {
|
|
6826
|
+
const record = asRecord$24(value);
|
|
6827
|
+
if (record === void 0) return null;
|
|
6828
|
+
const mode = record["mode"];
|
|
6829
|
+
if (!isProxyMode(mode)) return null;
|
|
6830
|
+
const customProxyUrl = normalizeLineProxyUrl(record["customProxyUrl"]);
|
|
6831
|
+
return {
|
|
6832
|
+
mode,
|
|
6833
|
+
customProxyUrl: mode === "custom" ? customProxyUrl : null
|
|
6834
|
+
};
|
|
6835
|
+
}
|
|
6836
|
+
/**
|
|
6837
|
+
* Merge a per-line proxy patch into the stored map.
|
|
6838
|
+
*
|
|
6839
|
+
* A merge, not a replace: saving one card must not rewrite the other twelve,
|
|
6840
|
+
* and `null` is how one line returns to the shipped `auto` default. Unknown
|
|
6841
|
+
* provider ids are refused rather than stored, because a typo would otherwise
|
|
6842
|
+
* look like a saved setting that never takes effect.
|
|
6843
|
+
* @param current - Map already stored in the preferences document.
|
|
6844
|
+
* @param patch - Incoming patch from a settings card or a route body.
|
|
6845
|
+
* @returns the merged map, or null when any key or value is malformed.
|
|
6846
|
+
*/
|
|
6847
|
+
function mergeLineProxies(current, patch) {
|
|
6848
|
+
const record = asRecord$24(patch);
|
|
6849
|
+
if (record === void 0) return null;
|
|
6850
|
+
const merged = { ...current };
|
|
6851
|
+
for (const [rawKey, rawValue] of Object.entries(record)) {
|
|
6852
|
+
const key = rawKey.trim();
|
|
6853
|
+
if (!isLineProxyProviderId(key)) return null;
|
|
6854
|
+
if (rawValue === null) {
|
|
6855
|
+
delete merged[key];
|
|
6856
|
+
continue;
|
|
6857
|
+
}
|
|
6858
|
+
const normalized = normalizeLineProxyConfig(rawValue);
|
|
6859
|
+
if (normalized === null) return null;
|
|
6860
|
+
merged[key] = normalized;
|
|
6861
|
+
}
|
|
6862
|
+
return merged;
|
|
6863
|
+
}
|
|
6864
|
+
/**
|
|
6865
|
+
* Whether one id names a provider line a proxy can be stored for.
|
|
6866
|
+
* @param value - Candidate provider id.
|
|
6867
|
+
* @returns whether the id is in {@link LINE_PROXY_PROVIDER_IDS}.
|
|
6868
|
+
*/
|
|
6869
|
+
function isLineProxyProviderId(value) {
|
|
6870
|
+
return typeof value === "string" && LINE_PROXY_PROVIDER_IDS.includes(value);
|
|
6871
|
+
}
|
|
6872
|
+
/**
|
|
6873
|
+
* Canonical form of one `NO_PROXY`-style bypass list.
|
|
6874
|
+
*
|
|
6875
|
+
* Entries may be separated by commas or whitespace, because a list pasted from
|
|
6876
|
+
* a README or a shell export is usually one or the other. Each entry is trimmed
|
|
6877
|
+
* and the list is deduplicated case-insensitively on first spelling and order:
|
|
6878
|
+
* the card shows the user's own arrangement back to them, while a host named
|
|
6879
|
+
* twice can never produce two matcher entries.
|
|
6880
|
+
* @param value - Raw list from the card, the environment, or a document.
|
|
6881
|
+
* @returns the canonical comma-separated list; an empty string when none.
|
|
6882
|
+
*/
|
|
6883
|
+
function normalizeNoProxyList(value) {
|
|
6884
|
+
const entries = [];
|
|
6885
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6886
|
+
for (const raw of value.split(/[,\s]+/)) {
|
|
6887
|
+
const entry = raw.trim();
|
|
6888
|
+
if (entry.length === 0) continue;
|
|
6889
|
+
const key = entry.toLowerCase();
|
|
6890
|
+
if (seen.has(key)) continue;
|
|
6891
|
+
seen.add(key);
|
|
6892
|
+
entries.push(entry);
|
|
6893
|
+
}
|
|
6894
|
+
return entries.join(", ");
|
|
6895
|
+
}
|
|
6896
|
+
function asRecord$24(value) {
|
|
6897
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
6898
|
+
}
|
|
6899
|
+
/**
|
|
6900
|
+
* Read one non-empty trimmed string field.
|
|
6901
|
+
* @param value - Candidate field value from stored JSON.
|
|
6902
|
+
* @returns the trimmed string, or undefined when it is not a non-empty string.
|
|
6903
|
+
*/
|
|
6904
|
+
function trimmedString(value) {
|
|
6905
|
+
if (typeof value !== "string") return void 0;
|
|
6906
|
+
const trimmed = value.trim();
|
|
6907
|
+
return trimmed.length === 0 ? void 0 : trimmed;
|
|
6908
|
+
}
|
|
6909
|
+
/**
|
|
6910
|
+
* Whether one value is a complete `{ provider, model }` route.
|
|
6911
|
+
*
|
|
6912
|
+
* Both halves are trimmed and must be non-empty: a route with a blank provider
|
|
6913
|
+
* names no adapter, and a blank model names no model, so neither can ever be
|
|
6914
|
+
* authorized. Stored documents are untrusted JSON, which is why this narrows
|
|
6915
|
+
* rather than asserts.
|
|
6916
|
+
* @param value - Candidate route.
|
|
6917
|
+
* @returns whether the value is a usable route.
|
|
6918
|
+
*/
|
|
6919
|
+
function isSubagentModelRoute(value) {
|
|
6920
|
+
const record = asRecord$24(value);
|
|
6921
|
+
if (record === void 0) return false;
|
|
6922
|
+
return trimmedString(record["provider"]) !== void 0 && trimmedString(record["model"]) !== void 0;
|
|
6923
|
+
}
|
|
6924
|
+
/**
|
|
6925
|
+
* Normalize one route list, deduplicating it without reordering.
|
|
6926
|
+
*
|
|
6927
|
+
* Order is preserved because it is the order the settings card shows and the
|
|
6928
|
+
* order `list_subagent_models` prints: a set would silently reshuffle the list
|
|
6929
|
+
* a user arranged.
|
|
6930
|
+
* @param value - Candidate route list from stored JSON.
|
|
6931
|
+
* @returns the trimmed, deduplicated routes, or null when the value is not an
|
|
6932
|
+
* array of well-formed routes.
|
|
6933
|
+
*/
|
|
6934
|
+
function normalizeSubagentModelRoutes(value) {
|
|
6935
|
+
if (!Array.isArray(value)) return null;
|
|
6936
|
+
const routes = [];
|
|
6937
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6938
|
+
for (const entry of value) {
|
|
6939
|
+
if (!isSubagentModelRoute(entry)) return null;
|
|
6940
|
+
const provider = entry.provider.trim();
|
|
6941
|
+
const model = entry.model.trim();
|
|
6942
|
+
const key = `${provider}/${model}`;
|
|
6943
|
+
if (seen.has(key)) continue;
|
|
6944
|
+
seen.add(key);
|
|
6945
|
+
routes.push({
|
|
6946
|
+
provider,
|
|
6947
|
+
model
|
|
6948
|
+
});
|
|
6949
|
+
}
|
|
6950
|
+
return routes;
|
|
6951
|
+
}
|
|
6952
|
+
/**
|
|
6953
|
+
* Whether one key names a main agent route as `provider/model`.
|
|
6954
|
+
*
|
|
6955
|
+
* The split is at the FIRST slash, so a model id that legally contains a slash
|
|
6956
|
+
* (`command-code` + `deepseek/deepseek-v4.1-flash`) still round-trips: the
|
|
6957
|
+
* provider half ends at the first separator and the model half keeps the rest.
|
|
6958
|
+
* @param key - Candidate map key.
|
|
6959
|
+
* @returns whether the key carries a non-empty provider and a non-empty model.
|
|
6960
|
+
*/
|
|
6961
|
+
function isValidMainModelKey(key) {
|
|
6962
|
+
if (typeof key !== "string") return false;
|
|
6963
|
+
const trimmed = key.trim();
|
|
6964
|
+
const separator = trimmed.indexOf("/");
|
|
6965
|
+
if (separator <= 0) return false;
|
|
6966
|
+
return trimmed.slice(separator + 1).length > 0;
|
|
6967
|
+
}
|
|
6968
|
+
/**
|
|
6969
|
+
* Merge one `subagentModelsByMainModel` patch into the stored map.
|
|
6970
|
+
*
|
|
6971
|
+
* A merge rather than a replace, so the card can clear or set one main model
|
|
6972
|
+
* without resending every other entry — and `null` (or `[]`) is how one entry
|
|
6973
|
+
* is cleared, since a stored map has no other way to say "no override".
|
|
6974
|
+
* @param current - Map already stored in the preferences document.
|
|
6975
|
+
* @param patch - Incoming patch from a settings card or a route body.
|
|
6976
|
+
* @returns the merged map, or null when any key or value is malformed.
|
|
6977
|
+
*/
|
|
6978
|
+
function mergeSubagentModelsByMainModel(current, patch) {
|
|
6979
|
+
const patchRecord = asRecord$24(patch);
|
|
6980
|
+
if (patchRecord === void 0) return null;
|
|
6981
|
+
const merged = { ...current };
|
|
6982
|
+
for (const [rawKey, rawRoutes] of Object.entries(patchRecord)) {
|
|
6983
|
+
const key = rawKey.trim();
|
|
6984
|
+
if (!isValidMainModelKey(key)) return null;
|
|
6985
|
+
if (rawRoutes === null || Array.isArray(rawRoutes) && rawRoutes.length === 0) {
|
|
6986
|
+
delete merged[key];
|
|
6987
|
+
continue;
|
|
6988
|
+
}
|
|
6989
|
+
const routes = normalizeSubagentModelRoutes(rawRoutes);
|
|
6990
|
+
if (routes === null) return null;
|
|
6991
|
+
merged[key] = routes;
|
|
6992
|
+
}
|
|
6993
|
+
return merged;
|
|
6994
|
+
}
|
|
6995
|
+
/**
|
|
6996
|
+
* Merge one `subagentAllowParentForkByMainModel` patch into the stored map.
|
|
6997
|
+
*
|
|
6998
|
+
* `null` clears one key so that main model falls back to
|
|
6999
|
+
* `subagentDefaultAllowParentFork`; a boolean sets an explicit per-main-model
|
|
7000
|
+
* override (`true` OR `false`, since overriding a `true` global default back to
|
|
7001
|
+
* `false` for one main model is legitimate).
|
|
7002
|
+
* @param current - Map already stored in the preferences document.
|
|
7003
|
+
* @param patch - Incoming patch from a settings card or a route body.
|
|
7004
|
+
* @returns the merged map, or null when any key or value is malformed.
|
|
7005
|
+
*/
|
|
7006
|
+
function mergeSubagentAllowParentForkByMainModel(current, patch) {
|
|
7007
|
+
const patchRecord = asRecord$24(patch);
|
|
7008
|
+
if (patchRecord === void 0) return null;
|
|
7009
|
+
const merged = {};
|
|
7010
|
+
if (current !== void 0) {
|
|
7011
|
+
for (const [k, v] of Object.entries(current)) if (typeof v === "boolean" && isValidMainModelKey(k)) merged[k.trim()] = v;
|
|
7012
|
+
}
|
|
7013
|
+
for (const [rawKey, rawValue] of Object.entries(patchRecord)) {
|
|
7014
|
+
const key = rawKey.trim();
|
|
7015
|
+
if (!isValidMainModelKey(key)) return null;
|
|
7016
|
+
if (rawValue === null) {
|
|
7017
|
+
delete merged[key];
|
|
7018
|
+
continue;
|
|
7019
|
+
}
|
|
7020
|
+
if (typeof rawValue !== "boolean") return null;
|
|
7021
|
+
merged[key] = rawValue;
|
|
7022
|
+
}
|
|
7023
|
+
return merged;
|
|
7024
|
+
}
|
|
7025
|
+
//#endregion
|
|
6695
7026
|
//#region src/host/proxy-manager.ts
|
|
6696
7027
|
const SYSTEM_PROXY_CACHE_TTL_MS = 5e3;
|
|
6697
7028
|
/**
|
|
@@ -6727,8 +7058,8 @@ function proxyAgentOptions(uri, allowH2, headersTimeoutMs) {
|
|
|
6727
7058
|
};
|
|
6728
7059
|
}
|
|
6729
7060
|
/** One pool per (proxy, protocol policy, credential): neither policy nor identity may be shared. */
|
|
6730
|
-
function agentCacheKey(proxyUrl, allowH2, poolKey, headersTimeoutMs) {
|
|
6731
|
-
return `${poolKey ?? "shared"}:${allowH2 === false ? "h1" : "auto"}:${headersTimeoutMs ?? "default"}:${proxyUrl}`;
|
|
7061
|
+
function agentCacheKey(proxyUrl, allowH2, poolKey, headersTimeoutMs, line) {
|
|
7062
|
+
return `${line ?? "shared"}:${poolKey ?? "shared"}:${allowH2 === false ? "h1" : "auto"}:${headersTimeoutMs ?? "default"}:${proxyUrl}`;
|
|
6732
7063
|
}
|
|
6733
7064
|
/** The key of the dispatcher that serves one credential's unproxied traffic. */
|
|
6734
7065
|
function directAgentKey(poolKey, allowH2, omitAlpn, headersTimeoutMs) {
|
|
@@ -7169,21 +7500,34 @@ var ProxyManager = class {
|
|
|
7169
7500
|
/**
|
|
7170
7501
|
* The active `NO_PROXY` list, re-read at most once per TTL.
|
|
7171
7502
|
*
|
|
7503
|
+
* Two sources, one answer: the deployment list from {@link ProxyFetchOptions.noProxyReader}
|
|
7504
|
+
* and the list the settings card stores in `getPreferences().noProxy`. Neither
|
|
7505
|
+
* replaces the other, because the card is the discoverable place and the
|
|
7506
|
+
* environment file is the deployment-level place.
|
|
7507
|
+
*
|
|
7172
7508
|
* A reader that throws (an unreadable `$DSH_HOME/.env`) reads as "no bypass
|
|
7173
7509
|
* list", never as "bypass everything": the wrong guess in that direction would
|
|
7174
|
-
* take an active proxy away from every line at once.
|
|
7510
|
+
* take an active proxy away from every line at once. The same applies to one
|
|
7511
|
+
* source failing: the other source still answers.
|
|
7175
7512
|
*/
|
|
7176
7513
|
getNoProxyList(force = false) {
|
|
7177
7514
|
const now = Date.now();
|
|
7178
7515
|
if (!force && now - this.lastNoProxyCheck < SYSTEM_PROXY_CACHE_TTL_MS) return this.cachedNoProxy;
|
|
7179
7516
|
this.lastNoProxyCheck = now;
|
|
7180
|
-
|
|
7181
|
-
this.cachedNoProxy = this.noProxyReader().trim();
|
|
7182
|
-
} catch {
|
|
7183
|
-
this.cachedNoProxy = "";
|
|
7184
|
-
}
|
|
7517
|
+
this.cachedNoProxy = this.readNoProxyList();
|
|
7185
7518
|
return this.cachedNoProxy;
|
|
7186
7519
|
}
|
|
7520
|
+
/** Both bypass sources, canonicalized and concatenated; each failure reads as empty. */
|
|
7521
|
+
readNoProxyList() {
|
|
7522
|
+
const parts = [];
|
|
7523
|
+
try {
|
|
7524
|
+
parts.push(this.noProxyReader());
|
|
7525
|
+
} catch {}
|
|
7526
|
+
try {
|
|
7527
|
+
parts.push(this.getPreferences().noProxy ?? "");
|
|
7528
|
+
} catch {}
|
|
7529
|
+
return normalizeNoProxyList(parts.join(","));
|
|
7530
|
+
}
|
|
7187
7531
|
/**
|
|
7188
7532
|
* Observe the system proxy becoming known.
|
|
7189
7533
|
*
|
|
@@ -7200,15 +7544,30 @@ var ProxyManager = class {
|
|
|
7200
7544
|
this.proxyListeners.delete(listener);
|
|
7201
7545
|
};
|
|
7202
7546
|
}
|
|
7203
|
-
|
|
7547
|
+
/**
|
|
7548
|
+
* The proxy one provider line actually uses.
|
|
7549
|
+
*
|
|
7550
|
+
* With a `line`, that line's own entry decides: an absent entry is the
|
|
7551
|
+
* shipped `auto` default, so a fresh install keeps following the machine and
|
|
7552
|
+
* a line a user never opened is not silently forced direct. Without a
|
|
7553
|
+
* `line`, the retired shared pair answers — kept only so an older caller (or
|
|
7554
|
+
* a deployment pinning the old field) still resolves to what it always did.
|
|
7555
|
+
*
|
|
7556
|
+
* @param line - Provider id whose entry should decide, or undefined for the
|
|
7557
|
+
* legacy shared setting.
|
|
7558
|
+
* @returns the proxy URL in force, or null for a direct connection.
|
|
7559
|
+
*/
|
|
7560
|
+
resolveActiveProxyUrl(line) {
|
|
7204
7561
|
const prefs = this.getPreferences();
|
|
7205
|
-
const
|
|
7562
|
+
const entry = line === void 0 ? void 0 : (prefs.lineProxies ?? {})[line];
|
|
7563
|
+
const mode = entry?.mode ?? (line === void 0 ? prefs.proxyMode ?? "auto" : DEFAULT_LINE_PROXY.mode);
|
|
7564
|
+
const customUrl = line === void 0 ? prefs.customProxyUrl : entry?.customProxyUrl ?? null;
|
|
7206
7565
|
if (mode === "direct") return null;
|
|
7207
|
-
if (mode === "custom") return
|
|
7566
|
+
if (mode === "custom") return customUrl ? normalizeProxyUrl(customUrl) : null;
|
|
7208
7567
|
return this.getSystemProxy();
|
|
7209
7568
|
}
|
|
7210
|
-
getOrCreateAgent(proxyUrl, allowH2, poolKey, headersTimeoutMs) {
|
|
7211
|
-
const key = agentCacheKey(proxyUrl, allowH2, poolKey, headersTimeoutMs);
|
|
7569
|
+
getOrCreateAgent(proxyUrl, allowH2, poolKey, headersTimeoutMs, line) {
|
|
7570
|
+
const key = agentCacheKey(proxyUrl, allowH2, poolKey, headersTimeoutMs, line);
|
|
7212
7571
|
const existing = this.agents.get(key);
|
|
7213
7572
|
if (existing instanceof ProxyAgent) return existing;
|
|
7214
7573
|
const agent = new ProxyAgent(proxyAgentOptions(proxyUrl, allowH2, headersTimeoutMs));
|
|
@@ -7280,15 +7639,15 @@ var ProxyManager = class {
|
|
|
7280
7639
|
};
|
|
7281
7640
|
return async (input, init) => {
|
|
7282
7641
|
const poolKey = overrides?.credentialPools === true ? credentialPoolKey(init) : void 0;
|
|
7283
|
-
const activeProxy = this.resolveActiveProxyUrl();
|
|
7642
|
+
const activeProxy = this.resolveActiveProxyUrl(overrides?.line);
|
|
7284
7643
|
if (!activeProxy) return poolKey === void 0 && overrides?.headersTimeoutMs === void 0 ? this.baseFetch(input, init) : this.dispatchWith(input, init, shape(this.getOrCreateDirectAgent(poolKey ?? "shared", overrides)));
|
|
7285
7644
|
if (shouldBypassProxy(requestTarget(input), this.getNoProxyList())) return poolKey === void 0 && overrides?.headersTimeoutMs === void 0 ? this.baseFetch(input, init) : this.dispatchWith(input, init, shape(this.getOrCreateDirectAgent(poolKey ?? "shared", overrides)));
|
|
7286
7645
|
for (let attempt = 0;; attempt += 1) try {
|
|
7287
|
-
const agent = shape(this.getOrCreateAgent(activeProxy, overrides?.allowH2, poolKey, overrides?.headersTimeoutMs));
|
|
7646
|
+
const agent = shape(this.getOrCreateAgent(activeProxy, overrides?.allowH2, poolKey, overrides?.headersTimeoutMs, overrides?.line));
|
|
7288
7647
|
return await this.dispatchWith(input, init, agent);
|
|
7289
7648
|
} catch (error) {
|
|
7290
7649
|
if (attempt === 0 && isDestroyedClientError(error)) {
|
|
7291
|
-
this.agents.delete(agentCacheKey(activeProxy, overrides?.allowH2, poolKey, overrides?.headersTimeoutMs));
|
|
7650
|
+
this.agents.delete(agentCacheKey(activeProxy, overrides?.allowH2, poolKey, overrides?.headersTimeoutMs, overrides?.line));
|
|
7292
7651
|
continue;
|
|
7293
7652
|
}
|
|
7294
7653
|
throw error;
|
|
@@ -8693,212 +9052,6 @@ var FilePreferencesStore = class {
|
|
|
8693
9052
|
}
|
|
8694
9053
|
};
|
|
8695
9054
|
//#endregion
|
|
8696
|
-
//#region src/shared/compaction-route.ts
|
|
8697
|
-
/** Runtime membership test for one stored target. */
|
|
8698
|
-
function isCompactionRouteTarget(value) {
|
|
8699
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
8700
|
-
const record = value;
|
|
8701
|
-
return isNonEmptyString(record.provider) && isNonEmptyString(record.model);
|
|
8702
|
-
}
|
|
8703
|
-
function isNonEmptyString(value) {
|
|
8704
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
8705
|
-
}
|
|
8706
|
-
/**
|
|
8707
|
-
* Decide whether the payload is admissible on the target.
|
|
8708
|
-
*
|
|
8709
|
-
* An undisclosed modality list is unknown, not negative: the harness documents
|
|
8710
|
-
* absence as "not disclosed", so refusing on it would disable the feature on
|
|
8711
|
-
* every route that simply does not advertise. The request still runs, and a
|
|
8712
|
-
* real rejection falls back the same way an error does.
|
|
8713
|
-
*
|
|
8714
|
-
* @param facts - what the directory says about the target.
|
|
8715
|
-
* @param needs - what the payload contains.
|
|
8716
|
-
* @returns the refusal reason, or `undefined` when the target may take it.
|
|
8717
|
-
*/
|
|
8718
|
-
function compactionSkipReason(facts, needs) {
|
|
8719
|
-
const modalities = facts.modalities;
|
|
8720
|
-
if (modalities === void 0) return void 0;
|
|
8721
|
-
const accepts = new Set(modalities);
|
|
8722
|
-
if (needs.video && !accepts.has("video")) return "target-accepts-no-video";
|
|
8723
|
-
}
|
|
8724
|
-
/**
|
|
8725
|
-
* Whether the target can carry images inline.
|
|
8726
|
-
*
|
|
8727
|
-
* Used for the recorded outcome only: an image the target cannot take is
|
|
8728
|
-
* replaced by a placeholder during projection, so the summary is still produced
|
|
8729
|
-
* but may describe a screenshot it never saw.
|
|
8730
|
-
*
|
|
8731
|
-
* @param facts - what the directory says about the target.
|
|
8732
|
-
* @returns false only when the target discloses image support and omits it.
|
|
8733
|
-
*/
|
|
8734
|
-
function compactionRoutesImages(facts) {
|
|
8735
|
-
const modalities = facts.modalities;
|
|
8736
|
-
if (modalities === void 0) return true;
|
|
8737
|
-
return modalities.includes("image");
|
|
8738
|
-
}
|
|
8739
|
-
//#endregion
|
|
8740
|
-
//#region src/shared/preferences.ts
|
|
8741
|
-
const PREFERENCES_NAMESPACE = "dsh-chatgpt-subscription";
|
|
8742
|
-
const DEFAULT_PREFERENCES = {
|
|
8743
|
-
enabled: true,
|
|
8744
|
-
quickQuotaVisible: false,
|
|
8745
|
-
fastMode: false,
|
|
8746
|
-
outputVerbosity: null,
|
|
8747
|
-
reasoningSummary: null,
|
|
8748
|
-
visibleModelIds: [...DEFAULT_VISIBLE_CODEX_MODEL_IDS],
|
|
8749
|
-
searchProvider: "dsh",
|
|
8750
|
-
contextWindowOverrides: {},
|
|
8751
|
-
proxyMode: "auto",
|
|
8752
|
-
customProxyUrl: null,
|
|
8753
|
-
compactionRoute: null,
|
|
8754
|
-
subagentDefaultModels: [],
|
|
8755
|
-
subagentModelsByMainModel: {},
|
|
8756
|
-
subagentDefaultAllowParentFork: false,
|
|
8757
|
-
subagentAllowParentForkByMainModel: {}
|
|
8758
|
-
};
|
|
8759
|
-
const SEARCH_PROVIDER_CODEX = "codex";
|
|
8760
|
-
function isSearchProviderPreference(value) {
|
|
8761
|
-
return value === "dsh" || value === "codex";
|
|
8762
|
-
}
|
|
8763
|
-
function isCodexOutputVerbosity(value) {
|
|
8764
|
-
return value === "low" || value === "medium" || value === "high";
|
|
8765
|
-
}
|
|
8766
|
-
function isCodexReasoningSummary(value) {
|
|
8767
|
-
return value === "auto" || value === "concise" || value === "detailed" || value === "none";
|
|
8768
|
-
}
|
|
8769
|
-
function isProxyMode(value) {
|
|
8770
|
-
return value === "auto" || value === "custom" || value === "direct";
|
|
8771
|
-
}
|
|
8772
|
-
function asRecord$24(value) {
|
|
8773
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
8774
|
-
}
|
|
8775
|
-
/**
|
|
8776
|
-
* Read one non-empty trimmed string field.
|
|
8777
|
-
* @param value - Candidate field value from stored JSON.
|
|
8778
|
-
* @returns the trimmed string, or undefined when it is not a non-empty string.
|
|
8779
|
-
*/
|
|
8780
|
-
function trimmedString(value) {
|
|
8781
|
-
if (typeof value !== "string") return void 0;
|
|
8782
|
-
const trimmed = value.trim();
|
|
8783
|
-
return trimmed.length === 0 ? void 0 : trimmed;
|
|
8784
|
-
}
|
|
8785
|
-
/**
|
|
8786
|
-
* Whether one value is a complete `{ provider, model }` route.
|
|
8787
|
-
*
|
|
8788
|
-
* Both halves are trimmed and must be non-empty: a route with a blank provider
|
|
8789
|
-
* names no adapter, and a blank model names no model, so neither can ever be
|
|
8790
|
-
* authorized. Stored documents are untrusted JSON, which is why this narrows
|
|
8791
|
-
* rather than asserts.
|
|
8792
|
-
* @param value - Candidate route.
|
|
8793
|
-
* @returns whether the value is a usable route.
|
|
8794
|
-
*/
|
|
8795
|
-
function isSubagentModelRoute(value) {
|
|
8796
|
-
const record = asRecord$24(value);
|
|
8797
|
-
if (record === void 0) return false;
|
|
8798
|
-
return trimmedString(record["provider"]) !== void 0 && trimmedString(record["model"]) !== void 0;
|
|
8799
|
-
}
|
|
8800
|
-
/**
|
|
8801
|
-
* Normalize one route list, deduplicating it without reordering.
|
|
8802
|
-
*
|
|
8803
|
-
* Order is preserved because it is the order the settings card shows and the
|
|
8804
|
-
* order `list_subagent_models` prints: a set would silently reshuffle the list
|
|
8805
|
-
* a user arranged.
|
|
8806
|
-
* @param value - Candidate route list from stored JSON.
|
|
8807
|
-
* @returns the trimmed, deduplicated routes, or null when the value is not an
|
|
8808
|
-
* array of well-formed routes.
|
|
8809
|
-
*/
|
|
8810
|
-
function normalizeSubagentModelRoutes(value) {
|
|
8811
|
-
if (!Array.isArray(value)) return null;
|
|
8812
|
-
const routes = [];
|
|
8813
|
-
const seen = /* @__PURE__ */ new Set();
|
|
8814
|
-
for (const entry of value) {
|
|
8815
|
-
if (!isSubagentModelRoute(entry)) return null;
|
|
8816
|
-
const provider = entry.provider.trim();
|
|
8817
|
-
const model = entry.model.trim();
|
|
8818
|
-
const key = `${provider}/${model}`;
|
|
8819
|
-
if (seen.has(key)) continue;
|
|
8820
|
-
seen.add(key);
|
|
8821
|
-
routes.push({
|
|
8822
|
-
provider,
|
|
8823
|
-
model
|
|
8824
|
-
});
|
|
8825
|
-
}
|
|
8826
|
-
return routes;
|
|
8827
|
-
}
|
|
8828
|
-
/**
|
|
8829
|
-
* Whether one key names a main agent route as `provider/model`.
|
|
8830
|
-
*
|
|
8831
|
-
* The split is at the FIRST slash, so a model id that legally contains a slash
|
|
8832
|
-
* (`command-code` + `deepseek/deepseek-v4.1-flash`) still round-trips: the
|
|
8833
|
-
* provider half ends at the first separator and the model half keeps the rest.
|
|
8834
|
-
* @param key - Candidate map key.
|
|
8835
|
-
* @returns whether the key carries a non-empty provider and a non-empty model.
|
|
8836
|
-
*/
|
|
8837
|
-
function isValidMainModelKey(key) {
|
|
8838
|
-
if (typeof key !== "string") return false;
|
|
8839
|
-
const trimmed = key.trim();
|
|
8840
|
-
const separator = trimmed.indexOf("/");
|
|
8841
|
-
if (separator <= 0) return false;
|
|
8842
|
-
return trimmed.slice(separator + 1).length > 0;
|
|
8843
|
-
}
|
|
8844
|
-
/**
|
|
8845
|
-
* Merge one `subagentModelsByMainModel` patch into the stored map.
|
|
8846
|
-
*
|
|
8847
|
-
* A merge rather than a replace, so the card can clear or set one main model
|
|
8848
|
-
* without resending every other entry — and `null` (or `[]`) is how one entry
|
|
8849
|
-
* is cleared, since a stored map has no other way to say "no override".
|
|
8850
|
-
* @param current - Map already stored in the preferences document.
|
|
8851
|
-
* @param patch - Incoming patch from a settings card or a route body.
|
|
8852
|
-
* @returns the merged map, or null when any key or value is malformed.
|
|
8853
|
-
*/
|
|
8854
|
-
function mergeSubagentModelsByMainModel(current, patch) {
|
|
8855
|
-
const patchRecord = asRecord$24(patch);
|
|
8856
|
-
if (patchRecord === void 0) return null;
|
|
8857
|
-
const merged = { ...current };
|
|
8858
|
-
for (const [rawKey, rawRoutes] of Object.entries(patchRecord)) {
|
|
8859
|
-
const key = rawKey.trim();
|
|
8860
|
-
if (!isValidMainModelKey(key)) return null;
|
|
8861
|
-
if (rawRoutes === null || Array.isArray(rawRoutes) && rawRoutes.length === 0) {
|
|
8862
|
-
delete merged[key];
|
|
8863
|
-
continue;
|
|
8864
|
-
}
|
|
8865
|
-
const routes = normalizeSubagentModelRoutes(rawRoutes);
|
|
8866
|
-
if (routes === null) return null;
|
|
8867
|
-
merged[key] = routes;
|
|
8868
|
-
}
|
|
8869
|
-
return merged;
|
|
8870
|
-
}
|
|
8871
|
-
/**
|
|
8872
|
-
* Merge one `subagentAllowParentForkByMainModel` patch into the stored map.
|
|
8873
|
-
*
|
|
8874
|
-
* `null` clears one key so that main model falls back to
|
|
8875
|
-
* `subagentDefaultAllowParentFork`; a boolean sets an explicit per-main-model
|
|
8876
|
-
* override (`true` OR `false`, since overriding a `true` global default back to
|
|
8877
|
-
* `false` for one main model is legitimate).
|
|
8878
|
-
* @param current - Map already stored in the preferences document.
|
|
8879
|
-
* @param patch - Incoming patch from a settings card or a route body.
|
|
8880
|
-
* @returns the merged map, or null when any key or value is malformed.
|
|
8881
|
-
*/
|
|
8882
|
-
function mergeSubagentAllowParentForkByMainModel(current, patch) {
|
|
8883
|
-
const patchRecord = asRecord$24(patch);
|
|
8884
|
-
if (patchRecord === void 0) return null;
|
|
8885
|
-
const merged = {};
|
|
8886
|
-
if (current !== void 0) {
|
|
8887
|
-
for (const [k, v] of Object.entries(current)) if (typeof v === "boolean" && isValidMainModelKey(k)) merged[k.trim()] = v;
|
|
8888
|
-
}
|
|
8889
|
-
for (const [rawKey, rawValue] of Object.entries(patchRecord)) {
|
|
8890
|
-
const key = rawKey.trim();
|
|
8891
|
-
if (!isValidMainModelKey(key)) return null;
|
|
8892
|
-
if (rawValue === null) {
|
|
8893
|
-
delete merged[key];
|
|
8894
|
-
continue;
|
|
8895
|
-
}
|
|
8896
|
-
if (typeof rawValue !== "boolean") return null;
|
|
8897
|
-
merged[key] = rawValue;
|
|
8898
|
-
}
|
|
8899
|
-
return merged;
|
|
8900
|
-
}
|
|
8901
|
-
//#endregion
|
|
8902
9055
|
//#region src/host/common/legacy-preferences.ts
|
|
8903
9056
|
/**
|
|
8904
9057
|
* One-time import of the preferences earlier releases kept in the harness's own
|
|
@@ -9143,6 +9296,15 @@ function registerPreferenceStore(settings) {
|
|
|
9143
9296
|
z$1.const("direct")
|
|
9144
9297
|
]).default(DEFAULT_PREFERENCES.proxyMode),
|
|
9145
9298
|
customProxyUrl: z$1.union([z$1.string(), z$1.const(null)]).default(DEFAULT_PREFERENCES.customProxyUrl),
|
|
9299
|
+
noProxy: z$1.union([z$1.string(), z$1.const(null)]).default(DEFAULT_PREFERENCES.noProxy ?? null),
|
|
9300
|
+
lineProxies: z$1.dict(z$1.object({
|
|
9301
|
+
mode: z$1.union([
|
|
9302
|
+
z$1.const("auto"),
|
|
9303
|
+
z$1.const("custom"),
|
|
9304
|
+
z$1.const("direct")
|
|
9305
|
+
]),
|
|
9306
|
+
customProxyUrl: z$1.union([z$1.string(), z$1.const(null)])
|
|
9307
|
+
})).default(DEFAULT_PREFERENCES.lineProxies ?? {}),
|
|
9146
9308
|
compactionRoute: z$1.union([z$1.object({
|
|
9147
9309
|
provider: z$1.string(),
|
|
9148
9310
|
model: z$1.string()
|
|
@@ -9161,6 +9323,17 @@ function registerPreferenceStore(settings) {
|
|
|
9161
9323
|
var SettingsPreferenceStore = class {
|
|
9162
9324
|
scope;
|
|
9163
9325
|
load;
|
|
9326
|
+
/** One-shot load plus the one-time per-line proxy migration it triggers. */
|
|
9327
|
+
hydrated;
|
|
9328
|
+
/**
|
|
9329
|
+
* True while the one-time migration writes.
|
|
9330
|
+
*
|
|
9331
|
+
* That write is bookkeeping, not a user change: waking the preference
|
|
9332
|
+
* watchers with it would restart the web provider selection during the
|
|
9333
|
+
* profile composition window, which is exactly the startup race those
|
|
9334
|
+
* watchers' deferral exists to avoid.
|
|
9335
|
+
*/
|
|
9336
|
+
migrating = false;
|
|
9164
9337
|
/**
|
|
9165
9338
|
* @param scope - Namespace scope, or the plugin-owned file store standing in for one.
|
|
9166
9339
|
* @param load - One-shot load of that file store; absent for a settings scope.
|
|
@@ -9170,7 +9343,39 @@ var SettingsPreferenceStore = class {
|
|
|
9170
9343
|
this.load = load;
|
|
9171
9344
|
}
|
|
9172
9345
|
hydrate() {
|
|
9173
|
-
|
|
9346
|
+
this.hydrated ??= this.load().then(() => this.migrateLineProxies());
|
|
9347
|
+
return this.hydrated;
|
|
9348
|
+
}
|
|
9349
|
+
/**
|
|
9350
|
+
* Copy the retired shared proxy setting onto every provider line, once.
|
|
9351
|
+
*
|
|
9352
|
+
* Before per-line proxies there was one `proxyMode`/`customProxyUrl` pair that
|
|
9353
|
+
* every line shared. Leaving those values where they are would be a silent
|
|
9354
|
+
* behaviour change at upgrade: the fields stay for export compatibility, but
|
|
9355
|
+
* nothing reads them any more, so every line would quietly fall back to
|
|
9356
|
+
* `auto`. The migration makes each line state the value it was already using.
|
|
9357
|
+
*
|
|
9358
|
+
* Idempotent by construction: a document that carries ANY per-line entry has
|
|
9359
|
+
* already been migrated (or has been edited since), and is never touched —
|
|
9360
|
+
* re-running this on a user's own choices would silently undo them.
|
|
9361
|
+
*/
|
|
9362
|
+
async migrateLineProxies() {
|
|
9363
|
+
const current = this.scope.get();
|
|
9364
|
+
if (Object.keys(current.lineProxies ?? {}).length > 0) return;
|
|
9365
|
+
const legacy = {
|
|
9366
|
+
mode: current.proxyMode ?? DEFAULT_LINE_PROXY.mode,
|
|
9367
|
+
customProxyUrl: normalizeLineProxyUrl(current.customProxyUrl)
|
|
9368
|
+
};
|
|
9369
|
+
const lineProxies = Object.fromEntries(LINE_PROXY_PROVIDER_IDS.map((line) => [line, {
|
|
9370
|
+
mode: legacy.mode,
|
|
9371
|
+
customProxyUrl: legacy.mode === "custom" ? legacy.customProxyUrl : null
|
|
9372
|
+
}]));
|
|
9373
|
+
this.migrating = true;
|
|
9374
|
+
try {
|
|
9375
|
+
await this.scope.update({ lineProxies });
|
|
9376
|
+
} catch {} finally {
|
|
9377
|
+
this.migrating = false;
|
|
9378
|
+
}
|
|
9174
9379
|
}
|
|
9175
9380
|
status() {
|
|
9176
9381
|
return withWritable(this.scope.get());
|
|
@@ -9227,6 +9432,16 @@ var SettingsPreferenceStore = class {
|
|
|
9227
9432
|
if (merged === null) throw new PreferenceError("Unsupported subagentAllowParentForkByMainModel preference.");
|
|
9228
9433
|
normalized.subagentAllowParentForkByMainModel = merged;
|
|
9229
9434
|
}
|
|
9435
|
+
if (patch.lineProxies !== void 0) {
|
|
9436
|
+
const merged = mergeLineProxies(this.scope.get().lineProxies, patch.lineProxies);
|
|
9437
|
+
if (merged === null) throw new PreferenceError("Unsupported lineProxies preference.");
|
|
9438
|
+
normalized.lineProxies = merged;
|
|
9439
|
+
}
|
|
9440
|
+
if (patch.noProxy !== void 0) {
|
|
9441
|
+
if (patch.noProxy !== null && typeof patch.noProxy !== "string") throw new PreferenceError("Unsupported noProxy preference.");
|
|
9442
|
+
const normalizedList = patch.noProxy === null ? "" : normalizeNoProxyList(patch.noProxy);
|
|
9443
|
+
normalized.noProxy = normalizedList.length === 0 ? null : normalizedList;
|
|
9444
|
+
}
|
|
9230
9445
|
if (patch.customProxyUrl !== void 0) if (patch.customProxyUrl !== null) {
|
|
9231
9446
|
const trimmed = patch.customProxyUrl.trim();
|
|
9232
9447
|
if (trimmed.length > 0 && !/^https?:\/\//i.test(trimmed) && !/^socks5?:\/\//i.test(trimmed)) normalized.customProxyUrl = `http://${trimmed}`;
|
|
@@ -9236,7 +9451,10 @@ var SettingsPreferenceStore = class {
|
|
|
9236
9451
|
return this.status();
|
|
9237
9452
|
}
|
|
9238
9453
|
watch(callback) {
|
|
9239
|
-
return this.scope.watch((next, prev) =>
|
|
9454
|
+
return this.scope.watch((next, prev) => {
|
|
9455
|
+
if (this.migrating) return void 0;
|
|
9456
|
+
return callback(withWritable(next), withWritable(prev));
|
|
9457
|
+
});
|
|
9240
9458
|
}
|
|
9241
9459
|
};
|
|
9242
9460
|
var PreferenceError = class extends Error {
|
|
@@ -12372,12 +12590,26 @@ function registerRoutes(ctx, oauth, usage, preferences, proxyManager, searchSwit
|
|
|
12372
12590
|
codexCliSignInPath,
|
|
12373
12591
|
detectedProxy: proxyManager?.getSystemProxy() ?? null,
|
|
12374
12592
|
activeProxy: proxyManager?.resolveActiveProxyUrl() ?? null,
|
|
12593
|
+
activeProxies: proxyManager === void 0 ? void 0 : Object.fromEntries(LINE_PROXY_PROVIDER_IDS.map((line) => [line, maskProxyUrl(proxyManager.resolveActiveProxyUrl(line))])),
|
|
12375
12594
|
switcher: searchSwitcher?.status() ?? null,
|
|
12376
12595
|
fetchConfiguration
|
|
12377
12596
|
}
|
|
12378
12597
|
});
|
|
12379
12598
|
return;
|
|
12380
12599
|
}
|
|
12600
|
+
if (request.method === "GET" && url.pathname === `/api/dsh-chatgpt-subscription/proxy`) {
|
|
12601
|
+
const prefs = preferences.status();
|
|
12602
|
+
json(response, {
|
|
12603
|
+
ok: true,
|
|
12604
|
+
value: {
|
|
12605
|
+
lineProxies: prefs.lineProxies ?? {},
|
|
12606
|
+
noProxy: prefs.noProxy ?? null,
|
|
12607
|
+
detectedProxy: proxyManager?.getSystemProxy() ?? null,
|
|
12608
|
+
activeProxies: proxyManager === void 0 ? {} : Object.fromEntries(LINE_PROXY_PROVIDER_IDS.map((line) => [line, maskProxyUrl(proxyManager.resolveActiveProxyUrl(line))]))
|
|
12609
|
+
}
|
|
12610
|
+
});
|
|
12611
|
+
return;
|
|
12612
|
+
}
|
|
12381
12613
|
if (request.method === "GET" && url.pathname === `/api/dsh-chatgpt-subscription/subagent-route-audit`) {
|
|
12382
12614
|
const sessionId = url.searchParams.get("sessionId");
|
|
12383
12615
|
if (sessionId === null || sessionId.length === 0) {
|
|
@@ -12746,6 +12978,28 @@ async function compactionCandidates(ctx) {
|
|
|
12746
12978
|
};
|
|
12747
12979
|
}))).filter((provider) => provider.models.length > 0) };
|
|
12748
12980
|
}
|
|
12981
|
+
/**
|
|
12982
|
+
* A proxy URL with any credential half removed.
|
|
12983
|
+
*
|
|
12984
|
+
* The status route reports which proxy a line uses, and a custom proxy may carry
|
|
12985
|
+
* `user:pass@`. The card only needs to say WHICH proxy answered, so the user
|
|
12986
|
+
* half never travels: a settings page is not a place to re-display a secret
|
|
12987
|
+
* that was typed once.
|
|
12988
|
+
* @param value - Resolved proxy URL, or null for a direct connection.
|
|
12989
|
+
* @returns the URL without credentials, or null.
|
|
12990
|
+
*/
|
|
12991
|
+
function maskProxyUrl(value) {
|
|
12992
|
+
if (value === null) return null;
|
|
12993
|
+
try {
|
|
12994
|
+
const url = new URL(value);
|
|
12995
|
+
if (url.username === "" && url.password === "") return value;
|
|
12996
|
+
url.username = "";
|
|
12997
|
+
url.password = "";
|
|
12998
|
+
return url.toString();
|
|
12999
|
+
} catch {
|
|
13000
|
+
return null;
|
|
13001
|
+
}
|
|
13002
|
+
}
|
|
12749
13003
|
function isRecord$64(value) {
|
|
12750
13004
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12751
13005
|
}
|
|
@@ -12821,6 +13075,15 @@ function readPreferencesUpdate(value, current) {
|
|
|
12821
13075
|
if (value.proxyMode !== "auto" && value.proxyMode !== "custom" && value.proxyMode !== "direct") throw new PreferenceError("proxyMode must be auto, custom, or direct.");
|
|
12822
13076
|
patch.proxyMode = value.proxyMode;
|
|
12823
13077
|
}
|
|
13078
|
+
if ("lineProxies" in value) {
|
|
13079
|
+
if (mergeLineProxies(current.lineProxies, value.lineProxies) === null) throw new PreferenceError("lineProxies must map known provider ids to { mode, customProxyUrl }, or null to clear one.");
|
|
13080
|
+
patch.lineProxies = value.lineProxies;
|
|
13081
|
+
}
|
|
13082
|
+
if ("noProxy" in value) {
|
|
13083
|
+
if (value.noProxy !== null && typeof value.noProxy !== "string") throw new PreferenceError("noProxy must be a string or null.");
|
|
13084
|
+
patch.noProxy = value.noProxy === null ? null : normalizeNoProxyList(value.noProxy);
|
|
13085
|
+
if (patch.noProxy === "") patch.noProxy = null;
|
|
13086
|
+
}
|
|
12824
13087
|
if ("customProxyUrl" in value) {
|
|
12825
13088
|
if (value.customProxyUrl !== null && typeof value.customProxyUrl !== "string") throw new PreferenceError("customProxyUrl must be a string or null.");
|
|
12826
13089
|
patch.customProxyUrl = value.customProxyUrl;
|
|
@@ -27498,6 +27761,15 @@ const ACP_BINARY_RELEASES = {
|
|
|
27498
27761
|
executable: "agy_acp_server.par"
|
|
27499
27762
|
}
|
|
27500
27763
|
};
|
|
27764
|
+
/**
|
|
27765
|
+
* Arguments for the resolved executable.
|
|
27766
|
+
* The registry's standalone server already speaks ACP on stdio and rejects the
|
|
27767
|
+
* full CLI's acp and disable-telemetry flags. Detect configured paths too.
|
|
27768
|
+
*/
|
|
27769
|
+
function acpLaunchArgs(binary) {
|
|
27770
|
+
const executable = path.basename(binary.path).toLowerCase();
|
|
27771
|
+
return binary.kind === "downloaded" || executable === "agy_acp_server.exe" || executable === "agy_acp_server.par" ? [] : ["acp", "--disable-telemetry"];
|
|
27772
|
+
}
|
|
27501
27773
|
/** How long a resolved executable is reused before the disk is read again. */
|
|
27502
27774
|
const BINARY_CACHE_TTL_MS = 5 * 6e4;
|
|
27503
27775
|
/** Candidate paths the local CLI may live at, most specific first. */
|
|
@@ -27788,10 +28060,9 @@ function findEndOfCentralDirectory(bytes) {
|
|
|
27788
28060
|
*
|
|
27789
28061
|
* Two consequences follow, and they are the whole design:
|
|
27790
28062
|
*
|
|
27791
|
-
* - **The browser is opened exactly once.**
|
|
27792
|
-
*
|
|
27793
|
-
*
|
|
27794
|
-
* lines. So nothing here calls `openBrowser`.
|
|
28063
|
+
* - **The browser is opened exactly once.** ACP authenticate opens it for
|
|
28064
|
+
* protocol-driven methods; only a server that exclusively offers terminal
|
|
28065
|
+
* login falls back to agy acp --login. Nothing here calls openBrowser.
|
|
27795
28066
|
* - **"Signed in" is a probe, not a flag.** There is no local state to read: the
|
|
27796
28067
|
* only truthful answer comes from asking the agent to create a session, which
|
|
27797
28068
|
* is what {@link probeAuth} does. A failed probe is reported as "not signed in",
|
|
@@ -27815,22 +28086,71 @@ const LOGIN_STDERR_CAP = 2e3;
|
|
|
27815
28086
|
/**
|
|
27816
28087
|
* Start the official sign-in.
|
|
27817
28088
|
*
|
|
27818
|
-
*
|
|
27819
|
-
*
|
|
27820
|
-
*
|
|
27821
|
-
*
|
|
27822
|
-
*
|
|
27823
|
-
* The command line is `agy acp --login`, and a rejected command line, a
|
|
27824
|
-
* misconfigured path or a binary that cannot be spawned all exit (or error)
|
|
27825
|
-
* within milliseconds - and the previous version reported "sign-in started" for
|
|
27826
|
-
* every one of them while discarding the only sentence that explained it. The
|
|
27827
|
-
* launcher is therefore watched for {@link LOGIN_FAILURE_WINDOW_MS}: a spawn
|
|
27828
|
-
* error, or a non-zero exit that left stderr behind, is returned as the reason.
|
|
28089
|
+
* Protocol-driven methods run through ACP authenticate. A server that only
|
|
28090
|
+
* offers terminal-login keeps the detached agy acp --login fallback. Both paths
|
|
28091
|
+
* return after the start-up window instead of waiting for the browser callback,
|
|
28092
|
+
* and both surface an early process or protocol failure instead of claiming
|
|
28093
|
+
* that sign-in started.
|
|
27829
28094
|
*
|
|
27830
28095
|
* @param launch - The resolved executable.
|
|
27831
28096
|
* @returns whether a process was started, and why it was not.
|
|
27832
28097
|
*/
|
|
27833
|
-
function startLogin(launch) {
|
|
28098
|
+
async function startLogin(launch) {
|
|
28099
|
+
let client;
|
|
28100
|
+
try {
|
|
28101
|
+
client = new AcpClient({
|
|
28102
|
+
command: launch.command,
|
|
28103
|
+
args: launch.args,
|
|
28104
|
+
cwd: process.cwd()
|
|
28105
|
+
});
|
|
28106
|
+
const init = asRecord$17(await client.request("initialize", {
|
|
28107
|
+
protocolVersion: 1,
|
|
28108
|
+
clientCapabilities: {
|
|
28109
|
+
fs: {
|
|
28110
|
+
readTextFile: false,
|
|
28111
|
+
writeTextFile: false
|
|
28112
|
+
},
|
|
28113
|
+
terminal: false
|
|
28114
|
+
},
|
|
28115
|
+
clientInfo: {
|
|
28116
|
+
name: "dsh-chatgpt-subscription",
|
|
28117
|
+
version: "1.0.0"
|
|
28118
|
+
}
|
|
28119
|
+
}));
|
|
28120
|
+
const authMethods = Array.isArray(init?.authMethods) ? init.authMethods.map((entry) => String(entry.id ?? "")).filter((id) => id !== "") : [];
|
|
28121
|
+
if (authMethods.length === 0) throw new Error("The Antigravity ACP server advertised no authentication methods.");
|
|
28122
|
+
const methodId = preferAuthMethod(authMethods);
|
|
28123
|
+
if (methodId === "terminal-login") {
|
|
28124
|
+
await client.dispose().catch(() => void 0);
|
|
28125
|
+
return startTerminalLogin(launch);
|
|
28126
|
+
}
|
|
28127
|
+
return await startProtocolLogin(client, methodId);
|
|
28128
|
+
} catch (error) {
|
|
28129
|
+
if (client !== void 0) await client.dispose().catch(() => void 0);
|
|
28130
|
+
return {
|
|
28131
|
+
started: false,
|
|
28132
|
+
error: error instanceof Error ? error.message : String(error)
|
|
28133
|
+
};
|
|
28134
|
+
}
|
|
28135
|
+
}
|
|
28136
|
+
async function startProtocolLogin(client, methodId) {
|
|
28137
|
+
const completion = client.request("authenticate", { methodId }).then(() => ({ started: true }), (error) => ({
|
|
28138
|
+
started: false,
|
|
28139
|
+
error: error instanceof Error ? error.message : String(error)
|
|
28140
|
+
}));
|
|
28141
|
+
completion.then(() => client.dispose().catch(() => void 0));
|
|
28142
|
+
let timer;
|
|
28143
|
+
const detached = new Promise((resolve) => {
|
|
28144
|
+
timer = setTimeout(() => resolve({ started: true }), LOGIN_FAILURE_WINDOW_MS);
|
|
28145
|
+
timer.unref?.();
|
|
28146
|
+
});
|
|
28147
|
+
try {
|
|
28148
|
+
return await Promise.race([completion, detached]);
|
|
28149
|
+
} finally {
|
|
28150
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
28151
|
+
}
|
|
28152
|
+
}
|
|
28153
|
+
function startTerminalLogin(launch) {
|
|
27834
28154
|
let child;
|
|
27835
28155
|
try {
|
|
27836
28156
|
child = spawn(launch.command, [...launch.args, "--login"], {
|
|
@@ -97886,7 +98206,7 @@ function refreshSourceForDomain(domain) {
|
|
|
97886
98206
|
* with that list — so a row living only in the fallback would drop out of the
|
|
97887
98207
|
* picker the moment the catalog loaded.
|
|
97888
98208
|
*
|
|
97889
|
-
* The list is empty as of the 2026-11-
|
|
98209
|
+
* The list is empty as of the 2026-11-16 read: all three ids are published now,
|
|
97890
98210
|
* with figures measured on the wire, and their rows therefore live in
|
|
97891
98211
|
* {@link FALLBACK_MODELS} like any other. The seam stays rather than being
|
|
97892
98212
|
* deleted because the gap it covers belongs to the gateway, not to those three
|
|
@@ -97897,7 +98217,7 @@ const UNPUBLISHED_MODELS = [];
|
|
|
97897
98217
|
/**
|
|
97898
98218
|
* Offline fallback catalog, transcribed from a live `/v3/config` read.
|
|
97899
98219
|
*
|
|
97900
|
-
* Last transcribed 2026-11-
|
|
98220
|
+
* Last transcribed 2026-11-16 from both backends. Used when the gateway cannot
|
|
97901
98221
|
* be reached (first run before sign-in, or a network failure); a reachable
|
|
97902
98222
|
* gateway always wins.
|
|
97903
98223
|
*/
|
|
@@ -97988,7 +98308,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
97988
98308
|
],
|
|
97989
98309
|
defaultReasoningEffort: "high",
|
|
97990
98310
|
canDisableThinking: false,
|
|
97991
|
-
description: "DeepSeek
|
|
98311
|
+
description: "DeepSeek · 修订版 1017 · 原生多模态模型,支持 1M 上下文"
|
|
97992
98312
|
},
|
|
97993
98313
|
{
|
|
97994
98314
|
id: "deepseek-v4.1-flash-sg",
|
|
@@ -98027,7 +98347,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98027
98347
|
],
|
|
98028
98348
|
defaultReasoningEffort: "high",
|
|
98029
98349
|
canDisableThinking: false,
|
|
98030
|
-
description: "原生多模态模型,擅长视觉理解与专业任务"
|
|
98350
|
+
description: "Z.ai · 原生多模态模型,擅长视觉理解与专业任务"
|
|
98031
98351
|
},
|
|
98032
98352
|
{
|
|
98033
98353
|
id: "gpt-6-astra",
|
|
@@ -98069,11 +98389,8 @@ const FALLBACK_MODELS$1 = [
|
|
|
98069
98389
|
contextWindow: 192e3,
|
|
98070
98390
|
maxContextWindow: 192e3,
|
|
98071
98391
|
maxTokens: 64e3,
|
|
98072
|
-
regions: ["intl"
|
|
98073
|
-
credits: {
|
|
98074
|
-
cn: "0.00",
|
|
98075
|
-
intl: "0.00"
|
|
98076
|
-
},
|
|
98392
|
+
regions: ["intl"],
|
|
98393
|
+
credits: { intl: "0.00" },
|
|
98077
98394
|
supportsImage: true,
|
|
98078
98395
|
reasoningEfforts: ["low", "high"],
|
|
98079
98396
|
defaultReasoningEffort: "high",
|
|
@@ -98197,7 +98514,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98197
98514
|
],
|
|
98198
98515
|
defaultReasoningEffort: "high",
|
|
98199
98516
|
canDisableThinking: false,
|
|
98200
|
-
description: "
|
|
98517
|
+
description: "Z.ai · 旗舰模型,擅长复杂软件工程与长程智能体任务"
|
|
98201
98518
|
},
|
|
98202
98519
|
{
|
|
98203
98520
|
id: "glm-5.2",
|
|
@@ -98214,7 +98531,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98214
98531
|
reasoningEfforts: ["high"],
|
|
98215
98532
|
defaultReasoningEffort: "high",
|
|
98216
98533
|
canDisableThinking: false,
|
|
98217
|
-
description: "1M 上下文,擅长长程任务"
|
|
98534
|
+
description: "Z.ai · 支持 1M 上下文,擅长长程任务"
|
|
98218
98535
|
},
|
|
98219
98536
|
{
|
|
98220
98537
|
id: "minimax-m3.1-flash",
|
|
@@ -98237,7 +98554,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98237
98554
|
],
|
|
98238
98555
|
defaultReasoningEffort: "max",
|
|
98239
98556
|
canDisableThinking: false,
|
|
98240
|
-
description: "
|
|
98557
|
+
description: "MiniMax · 原生多模态,擅长办公、智能体与编程任务,推理速度优异"
|
|
98241
98558
|
},
|
|
98242
98559
|
{
|
|
98243
98560
|
id: "kimi-k3.1-pro",
|
|
@@ -98258,7 +98575,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98258
98575
|
],
|
|
98259
98576
|
defaultReasoningEffort: "high",
|
|
98260
98577
|
canDisableThinking: false,
|
|
98261
|
-
description: "
|
|
98578
|
+
description: "Moonshot AI · 新一代旗舰,办公、编程、3D 创作、金融研究与建模及长程智能体任务"
|
|
98262
98579
|
},
|
|
98263
98580
|
{
|
|
98264
98581
|
id: "kimi-k3.1-pro-highspeed",
|
|
@@ -98420,7 +98737,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98420
98737
|
],
|
|
98421
98738
|
defaultReasoningEffort: "high",
|
|
98422
98739
|
canDisableThinking: false,
|
|
98423
|
-
description: ""
|
|
98740
|
+
description: "DeepSeek · 旗舰模型,支持 1M 上下文"
|
|
98424
98741
|
},
|
|
98425
98742
|
{
|
|
98426
98743
|
id: "deepseek-v4-flash",
|
|
@@ -98492,7 +98809,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98492
98809
|
],
|
|
98493
98810
|
defaultReasoningEffort: "high",
|
|
98494
98811
|
canDisableThinking: false,
|
|
98495
|
-
description: ""
|
|
98812
|
+
description: "MiniMax · 软件工程与办公工作流,涵盖调试与重构"
|
|
98496
98813
|
},
|
|
98497
98814
|
{
|
|
98498
98815
|
id: "glm-5.0",
|
|
@@ -98588,7 +98905,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98588
98905
|
],
|
|
98589
98906
|
defaultReasoningEffort: "high",
|
|
98590
98907
|
canDisableThinking: false,
|
|
98591
|
-
description: "
|
|
98908
|
+
description: "Moonshot AI · 擅长大型代码库开发与复杂长程自主任务,前端开发、知识工作与科研推理突出(前代模型)"
|
|
98592
98909
|
},
|
|
98593
98910
|
{
|
|
98594
98911
|
id: "kimi-k2.8-preview",
|
|
@@ -98644,24 +98961,6 @@ const FALLBACK_MODELS$1 = [
|
|
|
98644
98961
|
canDisableThinking: false,
|
|
98645
98962
|
description: ""
|
|
98646
98963
|
},
|
|
98647
|
-
{
|
|
98648
|
-
id: "hy3-x",
|
|
98649
|
-
name: "Hy3",
|
|
98650
|
-
contextWindow: 192e3,
|
|
98651
|
-
maxContextWindow: 192e3,
|
|
98652
|
-
maxTokens: 64e3,
|
|
98653
|
-
regions: ["cn"],
|
|
98654
|
-
credits: { cn: "0.05" },
|
|
98655
|
-
supportsImage: true,
|
|
98656
|
-
reasoningEfforts: [
|
|
98657
|
-
"low",
|
|
98658
|
-
"high",
|
|
98659
|
-
"max"
|
|
98660
|
-
],
|
|
98661
|
-
defaultReasoningEffort: "high",
|
|
98662
|
-
canDisableThinking: false,
|
|
98663
|
-
description: "混元思考模型,具有增强的推理能力"
|
|
98664
|
-
},
|
|
98665
98964
|
{
|
|
98666
98965
|
id: "hy4-preview-x",
|
|
98667
98966
|
name: "Hy4 preview",
|
|
@@ -98708,7 +99007,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98708
99007
|
],
|
|
98709
99008
|
defaultReasoningEffort: "max",
|
|
98710
99009
|
canDisableThinking: false,
|
|
98711
|
-
description: "
|
|
99010
|
+
description: "匿名模型 · 推理速度极快,编码能力强劲,支持原生多模态输入"
|
|
98712
99011
|
},
|
|
98713
99012
|
{
|
|
98714
99013
|
id: "step-5-preview",
|
|
@@ -98726,7 +99025,7 @@ const FALLBACK_MODELS$1 = [
|
|
|
98726
99025
|
],
|
|
98727
99026
|
defaultReasoningEffort: "high",
|
|
98728
99027
|
canDisableThinking: false,
|
|
98729
|
-
description: "
|
|
99028
|
+
description: "StepFun · 新一代旗舰,编程、专业知识工作与多步骤智能体任务,支持 1M 上下文"
|
|
98730
99029
|
},
|
|
98731
99030
|
{
|
|
98732
99031
|
id: "mimo-v2.6-pro",
|
|
@@ -98747,8 +99046,22 @@ const FALLBACK_MODELS$1 = [
|
|
|
98747
99046
|
description: "Xiaomi · 旗舰推理模型,面向专业、复杂长程工作流,兼顾高阶科研与网络安全"
|
|
98748
99047
|
},
|
|
98749
99048
|
{
|
|
98750
|
-
id: "
|
|
98751
|
-
name: "Hy4
|
|
99049
|
+
id: "hy4std",
|
|
99050
|
+
name: "Hy4",
|
|
99051
|
+
contextWindow: 1e6,
|
|
99052
|
+
maxContextWindow: 1e6,
|
|
99053
|
+
maxTokens: 64e3,
|
|
99054
|
+
regions: ["cn"],
|
|
99055
|
+
credits: { cn: "0.29" },
|
|
99056
|
+
supportsImage: true,
|
|
99057
|
+
reasoningEfforts: ["high"],
|
|
99058
|
+
defaultReasoningEffort: "high",
|
|
99059
|
+
canDisableThinking: false,
|
|
99060
|
+
description: "Tencent · 最新旗舰模型,擅长智能体任务与多模态理解,最大输入 960K"
|
|
99061
|
+
},
|
|
99062
|
+
{
|
|
99063
|
+
id: "hy4flash-free",
|
|
99064
|
+
name: "Hy4 Flash Free",
|
|
98752
99065
|
contextWindow: 1e6,
|
|
98753
99066
|
maxContextWindow: 1e6,
|
|
98754
99067
|
maxTokens: 64e3,
|
|
@@ -98758,21 +99071,21 @@ const FALLBACK_MODELS$1 = [
|
|
|
98758
99071
|
reasoningEfforts: ["high"],
|
|
98759
99072
|
defaultReasoningEffort: "high",
|
|
98760
99073
|
canDisableThinking: false,
|
|
98761
|
-
description: "
|
|
99074
|
+
description: "更轻量、更高效的日常主力模型。适合日常办公等高频、规模化场景"
|
|
98762
99075
|
},
|
|
98763
99076
|
{
|
|
98764
|
-
id: "
|
|
98765
|
-
name: "Hy4",
|
|
99077
|
+
id: "hy4flash",
|
|
99078
|
+
name: "Hy4 Flash",
|
|
98766
99079
|
contextWindow: 1e6,
|
|
98767
99080
|
maxContextWindow: 1e6,
|
|
98768
99081
|
maxTokens: 64e3,
|
|
98769
99082
|
regions: ["cn"],
|
|
98770
|
-
credits: { cn: "0.
|
|
99083
|
+
credits: { cn: "0.03" },
|
|
98771
99084
|
supportsImage: true,
|
|
98772
99085
|
reasoningEfforts: ["high"],
|
|
98773
99086
|
defaultReasoningEffort: "high",
|
|
98774
99087
|
canDisableThinking: false,
|
|
98775
|
-
description: "
|
|
99088
|
+
description: "更轻量、更高效的日常主力模型。适合日常办公等高频、规模化场景"
|
|
98776
99089
|
}
|
|
98777
99090
|
];
|
|
98778
99091
|
/**
|
|
@@ -105853,10 +106166,21 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
105853
106166
|
getPreferences: () => preferences.status(),
|
|
105854
106167
|
logger: ctx.logger
|
|
105855
106168
|
});
|
|
105856
|
-
const
|
|
105857
|
-
const
|
|
106169
|
+
const lineProxyFetches = /* @__PURE__ */ new Map();
|
|
106170
|
+
const proxyFetchFor = (line) => {
|
|
106171
|
+
let fetchForLine = lineProxyFetches.get(line);
|
|
106172
|
+
if (fetchForLine === void 0) {
|
|
106173
|
+
fetchForLine = proxyManager.createFetch({
|
|
106174
|
+
line,
|
|
106175
|
+
...line === "kimi-code" ? { headersTimeoutMs: TRANSPORT_HEADERS_TIMEOUT_MS } : {}
|
|
106176
|
+
});
|
|
106177
|
+
lineProxyFetches.set(line, fetchForLine);
|
|
106178
|
+
}
|
|
106179
|
+
return fetchForLine;
|
|
106180
|
+
};
|
|
106181
|
+
const proxyFetch = proxyFetchFor("codex-chatgpt");
|
|
105858
106182
|
const providerLimits = readModelRequestLimits();
|
|
105859
|
-
const baseFetchFor = (provider) => provider === "
|
|
106183
|
+
const baseFetchFor = (provider) => proxyFetchFor(provider === "claude" ? "claude-subscription" : provider);
|
|
105860
106184
|
const modelFetch = Object.fromEntries(CONTROLLED_PROVIDERS.map((provider) => [provider, createControlledModelFetch(createDiagnosticFetch(baseFetchFor(provider), {
|
|
105861
106185
|
provider,
|
|
105862
106186
|
onRecord: (record) => ctx.logger.info("[provider-diagnostics] " + JSON.stringify(record))
|
|
@@ -105865,7 +106189,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
105865
106189
|
limits: providerLimits
|
|
105866
106190
|
})]));
|
|
105867
106191
|
const disposeCommandCodeRoutes = registerCommandCodeRoutes(ctx, commandCodeStore, commandCodeModelSettings, commandCodePreferences, {
|
|
105868
|
-
fetchFn:
|
|
106192
|
+
fetchFn: proxyFetchFor("command-code"),
|
|
105869
106193
|
serving: () => commandCodeClaim.serving(),
|
|
105870
106194
|
conflict: () => commandCodeClaim.conflict()
|
|
105871
106195
|
}, commandCodeAccountPool);
|
|
@@ -105889,7 +106213,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
105889
106213
|
if (resolved.binary === void 0) throw new Error(resolved.diagnostics.error ?? "No usable Antigravity CLI (agy) was found.");
|
|
105890
106214
|
return {
|
|
105891
106215
|
command: resolved.binary.path,
|
|
105892
|
-
args:
|
|
106216
|
+
args: acpLaunchArgs(resolved.binary),
|
|
105893
106217
|
version: resolved.binary.version
|
|
105894
106218
|
};
|
|
105895
106219
|
};
|
|
@@ -105916,7 +106240,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
105916
106240
|
if (resolved.binary === void 0) throw new Error(resolved.diagnostics.error ?? "No usable Antigravity CLI (agy) was found.");
|
|
105917
106241
|
return {
|
|
105918
106242
|
command: resolved.binary.path,
|
|
105919
|
-
args:
|
|
106243
|
+
args: acpLaunchArgs(resolved.binary),
|
|
105920
106244
|
version: resolved.binary.version
|
|
105921
106245
|
};
|
|
105922
106246
|
}));
|
|
@@ -105942,7 +106266,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
105942
106266
|
const disposeOllamaRoutes = registerOllamaRoutes(ctx, {
|
|
105943
106267
|
accountPool: ollamaAccountPool,
|
|
105944
106268
|
modelSettings: ollamaModelSettings,
|
|
105945
|
-
fetchFn:
|
|
106269
|
+
fetchFn: proxyFetchFor("ollama")
|
|
105946
106270
|
});
|
|
105947
106271
|
const antigravityAcpClaim = claimProviderRoute(ctx, {
|
|
105948
106272
|
providerId: PROVIDER_ID$10,
|
|
@@ -106006,7 +106330,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106006
106330
|
adapter: commandCodeAdapter
|
|
106007
106331
|
});
|
|
106008
106332
|
const disposeKimiCodeRoutes = registerKimiCodeRoutes(ctx, kimiCodeStore, kimiCodeModelSettings, kimiCodePreferences, {
|
|
106009
|
-
fetchFn:
|
|
106333
|
+
fetchFn: proxyFetchFor("kimi-code"),
|
|
106010
106334
|
serving: () => kimiCodeClaim.serving(),
|
|
106011
106335
|
conflict: () => kimiCodeClaim.conflict()
|
|
106012
106336
|
}, kimiCodeAccountPool);
|
|
@@ -106020,7 +106344,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106020
106344
|
})
|
|
106021
106345
|
});
|
|
106022
106346
|
const disposeGlmCodingPlanRoutes = registerGlmCodingPlanRoutes(ctx, glmCodingPlanSettingsSource(glmCodingPlanPreferences, glmCodingPlanModelSettings), {
|
|
106023
|
-
fetchFn:
|
|
106347
|
+
fetchFn: proxyFetchFor("glm-coding-plan"),
|
|
106024
106348
|
serving: () => glmCodingPlanClaim.serving(),
|
|
106025
106349
|
conflict: () => glmCodingPlanClaim.conflict(),
|
|
106026
106350
|
accountPool: glmCodingPlanAccountPool
|
|
@@ -106043,7 +106367,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106043
106367
|
minimaxCodeAppVersion = void 0;
|
|
106044
106368
|
}
|
|
106045
106369
|
const minimaxCodeCheckin = new MinimaxCodeCheckinService(minimaxCodeAccountPool, {
|
|
106046
|
-
fetchFn:
|
|
106370
|
+
fetchFn: proxyFetchFor("minimax-code"),
|
|
106047
106371
|
settings: () => minimaxCodePreferences.status().checkin ?? { enabled: true },
|
|
106048
106372
|
ready: () => minimaxCodePreferences.ready(),
|
|
106049
106373
|
...minimaxCodeAppVersion === void 0 ? {} : { appVersion: minimaxCodeAppVersion },
|
|
@@ -106057,7 +106381,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106057
106381
|
const minimaxCodeCheckinTimer = setInterval(minimaxCodeCheckinTick, CHECKIN_TICK_MS$1);
|
|
106058
106382
|
minimaxCodeCheckinTick();
|
|
106059
106383
|
const disposeMinimaxCodeRoutes = registerMinimaxCodeRoutes(ctx, minimaxCodeStore, {
|
|
106060
|
-
fetchFn:
|
|
106384
|
+
fetchFn: proxyFetchFor("minimax-code"),
|
|
106061
106385
|
serving: () => minimaxCodeClaim.serving(),
|
|
106062
106386
|
conflict: () => minimaxCodeClaim.conflict(),
|
|
106063
106387
|
accountPool: minimaxCodeAccountPool,
|
|
@@ -106074,7 +106398,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106074
106398
|
})
|
|
106075
106399
|
});
|
|
106076
106400
|
const disposeClaudeRoutes = registerClaudeRoutes(ctx, claudeStore, claudeModelSettings, claudePreferences, {
|
|
106077
|
-
fetchFn:
|
|
106401
|
+
fetchFn: proxyFetchFor("claude-subscription"),
|
|
106078
106402
|
serving: () => claudeClaim.serving(),
|
|
106079
106403
|
conflict: () => claudeClaim.conflict(),
|
|
106080
106404
|
accountPool: claudeAccountPool
|
|
@@ -106090,14 +106414,14 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106090
106414
|
})
|
|
106091
106415
|
});
|
|
106092
106416
|
const disposeStepCodeRoutes = registerStepCodeRoutes(ctx, stepCodeSettingsSource(stepCodePreferences, stepCodeModelSettings), {
|
|
106093
|
-
fetchFn:
|
|
106417
|
+
fetchFn: proxyFetchFor("step-code"),
|
|
106094
106418
|
serving: () => stepCodeClaim.serving(),
|
|
106095
106419
|
conflict: () => stepCodeClaim.conflict(),
|
|
106096
106420
|
accountPool: stepCodeAccountPool,
|
|
106097
106421
|
promptCache: promptCacheOverrides["step-code"]
|
|
106098
106422
|
});
|
|
106099
106423
|
const clinePassLine = createClinePassLine(ctx, {
|
|
106100
|
-
fetchFn:
|
|
106424
|
+
fetchFn: proxyFetchFor("cline-pass"),
|
|
106101
106425
|
modelFetchFn: modelFetch["cline-pass"],
|
|
106102
106426
|
attachments: ctx.attachments
|
|
106103
106427
|
});
|
|
@@ -106111,17 +106435,17 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106111
106435
|
})
|
|
106112
106436
|
});
|
|
106113
106437
|
const disposeQoderRoutes = registerQoderRoutes(ctx, qoderSettingsSource(qoderPreferences, qoderModelSettings), {
|
|
106114
|
-
fetchFn:
|
|
106438
|
+
fetchFn: proxyFetchFor("qoder"),
|
|
106115
106439
|
serving: () => qoderClaim.serving(),
|
|
106116
106440
|
conflict: () => qoderClaim.conflict(),
|
|
106117
106441
|
accountPool: qoderAccountPool
|
|
106118
106442
|
});
|
|
106119
106443
|
warmQoderCatalogOnStartup(ctx, {
|
|
106120
|
-
fetchFn:
|
|
106444
|
+
fetchFn: proxyFetchFor("qoder"),
|
|
106121
106445
|
accountPool: qoderAccountPool
|
|
106122
106446
|
}).catch(() => void 0);
|
|
106123
106447
|
const openDesignLine = createOpenDesignLine(ctx, {
|
|
106124
|
-
fetchFn:
|
|
106448
|
+
fetchFn: proxyFetchFor("opendesign"),
|
|
106125
106449
|
modelFetchFn: modelFetch["opendesign"],
|
|
106126
106450
|
attachments: ctx.attachments
|
|
106127
106451
|
});
|
|
@@ -106136,7 +106460,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106136
106460
|
})
|
|
106137
106461
|
});
|
|
106138
106462
|
const workBuddyCheckin = new WorkBuddyCheckinService(workBuddyStore, {
|
|
106139
|
-
fetchFn:
|
|
106463
|
+
fetchFn: proxyFetchFor("workbuddy-subscription"),
|
|
106140
106464
|
settings: () => workBuddyPreferences.status().checkin,
|
|
106141
106465
|
ready: () => workBuddyPreferences.ready(),
|
|
106142
106466
|
logger: ctx.logger
|
|
@@ -106149,7 +106473,7 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106149
106473
|
const workBuddyCheckinTimer = setInterval(workBuddyCheckinTick, CHECKIN_TICK_MS);
|
|
106150
106474
|
workBuddyCheckinTick();
|
|
106151
106475
|
const disposeWorkBuddyRoutes = registerWorkBuddyRoutes(ctx, workBuddyStore, workBuddyModelSettings, workBuddyPreferences, {
|
|
106152
|
-
fetchFn:
|
|
106476
|
+
fetchFn: proxyFetchFor("workbuddy-subscription"),
|
|
106153
106477
|
serving: () => workBuddyClaim.serving(),
|
|
106154
106478
|
conflict: () => workBuddyClaim.conflict(),
|
|
106155
106479
|
accountPool: workBuddyAccountPool,
|
|
@@ -106474,14 +106798,14 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
106474
106798
|
const disposeAdapter = ctx.llm.registerAdapter([PROVIDER_ID$13], adapter);
|
|
106475
106799
|
const mediaToolsEnabled = pluginConfig.mediaTools?.get() !== false;
|
|
106476
106800
|
const disposeImageTool = mediaToolsEnabled ? ctx.tools.register(createCodexImageTool(oauth, ctx.attachments, { fetchFn: proxyFetch })) : () => void 0;
|
|
106477
|
-
const disposeVideoTool = mediaToolsEnabled ? ctx.tools.register(createKimiVideoTool(ctx, { fetchFn:
|
|
106801
|
+
const disposeVideoTool = mediaToolsEnabled ? ctx.tools.register(createKimiVideoTool(ctx, { fetchFn: proxyFetchFor("kimi-code") })) : () => void 0;
|
|
106478
106802
|
const minimaxMediaToolsEnabled = mediaToolsEnabled && minimaxCodePreferences.status().enabled;
|
|
106479
106803
|
const disposeMinimaxUnderstandVideoTool = minimaxMediaToolsEnabled ? ctx.tools.register(createMinimaxUnderstandVideoTool(ctx, {
|
|
106480
|
-
fetchFn:
|
|
106804
|
+
fetchFn: proxyFetchFor("minimax-code"),
|
|
106481
106805
|
pool: minimaxCodeAccountPool
|
|
106482
106806
|
})) : () => void 0;
|
|
106483
106807
|
const disposeMinimaxGenerateVideoTool = minimaxMediaToolsEnabled ? ctx.tools.register(createMinimaxGenerateVideoTool(ctx, {
|
|
106484
|
-
fetchFn:
|
|
106808
|
+
fetchFn: proxyFetchFor("minimax-code"),
|
|
106485
106809
|
pool: minimaxCodeAccountPool
|
|
106486
106810
|
})) : () => void 0;
|
|
106487
106811
|
ctx.inject(["web"], (ctx) => {
|