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

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.60";
1649
+ var version = "0.4.0-alpha.62";
1650
1650
  //#endregion
1651
1651
  //#region lib/types/probe.js
1652
1652
  /**
@@ -2067,8 +2067,10 @@ const WebSearchRoutingConfigSchema = z.object({
2067
2067
  */
2068
2068
  /** Keep native live references at the boundary; request code consumes plain snapshots. */
2069
2069
  function readInlineConfig(config) {
2070
+ const exclusions = readConfigValue(config.excludedModelIds);
2070
2071
  return {
2071
2072
  ...config,
2073
+ excludedModelIds: exclusions === void 0 ? void 0 : Array.from(exclusions),
2072
2074
  searchModel: readConfigValue(config.searchModel),
2073
2075
  searchRouting: readConfigValue(config.searchRouting),
2074
2076
  temporaryRouteBackup: readConfigValue(config.temporaryRouteBackup)
@@ -2087,7 +2089,7 @@ const Config = z.object({
2087
2089
  probeTimeoutMs: z.number().step(1).min(1).max(MAX_TIMEOUT_MS).default(3e4),
2088
2090
  accountModelTtlMs: z.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(864e5),
2089
2091
  accountModelFailureCooldownMs: z.number().step(1).min(0).max(MAX_TIMEOUT_MS).default(3e5),
2090
- excludedModelIds: z.array(z.string()).default([]).hidden(),
2092
+ excludedModelIds: z.array(z.string()).default([]).hidden().volatile(),
2091
2093
  requestBudgetSafetyTokens: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(DEFAULT_REQUEST_BUDGET_POLICY.safetyTokens),
2092
2094
  requestBudgetPressureRatio: z.number().step(.01).min(.01).max(1).default(DEFAULT_REQUEST_BUDGET_POLICY.pressureRatio),
2093
2095
  compactionReasoning: z.union(["prefer-low", "preserve"]).default(DEFAULT_REQUEST_BUDGET_POLICY.compactionReasoning),
@@ -4426,25 +4428,44 @@ function selectedFixedModelIds(ctx) {
4426
4428
  }
4427
4429
  }
4428
4430
  function modelPreferencesView(ctx, accountModels, error) {
4431
+ const unavailable = (diagnostic) => ({
4432
+ state: "error",
4433
+ writable: false,
4434
+ excludedModelIds: [],
4435
+ lockedModelIds: [],
4436
+ unavailableExcludedModelIds: [],
4437
+ error: diagnostic
4438
+ });
4439
+ let settings;
4440
+ let descriptor;
4429
4441
  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
- };
4442
+ settings = service(ctx, "settings", ["describe", "mutate"]);
4443
+ descriptor = settings.describe({ redactSecrets: true }).find((item) => item.ns === GITHUB_COPILOT_SETTINGS_NAMESPACE$1);
4445
4444
  } catch {
4446
- return;
4445
+ return unavailable("COPILOT_MODEL_SETTINGS_UNAVAILABLE");
4447
4446
  }
4447
+ if (descriptor === void 0) return unavailable("COPILOT_MODEL_SETTINGS_UNAVAILABLE");
4448
+ if (!Number.isSafeInteger(descriptor.revision) || descriptor.revision < 0) return unavailable("COPILOT_MODEL_SETTINGS_INVALID");
4449
+ let excludedModelIds;
4450
+ try {
4451
+ const raw = object$3(descriptor.value);
4452
+ if (raw === void 0) return unavailable("COPILOT_MODEL_SETTINGS_INVALID");
4453
+ excludedModelIds = normalizeExcludedModelIds(raw.excludedModelIds);
4454
+ } catch {
4455
+ return unavailable("COPILOT_MODEL_SETTINGS_INVALID");
4456
+ }
4457
+ const lockedModelIds = selectedFixedModelIds(ctx);
4458
+ const diagnostic = lockedModelIds === void 0 ? "COPILOT_MODEL_SELECTION_UNAVAILABLE" : error;
4459
+ const available = new Set(accountModels?.models.map((model) => model.id) ?? []);
4460
+ return {
4461
+ state: diagnostic === void 0 ? "ready" : "error",
4462
+ writable: lockedModelIds !== void 0,
4463
+ revision: descriptor.revision,
4464
+ excludedModelIds,
4465
+ lockedModelIds: lockedModelIds ?? [],
4466
+ unavailableExcludedModelIds: excludedModelIds.filter((id) => !available.has(id)),
4467
+ ...diagnostic === void 0 ? {} : { error: diagnostic }
4468
+ };
4448
4469
  }
4449
4470
  function validateGrant(record) {
4450
4471
  if (record.kind !== "grant") throw new Error("github-copilot: the configured credential is not an OAuth grant");
@@ -4932,7 +4953,7 @@ let GitHubCopilotAuthorizationController = (() => {
4932
4953
  return this.status();
4933
4954
  }
4934
4955
  const current = modelPreferencesView(this.ctx, accountModelsView(this.ctx));
4935
- if (current === void 0 || current.revision === void 0) {
4956
+ if (!current.writable || current.revision === void 0) {
4936
4957
  this.modelPreferenceFailure = "COPILOT_MODEL_PREFERENCES_UNAVAILABLE";
4937
4958
  return this.status();
4938
4959
  }
@@ -5207,6 +5228,112 @@ function normalizeCopilotResponsesPayload(payload) {
5207
5228
  throw new CopilotResponsesReplayError("invalid-payload");
5208
5229
  }
5209
5230
  }
5231
+ const retryLifetimeMs = 6e4;
5232
+ const maxRetryBytes = 2097152;
5233
+ function cacheBytes(value) {
5234
+ let json;
5235
+ try {
5236
+ json = JSON.stringify(value);
5237
+ } catch {
5238
+ return;
5239
+ }
5240
+ if (json === void 0 || Buffer.byteLength(json, "utf8") > maxRetryBytes) return void 0;
5241
+ return json;
5242
+ }
5243
+ /** A single lease can admit one HTTP-verified retry at a time; it never reads durable history. */
5244
+ var ResponsesRetryReplay = class {
5245
+ snapshot;
5246
+ active = 0;
5247
+ disposed = false;
5248
+ dispose() {
5249
+ this.disposed = true;
5250
+ this.snapshot = void 0;
5251
+ }
5252
+ belongsTo(sessionId) {
5253
+ return this.snapshot?.sessionId === sessionId;
5254
+ }
5255
+ begin(context, signal, sessionId, modelId) {
5256
+ const contextBytes = cacheBytes(context);
5257
+ const overlapping = this.active++ !== 0;
5258
+ if (overlapping) this.snapshot = void 0;
5259
+ const previous = this.snapshot;
5260
+ if (previous !== void 0 && (signal !== previous.signal || signal?.aborted || previous.sessionId !== sessionId || previous.modelId !== modelId || previous.context !== contextBytes || Date.now() - previous.at >= retryLifetimeMs)) this.snapshot = void 0;
5261
+ const eligible = contextBytes !== void 0 && !overlapping && !this.disposed && !signal?.aborted && this.snapshot;
5262
+ let candidate;
5263
+ let payloadBytes;
5264
+ let finished = false;
5265
+ let observed = false;
5266
+ return {
5267
+ normalize: (payload) => {
5268
+ if (this.disposed || signal?.aborted) throw new CopilotResponsesReplayError();
5269
+ const rawBytes = cacheBytes(payload);
5270
+ let normalized;
5271
+ let reused = false;
5272
+ try {
5273
+ normalized = normalizeCopilotResponsesPayload(payload);
5274
+ } catch (error) {
5275
+ if (!(error instanceof CopilotResponsesReplayError) || !eligible || !isRecord$1(payload) || !Array.isArray(payload.input) || !isRecord$1(eligible.raw) || !Array.isArray(eligible.raw.input)) {
5276
+ this.snapshot = void 0;
5277
+ throw error;
5278
+ }
5279
+ try {
5280
+ const prior = eligible.raw.input;
5281
+ if (payload.input.length !== prior.length) throw error;
5282
+ let references = 0;
5283
+ const restored = payload.input.map((item, index) => {
5284
+ if (!isRecord$1(item) || !Object.hasOwn(item, "id")) return item;
5285
+ const original = prior[index];
5286
+ if (!isRecord$1(original) || !nonemptyString(item.id) || original.id !== item.id || ![
5287
+ "reasoning",
5288
+ "message",
5289
+ "function_call"
5290
+ ].includes(String(original.type)) || normalizeItem(original) === original) throw error;
5291
+ if (item.type === "item_reference") {
5292
+ if (Object.keys(item).length !== 2) throw error;
5293
+ } else if (item.type !== original.type || Object.keys(item).length >= Object.keys(original).length || Object.entries(item).some(([key, value]) => !Object.hasOwn(original, key) || cacheBytes(value) !== cacheBytes(original[key]))) throw error;
5294
+ references++;
5295
+ return original;
5296
+ });
5297
+ if (references === 0 || cacheBytes({
5298
+ ...payload,
5299
+ input: restored
5300
+ }) !== cacheBytes(eligible.raw)) throw error;
5301
+ } catch {
5302
+ this.snapshot = void 0;
5303
+ throw error;
5304
+ }
5305
+ normalized = JSON.parse(eligible.normalized);
5306
+ reused = true;
5307
+ }
5308
+ payloadBytes = cacheBytes(normalized);
5309
+ candidate = signal === void 0 || !sessionId || !modelId || contextBytes === void 0 || rawBytes === void 0 || payloadBytes === void 0 ? void 0 : {
5310
+ raw: JSON.parse(rawBytes),
5311
+ normalized: payloadBytes,
5312
+ context: contextBytes,
5313
+ signal,
5314
+ sessionId,
5315
+ modelId,
5316
+ at: Date.now()
5317
+ };
5318
+ if (reused && eligible) candidate = {
5319
+ ...eligible,
5320
+ at: Date.now()
5321
+ };
5322
+ return normalized;
5323
+ },
5324
+ observe: (body, status) => {
5325
+ observed = true;
5326
+ this.snapshot = !this.disposed && !signal?.aborted && this.active === 1 && !overlapping && status === 408 && candidate !== void 0 && body === payloadBytes ? candidate : void 0;
5327
+ },
5328
+ finish: () => {
5329
+ if (finished) return;
5330
+ finished = true;
5331
+ this.active--;
5332
+ if (!observed || signal?.aborted || this.disposed || overlapping) this.snapshot = void 0;
5333
+ }
5334
+ };
5335
+ }
5336
+ };
5210
5337
  const scopeMessages = /* @__PURE__ */ new Set(["input item ID does not belong to this connection", "input item does not belong to this connection"]);
5211
5338
  const maxErrorBytes = 8192;
5212
5339
  const errorReadTimeoutMs = 250;
@@ -5458,6 +5585,13 @@ function createAccountProvider(descriptors, guard, baseURL) {
5458
5585
  headers["x-api-key"] = null;
5459
5586
  let unauthorized = false;
5460
5587
  const responses = model.api === "openai-responses";
5588
+ let retry;
5589
+ try {
5590
+ retry = responses ? guard.retryReplay?.begin(context, guard.retrySignal, options?.sessionId, model.id) : void 0;
5591
+ } catch (error) {
5592
+ lease.release();
5593
+ throw error;
5594
+ }
5461
5595
  const reportReplayFailure = (error) => {
5462
5596
  if (lease.signal.aborted || options.signal?.aborted) return;
5463
5597
  try {
@@ -5468,7 +5602,8 @@ function createAccountProvider(descriptors, guard, baseURL) {
5468
5602
  const replacement = await options.onPayload?.(payload, selectedModel);
5469
5603
  if (lease.signal.aborted || options.signal?.aborted) throw new Error("COPILOT_MANAGED_ABORTED");
5470
5604
  try {
5471
- return normalizeCopilotResponsesPayload(replacement === void 0 ? payload : replacement);
5605
+ const effective = replacement === void 0 ? payload : replacement;
5606
+ return retry === void 0 ? normalizeCopilotResponsesPayload(effective) : retry.normalize(effective);
5472
5607
  } catch (error) {
5473
5608
  if (error instanceof CopilotResponsesReplayError) reportReplayFailure(error);
5474
5609
  throw error;
@@ -5476,7 +5611,14 @@ function createAccountProvider(descriptors, guard, baseURL) {
5476
5611
  } : options.onPayload;
5477
5612
  const fetch = options.fetch ?? globalThis.fetch;
5478
5613
  const observeResponse = async (input, init) => {
5479
- const response = await fetch(input, init);
5614
+ let response;
5615
+ try {
5616
+ response = await fetch(input, init);
5617
+ } catch (error) {
5618
+ retry?.observe(void 0, 0);
5619
+ throw error;
5620
+ }
5621
+ retry?.observe(typeof init?.body === "string" ? init.body : void 0, response.status);
5480
5622
  if (response.status === 401) {
5481
5623
  if (responses && await isCopilotInputItemScopeError(response, lease.signal)) reportReplayFailure(new CopilotResponsesReplayError("scope-mismatch"));
5482
5624
  else unauthorized = true;
@@ -5497,6 +5639,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
5497
5639
  onPayload
5498
5640
  };
5499
5641
  if (!hasApi(model, "openai-responses") && !hasApi(model, "openai-completions") && !hasApi(model, "anthropic-messages")) {
5642
+ retry?.finish();
5500
5643
  lease.release();
5501
5644
  throw new Error("COPILOT_MANAGED_PROTOCOL_UNSUPPORTED");
5502
5645
  }
@@ -5507,6 +5650,8 @@ function createAccountProvider(descriptors, guard, baseURL) {
5507
5650
  yield event;
5508
5651
  }
5509
5652
  } finally {
5653
+ if (lease.signal.aborted || options.signal?.aborted) retry?.observe(void 0, 0);
5654
+ retry?.finish();
5510
5655
  lease.release();
5511
5656
  if (unauthorized && !guard.signal.aborted && !options.signal?.aborted) try {
5512
5657
  guard.onUnauthorized?.();
@@ -6814,6 +6959,7 @@ var PreviewLifetime = class {
6814
6959
  excluded;
6815
6960
  controller = new AbortController();
6816
6961
  wires = /* @__PURE__ */ new Set();
6962
+ retryEntries = /* @__PURE__ */ new Map();
6817
6963
  revision = 0;
6818
6964
  active = true;
6819
6965
  constructor(credentials, source, proofFor, displayProofFor, excluded) {
@@ -6829,15 +6975,52 @@ var PreviewLifetime = class {
6829
6975
  isCurrent(revision) {
6830
6976
  return this.active && revision === this.revision;
6831
6977
  }
6978
+ removeRetry(signal) {
6979
+ const entry = this.retryEntries.get(signal);
6980
+ if (entry === void 0) return;
6981
+ signal.removeEventListener("abort", entry.onAbort);
6982
+ entry.replay.dispose();
6983
+ this.retryEntries.delete(signal);
6984
+ }
6985
+ clearRetries() {
6986
+ for (const signal of this.retryEntries.keys()) this.removeRetry(signal);
6987
+ }
6988
+ clearSessionRetries(sessionId) {
6989
+ for (const [signal, entry] of this.retryEntries) if (entry.replay.belongsTo(sessionId)) this.removeRetry(signal);
6990
+ }
6991
+ retryFor(signal, snapshot, proof, model) {
6992
+ let entry = this.retryEntries.get(signal);
6993
+ if (entry !== void 0 && (entry.snapshot !== snapshot || entry.proof !== proof || entry.model !== model || entry.revision !== this.revision || Date.now() - entry.at >= 6e4)) {
6994
+ this.removeRetry(signal);
6995
+ entry = void 0;
6996
+ }
6997
+ if (entry !== void 0) return entry.replay;
6998
+ if (this.retryEntries.size >= 16) this.removeRetry(this.retryEntries.keys().next().value);
6999
+ const replay = new ResponsesRetryReplay();
7000
+ const onAbort = () => this.removeRetry(signal);
7001
+ signal.addEventListener("abort", onAbort, { once: true });
7002
+ this.retryEntries.set(signal, {
7003
+ replay,
7004
+ snapshot,
7005
+ proof,
7006
+ model,
7007
+ revision: this.revision,
7008
+ at: Date.now(),
7009
+ onAbort
7010
+ });
7011
+ return replay;
7012
+ }
6832
7013
  change() {
6833
7014
  this.assertActive();
6834
7015
  this.revision++;
7016
+ this.clearRetries();
6835
7017
  this.source.invalidate();
6836
7018
  for (const wire of this.wires) wire.abort(new ManagedWireAbortError("COPILOT_PREVIEW_CREDENTIAL_CHANGED"));
6837
7019
  }
6838
7020
  dispose() {
6839
7021
  if (!this.active) return;
6840
7022
  this.active = false;
7023
+ this.clearRetries();
6841
7024
  this.source.dispose();
6842
7025
  this.controller.abort(new ManagedWireAbortError("COPILOT_PREVIEW_DISPOSED"));
6843
7026
  for (const wire of this.wires) wire.abort();
@@ -6900,6 +7083,11 @@ var PreviewLifetime = class {
6900
7083
  started: false
6901
7084
  };
6902
7085
  this.entitled(lease, grant, model);
7086
+ if (signal !== void 0 && !signal.aborted) return {
7087
+ ...lease,
7088
+ retrySignal: signal,
7089
+ retryReplay: this.retryFor(signal, snapshot, proof, model)
7090
+ };
6903
7091
  return lease;
6904
7092
  }
6905
7093
  account(lease, grant) {
@@ -6925,7 +7113,11 @@ var PreviewLifetime = class {
6925
7113
  guard(lease) {
6926
7114
  return {
6927
7115
  signal: lease?.signal ?? this.controller.signal,
6928
- ...lease === void 0 ? {} : { selectedModelId: lease.descriptor.id },
7116
+ ...lease === void 0 ? {} : {
7117
+ selectedModelId: lease.descriptor.id,
7118
+ retryReplay: lease.retryReplay,
7119
+ retrySignal: lease.retrySignal
7120
+ },
6929
7121
  assertActive: () => this.assertActive(),
6930
7122
  assertAccount: (grant) => this.account(lease, grant),
6931
7123
  assertEntitled: (grant, model) => this.entitled(lease, grant, model),
@@ -7255,6 +7447,9 @@ function apply$1(ctx, config = {}) {
7255
7447
  const displayProofFor = (snapshot) => source.readDisplaySnapshot() === snapshot && provenSnapshot === snapshot && snapshotProof?.accountKey === snapshot.accountKey ? snapshotProof : void 0;
7256
7448
  const proofFor = (snapshot) => source.readSnapshot() === snapshot && snapshotProof !== void 0 && snapshotProof.expires > Date.now() ? displayProofFor(snapshot) : void 0;
7257
7449
  const lifetime = new PreviewLifetime(store, source, proofFor, displayProofFor, (modelId) => excludedModels().has(modelId));
7450
+ const removeStepListener = ctx.on("session/event", (session, event) => {
7451
+ if (event.type === "step/start" || event.type === "turn/end") lifetime.clearSessionRetries(session.id);
7452
+ });
7258
7453
  const template = resolvedProfile(createAccountProvider([], lifetime.guard(), "https://api.individual.githubcopilot.com").provider, requestConfig);
7259
7454
  let configured = false;
7260
7455
  let readError;
@@ -7529,6 +7724,7 @@ function apply$1(ctx, config = {}) {
7529
7724
  });
7530
7725
  ctx.effect(() => () => {
7531
7726
  lifetime.dispose();
7727
+ removeStepListener();
7532
7728
  removeListener();
7533
7729
  removeSettings();
7534
7730
  removeAutoRoute();
package/lib/remote.js CHANGED
@@ -314,6 +314,9 @@ const GitHubCopilotAuthorizationViewSchema = z.object({
314
314
  unavailableExcludedModelIds: z.array(z.string().min(1).max(512)).max(512),
315
315
  error: z.enum([
316
316
  "COPILOT_MODEL_PREFERENCES_UNAVAILABLE",
317
+ "COPILOT_MODEL_SETTINGS_UNAVAILABLE",
318
+ "COPILOT_MODEL_SETTINGS_INVALID",
319
+ "COPILOT_MODEL_SELECTION_UNAVAILABLE",
317
320
  "COPILOT_MODEL_EXCLUSION_SELECTED",
318
321
  "COPILOT_MODEL_EXCLUSION_CONFLICT",
319
322
  "COPILOT_MODEL_EXCLUSION_SAVE_FAILED"
@@ -58,7 +58,7 @@ export interface GitHubCopilotModelPreferencesView {
58
58
  readonly excludedModelIds: readonly string[];
59
59
  readonly lockedModelIds: readonly string[];
60
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';
61
+ readonly error?: 'COPILOT_MODEL_PREFERENCES_UNAVAILABLE' | 'COPILOT_MODEL_EXCLUSION_SELECTED' | 'COPILOT_MODEL_EXCLUSION_CONFLICT' | 'COPILOT_MODEL_EXCLUSION_SAVE_FAILED' | 'COPILOT_MODEL_SETTINGS_UNAVAILABLE' | 'COPILOT_MODEL_SETTINGS_INVALID' | 'COPILOT_MODEL_SELECTION_UNAVAILABLE';
62
62
  }
63
63
  export interface GitHubCopilotAuthorizationView {
64
64
  readonly phase: GitHubCopilotAuthorizationPhase;
@@ -50,12 +50,14 @@ export interface InlineConfig {
50
50
  /** Internal JSON backup of route leaves temporarily owned by the GPT-6 overlay. */
51
51
  temporaryRouteBackup?: string;
52
52
  }
53
- export type LiveInlineConfig = Omit<InlineConfig, 'searchModel' | 'searchRouting' | 'temporaryRouteBackup'> & {
53
+ export type LiveInlineConfig = Omit<InlineConfig, 'searchModel' | 'searchRouting' | 'temporaryRouteBackup' | 'excludedModelIds'> & {
54
+ excludedModelIds?: string[] | LiveSetting<ArrayLike<string>>;
54
55
  searchModel?: string | LiveSetting<string | undefined>;
55
56
  searchRouting?: WebSearchRoutingConfig | LiveSetting<WebSearchRoutingConfig | undefined>;
56
57
  temporaryRouteBackup?: string | LiveSetting<string | undefined>;
57
58
  };
58
- export type ResolvedInlineConfig = Omit<InlineConfig, 'searchModel' | 'searchRouting' | 'temporaryRouteBackup'> & {
59
+ export type ResolvedInlineConfig = Omit<InlineConfig, 'searchModel' | 'searchRouting' | 'temporaryRouteBackup' | 'excludedModelIds'> & {
60
+ excludedModelIds: LiveSetting<ArrayLike<string>>;
59
61
  searchModel: LiveSetting<string | undefined>;
60
62
  searchRouting: LiveSetting<WebSearchRoutingConfig>;
61
63
  temporaryRouteBackup: LiveSetting<string | undefined>;
@@ -3,6 +3,7 @@ import type { AccountModelApi, AccountModelDescriptor } from './account-model-ca
3
3
  import type { CoreCompatibleProvider } from './pi-provider-bridge.ts';
4
4
  import type { GitHubCopilotOAuthCredential } from './copilot-grant.ts';
5
5
  import { CopilotResponsesReplayError } from './responses-replay-compat.ts';
6
+ import type { ResponsesRetryReplay } from './responses-replay-compat.ts';
6
7
  export type ManagedWireAbortCode = 'COPILOT_PREVIEW_CREDENTIAL_CHANGED' | 'COPILOT_PREVIEW_DISPOSED';
7
8
  /** Identity, not upstream error text, proves that the plugin revoked this wire. */
8
9
  export declare class ManagedWireAbortError extends Error {
@@ -28,6 +29,8 @@ export interface PreviewProviderGuard {
28
29
  /** Guard for one selected model in an account-bound descriptor snapshot. */
29
30
  export interface AccountProviderGuard extends PreviewProviderGuard {
30
31
  readonly selectedModelId?: string;
32
+ readonly retryReplay?: ResponsesRetryReplay;
33
+ readonly retrySignal?: AbortSignal;
31
34
  /** Per-dispatch admission after native context conversion, before starting a model wire. */
32
35
  inspectRequest?(model: Model<Api>, context: TranscriptContext, options?: StreamOptions): void;
33
36
  assertEntitled(credential: GitHubCopilotOAuthCredential, modelId: string): void;
@@ -91,6 +91,9 @@ export declare const GitHubCopilotAuthorizationViewSchema: z.ZodObject<{
91
91
  COPILOT_MODEL_EXCLUSION_SELECTED: "COPILOT_MODEL_EXCLUSION_SELECTED";
92
92
  COPILOT_MODEL_EXCLUSION_CONFLICT: "COPILOT_MODEL_EXCLUSION_CONFLICT";
93
93
  COPILOT_MODEL_EXCLUSION_SAVE_FAILED: "COPILOT_MODEL_EXCLUSION_SAVE_FAILED";
94
+ COPILOT_MODEL_SETTINGS_UNAVAILABLE: "COPILOT_MODEL_SETTINGS_UNAVAILABLE";
95
+ COPILOT_MODEL_SETTINGS_INVALID: "COPILOT_MODEL_SETTINGS_INVALID";
96
+ COPILOT_MODEL_SELECTION_UNAVAILABLE: "COPILOT_MODEL_SELECTION_UNAVAILABLE";
94
97
  }>>;
95
98
  }, z.core.$strict>>;
96
99
  route: z.ZodOptional<z.ZodObject<{
@@ -5,6 +5,20 @@ export declare class CopilotResponsesReplayError extends Error {
5
5
  }
6
6
  /** Normalize only the outgoing managed Responses payload, never stored history/context. */
7
7
  export declare function normalizeCopilotResponsesPayload(payload: unknown): unknown;
8
+ /** A single lease can admit one HTTP-verified retry at a time; it never reads durable history. */
9
+ export declare class ResponsesRetryReplay {
10
+ private snapshot;
11
+ private active;
12
+ private disposed;
13
+ dispose(): void;
14
+ belongsTo(sessionId: string): boolean;
15
+ begin(context: unknown, signal?: AbortSignal, sessionId?: string, modelId?: string): ResponsesRetryAttempt;
16
+ }
17
+ export interface ResponsesRetryAttempt {
18
+ normalize(payload: unknown): unknown;
19
+ observe(body: string | undefined, status: number): void;
20
+ finish(): void;
21
+ }
8
22
  /** Observe a cloned, bounded 401 body; every unknown result retains native auth behavior. */
9
23
  export declare function isCopilotInputItemScopeError(response: Response, signal?: AbortSignal): Promise<boolean>;
10
24
  export {};
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.60",
4
+ "version": "0.4.0-alpha.62",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",