dsh-codex-subscription 2.5.5 → 2.5.6

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/index.js CHANGED
@@ -424,6 +424,11 @@ const PREFERENCE_FIELDS = Object.freeze({
424
424
  default: "sse",
425
425
  error: "Invalid connection mode"
426
426
  },
427
+ reviewModel: {
428
+ choices: ["session", "official"],
429
+ default: "session",
430
+ error: "Invalid review model"
431
+ },
427
432
  subagentBackend: {
428
433
  choices: ["dsh", "codex"],
429
434
  default: "dsh",
@@ -2044,7 +2049,7 @@ function inheritedOriginalImageRef(session, assetId) {
2044
2049
  }
2045
2050
  //#endregion
2046
2051
  //#region src/version.js
2047
- const PACKAGE_VERSION = "2.5.5";
2052
+ const PACKAGE_VERSION = "2.5.6";
2048
2053
  const USER_AGENT = `dsh-codex-subscription/${PACKAGE_VERSION}`;
2049
2054
  //#endregion
2050
2055
  //#region src/codex-images.js
@@ -2672,23 +2677,6 @@ function createSketchAgentTool(bridge, attachments, getSessionMessages = () => [
2672
2677
  });
2673
2678
  }
2674
2679
  //#endregion
2675
- //#region src/sketch-codec-route.js
2676
- function registerSketchCodec(connection) {
2677
- let source;
2678
- return connection.fetch.register({
2679
- path: "/api/codex-subscription/sketch-psd-worker",
2680
- methods: ["GET"],
2681
- requestBody: "buffered",
2682
- async fetch() {
2683
- source ??= await readFile(new URL("./sketch-psd-worker.js", import.meta.url));
2684
- return new Response(source, { headers: {
2685
- "content-type": "text/javascript; charset=utf-8",
2686
- "cache-control": "no-store"
2687
- } });
2688
- }
2689
- });
2690
- }
2691
- //#endregion
2692
2680
  //#region src/account-vault.js
2693
2681
  const VERSION = 1;
2694
2682
  const DEFAULT_LABEL = "Account 1";
@@ -3600,6 +3588,18 @@ function withInputImageDetail(payload, detail) {
3600
3588
  input
3601
3589
  } : payload;
3602
3590
  }
3591
+ const DSH_REVIEW_POLICY_PREFIX = "REVIEW_POLICY\nYou are the final authorization reviewer";
3592
+ const REVIEW_MODEL_SESSION = "session";
3593
+ function systemText(context) {
3594
+ if (typeof context?.systemPrompt === "string") return context.systemPrompt;
3595
+ const first = Array.isArray(context?.messages) ? context.messages[0] : void 0;
3596
+ if (first?.role !== "system") return "";
3597
+ return typeof first.content === "string" ? first.content : Array.isArray(first.content) ? first.content.map((part) => part?.text ?? "").join("") : "";
3598
+ }
3599
+ /** Whether this request is DSH Auto review judging one pending tool call. */
3600
+ function isDshAutoReview(context) {
3601
+ return systemText(context).startsWith(DSH_REVIEW_POLICY_PREFIX);
3602
+ }
3603
3603
  /**
3604
3604
  * Preserve pi-ai's native Codex OAuth provider while allowing DSH's generic
3605
3605
  * PiAiAdapter to pass the access token resolved by the host credential store.
@@ -3612,7 +3612,7 @@ function withInputImageDetail(payload, detail) {
3612
3612
  * persistence, headers, transport, and model behavior remain owned by the
3613
3613
  * original provider.
3614
3614
  */
3615
- function openaiCodexSubscriptionProvider({ resolveSpeedMode = () => void 0, resolveOutputVerbosity = () => OUTPUT_VERBOSITY_DEFAULT, resolveInputImageDetail = () => void 0, resolveContextMode = () => void 0, resolveCustomContextWindow = () => void 0, catalog, connection, compaction, runNetwork = (_area, operation) => operation() } = {}) {
3615
+ function openaiCodexSubscriptionProvider({ resolveSpeedMode = () => void 0, resolveOutputVerbosity = () => OUTPUT_VERBOSITY_DEFAULT, resolveInputImageDetail = () => void 0, resolveContextMode = () => void 0, resolveCustomContextWindow = () => void 0, resolveReviewModel = () => REVIEW_MODEL_SESSION, catalog, connection, compaction, runNetwork = (_area, operation) => operation() } = {}) {
3616
3616
  const provider = createOpenAICodexProvider();
3617
3617
  const requestToken = Object.freeze({
3618
3618
  name: "DSH-managed Codex OAuth request token",
@@ -3680,18 +3680,48 @@ function openaiCodexSubscriptionProvider({ resolveSpeedMode = () => void 0, reso
3680
3680
  contextWindow: requested
3681
3681
  };
3682
3682
  });
3683
- const networkIterable = (factory, options) => {
3683
+ const review = {
3684
+ requests: 0,
3685
+ routed: 0,
3686
+ sessionModel: 0
3687
+ };
3688
+ const reviewRoute = (model, context) => {
3689
+ if (resolveReviewModel() !== "official" || !isDshAutoReview(context)) return void 0;
3690
+ review.requests += 1;
3691
+ const route = catalog?.reviewModel?.(model?.id);
3692
+ if (route === void 0) review.sessionModel += 1;
3693
+ else review.routed += 1;
3694
+ return route;
3695
+ };
3696
+ const withReview = (route, options = {}) => {
3697
+ const { temperature: _temperature, onPayload, ...rest } = options;
3698
+ return {
3699
+ ...rest,
3700
+ async onPayload(payload, requestModel) {
3701
+ const { temperature: _dropped, service_tier: _tier, text: _text, ...accepted } = await onPayload?.(payload, requestModel) ?? payload;
3702
+ return {
3703
+ ...accepted,
3704
+ model: route.id,
3705
+ ...route.effort === void 0 ? {} : { reasoning: {
3706
+ ...accepted.reasoning ?? {},
3707
+ effort: route.effort
3708
+ } }
3709
+ };
3710
+ }
3711
+ };
3712
+ };
3713
+ const networkIterable = (factory, options, direct = false) => {
3684
3714
  let iterator;
3685
3715
  let prepared;
3686
3716
  const step = async (method, value) => {
3687
- const request = await (prepared ??= connection?.prepare(options) ?? Promise.resolve({ options }));
3717
+ const request = await (prepared ??= (direct ? void 0 : connection?.prepare(options)) ?? Promise.resolve({ options }));
3688
3718
  const result = await runNetwork("model", () => {
3689
- iterator ??= factory(compaction?.requestOptions(request.options) ?? request.options)[Symbol.asyncIterator]();
3719
+ iterator ??= factory(direct ? request.options : compaction?.requestOptions(request.options) ?? request.options)[Symbol.asyncIterator]();
3690
3720
  return iterator[method]?.(value) ?? (method === "throw" ? Promise.reject(value) : Promise.resolve({
3691
3721
  done: true,
3692
3722
  value
3693
3723
  }));
3694
- }, compaction?.networkOptions(request.network) ?? request.network);
3724
+ }, direct ? request.network : compaction?.networkOptions(request.network) ?? request.network);
3695
3725
  return result.done ? result : {
3696
3726
  ...result,
3697
3727
  value: normalizeTransportEvent(result.value, request.options?.signal)
@@ -3716,8 +3746,15 @@ function openaiCodexSubscriptionProvider({ resolveSpeedMode = () => void 0, reso
3716
3746
  apiKey: requestToken
3717
3747
  }),
3718
3748
  getModels,
3719
- stream: (model, context, options) => networkIterable((prepared) => provider.stream(model, context, prepared), withPreferences(model, options)),
3720
- streamSimple: (model, context, options) => networkIterable((prepared) => provider.streamSimple(model, context, prepared), withPreferences(model, options))
3749
+ stream: (model, context, options) => {
3750
+ const route = reviewRoute(model, context);
3751
+ return route === void 0 ? networkIterable((prepared) => provider.stream(model, context, prepared), withPreferences(model, options)) : networkIterable((prepared) => provider.stream(model, context, prepared), withReview(route, options), true);
3752
+ },
3753
+ streamSimple: (model, context, options) => {
3754
+ const route = reviewRoute(model, context);
3755
+ return route === void 0 ? networkIterable((prepared) => provider.streamSimple(model, context, prepared), withPreferences(model, options)) : networkIterable((prepared) => provider.streamSimple(model, context, prepared), withReview(route, options), true);
3756
+ },
3757
+ reviewCounters: () => ({ ...review })
3721
3758
  });
3722
3759
  }
3723
3760
  Object.freeze([
@@ -3844,6 +3881,23 @@ function visibleModel(value, displayNames, now) {
3844
3881
  supportsUltrafast: speedTierIds(value).includes("ultrafast")
3845
3882
  };
3846
3883
  }
3884
+ /**
3885
+ * Mirror Codex's reviewer selection: a parent model's override, else the
3886
+ * default reviewer, used only when the account catalog lists that slug (any
3887
+ * visibility), with low reasoning when the reviewer supports it.
3888
+ */
3889
+ function officialReviewModel(value, parentId) {
3890
+ if (!record$3(value) || !Array.isArray(value.models)) return void 0;
3891
+ const parent = value.models.find((model) => record$3(model) && model.slug === parentId);
3892
+ const id = nonEmpty$1(parent?.auto_review_model_override) ?? "codex-auto-review";
3893
+ const preset = value.models.find((model) => record$3(model) && model.slug === id);
3894
+ if (preset === void 0) return void 0;
3895
+ const effort = (Array.isArray(preset.supported_reasoning_levels) ? preset.supported_reasoning_levels : []).some((level) => (record$3(level) ? level.effort : level) === "low") ? "low" : nonEmpty$1(preset.default_reasoning_level);
3896
+ return {
3897
+ id,
3898
+ ...effort === void 0 ? {} : { effort }
3899
+ };
3900
+ }
3847
3901
  function parseOfficialModelCatalog(value, now = Date.now()) {
3848
3902
  if (!record$3(value) || !Array.isArray(value.models)) throw new Error("Codex returned a malformed model catalog");
3849
3903
  const displayNames = /* @__PURE__ */ new Map();
@@ -3985,6 +4039,7 @@ function createOfficialModelCatalog(options = {}) {
3985
4039
  refresh,
3986
4040
  getModels: () => models ?? [],
3987
4041
  metadata: (modelId) => metadata.get(modelId),
4042
+ reviewModel: (parentId) => officialReviewModel(rawCatalog, parentId),
3988
4043
  revision: () => revision,
3989
4044
  capabilityGaps: () => [...metadata.values()].filter((model) => model.unsupported && /^[a-z][a-z0-9._-]{0,79}$/u.test(model.id)).slice(0, 20).map((model) => ({
3990
4045
  model: model.id,
@@ -4644,7 +4699,7 @@ function safeRequests(network) {
4644
4699
  return result;
4645
4700
  }
4646
4701
  /** Build a support report that deliberately excludes OAuth and account metadata. */
4647
- async function createSubscriptionDiagnostics({ auth, preferences, login = { phase: "idle" }, network, modelCatalog, connection, compaction, inspectionOptions, operations, runtimeManagement, storage, tools }) {
4702
+ async function createSubscriptionDiagnostics({ auth, preferences, login = { phase: "idle" }, network, modelCatalog, connection, compaction, review, inspectionOptions, operations, runtimeManagement, storage, tools }) {
4648
4703
  const collected = {};
4649
4704
  const checks = await collectChecks([
4650
4705
  [
@@ -4698,6 +4753,15 @@ async function createSubscriptionDiagnostics({ auth, preferences, login = { phas
4698
4753
  "checkpointsReused"
4699
4754
  ]) : void 0
4700
4755
  ],
4756
+ [
4757
+ "review",
4758
+ "transport",
4759
+ () => typeof review?.reviewCounters === "function" ? safeCounters({ snapshot: () => review.reviewCounters() }, [
4760
+ "requests",
4761
+ "routed",
4762
+ "sessionModel"
4763
+ ]) : void 0
4764
+ ],
4701
4765
  [
4702
4766
  "operations",
4703
4767
  "transport",
@@ -4800,6 +4864,7 @@ async function createSubscriptionDiagnostics({ auth, preferences, login = { phas
4800
4864
  ...collected.operations ? { operations: collected.operations } : {},
4801
4865
  ...collected.websocket ? { websocket: collected.websocket } : {},
4802
4866
  ...collected.compaction ? { compaction: collected.compaction } : {},
4867
+ ...collected.review ? { review: collected.review } : {},
4803
4868
  ...catalog && ["unavailable", "online"].includes(catalog.source) && [
4804
4869
  "idle",
4805
4870
  "refreshing",
@@ -6295,6 +6360,7 @@ function apply(ctx, config = {}) {
6295
6360
  if (field === void 0) return void 0;
6296
6361
  return normalizeCustomContextWindow(settings.get()[field] ?? CUSTOM_CONTEXT_MODEL_DEFAULTS[modelKey], CUSTOM_CONTEXT_MODEL_CAPS[modelKey]);
6297
6362
  },
6363
+ resolveReviewModel: () => settings.get().reviewModel,
6298
6364
  catalog: modelCatalog,
6299
6365
  runNetwork: network.run
6300
6366
  });
@@ -6306,6 +6372,7 @@ function apply(ctx, config = {}) {
6306
6372
  [AUTO_QUOTA_RETRY_FIELD]: normalizeAutoQuotaRetry(settings.get()[AUTO_QUOTA_RETRY_FIELD]),
6307
6373
  compactionMode: settings.get().compactionMode ?? "dsh",
6308
6374
  connectionMode: settings.get().connectionMode ?? "sse",
6375
+ reviewModel: settings.get().reviewModel ?? "session",
6309
6376
  subagentBackend: settings.get().subagentBackend ?? "dsh",
6310
6377
  subagentBackendAvailable: subagentBackend !== void 0,
6311
6378
  subagentRuntimeInstalled: inspectSubagentRuntime().installed,
@@ -6593,6 +6660,7 @@ function apply(ctx, config = {}) {
6593
6660
  modelCatalog,
6594
6661
  connection,
6595
6662
  compaction,
6663
+ review: provider,
6596
6664
  operations: diagnosticOperations,
6597
6665
  runtimeManagement,
6598
6666
  storage: () => usageReader.storage(),
@@ -6608,20 +6676,7 @@ function apply(ctx, config = {}) {
6608
6676
  ctx.effect(() => {
6609
6677
  modelCatalog.refresh().catch((error) => ctx.logger?.debug?.("could not refresh Codex model catalog: %s", error.message));
6610
6678
  }, "codex-subscription: official model catalog");
6611
- ctx.inject(["connection"], (connectionContext) => connectionContext.effect(() => {
6612
- const transport = registerSubscriptionTransport(connectionContext.connection, handler);
6613
- let codec;
6614
- try {
6615
- codec = registerSketchCodec(connectionContext.connection);
6616
- } catch (error) {
6617
- transport();
6618
- throw error;
6619
- }
6620
- return () => {
6621
- codec();
6622
- transport();
6623
- };
6624
- }, "codex-subscription: DSH-trusted account RPC"));
6679
+ ctx.inject(["connection"], (connectionContext) => connectionContext.effect(() => registerSubscriptionTransport(connectionContext.connection, handler), "codex-subscription: DSH-trusted account RPC"));
6625
6680
  }
6626
6681
  //#endregion
6627
6682
  export { CODEX_IMAGE_GENERATION_URL, CODEX_IMAGE_TOOL_NAME, CODEX_RESET_CONSUME_URL, CODEX_RESET_CREDITS_URL, CODEX_USAGE_URL, CodexLoginCoordinator, Config, DEFAULT_MODEL_PROVIDER, DshOAuthCredentialStore, apply, assertCodexAuthUrl, commandForCodexAuthUrl, createCodexAuthService, createCodexImageTool, createCodexResetCreditService, createCodexRpcHandler, createCodexUsageReader, createDefaultModelController, createSearchProviderSwitcher, createSubscriptionDiagnostics, createSubscriptionRpcHandler, decodeCodexPng, inject, name, normalizeContextMode, normalizeCustomContextWindow, openCodexAuthUrl, parseCodexUsage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-codex-subscription",
3
- "version": "2.5.5",
3
+ "version": "2.5.6",
4
4
  "description": "Use ChatGPT and Codex subscriptions in DeepSeek Harness with OAuth, quota, safe resets, web search, images, and Fast mode",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -121,7 +121,6 @@
121
121
  "@deepseek-ai/schemastery": "3.18.4",
122
122
  "@earendil-works/pi-ai": "0.85.1",
123
123
  "@heroicons/react": "2.2.0",
124
- "ag-psd": "31.0.2",
125
124
  "fake-indexeddb": "6.2.5",
126
125
  "react": "18.3.1",
127
126
  "react-dom": "18.3.1",