dsh-codex-subscription 3.2.4 → 3.2.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
@@ -34,7 +34,7 @@ function createSettingsAdapter(ctx, config) {
34
34
  if (!id) throw new Error("DSH settings entry is unavailable");
35
35
  const liveConfig = () => {
36
36
  try {
37
- const current = ctx.fiber?.config ?? ctx.config;
37
+ const current = ctx.fiber?.effectiveConfig ?? ctx.fiber?.config ?? ctx.config;
38
38
  return current !== null && typeof current === "object" ? current : config;
39
39
  } catch {
40
40
  return config;
@@ -718,6 +718,67 @@ function withDefaultReasoningEffort(adapter, { provider = "openai-codex", prefer
718
718
  } });
719
719
  }
720
720
  //#endregion
721
+ //#region src/subagent-defaults.js
722
+ const PROVIDER$3 = "openai-codex";
723
+ const SUBAGENT_EFFORTS = Object.freeze(DEFAULT_REASONING_EFFORTS.filter((value) => value !== "ultra"));
724
+ const normalizeSubagentModel = (value) => typeof value === "string" && /^[a-z][a-z0-9._-]{0,79}$/u.test(value) ? value : "";
725
+ const normalizeSubagentEffort = (value) => SUBAGENT_EFFORTS.includes(value) ? value : "auto";
726
+ const permits = (routes, id) => Array.isArray(routes) && routes.some((route) => route.provider === PROVIDER$3 && route.model === id);
727
+ function createSubagentDefaults({ readSettings, catalog, modelSelection, projections }) {
728
+ function models(settings, selection) {
729
+ if (!selection || typeof selection.enabled !== "boolean") return [];
730
+ const disabled = normalizeDisabledModels(settings.disabledModels);
731
+ return catalog.getModels().filter((model) => !disabled.includes(model.id) && (!selection.enabled || permits(selection.allowedModels, model.id))).map((model) => ({
732
+ id: model.id,
733
+ name: model.name,
734
+ efforts: SUBAGENT_EFFORTS.filter((effort) => catalog.metadata(model.id)?.thinkingLevelMap?.[effort] != null)
735
+ }));
736
+ }
737
+ return {
738
+ list() {
739
+ try {
740
+ return models(readSettings(), modelSelection());
741
+ } catch {
742
+ return [];
743
+ }
744
+ },
745
+ async ready(requested = {}, signal) {
746
+ if (Object.keys(requested).length > 0 || catalog.getModels().length > 0) return;
747
+ const settings = readSettings();
748
+ if (!normalizeSubagentModel(settings.subagentDefaultModel) && normalizeSubagentEffort(settings.subagentDefaultEffort) === "auto") return;
749
+ try {
750
+ await catalog.refresh({ signal });
751
+ } catch {
752
+ signal?.throwIfAborted();
753
+ }
754
+ },
755
+ resolve(parent, requested = {}) {
756
+ if (Object.keys(requested).length > 0) return requested;
757
+ const settings = readSettings();
758
+ const chosen = normalizeSubagentModel(settings.subagentDefaultModel);
759
+ const effort = normalizeSubagentEffort(settings.subagentDefaultEffort);
760
+ if (!chosen && effort === "auto") return requested;
761
+ const parentRoute = parent.session.requestHeader?.()?.config ?? parent.options ?? {};
762
+ const id = chosen || (parentRoute.provider === PROVIDER$3 ? parentRoute.model : void 0);
763
+ if (!id) return requested;
764
+ try {
765
+ const model = models(settings, modelSelection()).find((candidate) => candidate.id === id);
766
+ const registry = projections();
767
+ if (!model || typeof registry?.stateOf !== "function") return requested;
768
+ const allowed = registry.stateOf(parent.session, "subagentModelSelectionPolicy");
769
+ if (allowed != null && !permits(allowed, id)) return requested;
770
+ if (!chosen && !model.efforts.includes(effort)) return requested;
771
+ return {
772
+ ...chosen ? { model: chosen } : {},
773
+ ...model.efforts.includes(effort) ? { reasoningEffort: effort === "off" ? "none" : effort } : {}
774
+ };
775
+ } catch {
776
+ return requested;
777
+ }
778
+ }
779
+ };
780
+ }
781
+ //#endregion
721
782
  //#region src/preference-fields.js
722
783
  const PREFERENCE_FIELDS = Object.freeze({
723
784
  compactionMode: {
@@ -769,6 +830,11 @@ const PREFERENCE_FIELDS = Object.freeze({
769
830
  default: "dsh",
770
831
  error: "Invalid subagent backend"
771
832
  },
833
+ subagentDefaultEffort: {
834
+ choices: SUBAGENT_EFFORTS,
835
+ default: "auto",
836
+ error: "Invalid subtask reasoning effort"
837
+ },
772
838
  [QUICK_QUOTA_MODE_FIELD]: {
773
839
  choices: [
774
840
  "off",
@@ -3536,10 +3602,14 @@ function authenticatedSubagentChild(child, { Transport, getTokens, thread, signa
3536
3602
  if (method === "thread/start") {
3537
3603
  if (!initialized) throw new Error("Codex initialization incomplete");
3538
3604
  await login();
3539
- return server.request(method, {
3605
+ const result = await server.request(method, {
3540
3606
  ...params,
3541
3607
  ...thread
3542
3608
  }, signal);
3609
+ if (result.model !== thread.model) throw new Error("Codex did not apply the selected subtask model");
3610
+ const effort = thread.config?.model_reasoning_effort;
3611
+ if (effort !== void 0 && result.reasoningEffort !== effort) throw new Error("Codex did not apply the selected subtask reasoning effort");
3612
+ return result;
3543
3613
  }
3544
3614
  return server.request(method, params, signal);
3545
3615
  });
@@ -3557,6 +3627,100 @@ function authenticatedSubagentChild(child, { Transport, getTokens, thread, signa
3557
3627
  } });
3558
3628
  }
3559
3629
  //#endregion
3630
+ //#region src/subagent-cli.js
3631
+ const SUBAGENT_CLI_ALIAS = "dsh-codex-subtask-cli";
3632
+ const SUBAGENT_CODEX_VERSION = "0.166.0";
3633
+ const SUBAGENT_CLI_SPEC = `${SUBAGENT_CLI_ALIAS}@npm:@openai/codex@${SUBAGENT_CODEX_VERSION}`;
3634
+ const spec = `npm:@openai/codex@${SUBAGENT_CODEX_VERSION}`;
3635
+ /** A profile-owned alias, never the host CLI, PATH, or another app's installation. */
3636
+ function createSubagentCli({ profile, loadOperations = async (value) => {
3637
+ return import(pathToFileURL(createRequire(value.installAnchor).resolve("@deepseek-ai/dsh-plugin-manager/operations")).href);
3638
+ } }) {
3639
+ function inspect() {
3640
+ const value = profile();
3641
+ if (!value?.dir || !value.installAnchor) return {
3642
+ available: false,
3643
+ installed: false,
3644
+ owned: false
3645
+ };
3646
+ try {
3647
+ const manifestPath = resolve(value.dir, "package.json");
3648
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
3649
+ const dependency = manifest.dependencies?.[SUBAGENT_CLI_ALIAS];
3650
+ const owned = typeof dependency === "string" && /^npm:@openai\/codex@\d+\.\d+\.\d+$/u.test(dependency);
3651
+ if (dependency !== void 0 && !owned || [
3652
+ "devDependencies",
3653
+ "optionalDependencies",
3654
+ "peerDependencies"
3655
+ ].some((field) => Object.hasOwn(manifest[field] ?? {}, "dsh-codex-subtask-cli"))) return {
3656
+ available: false,
3657
+ installed: false,
3658
+ owned: false
3659
+ };
3660
+ if (!owned) return {
3661
+ available: true,
3662
+ installed: false,
3663
+ owned: false
3664
+ };
3665
+ try {
3666
+ const path = createRequire(manifestPath).resolve(`${SUBAGENT_CLI_ALIAS}/package.json`);
3667
+ const cli = JSON.parse(readFileSync(path, "utf8"));
3668
+ const installed = dependency === spec && cli.name === "@openai/codex" && cli.version === "0.166.0" && cli.bin?.codex === "bin/codex.js";
3669
+ return {
3670
+ available: true,
3671
+ owned,
3672
+ installed,
3673
+ ...installed ? { wrapper: resolve(dirname(path), cli.bin.codex) } : {}
3674
+ };
3675
+ } catch {
3676
+ return {
3677
+ available: true,
3678
+ owned,
3679
+ installed: false
3680
+ };
3681
+ }
3682
+ } catch {
3683
+ return {
3684
+ available: true,
3685
+ owned: false,
3686
+ installed: false
3687
+ };
3688
+ }
3689
+ }
3690
+ return {
3691
+ inspect,
3692
+ async change(action, signal) {
3693
+ if (!["install", "remove"].includes(action)) throw Error("invalid-action");
3694
+ const state = inspect();
3695
+ if (!state.available) throw Error("unavailable");
3696
+ if (action === "remove" && !state.owned) return;
3697
+ const value = profile(), { runPluginCommand } = await loadOperations(value);
3698
+ if (typeof runPluginCommand !== "function") throw Error("unavailable");
3699
+ signal.throwIfAborted();
3700
+ const result = await runPluginCommand({
3701
+ ...value,
3702
+ profile: value.name
3703
+ }, action === "install" ? [
3704
+ "add",
3705
+ "--save-exact",
3706
+ "--ignore-scripts",
3707
+ SUBAGENT_CLI_SPEC
3708
+ ] : ["remove", SUBAGENT_CLI_ALIAS], {
3709
+ ...value.packageManager,
3710
+ execution: "service",
3711
+ signal,
3712
+ outputBytes: 16384,
3713
+ activateNewBundles: false,
3714
+ lockWaitMs: 1e4,
3715
+ idleTimeoutMs: 12e4
3716
+ });
3717
+ signal.throwIfAborted();
3718
+ if (result.exitCode !== 0 || result.timedOut) throw Error("operation-error");
3719
+ if (action === "install" && !inspect().installed) throw Error("operation-error");
3720
+ }
3721
+ };
3722
+ }
3723
+ //#endregion
3560
3724
  //#region src/subagent-runtime.js
3561
3725
  const SUBAGENT_RUNTIME_PACKAGE = "@deepseek-ai/dsh-subagent-codex";
3562
3726
  const SUPPORTED_RUNTIME_VERSIONS = Object.freeze([
@@ -3573,7 +3737,9 @@ const SUPPORTED_RUNTIME_VERSIONS = Object.freeze([
3573
3737
  "0.2.1-rc.3",
3574
3738
  "0.2.1-rc.4",
3575
3739
  "0.2.1-rc.5",
3576
- "0.2.2-alpha.2"
3740
+ "0.2.2-alpha.2",
3741
+ "0.2.2-alpha.3",
3742
+ "0.2.2-rc.1"
3577
3743
  ]);
3578
3744
  const require = createRequire(import.meta.url);
3579
3745
  const execute = promisify(execFile);
@@ -3591,7 +3757,7 @@ function matchingSubagentRuntimeVersion(resolve = require.resolve) {
3591
3757
  const version = hostDshVersion(resolve, resolve === require.resolve ? process.argv[1] : "");
3592
3758
  return SUPPORTED_RUNTIME_VERSIONS.includes(version) ? version : void 0;
3593
3759
  }
3594
- function inspectSubagentRuntime(resolve = require.resolve) {
3760
+ function inspectSubagentRuntime(resolve = require.resolve, cli) {
3595
3761
  try {
3596
3762
  const manifestPath = resolve(`${SUBAGENT_RUNTIME_PACKAGE}/package.json`);
3597
3763
  const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
@@ -3599,33 +3765,46 @@ function inspectSubagentRuntime(resolve = require.resolve) {
3599
3765
  installed: false,
3600
3766
  present: true
3601
3767
  };
3602
- return { installed: true };
3768
+ return {
3769
+ installed: cli?.inspect().installed === true,
3770
+ present: true,
3771
+ adapterInstalled: true
3772
+ };
3603
3773
  } catch {
3604
3774
  return { installed: false };
3605
3775
  }
3606
3776
  }
3607
- async function loadSubagentRuntime({ resolve: resolve$1 = require.resolve, run = execute, importModule = (url) => import(url) } = {}) {
3608
- if (!inspectSubagentRuntime(resolve$1).installed) throw new Error("Codex subtask runtime is not prepared");
3609
- const entry = resolve$1(SUBAGENT_RUNTIME_PACKAGE);
3777
+ async function loadSubagentRuntime({ resolve = require.resolve, cli, run = execute, importModule = (url) => import(url), platform = process.platform } = {}) {
3778
+ if (!inspectSubagentRuntime(resolve, cli).installed) throw new Error("Codex subtask runtime is not prepared");
3779
+ const entry = resolve(SUBAGENT_RUNTIME_PACKAGE);
3610
3780
  const providerRequire = createRequire(entry);
3611
- const codexManifestPath = providerRequire.resolve("@openai/codex/package.json");
3612
- const codex = JSON.parse(readFileSync(codexManifestPath, "utf8"));
3613
- if (codex.version !== "0.153.4" || typeof codex.bin?.codex !== "string") throw new Error("Codex subtask runtime version is unsupported");
3614
- const wrapper = resolve(dirname(codexManifestPath), codex.bin.codex);
3781
+ const { wrapper } = cli.inspect();
3615
3782
  try {
3616
3783
  const { stdout } = await run(process.execPath, [wrapper, "--version"], {
3617
3784
  timeout: 1e4,
3618
3785
  maxBuffer: 4096,
3619
3786
  windowsHide: true
3620
3787
  });
3621
- if (stdout.trim() !== "codex-cli 0.153.4") throw new Error("Unexpected CLI version");
3788
+ if (stdout.trim() !== `codex-cli 0.166.0`) throw new Error("Unexpected CLI version");
3622
3789
  } catch {
3623
3790
  throw new Error("Codex subtask runtime is incomplete; prepare it for this platform");
3624
3791
  }
3625
3792
  const [official, { JsonRpcLineTransport: Transport }] = await Promise.all([importModule(pathToFileURL(entry).href), importModule(pathToFileURL(providerRequire.resolve("@deepseek-ai/dsh-sdk-protocol")).href)]);
3626
3793
  return {
3627
3794
  official,
3628
- Transport
3795
+ Transport,
3796
+ argv: [
3797
+ process.execPath,
3798
+ wrapper,
3799
+ "app-server",
3800
+ "--listen",
3801
+ "stdio://",
3802
+ "-c",
3803
+ "features.apps=false",
3804
+ "-c",
3805
+ "features.plugins=false",
3806
+ ...platform === "win32" ? ["-c", "features.prefer_mxc=true"] : []
3807
+ ]
3629
3808
  };
3630
3809
  }
3631
3810
  //#endregion
@@ -3636,7 +3815,7 @@ const MODES = /* @__PURE__ */ new Set([
3636
3815
  "workspace-write",
3637
3816
  "danger-full-access"
3638
3817
  ]);
3639
- function subagentThreadPolicy(parent, policy, requested = {}) {
3818
+ function subagentThreadPolicy(parent, policy, requested = {}, platform = process.platform) {
3640
3819
  if (!MODES.has(policy?.mode)) throw new Error("DSH subagent sandbox policy is unavailable");
3641
3820
  const selected = parent.session.requestHeader?.()?.config ?? parent.options ?? {};
3642
3821
  for (const key of Object.keys(requested)) if (![
@@ -3664,7 +3843,10 @@ function subagentThreadPolicy(parent, policy, requested = {}) {
3664
3843
  approvalPolicy: "never",
3665
3844
  sandbox: policy.mode,
3666
3845
  config: {
3667
- ...CHILD_FEATURES_OFF,
3846
+ features: {
3847
+ ...CHILD_FEATURES_OFF.features,
3848
+ ...platform === "win32" ? { prefer_mxc: true } : {}
3849
+ },
3668
3850
  ...effort === void 0 ? {} : { model_reasoning_effort: effort }
3669
3851
  }
3670
3852
  };
@@ -3687,12 +3869,8 @@ const CHILD_FEATURES_OFF = Object.freeze({ features: Object.freeze(Object.fromEn
3687
3869
  "in_app_browser"
3688
3870
  ].map((name) => [name, false]))) });
3689
3871
  /** Reuse the official DSH process/turn provider; keep only subscription auth here. */
3690
- function createSubscriptionSubagent({ ctx, nativeHome, resolveAuth, store, refresh, loadRuntime, maintenance = () => false }) {
3691
- let runtime;
3692
- const load = () => runtime ??= loadRuntime().catch((error) => {
3693
- runtime = void 0;
3694
- throw error;
3695
- });
3872
+ function createSubscriptionSubagent({ ctx, nativeHome, resolveAuth, store, refresh, loadRuntime, maintenance = () => false, defaults }) {
3873
+ const load = () => loadRuntime();
3696
3874
  const active = /* @__PURE__ */ new Set();
3697
3875
  let disposed = false;
3698
3876
  return {
@@ -3714,14 +3892,17 @@ function createSubscriptionSubagent({ ctx, nativeHome, resolveAuth, store, refre
3714
3892
  const signal = AbortSignal.any([request.signal, controller.signal]);
3715
3893
  let run;
3716
3894
  try {
3717
- const thread = subagentThreadPolicy(request.parent, ctx.sandboxPolicy.resolve({ session: request.parent.session }), request.agentOptions);
3895
+ await defaults?.ready(request.agentOptions, signal);
3896
+ signal.throwIfAborted();
3897
+ const options = defaults?.resolve(request.parent, request.agentOptions) ?? request.agentOptions;
3898
+ const thread = subagentThreadPolicy(request.parent, ctx.sandboxPolicy.resolve({ session: request.parent.session }), options);
3718
3899
  const getTokens = await createSubagentTokens({
3719
3900
  resolveAuth,
3720
3901
  store,
3721
3902
  refresh,
3722
3903
  signal
3723
3904
  });
3724
- const { official, Transport } = await load();
3905
+ const { official, Transport, argv } = await load();
3725
3906
  const proxy = await resolveCodexOAuthProxy({ target: new URL("https://chatgpt.com/") });
3726
3907
  signal.throwIfAborted();
3727
3908
  await mkdir(nativeHome, { recursive: true });
@@ -3740,6 +3921,7 @@ function createSubscriptionSubagent({ ctx, nativeHome, resolveAuth, store, refre
3740
3921
  } },
3741
3922
  subprocess: { spawn: (spec) => authenticatedSubagentChild(ctx.subprocess.spawn({
3742
3923
  ...spec,
3924
+ argv,
3743
3925
  env: {
3744
3926
  ...spec.env,
3745
3927
  ...env
@@ -3844,7 +4026,7 @@ function createSubagentBackendSwitcher({ entries, prepare, persist }) {
3844
4026
  if (!originals.has(fiber)) originals.set(fiber, { ...config });
3845
4027
  return selected === "codex" ? convert(config) : config;
3846
4028
  };
3847
- const select = (mode) => {
4029
+ const select = (mode, { validate = true } = {}) => {
3848
4030
  if (!["dsh", "codex"].includes(mode)) return Promise.reject(/* @__PURE__ */ new Error("Invalid subagent backend"));
3849
4031
  const next = tail.catch(() => {}).then(async () => {
3850
4032
  if (disposed) throw new Error("Subagent backend is unavailable");
@@ -3852,7 +4034,7 @@ function createSubagentBackendSwitcher({ entries, prepare, persist }) {
3852
4034
  for (const entry of all) if (entry.fiber && standard(entry, entry.fiber.config) && !originals.has(entry.fiber)) originals.set(entry.fiber, { ...entry.fiber.config });
3853
4035
  if (mode === "codex") {
3854
4036
  if (!originals.size && !all.some((entry) => standard(entry, entry.options?.config))) throw new Error("No standard DSH independent subagent tool is available");
3855
- await prepare();
4037
+ if (validate) await prepare();
3856
4038
  }
3857
4039
  const changed = [];
3858
4040
  const previous = selected;
@@ -3895,7 +4077,7 @@ function createSubagentBackendSwitcher({ entries, prepare, persist }) {
3895
4077
  }
3896
4078
  //#endregion
3897
4079
  //#region src/runtime-management.js
3898
- function createRuntimeManagement({ manager, inspect, active, selectDsh, componentVersion = matchingSubagentRuntimeVersion }) {
4080
+ function createRuntimeManagement({ manager, inspect, active, selectDsh, cli, componentVersion = matchingSubagentRuntimeVersion }) {
3899
4081
  let operation;
3900
4082
  let state = {
3901
4083
  phase: "idle",
@@ -3917,15 +4099,20 @@ function createRuntimeManagement({ manager, inspect, active, selectDsh, componen
3917
4099
  available = false;
3918
4100
  }
3919
4101
  const runtime = inspect();
4102
+ const cliState = cli?.inspect();
3920
4103
  const version = componentVersion();
3921
4104
  return {
3922
4105
  ...state,
3923
4106
  available,
3924
- installable: available && version !== void 0,
4107
+ installable: available && version !== void 0 && (!cli || cliState?.available === true),
3925
4108
  componentVersion: version,
4109
+ ...cli ? {
4110
+ codexVersion: SUBAGENT_CODEX_VERSION,
4111
+ cliUpdateRequired: runtime.adapterInstalled === true && !runtime.installed
4112
+ } : {},
3926
4113
  installed: runtime.installed,
3927
- present: runtime.installed || runtime.present === true || bundle?.installed === true,
3928
- removable: available && bundle?.installed === true && !bundle.readOnlyReason,
4114
+ present: runtime.installed || runtime.present === true || bundle?.installed === true || cliState?.owned === true,
4115
+ removable: available && (bundle?.installed === true && !bundle.readOnlyReason || cliState?.owned === true),
3929
4116
  active: active()
3930
4117
  };
3931
4118
  };
@@ -3937,12 +4124,14 @@ function createRuntimeManagement({ manager, inspect, active, selectDsh, componen
3937
4124
  const host = manager();
3938
4125
  if (!supported(host)) throw Error("unavailable");
3939
4126
  const version = componentVersion();
3940
- if (action === "install" && version === void 0) throw Error("unavailable");
4127
+ if (action === "install" && (version === void 0 || cli && !cli.inspect().available)) throw Error("unavailable");
3941
4128
  const requestId = randomUUID();
3942
4129
  const current = {
3943
4130
  action,
3944
4131
  requestId,
3945
- host
4132
+ host,
4133
+ controller: new AbortController(),
4134
+ changed: false
3946
4135
  };
3947
4136
  operation = current;
3948
4137
  state = {
@@ -3951,33 +4140,50 @@ function createRuntimeManagement({ manager, inspect, active, selectDsh, componen
3951
4140
  };
3952
4141
  current.done = (async () => {
3953
4142
  try {
4143
+ let bundle;
3954
4144
  if (action === "remove") {
3955
- const bundle = (await host.listBundles()).find((value) => value.name === SUBAGENT_RUNTIME_PACKAGE);
3956
- if (!bundle?.installed || bundle.readOnlyReason) throw Error("not-removable");
4145
+ bundle = (await host.listBundles()).find((value) => value.name === SUBAGENT_RUNTIME_PACKAGE);
4146
+ if ((!bundle?.installed || bundle.readOnlyReason) && !cli?.inspect().owned) throw Error("not-removable");
3957
4147
  await selectDsh();
3958
4148
  }
3959
- const result = action === "install" ? await host.installBundle(`${SUBAGENT_RUNTIME_PACKAGE}@${version}`, {
3960
- enabled: false,
3961
- requestId
3962
- }) : await host.removeBundle(SUBAGENT_RUNTIME_PACKAGE);
3963
- if (result.application === "cancelled") state = {
3964
- phase: "cancelled",
3965
- restartRequired: false
3966
- };
3967
- else if (["applied", "restart-required"].includes(result.application)) state = {
4149
+ if (action === "install" && !inspect().adapterInstalled || action === "remove" && bundle?.installed && !bundle.readOnlyReason) {
4150
+ const result = action === "install" ? await host.installBundle(`${SUBAGENT_RUNTIME_PACKAGE}@${version}`, {
4151
+ enabled: false,
4152
+ requestId
4153
+ }) : await host.removeBundle(SUBAGENT_RUNTIME_PACKAGE);
4154
+ if (result.application === "cancelled") {
4155
+ state = {
4156
+ phase: "cancelled",
4157
+ restartRequired: false
4158
+ };
4159
+ return;
4160
+ }
4161
+ if (!["applied", "restart-required"].includes(result.application)) throw Error(result.packageResult?.kind ?? result.error?.code ?? "operation-error");
4162
+ current.changed = true;
4163
+ }
4164
+ current.controller.signal.throwIfAborted();
4165
+ if (cli) {
4166
+ current.cli = true;
4167
+ state.phase = action === "install" ? "installing" : "removing";
4168
+ await cli.change(action, current.controller.signal);
4169
+ current.changed = true;
4170
+ }
4171
+ state = {
3968
4172
  phase: "done",
3969
4173
  restartRequired: true
3970
4174
  };
3971
- else state = {
3972
- phase: "failed",
3973
- restartRequired: false,
3974
- error: result.packageResult?.kind ?? result.error?.code ?? "operation-error"
3975
- };
3976
4175
  } catch (error) {
3977
- state = {
4176
+ state = current.controller.signal.aborted ? {
4177
+ phase: "cancelled",
4178
+ restartRequired: current.changed
4179
+ } : {
3978
4180
  phase: "failed",
3979
- restartRequired: false,
3980
- error: error.message === "not-removable" ? "not-removable" : "operation-error"
4181
+ restartRequired: current.changed,
4182
+ error: [
4183
+ "not-removable",
4184
+ "build-blocked",
4185
+ "network"
4186
+ ].includes(error.message) ? error.message : "operation-error"
3981
4187
  };
3982
4188
  } finally {
3983
4189
  operation = void 0;
@@ -3995,6 +4201,11 @@ function createRuntimeManagement({ manager, inspect, active, selectDsh, componen
3995
4201
  async cancel() {
3996
4202
  const current = operation;
3997
4203
  if (current?.action !== "install") return status();
4204
+ if (current.cli) {
4205
+ current.controller.abort();
4206
+ await current.done;
4207
+ return status();
4208
+ }
3998
4209
  if ((await current.host.cancelInstall(current.requestId)).status === "cancelled") await current.done;
3999
4210
  return status();
4000
4211
  }
@@ -4399,7 +4610,7 @@ function inheritedOriginalImageRef(session, assetId) {
4399
4610
  }
4400
4611
  //#endregion
4401
4612
  //#region src/version.js
4402
- const PACKAGE_VERSION = "3.2.4";
4613
+ const PACKAGE_VERSION = "3.2.6";
4403
4614
  const USER_AGENT = `dsh-codex-subscription/${PACKAGE_VERSION}`;
4404
4615
  //#endregion
4405
4616
  //#region src/codex-images.js
@@ -10258,7 +10469,7 @@ function nativeDelegations(ctx, agent) {
10258
10469
  const tools = scopedTools(agent) ?? ctx.get?.("tools");
10259
10470
  const subagents = ctx.get?.("subagents");
10260
10471
  return presetEntries(ctx).flatMap((entry) => {
10261
- const config = entry.fiber?.config ?? entry.options?.config;
10472
+ const config = entry.fiber?.effectiveConfig ?? entry.fiber?.config ?? entry.options?.config;
10262
10473
  if (entry.options?.name !== "@deepseek-ai/dsh-tool-subagent" || !["spawn", "codex-subscription-subagent"].includes(config?.provider) || !subagents?.getProvider?.(config.provider)) return [];
10263
10474
  const name = config.toolName ?? "subagent";
10264
10475
  const definition = tools?.get?.(name, agent);
@@ -10302,7 +10513,7 @@ function createUltraExecutionPreset({ catalog, resolveAgent = () => void 0, defa
10302
10513
  if (!state || !state.tools.some((tool) => tool.name === exec.name)) return;
10303
10514
  if (!state.active || state.signal.aborted || exec.agent !== agent) return "Ultra delegation belongs to an inactive or cancelled request";
10304
10515
  const tool = state.tools.find((tool) => tool.name === exec.name);
10305
- if (tools.get(exec.name, agent) !== tool.definition) return "Ultra delegation tool changed after request preparation; retry the request";
10516
+ if (tools.get(exec.name, agent, exec.toolSet) !== tool.definition) return "Ultra delegation tool changed after request preparation; retry the request";
10306
10517
  });
10307
10518
  bindings.set(agent, binding);
10308
10519
  return binding;
@@ -11824,7 +12035,8 @@ const LEVELS = [
11824
12035
  "xhigh",
11825
12036
  "max"
11826
12037
  ];
11827
- const DEFAULT_REFRESH_TIMEOUT_MS = 1e4;
12038
+ const DEFAULT_REFRESH_TIMEOUT_MS = 6e4;
12039
+ const DEFAULT_LOCAL_TIMEOUT_MS = 1e4;
11828
12040
  const record$6 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
11829
12041
  const nonEmpty$1 = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
11830
12042
  const positiveInteger = (value) => Number.isSafeInteger(value) && value > 0 ? value : void 0;
@@ -12021,11 +12233,13 @@ function mergeModel(baseModels, remote) {
12021
12233
  * @returns {object} 可初始化、刷新、查询和清除的模型目录
12022
12234
  */
12023
12235
  function createOfficialModelCatalog(options = {}) {
12236
+ const nativeVersion = options.nativeVersion;
12237
+ const endpoint = nativeVersion === void 0 ? CODEX_MODELS_URL : `https://chatgpt.com/backend-api/codex/models?client_version=${encodeURIComponent(nativeVersion)}`;
12024
12238
  const fetchCatalog = options.fetch ?? fetch;
12025
12239
  const getNow = options.now ?? Date.now;
12026
12240
  const schedule = options.setTimeout ?? setTimeout;
12027
12241
  const cancelTimer = options.clearTimeout ?? clearTimeout;
12028
- const timeoutMs = Number.isFinite(options.timeoutMs) && options.timeoutMs > 0 ? options.timeoutMs : DEFAULT_REFRESH_TIMEOUT_MS;
12242
+ const timeoutMs = Number.isFinite(options.timeoutMs) && options.timeoutMs > 0 ? options.timeoutMs : void 0;
12029
12243
  const loadCache = options.loadCache ?? loadModelCatalogCache;
12030
12244
  const saveCache = options.saveCache ?? saveModelCatalogCache;
12031
12245
  const retryDelays = (options.retryDelaysMs ?? []).filter((delay) => Number.isFinite(delay) && delay > 0);
@@ -12068,7 +12282,7 @@ function createOfficialModelCatalog(options = {}) {
12068
12282
  generation,
12069
12283
  controller
12070
12284
  };
12071
- const timer = schedule(() => controller.abort(/* @__PURE__ */ new Error(`Codex model catalog ${label} timed out`)), timeoutMs);
12285
+ const timer = schedule(() => controller.abort(Object.assign(/* @__PURE__ */ new Error(`Codex model catalog ${label} timed out`), { name: "TimeoutError" })), timeoutMs ?? (label === "refresh" ? DEFAULT_REFRESH_TIMEOUT_MS : DEFAULT_LOCAL_TIMEOUT_MS));
12072
12286
  timer.unref?.();
12073
12287
  const task = Promise.resolve().then(() => {
12074
12288
  controller.signal.throwIfAborted();
@@ -12188,7 +12402,7 @@ function createOfficialModelCatalog(options = {}) {
12188
12402
  initialized = true;
12189
12403
  }
12190
12404
  const id = credentials.accountId;
12191
- const response = await fetchCatalog(CODEX_MODELS_URL, {
12405
+ const response = await fetchCatalog(endpoint, {
12192
12406
  method: "GET",
12193
12407
  redirect: "error",
12194
12408
  signal: requestSignal,
@@ -12196,7 +12410,7 @@ function createOfficialModelCatalog(options = {}) {
12196
12410
  authorization: `Bearer ${credentials.access}`,
12197
12411
  "chatgpt-account-id": id,
12198
12412
  accept: "application/json",
12199
- originator: "pi",
12413
+ originator: nativeVersion === void 0 ? "pi" : "codex_cli_rs",
12200
12414
  "user-agent": USER_AGENT,
12201
12415
  ...etag === void 0 ? {} : { "if-none-match": etag }
12202
12416
  }
@@ -12206,7 +12420,10 @@ function createOfficialModelCatalog(options = {}) {
12206
12420
  const raw = response.status === 304 ? rawCatalog : await response.json();
12207
12421
  if (!current(flight) || accountId !== id) return false;
12208
12422
  if (raw === void 0) throw new Error("Codex returned HTTP 304 without a cached model catalog");
12209
- const remote = parseOfficialModelCatalog(raw, getNow());
12423
+ const remote = parseOfficialModelCatalog((options.subagent === true || nativeVersion !== void 0) && Array.isArray(raw?.models) ? {
12424
+ ...raw,
12425
+ models: raw.models.filter((model) => model?.visibility === "list" && model.supported_in_api !== false)
12426
+ } : raw, getNow());
12210
12427
  const next = remote.map((model) => mergeModel(options.baseModels(), model)).filter(Boolean);
12211
12428
  if (!next.length) throw new Error("Codex returned an empty or incompatible model catalog");
12212
12429
  const changed = response.status !== 304 || JSON.stringify(next) !== JSON.stringify(models);
@@ -12748,7 +12965,8 @@ function configuredFetchProviderId(web, entries = [], ambient = process.env.DSH_
12748
12965
  const environment = "fetchProviderEnv" in web ? web.fetchProviderEnv : ambient;
12749
12966
  if (typeof web.config?.fetchProvider?.get === "function") return web.config.fetchProvider.get() ?? environment;
12750
12967
  const entry = [...entries].find((item) => item.options?.id === "web");
12751
- const value = entry?.fiber?.config?.fetchProvider;
12968
+ const fiber = entry?.fiber;
12969
+ const value = (fiber?.effectiveConfig ?? fiber?.config)?.fetchProvider;
12752
12970
  if (typeof value?.get === "function") return value.get() ?? environment;
12753
12971
  return value ?? entry?.options?.config?.fetchProvider ?? environment;
12754
12972
  }
@@ -15177,12 +15395,11 @@ function parseDetails(value, now) {
15177
15395
  if (available.length === 0) throw new Error("No usable quota reset is available");
15178
15396
  return {
15179
15397
  availableCount: value.available_count,
15180
- credits: available.map(({ credit, expiresAt }, index) => ({
15398
+ credits: available.map(({ credit, expiresAt }) => ({
15181
15399
  creditId: credit.id,
15182
15400
  title: safeCopy(credit.title),
15183
15401
  description: safeCopy(credit.description),
15184
- creditExpiresAt: expiresAt,
15185
- index
15402
+ creditExpiresAt: expiresAt
15186
15403
  }))
15187
15404
  };
15188
15405
  }
@@ -15220,11 +15437,16 @@ function createCodexResetCreditService(options) {
15220
15437
  const creditRefs = /* @__PURE__ */ new Map();
15221
15438
  let creditRefSequence = 0;
15222
15439
  const rememberCreditRef = (accountId, credit) => {
15440
+ for (const [ref, stored] of creditRefs) {
15441
+ if (stored.accountId !== accountId || stored.creditId !== credit.creditId) continue;
15442
+ creditRefs.delete(ref);
15443
+ creditRefs.set(ref, stored);
15444
+ return ref;
15445
+ }
15223
15446
  const ref = `${randomUUID$1()}-${++creditRefSequence}`;
15224
15447
  creditRefs.set(ref, {
15225
15448
  accountId,
15226
- creditId: credit.creditId,
15227
- index: credit.index
15449
+ creditId: credit.creditId
15228
15450
  });
15229
15451
  while (creditRefs.size > 64) creditRefs.delete(creditRefs.keys().next().value);
15230
15452
  return ref;
@@ -15303,7 +15525,7 @@ function createCodexResetCreditService(options) {
15303
15525
  if (creditRef !== void 0) {
15304
15526
  const reference = typeof creditRef === "string" ? creditRefs.get(creditRef) : void 0;
15305
15527
  if (reference === void 0 || reference.accountId !== accountId) throw new Error("This quota reset confirmation is no longer valid");
15306
- selected = details.credits.find((credit) => credit.creditId === reference.creditId && credit.index === reference.index);
15528
+ selected = details.credits.find((credit) => credit.creditId === reference.creditId);
15307
15529
  if (selected === void 0) throw new Error("This quota reset confirmation is no longer valid");
15308
15530
  }
15309
15531
  if (selected === void 0) throw new Error("No usable quota reset is available");
@@ -15439,7 +15661,7 @@ async function settlesLive(preferences, patch, signal, { attempts = 8, delayMs =
15439
15661
  }
15440
15662
  return live();
15441
15663
  }
15442
- function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageReader, planHistoryReader, usageProfileReader, resetCreditService, preferences, defaultModel, runtimeManagement, remoteControl, desktopVoice, nativeVoice, voicePreview, composerPredictions, diagnosticsReader, modelCatalog, originalImages, resolveInheritedOriginal, closeConnections, onAccountChanged, onCleanupFailure }) {
15664
+ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageReader, planHistoryReader, usageProfileReader, resetCreditService, preferences, defaultModel, runtimeManagement, remoteControl, desktopVoice, nativeVoice, voicePreview, composerPredictions, diagnosticsReader, modelCatalog, subagentCatalog, originalImages, resolveInheritedOriginal, closeConnections, onAccountChanged, onCleanupFailure }) {
15443
15665
  return async (endpoint, payload, signal) => {
15444
15666
  if (endpoint === "predictions/generate") try {
15445
15667
  signal?.throwIfAborted();
@@ -15665,12 +15887,15 @@ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageRe
15665
15887
  if (endpoint === "preferences/models") try {
15666
15888
  signal.throwIfAborted();
15667
15889
  if (typeof modelCatalog?.refresh !== "function" || typeof preferences?.status !== "function") return publicError("internal", "Could not refresh Codex model catalog");
15668
- await modelCatalog.refresh({ signal });
15890
+ const native = subagentCatalog && preferences.status()?.subagentBackend === "codex" ? subagentCatalog.refresh({ signal }).catch(() => {}) : void 0;
15891
+ await Promise.all([modelCatalog.refresh({ signal }), native]);
15892
+ signal.throwIfAborted();
15669
15893
  const value = preferences.status();
15670
15894
  return {
15671
15895
  ok: true,
15672
15896
  value: {
15673
15897
  availableModels: Array.isArray(value?.availableModels) ? value.availableModels : [],
15898
+ subagentModels: Array.isArray(value?.subagentModels) ? value.subagentModels : [],
15674
15899
  contextModels: Array.isArray(value?.contextModels) ? value.contextModels : [],
15675
15900
  verbosityModels: Array.isArray(value?.verbosityModels) ? value.verbosityModels : [],
15676
15901
  fastModels: Array.isArray(value?.fastModels) ? value.fastModels : [],
@@ -15681,6 +15906,7 @@ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageRe
15681
15906
  };
15682
15907
  } catch (error) {
15683
15908
  if (signal.aborted) throw error;
15909
+ if (error?.name === "TimeoutError") return publicError("internal", "Codex model catalog refresh timed out");
15684
15910
  return publicError("internal", "Could not refresh Codex model catalog");
15685
15911
  }
15686
15912
  if (endpoint === "preferences/status" || endpoint === "preferences/update") try {
@@ -15703,6 +15929,10 @@ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageRe
15703
15929
  if (!rule.choices.includes(payload[field])) return publicError("internal", rule.error);
15704
15930
  patch[field] = payload[field];
15705
15931
  }
15932
+ if (Object.hasOwn(payload ?? {}, "subagentDefaultModel")) {
15933
+ if (normalizeSubagentModel(payload.subagentDefaultModel) !== payload.subagentDefaultModel) return publicError("internal", "Invalid subtask model");
15934
+ patch.subagentDefaultModel = payload.subagentDefaultModel;
15935
+ }
15706
15936
  if (Object.hasOwn(payload ?? {}, "customContextWindow")) {
15707
15937
  if (normalizeCustomContextWindow(payload["customContextWindow"]) !== payload["customContextWindow"]) return publicError("internal", "Invalid custom context window");
15708
15938
  patch[CUSTOM_CONTEXT_WINDOW_FIELD] = payload[CUSTOM_CONTEXT_WINDOW_FIELD];
@@ -15849,7 +16079,7 @@ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageRe
15849
16079
  onCleanupFailure?.();
15850
16080
  } catch {}
15851
16081
  if (endpoint !== "logout") Promise.resolve().then(() => modelCatalog?.refresh({ signal: void 0 })).catch(() => {});
15852
- } else if (result.ok === true && (endpoint === "status" || result.value?.authenticated === true)) modelCatalog?.refresh({ signal: void 0 }).catch(() => {});
16082
+ } else if (result.ok === true && result.value?.authenticated === true && modelCatalog?.status?.().source === "unavailable" && modelCatalog.status().refresh === "idle") modelCatalog?.refresh({ signal: void 0 }).catch(() => {});
15853
16083
  return result;
15854
16084
  };
15855
16085
  }
@@ -16942,7 +17172,8 @@ function createSearchProviderSwitcher(loader) {
16942
17172
  return typeof configured === "string" && configured.length > 0 && !SUBSCRIPTION_SEARCH_PROVIDER_IDS.has(configured) ? configured : DSH_SEARCH_PROVIDER_FALLBACK;
16943
17173
  };
16944
17174
  const current = () => {
16945
- const value = webEntry()?.fiber?.config?.searchProvider;
17175
+ const fiber = webEntry()?.fiber;
17176
+ const value = (fiber?.effectiveConfig ?? fiber?.config)?.searchProvider;
16946
17177
  return typeof value === "string" ? value : value?.get?.();
16947
17178
  };
16948
17179
  const writeProvider = async (provider) => {
@@ -16965,6 +17196,7 @@ function createSearchProviderSwitcher(loader) {
16965
17196
  const settingsFields = {
16966
17197
  [DISABLED_MODELS_FIELD]: z.transform(z.array(z.string()).max(100), normalizeDisabledModels).default([]),
16967
17198
  [AUTO_QUOTA_RETRY_FIELD]: z.boolean().default(false),
17199
+ subagentDefaultModel: z.transform(z.string().max(80), normalizeSubagentModel).default(""),
16968
17200
  ...Object.fromEntries(Object.entries(PREFERENCE_FIELDS).map(([field, rule]) => [field, rule.default === void 0 ? z.union(rule.choices) : z.union(rule.choices).default(rule.default)])),
16969
17201
  imageModel: z.union(Object.keys(IMAGE_MODELS)).default(DEFAULT_IMAGE_MODEL),
16970
17202
  imageQuality: z.union([
@@ -17008,9 +17240,11 @@ function apply(ctx, config = {}) {
17008
17240
  const baseProvider = createOpenAICodexProvider();
17009
17241
  let resolveAuth = async () => void 0;
17010
17242
  let subagentBackend;
17243
+ const subagentCli = createSubagentCli({ profile: () => ctx.get?.("profileContext") });
17011
17244
  const runtimeManagement = createRuntimeManagement({
17012
17245
  manager: () => ctx.get?.("pluginManager"),
17013
- inspect: inspectSubagentRuntime,
17246
+ inspect: () => inspectSubagentRuntime(void 0, subagentCli),
17247
+ cli: subagentCli,
17014
17248
  active: () => subagentBackend?.activeCount() ?? 0,
17015
17249
  selectDsh: async () => {
17016
17250
  if (subagentBackend) await subagentBackend.select("dsh");
@@ -17036,6 +17270,20 @@ function apply(ctx, config = {}) {
17036
17270
  ]
17037
17271
  });
17038
17272
  const appendUltraPolicy = loadHostSessionSdk()?.appendPluginRecord;
17273
+ const subagentCatalog = createOfficialModelCatalog({
17274
+ subagent: true,
17275
+ getAuth: (options) => resolveAuth(options),
17276
+ readCredential: (options) => store.read(PROVIDER, options),
17277
+ baseModels: () => baseProvider.getModels(),
17278
+ fetch: (input, init) => network.fetch("catalog", input, init)
17279
+ });
17280
+ ctx.effect(() => () => subagentCatalog.clear());
17281
+ const subagentDefaults = createSubagentDefaults({
17282
+ readSettings: settings.get,
17283
+ catalog: subagentCatalog,
17284
+ modelSelection: () => ctx.get?.("subagentModelSelection")?.current(),
17285
+ projections: () => ctx.get?.("sessionProjections")
17286
+ });
17039
17287
  const ultra = createUltraExecutionPreset({
17040
17288
  catalog: modelCatalog,
17041
17289
  resolveAgent: () => ctx.get?.("agents")?.currentInitiator?.(),
@@ -17109,8 +17357,11 @@ function apply(ctx, config = {}) {
17109
17357
  composerPredictions: settings.get().composerPredictions === "on" ? "on" : "off",
17110
17358
  otherModels: settings.get().otherModels === "off" ? "off" : "on",
17111
17359
  subagentBackend: settings.get().subagentBackend ?? "dsh",
17360
+ subagentDefaultModel: normalizeSubagentModel(settings.get().subagentDefaultModel),
17361
+ subagentDefaultEffort: normalizeSubagentEffort(settings.get().subagentDefaultEffort),
17362
+ subagentModels: subagentDefaults.list(),
17112
17363
  subagentBackendAvailable: subagentBackend !== void 0,
17113
- subagentRuntimeInstalled: inspectSubagentRuntime().installed,
17364
+ subagentRuntimeInstalled: inspectSubagentRuntime(void 0, subagentCli).installed,
17114
17365
  ...readCapabilitySettings(settings.get()),
17115
17366
  [QUICK_QUOTA_MODE_FIELD]: normalizeQuickQuotaMode(settings.get()[QUICK_QUOTA_MODE_FIELD], settings.get()[LEGACY_QUICK_QUOTA_FIELD]),
17116
17367
  [SEARCH_PROVIDER_FIELD]: settings.get()[SEARCH_PROVIDER_FIELD],
@@ -17143,10 +17394,12 @@ function apply(ctx, config = {}) {
17143
17394
  };
17144
17395
  },
17145
17396
  update: async (patch) => {
17397
+ if (patch.subagentDefaultModel && !subagentDefaults.list().some((model) => model.id === patch.subagentDefaultModel)) throw new Error("Codex subtask model is unavailable or disallowed");
17146
17398
  if (patch["fetchProvider"] === "codex" && !fetchRouted) throw new Error("This DSH version does not support Codex webpage reading");
17147
17399
  if (Object.hasOwn(patch, "subagentBackend")) {
17148
17400
  if (!subagentBackend) throw new Error("DSH subagent services are unavailable");
17149
17401
  await subagentBackend.select(patch.subagentBackend);
17402
+ if (patch.subagentBackend === "codex") await subagentCatalog.refresh().catch(() => {});
17150
17403
  }
17151
17404
  const rest = { ...patch };
17152
17405
  delete rest.subagentBackend;
@@ -17207,8 +17460,9 @@ function apply(ctx, config = {}) {
17207
17460
  resolveAuth,
17208
17461
  store,
17209
17462
  refresh: (credential) => network.run("oauth", () => baseProvider.auth.oauth.refresh(credential)),
17210
- loadRuntime: loadSubagentRuntime,
17211
- maintenance: runtimeManagement.blocked
17463
+ loadRuntime: () => loadSubagentRuntime({ cli: subagentCli }),
17464
+ maintenance: runtimeManagement.blocked,
17465
+ defaults: subagentDefaults
17212
17466
  });
17213
17467
  scoped.subagents.registerProvider(instance.provider);
17214
17468
  const switcher = createSubagentBackendSwitcher({
@@ -17218,10 +17472,10 @@ function apply(ctx, config = {}) {
17218
17472
  });
17219
17473
  const unconfigure = scoped.on("internal/config", subagentConfigListener(switcher), { global: true });
17220
17474
  let requested = "dsh";
17221
- const select = async (mode) => {
17475
+ const select = async (mode, options) => {
17222
17476
  requested = mode;
17223
17477
  try {
17224
- await switcher.select(mode);
17478
+ await switcher.select(mode, options);
17225
17479
  } catch (error) {
17226
17480
  requested = settings.get().subagentBackend ?? "dsh";
17227
17481
  throw error;
@@ -17233,7 +17487,7 @@ function apply(ctx, config = {}) {
17233
17487
  };
17234
17488
  const sync = (value) => {
17235
17489
  const mode = value.subagentBackend ?? "dsh";
17236
- if (mode !== requested) select(mode).catch(() => scoped.logger.warn("Could not switch the subscription subagent backend"));
17490
+ if (mode !== requested) select(mode, { validate: false }).catch(() => scoped.logger.warn("Could not switch the subscription subagent backend"));
17237
17491
  };
17238
17492
  scoped.loader.await().then(() => sync(settings.get())).catch(() => scoped.logger.warn("Could not initialize the subscription subagent backend"));
17239
17493
  const unwatch = settings.watch(sync);
@@ -17753,6 +18007,7 @@ function apply(ctx, config = {}) {
17753
18007
  voicePreview,
17754
18008
  composerPredictions,
17755
18009
  onAccountChanged: () => {
18010
+ subagentCatalog.clear();
17756
18011
  connectorsClient.clear();
17757
18012
  usageProfileReader.clear();
17758
18013
  voicePreview.clear();
@@ -17775,6 +18030,7 @@ function apply(ctx, config = {}) {
17775
18030
  }),
17776
18031
  onCleanupFailure: () => diagnosticOperations.record("account/cleanup", "failed"),
17777
18032
  modelCatalog,
18033
+ subagentCatalog,
17778
18034
  closeConnections: () => connection.dispose(),
17779
18035
  originalImages,
17780
18036
  resolveInheritedOriginal: (sessionId, assetId) => inheritedOriginalImageRef(ctx.get?.("sessions")?.get?.(sessionId), assetId)