@opengeni/codex 6.7.0 → 6.7.1-canary.41759707569001
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/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/plan-entitlement.d.ts +1 -1
- package/package.json +5 -4
- package/src/plan-entitlement.ts +21 -2
package/dist/index.js
CHANGED
|
@@ -2875,6 +2875,7 @@ var CODEX_PLAN_ENTITLEMENT_CODES = /* @__PURE__ */ new Set([
|
|
|
2875
2875
|
"upgrade_required"
|
|
2876
2876
|
]);
|
|
2877
2877
|
var PLAN_ENTITLEMENT_MESSAGE = /\b(?:not (?:available|included|supported|enabled) (?:on|in|for|with) (?:your|this|the|a) (?:current )?(?:chatgpt )?(?:plan|subscription|tier)|upgrade (?:your (?:chatgpt )?(?:plan|subscription)|to (?:a |the )?(?:paid|plus|pro|team|business|enterprise)\b)|(?:plan|subscription|tier) (?:does not|doesn't) (?:include|support|allow)|requires? (?:a |an )?(?:paid|plus|pro|team|business|enterprise|higher) (?:chatgpt )?(?:plan|subscription|tier))/i;
|
|
2878
|
+
var MODEL_ACCESS_MESSAGE = /\bmodel is not supported when using codex with a chatgpt account\b/i;
|
|
2878
2879
|
function stringField(value) {
|
|
2879
2880
|
return typeof value === "string" ? value : "";
|
|
2880
2881
|
}
|
|
@@ -2890,13 +2891,20 @@ function classifyCodexEntitlementRejection(error) {
|
|
|
2890
2891
|
const value = current;
|
|
2891
2892
|
const body = value.error && typeof value.error === "object" ? value.error : null;
|
|
2892
2893
|
const status = Number(value.status ?? value.statusCode ?? body?.status);
|
|
2894
|
+
const message = [
|
|
2895
|
+
stringField(value.message),
|
|
2896
|
+
stringField(body?.message),
|
|
2897
|
+
stringField(body?.detail)
|
|
2898
|
+
].join(" ");
|
|
2899
|
+
if (status === 400 && MODEL_ACCESS_MESSAGE.test(message)) {
|
|
2900
|
+
return { status, evidence: "plan_entitlement" };
|
|
2901
|
+
}
|
|
2893
2902
|
if (status === 400 || status === 403 || status === 429) {
|
|
2894
2903
|
const codes = [value.code, value.type, body?.code, body?.type].map((field) => stringField(field).toLowerCase()).filter((field) => field.length > 0);
|
|
2895
2904
|
if (codes.some((code) => CODEX_PLAN_ENTITLEMENT_CODES.has(code))) {
|
|
2896
2905
|
return { status, evidence: "plan_entitlement" };
|
|
2897
2906
|
}
|
|
2898
2907
|
if (!usageLimit) {
|
|
2899
|
-
const message = [stringField(value.message), stringField(body?.message)].join(" ");
|
|
2900
2908
|
if (status !== 429 && PLAN_ENTITLEMENT_MESSAGE.test(message)) {
|
|
2901
2909
|
return { status, evidence: "plan_entitlement" };
|
|
2902
2910
|
}
|