dsh-github-copilot 0.4.0-alpha.59 → 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
@@ -1646,7 +1646,7 @@ let GitHubCopilotUsageController = (() => {
1646
1646
  //#endregion
1647
1647
  //#region package.json
1648
1648
  var name$1 = "dsh-github-copilot";
1649
- var version = "0.4.0-alpha.59";
1649
+ var version = "0.4.0-alpha.60";
1650
1650
  //#endregion
1651
1651
  //#region lib/types/probe.js
1652
1652
  /**
@@ -2087,6 +2087,7 @@ const Config = z.object({
2087
2087
  probeTimeoutMs: z.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e4),
2088
2088
  accountModelTtlMs: z.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(864e5),
2089
2089
  accountModelFailureCooldownMs: z.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(3e5),
2090
+ excludedModelIds: z.array(z.string()).default([]).hidden(),
2090
2091
  requestBudgetSafetyTokens: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens),
2091
2092
  requestBudgetPressureRatio: z.number().step(.01).min(.01).max(1).default(DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio),
2092
2093
  compactionReasoning: z.union(["prefer-low", "preserve"]).default(DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning),
@@ -4235,6 +4236,20 @@ function migrationStatus(ctx) {
4235
4236
  result.complete.routes = result.routes.nativeConfigured !== null && result.routes.nativeRegistered !== null && result.routes.managedRegistered !== null;
4236
4237
  return result;
4237
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
+ }
4238
4253
  //#endregion
4239
4254
  //#region lib/types/authorization-controller.js
4240
4255
  /**
@@ -4360,6 +4375,77 @@ function accountModelsView(ctx) {
4360
4375
  return empty;
4361
4376
  }
4362
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
+ }
4363
4449
  function validateGrant(record) {
4364
4450
  if (record.kind !== "grant") throw new Error("github-copilot: the configured credential is not an OAuth grant");
4365
4451
  normalizeGitHubCopilotOAuthCredential(record.payload);
@@ -4514,6 +4600,8 @@ let GitHubCopilotAuthorizationController = (() => {
4514
4600
  let _instanceExtraInitializers = [];
4515
4601
  let _migrationStatus_decorators;
4516
4602
  let _status_decorators;
4603
+ let _excludeModel_decorators;
4604
+ let _restoreModel_decorators;
4517
4605
  let _discoverModels_decorators;
4518
4606
  let _ensureModels_decorators;
4519
4607
  let _reconcile_decorators;
@@ -4525,6 +4613,8 @@ let GitHubCopilotAuthorizationController = (() => {
4525
4613
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
4526
4614
  _migrationStatus_decorators = [Remote];
4527
4615
  _status_decorators = [Remote];
4616
+ _excludeModel_decorators = [Remote];
4617
+ _restoreModel_decorators = [Remote];
4528
4618
  _discoverModels_decorators = [Remote];
4529
4619
  _ensureModels_decorators = [Remote];
4530
4620
  _reconcile_decorators = [Remote];
@@ -4553,6 +4643,28 @@ let GitHubCopilotAuthorizationController = (() => {
4553
4643
  },
4554
4644
  metadata: _metadata
4555
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);
4556
4668
  __esDecorate(this, null, _discoverModels_decorators, {
4557
4669
  kind: "method",
4558
4670
  name: "discoverModels",
@@ -4631,6 +4743,7 @@ let GitHubCopilotAuthorizationController = (() => {
4631
4743
  reconciliationFailed = false;
4632
4744
  attempt;
4633
4745
  authorizationMilestone;
4746
+ modelPreferenceFailure;
4634
4747
  constructor(ctx) {
4635
4748
  super(ctx, "githubCopilotAuthorization", { namespace: "githubCopilot" });
4636
4749
  }
@@ -4664,6 +4777,7 @@ let GitHubCopilotAuthorizationController = (() => {
4664
4777
  }
4665
4778
  const inFlight = authorization.describe("llm-pi-ai/github-copilot")?.inFlight === true || this.attempt !== void 0;
4666
4779
  const discovered = accountModelsView(this.ctx);
4780
+ const modelPreferences = modelPreferencesView(this.ctx, discovered, this.modelPreferenceFailure);
4667
4781
  return {
4668
4782
  phase: inFlight ? "authorizing" : this.failure !== void 0 ? "error" : record.configured ? "signed-in" : "signed-out",
4669
4783
  configured: record.configured,
@@ -4673,10 +4787,17 @@ let GitHubCopilotAuthorizationController = (() => {
4673
4787
  route,
4674
4788
  ...catalog === void 0 ? {} : { catalog },
4675
4789
  ...discovered === void 0 ? {} : { accountModels: discovered },
4790
+ ...modelPreferences === void 0 ? {} : { modelPreferences },
4676
4791
  ...this.failure === void 0 ? {} : { error: this.failure },
4677
4792
  ...this.authorizationMilestone === void 0 ? {} : { authorizationMilestone: this.authorizationMilestone }
4678
4793
  };
4679
4794
  }
4795
+ async excludeModel(modelId) {
4796
+ return this.updateModelExclusion(modelId, true);
4797
+ }
4798
+ async restoreModel(modelId) {
4799
+ return this.updateModelExclusion(modelId, false);
4800
+ }
4680
4801
  /** Explicit model discovery: may refresh OAuth and GET the account catalog, never changes selection. */
4681
4802
  async discoverModels() {
4682
4803
  return this.loadAccountModels(true);
@@ -4802,6 +4923,44 @@ let GitHubCopilotAuthorizationController = (() => {
4802
4923
  this.authorizationMilestone = void 0;
4803
4924
  return this.status();
4804
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
+ }
4805
4964
  async ensureProviderProfile() {
4806
4965
  try {
4807
4966
  await ensureGitHubCopilotProviderProfile(this.ctx);
@@ -6652,15 +6811,17 @@ var PreviewLifetime = class {
6652
6811
  source;
6653
6812
  proofFor;
6654
6813
  displayProofFor;
6814
+ excluded;
6655
6815
  controller = new AbortController();
6656
6816
  wires = /* @__PURE__ */ new Set();
6657
6817
  revision = 0;
6658
6818
  active = true;
6659
- constructor(credentials, source, proofFor, displayProofFor) {
6819
+ constructor(credentials, source, proofFor, displayProofFor, excluded) {
6660
6820
  this.credentials = credentials;
6661
6821
  this.source = source;
6662
6822
  this.proofFor = proofFor;
6663
6823
  this.displayProofFor = displayProofFor;
6824
+ this.excluded = excluded;
6664
6825
  }
6665
6826
  assertActive() {
6666
6827
  if (!this.active) throw failure("COPILOT_PREVIEW_DISPOSED", "ABORTED");
@@ -6725,6 +6886,7 @@ var PreviewLifetime = class {
6725
6886
  const combined = signal === void 0 ? this.controller.signal : AbortSignal.any([signal, this.controller.signal]);
6726
6887
  const grant = await this.read(combined);
6727
6888
  if (grant === void 0) throw failure("COPILOT_PREVIEW_OAUTH_REQUIRED");
6889
+ if (this.excluded(model)) throw failure("COPILOT_PREVIEW_MODEL_EXCLUDED", "INVALID_REQUEST");
6728
6890
  const descriptor = snapshot.models.find((item) => item.id === model);
6729
6891
  if (descriptor === void 0) throw failure("COPILOT_PREVIEW_MODEL_NOT_ENTITLED", "UNKNOWN_MODEL");
6730
6892
  const proof = this.proofFor(snapshot);
@@ -6746,6 +6908,7 @@ var PreviewLifetime = class {
6746
6908
  }
6747
6909
  entitled(lease, grant, model) {
6748
6910
  this.account(lease, grant);
6911
+ if (this.excluded(model)) throw failure("COPILOT_PREVIEW_MODEL_EXCLUDED", "INVALID_REQUEST");
6749
6912
  if (lease.descriptor.id !== model) throw failure("COPILOT_PREVIEW_MODEL_MISMATCH", "UNKNOWN_MODEL");
6750
6913
  if (this.source.readSnapshot() !== lease.snapshot || this.proofFor(lease.snapshot) !== lease.proof) throw failure("COPILOT_PREVIEW_METADATA_STALE");
6751
6914
  if (tokenFingerprint(grant.access) !== lease.proof.tokenFingerprint || copilotEntitlementKey(grant) !== lease.proof.entitlementKey || grant.expires <= Date.now()) {
@@ -6842,13 +7005,15 @@ var PreviewAdapter = class extends PiAiAdapter {
6842
7005
  discoverSnapshot;
6843
7006
  refreshRejected;
6844
7007
  requestBudgetSettings;
6845
- constructor(lifetime, optionsFor, discoverSnapshot, refreshRejected, requestBudgetSettings) {
7008
+ accountModelSettings;
7009
+ constructor(lifetime, optionsFor, discoverSnapshot, refreshRejected, requestBudgetSettings, accountModelSettings) {
6846
7010
  super(optionsFor());
6847
7011
  this.lifetime = lifetime;
6848
7012
  this.optionsFor = optionsFor;
6849
7013
  this.discoverSnapshot = discoverSnapshot;
6850
7014
  this.refreshRejected = refreshRejected;
6851
7015
  this.requestBudgetSettings = requestBudgetSettings;
7016
+ this.accountModelSettings = accountModelSettings;
6852
7017
  }
6853
7018
  async listModels(provider) {
6854
7019
  owned(provider);
@@ -6858,7 +7023,8 @@ var PreviewAdapter = class extends PiAiAdapter {
6858
7023
  if (grant === void 0 || snapshot.accountKey !== copilotAccountKey(grant)) return [];
6859
7024
  const proof = this.lifetime.proofFor(snapshot);
6860
7025
  if (proof === void 0 || tokenFingerprint(grant.access) !== proof.tokenFingerprint || grant.expires <= Date.now()) return [];
6861
- 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"));
6862
7028
  if (models.length === 0) return [];
6863
7029
  return [
6864
7030
  {
@@ -6895,7 +7061,8 @@ var PreviewAdapter = class extends PiAiAdapter {
6895
7061
  const cached = this.lifetime.source.readSnapshot();
6896
7062
  const snapshot = await this.discoverSnapshot({ signal });
6897
7063
  if (autoModelPreference(model) !== void 0) {
6898
- 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"));
6899
7066
  if (models.length === 0) throw failure("COPILOT_AUTO_NO_ELIGIBLE_MODEL", "UNKNOWN_MODEL");
6900
7067
  return {
6901
7068
  provider,
@@ -7013,15 +7180,20 @@ var PreviewAdapter = class extends PiAiAdapter {
7013
7180
  }
7014
7181
  })();
7015
7182
  }
7183
+ excludedModels() {
7184
+ return excludedModelSet(this.accountModelSettings().excludedModelIds);
7185
+ }
7016
7186
  };
7017
7187
  /** Register one stable account route; attach/status remain network-free. */
7018
7188
  function apply$1(ctx, config = {}) {
7019
7189
  const { accountModelTtlMs, accountModelFailureCooldownMs, accountModelSettings, requestBudget, requestBudgetSettings, ...requestConfig } = config;
7020
7190
  const cacheSettings = accountModelSettings ?? (() => ({
7021
7191
  accountModelTtlMs,
7022
- accountModelFailureCooldownMs
7192
+ accountModelFailureCooldownMs,
7193
+ excludedModelIds: []
7023
7194
  }));
7024
7195
  const budgetSettings = requestBudgetSettings ?? (() => requestBudget ?? {});
7196
+ const excludedModels = () => excludedModelSet(cacheSettings().excludedModelIds);
7025
7197
  resolveRequestBudgetPolicy(budgetSettings());
7026
7198
  const store = createGitHubCopilotCredentialStore(ctx, GITHUB_COPILOT_PREVIEW_PROVIDER_ID);
7027
7199
  let rejectedAuth;
@@ -7082,7 +7254,7 @@ function apply$1(ctx, config = {}) {
7082
7254
  });
7083
7255
  const displayProofFor = (snapshot) => source.readDisplaySnapshot() === snapshot && provenSnapshot === snapshot && snapshotProof?.accountKey === snapshot.accountKey ? snapshotProof : void 0;
7084
7256
  const proofFor = (snapshot) => source.readSnapshot() === snapshot && snapshotProof !== void 0 && snapshotProof.expires > Date.now() ? displayProofFor(snapshot) : void 0;
7085
- const lifetime = new PreviewLifetime(store, source, proofFor, displayProofFor);
7257
+ const lifetime = new PreviewLifetime(store, source, proofFor, displayProofFor, (modelId) => excludedModels().has(modelId));
7086
7258
  const template = resolvedProfile(createAccountProvider([], lifetime.guard(), "https://api.individual.githubcopilot.com").provider, requestConfig);
7087
7259
  let configured = false;
7088
7260
  let readError;
@@ -7268,14 +7440,25 @@ function apply$1(ctx, config = {}) {
7268
7440
  };
7269
7441
  const removeAutoRoute = installAutoModelRouting(ctx, {
7270
7442
  async loadModels(signal) {
7271
- return (await discoverSnapshot({ signal })).models;
7443
+ const excluded = excludedModels();
7444
+ return (await discoverSnapshot({ signal })).models.filter((model) => !excluded.has(model.id));
7272
7445
  },
7273
7446
  budgetPolicy: () => budgetSettings()
7274
7447
  });
7275
- 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
+ });
7276
7458
  installCopilotCompactionPressure(ctx, { resolve(request) {
7277
7459
  const snapshot = source.readSnapshot();
7278
7460
  if (snapshot === void 0 || proofFor(snapshot) === void 0) return void 0;
7461
+ if (excludedModels().has(request.model)) return void 0;
7279
7462
  const descriptor = snapshot.models.find((model) => model.id === request.model);
7280
7463
  if (descriptor === void 0) return void 0;
7281
7464
  const result = calculateRequestBudget(descriptor, request.maxTokens, resolveRequestBudgetPolicy(budgetSettings()));
@@ -7302,6 +7485,7 @@ function apply$1(ctx, config = {}) {
7302
7485
  return () => lifetime.isCurrent(revision) && (expires === void 0 || expires > Date.now()) && (snapshotProof === captured || snapshotProof === void 0 || snapshotProof.expires > Date.now());
7303
7486
  },
7304
7487
  routeFacts(modelId) {
7488
+ if (excludedModels().has(modelId)) return void 0;
7305
7489
  const snapshot = source.readSnapshot();
7306
7490
  const proof = snapshot === void 0 ? void 0 : proofFor(snapshot);
7307
7491
  const descriptor = snapshot?.models.find((model) => model.id === modelId);
@@ -7346,6 +7530,7 @@ function apply$1(ctx, config = {}) {
7346
7530
  ctx.effect(() => () => {
7347
7531
  lifetime.dispose();
7348
7532
  removeListener();
7533
+ removeSettings();
7349
7534
  removeAutoRoute();
7350
7535
  registration();
7351
7536
  });
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",
@@ -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'];
@@ -31,6 +31,8 @@ export interface InlineConfig {
31
31
  accountModelTtlMs?: number;
32
32
  /** Minimum delay after failed passive discovery; explicit Refresh bypasses it. */
33
33
  accountModelFailureCooldownMs?: number;
34
+ /** Exact account model IDs hidden from the managed directory and every Auto candidate pool. */
35
+ excludedModelIds?: string[];
34
36
  /** Estimated managed-route input headroom, separate from truthful catalog capacities. */
35
37
  requestBudgetSafetyTokens?: number;
36
38
  /** Fraction of admissible input used by eligible automatic-compaction requests. */
@@ -0,0 +1,7 @@
1
+ export declare const MAX_EXCLUDED_MODEL_IDS = 512;
2
+ export declare function normalizeExcludedModelIds(value: unknown): readonly string[];
3
+ export declare function excludedModelSet(value: unknown): ReadonlySet<string>;
4
+ export declare function filterExcludedModels<T extends {
5
+ readonly id: string;
6
+ }>(models: readonly T[], value: unknown): readonly T[];
7
+ //# sourceMappingURL=model-exclusions.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
2
+ import type { ReactElement } from 'react';
3
+ import type { GitHubCopilotAuthorizationView } from './authorization-controller.ts';
4
+ export declare function GitHubCopilotModelPreferencesPanel(props: {
5
+ readonly remote: ClientContext['remote']['githubCopilot'];
6
+ readonly models: GitHubCopilotAuthorizationView['accountModels'];
7
+ readonly preferences: GitHubCopilotAuthorizationView['modelPreferences'];
8
+ }): ReactElement;
9
+ //# sourceMappingURL=model-preferences-card.d.ts.map
@@ -7,7 +7,7 @@ import type { InlineConfig } from './config.ts';
7
7
  import type { RequestBudgetPolicy } from './request-budget.ts';
8
8
  /** Safe request knobs; identities, model tables, endpoints and credentials are not configurable. */
9
9
  export type PreviewRouteConfig = Pick<PiAiProviderProfile, 'reasoning' | 'cacheRetention' | 'transport' | 'timeoutMs' | 'websocketConnectTimeoutMs' | 'streamIdleTimeoutMs' | 'maxRequestImageBytes' | 'requestImagePixelBudget' | 'requestImageMaxBytes' | 'retryPolicy'> & Pick<InlineConfig, 'accountModelTtlMs' | 'accountModelFailureCooldownMs'> & {
10
- readonly accountModelSettings?: () => Pick<InlineConfig, 'accountModelTtlMs' | 'accountModelFailureCooldownMs'>;
10
+ readonly accountModelSettings?: () => Pick<InlineConfig, 'accountModelTtlMs' | 'accountModelFailureCooldownMs' | 'excludedModelIds'>;
11
11
  readonly requestBudget?: Partial<RequestBudgetPolicy>;
12
12
  readonly requestBudgetSettings?: () => Partial<RequestBudgetPolicy>;
13
13
  };
@@ -13,6 +13,8 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
13
13
  reconcile(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
14
14
  discoverModels(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
15
15
  ensureModels(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
16
+ excludeModel(modelId: string): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
17
+ restoreModel(modelId: string): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
16
18
  start(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
17
19
  cancel(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
18
20
  signOut(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
@@ -74,6 +76,23 @@ export declare const GitHubCopilotAuthorizationViewSchema: z.ZodObject<{
74
76
  discoveredAt: z.ZodOptional<z.ZodNumber>;
75
77
  error: z.ZodOptional<z.ZodString>;
76
78
  }, z.core.$strict>>;
79
+ modelPreferences: z.ZodOptional<z.ZodObject<{
80
+ state: z.ZodEnum<{
81
+ error: "error";
82
+ ready: "ready";
83
+ }>;
84
+ writable: z.ZodBoolean;
85
+ revision: z.ZodOptional<z.ZodNumber>;
86
+ excludedModelIds: z.ZodArray<z.ZodString>;
87
+ lockedModelIds: z.ZodArray<z.ZodString>;
88
+ unavailableExcludedModelIds: z.ZodArray<z.ZodString>;
89
+ error: z.ZodOptional<z.ZodEnum<{
90
+ COPILOT_MODEL_PREFERENCES_UNAVAILABLE: "COPILOT_MODEL_PREFERENCES_UNAVAILABLE";
91
+ COPILOT_MODEL_EXCLUSION_SELECTED: "COPILOT_MODEL_EXCLUSION_SELECTED";
92
+ COPILOT_MODEL_EXCLUSION_CONFLICT: "COPILOT_MODEL_EXCLUSION_CONFLICT";
93
+ COPILOT_MODEL_EXCLUSION_SAVE_FAILED: "COPILOT_MODEL_EXCLUSION_SAVE_FAILED";
94
+ }>>;
95
+ }, z.core.$strict>>;
77
96
  route: z.ZodOptional<z.ZodObject<{
78
97
  state: z.ZodEnum<{
79
98
  error: "error";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-github-copilot",
3
3
  "description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
4
- "version": "0.4.0-alpha.59",
4
+ "version": "0.4.0-alpha.60",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",