dsh-codex-subscription 3.2.23 → 3.2.24
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/README.de.md +12 -5
- package/README.en.md +13 -6
- package/README.es.md +12 -5
- package/README.fr.md +12 -5
- package/README.ja.md +13 -6
- package/README.md +13 -6
- package/README.pt.md +12 -5
- package/README.ru.md +12 -5
- package/README.zh-CN.md +13 -6
- package/lib/client.js +418 -306
- package/lib/index.js +60 -37
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -3875,6 +3875,7 @@ const RPC_ENDPOINTS = Object.freeze([
|
|
|
3875
3875
|
"default-model/select",
|
|
3876
3876
|
"default-model/reset",
|
|
3877
3877
|
"predictions/generate",
|
|
3878
|
+
"predictions/models",
|
|
3878
3879
|
"runtime/status",
|
|
3879
3880
|
"runtime/install",
|
|
3880
3881
|
"runtime/remove",
|
|
@@ -5058,7 +5059,7 @@ function inheritedOriginalImageRef(session, assetId) {
|
|
|
5058
5059
|
}
|
|
5059
5060
|
//#endregion
|
|
5060
5061
|
//#region src/version.js
|
|
5061
|
-
const PACKAGE_VERSION = "3.2.
|
|
5062
|
+
const PACKAGE_VERSION = "3.2.24";
|
|
5062
5063
|
const USER_AGENT = `dsh-codex-subscription/${PACKAGE_VERSION}`;
|
|
5063
5064
|
//#endregion
|
|
5064
5065
|
//#region src/image-original-store.js
|
|
@@ -13842,6 +13843,10 @@ function visibleModel(value, displayNames, now) {
|
|
|
13842
13843
|
supportsUltrafast: speedTierIds(value).includes("ultrafast")
|
|
13843
13844
|
};
|
|
13844
13845
|
}
|
|
13846
|
+
/** Newest available Luna generation for lightweight background requests. */
|
|
13847
|
+
function latestCodexLuna(models) {
|
|
13848
|
+
return models.map((model) => model.id).filter((id) => /^gpt-\d+(?:\.\d+)*-luna$/u.test(id)).sort((left, right) => right.localeCompare(left, "en", { numeric: true }))[0];
|
|
13849
|
+
}
|
|
13845
13850
|
/**
|
|
13846
13851
|
* Mirror Codex's reviewer selection: a parent model's override, else the
|
|
13847
13852
|
* default reviewer, used only when the account catalog lists that slug (any
|
|
@@ -17346,6 +17351,15 @@ async function settlesLive(preferences, patch, signal, { attempts = 8, delayMs =
|
|
|
17346
17351
|
}
|
|
17347
17352
|
function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageReader, planHistoryReader, usageProfileReader, resetCreditService, preferences, defaultModel, runtimeManagement, remoteControl, desktopVoice, nativeVoice, voicePreview, composerPredictions, diagnosticsReader, modelCatalog, subagentCatalog, originalImages, resolveInheritedOriginal, closeConnections, onAccountChanged, onCleanupFailure }) {
|
|
17348
17353
|
return async (endpoint, payload, signal) => {
|
|
17354
|
+
if (endpoint === "predictions/models") try {
|
|
17355
|
+
return {
|
|
17356
|
+
ok: true,
|
|
17357
|
+
value: await composerPredictions?.modelNames(modelCatalog?.getModels?.() ?? [], signal) ?? []
|
|
17358
|
+
};
|
|
17359
|
+
} catch (error) {
|
|
17360
|
+
if (signal?.aborted) throw error;
|
|
17361
|
+
return publicError("operation-error", "Could not read supported input prediction models");
|
|
17362
|
+
}
|
|
17349
17363
|
if (endpoint === "predictions/generate") try {
|
|
17350
17364
|
signal?.throwIfAborted();
|
|
17351
17365
|
return {
|
|
@@ -17907,21 +17921,12 @@ function createVoicePreview({ fetch, credentials, userAgent, now = Date.now, bas
|
|
|
17907
17921
|
};
|
|
17908
17922
|
}
|
|
17909
17923
|
//#endregion
|
|
17910
|
-
//#region src/composer-prediction-models.js
|
|
17911
|
-
const models = /* @__PURE__ */ new Map([
|
|
17912
|
-
["gpt-6-astra", "GPT-6 Astra"],
|
|
17913
|
-
["gpt-6.1-sol", "GPT-6.1 Sol"],
|
|
17914
|
-
["gpt-6.1-terra", "GPT-6.1 Terra"]
|
|
17915
|
-
]);
|
|
17916
|
-
[...models.values()].join(", ");
|
|
17917
|
-
const supportsComposerPrediction = (model) => models.has(model);
|
|
17918
|
-
//#endregion
|
|
17919
17924
|
//#region src/composer-predictions.js
|
|
17920
17925
|
const BASE = "https://chatgpt.com/backend-api";
|
|
17921
17926
|
const invalid = () => Object.assign(/* @__PURE__ */ new Error("Invalid prediction request"), { code: "invalid-input" });
|
|
17922
17927
|
const cancelled = () => new DOMException("Prediction scope changed", "AbortError");
|
|
17923
17928
|
function predictionInput(value) {
|
|
17924
|
-
if (!value || !
|
|
17929
|
+
if (!value || !validModelKey(value.model) || typeof value.sessionId !== "string" || !value.sessionId || value.sessionId.length > 512 || typeof value.turnId !== "string" || !value.turnId || value.turnId.length > 512 || !Array.isArray(value.messages) || value.messages.length < 2 || value.messages.length > 12) throw invalid();
|
|
17925
17930
|
let length = 0;
|
|
17926
17931
|
const messages = value.messages.map((message) => {
|
|
17927
17932
|
if (!message || !["user", "assistant"].includes(message.role) || typeof message.text !== "string" || !message.text.trim()) throw invalid();
|
|
@@ -17975,7 +17980,7 @@ function predictionText(sse) {
|
|
|
17975
17980
|
return result.suggestion.trim() || null;
|
|
17976
17981
|
}
|
|
17977
17982
|
/** Optional, isolated next-message inference. Never runs tools or mutates the source conversation. */
|
|
17978
|
-
function createComposerPredictions({ fetch, credentials, enabled, userAgent, now = Date.now, base = BASE, timeoutMs = 3e4 }) {
|
|
17983
|
+
function createComposerPredictions({ fetch, credentials, enabled, modelAvailable, userAgent, now = Date.now, base = BASE, timeoutMs = 3e4 }) {
|
|
17979
17984
|
const requests = createSharedRequests(), results = /* @__PURE__ */ new Map();
|
|
17980
17985
|
let generation = 0, accountId, config;
|
|
17981
17986
|
const clear = () => {
|
|
@@ -17985,9 +17990,22 @@ function createComposerPredictions({ fetch, credentials, enabled, userAgent, now
|
|
|
17985
17990
|
results.clear();
|
|
17986
17991
|
requests.clear(cancelled());
|
|
17987
17992
|
};
|
|
17988
|
-
const active = (auth, signal) => {
|
|
17993
|
+
const active = (auth, signal, requireEnabled = true) => {
|
|
17994
|
+
signal?.throwIfAborted();
|
|
17995
|
+
if (auth.generation !== generation || requireEnabled && !enabled()) throw cancelled();
|
|
17996
|
+
};
|
|
17997
|
+
const authorize = async (signal) => {
|
|
17998
|
+
const initialGeneration = generation;
|
|
17999
|
+
const credential = await credentials(signal);
|
|
17989
18000
|
signal?.throwIfAborted();
|
|
17990
|
-
if (
|
|
18001
|
+
if (initialGeneration !== generation) throw cancelled();
|
|
18002
|
+
if (!credential?.access || !credential.accountId) return void 0;
|
|
18003
|
+
if (accountId !== void 0 && credential.accountId !== accountId) clear();
|
|
18004
|
+
accountId = credential.accountId;
|
|
18005
|
+
return {
|
|
18006
|
+
...credential,
|
|
18007
|
+
generation
|
|
18008
|
+
};
|
|
17991
18009
|
};
|
|
17992
18010
|
const headers = (auth) => ({
|
|
17993
18011
|
authorization: `Bearer ${auth.access}`,
|
|
@@ -17995,7 +18013,7 @@ function createComposerPredictions({ fetch, credentials, enabled, userAgent, now
|
|
|
17995
18013
|
"user-agent": userAgent
|
|
17996
18014
|
});
|
|
17997
18015
|
const configuration = async (auth, signal) => {
|
|
17998
|
-
active(auth, signal);
|
|
18016
|
+
active(auth, signal, false);
|
|
17999
18017
|
if (config && now() - config.at < 3e5) return config.value;
|
|
18000
18018
|
return requests.run("config", async (sharedSignal) => {
|
|
18001
18019
|
const response = await fetch(`${base}/wham/predictions/config`, {
|
|
@@ -18012,7 +18030,7 @@ function createComposerPredictions({ fetch, credentials, enabled, userAgent, now
|
|
|
18012
18030
|
}
|
|
18013
18031
|
const value = JSON.parse(await boundedText(response, 32e3));
|
|
18014
18032
|
if (typeof value?.is_enabled !== "boolean" || value.is_enabled && (typeof value.prompt !== "string" || !value.prompt || value.prompt.length > 16e3) || value.unsupported_models !== void 0 && (!Array.isArray(value.unsupported_models) || value.unsupported_models.some((model) => typeof model !== "string"))) throw new Error("Invalid prediction capability");
|
|
18015
|
-
active(auth, sharedSignal);
|
|
18033
|
+
active(auth, sharedSignal, false);
|
|
18016
18034
|
config = {
|
|
18017
18035
|
at: now(),
|
|
18018
18036
|
value
|
|
@@ -18022,29 +18040,34 @@ function createComposerPredictions({ fetch, credentials, enabled, userAgent, now
|
|
|
18022
18040
|
};
|
|
18023
18041
|
return {
|
|
18024
18042
|
clear,
|
|
18043
|
+
async modelNames(models, signal) {
|
|
18044
|
+
if (!models.length) return [];
|
|
18045
|
+
const auth = await authorize(signal);
|
|
18046
|
+
if (!auth) return [];
|
|
18047
|
+
const cap = await configuration(auth, signal);
|
|
18048
|
+
active(auth, signal, false);
|
|
18049
|
+
return cap.is_enabled ? models.filter(({ id }) => modelAvailable(id) && !cap.unsupported_models?.includes(id)).map(({ name }) => name).slice(0, 32) : [];
|
|
18050
|
+
},
|
|
18025
18051
|
async generate(raw, signal) {
|
|
18026
18052
|
signal?.throwIfAborted();
|
|
18027
18053
|
if (!enabled()) return {
|
|
18028
18054
|
prediction: null,
|
|
18029
18055
|
reason: "disabled"
|
|
18030
18056
|
};
|
|
18031
|
-
const input = predictionInput(raw)
|
|
18032
|
-
|
|
18033
|
-
signal?.throwIfAborted();
|
|
18034
|
-
if (initialGeneration !== generation) throw cancelled();
|
|
18035
|
-
if (!credential?.access || !credential.accountId) return {
|
|
18057
|
+
const input = predictionInput(raw);
|
|
18058
|
+
if (!modelAvailable(input.model)) return {
|
|
18036
18059
|
prediction: null,
|
|
18037
|
-
reason: "
|
|
18060
|
+
reason: "unavailable"
|
|
18038
18061
|
};
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18043
|
-
generation
|
|
18062
|
+
const auth = await authorize(signal);
|
|
18063
|
+
if (!auth) return {
|
|
18064
|
+
prediction: null,
|
|
18065
|
+
reason: "authentication"
|
|
18044
18066
|
};
|
|
18067
|
+
active(auth, signal);
|
|
18045
18068
|
const cap = await configuration(auth, signal);
|
|
18046
18069
|
active(auth, signal);
|
|
18047
|
-
if (!cap.is_enabled || cap.unsupported_models?.includes(input.model)) return {
|
|
18070
|
+
if (!cap.is_enabled || cap.unsupported_models?.includes(input.model) || !modelAvailable(input.model)) return {
|
|
18048
18071
|
prediction: null,
|
|
18049
18072
|
reason: "unavailable"
|
|
18050
18073
|
};
|
|
@@ -19316,14 +19339,16 @@ function apply(ctx, config = {}) {
|
|
|
19316
19339
|
};
|
|
19317
19340
|
}, "codex-subscription: official model catalog");
|
|
19318
19341
|
const currentAgent = () => ctx.get?.("agents")?.currentInitiator?.();
|
|
19342
|
+
const latestLuna = () => latestCodexLuna(modelCatalog.getModels());
|
|
19343
|
+
const resolveWebModel = () => {
|
|
19344
|
+
const request = currentAgent()?.session.requestContext?.();
|
|
19345
|
+
return (request?.provider === PROVIDER ? request.model : void 0) || latestLuna();
|
|
19346
|
+
};
|
|
19319
19347
|
const codexFetch = createCodexFetchProvider({
|
|
19320
19348
|
allowed: (llmProvider) => (nativeWebSettings() || fetchRouted) && (settings.get().otherModels !== "off" || (llmProvider ?? currentAgent()?.session.requestContext?.()?.provider) === PROVIDER),
|
|
19321
19349
|
getAuth: resolveAuth,
|
|
19322
19350
|
readCredential: (options) => store.read(PROVIDER, options),
|
|
19323
|
-
resolveModel:
|
|
19324
|
-
const request = currentAgent()?.session.requestContext?.();
|
|
19325
|
-
return request?.provider === PROVIDER ? request.model : void 0;
|
|
19326
|
-
},
|
|
19351
|
+
resolveModel: resolveWebModel,
|
|
19327
19352
|
resolveSessionId: () => currentAgent()?.session.id,
|
|
19328
19353
|
fetch: (input, init) => network.fetch("search", input, init)
|
|
19329
19354
|
});
|
|
@@ -19377,10 +19402,7 @@ function apply(ctx, config = {}) {
|
|
|
19377
19402
|
resolvePreferences: () => readCapabilitySettings(settings.get()),
|
|
19378
19403
|
getAuth: resolveAuth,
|
|
19379
19404
|
readCredential: (options) => store.read(PROVIDER, options),
|
|
19380
|
-
resolveModel:
|
|
19381
|
-
const request = currentAgent()?.session.requestContext?.();
|
|
19382
|
-
return request?.provider === PROVIDER ? request.model : void 0;
|
|
19383
|
-
},
|
|
19405
|
+
resolveModel: resolveWebModel,
|
|
19384
19406
|
resolveSessionId: () => currentAgent()?.session.id,
|
|
19385
19407
|
fetch: (input, init) => network.fetch("search", input, init)
|
|
19386
19408
|
});
|
|
@@ -19534,7 +19556,7 @@ function apply(ctx, config = {}) {
|
|
|
19534
19556
|
classifyHangUp: createVoiceHangupClassifier({
|
|
19535
19557
|
stream: (request) => ctx.llm.stream(request),
|
|
19536
19558
|
provider: PROVIDER,
|
|
19537
|
-
model: () =>
|
|
19559
|
+
model: () => latestLuna() ?? (modelCatalog.getModels().some((model) => model.id === "gpt-5.4-mini") ? "gpt-5.4-mini" : "gpt-5.6-luna")
|
|
19538
19560
|
})
|
|
19539
19561
|
}
|
|
19540
19562
|
});
|
|
@@ -19729,6 +19751,7 @@ function apply(ctx, config = {}) {
|
|
|
19729
19751
|
...options,
|
|
19730
19752
|
signal
|
|
19731
19753
|
}), signal),
|
|
19754
|
+
modelAvailable: (id) => provider.getModels().some((model) => model.id === id),
|
|
19732
19755
|
enabled: () => settings.get().composerPredictions === "on",
|
|
19733
19756
|
userAgent: USER_AGENT
|
|
19734
19757
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-codex-subscription",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.24",
|
|
4
4
|
"description": "Use ChatGPT and Codex subscriptions in DeepSeek Harness with OAuth, quota, safe resets, web search, images and Fast mode, and control DSH from the ChatGPT mobile app (Beta)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|