dsh-github-copilot 0.4.0-alpha.58 → 0.4.0-alpha.60

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
@@ -1,4 +1,4 @@
1
- import { A as GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID, C as currentSearchInitiator, D as isPluginPreviewProvider, E as readSettingsNamespace, F as autoModelPreference, M as GITHUB_COPILOT_CREDENTIAL_KEY, N as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, O as readCopilotCatalog, P as GITHUB_COPILOT_PROVIDER_ID, S as currentChatRoute, T as onSettingsNamespaceUpdated, _ as RESPONSES_WEB_SEARCH_TOOL_TYPE, a as COPILOT_HOSTED_SEARCH_PROVIDER_ID, b as candidatesForRoute, c as abortable$1, d as readBounded, f as applyRequestAuth, h as ANTHROPIC_WEB_SEARCH_TOOL_TYPE, i as describeSearchBackend, j as GITHUB_COPILOT_AUTO_MODEL_ID, k as GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID, l as isAbortError, m as providerRequestHeaders, n as routeSessionSearch, o as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, p as normalizeRequestAuth, r as DescribedSearchFallbackError, s as createTraditionalSearchProvider, t as isCopilotSearchSelection, u as providerErrorMessage, v as SearchPlan, w as currentSearchSelection, x as sameCandidates, y as WEB_SEARCH_TOOL_TYPE } from "./search-routing-CncYAO8_.js";
1
+ import { A as GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID, C as currentSearchInitiator, D as readSettingsNamespace, E as readConfigValue, F as GITHUB_COPILOT_PROVIDER_ID, I as autoModelPreference, M as GITHUB_COPILOT_AUTO_MODEL_ID, N as GITHUB_COPILOT_CREDENTIAL_KEY, O as isPluginPreviewProvider, P as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, S as currentChatRoute, T as onSettingsNamespaceUpdated, _ as RESPONSES_WEB_SEARCH_TOOL_TYPE, a as COPILOT_HOSTED_SEARCH_PROVIDER_ID, b as candidatesForRoute, c as abortable$1, d as readBounded, f as applyRequestAuth, h as ANTHROPIC_WEB_SEARCH_TOOL_TYPE, i as describeSearchBackend, j as GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID, k as readCopilotCatalog, l as isAbortError, m as providerRequestHeaders, n as routeSessionSearch, o as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, p as normalizeRequestAuth, r as DescribedSearchFallbackError, s as createTraditionalSearchProvider, t as isCopilotSearchSelection, u as providerErrorMessage, v as SearchPlan, w as currentSearchSelection, x as sameCandidates, y as WEB_SEARCH_TOOL_TYPE } from "./search-routing-BhrTbF-V.js";
2
2
  import AuthorizationService from "@deepseek-ai/dsh-authorization";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as dshScope from "@deepseek-ai/dsh-scope";
@@ -13,7 +13,6 @@ import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
13
13
  import * as dshLlm from "@deepseek-ai/dsh-llm";
14
14
  import { CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, ReasoningEffortId, attributionHeaders, boundContextSummary, callConfigEquals, contentHasImage, createUserMessage, isAgentLoopRequest, resolveImageAttachmentAccess, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
15
15
  import { WebError } from "@deepseek-ai/dsh-web";
16
- import * as dshSettings from "@deepseek-ai/dsh-settings";
17
16
  import { credentialRef } from "@deepseek-ai/dsh-credentials";
18
17
  import { Config as Config$1, PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
19
18
  import { estimateContextTokens, estimateMessageTokens } from "@earendil-works/pi-ai/utils/estimate";
@@ -1647,7 +1646,7 @@ let GitHubCopilotUsageController = (() => {
1647
1646
  //#endregion
1648
1647
  //#region package.json
1649
1648
  var name$1 = "dsh-github-copilot";
1650
- var version = "0.4.0-alpha.58";
1649
+ var version = "0.4.0-alpha.60";
1651
1650
  //#endregion
1652
1651
  //#region lib/types/probe.js
1653
1652
  /**
@@ -2066,6 +2065,15 @@ const WebSearchRoutingConfigSchema = z.object({
2066
2065
  * configurable through the settings seam; defaults follow the chat route.
2067
2066
  * @module dsh-github-copilot/config
2068
2067
  */
2068
+ /** Keep native live references at the boundary; request code consumes plain snapshots. */
2069
+ function readInlineConfig(config) {
2070
+ return {
2071
+ ...config,
2072
+ searchModel: readConfigValue(config.searchModel),
2073
+ searchRouting: readConfigValue(config.searchRouting),
2074
+ temporaryRouteBackup: readConfigValue(config.temporaryRouteBackup)
2075
+ };
2076
+ }
2069
2077
  /** Longest timer either bound may take; `setTimeout`/`AbortSignal.timeout` refuse more. */
2070
2078
  const MAX_TIMEOUT_MS = 2147483647;
2071
2079
  /** Schema of the plugin's settings section. */
@@ -2079,14 +2087,15 @@ const Config = z.object({
2079
2087
  probeTimeoutMs: z.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e4),
2080
2088
  accountModelTtlMs: z.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(864e5),
2081
2089
  accountModelFailureCooldownMs: z.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(3e5),
2090
+ excludedModelIds: z.array(z.string()).default([]).hidden(),
2082
2091
  requestBudgetSafetyTokens: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens),
2083
2092
  requestBudgetPressureRatio: z.number().step(.01).min(.01).max(1).default(DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio),
2084
2093
  compactionReasoning: z.union(["prefer-low", "preserve"]).default(DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning),
2085
2094
  routeWebSearch: z.boolean().default(true),
2086
2095
  searchFallback: z.union(["none", "deepseek"]).default("deepseek"),
2087
- searchModel: z.string().hidden(),
2088
- searchRouting: WebSearchRoutingConfigSchema.default({}),
2089
- temporaryRouteBackup: z.string().hidden()
2096
+ searchModel: z.string().hidden().volatile(),
2097
+ searchRouting: WebSearchRoutingConfigSchema.default({}).volatile(),
2098
+ temporaryRouteBackup: z.string().hidden().volatile()
2090
2099
  });
2091
2100
  //#endregion
2092
2101
  //#region lib/types/search-tool-routing.js
@@ -3680,12 +3689,6 @@ async function* inlineStream(request, candidate, hooks, cfg) {
3680
3689
  }
3681
3690
  //#endregion
3682
3691
  //#region lib/types/deepseek-search-fallback.js
3683
- function isVolatileSetting(value) {
3684
- return typeof value === "object" && value !== null && typeof Reflect.get(value, "get") === "function";
3685
- }
3686
- function readConfigValue(value) {
3687
- return isVolatileSetting(value) ? value.get() : value;
3688
- }
3689
3692
  var InvalidFallbackBase = class extends WebError {
3690
3693
  constructor() {
3691
3694
  super("DeepSeek fallback requires an HTTP(S) API base URL without userinfo, query or fragment", "WEB_PROVIDER_UNAVAILABLE");
@@ -4233,6 +4236,20 @@ function migrationStatus(ctx) {
4233
4236
  result.complete.routes = result.routes.nativeConfigured !== null && result.routes.nativeRegistered !== null && result.routes.managedRegistered !== null;
4234
4237
  return result;
4235
4238
  }
4239
+ const MAX_MODEL_ID_LENGTH = 512;
4240
+ function normalizeExcludedModelIds(value) {
4241
+ if (value === void 0) return [];
4242
+ if (!Array.isArray(value) || value.length > 512) throw new Error("COPILOT_MODEL_EXCLUSIONS_INVALID");
4243
+ const ids = /* @__PURE__ */ new Set();
4244
+ for (const candidate of value) {
4245
+ if (typeof candidate !== "string" || candidate.length === 0 || candidate.length > MAX_MODEL_ID_LENGTH || candidate.trim() !== candidate || autoModelPreference(candidate) !== void 0) throw new Error("COPILOT_MODEL_EXCLUSIONS_INVALID");
4246
+ ids.add(candidate);
4247
+ }
4248
+ return [...ids].toSorted();
4249
+ }
4250
+ function excludedModelSet(value) {
4251
+ return new Set(normalizeExcludedModelIds(value));
4252
+ }
4236
4253
  //#endregion
4237
4254
  //#region lib/types/authorization-controller.js
4238
4255
  /**
@@ -4358,6 +4375,77 @@ function accountModelsView(ctx) {
4358
4375
  return empty;
4359
4376
  }
4360
4377
  }
4378
+ function modelSelection(value) {
4379
+ const selection = object$3(value);
4380
+ const provider = selection?.provider;
4381
+ const model = selection?.model;
4382
+ return typeof provider === "string" && provider.length > 0 && typeof model === "string" && model.length > 0 ? {
4383
+ provider,
4384
+ model
4385
+ } : void 0;
4386
+ }
4387
+ function fixedPreviewModel(value) {
4388
+ const selection = modelSelection(value);
4389
+ return selection?.provider === "github-copilot-preview" && autoModelPreference(selection.model) === void 0 ? selection.model : void 0;
4390
+ }
4391
+ function selectedFixedModelIds(ctx) {
4392
+ try {
4393
+ const defaults = service(ctx, "agentDefaultModel", ["currentSelection"]);
4394
+ const agents = service(ctx, "agents", ["list"]);
4395
+ const projections = service(ctx, "sessionProjections", ["stateOf"]);
4396
+ const locked = /* @__PURE__ */ new Set();
4397
+ const currentSelection = Reflect.get(defaults, "currentSelection");
4398
+ const defaultValue = typeof currentSelection === "function" ? Reflect.apply(currentSelection, defaults, []) : void 0;
4399
+ if (defaultValue !== null && defaultValue !== void 0 && modelSelection(defaultValue) === void 0) return void 0;
4400
+ const defaultSelection = fixedPreviewModel(defaultValue);
4401
+ if (defaultSelection !== void 0) locked.add(defaultSelection);
4402
+ const list = Reflect.get(agents, "list");
4403
+ const rows = typeof list === "function" ? Reflect.apply(list, agents, []) : void 0;
4404
+ if (!Array.isArray(rows) || rows.length > 1024) return void 0;
4405
+ const stateOf = Reflect.get(projections, "stateOf");
4406
+ if (typeof stateOf !== "function") return void 0;
4407
+ for (const candidate of rows) {
4408
+ const session = object$3(object$3(candidate)?.session);
4409
+ if (session === void 0) return void 0;
4410
+ const state = object$3(Reflect.apply(stateOf, projections, [session, "modelSelection"]));
4411
+ if (state === void 0 || !("pending" in state)) return void 0;
4412
+ const pending = state.pending;
4413
+ if (pending !== null && modelSelection(pending) === void 0) return void 0;
4414
+ let selected = pending === null ? void 0 : fixedPreviewModel(pending);
4415
+ if (pending === null) {
4416
+ const requestHeader = session.requestHeader;
4417
+ const header = typeof requestHeader === "function" ? object$3(Reflect.apply(requestHeader, session, [])) : void 0;
4418
+ if (header?.config !== void 0 && modelSelection(header.config) === void 0) return void 0;
4419
+ selected = fixedPreviewModel(header?.config);
4420
+ }
4421
+ if (selected !== void 0) locked.add(selected);
4422
+ }
4423
+ return [...locked].toSorted();
4424
+ } catch {
4425
+ return;
4426
+ }
4427
+ }
4428
+ function modelPreferencesView(ctx, accountModels, error) {
4429
+ try {
4430
+ const descriptor = service(ctx, "settings", ["describe", "mutate"]).describe({ redactSecrets: true }).find((item) => item.ns === GITHUB_COPILOT_SETTINGS_NAMESPACE$1);
4431
+ if (descriptor === void 0 || !Number.isSafeInteger(descriptor.revision) || descriptor.revision < 0) return void 0;
4432
+ const excludedModelIds = normalizeExcludedModelIds(object$3(descriptor.value)?.excludedModelIds);
4433
+ const lockedModelIds = selectedFixedModelIds(ctx);
4434
+ if (lockedModelIds === void 0) return void 0;
4435
+ const available = new Set(accountModels?.models.map((model) => model.id) ?? []);
4436
+ return {
4437
+ state: error === void 0 ? "ready" : "error",
4438
+ writable: true,
4439
+ revision: descriptor.revision,
4440
+ excludedModelIds,
4441
+ lockedModelIds,
4442
+ unavailableExcludedModelIds: excludedModelIds.filter((id) => !available.has(id)),
4443
+ ...error === void 0 ? {} : { error }
4444
+ };
4445
+ } catch {
4446
+ return;
4447
+ }
4448
+ }
4361
4449
  function validateGrant(record) {
4362
4450
  if (record.kind !== "grant") throw new Error("github-copilot: the configured credential is not an OAuth grant");
4363
4451
  normalizeGitHubCopilotOAuthCredential(record.payload);
@@ -4512,6 +4600,8 @@ let GitHubCopilotAuthorizationController = (() => {
4512
4600
  let _instanceExtraInitializers = [];
4513
4601
  let _migrationStatus_decorators;
4514
4602
  let _status_decorators;
4603
+ let _excludeModel_decorators;
4604
+ let _restoreModel_decorators;
4515
4605
  let _discoverModels_decorators;
4516
4606
  let _ensureModels_decorators;
4517
4607
  let _reconcile_decorators;
@@ -4523,6 +4613,8 @@ let GitHubCopilotAuthorizationController = (() => {
4523
4613
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
4524
4614
  _migrationStatus_decorators = [Remote];
4525
4615
  _status_decorators = [Remote];
4616
+ _excludeModel_decorators = [Remote];
4617
+ _restoreModel_decorators = [Remote];
4526
4618
  _discoverModels_decorators = [Remote];
4527
4619
  _ensureModels_decorators = [Remote];
4528
4620
  _reconcile_decorators = [Remote];
@@ -4551,6 +4643,28 @@ let GitHubCopilotAuthorizationController = (() => {
4551
4643
  },
4552
4644
  metadata: _metadata
4553
4645
  }, null, _instanceExtraInitializers);
4646
+ __esDecorate(this, null, _excludeModel_decorators, {
4647
+ kind: "method",
4648
+ name: "excludeModel",
4649
+ static: false,
4650
+ private: false,
4651
+ access: {
4652
+ has: (obj) => "excludeModel" in obj,
4653
+ get: (obj) => obj.excludeModel
4654
+ },
4655
+ metadata: _metadata
4656
+ }, null, _instanceExtraInitializers);
4657
+ __esDecorate(this, null, _restoreModel_decorators, {
4658
+ kind: "method",
4659
+ name: "restoreModel",
4660
+ static: false,
4661
+ private: false,
4662
+ access: {
4663
+ has: (obj) => "restoreModel" in obj,
4664
+ get: (obj) => obj.restoreModel
4665
+ },
4666
+ metadata: _metadata
4667
+ }, null, _instanceExtraInitializers);
4554
4668
  __esDecorate(this, null, _discoverModels_decorators, {
4555
4669
  kind: "method",
4556
4670
  name: "discoverModels",
@@ -4629,6 +4743,7 @@ let GitHubCopilotAuthorizationController = (() => {
4629
4743
  reconciliationFailed = false;
4630
4744
  attempt;
4631
4745
  authorizationMilestone;
4746
+ modelPreferenceFailure;
4632
4747
  constructor(ctx) {
4633
4748
  super(ctx, "githubCopilotAuthorization", { namespace: "githubCopilot" });
4634
4749
  }
@@ -4662,6 +4777,7 @@ let GitHubCopilotAuthorizationController = (() => {
4662
4777
  }
4663
4778
  const inFlight = authorization.describe("llm-pi-ai/github-copilot")?.inFlight === true || this.attempt !== void 0;
4664
4779
  const discovered = accountModelsView(this.ctx);
4780
+ const modelPreferences = modelPreferencesView(this.ctx, discovered, this.modelPreferenceFailure);
4665
4781
  return {
4666
4782
  phase: inFlight ? "authorizing" : this.failure !== void 0 ? "error" : record.configured ? "signed-in" : "signed-out",
4667
4783
  configured: record.configured,
@@ -4671,10 +4787,17 @@ let GitHubCopilotAuthorizationController = (() => {
4671
4787
  route,
4672
4788
  ...catalog === void 0 ? {} : { catalog },
4673
4789
  ...discovered === void 0 ? {} : { accountModels: discovered },
4790
+ ...modelPreferences === void 0 ? {} : { modelPreferences },
4674
4791
  ...this.failure === void 0 ? {} : { error: this.failure },
4675
4792
  ...this.authorizationMilestone === void 0 ? {} : { authorizationMilestone: this.authorizationMilestone }
4676
4793
  };
4677
4794
  }
4795
+ async excludeModel(modelId) {
4796
+ return this.updateModelExclusion(modelId, true);
4797
+ }
4798
+ async restoreModel(modelId) {
4799
+ return this.updateModelExclusion(modelId, false);
4800
+ }
4678
4801
  /** Explicit model discovery: may refresh OAuth and GET the account catalog, never changes selection. */
4679
4802
  async discoverModels() {
4680
4803
  return this.loadAccountModels(true);
@@ -4800,6 +4923,44 @@ let GitHubCopilotAuthorizationController = (() => {
4800
4923
  this.authorizationMilestone = void 0;
4801
4924
  return this.status();
4802
4925
  }
4926
+ async updateModelExclusion(modelId, exclude) {
4927
+ let normalized;
4928
+ try {
4929
+ [normalized] = normalizeExcludedModelIds([modelId]);
4930
+ } catch {
4931
+ this.modelPreferenceFailure = "COPILOT_MODEL_EXCLUSION_SAVE_FAILED";
4932
+ return this.status();
4933
+ }
4934
+ const current = modelPreferencesView(this.ctx, accountModelsView(this.ctx));
4935
+ if (current === void 0 || current.revision === void 0) {
4936
+ this.modelPreferenceFailure = "COPILOT_MODEL_PREFERENCES_UNAVAILABLE";
4937
+ return this.status();
4938
+ }
4939
+ if (exclude && current.lockedModelIds.includes(normalized)) {
4940
+ this.modelPreferenceFailure = "COPILOT_MODEL_EXCLUSION_SELECTED";
4941
+ return this.status();
4942
+ }
4943
+ const ids = new Set(current.excludedModelIds);
4944
+ if (exclude) ids.add(normalized);
4945
+ else ids.delete(normalized);
4946
+ const next = normalizeExcludedModelIds([...ids]);
4947
+ if (next.length === current.excludedModelIds.length && next.every((id, index) => id === current.excludedModelIds[index])) {
4948
+ this.modelPreferenceFailure = void 0;
4949
+ return this.status();
4950
+ }
4951
+ try {
4952
+ await service(this.ctx, "settings", ["describe", "mutate"]).mutate(GITHUB_COPILOT_SETTINGS_NAMESPACE$1, [{
4953
+ op: "set",
4954
+ path: ["excludedModelIds"],
4955
+ value: next
4956
+ }], current.revision);
4957
+ this.modelPreferenceFailure = void 0;
4958
+ } catch (cause) {
4959
+ const record = object$3(cause);
4960
+ this.modelPreferenceFailure = record?.code === "SETTINGS_CONFLICT" || cause instanceof Error && /conflict/i.test(cause.message) ? "COPILOT_MODEL_EXCLUSION_CONFLICT" : "COPILOT_MODEL_EXCLUSION_SAVE_FAILED";
4961
+ }
4962
+ return this.status();
4963
+ }
4803
4964
  async ensureProviderProfile() {
4804
4965
  try {
4805
4966
  await ensureGitHubCopilotProviderProfile(this.ctx);
@@ -6650,15 +6811,17 @@ var PreviewLifetime = class {
6650
6811
  source;
6651
6812
  proofFor;
6652
6813
  displayProofFor;
6814
+ excluded;
6653
6815
  controller = new AbortController();
6654
6816
  wires = /* @__PURE__ */ new Set();
6655
6817
  revision = 0;
6656
6818
  active = true;
6657
- constructor(credentials, source, proofFor, displayProofFor) {
6819
+ constructor(credentials, source, proofFor, displayProofFor, excluded) {
6658
6820
  this.credentials = credentials;
6659
6821
  this.source = source;
6660
6822
  this.proofFor = proofFor;
6661
6823
  this.displayProofFor = displayProofFor;
6824
+ this.excluded = excluded;
6662
6825
  }
6663
6826
  assertActive() {
6664
6827
  if (!this.active) throw failure("COPILOT_PREVIEW_DISPOSED", "ABORTED");
@@ -6723,6 +6886,7 @@ var PreviewLifetime = class {
6723
6886
  const combined = signal === void 0 ? this.controller.signal : AbortSignal.any([signal, this.controller.signal]);
6724
6887
  const grant = await this.read(combined);
6725
6888
  if (grant === void 0) throw failure("COPILOT_PREVIEW_OAUTH_REQUIRED");
6889
+ if (this.excluded(model)) throw failure("COPILOT_PREVIEW_MODEL_EXCLUDED", "INVALID_REQUEST");
6726
6890
  const descriptor = snapshot.models.find((item) => item.id === model);
6727
6891
  if (descriptor === void 0) throw failure("COPILOT_PREVIEW_MODEL_NOT_ENTITLED", "UNKNOWN_MODEL");
6728
6892
  const proof = this.proofFor(snapshot);
@@ -6744,6 +6908,7 @@ var PreviewLifetime = class {
6744
6908
  }
6745
6909
  entitled(lease, grant, model) {
6746
6910
  this.account(lease, grant);
6911
+ if (this.excluded(model)) throw failure("COPILOT_PREVIEW_MODEL_EXCLUDED", "INVALID_REQUEST");
6747
6912
  if (lease.descriptor.id !== model) throw failure("COPILOT_PREVIEW_MODEL_MISMATCH", "UNKNOWN_MODEL");
6748
6913
  if (this.source.readSnapshot() !== lease.snapshot || this.proofFor(lease.snapshot) !== lease.proof) throw failure("COPILOT_PREVIEW_METADATA_STALE");
6749
6914
  if (tokenFingerprint(grant.access) !== lease.proof.tokenFingerprint || copilotEntitlementKey(grant) !== lease.proof.entitlementKey || grant.expires <= Date.now()) {
@@ -6840,13 +7005,15 @@ var PreviewAdapter = class extends PiAiAdapter {
6840
7005
  discoverSnapshot;
6841
7006
  refreshRejected;
6842
7007
  requestBudgetSettings;
6843
- constructor(lifetime, optionsFor, discoverSnapshot, refreshRejected, requestBudgetSettings) {
7008
+ accountModelSettings;
7009
+ constructor(lifetime, optionsFor, discoverSnapshot, refreshRejected, requestBudgetSettings, accountModelSettings) {
6844
7010
  super(optionsFor());
6845
7011
  this.lifetime = lifetime;
6846
7012
  this.optionsFor = optionsFor;
6847
7013
  this.discoverSnapshot = discoverSnapshot;
6848
7014
  this.refreshRejected = refreshRejected;
6849
7015
  this.requestBudgetSettings = requestBudgetSettings;
7016
+ this.accountModelSettings = accountModelSettings;
6850
7017
  }
6851
7018
  async listModels(provider) {
6852
7019
  owned(provider);
@@ -6856,7 +7023,8 @@ var PreviewAdapter = class extends PiAiAdapter {
6856
7023
  if (grant === void 0 || snapshot.accountKey !== copilotAccountKey(grant)) return [];
6857
7024
  const proof = this.lifetime.proofFor(snapshot);
6858
7025
  if (proof === void 0 || tokenFingerprint(grant.access) !== proof.tokenFingerprint || grant.expires <= Date.now()) return [];
6859
- const models = snapshot.models.filter((model) => autoModelPreference(model.id) === void 0 && model.input.includes("text"));
7026
+ const excluded = this.excludedModels();
7027
+ const models = snapshot.models.filter((model) => autoModelPreference(model.id) === void 0 && !excluded.has(model.id) && model.input.includes("text"));
6860
7028
  if (models.length === 0) return [];
6861
7029
  return [
6862
7030
  {
@@ -6893,7 +7061,8 @@ var PreviewAdapter = class extends PiAiAdapter {
6893
7061
  const cached = this.lifetime.source.readSnapshot();
6894
7062
  const snapshot = await this.discoverSnapshot({ signal });
6895
7063
  if (autoModelPreference(model) !== void 0) {
6896
- const models = snapshot.models.filter((candidate) => autoModelPreference(candidate.id) === void 0 && candidate.input.includes("text"));
7064
+ const excluded = this.excludedModels();
7065
+ const models = snapshot.models.filter((candidate) => autoModelPreference(candidate.id) === void 0 && !excluded.has(candidate.id) && candidate.input.includes("text"));
6897
7066
  if (models.length === 0) throw failure("COPILOT_AUTO_NO_ELIGIBLE_MODEL", "UNKNOWN_MODEL");
6898
7067
  return {
6899
7068
  provider,
@@ -7011,15 +7180,20 @@ var PreviewAdapter = class extends PiAiAdapter {
7011
7180
  }
7012
7181
  })();
7013
7182
  }
7183
+ excludedModels() {
7184
+ return excludedModelSet(this.accountModelSettings().excludedModelIds);
7185
+ }
7014
7186
  };
7015
7187
  /** Register one stable account route; attach/status remain network-free. */
7016
7188
  function apply$1(ctx, config = {}) {
7017
7189
  const { accountModelTtlMs, accountModelFailureCooldownMs, accountModelSettings, requestBudget, requestBudgetSettings, ...requestConfig } = config;
7018
7190
  const cacheSettings = accountModelSettings ?? (() => ({
7019
7191
  accountModelTtlMs,
7020
- accountModelFailureCooldownMs
7192
+ accountModelFailureCooldownMs,
7193
+ excludedModelIds: []
7021
7194
  }));
7022
7195
  const budgetSettings = requestBudgetSettings ?? (() => requestBudget ?? {});
7196
+ const excludedModels = () => excludedModelSet(cacheSettings().excludedModelIds);
7023
7197
  resolveRequestBudgetPolicy(budgetSettings());
7024
7198
  const store = createGitHubCopilotCredentialStore(ctx, GITHUB_COPILOT_PREVIEW_PROVIDER_ID);
7025
7199
  let rejectedAuth;
@@ -7080,7 +7254,7 @@ function apply$1(ctx, config = {}) {
7080
7254
  });
7081
7255
  const displayProofFor = (snapshot) => source.readDisplaySnapshot() === snapshot && provenSnapshot === snapshot && snapshotProof?.accountKey === snapshot.accountKey ? snapshotProof : void 0;
7082
7256
  const proofFor = (snapshot) => source.readSnapshot() === snapshot && snapshotProof !== void 0 && snapshotProof.expires > Date.now() ? displayProofFor(snapshot) : void 0;
7083
- const lifetime = new PreviewLifetime(store, source, proofFor, displayProofFor);
7257
+ const lifetime = new PreviewLifetime(store, source, proofFor, displayProofFor, (modelId) => excludedModels().has(modelId));
7084
7258
  const template = resolvedProfile(createAccountProvider([], lifetime.guard(), "https://api.individual.githubcopilot.com").provider, requestConfig);
7085
7259
  let configured = false;
7086
7260
  let readError;
@@ -7266,14 +7440,25 @@ function apply$1(ctx, config = {}) {
7266
7440
  };
7267
7441
  const removeAutoRoute = installAutoModelRouting(ctx, {
7268
7442
  async loadModels(signal) {
7269
- return (await discoverSnapshot({ signal })).models;
7443
+ const excluded = excludedModels();
7444
+ return (await discoverSnapshot({ signal })).models.filter((model) => !excluded.has(model.id));
7270
7445
  },
7271
7446
  budgetPolicy: () => budgetSettings()
7272
7447
  });
7273
- const registration = ctx.llm.registerAdapter([GITHUB_COPILOT_PREVIEW_PROVIDER_ID], new PreviewAdapter(lifetime, optionsFor, discoverSnapshot, refreshRejected, budgetSettings));
7448
+ const registration = ctx.llm.registerAdapter([GITHUB_COPILOT_PREVIEW_PROVIDER_ID], new PreviewAdapter(lifetime, optionsFor, discoverSnapshot, refreshRejected, budgetSettings, cacheSettings));
7449
+ let exclusionSignature = JSON.stringify([...excludedModels()]);
7450
+ const removeSettings = onSettingsNamespaceUpdated(ctx, (namespace) => {
7451
+ if (namespace !== "github-copilot") return;
7452
+ const next = JSON.stringify([...excludedModels()]);
7453
+ if (next === exclusionSignature) return;
7454
+ exclusionSignature = next;
7455
+ publishedDirectory = "";
7456
+ registration.replace([GITHUB_COPILOT_PREVIEW_PROVIDER_ID]);
7457
+ });
7274
7458
  installCopilotCompactionPressure(ctx, { resolve(request) {
7275
7459
  const snapshot = source.readSnapshot();
7276
7460
  if (snapshot === void 0 || proofFor(snapshot) === void 0) return void 0;
7461
+ if (excludedModels().has(request.model)) return void 0;
7277
7462
  const descriptor = snapshot.models.find((model) => model.id === request.model);
7278
7463
  if (descriptor === void 0) return void 0;
7279
7464
  const result = calculateRequestBudget(descriptor, request.maxTokens, resolveRequestBudgetPolicy(budgetSettings()));
@@ -7300,6 +7485,7 @@ function apply$1(ctx, config = {}) {
7300
7485
  return () => lifetime.isCurrent(revision) && (expires === void 0 || expires > Date.now()) && (snapshotProof === captured || snapshotProof === void 0 || snapshotProof.expires > Date.now());
7301
7486
  },
7302
7487
  routeFacts(modelId) {
7488
+ if (excludedModels().has(modelId)) return void 0;
7303
7489
  const snapshot = source.readSnapshot();
7304
7490
  const proof = snapshot === void 0 ? void 0 : proofFor(snapshot);
7305
7491
  const descriptor = snapshot?.models.find((model) => model.id === modelId);
@@ -7344,6 +7530,7 @@ function apply$1(ctx, config = {}) {
7344
7530
  ctx.effect(() => () => {
7345
7531
  lifetime.dispose();
7346
7532
  removeListener();
7533
+ removeSettings();
7347
7534
  removeAutoRoute();
7348
7535
  registration();
7349
7536
  });
@@ -7387,31 +7574,21 @@ var ConfiguredSearchProofInvalidated = class extends WebError {
7387
7574
  super("configured Copilot search owner or account proof invalidated", "WEB_PROVIDER_UNAVAILABLE");
7388
7575
  }
7389
7576
  };
7390
- function installSettingsNamespace(ctx, namespace, schema, config, hooks) {
7391
- const legacyInstaller = dshSettings.installSettingsSection;
7392
- if (legacyInstaller !== void 0) {
7393
- legacyInstaller(ctx, namespace, schema, config, hooks);
7394
- return;
7395
- }
7396
- ctx.inject(["settings"], () => {
7577
+ function observeSettingsNamespace(ctx, namespace, config, hooks) {
7578
+ ctx.inject(["settings"], (scope) => {
7397
7579
  hooks.setSource(() => {
7398
- const value = readSettingsNamespace(ctx, namespace);
7399
- if (typeof value !== "object" || value === null) return config;
7400
- const merged = {
7401
- ...typeof config === "object" && config !== null ? config : {},
7580
+ const value = readSettingsNamespace(scope, namespace);
7581
+ const base = readInlineConfig(config);
7582
+ if (typeof value !== "object" || value === null) return base;
7583
+ return {
7584
+ ...base,
7402
7585
  ...value
7403
7586
  };
7404
- if (typeof schema === "function") try {
7405
- return schema(merged);
7406
- } catch {
7407
- return merged;
7408
- }
7409
- return merged;
7410
7587
  });
7411
- const dispose = onSettingsNamespaceUpdated(ctx, (changed) => {
7588
+ const dispose = onSettingsNamespaceUpdated(scope, (changed) => {
7412
7589
  if (changed === namespace || namespace === "github-copilot" && changed === "github-copilot-search-routing") hooks.onChange();
7413
7590
  });
7414
- ctx.effect(() => dispose);
7591
+ scope.effect(() => dispose);
7415
7592
  });
7416
7593
  }
7417
7594
  /**
@@ -7458,7 +7635,7 @@ function ensureAuthorization(ctx) {
7458
7635
  /** Activate the integration only after the complete DSH service contract is available. */
7459
7636
  function activate(ctx, config) {
7460
7637
  assertDshCompatibility(ctx);
7461
- let current = () => config;
7638
+ let current = () => readInlineConfig(config);
7462
7639
  const readRouting = () => {
7463
7640
  const rawRouting = readSettingsNamespace(ctx, GITHUB_COPILOT_SETTINGS_NAMESPACE)?.searchRouting;
7464
7641
  if (rawRouting && (rawRouting.searchProvider !== void 0 || rawRouting.defaultSearchProvider !== void 0 || rawRouting.searchMode !== void 0)) return rawRouting;
@@ -7852,7 +8029,7 @@ function activate(ctx, config) {
7852
8029
  canContinue
7853
8030
  })).result;
7854
8031
  } });
7855
- installSettingsNamespace(ctx, GITHUB_COPILOT_SETTINGS_NAMESPACE, Config, config, {
8032
+ observeSettingsNamespace(ctx, GITHUB_COPILOT_SETTINGS_NAMESPACE, config, {
7856
8033
  setSource: (source) => {
7857
8034
  current = source;
7858
8035
  },
package/lib/remote.js CHANGED
@@ -305,6 +305,20 @@ const GitHubCopilotAuthorizationViewSchema = z.object({
305
305
  discoveredAt: z.number().int().nonnegative().optional(),
306
306
  error: z.string().optional()
307
307
  }).strict().optional(),
308
+ modelPreferences: z.object({
309
+ state: z.enum(["ready", "error"]),
310
+ writable: z.boolean(),
311
+ revision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional(),
312
+ excludedModelIds: z.array(z.string().min(1).max(512)).max(512),
313
+ lockedModelIds: z.array(z.string().min(1).max(512)).max(512),
314
+ unavailableExcludedModelIds: z.array(z.string().min(1).max(512)).max(512),
315
+ error: z.enum([
316
+ "COPILOT_MODEL_PREFERENCES_UNAVAILABLE",
317
+ "COPILOT_MODEL_EXCLUSION_SELECTED",
318
+ "COPILOT_MODEL_EXCLUSION_CONFLICT",
319
+ "COPILOT_MODEL_EXCLUSION_SAVE_FAILED"
320
+ ]).optional()
321
+ }).strict().optional(),
308
322
  route: z.object({
309
323
  state: z.enum([
310
324
  "ready",
@@ -393,6 +407,20 @@ const contribution = {
393
407
  parameters: [],
394
408
  result
395
409
  })),
410
+ ...["excludeModel", "restoreModel"].map((method) => ({
411
+ id: `dsh-github-copilot:githubCopilot.${method}`,
412
+ service: "githubCopilotAuthorization",
413
+ namespace: "githubCopilot",
414
+ method,
415
+ invocation: direct,
416
+ parameters: [{
417
+ name: "modelId",
418
+ wire: "modelId",
419
+ source: "json",
420
+ codec: strictRemoteCodec("dsh-github-copilot#GitHubCopilotModelId", z.string().min(1).max(512))
421
+ }],
422
+ result
423
+ })),
396
424
  {
397
425
  id: "dsh-github-copilot:githubCopilot.migrationStatus",
398
426
  service: "githubCopilotAuthorization",
package/lib/routed-web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as currentSearchInitiator, D as isPluginPreviewProvider, t as isCopilotSearchSelection, w as currentSearchSelection } from "./search-routing-CncYAO8_.js";
1
+ import { C as currentSearchInitiator, O as isPluginPreviewProvider, t as isCopilotSearchSelection, w as currentSearchSelection } from "./search-routing-BhrTbF-V.js";
2
2
  import { WebError, WebRuntime } from "@deepseek-ai/dsh-web";
3
3
  //#region lib/types/routed-web.js
4
4
  /**
@@ -54,6 +54,13 @@ function isPluginPreviewProvider(ctx, provider) {
54
54
  }
55
55
  //#endregion
56
56
  //#region lib/types/settings-reader.js
57
+ function isLiveSetting(value) {
58
+ return typeof value === "object" && value !== null && typeof Reflect.get(value, "get") === "function";
59
+ }
60
+ /** Capture a native volatile field for one operation, or retain a plain fixture value. */
61
+ function readConfigValue(value) {
62
+ return isLiveSetting(value) ? value.get() : value;
63
+ }
57
64
  function isRecord(value) {
58
65
  return typeof value === "object" && value !== null;
59
66
  }
@@ -795,4 +802,4 @@ async function routeSessionSearch(request, signal, deps) {
795
802
  };
796
803
  }
797
804
  //#endregion
798
- export { GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID as A, currentSearchInitiator as C, isPluginPreviewProvider as D, readSettingsNamespace as E, autoModelPreference as F, GITHUB_COPILOT_CREDENTIAL_KEY$1 as M, GITHUB_COPILOT_PREVIEW_PROVIDER_ID as N, readCopilotCatalog as O, GITHUB_COPILOT_PROVIDER_ID as P, currentChatRoute as S, onSettingsNamespaceUpdated as T, RESPONSES_WEB_SEARCH_TOOL_TYPE as _, COPILOT_HOSTED_SEARCH_PROVIDER_ID as a, candidatesForRoute as b, abortable as c, readBounded as d, applyRequestAuth as f, GITHUB_COPILOT_CREDENTIAL_KEY as g, ANTHROPIC_WEB_SEARCH_TOOL_TYPE as h, describeSearchBackend as i, GITHUB_COPILOT_AUTO_MODEL_ID as j, GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID as k, isAbortError as l, providerRequestHeaders as m, routeSessionSearch as n, GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID as o, normalizeRequestAuth as p, DescribedSearchFallbackError as r, createTraditionalSearchProvider as s, isCopilotSearchSelection as t, providerErrorMessage as u, SearchPlan as v, currentSearchSelection as w, sameCandidates as x, WEB_SEARCH_TOOL_TYPE as y };
805
+ export { GITHUB_COPILOT_AUTO_EFFICIENCY_MODEL_ID as A, currentSearchInitiator as C, readSettingsNamespace as D, readConfigValue as E, GITHUB_COPILOT_PROVIDER_ID as F, autoModelPreference as I, GITHUB_COPILOT_AUTO_MODEL_ID as M, GITHUB_COPILOT_CREDENTIAL_KEY$1 as N, isPluginPreviewProvider as O, GITHUB_COPILOT_PREVIEW_PROVIDER_ID as P, currentChatRoute as S, onSettingsNamespaceUpdated as T, RESPONSES_WEB_SEARCH_TOOL_TYPE as _, COPILOT_HOSTED_SEARCH_PROVIDER_ID as a, candidatesForRoute as b, abortable as c, readBounded as d, applyRequestAuth as f, GITHUB_COPILOT_CREDENTIAL_KEY as g, ANTHROPIC_WEB_SEARCH_TOOL_TYPE as h, describeSearchBackend as i, GITHUB_COPILOT_AUTO_INTELLIGENCE_MODEL_ID as j, readCopilotCatalog as k, isAbortError as l, providerRequestHeaders as m, routeSessionSearch as n, GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID as o, normalizeRequestAuth as p, DescribedSearchFallbackError as r, createTraditionalSearchProvider as s, isCopilotSearchSelection as t, providerErrorMessage as u, SearchPlan as v, currentSearchSelection as w, sameCandidates as x, WEB_SEARCH_TOOL_TYPE as y };
@@ -51,6 +51,15 @@ export interface GitHubCopilotAccountModelsView {
51
51
  readonly discoveredAt?: number;
52
52
  readonly error?: string;
53
53
  }
54
+ export interface GitHubCopilotModelPreferencesView {
55
+ readonly state: 'ready' | 'error';
56
+ readonly writable: boolean;
57
+ readonly revision?: number;
58
+ readonly excludedModelIds: readonly string[];
59
+ readonly lockedModelIds: readonly string[];
60
+ readonly unavailableExcludedModelIds: readonly string[];
61
+ readonly error?: 'COPILOT_MODEL_PREFERENCES_UNAVAILABLE' | 'COPILOT_MODEL_EXCLUSION_SELECTED' | 'COPILOT_MODEL_EXCLUSION_CONFLICT' | 'COPILOT_MODEL_EXCLUSION_SAVE_FAILED';
62
+ }
54
63
  export interface GitHubCopilotAuthorizationView {
55
64
  readonly phase: GitHubCopilotAuthorizationPhase;
56
65
  readonly configured: boolean;
@@ -60,6 +69,7 @@ export interface GitHubCopilotAuthorizationView {
60
69
  readonly catalog?: GitHubCopilotModelCatalogView;
61
70
  readonly route?: GitHubCopilotRouteView;
62
71
  readonly accountModels?: GitHubCopilotAccountModelsView;
72
+ readonly modelPreferences?: GitHubCopilotModelPreferencesView;
63
73
  readonly error?: string;
64
74
  /** Latest fixed interaction milestone observed during a failed or active attempt; never a failure cause. */
65
75
  readonly authorizationMilestone?: GitHubCopilotAuthorizationMilestone;
@@ -84,10 +94,13 @@ export declare class GitHubCopilotAuthorizationController extends TypertRemoteSe
84
94
  private reconciliationFailed;
85
95
  private attempt;
86
96
  private authorizationMilestone;
97
+ private modelPreferenceFailure;
87
98
  constructor(ctx: Context);
88
99
  /** No-argument Ops evidence; deliberately independent of ordinary account status. */
89
100
  migrationStatus(): GitHubCopilotMigrationStatus;
90
101
  status(): Promise<GitHubCopilotAuthorizationView>;
102
+ excludeModel(modelId: string): Promise<GitHubCopilotAuthorizationView>;
103
+ restoreModel(modelId: string): Promise<GitHubCopilotAuthorizationView>;
91
104
  /** Explicit model discovery: may refresh OAuth and GET the account catalog, never changes selection. */
92
105
  discoverModels(): Promise<GitHubCopilotAuthorizationView>;
93
106
  /** Ensure metadata for a visible account view, honoring shared cache and failure cooldown. */
@@ -98,6 +111,7 @@ export declare class GitHubCopilotAuthorizationController extends TypertRemoteSe
98
111
  start(): Promise<GitHubCopilotAuthorizationView>;
99
112
  cancel(): Promise<GitHubCopilotAuthorizationView>;
100
113
  signOut(): Promise<GitHubCopilotAuthorizationView>;
114
+ private updateModelExclusion;
101
115
  private ensureProviderProfile;
102
116
  }
103
117
  export default GitHubCopilotAuthorizationController;
@@ -9,6 +9,7 @@ import type { GitHubCopilotAuthorizationView } from './authorization-controller.
9
9
  import type { ProviderCardExtrasOwnerProps, SettingsSectionOwnerProps } from './dsh-supported-types.ts';
10
10
  export { HostedSearchSettingsCard, WebSearchRoutingCard } from './web-search-routing-card.ts';
11
11
  export { CopilotUsageCard } from './copilot-usage-card.ts';
12
+ export { GitHubCopilotModelPreferencesPanel } from './model-preferences-card.ts';
12
13
  export declare const inject: string[];
13
14
  interface GitHubCopilotProviderCardProps extends ProviderCardExtrasOwnerProps {
14
15
  readonly remote: ClientContext['remote']['githubCopilot'];
@@ -7,6 +7,7 @@
7
7
  import z from '@deepseek-ai/schemastery';
8
8
  import type { RequestBudgetPolicy } from './request-budget.ts';
9
9
  import type { WebSearchRoutingConfig } from './web-search-routing-config.ts';
10
+ import type { LiveSetting } from './settings-reader.ts';
10
11
  /** Plugin configuration. Defaults make the current chat route decide. */
11
12
  export interface InlineConfig {
12
13
  /** Master switch; false sends every request down the normal adapter path. */
@@ -30,6 +31,8 @@ export interface InlineConfig {
30
31
  accountModelTtlMs?: number;
31
32
  /** Minimum delay after failed passive discovery; explicit Refresh bypasses it. */
32
33
  accountModelFailureCooldownMs?: number;
34
+ /** Exact account model IDs hidden from the managed directory and every Auto candidate pool. */
35
+ excludedModelIds?: string[];
33
36
  /** Estimated managed-route input headroom, separate from truthful catalog capacities. */
34
37
  requestBudgetSafetyTokens?: number;
35
38
  /** Fraction of admissible input used by eligible automatic-compaction requests. */
@@ -47,6 +50,18 @@ export interface InlineConfig {
47
50
  /** Internal JSON backup of route leaves temporarily owned by the GPT-6 overlay. */
48
51
  temporaryRouteBackup?: string;
49
52
  }
53
+ export type LiveInlineConfig = Omit<InlineConfig, 'searchModel' | 'searchRouting' | 'temporaryRouteBackup'> & {
54
+ searchModel?: string | LiveSetting<string | undefined>;
55
+ searchRouting?: WebSearchRoutingConfig | LiveSetting<WebSearchRoutingConfig | undefined>;
56
+ temporaryRouteBackup?: string | LiveSetting<string | undefined>;
57
+ };
58
+ export type ResolvedInlineConfig = Omit<InlineConfig, 'searchModel' | 'searchRouting' | 'temporaryRouteBackup'> & {
59
+ searchModel: LiveSetting<string | undefined>;
60
+ searchRouting: LiveSetting<WebSearchRoutingConfig>;
61
+ temporaryRouteBackup: LiveSetting<string | undefined>;
62
+ };
63
+ /** Keep native live references at the boundary; request code consumes plain snapshots. */
64
+ export declare function readInlineConfig(config: LiveInlineConfig): InlineConfig;
50
65
  /** Schema of the plugin's settings section. */
51
- export declare const Config: z<InlineConfig>;
66
+ export declare const Config: z<Partial<InlineConfig>, ResolvedInlineConfig>;
52
67
  //# sourceMappingURL=config.d.ts.map