dsh-github-copilot 0.4.0-alpha.74 → 0.4.0-alpha.76

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
@@ -1700,7 +1700,7 @@ const usageSchema = z$1.object({
1700
1700
  totalTokens: count.optional(),
1701
1701
  reasoningTokens: count.optional()
1702
1702
  });
1703
- function record$4(value) {
1703
+ function record$5(value) {
1704
1704
  return typeof value === "object" && value !== null && !Array.isArray(value);
1705
1705
  }
1706
1706
  function sameRoute$1(left, right) {
@@ -1719,10 +1719,10 @@ function initialContextEvidence() {
1719
1719
  }
1720
1720
  /** Read only counts and routing leaves; never message content or opaque replay. */
1721
1721
  function foldContextEvidence(state, event) {
1722
- if (!record$4(event) || typeof event.type !== "string" || !record$4(event.data)) return state;
1722
+ if (!record$5(event) || typeof event.type !== "string" || !record$5(event.data)) return state;
1723
1723
  if (event.type === "request/header" || event.type === "model/selection") {
1724
- const raw = event.type === "request/header" ? record$4(event.data.header) ? event.data.header.config : void 0 : event.data;
1725
- if (!record$4(raw)) return {
1724
+ const raw = event.type === "request/header" ? record$5(event.data.header) ? event.data.header.config : void 0 : event.data;
1725
+ if (!record$5(raw)) return {
1726
1726
  ...state,
1727
1727
  route: null,
1728
1728
  sample: null,
@@ -1761,7 +1761,7 @@ function foldContextEvidence(state, event) {
1761
1761
  if (!copilot(state.route)) return state;
1762
1762
  if (event.type === "assistant/message" && event.data.source !== void 0) {
1763
1763
  const source = event.data.source;
1764
- const parsed = routeSchema.safeParse(record$4(source) ? {
1764
+ const parsed = routeSchema.safeParse(record$5(source) ? {
1765
1765
  provider: source.provider,
1766
1766
  model: source.model
1767
1767
  } : source);
@@ -1777,7 +1777,7 @@ function foldContextEvidence(state, event) {
1777
1777
  const settledUsage = usage !== void 0;
1778
1778
  let terminal;
1779
1779
  for (const entry of stream) {
1780
- if (!record$4(entry) || entry.type !== "chunk" || !record$4(entry.chunk)) continue;
1780
+ if (!record$5(entry) || entry.type !== "chunk" || !record$5(entry.chunk)) continue;
1781
1781
  if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
1782
1782
  if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
1783
1783
  }
@@ -1791,7 +1791,7 @@ function foldContextEvidence(state, event) {
1791
1791
  };
1792
1792
  const value = parsed.data;
1793
1793
  const zero = isZeroContextUsage(value);
1794
- const successful = record$4(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
1794
+ const successful = record$5(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
1795
1795
  if (zero && !successful) {
1796
1796
  const reason = state.sample !== null || state.reason === "none" ? "failed-zero" : state.reason;
1797
1797
  return {
@@ -1833,7 +1833,7 @@ const contextEvidenceDefinition = {
1833
1833
  function installContextEvidence(ctx) {
1834
1834
  ctx.inject(["sessionProjections"], (scope) => {
1835
1835
  const registry = scope.get("sessionProjections");
1836
- if (!record$4(registry) || typeof registry.register !== "function") {
1836
+ if (!record$5(registry) || typeof registry.register !== "function") {
1837
1837
  scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
1838
1838
  return;
1839
1839
  }
@@ -1847,7 +1847,7 @@ function installContextEvidence(ctx) {
1847
1847
  //#endregion
1848
1848
  //#region package.json
1849
1849
  var name$1 = "dsh-github-copilot";
1850
- var version = "0.4.0-alpha.74";
1850
+ var version = "0.4.0-alpha.76";
1851
1851
  //#endregion
1852
1852
  //#region lib/types/probe.js
1853
1853
  /**
@@ -2856,7 +2856,7 @@ function buildAnthropicWireBody(request, cfg, model) {
2856
2856
  }
2857
2857
  //#endregion
2858
2858
  //#region lib/types/responses-reasoning-text.js
2859
- function record$3(value) {
2859
+ function record$4(value) {
2860
2860
  return typeof value === "object" && value !== null;
2861
2861
  }
2862
2862
  function responseIndex(value) {
@@ -2914,13 +2914,13 @@ var ResponsesReasoningText = class {
2914
2914
  }
2915
2915
  /** Only recognized public text fields are examined; no copying of the item. */
2916
2916
  snapshot(item) {
2917
- if (!record$3(item) || item.type !== "reasoning") return "";
2917
+ if (!record$4(item) || item.type !== "reasoning") return "";
2918
2918
  let delta = "";
2919
2919
  for (const family of ["summary", "raw"]) {
2920
2920
  const value = family === "summary" ? item.summary : item.content;
2921
2921
  if (!Array.isArray(value)) continue;
2922
2922
  for (const [index, part] of value.entries()) {
2923
- if (!record$3(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
2923
+ if (!record$4(part) || part.type !== (family === "summary" ? "summary_text" : "reasoning_text")) continue;
2924
2924
  delta += this.update(family, index, part.text, true);
2925
2925
  }
2926
2926
  }
@@ -5300,6 +5300,56 @@ function coreProviderView(provider) {
5300
5300
  };
5301
5301
  }
5302
5302
  //#endregion
5303
+ //#region lib/types/response-error-body.js
5304
+ const maxErrorBytes = 8192;
5305
+ const errorReadTimeoutMs = 250;
5306
+ async function readError(reader) {
5307
+ const decoder = new TextDecoder("utf-8", { fatal: true });
5308
+ let bytes = 0, chunks = 0, text = "";
5309
+ while (true) {
5310
+ if (chunks++ > maxErrorBytes) return void 0;
5311
+ const chunk = await reader.read();
5312
+ if (chunk.done) break;
5313
+ bytes += chunk.value.byteLength;
5314
+ if (bytes > maxErrorBytes) return void 0;
5315
+ text += decoder.decode(chunk.value, { stream: true });
5316
+ }
5317
+ return JSON.parse(text + decoder.decode());
5318
+ }
5319
+ /** Optional classification evidence only; an unreadable clone leaves native handling unchanged. */
5320
+ async function readResponseErrorJson(response, signal) {
5321
+ if (signal?.aborted) return void 0;
5322
+ let reader;
5323
+ let timeout;
5324
+ let onAbort;
5325
+ try {
5326
+ const clone = response.clone();
5327
+ if (!clone.body) return void 0;
5328
+ reader = clone.body.getReader();
5329
+ const interrupted = new Promise((resolve) => {
5330
+ onAbort = () => resolve(void 0);
5331
+ signal?.addEventListener("abort", onAbort, { once: true });
5332
+ timeout = setTimeout(() => resolve(void 0), errorReadTimeoutMs);
5333
+ if (signal?.aborted) resolve(void 0);
5334
+ });
5335
+ const result = await Promise.race([readError(reader), interrupted]);
5336
+ return signal?.aborted ? void 0 : result;
5337
+ } catch {
5338
+ return;
5339
+ } finally {
5340
+ if (timeout !== void 0) clearTimeout(timeout);
5341
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
5342
+ if (reader) {
5343
+ try {
5344
+ reader.cancel().catch(() => {});
5345
+ } catch {}
5346
+ try {
5347
+ reader.releaseLock();
5348
+ } catch {}
5349
+ }
5350
+ }
5351
+ }
5352
+ //#endregion
5303
5353
  //#region lib/types/responses-replay-compat.js
5304
5354
  const replayDiagnostics = {
5305
5355
  "scope-mismatch": "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH: Copilot Responses input references belong to a different connection.",
@@ -5472,23 +5522,7 @@ var ResponsesRetryReplay = class {
5472
5522
  }
5473
5523
  };
5474
5524
  const scopeMessages = /* @__PURE__ */ new Set(["input item ID does not belong to this connection", "input item does not belong to this connection"]);
5475
- const maxErrorBytes = 8192;
5476
- const errorReadTimeoutMs = 250;
5477
- async function readScopeError(reader) {
5478
- const decoder = new TextDecoder("utf-8", { fatal: true });
5479
- let bytes = 0;
5480
- let chunks = 0;
5481
- let text = "";
5482
- while (true) {
5483
- if (chunks++ > maxErrorBytes) return false;
5484
- const chunk = await reader.read();
5485
- if (chunk.done) break;
5486
- bytes += chunk.value.byteLength;
5487
- if (bytes > maxErrorBytes) return false;
5488
- text += decoder.decode(chunk.value, { stream: true });
5489
- }
5490
- text += decoder.decode();
5491
- const body = JSON.parse(text);
5525
+ function isScopeError(body) {
5492
5526
  if (!isRecord$1(body)) return false;
5493
5527
  const error = Object.hasOwn(body, "error") ? body.error : body;
5494
5528
  if (!isRecord$1(error) || typeof error.message !== "string" || !scopeMessages.has(error.message)) return false;
@@ -5502,35 +5536,23 @@ async function readScopeError(reader) {
5502
5536
  /** Observe a cloned, bounded 401 body; every unknown result retains native auth behavior. */
5503
5537
  async function isCopilotInputItemScopeError(response, signal) {
5504
5538
  if (response.status !== 401 || signal?.aborted) return false;
5505
- let reader;
5506
- let timeout;
5507
- let onAbort;
5508
- try {
5509
- const clone = response.clone();
5510
- if (!clone.body) return false;
5511
- reader = clone.body.getReader();
5512
- const interrupted = new Promise((resolve) => {
5513
- onAbort = () => resolve(false);
5514
- signal?.addEventListener("abort", onAbort, { once: true });
5515
- timeout = setTimeout(() => resolve(false), errorReadTimeoutMs);
5516
- if (signal?.aborted) resolve(false);
5517
- });
5518
- const result = await Promise.race([readScopeError(reader), interrupted]);
5519
- return !signal?.aborted && result;
5520
- } catch {
5521
- return false;
5522
- } finally {
5523
- if (timeout !== void 0) clearTimeout(timeout);
5524
- if (onAbort) signal?.removeEventListener("abort", onAbort);
5525
- if (reader) {
5526
- try {
5527
- reader.cancel().catch(() => {});
5528
- } catch {}
5529
- try {
5530
- reader.releaseLock();
5531
- } catch {}
5532
- }
5533
- }
5539
+ const body = await readResponseErrorJson(response, signal);
5540
+ return !signal?.aborted && isScopeError(body);
5541
+ }
5542
+ //#endregion
5543
+ //#region lib/types/request-body-timeout.js
5544
+ const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
5545
+ function record$3(value) {
5546
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5547
+ }
5548
+ /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
5549
+ async function requestBodyTimeoutDiagnostic(response, body, signal) {
5550
+ if (response.status !== 408 || signal?.aborted) return void 0;
5551
+ const value = await readResponseErrorJson(response, signal);
5552
+ if (!record$3(value)) return void 0;
5553
+ const error = Object.hasOwn(value, "error") ? value.error : value;
5554
+ if (!record$3(error) || error.code !== "user_request_timeout" || error.message !== observedMessage || value.code !== void 0 && value.code !== error.code || value.message !== void 0 && value.message !== error.message) return void 0;
5555
+ return `COPILOT_REQUEST_BODY_TIMEOUT: Copilot returned HTTP 408 / user_request_timeout while reading the request body; this is not context-window overflow. ${body === void 0 ? "Request body size unavailable." : `Request body: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`} Native retry policy is unchanged. If retries exhaust, explicitly compact the conversation or reduce attachments/tool output before retrying; also check network/proxy health and GitHub service status. A larger client timeout does not change this server timeout. No history was trimmed or model switched.`;
5534
5556
  }
5535
5557
  //#endregion
5536
5558
  //#region lib/types/preview-provider.js
@@ -5748,6 +5770,7 @@ function createAccountProvider(descriptors, guard, baseURL) {
5748
5770
  } : options.onPayload;
5749
5771
  const fetch = options.fetch ?? globalThis.fetch;
5750
5772
  const observeResponse = async (input, init) => {
5773
+ guard.onRequestBodyTimeout?.(void 0);
5751
5774
  let response;
5752
5775
  try {
5753
5776
  response = await fetch(input, init);
@@ -5756,6 +5779,10 @@ function createAccountProvider(descriptors, guard, baseURL) {
5756
5779
  throw error;
5757
5780
  }
5758
5781
  retry?.observe(typeof init?.body === "string" ? init.body : void 0, response.status);
5782
+ if (response.status === 408 && guard.onRequestBodyTimeout !== void 0) {
5783
+ const diagnostic = await requestBodyTimeoutDiagnostic(response, typeof init?.body === "string" ? init.body : void 0, lease.signal);
5784
+ if (!lease.signal.aborted && !options.signal?.aborted) guard.onRequestBodyTimeout(diagnostic);
5785
+ }
5759
5786
  if (response.status === 401) {
5760
5787
  if (responses && await isCopilotInputItemScopeError(response, lease.signal)) reportReplayFailure(new CopilotResponsesReplayError("scope-mismatch"));
5761
5788
  else unauthorized = true;
@@ -7704,6 +7731,7 @@ var PreviewAdapter = class extends PiAiAdapter {
7704
7731
  }
7705
7732
  let requestFailure;
7706
7733
  let wireAbort;
7734
+ let bodyTimeout;
7707
7735
  const inspectRequest = (_model, context, nativeOptions) => {
7708
7736
  if (signal.aborted) throw abortFailure(signal);
7709
7737
  const imageFailure = imageInputFailure(lease.descriptor, context.messages);
@@ -7730,6 +7758,9 @@ var PreviewAdapter = class extends PiAiAdapter {
7730
7758
  onWireAbort(code) {
7731
7759
  wireAbort = code;
7732
7760
  },
7761
+ onRequestBodyTimeout(diagnostic) {
7762
+ bodyTimeout = diagnostic;
7763
+ },
7733
7764
  onReplayFailure(error) {
7734
7765
  if (!signal.aborted) requestFailure = new LlmError(error.message, "INVALID_REQUEST");
7735
7766
  }
@@ -7752,6 +7783,20 @@ var PreviewAdapter = class extends PiAiAdapter {
7752
7783
  throw failure(wireAbort, "ABORTED");
7753
7784
  }
7754
7785
  if (chunk.type === "finish" && chunk.reason.kind === "error" && chunk.reason.failure.code === "UNKNOWN_MODEL") await owner.refreshRejected(lease.snapshot, signal);
7786
+ if (chunk.type === "finish" && chunk.reason.kind === "error" && bodyTimeout !== void 0 && chunk.reason.failure.code !== "ABORTED") {
7787
+ if (signal.aborted) throw abortFailure(signal);
7788
+ yield {
7789
+ ...chunk,
7790
+ reason: {
7791
+ ...chunk.reason,
7792
+ failure: {
7793
+ ...chunk.reason.failure,
7794
+ message: bodyTimeout
7795
+ }
7796
+ }
7797
+ };
7798
+ continue;
7799
+ }
7755
7800
  yield chunk;
7756
7801
  }
7757
7802
  if (requestFailure !== void 0) throw requestFailure;
package/lib/remote.js CHANGED
@@ -225,10 +225,6 @@ const contribution$1 = {
225
225
  service: "githubCopilotTurnSelection",
226
226
  method: "get",
227
227
  invocation: { kind: "direct" },
228
- scope: {
229
- context: "agent",
230
- wire: "agentId"
231
- },
232
228
  parameters: [{
233
229
  name: "agent",
234
230
  wire: "agentId",
@@ -25,6 +25,8 @@ export interface PreviewProviderGuard {
25
25
  onReplayFailure?(error: CopilotResponsesReplayError): void;
26
26
  /** Preserve an owned abort cause before SDK terminal delivery and lease cleanup. */
27
27
  onWireAbort?(code: ManagedWireAbortCode): void;
28
+ /** Request-local safe guidance from a verified HTTP response; undefined clears prior evidence. */
29
+ onRequestBodyTimeout?(diagnostic: string | undefined): void;
28
30
  }
29
31
  /** Guard for one selected model in an account-bound descriptor snapshot. */
30
32
  export interface AccountProviderGuard extends PreviewProviderGuard {
@@ -0,0 +1,3 @@
1
+ /** Verified provider evidence, not guessed capabilities, token limits or network cause. */
2
+ export declare function requestBodyTimeoutDiagnostic(response: Response, body?: string, signal?: AbortSignal): Promise<string | undefined>;
3
+ //# sourceMappingURL=request-body-timeout.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** Optional classification evidence only; an unreadable clone leaves native handling unchanged. */
2
+ export declare function readResponseErrorJson(response: Response, signal?: AbortSignal): Promise<unknown>;
3
+ //# sourceMappingURL=response-error-body.d.ts.map
@@ -1,8 +1,10 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { TurnSelection } from './turn-selection.ts';
3
- export declare function TurnSelectionCard({ selection, locale, incomplete }: {
3
+ export declare function TurnSelectionCard({ selection, locale, incomplete, readState, retry }: {
4
4
  selection: TurnSelection;
5
5
  locale?: string;
6
6
  incomplete?: boolean;
7
+ readState?: 'loading' | 'ready' | 'failed';
8
+ retry?: () => void;
7
9
  }): ReactElement;
8
10
  //# sourceMappingURL=turn-selection-card.d.ts.map
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.74",
4
+ "version": "0.4.0-alpha.76",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/",